]>
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 | |
340 | -Wc11-c2x-compat | |
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 | |
451 | -fdump-analyzer-json | |
452 | -fdump-analyzer-state-purge | |
453 | -fdump-analyzer-stderr | |
454 | -fdump-analyzer-supergraph | |
455 | -fdump-analyzer-untracked | |
456 | -Wno-analyzer-double-fclose | |
457 | -Wno-analyzer-double-free | |
458 | -Wno-analyzer-exposure-through-output-file | |
459 | -Wno-analyzer-exposure-through-uninit-copy | |
460 | -Wno-analyzer-fd-access-mode-mismatch | |
461 | -Wno-analyzer-fd-double-close | |
462 | -Wno-analyzer-fd-leak | |
463 | -Wno-analyzer-fd-phase-mismatch | |
464 | -Wno-analyzer-fd-type-mismatch | |
465 | -Wno-analyzer-fd-use-after-close | |
466 | -Wno-analyzer-fd-use-without-check | |
467 | -Wno-analyzer-file-leak | |
468 | -Wno-analyzer-free-of-non-heap | |
469 | -Wno-analyzer-imprecise-fp-arithmetic | |
470 | -Wno-analyzer-infinite-recursion | |
471 | -Wno-analyzer-jump-through-null | |
472 | -Wno-analyzer-malloc-leak | |
473 | -Wno-analyzer-mismatching-deallocation | |
474 | -Wno-analyzer-null-argument | |
475 | -Wno-analyzer-null-dereference | |
476 | -Wno-analyzer-out-of-bounds | |
034d99e8 | 477 | -Wno-analyzer-overlapping-buffers |
43b72ede AA |
478 | -Wno-analyzer-possible-null-argument |
479 | -Wno-analyzer-possible-null-dereference | |
480 | -Wno-analyzer-putenv-of-auto-var | |
481 | -Wno-analyzer-shift-count-negative | |
482 | -Wno-analyzer-shift-count-overflow | |
483 | -Wno-analyzer-stale-setjmp-buffer | |
484 | -Wno-analyzer-tainted-allocation-size | |
485 | -Wno-analyzer-tainted-assertion | |
486 | -Wno-analyzer-tainted-array-index | |
487 | -Wno-analyzer-tainted-divisor | |
488 | -Wno-analyzer-tainted-offset | |
489 | -Wno-analyzer-tainted-size | |
490 | -Wanalyzer-too-complex | |
491 | -Wno-analyzer-unsafe-call-within-signal-handler | |
492 | -Wno-analyzer-use-after-free | |
493 | -Wno-analyzer-use-of-pointer-in-stale-stack-frame | |
494 | -Wno-analyzer-use-of-uninitialized-value | |
495 | -Wno-analyzer-va-arg-type-mismatch | |
496 | -Wno-analyzer-va-list-exhausted | |
497 | -Wno-analyzer-va-list-leak | |
498 | -Wno-analyzer-va-list-use-after-va-end | |
499 | -Wno-analyzer-write-to-const | |
500 | -Wno-analyzer-write-to-string-literal | |
d77de738 ML |
501 | } |
502 | ||
503 | @item C and Objective-C-only Warning Options | |
43b72ede | 504 | @gccoptlist{-Wbad-function-cast -Wmissing-declarations |
ffc74822 HM |
505 | -Wmissing-parameter-type -Wmissing-prototypes -Wmissing-variable-declarations |
506 | -Wnested-externs -Wold-style-declaration -Wold-style-definition | |
43b72ede | 507 | -Wstrict-prototypes -Wtraditional -Wtraditional-conversion |
d77de738 ML |
508 | -Wdeclaration-after-statement -Wpointer-sign} |
509 | ||
510 | @item Debugging Options | |
511 | @xref{Debugging Options,,Options for Debugging Your Program}. | |
43b72ede AA |
512 | @gccoptlist{-g -g@var{level} -gdwarf -gdwarf-@var{version} |
513 | -gbtf -gctf -gctf@var{level} | |
514 | -ggdb -grecord-gcc-switches -gno-record-gcc-switches | |
515 | -gstrict-dwarf -gno-strict-dwarf | |
516 | -gas-loc-support -gno-as-loc-support | |
517 | -gas-locview-support -gno-as-locview-support | |
3eeb4801 | 518 | -gcodeview |
43b72ede AA |
519 | -gcolumn-info -gno-column-info -gdwarf32 -gdwarf64 |
520 | -gstatement-frontiers -gno-statement-frontiers | |
521 | -gvariable-location-views -gno-variable-location-views | |
522 | -ginternal-reset-location-views -gno-internal-reset-location-views | |
523 | -ginline-points -gno-inline-points | |
524 | -gvms -gz@r{[}=@var{type}@r{]} | |
525 | -gsplit-dwarf -gdescribe-dies -gno-describe-dies | |
526 | -fdebug-prefix-map=@var{old}=@var{new} -fdebug-types-section | |
527 | -fno-eliminate-unused-debug-types | |
528 | -femit-struct-debug-baseonly -femit-struct-debug-reduced | |
529 | -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]} | |
530 | -fno-eliminate-unused-debug-symbols -femit-class-debug-always | |
531 | -fno-merge-debug-strings -fno-dwarf2-cfi-asm | |
d77de738 ML |
532 | -fvar-tracking -fvar-tracking-assignments} |
533 | ||
534 | @item Optimization Options | |
535 | @xref{Optimize Options,,Options that Control Optimization}. | |
43b72ede AA |
536 | @gccoptlist{-faggressive-loop-optimizations |
537 | -falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] | |
538 | -falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] | |
539 | -falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] | |
540 | -falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] | |
541 | -fno-allocation-dce -fallow-store-data-races | |
542 | -fassociative-math -fauto-profile -fauto-profile[=@var{path}] | |
543 | -fauto-inc-dec -fbranch-probabilities | |
544 | -fcaller-saves | |
545 | -fcombine-stack-adjustments -fconserve-stack | |
04c9cf5c | 546 | -ffold-mem-offsets |
43b72ede AA |
547 | -fcompare-elim -fcprop-registers -fcrossjumping |
548 | -fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules | |
549 | -fcx-limited-range | |
550 | -fdata-sections -fdce -fdelayed-branch | |
551 | -fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively | |
552 | -fdevirtualize-at-ltrans -fdse | |
553 | -fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects | |
554 | -ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style} | |
555 | -ffinite-loops | |
556 | -fforward-propagate -ffp-contract=@var{style} -ffunction-sections | |
557 | -fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity | |
558 | -fgcse-sm -fhoist-adjacent-loads -fif-conversion | |
559 | -fif-conversion2 -findirect-inlining | |
560 | -finline-functions -finline-functions-called-once -finline-limit=@var{n} | |
561 | -finline-small-functions -fipa-modref -fipa-cp -fipa-cp-clone | |
562 | -fipa-bit-cp -fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const | |
563 | -fipa-reference -fipa-reference-addressable | |
564 | -fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm} | |
565 | -flive-patching=@var{level} | |
566 | -fira-region=@var{region} -fira-hoist-pressure | |
567 | -fira-loop-pressure -fno-ira-share-save-slots | |
568 | -fno-ira-share-spill-slots | |
569 | -fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute | |
570 | -fivopts -fkeep-inline-functions -fkeep-static-functions | |
571 | -fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage | |
572 | -floop-block -floop-interchange -floop-strip-mine | |
573 | -floop-unroll-and-jam -floop-nest-optimize | |
574 | -floop-parallelize-all -flra-remat -flto -flto-compression-level | |
575 | -flto-partition=@var{alg} -fmerge-all-constants | |
576 | -fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves | |
577 | -fmove-loop-invariants -fmove-loop-stores -fno-branch-count-reg | |
578 | -fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse | |
579 | -fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole | |
580 | -fno-peephole2 -fno-printf-return-value -fno-sched-interblock | |
581 | -fno-sched-spec -fno-signed-zeros | |
582 | -fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss | |
583 | -fomit-frame-pointer -foptimize-sibling-calls | |
584 | -fpartial-inlining -fpeel-loops -fpredictive-commoning | |
585 | -fprefetch-loop-arrays | |
586 | -fprofile-correction | |
587 | -fprofile-use -fprofile-use=@var{path} -fprofile-partial-training | |
588 | -fprofile-values -fprofile-reorder-functions | |
589 | -freciprocal-math -free -frename-registers -freorder-blocks | |
590 | -freorder-blocks-algorithm=@var{algorithm} | |
591 | -freorder-blocks-and-partition -freorder-functions | |
592 | -frerun-cse-after-loop -freschedule-modulo-scheduled-loops | |
593 | -frounding-math -fsave-optimization-record | |
594 | -fsched2-use-superblocks -fsched-pressure | |
595 | -fsched-spec-load -fsched-spec-load-dangerous | |
596 | -fsched-stalled-insns-dep[=@var{n}] -fsched-stalled-insns[=@var{n}] | |
597 | -fsched-group-heuristic -fsched-critical-path-heuristic | |
598 | -fsched-spec-insn-heuristic -fsched-rank-heuristic | |
599 | -fsched-last-insn-heuristic -fsched-dep-count-heuristic | |
600 | -fschedule-fusion | |
601 | -fschedule-insns -fschedule-insns2 -fsection-anchors | |
602 | -fselective-scheduling -fselective-scheduling2 | |
603 | -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops | |
604 | -fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate | |
605 | -fsignaling-nans | |
606 | -fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops | |
607 | -fsplit-paths | |
608 | -fsplit-wide-types -fsplit-wide-types-early -fssa-backprop -fssa-phiopt | |
609 | -fstdarg-opt -fstore-merging -fstrict-aliasing -fipa-strict-aliasing | |
610 | -fthread-jumps -ftracer -ftree-bit-ccp | |
611 | -ftree-builtin-call-dce -ftree-ccp -ftree-ch | |
612 | -ftree-coalesce-vars -ftree-copy-prop -ftree-dce -ftree-dominator-opts | |
613 | -ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting | |
614 | -ftree-loop-if-convert -ftree-loop-im | |
615 | -ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns | |
616 | -ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize | |
617 | -ftree-loop-vectorize | |
618 | -ftree-parallelize-loops=@var{n} -ftree-pre -ftree-partial-pre -ftree-pta | |
619 | -ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slsr -ftree-sra | |
620 | -ftree-switch-conversion -ftree-tail-merge | |
621 | -ftree-ter -ftree-vectorize -ftree-vrp -ftrivial-auto-var-init | |
622 | -funconstrained-commons -funit-at-a-time -funroll-all-loops | |
623 | -funroll-loops -funsafe-math-optimizations -funswitch-loops | |
624 | -fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt | |
625 | -fweb -fwhole-program -fwpa -fuse-linker-plugin -fzero-call-used-regs | |
d77de738 ML |
626 | --param @var{name}=@var{value} |
627 | -O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz} | |
628 | ||
629 | @item Program Instrumentation Options | |
630 | @xref{Instrumentation Options,,Program Instrumentation Options}. | |
43b72ede AA |
631 | @gccoptlist{-p -pg -fprofile-arcs --coverage -ftest-coverage |
632 | -fprofile-abs-path | |
633 | -fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path} | |
634 | -fprofile-info-section -fprofile-info-section=@var{name} | |
635 | -fprofile-note=@var{path} -fprofile-prefix-path=@var{path} | |
636 | -fprofile-update=@var{method} -fprofile-filter-files=@var{regex} | |
637 | -fprofile-exclude-files=@var{regex} | |
638 | -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]} | |
639 | -fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style} | |
640 | -fsanitize-trap -fsanitize-trap=@var{style} | |
641 | -fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},... | |
642 | -fsanitize-undefined-trap-on-error -fbounds-check | |
643 | -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]} | |
644 | -fharden-compares -fharden-conditional-branches | |
645 | -fstack-protector -fstack-protector-all -fstack-protector-strong | |
646 | -fstack-protector-explicit -fstack-check | |
647 | -fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} | |
648 | -fno-stack-limit -fsplit-stack | |
649 | -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} | |
650 | -fvtv-counts -fvtv-debug | |
651 | -finstrument-functions -finstrument-functions-once | |
652 | -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} | |
653 | -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{} | |
654 | -fprofile-prefix-map=@var{old}=@var{new}} | |
d77de738 ML |
655 | |
656 | @item Preprocessor Options | |
657 | @xref{Preprocessor Options,,Options Controlling the Preprocessor}. | |
43b72ede AA |
658 | @gccoptlist{-A@var{question}=@var{answer} |
659 | -A-@var{question}@r{[}=@var{answer}@r{]} | |
660 | -C -CC -D@var{macro}@r{[}=@var{defn}@r{]} | |
661 | -dD -dI -dM -dN -dU | |
662 | -fdebug-cpp -fdirectives-only -fdollars-in-identifiers | |
663 | -fexec-charset=@var{charset} -fextended-identifiers | |
664 | -finput-charset=@var{charset} -flarge-source-files | |
665 | -fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth} | |
666 | -fno-canonical-system-headers -fpch-deps -fpch-preprocess | |
667 | -fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion | |
668 | -fwide-exec-charset=@var{charset} -fworking-directory | |
669 | -H -imacros @var{file} -include @var{file} | |
670 | -M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mno-modules | |
671 | -no-integrated-cpp -P -pthread -remap | |
672 | -traditional -traditional-cpp -trigraphs | |
673 | -U@var{macro} -undef | |
d77de738 ML |
674 | -Wp,@var{option} -Xpreprocessor @var{option}} |
675 | ||
676 | @item Assembler Options | |
677 | @xref{Assembler Options,,Passing Options to the Assembler}. | |
678 | @gccoptlist{-Wa,@var{option} -Xassembler @var{option}} | |
679 | ||
680 | @item Linker Options | |
681 | @xref{Link Options,,Options for Linking}. | |
43b72ede AA |
682 | @gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library} |
683 | -nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++ | |
684 | -e @var{entry} --entry=@var{entry} | |
685 | -pie -pthread -r -rdynamic | |
686 | -s -static -static-pie -static-libgcc -static-libstdc++ | |
687 | -static-libasan -static-libtsan -static-liblsan -static-libubsan | |
688 | -shared -shared-libgcc -symbolic | |
689 | -T @var{script} -Wl,@var{option} -Xlinker @var{option} | |
d77de738 ML |
690 | -u @var{symbol} -z @var{keyword}} |
691 | ||
692 | @item Directory Options | |
693 | @xref{Directory Options,,Options for Directory Search}. | |
43b72ede AA |
694 | @gccoptlist{-B@var{prefix} -I@var{dir} -I- |
695 | -idirafter @var{dir} | |
696 | -imacros @var{file} -imultilib @var{dir} | |
697 | -iplugindir=@var{dir} -iprefix @var{file} | |
698 | -iquote @var{dir} -isysroot @var{dir} -isystem @var{dir} | |
699 | -iwithprefix @var{dir} -iwithprefixbefore @var{dir} | |
700 | -L@var{dir} -no-canonical-prefixes --no-sysroot-suffix | |
d77de738 ML |
701 | -nostdinc -nostdinc++ --sysroot=@var{dir}} |
702 | ||
703 | @item Code Generation Options | |
704 | @xref{Code Gen Options,,Options for Code Generation Conventions}. | |
43b72ede AA |
705 | @gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg} |
706 | -ffixed-@var{reg} -fexceptions | |
707 | -fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables | |
708 | -fasynchronous-unwind-tables | |
709 | -fno-gnu-unique | |
710 | -finhibit-size-directive -fcommon -fno-ident | |
711 | -fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt | |
712 | -fno-jump-tables -fno-bit-tests | |
713 | -frecord-gcc-switches | |
714 | -freg-struct-return -fshort-enums -fshort-wchar | |
715 | -fverbose-asm -fpack-struct[=@var{n}] | |
716 | -fleading-underscore -ftls-model=@var{model} | |
717 | -fstack-reuse=@var{reuse_level} | |
718 | -ftrampolines -ftrapv -fwrapv | |
719 | -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} | |
d77de738 ML |
720 | -fstrict-volatile-bitfields -fsync-libcalls} |
721 | ||
722 | @item Developer Options | |
723 | @xref{Developer Options,,GCC Developer Options}. | |
43b72ede | 724 | @gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion |
d77de738 | 725 | -dumpfullversion -fcallgraph-info@r{[}=su,da@r{]} |
43b72ede AA |
726 | -fchecking -fchecking=@var{n} |
727 | -fdbg-cnt-list -fdbg-cnt=@var{counter-value-list} | |
728 | -fdisable-ipa-@var{pass_name} | |
729 | -fdisable-rtl-@var{pass_name} | |
730 | -fdisable-rtl-@var{pass-name}=@var{range-list} | |
731 | -fdisable-tree-@var{pass_name} | |
732 | -fdisable-tree-@var{pass-name}=@var{range-list} | |
733 | -fdump-debug -fdump-earlydebug | |
734 | -fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links | |
735 | -fdump-final-insns@r{[}=@var{file}@r{]} | |
736 | -fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline | |
737 | -fdump-lang-all | |
738 | -fdump-lang-@var{switch} | |
739 | -fdump-lang-@var{switch}-@var{options} | |
740 | -fdump-lang-@var{switch}-@var{options}=@var{filename} | |
741 | -fdump-passes | |
742 | -fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename} | |
743 | -fdump-statistics | |
744 | -fdump-tree-all | |
745 | -fdump-tree-@var{switch} | |
746 | -fdump-tree-@var{switch}-@var{options} | |
747 | -fdump-tree-@var{switch}-@var{options}=@var{filename} | |
748 | -fcompare-debug@r{[}=@var{opts}@r{]} -fcompare-debug-second | |
749 | -fenable-@var{kind}-@var{pass} | |
750 | -fenable-@var{kind}-@var{pass}=@var{range-list} | |
751 | -fira-verbose=@var{n} | |
752 | -flto-report -flto-report-wpa -fmem-report-wpa | |
753 | -fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report | |
754 | -fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]} | |
755 | -fmultiflags -fprofile-report | |
756 | -frandom-seed=@var{string} -fsched-verbose=@var{n} | |
757 | -fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose | |
758 | -fstats -fstack-usage -ftime-report -ftime-report-details | |
759 | -fvar-tracking-assignments-toggle -gtoggle | |
760 | -print-file-name=@var{library} -print-libgcc-file-name | |
761 | -print-multi-directory -print-multi-lib -print-multi-os-directory | |
762 | -print-prog-name=@var{program} -print-search-dirs -Q | |
763 | -print-sysroot -print-sysroot-headers-suffix | |
d77de738 ML |
764 | -save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}} |
765 | ||
766 | @item Machine-Dependent Options | |
767 | @xref{Submodel Options,,Machine-Dependent Options}. | |
768 | @c This list is ordered alphanumerically by subsection name. | |
769 | @c Try and put the significant identifier (CPU or system) first, | |
770 | @c so users have a clue at guessing where the ones they want will be. | |
771 | ||
772 | @emph{AArch64 Options} | |
43b72ede AA |
773 | @gccoptlist{-mabi=@var{name} -mbig-endian -mlittle-endian |
774 | -mgeneral-regs-only | |
775 | -mcmodel=tiny -mcmodel=small -mcmodel=large | |
776 | -mstrict-align -mno-strict-align | |
777 | -momit-leaf-frame-pointer | |
778 | -mtls-dialect=desc -mtls-dialect=traditional | |
779 | -mtls-size=@var{size} | |
780 | -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 | |
781 | -mlow-precision-recip-sqrt -mlow-precision-sqrt -mlow-precision-div | |
782 | -mpc-relative-literal-loads | |
783 | -msign-return-address=@var{scope} | |
d77de738 | 784 | -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf} |
43b72ede AA |
785 | +@var{b-key}]|@var{bti} |
786 | -mharden-sls=@var{opts} | |
787 | -march=@var{name} -mcpu=@var{name} -mtune=@var{name} | |
788 | -moverride=@var{string} -mverbose-cost-dump | |
789 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg} | |
790 | -mstack-protector-guard-offset=@var{offset} -mtrack-speculation | |
d77de738 ML |
791 | -moutline-atomics } |
792 | ||
793 | @emph{Adapteva Epiphany Options} | |
43b72ede AA |
794 | @gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs |
795 | -mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf | |
796 | -msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num} | |
797 | -mround-nearest -mlong-calls -mshort-calls -msmall16 | |
798 | -mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num} | |
d77de738 ML |
799 | -msplit-vecmove-early -m1reg-@var{reg}} |
800 | ||
801 | @emph{AMD GCN Options} | |
802 | @gccoptlist{-march=@var{gpu} -mtune=@var{gpu} -mstack-size=@var{bytes}} | |
803 | ||
804 | @emph{ARC Options} | |
43b72ede AA |
805 | @gccoptlist{-mbarrel-shifter -mjli-always |
806 | -mcpu=@var{cpu} -mA6 -mARC600 -mA7 -mARC700 | |
807 | -mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr | |
808 | -mea -mno-mpy -mmul32x16 -mmul64 -matomic | |
809 | -mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap | |
810 | -mcrc -mdsp-packa -mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape | |
811 | -mtelephony -mxy -misize -mannotate-align -marclinux -marclinux_prof | |
812 | -mlong-calls -mmedium-calls -msdata -mirq-ctrl-saved | |
813 | -mrgf-banked-regs -mlpc-width=@var{width} -G @var{num} | |
814 | -mvolatile-cache -mtp-regno=@var{regno} | |
815 | -malign-call -mauto-modify-reg -mbbit-peephole -mno-brcc | |
816 | -mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi | |
817 | -mexpand-adddi -mindexed-loads -mlra -mlra-priority-none | |
818 | -mlra-priority-compact -mlra-priority-noncompact -mmillicode | |
819 | -mmixed-code -mq-class -mRcq -mRcw -msize-level=@var{level} | |
820 | -mtune=@var{cpu} -mmultcost=@var{num} -mcode-density-frame | |
821 | -munalign-prob-threshold=@var{probability} -mmpy-option=@var{multo} | |
d77de738 ML |
822 | -mdiv-rem -mcode-density -mll64 -mfpu=@var{fpu} -mrf16 -mbranch-index} |
823 | ||
824 | @emph{ARM Options} | |
43b72ede AA |
825 | @gccoptlist{-mapcs-frame -mno-apcs-frame |
826 | -mabi=@var{name} | |
827 | -mapcs-stack-check -mno-apcs-stack-check | |
828 | -mapcs-reentrant -mno-apcs-reentrant | |
829 | -mgeneral-regs-only | |
830 | -msched-prolog -mno-sched-prolog | |
831 | -mlittle-endian -mbig-endian | |
832 | -mbe8 -mbe32 | |
833 | -mfloat-abi=@var{name} | |
d77de738 | 834 | -mfp16-format=@var{name} |
43b72ede AA |
835 | -mthumb-interwork -mno-thumb-interwork |
836 | -mcpu=@var{name} -march=@var{name} -mfpu=@var{name} | |
837 | -mtune=@var{name} -mprint-tune-info | |
838 | -mstructure-size-boundary=@var{n} | |
839 | -mabort-on-noreturn | |
840 | -mlong-calls -mno-long-calls | |
841 | -msingle-pic-base -mno-single-pic-base | |
842 | -mpic-register=@var{reg} | |
843 | -mnop-fun-dllimport | |
844 | -mpoke-function-name | |
845 | -mthumb -marm -mflip-thumb | |
846 | -mtpcs-frame -mtpcs-leaf-frame | |
847 | -mcaller-super-interworking -mcallee-super-interworking | |
848 | -mtp=@var{name} -mtls-dialect=@var{dialect} | |
849 | -mword-relocations | |
850 | -mfix-cortex-m3-ldrd | |
851 | -mfix-cortex-a57-aes-1742098 | |
852 | -mfix-cortex-a72-aes-1655431 | |
853 | -munaligned-access | |
854 | -mneon-for-64bits | |
855 | -mslow-flash-data | |
856 | -masm-syntax-unified | |
857 | -mrestrict-it | |
858 | -mverbose-cost-dump | |
859 | -mpure-code | |
860 | -mcmse | |
861 | -mfix-cmse-cve-2021-35465 | |
862 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset} | |
863 | -mfdpic | |
14fab5fb AC |
864 | -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}] |
865 | [+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]} | |
d77de738 ML |
866 | |
867 | @emph{AVR Options} | |
43b72ede AA |
868 | @gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args |
869 | -mbranch-cost=@var{cost} | |
870 | -mcall-prologues -mgas-isr-prologues -mint8 | |
871 | -mdouble=@var{bits} -mlong-double=@var{bits} | |
872 | -mn_flash=@var{size} -mno-interrupts | |
873 | -mmain-is-OS_task -mrelax -mrmw -mstrict-X -mtiny-stack | |
874 | -mfract-convert-truncate | |
875 | -mshort-calls -nodevicelib -nodevicespecs | |
d77de738 ML |
876 | -Waddr-space-convert -Wmisspelled-isr} |
877 | ||
878 | @emph{Blackfin Options} | |
43b72ede AA |
879 | @gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} |
880 | -msim -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer | |
881 | -mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly | |
882 | -mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library | |
883 | -mno-id-shared-library -mshared-library-id=@var{n} | |
884 | -mleaf-id-shared-library -mno-leaf-id-shared-library | |
885 | -msep-data -mno-sep-data -mlong-calls -mno-long-calls | |
886 | -mfast-fp -minline-plt -mmulticore -mcorea -mcoreb -msdram | |
d77de738 ML |
887 | -micplb} |
888 | ||
889 | @emph{C6X Options} | |
43b72ede | 890 | @gccoptlist{-mbig-endian -mlittle-endian -march=@var{cpu} |
d77de738 ML |
891 | -msim -msdata=@var{sdata-type}} |
892 | ||
893 | @emph{CRIS Options} | |
894 | @gccoptlist{-mcpu=@var{cpu} -march=@var{cpu} | |
43b72ede AA |
895 | -mtune=@var{cpu} -mmax-stack-frame=@var{n} |
896 | -metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects | |
897 | -mstack-align -mdata-align -mconst-align | |
898 | -m32-bit -m16-bit -m8-bit -mno-prologue-epilogue | |
899 | -melf -maout -sim -sim2 | |
d77de738 ML |
900 | -mmul-bug-workaround -mno-mul-bug-workaround} |
901 | ||
902 | @emph{C-SKY Options} | |
43b72ede AA |
903 | @gccoptlist{-march=@var{arch} -mcpu=@var{cpu} |
904 | -mbig-endian -EB -mlittle-endian -EL | |
905 | -mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu | |
906 | -mfloat-abi=@var{name} | |
907 | -melrw -mistack -mmp -mcp -mcache -msecurity -mtrust | |
908 | -mdsp -medsp -mvdsp | |
909 | -mdiv -msmart -mhigh-registers -manchor | |
910 | -mpushpop -mmultiple-stld -mconstpool -mstack-size -mccrt | |
d77de738 ML |
911 | -mbranch-cost=@var{n} -mcse-cc -msched-prolog -msim} |
912 | ||
913 | @emph{Darwin Options} | |
43b72ede AA |
914 | @gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal |
915 | -arch_only -bind_at_load -bundle -bundle_loader | |
916 | -client_name -compatibility_version -current_version | |
917 | -dead_strip | |
918 | -dependency-file -dylib_file -dylinker_install_name | |
919 | -dynamic -dynamiclib -exported_symbols_list | |
920 | -filelist -flat_namespace -force_cpusubtype_ALL | |
921 | -force_flat_namespace -headerpad_max_install_names | |
922 | -iframework | |
923 | -image_base -init -install_name -keep_private_externs | |
924 | -multi_module -multiply_defined -multiply_defined_unused | |
925 | -noall_load -no_dead_strip_inits_and_terms | |
926 | -nofixprebinding -nomultidefs -noprebind -noseglinkedit | |
927 | -pagezero_size -prebind -prebind_all_twolevel_modules | |
928 | -private_bundle -read_only_relocs -sectalign | |
929 | -sectobjectsymbols -whyload -seg1addr | |
930 | -sectcreate -sectobjectsymbols -sectorder | |
931 | -segaddr -segs_read_only_addr -segs_read_write_addr | |
932 | -seg_addr_table -seg_addr_table_filename -seglinkedit | |
933 | -segprot -segs_read_only_addr -segs_read_write_addr | |
934 | -single_module -static -sub_library -sub_umbrella | |
935 | -twolevel_namespace -umbrella -undefined | |
936 | -unexported_symbols_list -weak_reference_mismatches | |
937 | -whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version} | |
d77de738 ML |
938 | -mkernel -mone-byte-bool} |
939 | ||
940 | @emph{DEC Alpha Options} | |
43b72ede AA |
941 | @gccoptlist{-mno-fp-regs -msoft-float |
942 | -mieee -mieee-with-inexact -mieee-conformant | |
943 | -mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} | |
944 | -mtrap-precision=@var{mode} -mbuild-constants | |
945 | -mcpu=@var{cpu-type} -mtune=@var{cpu-type} | |
946 | -mbwx -mmax -mfix -mcix | |
947 | -mfloat-vax -mfloat-ieee | |
948 | -mexplicit-relocs -msmall-data -mlarge-data | |
949 | -msmall-text -mlarge-text | |
d77de738 ML |
950 | -mmemory-latency=@var{time}} |
951 | ||
952 | @emph{eBPF Options} | |
9cbf4286 | 953 | @gccoptlist{-mbig-endian -mlittle-endian |
77d0f9ec | 954 | -mframe-limit=@var{bytes} -mxbpf -mco-re -mno-co-re -mjmpext |
14dab1a1 | 955 | -mjmp32 -malu32 -mv3-atomics -mbswap -msdiv -msmov -mcpu=@var{version} |
9cbf4286 | 956 | -masm=@var{dialect}} |
d77de738 ML |
957 | |
958 | @emph{FR30 Options} | |
959 | @gccoptlist{-msmall-model -mno-lsim} | |
960 | ||
961 | @emph{FT32 Options} | |
962 | @gccoptlist{-msim -mlra -mnodiv -mft32b -mcompress -mnopm} | |
963 | ||
964 | @emph{FRV Options} | |
43b72ede AA |
965 | @gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64 |
966 | -mhard-float -msoft-float | |
967 | -malloc-cc -mfixed-cc -mdword -mno-dword | |
968 | -mdouble -mno-double | |
969 | -mmedia -mno-media -mmuladd -mno-muladd | |
970 | -mfdpic -minline-plt -mgprel-ro -multilib-library-pic | |
971 | -mlinked-fp -mlong-calls -malign-labels | |
972 | -mlibrary-pic -macc-4 -macc-8 | |
973 | -mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move | |
974 | -moptimize-membar -mno-optimize-membar | |
975 | -mscc -mno-scc -mcond-exec -mno-cond-exec | |
976 | -mvliw-branch -mno-vliw-branch | |
977 | -mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec | |
978 | -mno-nested-cond-exec -mtomcat-stats | |
979 | -mTLS -mtls | |
d77de738 ML |
980 | -mcpu=@var{cpu}} |
981 | ||
982 | @emph{GNU/Linux Options} | |
43b72ede | 983 | @gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid |
d77de738 ML |
984 | -tno-android-cc -tno-android-ld} |
985 | ||
986 | @emph{H8/300 Options} | |
987 | @gccoptlist{-mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300} | |
988 | ||
989 | @emph{HPPA Options} | |
43b72ede AA |
990 | @gccoptlist{-march=@var{architecture-type} |
991 | -matomic-libcalls -mbig-switch | |
992 | -mcaller-copies -mdisable-fpregs -mdisable-indexing | |
993 | -mordered -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld | |
994 | -mfixed-range=@var{register-range} | |
995 | -mcoherent-ldcw -mjump-in-delay -mlinker-opt -mlong-calls | |
996 | -mlong-load-store -mno-atomic-libcalls -mno-disable-fpregs | |
997 | -mno-disable-indexing -mno-fast-indirect-calls -mno-gas | |
998 | -mno-jump-in-delay -mno-long-load-store | |
999 | -mno-portable-runtime -mno-soft-float | |
1000 | -mno-space-regs -msoft-float -mpa-risc-1-0 | |
1001 | -mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime | |
1002 | -mschedule=@var{cpu-type} -mspace-regs -msoft-mult -msio -mwsio | |
d77de738 ML |
1003 | -munix=@var{unix-std} -nolibdld -static -threads} |
1004 | ||
1005 | @emph{IA-64 Options} | |
43b72ede AA |
1006 | @gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic |
1007 | -mvolatile-asm-stop -mregister-names -msdata -mno-sdata | |
1008 | -mconstant-gp -mauto-pic -mfused-madd | |
1009 | -minline-float-divide-min-latency | |
1010 | -minline-float-divide-max-throughput | |
1011 | -mno-inline-float-divide | |
1012 | -minline-int-divide-min-latency | |
1013 | -minline-int-divide-max-throughput | |
1014 | -mno-inline-int-divide | |
1015 | -minline-sqrt-min-latency -minline-sqrt-max-throughput | |
1016 | -mno-inline-sqrt | |
1017 | -mdwarf2-asm -mearly-stop-bits | |
1018 | -mfixed-range=@var{register-range} -mtls-size=@var{tls-size} | |
1019 | -mtune=@var{cpu-type} -milp32 -mlp64 | |
1020 | -msched-br-data-spec -msched-ar-data-spec -msched-control-spec | |
1021 | -msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec | |
1022 | -msched-spec-ldc -msched-spec-control-ldc | |
1023 | -msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns | |
1024 | -msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path | |
1025 | -msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost | |
d77de738 ML |
1026 | -msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}} |
1027 | ||
1028 | @emph{LM32 Options} | |
43b72ede | 1029 | @gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled |
d77de738 ML |
1030 | -msign-extend-enabled -muser-enabled} |
1031 | ||
1032 | @emph{LoongArch Options} | |
43b72ede | 1033 | @gccoptlist{-march=@var{cpu-type} -mtune=@var{cpu-type} -mabi=@var{base-abi-type} |
bb4a8198 YY |
1034 | -mfpu=@var{fpu-type} -msimd=@var{simd-type} |
1035 | -msoft-float -msingle-float -mdouble-float -mlsx -mno-lsx -mlasx -mno-lasx | |
43b72ede AA |
1036 | -mbranch-cost=@var{n} -mcheck-zero-division -mno-check-zero-division |
1037 | -mcond-move-int -mno-cond-move-int | |
1038 | -mcond-move-float -mno-cond-move-float | |
1039 | -memcpy -mno-memcpy -mstrict-align -mno-strict-align | |
1040 | -mmax-inline-memcpy-size=@var{n} | |
1041 | -mexplicit-relocs -mno-explicit-relocs | |
1042 | -mdirect-extern-access -mno-direct-extern-access | |
d77de738 ML |
1043 | -mcmodel=@var{code-model}} |
1044 | ||
1045 | @emph{M32R/D Options} | |
43b72ede AA |
1046 | @gccoptlist{-m32r2 -m32rx -m32r |
1047 | -mdebug | |
1048 | -malign-loops -mno-align-loops | |
1049 | -missue-rate=@var{number} | |
1050 | -mbranch-cost=@var{number} | |
1051 | -mmodel=@var{code-size-model-type} | |
1052 | -msdata=@var{sdata-type} | |
1053 | -mno-flush-func -mflush-func=@var{name} | |
1054 | -mno-flush-trap -mflush-trap=@var{number} | |
d77de738 ML |
1055 | -G @var{num}} |
1056 | ||
1057 | @emph{M32C Options} | |
1058 | @gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}} | |
1059 | ||
1060 | @emph{M680x0 Options} | |
43b72ede AA |
1061 | @gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune} |
1062 | -m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 | |
1063 | -m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407 | |
1064 | -mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020 | |
1065 | -mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort | |
1066 | -mno-short -mhard-float -m68881 -msoft-float -mpcrel | |
1067 | -malign-int -mstrict-align -msep-data -mno-sep-data | |
1068 | -mshared-library-id=n -mid-shared-library -mno-id-shared-library | |
d77de738 ML |
1069 | -mxgot -mno-xgot -mlong-jump-table-offsets} |
1070 | ||
1071 | @emph{MCore Options} | |
43b72ede AA |
1072 | @gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates |
1073 | -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields | |
1074 | -m4byte-functions -mno-4byte-functions -mcallgraph-data | |
1075 | -mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim | |
d77de738 ML |
1076 | -mlittle-endian -mbig-endian -m210 -m340 -mstack-increment} |
1077 | ||
d77de738 | 1078 | @emph{MicroBlaze Options} |
43b72ede AA |
1079 | @gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu} |
1080 | -mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift | |
1081 | -mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss | |
1082 | -mxl-multiply-high -mxl-float-convert -mxl-float-sqrt | |
1083 | -mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model} | |
d77de738 ML |
1084 | -mpic-data-is-text-relative} |
1085 | ||
1086 | @emph{MIPS Options} | |
43b72ede AA |
1087 | @gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} |
1088 | -mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5 | |
1089 | -mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6 | |
1090 | -mips16 -mno-mips16 -mflip-mips16 | |
1091 | -minterlink-compressed -mno-interlink-compressed | |
1092 | -minterlink-mips16 -mno-interlink-mips16 | |
1093 | -mabi=@var{abi} -mabicalls -mno-abicalls | |
1094 | -mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot | |
1095 | -mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float | |
1096 | -mno-float -msingle-float -mdouble-float | |
1097 | -modd-spreg -mno-odd-spreg | |
1098 | -mabs=@var{mode} -mnan=@var{encoding} | |
1099 | -mdsp -mno-dsp -mdspr2 -mno-dspr2 | |
1100 | -mmcu -mmno-mcu | |
1101 | -meva -mno-eva | |
1102 | -mvirt -mno-virt | |
1103 | -mxpa -mno-xpa | |
1104 | -mcrc -mno-crc | |
1105 | -mginv -mno-ginv | |
1106 | -mmicromips -mno-micromips | |
1107 | -mmsa -mno-msa | |
1108 | -mloongson-mmi -mno-loongson-mmi | |
1109 | -mloongson-ext -mno-loongson-ext | |
1110 | -mloongson-ext2 -mno-loongson-ext2 | |
1111 | -mfpu=@var{fpu-type} | |
1112 | -msmartmips -mno-smartmips | |
1113 | -mpaired-single -mno-paired-single -mdmx -mno-mdmx | |
1114 | -mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc | |
1115 | -mlong64 -mlong32 -msym32 -mno-sym32 | |
1116 | -G@var{num} -mlocal-sdata -mno-local-sdata | |
1117 | -mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt | |
1118 | -membedded-data -mno-embedded-data | |
1119 | -muninit-const-in-rodata -mno-uninit-const-in-rodata | |
1120 | -mcode-readable=@var{setting} | |
1121 | -msplit-addresses -mno-split-addresses | |
1122 | -mexplicit-relocs -mno-explicit-relocs | |
1123 | -mcheck-zero-division -mno-check-zero-division | |
1124 | -mdivide-traps -mdivide-breaks | |
1125 | -mload-store-pairs -mno-load-store-pairs | |
1126 | -munaligned-access -mno-unaligned-access | |
1127 | -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls | |
1128 | -mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp | |
1129 | -mfix-24k -mno-fix-24k | |
1130 | -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 | |
1131 | -mfix-r5900 -mno-fix-r5900 | |
1132 | -mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000 | |
1133 | -mfix-vr4120 -mno-fix-vr4120 | |
1134 | -mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1 | |
1135 | -mflush-func=@var{func} -mno-flush-func | |
1136 | -mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely | |
1137 | -mcompact-branches=@var{policy} | |
1138 | -mfp-exceptions -mno-fp-exceptions | |
1139 | -mvr4130-align -mno-vr4130-align -msynci -mno-synci | |
1140 | -mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4 | |
1141 | -mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address | |
d77de738 ML |
1142 | -mframe-header-opt -mno-frame-header-opt} |
1143 | ||
1144 | @emph{MMIX Options} | |
43b72ede AA |
1145 | @gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu |
1146 | -mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols | |
1147 | -melf -mbranch-predict -mno-branch-predict -mbase-addresses | |
d77de738 ML |
1148 | -mno-base-addresses -msingle-exit -mno-single-exit} |
1149 | ||
1150 | @emph{MN10300 Options} | |
43b72ede AA |
1151 | @gccoptlist{-mmult-bug -mno-mult-bug |
1152 | -mno-am33 -mam33 -mam33-2 -mam34 | |
1153 | -mtune=@var{cpu-type} | |
1154 | -mreturn-pointer-on-d0 | |
d77de738 ML |
1155 | -mno-crt0 -mrelax -mliw -msetlb} |
1156 | ||
1157 | @emph{Moxie Options} | |
1158 | @gccoptlist{-meb -mel -mmul.x -mno-crt0} | |
1159 | ||
1160 | @emph{MSP430 Options} | |
43b72ede AA |
1161 | @gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax |
1162 | -mwarn-mcu | |
1163 | -mcode-region= -mdata-region= | |
1164 | -msilicon-errata= -msilicon-errata-warn= | |
d77de738 ML |
1165 | -mhwmult= -minrt -mtiny-printf -mmax-inline-shift=} |
1166 | ||
1167 | @emph{NDS32 Options} | |
43b72ede AA |
1168 | @gccoptlist{-mbig-endian -mlittle-endian |
1169 | -mreduced-regs -mfull-regs | |
1170 | -mcmov -mno-cmov | |
1171 | -mext-perf -mno-ext-perf | |
1172 | -mext-perf2 -mno-ext-perf2 | |
1173 | -mext-string -mno-ext-string | |
1174 | -mv3push -mno-v3push | |
1175 | -m16bit -mno-16bit | |
1176 | -misr-vector-size=@var{num} | |
1177 | -mcache-block-size=@var{num} | |
1178 | -march=@var{arch} | |
1179 | -mcmodel=@var{code-model} | |
d77de738 ML |
1180 | -mctor-dtor -mrelax} |
1181 | ||
1182 | @emph{Nios II Options} | |
43b72ede AA |
1183 | @gccoptlist{-G @var{num} -mgpopt=@var{option} -mgpopt -mno-gpopt |
1184 | -mgprel-sec=@var{regexp} -mr0rel-sec=@var{regexp} | |
1185 | -mel -meb | |
1186 | -mno-bypass-cache -mbypass-cache | |
1187 | -mno-cache-volatile -mcache-volatile | |
1188 | -mno-fast-sw-div -mfast-sw-div | |
1189 | -mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx -mno-hw-div -mhw-div | |
1190 | -mcustom-@var{insn}=@var{N} -mno-custom-@var{insn} | |
1191 | -mcustom-fpu-cfg=@var{name} | |
1192 | -mhal -msmallc -msys-crt0=@var{name} -msys-lib=@var{name} | |
d77de738 ML |
1193 | -march=@var{arch} -mbmx -mno-bmx -mcdx -mno-cdx} |
1194 | ||
1195 | @emph{Nvidia PTX Options} | |
1196 | @gccoptlist{-m64 -mmainkernel -moptimize} | |
1197 | ||
1198 | @emph{OpenRISC Options} | |
43b72ede AA |
1199 | @gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div |
1200 | -msoft-mul -msoft-div | |
1201 | -msoft-float -mhard-float -mdouble-float -munordered-float | |
1202 | -mcmov -mror -mrori -msext -msfimm -mshftimm | |
d77de738 ML |
1203 | -mcmodel=@var{code-model}} |
1204 | ||
1205 | @emph{PDP-11 Options} | |
43b72ede AA |
1206 | @gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 |
1207 | -mint32 -mno-int16 -mint16 -mno-int32 | |
d77de738 ML |
1208 | -msplit -munix-asm -mdec-asm -mgnu-asm -mlra} |
1209 | ||
d77de738 ML |
1210 | @emph{PowerPC Options} |
1211 | See RS/6000 and PowerPC Options. | |
1212 | ||
1213 | @emph{PRU Options} | |
43b72ede | 1214 | @gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop |
f58e6d42 | 1215 | -mabi=@var{variant}} |
d77de738 ML |
1216 | |
1217 | @emph{RISC-V Options} | |
43b72ede AA |
1218 | @gccoptlist{-mbranch-cost=@var{N-instruction} |
1219 | -mplt -mno-plt | |
1220 | -mabi=@var{ABI-string} | |
1221 | -mfdiv -mno-fdiv | |
1222 | -mdiv -mno-div | |
1223 | -misa-spec=@var{ISA-spec-string} | |
1224 | -march=@var{ISA-string} | |
1225 | -mtune=@var{processor-string} | |
1226 | -mpreferred-stack-boundary=@var{num} | |
1227 | -msmall-data-limit=@var{N-bytes} | |
1228 | -msave-restore -mno-save-restore | |
1229 | -mshorten-memrefs -mno-shorten-memrefs | |
1230 | -mstrict-align -mno-strict-align | |
1231 | -mcmodel=medlow -mcmodel=medany | |
1232 | -mexplicit-relocs -mno-explicit-relocs | |
1233 | -mrelax -mno-relax | |
1234 | -mriscv-attribute -mno-riscv-attribute | |
1235 | -malign-data=@var{type} | |
1236 | -mbig-endian -mlittle-endian | |
1237 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} | |
1238 | -mstack-protector-guard-offset=@var{offset} | |
f797260a | 1239 | -mcsr-check -mno-csr-check |
df48285b | 1240 | -minline-atomics -mno-inline-atomics |
949f1ccf CM |
1241 | -minline-strlen -mno-inline-strlen |
1242 | -minline-strcmp -mno-inline-strcmp | |
1243 | -minline-strncmp -mno-inline-strncmp} | |
d77de738 ML |
1244 | |
1245 | @emph{RL78 Options} | |
43b72ede AA |
1246 | @gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs |
1247 | -mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14 | |
d77de738 ML |
1248 | -m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts} |
1249 | ||
1250 | @emph{RS/6000 and PowerPC Options} | |
43b72ede AA |
1251 | @gccoptlist{-mcpu=@var{cpu-type} |
1252 | -mtune=@var{cpu-type} | |
1253 | -mcmodel=@var{code-model} | |
1254 | -mpowerpc64 | |
1255 | -maltivec -mno-altivec | |
1256 | -mpowerpc-gpopt -mno-powerpc-gpopt | |
1257 | -mpowerpc-gfxopt -mno-powerpc-gfxopt | |
1258 | -mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd | |
1259 | -mfprnd -mno-fprnd | |
1260 | -mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp | |
1261 | -mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc | |
1262 | -m64 -m32 -mxl-compat -mno-xl-compat -mpe | |
1263 | -malign-power -malign-natural | |
1264 | -msoft-float -mhard-float -mmultiple -mno-multiple | |
1265 | -mupdate -mno-update | |
1266 | -mavoid-indexed-addresses -mno-avoid-indexed-addresses | |
1267 | -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align | |
1268 | -mstrict-align -mno-strict-align -mrelocatable | |
1269 | -mno-relocatable -mrelocatable-lib -mno-relocatable-lib | |
1270 | -mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian | |
1271 | -mdynamic-no-pic -mswdiv -msingle-pic-base | |
1272 | -mprioritize-restricted-insns=@var{priority} | |
1273 | -msched-costly-dep=@var{dependence_type} | |
1274 | -minsert-sched-nops=@var{scheme} | |
1275 | -mcall-aixdesc -mcall-eabi -mcall-freebsd | |
1276 | -mcall-linux -mcall-netbsd -mcall-openbsd | |
1277 | -mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi | |
1278 | -mtraceback=@var{traceback_type} | |
1279 | -maix-struct-return -msvr4-struct-return | |
1280 | -mabi=@var{abi-type} -msecure-plt -mbss-plt | |
1281 | -mlongcall -mno-longcall -mpltseq -mno-pltseq | |
1282 | -mblock-move-inline-limit=@var{num} | |
1283 | -mblock-compare-inline-limit=@var{num} | |
1284 | -mblock-compare-inline-loop-limit=@var{num} | |
1285 | -mno-block-ops-unaligned-vsx | |
1286 | -mstring-compare-inline-limit=@var{num} | |
1287 | -misel -mno-isel | |
1288 | -mvrsave -mno-vrsave | |
1289 | -mmulhw -mno-mulhw | |
1290 | -mdlmzb -mno-dlmzb | |
1291 | -mprototype -mno-prototype | |
1292 | -msim -mmvme -mads -myellowknife -memb -msdata | |
1293 | -msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num} | |
1294 | -mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision | |
1295 | -mno-recip-precision | |
1296 | -mveclibabi=@var{type} -mfriz -mno-friz | |
1297 | -mpointers-to-nested-functions -mno-pointers-to-nested-functions | |
1298 | -msave-toc-indirect -mno-save-toc-indirect | |
1299 | -mpower8-fusion -mno-mpower8-fusion -mpower8-vector -mno-power8-vector | |
1300 | -mcrypto -mno-crypto -mhtm -mno-htm | |
1301 | -mquad-memory -mno-quad-memory | |
1302 | -mquad-memory-atomic -mno-quad-memory-atomic | |
1303 | -mcompat-align-parm -mno-compat-align-parm | |
1304 | -mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware | |
1305 | -mgnu-attribute -mno-gnu-attribute | |
1306 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} | |
1307 | -mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed | |
1308 | -mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect | |
d77de738 ML |
1309 | -mprivileged -mno-privileged} |
1310 | ||
1311 | @emph{RX Options} | |
43b72ede AA |
1312 | @gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu |
1313 | -mcpu= | |
1314 | -mbig-endian-data -mlittle-endian-data | |
1315 | -msmall-data | |
1316 | -msim -mno-sim | |
1317 | -mas100-syntax -mno-as100-syntax | |
1318 | -mrelax | |
1319 | -mmax-constant-size= | |
1320 | -mint-register= | |
1321 | -mpid | |
1322 | -mallow-string-insns -mno-allow-string-insns | |
1323 | -mjsr | |
1324 | -mno-warn-multiple-fast-interrupts | |
d77de738 ML |
1325 | -msave-acc-in-interrupts} |
1326 | ||
1327 | @emph{S/390 and zSeries Options} | |
43b72ede AA |
1328 | @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} |
1329 | -mhard-float -msoft-float -mhard-dfp -mno-hard-dfp | |
1330 | -mlong-double-64 -mlong-double-128 | |
1331 | -mbackchain -mno-backchain -mpacked-stack -mno-packed-stack | |
1332 | -msmall-exec -mno-small-exec -mmvcle -mno-mvcle | |
1333 | -m64 -m31 -mdebug -mno-debug -mesa -mzarch | |
1334 | -mhtm -mvx -mzvector | |
1335 | -mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip | |
1336 | -mfused-madd -mno-fused-madd | |
1337 | -mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard | |
d77de738 ML |
1338 | -mhotpatch=@var{halfwords},@var{halfwords}} |
1339 | ||
d77de738 | 1340 | @emph{SH Options} |
43b72ede AA |
1341 | @gccoptlist{-m1 -m2 -m2e |
1342 | -m2a-nofpu -m2a-single-only -m2a-single -m2a | |
1343 | -m3 -m3e | |
1344 | -m4-nofpu -m4-single-only -m4-single -m4 | |
1345 | -m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al | |
1346 | -mb -ml -mdalign -mrelax | |
1347 | -mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave | |
1348 | -mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct | |
1349 | -mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy} | |
1350 | -mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range} | |
1351 | -maccumulate-outgoing-args | |
1352 | -matomic-model=@var{atomic-model} | |
1353 | -mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch | |
1354 | -mcbranch-force-delay-slot | |
1355 | -mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra | |
d77de738 ML |
1356 | -mpretend-cmove -mtas} |
1357 | ||
1358 | @emph{Solaris 2 Options} | |
43b72ede | 1359 | @gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text |
d77de738 ML |
1360 | -pthreads} |
1361 | ||
1362 | @emph{SPARC Options} | |
43b72ede AA |
1363 | @gccoptlist{-mcpu=@var{cpu-type} |
1364 | -mtune=@var{cpu-type} | |
1365 | -mcmodel=@var{code-model} | |
1366 | -mmemory-model=@var{mem-model} | |
1367 | -m32 -m64 -mapp-regs -mno-app-regs | |
1368 | -mfaster-structs -mno-faster-structs -mflat -mno-flat | |
1369 | -mfpu -mno-fpu -mhard-float -msoft-float | |
1370 | -mhard-quad-float -msoft-quad-float | |
1371 | -mstack-bias -mno-stack-bias | |
1372 | -mstd-struct-return -mno-std-struct-return | |
1373 | -munaligned-doubles -mno-unaligned-doubles | |
1374 | -muser-mode -mno-user-mode | |
1375 | -mv8plus -mno-v8plus -mvis -mno-vis | |
1376 | -mvis2 -mno-vis2 -mvis3 -mno-vis3 | |
1377 | -mvis4 -mno-vis4 -mvis4b -mno-vis4b | |
1378 | -mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld | |
1379 | -mpopc -mno-popc -msubxc -mno-subxc | |
1380 | -mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc | |
d77de738 ML |
1381 | -mlra -mno-lra} |
1382 | ||
1383 | @emph{System V Options} | |
1384 | @gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}} | |
1385 | ||
1386 | @emph{V850 Options} | |
43b72ede AA |
1387 | @gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep |
1388 | -mprolog-function -mno-prolog-function -mspace | |
1389 | -mtda=@var{n} -msda=@var{n} -mzda=@var{n} | |
1390 | -mapp-regs -mno-app-regs | |
1391 | -mdisable-callt -mno-disable-callt | |
1392 | -mv850e2v3 -mv850e2 -mv850e1 -mv850es | |
1393 | -mv850e -mv850 -mv850e3v5 | |
1394 | -mloop | |
1395 | -mrelax | |
1396 | -mlong-jumps | |
1397 | -msoft-float | |
1398 | -mhard-float | |
1399 | -mgcc-abi | |
1400 | -mrh850-abi | |
d77de738 ML |
1401 | -mbig-switch} |
1402 | ||
1403 | @emph{VAX Options} | |
1404 | @gccoptlist{-mg -mgnu -munix -mlra} | |
1405 | ||
1406 | @emph{Visium Options} | |
43b72ede | 1407 | @gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float |
d77de738 ML |
1408 | -mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode} |
1409 | ||
1410 | @emph{VMS Options} | |
43b72ede | 1411 | @gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64 |
d77de738 ML |
1412 | -mpointer-size=@var{size}} |
1413 | ||
1414 | @emph{VxWorks Options} | |
b6f4b000 | 1415 | @gccoptlist{-mrtp -msmp -non-static -Bstatic -Bdynamic |
d77de738 ML |
1416 | -Xbind-lazy -Xbind-now} |
1417 | ||
1418 | @emph{x86 Options} | |
43b72ede AA |
1419 | @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} |
1420 | -mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default | |
1421 | -mfpmath=@var{unit} | |
1422 | -masm=@var{dialect} -mno-fancy-math-387 | |
1423 | -mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float | |
1424 | -mno-wide-multiply -mrtd -malign-double | |
1425 | -mpreferred-stack-boundary=@var{num} | |
1426 | -mincoming-stack-boundary=@var{num} | |
1427 | -mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait | |
1428 | -mrecip -mrecip=@var{opt} | |
1429 | -mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt} | |
ad5b757d | 1430 | -mpartial-vector-fp-math |
43b72ede AA |
1431 | -mmove-max=@var{bits} -mstore-max=@var{bits} |
1432 | -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx | |
1433 | -mavx2 -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl | |
1434 | -mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes | |
1435 | -mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd | |
1436 | -mptwrite -mprefetchwt1 -mclflushopt -mclwb -mxsavec -mxsaves | |
1437 | -msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop | |
1438 | -madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp | |
1439 | -mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg | |
1440 | -mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call | |
1441 | -mavx512vbmi2 -mavx512bf16 -menqcmd | |
1442 | -mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq | |
1443 | -mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid | |
1444 | -mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk | |
1445 | -mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni | |
1446 | -mavx512fp16 -mavxifma -mavxvnniint8 -mavxneconvert -mcmpccxadd -mamx-fp16 | |
e686416b | 1447 | -mprefetchi -mraoint -mamx-complex -mavxvnniint16 -msm3 -msha512 -msm4 -mapxf |
5fbd91b1 | 1448 | -musermsr |
43b72ede AA |
1449 | -mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops |
1450 | -minline-stringops-dynamically -mstringop-strategy=@var{alg} | |
1451 | -mkl -mwidekl | |
1452 | -mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy} | |
1453 | -mpush-args -maccumulate-outgoing-args -m128bit-long-double | |
1454 | -m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128 | |
1455 | -mregparm=@var{num} -msseregparm | |
1456 | -mveclibabi=@var{type} -mvect8-ret-in-mem | |
1457 | -mpc32 -mpc64 -mpc80 -mdaz-ftz -mstackrealign | |
1458 | -momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs | |
1459 | -mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode} | |
1460 | -m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num} | |
1461 | -msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv | |
1462 | -minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name} | |
1463 | -mavx256-split-unaligned-load -mavx256-split-unaligned-store | |
1464 | -malign-data=@var{type} -mstack-protector-guard=@var{guard} | |
1465 | -mstack-protector-guard-reg=@var{reg} | |
1466 | -mstack-protector-guard-offset=@var{offset} | |
1467 | -mstack-protector-guard-symbol=@var{symbol} | |
1468 | -mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop | |
1469 | -mindirect-branch=@var{choice} -mfunction-return=@var{choice} | |
1470 | -mindirect-branch-register -mharden-sls=@var{choice} | |
1471 | -mindirect-branch-cs-prefix -mneeded -mno-direct-extern-access | |
bb576017 | 1472 | -munroll-only-small-loops -mlam=@var{choice}} |
d77de738 ML |
1473 | |
1474 | @emph{x86 Windows Options} | |
453cb585 | 1475 | @gccoptlist{-mconsole -mcrtdll=@var{library} -mcygwin -mno-cygwin -mdll |
43b72ede | 1476 | -mnop-fun-dllimport -mthread |
d77de738 ML |
1477 | -municode -mwin32 -mwindows -fno-set-stack-executable} |
1478 | ||
1479 | @emph{Xstormy16 Options} | |
1480 | @gccoptlist{-msim} | |
1481 | ||
1482 | @emph{Xtensa Options} | |
43b72ede AA |
1483 | @gccoptlist{-mconst16 -mno-const16 |
1484 | -mfused-madd -mno-fused-madd | |
1485 | -mforce-no-pic | |
1486 | -mserialize-volatile -mno-serialize-volatile | |
1487 | -mtext-section-literals -mno-text-section-literals | |
1488 | -mauto-litpools -mno-auto-litpools | |
1489 | -mtarget-align -mno-target-align | |
1490 | -mlongcalls -mno-longcalls | |
1491 | -mabi=@var{abi-type} | |
675b390e MF |
1492 | -mextra-l32r-costs=@var{cycles} |
1493 | -mstrict-align -mno-strict-align} | |
d77de738 ML |
1494 | |
1495 | @emph{zSeries Options} | |
1496 | See S/390 and zSeries Options. | |
1497 | @end table | |
1498 | ||
1499 | ||
1500 | @node Overall Options | |
1501 | @section Options Controlling the Kind of Output | |
1502 | ||
1503 | Compilation can involve up to four stages: preprocessing, compilation | |
1504 | proper, assembly and linking, always in that order. GCC is capable of | |
1505 | preprocessing and compiling several files either into several | |
1506 | assembler input files, or into one assembler input file; then each | |
1507 | assembler input file produces an object file, and linking combines all | |
1508 | the object files (those newly compiled, and those specified as input) | |
1509 | into an executable file. | |
1510 | ||
1511 | @cindex file name suffix | |
1512 | For any given input file, the file name suffix determines what kind of | |
1513 | compilation is done: | |
1514 | ||
1515 | @table @gcctabopt | |
1516 | @item @var{file}.c | |
1517 | C source code that must be preprocessed. | |
1518 | ||
1519 | @item @var{file}.i | |
1520 | C source code that should not be preprocessed. | |
1521 | ||
1522 | @item @var{file}.ii | |
1523 | C++ source code that should not be preprocessed. | |
1524 | ||
1525 | @item @var{file}.m | |
1526 | Objective-C source code. Note that you must link with the @file{libobjc} | |
1527 | library to make an Objective-C program work. | |
1528 | ||
1529 | @item @var{file}.mi | |
1530 | Objective-C source code that should not be preprocessed. | |
1531 | ||
1532 | @item @var{file}.mm | |
1533 | @itemx @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. Note that @samp{.M} refers | |
1536 | to a literal capital M@. | |
1537 | ||
1538 | @item @var{file}.mii | |
1539 | Objective-C++ source code that should not be preprocessed. | |
1540 | ||
1541 | @item @var{file}.h | |
1542 | C, C++, Objective-C or Objective-C++ header file to be turned into a | |
1543 | precompiled header (default), or C, C++ header file to be turned into an | |
1544 | Ada spec (via the @option{-fdump-ada-spec} switch). | |
1545 | ||
1546 | @item @var{file}.cc | |
1547 | @itemx @var{file}.cp | |
1548 | @itemx @var{file}.cxx | |
1549 | @itemx @var{file}.cpp | |
1550 | @itemx @var{file}.CPP | |
1551 | @itemx @var{file}.c++ | |
1552 | @itemx @var{file}.C | |
1553 | C++ source code that must be preprocessed. Note that in @samp{.cxx}, | |
1554 | the last two letters must both be literally @samp{x}. Likewise, | |
1555 | @samp{.C} refers to a literal capital C@. | |
1556 | ||
1557 | @item @var{file}.mm | |
1558 | @itemx @var{file}.M | |
1559 | Objective-C++ source code that must be preprocessed. | |
1560 | ||
1561 | @item @var{file}.mii | |
1562 | Objective-C++ source code that should not be preprocessed. | |
1563 | ||
1564 | @item @var{file}.hh | |
1565 | @itemx @var{file}.H | |
1566 | @itemx @var{file}.hp | |
1567 | @itemx @var{file}.hxx | |
1568 | @itemx @var{file}.hpp | |
1569 | @itemx @var{file}.HPP | |
1570 | @itemx @var{file}.h++ | |
1571 | @itemx @var{file}.tcc | |
1572 | C++ header file to be turned into a precompiled header or Ada spec. | |
1573 | ||
1574 | @item @var{file}.f | |
1575 | @itemx @var{file}.for | |
1576 | @itemx @var{file}.ftn | |
1577 | Fixed form Fortran source code that should not be preprocessed. | |
1578 | ||
1579 | @item @var{file}.F | |
1580 | @itemx @var{file}.FOR | |
1581 | @itemx @var{file}.fpp | |
1582 | @itemx @var{file}.FPP | |
1583 | @itemx @var{file}.FTN | |
1584 | Fixed form Fortran source code that must be preprocessed (with the traditional | |
1585 | preprocessor). | |
1586 | ||
1587 | @item @var{file}.f90 | |
1588 | @itemx @var{file}.f95 | |
1589 | @itemx @var{file}.f03 | |
1590 | @itemx @var{file}.f08 | |
1591 | Free form Fortran source code that should not be preprocessed. | |
1592 | ||
1593 | @item @var{file}.F90 | |
1594 | @itemx @var{file}.F95 | |
1595 | @itemx @var{file}.F03 | |
1596 | @itemx @var{file}.F08 | |
1597 | Free form Fortran source code that must be preprocessed (with the | |
1598 | traditional preprocessor). | |
1599 | ||
1600 | @item @var{file}.go | |
1601 | Go source code. | |
1602 | ||
1603 | @item @var{file}.d | |
1604 | D source code. | |
1605 | ||
1606 | @item @var{file}.di | |
1607 | D interface file. | |
1608 | ||
1609 | @item @var{file}.dd | |
1610 | D documentation code (Ddoc). | |
1611 | ||
1612 | @item @var{file}.ads | |
1613 | Ada source code file that contains a library unit declaration (a | |
1614 | declaration of a package, subprogram, or generic, or a generic | |
1615 | instantiation), or a library unit renaming declaration (a package, | |
1616 | generic, or subprogram renaming declaration). Such files are also | |
1617 | called @dfn{specs}. | |
1618 | ||
1619 | @item @var{file}.adb | |
1620 | Ada source code file containing a library unit body (a subprogram or | |
1621 | package body). Such files are also called @dfn{bodies}. | |
1622 | ||
1623 | @c GCC also knows about some suffixes for languages not yet included: | |
1624 | @c Ratfor: | |
1625 | @c @var{file}.r | |
1626 | ||
1627 | @item @var{file}.s | |
1628 | Assembler code. | |
1629 | ||
1630 | @item @var{file}.S | |
1631 | @itemx @var{file}.sx | |
1632 | Assembler code that must be preprocessed. | |
1633 | ||
1634 | @item @var{other} | |
1635 | An object file to be fed straight into linking. | |
1636 | Any file name with no recognized suffix is treated this way. | |
1637 | @end table | |
1638 | ||
1639 | @opindex x | |
1640 | You can specify the input language explicitly with the @option{-x} option: | |
1641 | ||
1642 | @table @gcctabopt | |
1643 | @item -x @var{language} | |
1644 | Specify explicitly the @var{language} for the following input files | |
1645 | (rather than letting the compiler choose a default based on the file | |
1646 | name suffix). This option applies to all following input files until | |
1647 | the next @option{-x} option. Possible values for @var{language} are: | |
1648 | @smallexample | |
1649 | c c-header cpp-output | |
1650 | c++ c++-header c++-system-header c++-user-header c++-cpp-output | |
1651 | objective-c objective-c-header objective-c-cpp-output | |
1652 | objective-c++ objective-c++-header objective-c++-cpp-output | |
1653 | assembler assembler-with-cpp | |
1654 | ada | |
1655 | d | |
1656 | f77 f77-cpp-input f95 f95-cpp-input | |
1657 | go | |
1658 | @end smallexample | |
1659 | ||
1660 | @item -x none | |
1661 | Turn off any specification of a language, so that subsequent files are | |
1662 | handled according to their file name suffixes (as they are if @option{-x} | |
1663 | has not been used at all). | |
1664 | @end table | |
1665 | ||
1666 | If you only want some of the stages of compilation, you can use | |
1667 | @option{-x} (or filename suffixes) to tell @command{gcc} where to start, and | |
1668 | one of the options @option{-c}, @option{-S}, or @option{-E} to say where | |
1669 | @command{gcc} is to stop. Note that some combinations (for example, | |
1670 | @samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all. | |
1671 | ||
1672 | @table @gcctabopt | |
d77de738 | 1673 | @opindex c |
ddf6fe37 | 1674 | @item -c |
d77de738 ML |
1675 | Compile or assemble the source files, but do not link. The linking |
1676 | stage simply is not done. The ultimate output is in the form of an | |
1677 | object file for each source file. | |
1678 | ||
1679 | By default, the object file name for a source file is made by replacing | |
1680 | the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}. | |
1681 | ||
1682 | Unrecognized input files, not requiring compilation or assembly, are | |
1683 | ignored. | |
1684 | ||
d77de738 | 1685 | @opindex S |
ddf6fe37 | 1686 | @item -S |
d77de738 ML |
1687 | Stop after the stage of compilation proper; do not assemble. The output |
1688 | is in the form of an assembler code file for each non-assembler input | |
1689 | file specified. | |
1690 | ||
1691 | By default, the assembler file name for a source file is made by | |
1692 | replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}. | |
1693 | ||
1694 | Input files that don't require compilation are ignored. | |
1695 | ||
d77de738 | 1696 | @opindex E |
ddf6fe37 | 1697 | @item -E |
d77de738 ML |
1698 | Stop after the preprocessing stage; do not run the compiler proper. The |
1699 | output is in the form of preprocessed source code, which is sent to the | |
1700 | standard output. | |
1701 | ||
1702 | Input files that don't require preprocessing are ignored. | |
1703 | ||
1704 | @cindex output file option | |
d77de738 | 1705 | @opindex o |
ddf6fe37 | 1706 | @item -o @var{file} |
d77de738 ML |
1707 | Place the primary output in file @var{file}. This applies to whatever |
1708 | sort of output is being produced, whether it be an executable file, an | |
1709 | object file, an assembler file or preprocessed C code. | |
1710 | ||
1711 | If @option{-o} is not specified, the default is to put an executable | |
1712 | file in @file{a.out}, the object file for | |
1713 | @file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its | |
1714 | assembler file in @file{@var{source}.s}, a precompiled header file in | |
1715 | @file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on | |
1716 | standard output. | |
1717 | ||
1718 | Though @option{-o} names only the primary output, it also affects the | |
1719 | naming of auxiliary and dump outputs. See the examples below. Unless | |
1720 | overridden, both auxiliary outputs and dump outputs are placed in the | |
1721 | same directory as the primary output. In auxiliary outputs, the suffix | |
1722 | of the input file is replaced with that of the auxiliary output file | |
1723 | type; in dump outputs, the suffix of the dump file is appended to the | |
1724 | input file suffix. In compilation commands, the base name of both | |
1725 | auxiliary and dump outputs is that of the primary output; in compile and | |
1726 | link commands, the primary output name, minus the executable suffix, is | |
1727 | combined with the input file name. If both share the same base name, | |
1728 | disregarding the suffix, the result of the combination is that base | |
1729 | name, otherwise, they are concatenated, separated by a dash. | |
1730 | ||
1731 | @smallexample | |
1732 | gcc -c foo.c ... | |
1733 | @end smallexample | |
1734 | ||
1735 | will use @file{foo.o} as the primary output, and place aux outputs and | |
1736 | dumps next to it, e.g., aux file @file{foo.dwo} for | |
1737 | @option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for | |
1738 | @option{-fdump-rtl-final}. | |
1739 | ||
1740 | If a non-linker output file is explicitly specified, aux and dump files | |
1741 | by default take the same base name: | |
1742 | ||
1743 | @smallexample | |
1744 | gcc -c foo.c -o dir/foobar.o ... | |
1745 | @end smallexample | |
1746 | ||
1747 | will name aux outputs @file{dir/foobar.*} and dump outputs | |
1748 | @file{dir/foobar.c.*}. | |
1749 | ||
1750 | A linker output will instead prefix aux and dump outputs: | |
1751 | ||
1752 | @smallexample | |
1753 | gcc foo.c bar.c -o dir/foobar ... | |
1754 | @end smallexample | |
1755 | ||
1756 | will generally name aux outputs @file{dir/foobar-foo.*} and | |
1757 | @file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and | |
1758 | @file{dir/foobar-bar.c.*}. | |
1759 | ||
1760 | The one exception to the above is when the executable shares the base | |
1761 | name with the single input: | |
1762 | ||
1763 | @smallexample | |
1764 | gcc foo.c -o dir/foo ... | |
1765 | @end smallexample | |
1766 | ||
1767 | in which case aux outputs are named @file{dir/foo.*} and dump outputs | |
1768 | named @file{dir/foo.c.*}. | |
1769 | ||
1770 | The location and the names of auxiliary and dump outputs can be adjusted | |
1771 | by the options @option{-dumpbase}, @option{-dumpbase-ext}, | |
1772 | @option{-dumpdir}, @option{-save-temps=cwd}, and | |
1773 | @option{-save-temps=obj}. | |
1774 | ||
1775 | ||
d77de738 | 1776 | @opindex dumpbase |
ddf6fe37 | 1777 | @item -dumpbase @var{dumpbase} |
d77de738 ML |
1778 | This option sets the base name for auxiliary and dump output files. It |
1779 | does not affect the name of the primary output file. Intermediate | |
1780 | outputs, when preserved, are not regarded as primary outputs, but as | |
1781 | auxiliary outputs: | |
1782 | ||
1783 | @smallexample | |
1784 | gcc -save-temps -S foo.c | |
1785 | @end smallexample | |
1786 | ||
1787 | saves the (no longer) temporary preprocessed file in @file{foo.i}, and | |
1788 | then compiles to the (implied) output file @file{foo.s}, whereas: | |
1789 | ||
1790 | @smallexample | |
1791 | gcc -save-temps -dumpbase save-foo -c foo.c | |
1792 | @end smallexample | |
1793 | ||
1794 | preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now | |
1795 | an intermediate, thus auxiliary output), and then assembles to the | |
1796 | (implied) output file @file{foo.o}. | |
1797 | ||
1798 | Absent this option, dump and aux files take their names from the input | |
1799 | file, or from the (non-linker) output file, if one is explicitly | |
1800 | specified: dump output files (e.g. those requested by @option{-fdump-*} | |
1801 | options) with the input name suffix, and aux output files (those | |
1802 | requested by other non-dump options, e.g. @code{-save-temps}, | |
1803 | @code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it. | |
1804 | ||
1805 | Similar suffix differentiation of dump and aux outputs can be attained | |
1806 | for explicitly-given @option{-dumpbase basename.suf} by also specifying | |
1807 | @option{-dumpbase-ext .suf}. | |
1808 | ||
1809 | If @var{dumpbase} is explicitly specified with any directory component, | |
1810 | any @var{dumppfx} specification (e.g. @option{-dumpdir} or | |
1811 | @option{-save-temps=*}) is ignored, and instead of appending to it, | |
1812 | @var{dumpbase} fully overrides it: | |
1813 | ||
1814 | @smallexample | |
1815 | gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \ | |
1816 | -dumpdir pfx- -save-temps=cwd ... | |
1817 | @end smallexample | |
1818 | ||
1819 | creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding | |
1820 | @file{dir/} in @option{-o}, the @file{./} prefix implied by | |
1821 | @option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}. | |
1822 | ||
1823 | When @option{-dumpbase} is specified in a command that compiles multiple | |
1824 | inputs, or that compiles and then links, it may be combined with | |
1825 | @var{dumppfx}, as specified under @option{-dumpdir}. Then, each input | |
1826 | file is compiled using the combined @var{dumppfx}, and default values | |
1827 | for @var{dumpbase} and @var{auxdropsuf} are computed for each input | |
1828 | file: | |
1829 | ||
1830 | @smallexample | |
1831 | gcc foo.c bar.c -c -dumpbase main ... | |
1832 | @end smallexample | |
1833 | ||
1834 | creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids | |
1835 | overwriting the auxiliary and dump outputs by using the @var{dumpbase} | |
1836 | as a prefix, creating auxiliary and dump outputs named @file{main-foo.*} | |
1837 | and @file{main-bar.*}. | |
1838 | ||
1839 | An empty string specified as @var{dumpbase} avoids the influence of the | |
1840 | output basename in the naming of auxiliary and dump outputs during | |
1841 | compilation, computing default values : | |
1842 | ||
1843 | @smallexample | |
1844 | gcc -c foo.c -o dir/foobar.o -dumpbase '' ... | |
1845 | @end smallexample | |
1846 | ||
1847 | will name aux outputs @file{dir/foo.*} and dump outputs | |
1848 | @file{dir/foo.c.*}. Note how their basenames are taken from the input | |
1849 | name, but the directory still defaults to that of the output. | |
1850 | ||
1851 | The empty-string dumpbase does not prevent the use of the output | |
1852 | basename for outputs during linking: | |
1853 | ||
1854 | @smallexample | |
1855 | gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ... | |
1856 | @end smallexample | |
1857 | ||
1858 | The compilation of the source files will name auxiliary outputs | |
1859 | @file{dir/foo.*} and @file{dir/bar.*}, and dump outputs | |
1860 | @file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during | |
1861 | linking will use @file{dir/foobar.} as the prefix for dumps and | |
1862 | auxiliary files. | |
1863 | ||
1864 | ||
d77de738 | 1865 | @opindex dumpbase-ext |
ddf6fe37 | 1866 | @item -dumpbase-ext @var{auxdropsuf} |
d77de738 ML |
1867 | When forming the name of an auxiliary (but not a dump) output file, drop |
1868 | trailing @var{auxdropsuf} from @var{dumpbase} before appending any | |
1869 | suffixes. If not specified, this option defaults to the suffix of a | |
1870 | default @var{dumpbase}, i.e., the suffix of the input file when | |
1871 | @option{-dumpbase} is not present in the command line, or @var{dumpbase} | |
1872 | is combined with @var{dumppfx}. | |
1873 | ||
1874 | @smallexample | |
1875 | gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ... | |
1876 | @end smallexample | |
1877 | ||
1878 | creates @file{dir/foo.o} as the main output, and generates auxiliary | |
1879 | outputs in @file{dir/x-foo.*}, taking the location of the primary | |
1880 | output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump | |
1881 | outputs retain the suffix: @file{dir/x-foo.c.*}. | |
1882 | ||
1883 | This option is disregarded if it does not match the suffix of a | |
1884 | specified @var{dumpbase}, except as an alternative to the executable | |
1885 | suffix when appending the linker output base name to @var{dumppfx}, as | |
1886 | specified below: | |
1887 | ||
1888 | @smallexample | |
1889 | gcc foo.c bar.c -o main.out -dumpbase-ext .out ... | |
1890 | @end smallexample | |
1891 | ||
1892 | creates @file{main.out} as the primary output, and avoids overwriting | |
1893 | the auxiliary and dump outputs by using the executable name minus | |
1894 | @var{auxdropsuf} as a prefix, creating auxiliary outputs named | |
1895 | @file{main-foo.*} and @file{main-bar.*} and dump outputs named | |
1896 | @file{main-foo.c.*} and @file{main-bar.c.*}. | |
1897 | ||
1898 | ||
d77de738 | 1899 | @opindex dumpdir |
ddf6fe37 | 1900 | @item -dumpdir @var{dumppfx} |
d77de738 ML |
1901 | When forming the name of an auxiliary or dump output file, use |
1902 | @var{dumppfx} as a prefix: | |
1903 | ||
1904 | @smallexample | |
1905 | gcc -dumpdir pfx- -c foo.c ... | |
1906 | @end smallexample | |
1907 | ||
1908 | creates @file{foo.o} as the primary output, and auxiliary outputs named | |
1909 | @file{pfx-foo.*}, combining the given @var{dumppfx} with the default | |
1910 | @var{dumpbase} derived from the default primary output, derived in turn | |
1911 | from the input name. Dump outputs also take the input name suffix: | |
1912 | @file{pfx-foo.c.*}. | |
1913 | ||
1914 | If @var{dumppfx} is to be used as a directory name, it must end with a | |
1915 | directory separator: | |
1916 | ||
1917 | @smallexample | |
1918 | gcc -dumpdir dir/ -c foo.c -o obj/bar.o ... | |
1919 | @end smallexample | |
1920 | ||
1921 | creates @file{obj/bar.o} as the primary output, and auxiliary outputs | |
1922 | named @file{dir/bar.*}, combining the given @var{dumppfx} with the | |
1923 | default @var{dumpbase} derived from the primary output name. Dump | |
1924 | outputs also take the input name suffix: @file{dir/bar.c.*}. | |
1925 | ||
1926 | It defaults to the location of the output file, unless the output | |
1927 | file is a special file like @code{/dev/null}. Options | |
1928 | @option{-save-temps=cwd} and @option{-save-temps=obj} override this | |
1929 | default, just like an explicit @option{-dumpdir} option. In case | |
1930 | multiple such options are given, the last one prevails: | |
1931 | ||
1932 | @smallexample | |
1933 | gcc -dumpdir pfx- -c foo.c -save-temps=obj ... | |
1934 | @end smallexample | |
1935 | ||
1936 | outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because | |
1937 | @option{-save-temps=*} overrides the @var{dumppfx} given by the earlier | |
1938 | @option{-dumpdir} option. It does not matter that @option{=obj} is the | |
1939 | default for @option{-save-temps}, nor that the output directory is | |
1940 | implicitly the current directory. Dump outputs are named | |
1941 | @file{foo.c.*}. | |
1942 | ||
1943 | When compiling from multiple input files, if @option{-dumpbase} is | |
1944 | specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash | |
1945 | are appended to (or override, if containing any directory components) an | |
1946 | explicit or defaulted @var{dumppfx}, so that each of the multiple | |
1947 | compilations gets differently-named aux and dump outputs. | |
1948 | ||
1949 | @smallexample | |
1950 | gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ... | |
1951 | @end smallexample | |
1952 | ||
1953 | outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and | |
1954 | @file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}. | |
1955 | Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*} | |
1956 | and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the | |
1957 | single-input compilation: | |
1958 | ||
1959 | @smallexample | |
1960 | gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ... | |
1961 | @end smallexample | |
1962 | ||
1963 | that, applying @option{-dumpbase} to a single source, does not compute | |
1964 | and append a separate @var{dumpbase} per input file. Its auxiliary and | |
1965 | dump outputs go in @file{dir/pfx-main.*}. | |
1966 | ||
1967 | When compiling and then linking from multiple input files, a defaulted | |
1968 | or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}- | |
1969 | transformation above (e.g. the compilation of @file{foo.c} and | |
1970 | @file{bar.c} above, but without @option{-c}). If neither | |
1971 | @option{-dumpdir} nor @option{-dumpbase} are given, the linker output | |
1972 | base name, minus @var{auxdropsuf}, if specified, or the executable | |
1973 | suffix otherwise, plus a dash is appended to the default @var{dumppfx} | |
1974 | instead. Note, however, that unlike earlier cases of linking: | |
1975 | ||
1976 | @smallexample | |
1977 | gcc foo.c bar.c -dumpdir dir/pfx- -o main ... | |
1978 | @end smallexample | |
1979 | ||
1980 | does not append the output name @file{main} to @var{dumppfx}, because | |
1981 | @option{-dumpdir} is explicitly specified. The goal is that the | |
1982 | explicitly-specified @var{dumppfx} may contain the specified output name | |
1983 | as part of the prefix, if desired; only an explicitly-specified | |
1984 | @option{-dumpbase} would be combined with it, in order to avoid simply | |
1985 | discarding a meaningful option. | |
1986 | ||
1987 | When compiling and then linking from a single input file, the linker | |
1988 | output base name will only be appended to the default @var{dumppfx} as | |
1989 | above if it does not share the base name with the single input file | |
1990 | name. This has been covered in single-input linking cases above, but | |
1991 | not with an explicit @option{-dumpdir} that inhibits the combination, | |
1992 | even if overridden by @option{-save-temps=*}: | |
1993 | ||
1994 | @smallexample | |
1995 | gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ... | |
1996 | @end smallexample | |
1997 | ||
1998 | Auxiliary outputs are named @file{foo.*}, and dump outputs | |
1999 | @file{foo.c.*}, in the current working directory as ultimately requested | |
2000 | by @option{-save-temps=cwd}. | |
2001 | ||
2002 | Summing it all up for an intuitive though slightly imprecise data flow: | |
2003 | the primary output name is broken into a directory part and a basename | |
2004 | part; @var{dumppfx} is set to the former, unless overridden by | |
2005 | @option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set | |
2006 | to the latter, unless overriden by @option{-dumpbase}. If there are | |
2007 | multiple inputs or linking, this @var{dumpbase} may be combined with | |
2008 | @var{dumppfx} and taken from each input file. Auxiliary output names | |
2009 | for each input are formed by combining @var{dumppfx}, @var{dumpbase} | |
2010 | minus suffix, and the auxiliary output suffix; dump output names are | |
2011 | only different in that the suffix from @var{dumpbase} is retained. | |
2012 | ||
2013 | When it comes to auxiliary and dump outputs created during LTO | |
2014 | recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as | |
2015 | given or as derived from the linker output name but not from inputs, | |
2016 | even in cases in which this combination would not otherwise be used as | |
2017 | such, is passed down with a trailing period replacing the compiler-added | |
2018 | dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper}; | |
2019 | being involved in linking, this program does not normally get any | |
2020 | @option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them. | |
2021 | ||
2022 | When running sub-compilers, @command{lto-wrapper} appends LTO stage | |
2023 | names to the received @var{dumppfx}, ensures it contains a directory | |
2024 | component so that it overrides any @option{-dumpdir}, and passes that as | |
2025 | @option{-dumpbase} to sub-compilers. | |
2026 | ||
d77de738 | 2027 | @opindex v |
ddf6fe37 | 2028 | @item -v |
d77de738 ML |
2029 | Print (on standard error output) the commands executed to run the stages |
2030 | of compilation. Also print the version number of the compiler driver | |
2031 | program and of the preprocessor and the compiler proper. | |
2032 | ||
d77de738 | 2033 | @opindex ### |
ddf6fe37 | 2034 | @item -### |
d77de738 ML |
2035 | Like @option{-v} except the commands are not executed and arguments |
2036 | are quoted unless they contain only alphanumeric characters or @code{./-_}. | |
2037 | This is useful for shell scripts to capture the driver-generated command lines. | |
2038 | ||
d77de738 | 2039 | @opindex help |
ddf6fe37 | 2040 | @item --help |
d77de738 ML |
2041 | Print (on the standard output) a description of the command-line options |
2042 | understood by @command{gcc}. If the @option{-v} option is also specified | |
2043 | then @option{--help} is also passed on to the various processes | |
2044 | invoked by @command{gcc}, so that they can display the command-line options | |
2045 | they accept. If the @option{-Wextra} option has also been specified | |
2046 | (prior to the @option{--help} option), then command-line options that | |
2047 | have no documentation associated with them are also displayed. | |
2048 | ||
d77de738 | 2049 | @opindex target-help |
ddf6fe37 | 2050 | @item --target-help |
d77de738 ML |
2051 | Print (on the standard output) a description of target-specific command-line |
2052 | options for each tool. For some targets extra target-specific | |
2053 | information may also be printed. | |
2054 | ||
2055 | @item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]} | |
2056 | Print (on the standard output) a description of the command-line | |
2057 | options understood by the compiler that fit into all specified classes | |
2058 | and qualifiers. These are the supported classes: | |
2059 | ||
2060 | @table @asis | |
2061 | @item @samp{optimizers} | |
2062 | Display all of the optimization options supported by the | |
2063 | compiler. | |
2064 | ||
2065 | @item @samp{warnings} | |
2066 | Display all of the options controlling warning messages | |
2067 | produced by the compiler. | |
2068 | ||
2069 | @item @samp{target} | |
2070 | Display target-specific options. Unlike the | |
2071 | @option{--target-help} option however, target-specific options of the | |
2072 | linker and assembler are not displayed. This is because those | |
2073 | tools do not currently support the extended @option{--help=} syntax. | |
2074 | ||
2075 | @item @samp{params} | |
2076 | Display the values recognized by the @option{--param} | |
2077 | option. | |
2078 | ||
2079 | @item @var{language} | |
2080 | Display the options supported for @var{language}, where | |
2081 | @var{language} is the name of one of the languages supported in this | |
2082 | version of GCC@. If an option is supported by all languages, one needs | |
2083 | to select @samp{common} class. | |
2084 | ||
2085 | @item @samp{common} | |
2086 | Display the options that are common to all languages. | |
2087 | @end table | |
2088 | ||
2089 | These are the supported qualifiers: | |
2090 | ||
2091 | @table @asis | |
2092 | @item @samp{undocumented} | |
2093 | Display only those options that are undocumented. | |
2094 | ||
2095 | @item @samp{joined} | |
2096 | Display options taking an argument that appears after an equal | |
2097 | sign in the same continuous piece of text, such as: | |
2098 | @samp{--help=target}. | |
2099 | ||
2100 | @item @samp{separate} | |
2101 | Display options taking an argument that appears as a separate word | |
2102 | following the original option, such as: @samp{-o output-file}. | |
2103 | @end table | |
2104 | ||
2105 | Thus for example to display all the undocumented target-specific | |
2106 | switches supported by the compiler, use: | |
2107 | ||
2108 | @smallexample | |
2109 | --help=target,undocumented | |
2110 | @end smallexample | |
2111 | ||
2112 | The sense of a qualifier can be inverted by prefixing it with the | |
2113 | @samp{^} character, so for example to display all binary warning | |
2114 | options (i.e., ones that are either on or off and that do not take an | |
2115 | argument) that have a description, use: | |
2116 | ||
2117 | @smallexample | |
2118 | --help=warnings,^joined,^undocumented | |
2119 | @end smallexample | |
2120 | ||
2121 | The argument to @option{--help=} should not consist solely of inverted | |
2122 | qualifiers. | |
2123 | ||
2124 | Combining several classes is possible, although this usually | |
2125 | restricts the output so much that there is nothing to display. One | |
2126 | case where it does work, however, is when one of the classes is | |
2127 | @var{target}. For example, to display all the target-specific | |
2128 | optimization options, use: | |
2129 | ||
2130 | @smallexample | |
2131 | --help=target,optimizers | |
2132 | @end smallexample | |
2133 | ||
2134 | The @option{--help=} option can be repeated on the command line. Each | |
2135 | successive use displays its requested class of options, skipping | |
2136 | those that have already been displayed. If @option{--help} is also | |
2137 | specified anywhere on the command line then this takes precedence | |
2138 | over any @option{--help=} option. | |
2139 | ||
2140 | If the @option{-Q} option appears on the command line before the | |
2141 | @option{--help=} option, then the descriptive text displayed by | |
2142 | @option{--help=} is changed. Instead of describing the displayed | |
2143 | options, an indication is given as to whether the option is enabled, | |
2144 | disabled or set to a specific value (assuming that the compiler | |
2145 | knows this at the point where the @option{--help=} option is used). | |
2146 | ||
2147 | Here is a truncated example from the ARM port of @command{gcc}: | |
2148 | ||
2149 | @smallexample | |
2150 | % gcc -Q -mabi=2 --help=target -c | |
2151 | The following options are target specific: | |
2152 | -mabi= 2 | |
2153 | -mabort-on-noreturn [disabled] | |
2154 | -mapcs [disabled] | |
2155 | @end smallexample | |
2156 | ||
2157 | The output is sensitive to the effects of previous command-line | |
2158 | options, so for example it is possible to find out which optimizations | |
2159 | are enabled at @option{-O2} by using: | |
2160 | ||
2161 | @smallexample | |
2162 | -Q -O2 --help=optimizers | |
2163 | @end smallexample | |
2164 | ||
2165 | Alternatively you can discover which binary optimizations are enabled | |
2166 | by @option{-O3} by using: | |
2167 | ||
2168 | @smallexample | |
2169 | gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts | |
2170 | gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts | |
2171 | diff /tmp/O2-opts /tmp/O3-opts | grep enabled | |
2172 | @end smallexample | |
2173 | ||
d77de738 | 2174 | @opindex version |
ddf6fe37 | 2175 | @item --version |
d77de738 ML |
2176 | Display the version number and copyrights of the invoked GCC@. |
2177 | ||
d77de738 | 2178 | @opindex pass-exit-codes |
ddf6fe37 | 2179 | @item -pass-exit-codes |
d77de738 ML |
2180 | Normally the @command{gcc} program exits with the code of 1 if any |
2181 | phase of the compiler returns a non-success return code. If you specify | |
2182 | @option{-pass-exit-codes}, the @command{gcc} program instead returns with | |
2183 | the numerically highest error produced by any phase returning an error | |
2184 | indication. The C, C++, and Fortran front ends return 4 if an internal | |
2185 | compiler error is encountered. | |
2186 | ||
d77de738 | 2187 | @opindex pipe |
ddf6fe37 | 2188 | @item -pipe |
d77de738 ML |
2189 | Use pipes rather than temporary files for communication between the |
2190 | various stages of compilation. This fails to work on some systems where | |
2191 | the assembler is unable to read from a pipe; but the GNU assembler has | |
2192 | no trouble. | |
2193 | ||
d77de738 | 2194 | @opindex specs |
ddf6fe37 | 2195 | @item -specs=@var{file} |
d77de738 ML |
2196 | Process @var{file} after the compiler reads in the standard @file{specs} |
2197 | file, in order to override the defaults which the @command{gcc} driver | |
2198 | program uses when determining what switches to pass to @command{cc1}, | |
2199 | @command{cc1plus}, @command{as}, @command{ld}, etc. More than one | |
2200 | @option{-specs=@var{file}} can be specified on the command line, and they | |
2201 | are processed in order, from left to right. @xref{Spec Files}, for | |
2202 | information about the format of the @var{file}. | |
2203 | ||
d77de738 | 2204 | @opindex wrapper |
ddf6fe37 | 2205 | @item -wrapper |
d77de738 ML |
2206 | Invoke all subcommands under a wrapper program. The name of the |
2207 | wrapper program and its parameters are passed as a comma separated | |
2208 | list. | |
2209 | ||
2210 | @smallexample | |
2211 | gcc -c t.c -wrapper gdb,--args | |
2212 | @end smallexample | |
2213 | ||
2214 | @noindent | |
2215 | This invokes all subprograms of @command{gcc} under | |
2216 | @samp{gdb --args}, thus the invocation of @command{cc1} is | |
2217 | @samp{gdb --args cc1 @dots{}}. | |
2218 | ||
d77de738 | 2219 | @opindex ffile-prefix-map |
ddf6fe37 | 2220 | @item -ffile-prefix-map=@var{old}=@var{new} |
d77de738 ML |
2221 | When compiling files residing in directory @file{@var{old}}, record |
2222 | any references to them in the result of the compilation as if the | |
2223 | files resided in directory @file{@var{new}} instead. Specifying this | |
2224 | option is equivalent to specifying all the individual | |
2225 | @option{-f*-prefix-map} options. This can be used to make reproducible | |
11543b27 | 2226 | builds that are location independent. Directories referenced by |
2eb0191a JJ |
2227 | directives are not affected by these options. See also |
2228 | @option{-fmacro-prefix-map}, @option{-fdebug-prefix-map}, | |
2229 | @option{-fprofile-prefix-map} and @option{-fcanon-prefix-map}. | |
2230 | ||
2eb0191a | 2231 | @opindex fcanon-prefix-map |
e54b01a1 | 2232 | @item -fcanon-prefix-map |
2eb0191a JJ |
2233 | For the @option{-f*-prefix-map} options normally comparison |
2234 | of @file{@var{old}} prefix against the filename that would be normally | |
2235 | referenced in the result of the compilation is done using textual | |
2236 | comparison of the prefixes, or ignoring character case for case insensitive | |
2237 | filesystems and considering slashes and backslashes as equal on DOS based | |
2238 | filesystems. The @option{-fcanon-prefix-map} causes such comparisons | |
2239 | to be done on canonicalized paths of @file{@var{old}} | |
2240 | and the referenced filename. | |
d77de738 | 2241 | |
d77de738 | 2242 | @opindex fplugin |
ddf6fe37 | 2243 | @item -fplugin=@var{name}.so |
d77de738 ML |
2244 | Load the plugin code in file @var{name}.so, assumed to be a |
2245 | shared object to be dlopen'd by the compiler. The base name of | |
2246 | the shared object file is used to identify the plugin for the | |
2247 | purposes of argument parsing (See | |
2248 | @option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below). | |
2249 | Each plugin should define the callback functions specified in the | |
2250 | Plugins API. | |
2251 | ||
d77de738 | 2252 | @opindex fplugin-arg |
ddf6fe37 | 2253 | @item -fplugin-arg-@var{name}-@var{key}=@var{value} |
d77de738 ML |
2254 | Define an argument called @var{key} with a value of @var{value} |
2255 | for the plugin called @var{name}. | |
2256 | ||
d77de738 | 2257 | @opindex fdump-ada-spec |
ddf6fe37 | 2258 | @item -fdump-ada-spec@r{[}-slim@r{]} |
d77de738 ML |
2259 | For C and C++ source and include files, generate corresponding Ada specs. |
2260 | @xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn, | |
2261 | GNAT User's Guide}, which provides detailed documentation on this feature. | |
2262 | ||
d77de738 | 2263 | @opindex fada-spec-parent |
ddf6fe37 | 2264 | @item -fada-spec-parent=@var{unit} |
d77de738 ML |
2265 | In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate |
2266 | Ada specs as child units of parent @var{unit}. | |
2267 | ||
d77de738 | 2268 | @opindex fdump-go-spec |
ddf6fe37 | 2269 | @item -fdump-go-spec=@var{file} |
d77de738 ML |
2270 | For input files in any language, generate corresponding Go |
2271 | declarations in @var{file}. This generates Go @code{const}, | |
2272 | @code{type}, @code{var}, and @code{func} declarations which may be a | |
2273 | useful way to start writing a Go interface to code written in some | |
2274 | other language. | |
2275 | ||
2276 | @include @value{srcdir}/../libiberty/at-file.texi | |
2277 | @end table | |
2278 | ||
2279 | @node Invoking G++ | |
2280 | @section Compiling C++ Programs | |
2281 | ||
2282 | @cindex suffixes for C++ source | |
2283 | @cindex C++ source file suffixes | |
2284 | C++ source files conventionally use one of the suffixes @samp{.C}, | |
2285 | @samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or | |
2286 | @samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp}, | |
2287 | @samp{.H}, or (for shared template code) @samp{.tcc}; and | |
2288 | preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes | |
2289 | files with these names and compiles them as C++ programs even if you | |
2290 | call the compiler the same way as for compiling C programs (usually | |
2291 | with the name @command{gcc}). | |
2292 | ||
2293 | @findex g++ | |
2294 | @findex c++ | |
2295 | However, the use of @command{gcc} does not add the C++ library. | |
2296 | @command{g++} is a program that calls GCC and automatically specifies linking | |
2297 | against the C++ library. It treats @samp{.c}, | |
2298 | @samp{.h} and @samp{.i} files as C++ source files instead of C source | |
2299 | files unless @option{-x} is used. This program is also useful when | |
2300 | precompiling a C header file with a @samp{.h} extension for use in C++ | |
2301 | compilations. On many systems, @command{g++} is also installed with | |
2302 | the name @command{c++}. | |
2303 | ||
2304 | @cindex invoking @command{g++} | |
2305 | When you compile C++ programs, you may specify many of the same | |
2306 | command-line options that you use for compiling programs in any | |
2307 | language; or command-line options meaningful for C and related | |
2308 | languages; or options that are meaningful only for C++ programs. | |
2309 | @xref{C Dialect Options,,Options Controlling C Dialect}, for | |
2310 | explanations of options for languages related to C@. | |
2311 | @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for | |
2312 | explanations of options that are meaningful only for C++ programs. | |
2313 | ||
2314 | @node C Dialect Options | |
2315 | @section Options Controlling C Dialect | |
2316 | @cindex dialect options | |
2317 | @cindex language dialect options | |
2318 | @cindex options, dialect | |
2319 | ||
2320 | The following options control the dialect of C (or languages derived | |
2321 | from C, such as C++, Objective-C and Objective-C++) that the compiler | |
2322 | accepts: | |
2323 | ||
2324 | @table @gcctabopt | |
2325 | @cindex ANSI support | |
2326 | @cindex ISO support | |
d77de738 | 2327 | @opindex ansi |
ddf6fe37 | 2328 | @item -ansi |
d77de738 ML |
2329 | In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is |
2330 | equivalent to @option{-std=c++98}. | |
2331 | ||
2332 | This turns off certain features of GCC that are incompatible with ISO | |
2333 | C90 (when compiling C code), or of standard C++ (when compiling C++ code), | |
2334 | such as the @code{asm} and @code{typeof} keywords, and | |
2335 | predefined macros such as @code{unix} and @code{vax} that identify the | |
2336 | type of system you are using. It also enables the undesirable and | |
2337 | rarely used ISO trigraph feature. For the C compiler, | |
2338 | it disables recognition of C++ style @samp{//} comments as well as | |
2339 | the @code{inline} keyword. | |
2340 | ||
2341 | The alternate keywords @code{__asm__}, @code{__extension__}, | |
2342 | @code{__inline__} and @code{__typeof__} continue to work despite | |
2343 | @option{-ansi}. You would not want to use them in an ISO C program, of | |
2344 | course, but it is useful to put them in header files that might be included | |
2345 | in compilations done with @option{-ansi}. Alternate predefined macros | |
2346 | such as @code{__unix__} and @code{__vax__} are also available, with or | |
2347 | without @option{-ansi}. | |
2348 | ||
2349 | The @option{-ansi} option does not cause non-ISO programs to be | |
2350 | rejected gratuitously. For that, @option{-Wpedantic} is required in | |
2351 | addition to @option{-ansi}. @xref{Warning Options}. | |
2352 | ||
2353 | The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi} | |
2354 | option is used. Some header files may notice this macro and refrain | |
2355 | from declaring certain functions or defining certain macros that the | |
2356 | ISO standard doesn't call for; this is to avoid interfering with any | |
2357 | programs that might use these names for other things. | |
2358 | ||
2359 | Functions that are normally built in but do not have semantics | |
2360 | defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in | |
2361 | functions when @option{-ansi} is used. @xref{Other Builtins,,Other | |
2362 | built-in functions provided by GCC}, for details of the functions | |
2363 | affected. | |
2364 | ||
d77de738 | 2365 | @opindex std |
ddf6fe37 | 2366 | @item -std= |
d77de738 ML |
2367 | Determine the language standard. @xref{Standards,,Language Standards |
2368 | Supported by GCC}, for details of these standard versions. This option | |
2369 | is currently only supported when compiling C or C++. | |
2370 | ||
2371 | The compiler can accept several base standards, such as @samp{c90} or | |
2372 | @samp{c++98}, and GNU dialects of those standards, such as | |
2373 | @samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the | |
2374 | compiler accepts all programs following that standard plus those | |
2375 | using GNU extensions that do not contradict it. For example, | |
2376 | @option{-std=c90} turns off certain features of GCC that are | |
2377 | incompatible with ISO C90, such as the @code{asm} and @code{typeof} | |
2378 | keywords, but not other GNU extensions that do not have a meaning in | |
2379 | ISO C90, such as omitting the middle term of a @code{?:} | |
2380 | expression. On the other hand, when a GNU dialect of a standard is | |
2381 | specified, all features supported by the compiler are enabled, even when | |
2382 | those features change the meaning of the base standard. As a result, some | |
2383 | strict-conforming programs may be rejected. The particular standard | |
2384 | is used by @option{-Wpedantic} to identify which features are GNU | |
2385 | extensions given that version of the standard. For example | |
2386 | @option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//} | |
2387 | comments, while @option{-std=gnu99 -Wpedantic} does not. | |
2388 | ||
2389 | A value for this option must be provided; possible values are | |
2390 | ||
2391 | @table @samp | |
2392 | @item c90 | |
2393 | @itemx c89 | |
2394 | @itemx iso9899:1990 | |
2395 | Support all ISO C90 programs (certain GNU extensions that conflict | |
2396 | with ISO C90 are disabled). Same as @option{-ansi} for C code. | |
2397 | ||
2398 | @item iso9899:199409 | |
2399 | ISO C90 as modified in amendment 1. | |
2400 | ||
2401 | @item c99 | |
2402 | @itemx c9x | |
2403 | @itemx iso9899:1999 | |
2404 | @itemx iso9899:199x | |
2405 | ISO C99. This standard is substantially completely supported, modulo | |
2406 | bugs and floating-point issues | |
2407 | (mainly but not entirely relating to optional C99 features from | |
2408 | Annexes F and G). See | |
2409 | @w{@uref{https://gcc.gnu.org/c99status.html}} for more information. The | |
2410 | names @samp{c9x} and @samp{iso9899:199x} are deprecated. | |
2411 | ||
2412 | @item c11 | |
2413 | @itemx c1x | |
2414 | @itemx iso9899:2011 | |
2415 | ISO C11, the 2011 revision of the ISO C standard. This standard is | |
2416 | substantially completely supported, modulo bugs, floating-point issues | |
2417 | (mainly but not entirely relating to optional C11 features from | |
2418 | Annexes F and G) and the optional Annexes K (Bounds-checking | |
2419 | interfaces) and L (Analyzability). The name @samp{c1x} is deprecated. | |
2420 | ||
2421 | @item c17 | |
2422 | @itemx c18 | |
2423 | @itemx iso9899:2017 | |
2424 | @itemx iso9899:2018 | |
2425 | ISO C17, the 2017 revision of the ISO C standard | |
2426 | (published in 2018). This standard is | |
2427 | same as C11 except for corrections of defects (all of which are also | |
2428 | applied with @option{-std=c11}) and a new value of | |
2429 | @code{__STDC_VERSION__}, and so is supported to the same extent as C11. | |
2430 | ||
2431 | @item c2x | |
2432 | The next version of the ISO C standard, still under development. The | |
2433 | support for this version is experimental and incomplete. | |
2434 | ||
2435 | @item gnu90 | |
2436 | @itemx gnu89 | |
2437 | GNU dialect of ISO C90 (including some C99 features). | |
2438 | ||
2439 | @item gnu99 | |
2440 | @itemx gnu9x | |
2441 | GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated. | |
2442 | ||
2443 | @item gnu11 | |
2444 | @itemx gnu1x | |
2445 | GNU dialect of ISO C11. | |
2446 | The name @samp{gnu1x} is deprecated. | |
2447 | ||
2448 | @item gnu17 | |
2449 | @itemx gnu18 | |
2450 | GNU dialect of ISO C17. This is the default for C code. | |
2451 | ||
2452 | @item gnu2x | |
2453 | The next version of the ISO C standard, still under development, plus | |
2454 | GNU extensions. The support for this version is experimental and | |
2455 | incomplete. | |
2456 | ||
2457 | @item c++98 | |
2458 | @itemx c++03 | |
2459 | The 1998 ISO C++ standard plus the 2003 technical corrigendum and some | |
2460 | additional defect reports. Same as @option{-ansi} for C++ code. | |
2461 | ||
2462 | @item gnu++98 | |
2463 | @itemx gnu++03 | |
2464 | GNU dialect of @option{-std=c++98}. | |
2465 | ||
2466 | @item c++11 | |
2467 | @itemx c++0x | |
2468 | The 2011 ISO C++ standard plus amendments. | |
2469 | The name @samp{c++0x} is deprecated. | |
2470 | ||
2471 | @item gnu++11 | |
2472 | @itemx gnu++0x | |
2473 | GNU dialect of @option{-std=c++11}. | |
2474 | The name @samp{gnu++0x} is deprecated. | |
2475 | ||
2476 | @item c++14 | |
2477 | @itemx c++1y | |
2478 | The 2014 ISO C++ standard plus amendments. | |
2479 | The name @samp{c++1y} is deprecated. | |
2480 | ||
2481 | @item gnu++14 | |
2482 | @itemx gnu++1y | |
2483 | GNU dialect of @option{-std=c++14}. | |
2484 | The name @samp{gnu++1y} is deprecated. | |
2485 | ||
2486 | @item c++17 | |
2487 | @itemx c++1z | |
2488 | The 2017 ISO C++ standard plus amendments. | |
2489 | The name @samp{c++1z} is deprecated. | |
2490 | ||
2491 | @item gnu++17 | |
2492 | @itemx gnu++1z | |
2493 | GNU dialect of @option{-std=c++17}. | |
2494 | This is the default for C++ code. | |
2495 | The name @samp{gnu++1z} is deprecated. | |
2496 | ||
2497 | @item c++20 | |
2498 | @itemx c++2a | |
2499 | The 2020 ISO C++ standard plus amendments. | |
2500 | Support is experimental, and could change in incompatible ways in | |
2501 | future releases. | |
2502 | The name @samp{c++2a} is deprecated. | |
2503 | ||
2504 | @item gnu++20 | |
2505 | @itemx gnu++2a | |
2506 | GNU dialect of @option{-std=c++20}. | |
2507 | Support is experimental, and could change in incompatible ways in | |
2508 | future releases. | |
2509 | The name @samp{gnu++2a} is deprecated. | |
2510 | ||
2511 | @item c++2b | |
2512 | @itemx c++23 | |
2513 | The next revision of the ISO C++ standard, planned for | |
2514 | 2023. Support is highly experimental, and will almost certainly | |
2515 | change in incompatible ways in future releases. | |
2516 | ||
2517 | @item gnu++2b | |
2518 | @itemx gnu++23 | |
2519 | GNU dialect of @option{-std=c++2b}. Support is highly experimental, | |
2520 | and will almost certainly change in incompatible ways in future | |
2521 | releases. | |
5388a43f MP |
2522 | |
2523 | @item c++2c | |
2524 | @itemx c++26 | |
2525 | The next revision of the ISO C++ standard, planned for | |
2526 | 2026. Support is highly experimental, and will almost certainly | |
2527 | change in incompatible ways in future releases. | |
2528 | ||
2529 | @item gnu++2c | |
2530 | @itemx gnu++26 | |
2531 | GNU dialect of @option{-std=c++2c}. Support is highly experimental, | |
2532 | and will almost certainly change in incompatible ways in future | |
2533 | releases. | |
d77de738 ML |
2534 | @end table |
2535 | ||
d77de738 | 2536 | @opindex aux-info |
ddf6fe37 | 2537 | @item -aux-info @var{filename} |
d77de738 ML |
2538 | Output to the given filename prototyped declarations for all functions |
2539 | declared and/or defined in a translation unit, including those in header | |
2540 | files. This option is silently ignored in any language other than C@. | |
2541 | ||
2542 | Besides declarations, the file indicates, in comments, the origin of | |
2543 | each declaration (source file and line), whether the declaration was | |
2544 | implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or | |
2545 | @samp{O} for old, respectively, in the first character after the line | |
2546 | number and the colon), and whether it came from a declaration or a | |
2547 | definition (@samp{C} or @samp{F}, respectively, in the following | |
2548 | character). In the case of function definitions, a K&R-style list of | |
2549 | arguments followed by their declarations is also provided, inside | |
2550 | comments, after the declaration. | |
2551 | ||
d77de738 ML |
2552 | @opindex fno-asm |
2553 | @opindex fasm | |
ddf6fe37 | 2554 | @item -fno-asm |
d77de738 ML |
2555 | Do not recognize @code{asm}, @code{inline} or @code{typeof} as a |
2556 | keyword, so that code can use these words as identifiers. You can use | |
2557 | the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__} | |
2558 | instead. In C, @option{-ansi} implies @option{-fno-asm}. | |
2559 | ||
2560 | In C++, @code{inline} is a standard keyword and is not affected by | |
2561 | this switch. You may want to use the @option{-fno-gnu-keywords} flag | |
2562 | instead, which disables @code{typeof} but not @code{asm} and | |
2563 | @code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}), | |
2564 | this switch only affects the @code{asm} and @code{typeof} keywords, | |
2565 | since @code{inline} is a standard keyword in ISO C99. In C2X mode | |
2566 | (@option{-std=c2x} or @option{-std=gnu2x}), this switch only affects | |
2567 | the @code{asm} keyword, since @code{typeof} is a standard keyword in | |
2568 | ISO C2X. | |
2569 | ||
d77de738 ML |
2570 | @opindex fno-builtin |
2571 | @opindex fbuiltin | |
f33d7a88 | 2572 | @cindex built-in functions |
ddf6fe37 AA |
2573 | @item -fno-builtin |
2574 | @itemx -fno-builtin-@var{function} | |
d77de738 ML |
2575 | Don't recognize built-in functions that do not begin with |
2576 | @samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in | |
2577 | functions provided by GCC}, for details of the functions affected, | |
2578 | including those which are not built-in functions when @option{-ansi} or | |
2579 | @option{-std} options for strict ISO C conformance are used because they | |
2580 | do not have an ISO standard meaning. | |
2581 | ||
2582 | GCC normally generates special code to handle certain built-in functions | |
2583 | more efficiently; for instance, calls to @code{alloca} may become single | |
2584 | instructions which adjust the stack directly, and calls to @code{memcpy} | |
2585 | may become inline copy loops. The resulting code is often both smaller | |
2586 | and faster, but since the function calls no longer appear as such, you | |
2587 | cannot set a breakpoint on those calls, nor can you change the behavior | |
2588 | of the functions by linking with a different library. In addition, | |
2589 | when a function is recognized as a built-in function, GCC may use | |
2590 | information about that function to warn about problems with calls to | |
2591 | that function, or to generate more efficient code, even if the | |
2592 | resulting code still contains calls to that function. For example, | |
2593 | warnings are given with @option{-Wformat} for bad calls to | |
2594 | @code{printf} when @code{printf} is built in and @code{strlen} is | |
2595 | known not to modify global memory. | |
2596 | ||
2597 | With the @option{-fno-builtin-@var{function}} option | |
2598 | only the built-in function @var{function} is | |
2599 | disabled. @var{function} must not begin with @samp{__builtin_}. If a | |
2600 | function is named that is not built-in in this version of GCC, this | |
2601 | option is ignored. There is no corresponding | |
2602 | @option{-fbuiltin-@var{function}} option; if you wish to enable | |
2603 | built-in functions selectively when using @option{-fno-builtin} or | |
2604 | @option{-ffreestanding}, you may define macros such as: | |
2605 | ||
2606 | @smallexample | |
2607 | #define abs(n) __builtin_abs ((n)) | |
2608 | #define strcpy(d, s) __builtin_strcpy ((d), (s)) | |
2609 | @end smallexample | |
2610 | ||
d77de738 | 2611 | @opindex fcond-mismatch |
ddf6fe37 | 2612 | @item -fcond-mismatch |
d77de738 ML |
2613 | Allow conditional expressions with mismatched types in the second and |
2614 | third arguments. The value of such an expression is void. This option | |
2615 | is not supported for C++. | |
2616 | ||
d77de738 ML |
2617 | @opindex ffreestanding |
2618 | @cindex hosted environment | |
f33d7a88 | 2619 | @item -ffreestanding |
d77de738 ML |
2620 | |
2621 | Assert that compilation targets a freestanding environment. This | |
2622 | implies @option{-fno-builtin}. A freestanding environment | |
2623 | is one in which the standard library may not exist, and program startup may | |
2624 | not necessarily be at @code{main}. The most obvious example is an OS kernel. | |
2625 | This is equivalent to @option{-fno-hosted}. | |
2626 | ||
2627 | @xref{Standards,,Language Standards Supported by GCC}, for details of | |
2628 | freestanding and hosted environments. | |
2629 | ||
d77de738 | 2630 | @opindex fgimple |
ddf6fe37 | 2631 | @item -fgimple |
d77de738 ML |
2632 | |
2633 | Enable parsing of function definitions marked with @code{__GIMPLE}. | |
2634 | This is an experimental feature that allows unit testing of GIMPLE | |
2635 | passes. | |
2636 | ||
d77de738 | 2637 | @opindex fgnu-tm |
ddf6fe37 | 2638 | @item -fgnu-tm |
d77de738 ML |
2639 | When the option @option{-fgnu-tm} is specified, the compiler |
2640 | generates code for the Linux variant of Intel's current Transactional | |
2641 | Memory ABI specification document (Revision 1.1, May 6 2009). This is | |
2642 | an experimental feature whose interface may change in future versions | |
2643 | of GCC, as the official specification changes. Please note that not | |
2644 | all architectures are supported for this feature. | |
2645 | ||
2646 | For more information on GCC's support for transactional memory, | |
2647 | @xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU | |
2648 | Transactional Memory Library}. | |
2649 | ||
2650 | Note that the transactional memory feature is not supported with | |
2651 | non-call exceptions (@option{-fnon-call-exceptions}). | |
2652 | ||
d77de738 | 2653 | @opindex fgnu89-inline |
ddf6fe37 | 2654 | @item -fgnu89-inline |
d77de738 ML |
2655 | The option @option{-fgnu89-inline} tells GCC to use the traditional |
2656 | GNU semantics for @code{inline} functions when in C99 mode. | |
2657 | @xref{Inline,,An Inline Function is As Fast As a Macro}. | |
2658 | Using this option is roughly equivalent to adding the | |
2659 | @code{gnu_inline} function attribute to all inline functions | |
2660 | (@pxref{Function Attributes}). | |
2661 | ||
2662 | The option @option{-fno-gnu89-inline} explicitly tells GCC to use the | |
2663 | C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it | |
2664 | specifies the default behavior). | |
2665 | This option is not supported in @option{-std=c90} or | |
2666 | @option{-std=gnu90} mode. | |
2667 | ||
2668 | The preprocessor macros @code{__GNUC_GNU_INLINE__} and | |
2669 | @code{__GNUC_STDC_INLINE__} may be used to check which semantics are | |
2670 | in effect for @code{inline} functions. @xref{Common Predefined | |
2671 | Macros,,,cpp,The C Preprocessor}. | |
2672 | ||
d77de738 ML |
2673 | @opindex fhosted |
2674 | @cindex hosted environment | |
f33d7a88 | 2675 | @item -fhosted |
d77de738 ML |
2676 | |
2677 | Assert that compilation targets a hosted environment. This implies | |
2678 | @option{-fbuiltin}. A hosted environment is one in which the | |
2679 | entire standard library is available, and in which @code{main} has a return | |
2680 | type of @code{int}. Examples are nearly everything except a kernel. | |
2681 | This is equivalent to @option{-fno-freestanding}. | |
2682 | ||
d77de738 | 2683 | @opindex flax-vector-conversions |
ddf6fe37 | 2684 | @item -flax-vector-conversions |
d77de738 ML |
2685 | Allow implicit conversions between vectors with differing numbers of |
2686 | elements and/or incompatible element types. This option should not be | |
2687 | used for new code. | |
2688 | ||
d77de738 | 2689 | @opindex fms-extensions |
ddf6fe37 | 2690 | @item -fms-extensions |
d77de738 ML |
2691 | Accept some non-standard constructs used in Microsoft header files. |
2692 | ||
2693 | In C++ code, this allows member names in structures to be similar | |
2694 | to previous types declarations. | |
2695 | ||
2696 | @smallexample | |
2697 | typedef int UOW; | |
2698 | struct ABC @{ | |
2699 | UOW UOW; | |
2700 | @}; | |
2701 | @end smallexample | |
2702 | ||
2703 | Some cases of unnamed fields in structures and unions are only | |
2704 | accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union | |
2705 | fields within structs/unions}, for details. | |
2706 | ||
2707 | Note that this option is off for all targets except for x86 | |
2708 | targets using ms-abi. | |
2709 | ||
ddf6fe37 | 2710 | @opindex foffload |
d77de738 ML |
2711 | @cindex Offloading targets |
2712 | @cindex OpenACC offloading targets | |
2713 | @cindex OpenMP offloading targets | |
f33d7a88 AA |
2714 | @item -foffload=disable |
2715 | @itemx -foffload=default | |
2716 | @itemx -foffload=@var{target-list} | |
d77de738 ML |
2717 | Specify for which OpenMP and OpenACC offload targets code should be generated. |
2718 | The default behavior, equivalent to @option{-foffload=default}, is to generate | |
2719 | code for all supported offload targets. The @option{-foffload=disable} form | |
2720 | generates code only for the host fallback, while | |
2721 | @option{-foffload=@var{target-list}} generates code only for the specified | |
2722 | comma-separated list of offload targets. | |
2723 | ||
2724 | Offload targets are specified in GCC's internal target-triplet format. You can | |
2725 | run the compiler with @option{-v} to show the list of configured offload targets | |
2726 | under @code{OFFLOAD_TARGET_NAMES}. | |
2727 | ||
ddf6fe37 | 2728 | @opindex foffload-options |
d77de738 ML |
2729 | @cindex Offloading options |
2730 | @cindex OpenACC offloading options | |
2731 | @cindex OpenMP offloading options | |
f33d7a88 AA |
2732 | @item -foffload-options=@var{options} |
2733 | @itemx -foffload-options=@var{target-triplet-list}=@var{options} | |
d77de738 ML |
2734 | |
2735 | With @option{-foffload-options=@var{options}}, GCC passes the specified | |
2736 | @var{options} to the compilers for all enabled offloading targets. You can | |
2737 | specify options that apply only to a specific target or targets by using | |
2738 | the @option{-foffload-options=@var{target-list}=@var{options}} form. The | |
2739 | @var{target-list} is a comma-separated list in the same format as for the | |
2740 | @option{-foffload=} option. | |
2741 | ||
2742 | Typical command lines are | |
2743 | ||
2744 | @smallexample | |
4bcb46b3 | 2745 | -foffload-options='-fno-math-errno -ffinite-math-only' -foffload-options=nvptx-none=-latomic |
e9c1679c | 2746 | -foffload-options=amdgcn-amdhsa=-march=gfx906 |
d77de738 ML |
2747 | @end smallexample |
2748 | ||
d77de738 ML |
2749 | @opindex fopenacc |
2750 | @cindex OpenACC accelerator programming | |
f33d7a88 | 2751 | @item -fopenacc |
643a5223 TB |
2752 | Enable handling of OpenACC directives @samp{#pragma acc} in C/C++ and |
2753 | @samp{!$acc} in free-form Fortran and @samp{!$acc}, @samp{c$acc} and | |
2754 | @samp{*$acc} in fixed-form Fortran. When @option{-fopenacc} is specified, | |
2755 | the compiler generates accelerated code according to the OpenACC Application | |
d77de738 ML |
2756 | Programming Interface v2.6 @w{@uref{https://www.openacc.org}}. This option |
2757 | implies @option{-pthread}, and thus is only supported on targets that | |
2758 | have support for @option{-pthread}. | |
2759 | ||
d77de738 ML |
2760 | @opindex fopenacc-dim |
2761 | @cindex OpenACC accelerator programming | |
f33d7a88 | 2762 | @item -fopenacc-dim=@var{geom} |
d77de738 ML |
2763 | Specify default compute dimensions for parallel offload regions that do |
2764 | not explicitly specify. The @var{geom} value is a triple of | |
2765 | ':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size | |
2766 | can be omitted, to use a target-specific default value. | |
2767 | ||
d77de738 ML |
2768 | @opindex fopenmp |
2769 | @cindex OpenMP parallel | |
f33d7a88 | 2770 | @item -fopenmp |
643a5223 TB |
2771 | Enable handling of OpenMP directives @samp{#pragma omp} in C/C++, |
2772 | @samp{[[omp::directive(...)]]}, @samp{[[omp::sequence(...)]]} and | |
2773 | @samp{[[omp::decl(...)]]} in C++ and @samp{!$omp} in Fortran. It | |
2774 | additionally enables the conditional compilation sentinel @samp{!$} in | |
2775 | Fortran. In fixed source form Fortran, the sentinels can also start with | |
2776 | @samp{c} or @samp{*}. When @option{-fopenmp} is specified, the | |
d77de738 ML |
2777 | compiler generates parallel code according to the OpenMP Application |
2778 | Program Interface v4.5 @w{@uref{https://www.openmp.org}}. This option | |
2779 | implies @option{-pthread}, and thus is only supported on targets that | |
2780 | have support for @option{-pthread}. @option{-fopenmp} implies | |
2781 | @option{-fopenmp-simd}. | |
2782 | ||
d77de738 ML |
2783 | @opindex fopenmp-simd |
2784 | @cindex OpenMP SIMD | |
2785 | @cindex SIMD | |
f33d7a88 | 2786 | @item -fopenmp-simd |
d77de738 | 2787 | Enable handling of OpenMP's @code{simd}, @code{declare simd}, |
1fab441d TB |
2788 | @code{declare reduction}, @code{assume}, @code{ordered}, @code{scan} |
2789 | and @code{loop} directive, and of combined or composite directives with | |
d77de738 | 2790 | @code{simd} as constituent with @code{#pragma omp} in C/C++, |
1fab441d | 2791 | @code{[[omp::directive(...)]]}, @code{[[omp::sequence(...)]]} and |
643a5223 TB |
2792 | @code{[[omp::decl(...)]]} in C++ and @code{!$omp} in Fortran. It |
2793 | additionally enables the conditional compilation sentinel @samp{!$} in | |
2794 | Fortran. In fixed source form Fortran, the sentinels can also start with | |
2795 | @samp{c} or @samp{*}. Other OpenMP directives are ignored. Unless | |
2796 | @option{-fopenmp} is additionally specified, the @code{loop} region binds | |
2797 | to the current task region, independent of the specified @code{bind} clause. | |
d77de738 | 2798 | |
ddf6fe37 | 2799 | @opindex fopenmp-target-simd-clone |
f33d7a88 | 2800 | @cindex OpenMP target SIMD clone |
309e2d95 SL |
2801 | @item -fopenmp-target-simd-clone |
2802 | @item -fopenmp-target-simd-clone=@var{device-type} | |
309e2d95 SL |
2803 | In addition to generating SIMD clones for functions marked with the |
2804 | @code{declare simd} directive, GCC also generates clones | |
2805 | for functions marked with the OpenMP @code{declare target} directive | |
2806 | that are suitable for vectorization when this option is in effect. The | |
2807 | @var{device-type} may be one of @code{none}, @code{host}, @code{nohost}, | |
2808 | and @code{any}, which correspond to keywords for the @code{device_type} | |
2809 | clause of the @code{declare target} directive; clones are generated for | |
2810 | the intersection of devices specified. | |
2811 | @option{-fopenmp-target-simd-clone} is equivalent to | |
2812 | @option{-fopenmp-target-simd-clone=any} and | |
2813 | @option{-fno-openmp-target-simd-clone} is equivalent to | |
2814 | @option{-fopenmp-target-simd-clone=none}. | |
2815 | ||
2816 | At @option{-O2} and higher (but not @option{-Os} or @option{-Og}) this | |
2817 | optimization defaults to @option{-fopenmp-target-simd-clone=nohost}; otherwise | |
2818 | it is disabled by default. | |
2819 | ||
d77de738 ML |
2820 | @opindex fpermitted-flt-eval-methods |
2821 | @opindex fpermitted-flt-eval-methods=c11 | |
2822 | @opindex fpermitted-flt-eval-methods=ts-18661-3 | |
ddf6fe37 | 2823 | @item -fpermitted-flt-eval-methods=@var{style} |
d77de738 ML |
2824 | ISO/IEC TS 18661-3 defines new permissible values for |
2825 | @code{FLT_EVAL_METHOD} that indicate that operations and constants with | |
2826 | a semantic type that is an interchange or extended format should be | |
2827 | evaluated to the precision and range of that type. These new values are | |
2828 | a superset of those permitted under C99/C11, which does not specify the | |
2829 | meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code | |
2830 | conforming to C11 may not have been written expecting the possibility of | |
2831 | the new values. | |
2832 | ||
2833 | @option{-fpermitted-flt-eval-methods} specifies whether the compiler | |
2834 | should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11, | |
2835 | or the extended set of values specified in ISO/IEC TS 18661-3. | |
2836 | ||
2837 | @var{style} is either @code{c11} or @code{ts-18661-3} as appropriate. | |
2838 | ||
2839 | The default when in a standards compliant mode (@option{-std=c11} or similar) | |
2840 | is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU | |
2841 | dialect (@option{-std=gnu11} or similar) is | |
2842 | @option{-fpermitted-flt-eval-methods=ts-18661-3}. | |
2843 | ||
024f135a BB |
2844 | @opindex fdeps- |
2845 | The @samp{-fdeps-*} options are used to extract structured dependency | |
2846 | information for a source. This involves determining what resources provided by | |
2847 | other source files will be required to compile the source as well as what | |
2848 | resources are provided by the source. This information can be used to add | |
2849 | required dependencies between compilation rules of dependent sources based on | |
2850 | their contents rather than requiring such information be reflected within the | |
2851 | build tools as well. | |
2852 | ||
2853 | @opindex fdeps-file | |
2854 | @item -fdeps-file=@var{file} | |
2855 | Where to write structured dependency information. | |
2856 | ||
2857 | @opindex fdeps-format | |
2858 | @item -fdeps-format=@var{format} | |
2859 | The format to use for structured dependency information. @samp{p1689r5} is the | |
2860 | only supported format right now. Note that when this argument is specified, the | |
2861 | output of @samp{-MF} is stripped of some information (namely C++ modules) so | |
2862 | that it does not use extended makefile syntax not understood by most tools. | |
2863 | ||
2864 | @opindex fdeps-target | |
2865 | @item -fdeps-target=@var{file} | |
2866 | Analogous to @option{-MT} but for structured dependency information. This | |
2867 | indicates the target which will ultimately need any required resources and | |
2868 | provide any resources extracted from the source that may be required by other | |
2869 | sources. | |
2870 | ||
d77de738 | 2871 | @opindex fplan9-extensions |
ddf6fe37 | 2872 | @item -fplan9-extensions |
d77de738 ML |
2873 | Accept some non-standard constructs used in Plan 9 code. |
2874 | ||
2875 | This enables @option{-fms-extensions}, permits passing pointers to | |
2876 | structures with anonymous fields to functions that expect pointers to | |
2877 | elements of the type of the field, and permits referring to anonymous | |
2878 | fields declared using a typedef. @xref{Unnamed Fields,,Unnamed | |
2879 | struct/union fields within structs/unions}, for details. This is only | |
2880 | supported for C, not C++. | |
2881 | ||
d77de738 ML |
2882 | @opindex fsigned-bitfields |
2883 | @opindex funsigned-bitfields | |
2884 | @opindex fno-signed-bitfields | |
2885 | @opindex fno-unsigned-bitfields | |
ddf6fe37 AA |
2886 | @item -fsigned-bitfields |
2887 | @itemx -funsigned-bitfields | |
2888 | @itemx -fno-signed-bitfields | |
2889 | @itemx -fno-unsigned-bitfields | |
d77de738 ML |
2890 | These options control whether a bit-field is signed or unsigned, when the |
2891 | declaration does not use either @code{signed} or @code{unsigned}. By | |
2892 | default, such a bit-field is signed, because this is consistent: the | |
2893 | basic integer types such as @code{int} are signed types. | |
2894 | ||
d77de738 | 2895 | @opindex fsigned-char |
ddf6fe37 | 2896 | @item -fsigned-char |
d77de738 ML |
2897 | Let the type @code{char} be signed, like @code{signed char}. |
2898 | ||
2899 | Note that this is equivalent to @option{-fno-unsigned-char}, which is | |
2900 | the negative form of @option{-funsigned-char}. Likewise, the option | |
2901 | @option{-fno-signed-char} is equivalent to @option{-funsigned-char}. | |
2902 | ||
d77de738 | 2903 | @opindex funsigned-char |
ddf6fe37 | 2904 | @item -funsigned-char |
d77de738 ML |
2905 | Let the type @code{char} be unsigned, like @code{unsigned char}. |
2906 | ||
2907 | Each kind of machine has a default for what @code{char} should | |
2908 | be. It is either like @code{unsigned char} by default or like | |
2909 | @code{signed char} by default. | |
2910 | ||
2911 | Ideally, a portable program should always use @code{signed char} or | |
2912 | @code{unsigned char} when it depends on the signedness of an object. | |
2913 | But many programs have been written to use plain @code{char} and | |
2914 | expect it to be signed, or expect it to be unsigned, depending on the | |
2915 | machines they were written for. This option, and its inverse, let you | |
2916 | make such a program work with the opposite default. | |
2917 | ||
2918 | The type @code{char} is always a distinct type from each of | |
2919 | @code{signed char} or @code{unsigned char}, even though its behavior | |
2920 | is always just like one of those two. | |
2921 | ||
d77de738 ML |
2922 | @opindex fstrict-flex-arrays |
2923 | @opindex fno-strict-flex-arrays | |
ddf6fe37 | 2924 | @item -fstrict-flex-arrays |
d77de738 ML |
2925 | Control when to treat the trailing array of a structure as a flexible array |
2926 | member for the purpose of accessing the elements of such an array. | |
2927 | The positive form is equivalent to @option{-fstrict-flex-arrays=3}, which is the | |
2928 | strictest. A trailing array is treated as a flexible array member only when it | |
2929 | is declared as a flexible array member per C99 standard onwards. | |
2930 | The negative form is equivalent to @option{-fstrict-flex-arrays=0}, which is the | |
2931 | least strict. All trailing arrays of structures are treated as flexible array | |
2932 | members. | |
2933 | ||
d77de738 | 2934 | @opindex fstrict-flex-arrays=@var{level} |
ddf6fe37 | 2935 | @item -fstrict-flex-arrays=@var{level} |
d77de738 ML |
2936 | Control when to treat the trailing array of a structure as a flexible array |
2937 | member for the purpose of accessing the elements of such an array. The value | |
2938 | of @var{level} controls the level of strictness. | |
2939 | ||
2940 | The possible values of @var{level} are the same as for the | |
2941 | @code{strict_flex_array} attribute (@pxref{Variable Attributes}). | |
2942 | ||
2943 | You can control this behavior for a specific trailing array field of a | |
2944 | structure by using the variable attribute @code{strict_flex_array} attribute | |
2945 | (@pxref{Variable Attributes}). | |
2946 | ||
d77de738 | 2947 | @opindex fsso-struct |
ddf6fe37 | 2948 | @item -fsso-struct=@var{endianness} |
d77de738 ML |
2949 | Set the default scalar storage order of structures and unions to the |
2950 | specified endianness. The accepted values are @samp{big-endian}, | |
2951 | @samp{little-endian} and @samp{native} for the native endianness of | |
2952 | the target (the default). This option is not supported for C++. | |
2953 | ||
2954 | @strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate | |
2955 | code that is not binary compatible with code generated without it if the | |
2956 | specified endianness is not the native endianness of the target. | |
2957 | @end table | |
2958 | ||
2959 | @node C++ Dialect Options | |
2960 | @section Options Controlling C++ Dialect | |
2961 | ||
2962 | @cindex compiler options, C++ | |
2963 | @cindex C++ options, command-line | |
2964 | @cindex options, C++ | |
2965 | This section describes the command-line options that are only meaningful | |
2966 | for C++ programs. You can also use most of the GNU compiler options | |
2967 | regardless of what language your program is in. For example, you | |
2968 | might compile a file @file{firstClass.C} like this: | |
2969 | ||
2970 | @smallexample | |
2971 | g++ -g -fstrict-enums -O -c firstClass.C | |
2972 | @end smallexample | |
2973 | ||
2974 | @noindent | |
2975 | In this example, only @option{-fstrict-enums} is an option meant | |
2976 | only for C++ programs; you can use the other options with any | |
2977 | language supported by GCC@. | |
2978 | ||
2979 | Some options for compiling C programs, such as @option{-std}, are also | |
2980 | relevant for C++ programs. | |
2981 | @xref{C Dialect Options,,Options Controlling C Dialect}. | |
2982 | ||
2983 | Here is a list of options that are @emph{only} for compiling C++ programs: | |
2984 | ||
2985 | @table @gcctabopt | |
2986 | ||
d77de738 | 2987 | @opindex fabi-version |
ddf6fe37 | 2988 | @item -fabi-version=@var{n} |
d77de738 ML |
2989 | Use version @var{n} of the C++ ABI@. The default is version 0. |
2990 | ||
2991 | Version 0 refers to the version conforming most closely to | |
2992 | the C++ ABI specification. Therefore, the ABI obtained using version 0 | |
2993 | will change in different versions of G++ as ABI bugs are fixed. | |
2994 | ||
2995 | Version 1 is the version of the C++ ABI that first appeared in G++ 3.2. | |
2996 | ||
2997 | Version 2 is the version of the C++ ABI that first appeared in G++ | |
2998 | 3.4, and was the default through G++ 4.9. | |
2999 | ||
3000 | Version 3 corrects an error in mangling a constant address as a | |
3001 | template argument. | |
3002 | ||
3003 | Version 4, which first appeared in G++ 4.5, implements a standard | |
3004 | mangling for vector types. | |
3005 | ||
3006 | Version 5, which first appeared in G++ 4.6, corrects the mangling of | |
3007 | attribute const/volatile on function pointer types, decltype of a | |
3008 | plain decl, and use of a function parameter in the declaration of | |
3009 | another parameter. | |
3010 | ||
3011 | Version 6, which first appeared in G++ 4.7, corrects the promotion | |
3012 | behavior of C++11 scoped enums and the mangling of template argument | |
3013 | packs, const/static_cast, prefix ++ and --, and a class scope function | |
3014 | used as a template argument. | |
3015 | ||
3016 | Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a | |
3017 | builtin type and corrects the mangling of lambdas in default argument | |
3018 | scope. | |
3019 | ||
3020 | Version 8, which first appeared in G++ 4.9, corrects the substitution | |
3021 | behavior of function types with function-cv-qualifiers. | |
3022 | ||
3023 | Version 9, which first appeared in G++ 5.2, corrects the alignment of | |
3024 | @code{nullptr_t}. | |
3025 | ||
3026 | Version 10, which first appeared in G++ 6.1, adds mangling of | |
3027 | attributes that affect type identity, such as ia32 calling convention | |
3028 | attributes (e.g.@: @samp{stdcall}). | |
3029 | ||
3030 | Version 11, which first appeared in G++ 7, corrects the mangling of | |
3031 | sizeof... expressions and operator names. For multiple entities with | |
3032 | the same name within a function, that are declared in different scopes, | |
3033 | the mangling now changes starting with the twelfth occurrence. It also | |
3034 | implies @option{-fnew-inheriting-ctors}. | |
3035 | ||
3036 | Version 12, which first appeared in G++ 8, corrects the calling | |
3037 | conventions for empty classes on the x86_64 target and for classes | |
3038 | with only deleted copy/move constructors. It accidentally changes the | |
3039 | calling convention for classes with a deleted copy constructor and a | |
3040 | trivial move constructor. | |
3041 | ||
3042 | Version 13, which first appeared in G++ 8.2, fixes the accidental | |
3043 | change in version 12. | |
3044 | ||
3045 | Version 14, which first appeared in G++ 10, corrects the mangling of | |
3046 | the nullptr expression. | |
3047 | ||
3048 | Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI | |
3049 | tag regression. | |
3050 | ||
3051 | Version 16, which first appeared in G++ 11, changes the mangling of | |
3052 | @code{__alignof__} to be distinct from that of @code{alignof}, and | |
3053 | dependent operator names. | |
3054 | ||
3055 | Version 17, which first appeared in G++ 12, fixes layout of classes | |
3056 | that inherit from aggregate classes with default member initializers | |
3057 | in C++14 and up. | |
3058 | ||
3059 | Version 18, which first appeard in G++ 13, fixes manglings of lambdas | |
3060 | that have additional context. | |
3061 | ||
cd37325b JJ |
3062 | Version 19, which first appeard in G++ 14, fixes manglings of structured |
3063 | bindings to include ABI tags. | |
3064 | ||
d77de738 ML |
3065 | See also @option{-Wabi}. |
3066 | ||
d77de738 | 3067 | @opindex fabi-compat-version |
ddf6fe37 | 3068 | @item -fabi-compat-version=@var{n} |
d77de738 ML |
3069 | On targets that support strong aliases, G++ |
3070 | works around mangling changes by creating an alias with the correct | |
3071 | mangled name when defining a symbol with an incorrect mangled name. | |
3072 | This switch specifies which ABI version to use for the alias. | |
3073 | ||
3074 | With @option{-fabi-version=0} (the default), this defaults to 13 (GCC 8.2 | |
3075 | compatibility). If another ABI version is explicitly selected, this | |
3076 | defaults to 0. For compatibility with GCC versions 3.2 through 4.9, | |
3077 | use @option{-fabi-compat-version=2}. | |
3078 | ||
3079 | If this option is not provided but @option{-Wabi=@var{n}} is, that | |
3080 | version is used for compatibility aliases. If this option is provided | |
3081 | along with @option{-Wabi} (without the version), the version from this | |
3082 | option is used for the warning. | |
3083 | ||
d77de738 ML |
3084 | @opindex fno-access-control |
3085 | @opindex faccess-control | |
ddf6fe37 | 3086 | @item -fno-access-control |
d77de738 ML |
3087 | Turn off all access checking. This switch is mainly useful for working |
3088 | around bugs in the access control code. | |
3089 | ||
d77de738 | 3090 | @opindex faligned-new |
ddf6fe37 | 3091 | @item -faligned-new |
d77de738 ML |
3092 | Enable support for C++17 @code{new} of types that require more |
3093 | alignment than @code{void* ::operator new(std::size_t)} provides. A | |
3094 | numeric argument such as @code{-faligned-new=32} can be used to | |
3095 | specify how much alignment (in bytes) is provided by that function, | |
3096 | but few users will need to override the default of | |
3097 | @code{alignof(std::max_align_t)}. | |
3098 | ||
3099 | This flag is enabled by default for @option{-std=c++17}. | |
3100 | ||
d77de738 ML |
3101 | @opindex fchar8_t |
3102 | @opindex fno-char8_t | |
ddf6fe37 AA |
3103 | @item -fchar8_t |
3104 | @itemx -fno-char8_t | |
d77de738 ML |
3105 | Enable support for @code{char8_t} as adopted for C++20. This includes |
3106 | the addition of a new @code{char8_t} fundamental type, changes to the | |
3107 | types of UTF-8 string and character literals, new signatures for | |
3108 | user-defined literals, associated standard library updates, and new | |
3109 | @code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros. | |
3110 | ||
3111 | This option enables functions to be overloaded for ordinary and UTF-8 | |
3112 | strings: | |
3113 | ||
3114 | @smallexample | |
3115 | int f(const char *); // #1 | |
3116 | int f(const char8_t *); // #2 | |
3117 | int v1 = f("text"); // Calls #1 | |
3118 | int v2 = f(u8"text"); // Calls #2 | |
3119 | @end smallexample | |
3120 | ||
3121 | @noindent | |
3122 | and introduces new signatures for user-defined literals: | |
3123 | ||
3124 | @smallexample | |
3125 | int operator""_udl1(char8_t); | |
3126 | int v3 = u8'x'_udl1; | |
3127 | int operator""_udl2(const char8_t*, std::size_t); | |
3128 | int v4 = u8"text"_udl2; | |
3129 | template<typename T, T...> int operator""_udl3(); | |
3130 | int v5 = u8"text"_udl3; | |
3131 | @end smallexample | |
3132 | ||
3133 | @noindent | |
3134 | The change to the types of UTF-8 string and character literals introduces | |
3135 | incompatibilities with ISO C++11 and later standards. For example, the | |
3136 | following code is well-formed under ISO C++11, but is ill-formed when | |
3137 | @option{-fchar8_t} is specified. | |
3138 | ||
3139 | @smallexample | |
d77de738 ML |
3140 | const char *cp = u8"xx";// error: invalid conversion from |
3141 | // `const char8_t*' to `const char*' | |
3142 | int f(const char*); | |
3143 | auto v = f(u8"xx"); // error: invalid conversion from | |
3144 | // `const char8_t*' to `const char*' | |
3145 | std::string s@{u8"xx"@}; // error: no matching function for call to | |
3146 | // `std::basic_string<char>::basic_string()' | |
3147 | using namespace std::literals; | |
3148 | s = u8"xx"s; // error: conversion from | |
3149 | // `basic_string<char8_t>' to non-scalar | |
3150 | // type `basic_string<char>' requested | |
3151 | @end smallexample | |
3152 | ||
d77de738 | 3153 | @opindex fcheck-new |
ddf6fe37 | 3154 | @item -fcheck-new |
d77de738 ML |
3155 | Check that the pointer returned by @code{operator new} is non-null |
3156 | before attempting to modify the storage allocated. This check is | |
3157 | normally unnecessary because the C++ standard specifies that | |
3158 | @code{operator new} only returns @code{0} if it is declared | |
3159 | @code{throw()}, in which case the compiler always checks the | |
3160 | return value even without this option. In all other cases, when | |
3161 | @code{operator new} has a non-empty exception specification, memory | |
3162 | exhaustion is signalled by throwing @code{std::bad_alloc}. See also | |
3163 | @samp{new (nothrow)}. | |
3164 | ||
d77de738 ML |
3165 | @opindex fconcepts |
3166 | @opindex fconcepts-ts | |
ddf6fe37 AA |
3167 | @item -fconcepts |
3168 | @itemx -fconcepts-ts | |
d77de738 ML |
3169 | Enable support for the C++ Concepts feature for constraining template |
3170 | arguments. With @option{-std=c++20} and above, Concepts are part of | |
3171 | the language standard, so @option{-fconcepts} defaults to on. | |
3172 | ||
3173 | Some constructs that were allowed by the earlier C++ Extensions for | |
3174 | Concepts Technical Specification, ISO 19217 (2015), but didn't make it | |
3175 | into the standard, can additionally be enabled by | |
3176 | @option{-fconcepts-ts}. | |
3177 | ||
d77de738 | 3178 | @opindex fconstexpr-depth |
ddf6fe37 | 3179 | @item -fconstexpr-depth=@var{n} |
d77de738 ML |
3180 | Set the maximum nested evaluation depth for C++11 constexpr functions |
3181 | to @var{n}. A limit is needed to detect endless recursion during | |
3182 | constant expression evaluation. The minimum specified by the standard | |
3183 | is 512. | |
3184 | ||
d77de738 | 3185 | @opindex fconstexpr-cache-depth |
ddf6fe37 | 3186 | @item -fconstexpr-cache-depth=@var{n} |
d77de738 ML |
3187 | Set the maximum level of nested evaluation depth for C++11 constexpr |
3188 | functions that will be cached to @var{n}. This is a heuristic that | |
3189 | trades off compilation speed (when the cache avoids repeated | |
3190 | calculations) against memory consumption (when the cache grows very | |
3191 | large from highly recursive evaluations). The default is 8. Very few | |
3192 | users are likely to want to adjust it, but if your code does heavy | |
3193 | constexpr calculations you might want to experiment to find which | |
3194 | value works best for you. | |
3195 | ||
d77de738 | 3196 | @opindex fconstexpr-fp-except |
ddf6fe37 | 3197 | @item -fconstexpr-fp-except |
d77de738 ML |
3198 | Annex F of the C standard specifies that IEC559 floating point |
3199 | exceptions encountered at compile time should not stop compilation. | |
3200 | C++ compilers have historically not followed this guidance, instead | |
3201 | treating floating point division by zero as non-constant even though | |
3202 | it has a well defined value. This flag tells the compiler to give | |
3203 | Annex F priority over other rules saying that a particular operation | |
3204 | is undefined. | |
3205 | ||
3206 | @smallexample | |
3207 | constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except | |
3208 | @end smallexample | |
3209 | ||
d77de738 | 3210 | @opindex fconstexpr-loop-limit |
ddf6fe37 | 3211 | @item -fconstexpr-loop-limit=@var{n} |
d77de738 ML |
3212 | Set the maximum number of iterations for a loop in C++14 constexpr functions |
3213 | to @var{n}. A limit is needed to detect infinite loops during | |
3214 | constant expression evaluation. The default is 262144 (1<<18). | |
3215 | ||
d77de738 | 3216 | @opindex fconstexpr-ops-limit |
ddf6fe37 | 3217 | @item -fconstexpr-ops-limit=@var{n} |
d77de738 ML |
3218 | Set the maximum number of operations during a single constexpr evaluation. |
3219 | Even when number of iterations of a single loop is limited with the above limit, | |
3220 | if there are several nested loops and each of them has many iterations but still | |
3221 | smaller than the above limit, or if in a body of some loop or even outside | |
3222 | of a loop too many expressions need to be evaluated, the resulting constexpr | |
3223 | evaluation might take too long. | |
3224 | The default is 33554432 (1<<25). | |
3225 | ||
2efb237f | 3226 | @opindex fcontracts |
ddf6fe37 | 3227 | @item -fcontracts |
2efb237f JCI |
3228 | Enable experimental support for the C++ Contracts feature, as briefly |
3229 | added to and then removed from the C++20 working paper (N4820). The | |
3230 | implementation also includes proposed enhancements from papers P1290, | |
3231 | P1332, and P1429. This functionality is intended mostly for those | |
3232 | interested in experimentation towards refining the feature to get it | |
3233 | into shape for a future C++ standard. | |
3234 | ||
3235 | On violation of a checked contract, the violation handler is called. | |
3236 | Users can replace the violation handler by defining | |
3237 | @smallexample | |
4ace81b6 SL |
3238 | void |
3239 | handle_contract_violation (const std::experimental::contract_violation&); | |
2efb237f JCI |
3240 | @end smallexample |
3241 | ||
3242 | There are different sets of additional flags that can be used together | |
3243 | to specify which contracts will be checked and how, for N4820 | |
3244 | contracts, P1332 contracts, or P1429 contracts; these sets cannot be | |
3245 | used together. | |
3246 | ||
3247 | @table @gcctabopt | |
2efb237f | 3248 | @opindex fcontract-mode |
ddf6fe37 | 3249 | @item -fcontract-mode=[on|off] |
2efb237f JCI |
3250 | Control whether any contracts have any semantics at all. Defaults to on. |
3251 | ||
2efb237f | 3252 | @opindex fcontract-assumption-mode |
ddf6fe37 | 3253 | @item -fcontract-assumption-mode=[on|off] |
2efb237f JCI |
3254 | [N4820] Control whether contracts with level @samp{axiom} |
3255 | should have the assume semantic. Defaults to on. | |
3256 | ||
2efb237f | 3257 | @opindex fcontract-build-level |
ddf6fe37 | 3258 | @item -fcontract-build-level=[off|default|audit] |
2efb237f JCI |
3259 | [N4820] Specify which level of contracts to generate checks |
3260 | for. Defaults to @samp{default}. | |
3261 | ||
2efb237f | 3262 | @opindex fcontract-continuation-mode |
ddf6fe37 | 3263 | @item -fcontract-continuation-mode=[on|off] |
2efb237f JCI |
3264 | [N4820] Control whether to allow the program to continue executing |
3265 | after a contract violation. That is, do checked contracts have the | |
3266 | @samp{maybe} semantic described below rather than the @samp{never} | |
3267 | semantic. Defaults to off. | |
3268 | ||
2efb237f | 3269 | @opindex fcontract-role |
ddf6fe37 | 3270 | @item -fcontract-role=<name>:<default>,<audit>,<axiom> |
2efb237f JCI |
3271 | [P1332] Specify the concrete semantics for each contract level |
3272 | of a particular contract role. | |
3273 | ||
3274 | @item -fcontract-semantic=[default|audit|axiom]:<semantic> | |
3275 | [P1429] Specify the concrete semantic for a particular | |
3276 | contract level. | |
3277 | ||
2efb237f | 3278 | @opindex fcontract-strict-declarations |
ddf6fe37 | 3279 | @item -fcontract-strict-declarations=[on|off] |
2efb237f JCI |
3280 | Control whether to reject adding contracts to a function after its |
3281 | first declaration. Defaults to off. | |
3282 | @end table | |
3283 | ||
3284 | The possible concrete semantics for that can be specified with | |
3285 | @samp{-fcontract-role} or @samp{-fcontract-semantic} are: | |
3286 | ||
3287 | @table @code | |
3288 | @item ignore | |
3289 | This contract has no effect. | |
3290 | ||
3291 | @item assume | |
3292 | This contract is treated like C++23 @code{[[assume]]}. | |
3293 | ||
3294 | @item check_never_continue | |
3295 | @itemx never | |
3296 | @itemx abort | |
3297 | This contract is checked. If it fails, the violation handler is | |
3298 | called. If the handler returns, @code{std::terminate} is called. | |
3299 | ||
3300 | @item check_maybe_continue | |
3301 | @itemx maybe | |
3302 | This contract is checked. If it fails, the violation handler is | |
3303 | called. If the handler returns, execution continues normally. | |
3304 | @end table | |
3305 | ||
d77de738 | 3306 | @opindex fcoroutines |
ddf6fe37 | 3307 | @item -fcoroutines |
d77de738 ML |
3308 | Enable support for the C++ coroutines extension (experimental). |
3309 | ||
d77de738 ML |
3310 | @opindex fno-elide-constructors |
3311 | @opindex felide-constructors | |
ddf6fe37 | 3312 | @item -fno-elide-constructors |
d77de738 ML |
3313 | The C++ standard allows an implementation to omit creating a temporary |
3314 | that is only used to initialize another object of the same type. | |
3315 | Specifying this option disables that optimization, and forces G++ to | |
3316 | call the copy constructor in all cases. This option also causes G++ | |
3317 | to call trivial member functions which otherwise would be expanded inline. | |
3318 | ||
3319 | In C++17, the compiler is required to omit these temporaries, but this | |
3320 | option still affects trivial member functions. | |
3321 | ||
d77de738 ML |
3322 | @opindex fno-enforce-eh-specs |
3323 | @opindex fenforce-eh-specs | |
ddf6fe37 | 3324 | @item -fno-enforce-eh-specs |
d77de738 ML |
3325 | Don't generate code to check for violation of exception specifications |
3326 | at run time. This option violates the C++ standard, but may be useful | |
3327 | for reducing code size in production builds, much like defining | |
3328 | @code{NDEBUG}. This does not give user code permission to throw | |
3329 | exceptions in violation of the exception specifications; the compiler | |
3330 | still optimizes based on the specifications, so throwing an | |
3331 | unexpected exception results in undefined behavior at run time. | |
3332 | ||
d77de738 ML |
3333 | @opindex fextern-tls-init |
3334 | @opindex fno-extern-tls-init | |
ddf6fe37 AA |
3335 | @item -fextern-tls-init |
3336 | @itemx -fno-extern-tls-init | |
d77de738 ML |
3337 | The C++11 and OpenMP standards allow @code{thread_local} and |
3338 | @code{threadprivate} variables to have dynamic (runtime) | |
3339 | initialization. To support this, any use of such a variable goes | |
3340 | through a wrapper function that performs any necessary initialization. | |
3341 | When the use and definition of the variable are in the same | |
3342 | translation unit, this overhead can be optimized away, but when the | |
3343 | use is in a different translation unit there is significant overhead | |
3344 | even if the variable doesn't actually need dynamic initialization. If | |
3345 | the programmer can be sure that no use of the variable in a | |
3346 | non-defining TU needs to trigger dynamic initialization (either | |
3347 | because the variable is statically initialized, or a use of the | |
3348 | variable in the defining TU will be executed before any uses in | |
3349 | another TU), they can avoid this overhead with the | |
3350 | @option{-fno-extern-tls-init} option. | |
3351 | ||
3352 | On targets that support symbol aliases, the default is | |
3353 | @option{-fextern-tls-init}. On targets that do not support symbol | |
3354 | aliases, the default is @option{-fno-extern-tls-init}. | |
3355 | ||
d77de738 ML |
3356 | @opindex ffold-simple-inlines |
3357 | @opindex fno-fold-simple-inlines | |
ddf6fe37 AA |
3358 | @item -ffold-simple-inlines |
3359 | @itemx -fno-fold-simple-inlines | |
d77de738 ML |
3360 | Permit the C++ frontend to fold calls to @code{std::move}, @code{std::forward}, |
3361 | @code{std::addressof} and @code{std::as_const}. In contrast to inlining, this | |
3362 | means no debug information will be generated for such calls. Since these | |
3363 | functions are rarely interesting to debug, this flag is enabled by default | |
3364 | unless @option{-fno-inline} is active. | |
3365 | ||
d77de738 ML |
3366 | @opindex fno-gnu-keywords |
3367 | @opindex fgnu-keywords | |
ddf6fe37 | 3368 | @item -fno-gnu-keywords |
d77de738 ML |
3369 | Do not recognize @code{typeof} as a keyword, so that code can use this |
3370 | word as an identifier. You can use the keyword @code{__typeof__} instead. | |
3371 | This option is implied by the strict ISO C++ dialects: @option{-ansi}, | |
3372 | @option{-std=c++98}, @option{-std=c++11}, etc. | |
3373 | ||
d77de738 | 3374 | @opindex fimplicit-constexpr |
ddf6fe37 | 3375 | @item -fimplicit-constexpr |
d77de738 ML |
3376 | Make inline functions implicitly constexpr, if they satisfy the |
3377 | requirements for a constexpr function. This option can be used in | |
3378 | C++14 mode or later. This can result in initialization changing from | |
3379 | dynamic to static and other optimizations. | |
3380 | ||
d77de738 ML |
3381 | @opindex fno-implicit-templates |
3382 | @opindex fimplicit-templates | |
ddf6fe37 | 3383 | @item -fno-implicit-templates |
d77de738 ML |
3384 | Never emit code for non-inline templates that are instantiated |
3385 | implicitly (i.e.@: by use); only emit code for explicit instantiations. | |
3386 | If you use this option, you must take care to structure your code to | |
3387 | include all the necessary explicit instantiations to avoid getting | |
3388 | undefined symbols at link time. | |
3389 | @xref{Template Instantiation}, for more information. | |
3390 | ||
d77de738 ML |
3391 | @opindex fno-implicit-inline-templates |
3392 | @opindex fimplicit-inline-templates | |
ddf6fe37 | 3393 | @item -fno-implicit-inline-templates |
d77de738 ML |
3394 | Don't emit code for implicit instantiations of inline templates, either. |
3395 | The default is to handle inlines differently so that compiles with and | |
3396 | without optimization need the same set of explicit instantiations. | |
3397 | ||
d77de738 ML |
3398 | @opindex fno-implement-inlines |
3399 | @opindex fimplement-inlines | |
ddf6fe37 | 3400 | @item -fno-implement-inlines |
d77de738 ML |
3401 | To save space, do not emit out-of-line copies of inline functions |
3402 | controlled by @code{#pragma implementation}. This causes linker | |
3403 | errors if these functions are not inlined everywhere they are called. | |
3404 | ||
d77de738 ML |
3405 | @opindex fmodules-ts |
3406 | @opindex fno-modules-ts | |
ddf6fe37 AA |
3407 | @item -fmodules-ts |
3408 | @itemx -fno-modules-ts | |
d77de738 ML |
3409 | Enable support for C++20 modules (@pxref{C++ Modules}). The |
3410 | @option{-fno-modules-ts} is usually not needed, as that is the | |
3411 | default. Even though this is a C++20 feature, it is not currently | |
3412 | implicitly enabled by selecting that standard version. | |
3413 | ||
ddf6fe37 | 3414 | @opindex fmodule-header |
d77de738 ML |
3415 | @item -fmodule-header |
3416 | @itemx -fmodule-header=user | |
3417 | @itemx -fmodule-header=system | |
d77de738 ML |
3418 | Compile a header file to create an importable header unit. |
3419 | ||
d77de738 | 3420 | @opindex fmodule-implicit-inline |
ddf6fe37 | 3421 | @item -fmodule-implicit-inline |
d77de738 ML |
3422 | Member functions defined in their class definitions are not implicitly |
3423 | inline for modular code. This is different to traditional C++ | |
3424 | behavior, for good reasons. However, it may result in a difficulty | |
3425 | during code porting. This option makes such function definitions | |
3426 | implicitly inline. It does however generate an ABI incompatibility, | |
3427 | so you must use it everywhere or nowhere. (Such definitions outside | |
3428 | of a named module remain implicitly inline, regardless.) | |
3429 | ||
d77de738 ML |
3430 | @opindex fno-module-lazy |
3431 | @opindex fmodule-lazy | |
ddf6fe37 | 3432 | @item -fno-module-lazy |
d77de738 ML |
3433 | Disable lazy module importing and module mapper creation. |
3434 | ||
f33d7a88 AA |
3435 | @vindex CXX_MODULE_MAPPER @r{environment variable} |
3436 | @opindex fmodule-mapper | |
d77de738 ML |
3437 | @item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]} |
3438 | @itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...} | |
3439 | @itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]} | |
3440 | @itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]} | |
3441 | @itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]} | |
3442 | @itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]} | |
d77de738 ML |
3443 | An oracle to query for module name to filename mappings. If |
3444 | unspecified the @env{CXX_MODULE_MAPPER} environment variable is used, | |
3445 | and if that is unset, an in-process default is provided. | |
3446 | ||
d77de738 | 3447 | @opindex fmodule-only |
ddf6fe37 | 3448 | @item -fmodule-only |
d77de738 ML |
3449 | Only emit the Compiled Module Interface, inhibiting any object file. |
3450 | ||
d77de738 | 3451 | @opindex fms-extensions |
ddf6fe37 | 3452 | @item -fms-extensions |
d77de738 ML |
3453 | Disable Wpedantic warnings about constructs used in MFC, such as implicit |
3454 | int and getting a pointer to member function via non-standard syntax. | |
3455 | ||
d77de738 | 3456 | @opindex fnew-inheriting-ctors |
ddf6fe37 | 3457 | @item -fnew-inheriting-ctors |
d77de738 ML |
3458 | Enable the P0136 adjustment to the semantics of C++11 constructor |
3459 | inheritance. This is part of C++17 but also considered to be a Defect | |
3460 | Report against C++11 and C++14. This flag is enabled by default | |
3461 | unless @option{-fabi-version=10} or lower is specified. | |
3462 | ||
d77de738 | 3463 | @opindex fnew-ttp-matching |
ddf6fe37 | 3464 | @item -fnew-ttp-matching |
d77de738 ML |
3465 | Enable the P0522 resolution to Core issue 150, template template |
3466 | parameters and default arguments: this allows a template with default | |
3467 | template arguments as an argument for a template template parameter | |
3468 | with fewer template parameters. This flag is enabled by default for | |
3469 | @option{-std=c++17}. | |
3470 | ||
d77de738 ML |
3471 | @opindex fno-nonansi-builtins |
3472 | @opindex fnonansi-builtins | |
ddf6fe37 | 3473 | @item -fno-nonansi-builtins |
d77de738 ML |
3474 | Disable built-in declarations of functions that are not mandated by |
3475 | ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit}, | |
3476 | @code{index}, @code{bzero}, @code{conjf}, and other related functions. | |
3477 | ||
d77de738 | 3478 | @opindex fnothrow-opt |
ddf6fe37 | 3479 | @item -fnothrow-opt |
d77de738 ML |
3480 | Treat a @code{throw()} exception specification as if it were a |
3481 | @code{noexcept} specification to reduce or eliminate the text size | |
3482 | overhead relative to a function with no exception specification. If | |
3483 | the function has local variables of types with non-trivial | |
3484 | destructors, the exception specification actually makes the | |
3485 | function smaller because the EH cleanups for those variables can be | |
3486 | optimized away. The semantic effect is that an exception thrown out of | |
3487 | a function with such an exception specification results in a call | |
3488 | to @code{terminate} rather than @code{unexpected}. | |
3489 | ||
d77de738 ML |
3490 | @opindex fno-operator-names |
3491 | @opindex foperator-names | |
ddf6fe37 | 3492 | @item -fno-operator-names |
d77de738 ML |
3493 | Do not treat the operator name keywords @code{and}, @code{bitand}, |
3494 | @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as | |
3495 | synonyms as keywords. | |
3496 | ||
d77de738 ML |
3497 | @opindex fno-optional-diags |
3498 | @opindex foptional-diags | |
ddf6fe37 | 3499 | @item -fno-optional-diags |
d77de738 ML |
3500 | Disable diagnostics that the standard says a compiler does not need to |
3501 | issue. Currently, the only such diagnostic issued by G++ is the one for | |
3502 | a name having multiple meanings within a class. | |
3503 | ||
d77de738 ML |
3504 | @opindex fno-pretty-templates |
3505 | @opindex fpretty-templates | |
ddf6fe37 | 3506 | @item -fno-pretty-templates |
d77de738 ML |
3507 | When an error message refers to a specialization of a function |
3508 | template, the compiler normally prints the signature of the | |
3509 | template followed by the template arguments and any typedefs or | |
3510 | typenames in the signature (e.g.@: @code{void f(T) [with T = int]} | |
3511 | rather than @code{void f(int)}) so that it's clear which template is | |
3512 | involved. When an error message refers to a specialization of a class | |
3513 | template, the compiler omits any template arguments that match | |
3514 | the default template arguments for that template. If either of these | |
3515 | behaviors make it harder to understand the error message rather than | |
3516 | easier, you can use @option{-fno-pretty-templates} to disable them. | |
3517 | ||
d77de738 ML |
3518 | @opindex fno-rtti |
3519 | @opindex frtti | |
ddf6fe37 | 3520 | @item -fno-rtti |
d77de738 ML |
3521 | Disable generation of information about every class with virtual |
3522 | functions for use by the C++ run-time type identification features | |
3523 | (@code{dynamic_cast} and @code{typeid}). If you don't use those parts | |
3524 | of the language, you can save some space by using this flag. Note that | |
3525 | exception handling uses the same information, but G++ generates it as | |
3526 | needed. The @code{dynamic_cast} operator can still be used for casts that | |
3527 | do not require run-time type information, i.e.@: casts to @code{void *} or to | |
3528 | unambiguous base classes. | |
3529 | ||
3530 | Mixing code compiled with @option{-frtti} with that compiled with | |
3531 | @option{-fno-rtti} may not work. For example, programs may | |
3532 | fail to link if a class compiled with @option{-fno-rtti} is used as a base | |
3533 | for a class compiled with @option{-frtti}. | |
3534 | ||
d77de738 | 3535 | @opindex fsized-deallocation |
ddf6fe37 | 3536 | @item -fsized-deallocation |
d77de738 ML |
3537 | Enable the built-in global declarations |
3538 | @smallexample | |
3539 | void operator delete (void *, std::size_t) noexcept; | |
3540 | void operator delete[] (void *, std::size_t) noexcept; | |
3541 | @end smallexample | |
3542 | as introduced in C++14. This is useful for user-defined replacement | |
3543 | deallocation functions that, for example, use the size of the object | |
3544 | to make deallocation faster. Enabled by default under | |
3545 | @option{-std=c++14} and above. The flag @option{-Wsized-deallocation} | |
3546 | warns about places that might want to add a definition. | |
3547 | ||
d77de738 | 3548 | @opindex fstrict-enums |
ddf6fe37 | 3549 | @item -fstrict-enums |
d77de738 ML |
3550 | Allow the compiler to optimize using the assumption that a value of |
3551 | enumerated type can only be one of the values of the enumeration (as | |
3552 | defined in the C++ standard; basically, a value that can be | |
3553 | represented in the minimum number of bits needed to represent all the | |
3554 | enumerators). This assumption may not be valid if the program uses a | |
3555 | cast to convert an arbitrary integer value to the enumerated type. | |
d8a656d5 JW |
3556 | This option has no effect for an enumeration type with a fixed underlying |
3557 | type. | |
d77de738 | 3558 | |
d77de738 | 3559 | @opindex fstrong-eval-order |
ddf6fe37 | 3560 | @item -fstrong-eval-order |
d77de738 ML |
3561 | Evaluate member access, array subscripting, and shift expressions in |
3562 | left-to-right order, and evaluate assignment in right-to-left order, | |
3563 | as adopted for C++17. Enabled by default with @option{-std=c++17}. | |
3564 | @option{-fstrong-eval-order=some} enables just the ordering of member | |
3565 | access and shift expressions, and is the default without | |
3566 | @option{-std=c++17}. | |
3567 | ||
d77de738 | 3568 | @opindex ftemplate-backtrace-limit |
ddf6fe37 | 3569 | @item -ftemplate-backtrace-limit=@var{n} |
d77de738 ML |
3570 | Set the maximum number of template instantiation notes for a single |
3571 | warning or error to @var{n}. The default value is 10. | |
3572 | ||
d77de738 | 3573 | @opindex ftemplate-depth |
ddf6fe37 | 3574 | @item -ftemplate-depth=@var{n} |
d77de738 ML |
3575 | Set the maximum instantiation depth for template classes to @var{n}. |
3576 | A limit on the template instantiation depth is needed to detect | |
3577 | endless recursions during template class instantiation. ANSI/ISO C++ | |
3578 | conforming programs must not rely on a maximum depth greater than 17 | |
3579 | (changed to 1024 in C++11). The default value is 900, as the compiler | |
3580 | can run out of stack space before hitting 1024 in some situations. | |
3581 | ||
d77de738 ML |
3582 | @opindex fno-threadsafe-statics |
3583 | @opindex fthreadsafe-statics | |
ddf6fe37 | 3584 | @item -fno-threadsafe-statics |
d77de738 ML |
3585 | Do not emit the extra code to use the routines specified in the C++ |
3586 | ABI for thread-safe initialization of local statics. You can use this | |
3587 | option to reduce code size slightly in code that doesn't need to be | |
3588 | thread-safe. | |
3589 | ||
d77de738 | 3590 | @opindex fuse-cxa-atexit |
ddf6fe37 | 3591 | @item -fuse-cxa-atexit |
d77de738 ML |
3592 | Register destructors for objects with static storage duration with the |
3593 | @code{__cxa_atexit} function rather than the @code{atexit} function. | |
3594 | This option is required for fully standards-compliant handling of static | |
3595 | destructors, but only works if your C library supports | |
3596 | @code{__cxa_atexit}. | |
3597 | ||
d77de738 ML |
3598 | @opindex fno-use-cxa-get-exception-ptr |
3599 | @opindex fuse-cxa-get-exception-ptr | |
ddf6fe37 | 3600 | @item -fno-use-cxa-get-exception-ptr |
d77de738 ML |
3601 | Don't use the @code{__cxa_get_exception_ptr} runtime routine. This |
3602 | causes @code{std::uncaught_exception} to be incorrect, but is necessary | |
3603 | if the runtime routine is not available. | |
3604 | ||
d77de738 | 3605 | @opindex fvisibility-inlines-hidden |
ddf6fe37 | 3606 | @item -fvisibility-inlines-hidden |
d77de738 ML |
3607 | This switch declares that the user does not attempt to compare |
3608 | pointers to inline functions or methods where the addresses of the two functions | |
3609 | are taken in different shared objects. | |
3610 | ||
3611 | The effect of this is that GCC may, effectively, mark inline methods with | |
3612 | @code{__attribute__ ((visibility ("hidden")))} so that they do not | |
3613 | appear in the export table of a DSO and do not require a PLT indirection | |
3614 | when used within the DSO@. Enabling this option can have a dramatic effect | |
3615 | on load and link times of a DSO as it massively reduces the size of the | |
3616 | dynamic export table when the library makes heavy use of templates. | |
3617 | ||
3618 | The behavior of this switch is not quite the same as marking the | |
3619 | methods as hidden directly, because it does not affect static variables | |
3620 | local to the function or cause the compiler to deduce that | |
3621 | the function is defined in only one shared object. | |
3622 | ||
3623 | You may mark a method as having a visibility explicitly to negate the | |
3624 | effect of the switch for that method. For example, if you do want to | |
3625 | compare pointers to a particular inline method, you might mark it as | |
3626 | having default visibility. Marking the enclosing class with explicit | |
3627 | visibility has no effect. | |
3628 | ||
3629 | Explicitly instantiated inline methods are unaffected by this option | |
3630 | as their linkage might otherwise cross a shared library boundary. | |
3631 | @xref{Template Instantiation}. | |
3632 | ||
d77de738 | 3633 | @opindex fvisibility-ms-compat |
ddf6fe37 | 3634 | @item -fvisibility-ms-compat |
d77de738 ML |
3635 | This flag attempts to use visibility settings to make GCC's C++ |
3636 | linkage model compatible with that of Microsoft Visual Studio. | |
3637 | ||
3638 | The flag makes these changes to GCC's linkage model: | |
3639 | ||
3640 | @enumerate | |
3641 | @item | |
3642 | It sets the default visibility to @code{hidden}, like | |
3643 | @option{-fvisibility=hidden}. | |
3644 | ||
3645 | @item | |
3646 | Types, but not their members, are not hidden by default. | |
3647 | ||
3648 | @item | |
3649 | The One Definition Rule is relaxed for types without explicit | |
3650 | visibility specifications that are defined in more than one | |
3651 | shared object: those declarations are permitted if they are | |
3652 | permitted when this option is not used. | |
3653 | @end enumerate | |
3654 | ||
3655 | In new code it is better to use @option{-fvisibility=hidden} and | |
3656 | export those classes that are intended to be externally visible. | |
3657 | Unfortunately it is possible for code to rely, perhaps accidentally, | |
3658 | on the Visual Studio behavior. | |
3659 | ||
3660 | Among the consequences of these changes are that static data members | |
3661 | of the same type with the same name but defined in different shared | |
3662 | objects are different, so changing one does not change the other; | |
3663 | and that pointers to function members defined in different shared | |
3664 | objects may not compare equal. When this flag is given, it is a | |
3665 | violation of the ODR to define types with the same name differently. | |
3666 | ||
d77de738 ML |
3667 | @opindex fno-weak |
3668 | @opindex fweak | |
ddf6fe37 | 3669 | @item -fno-weak |
d77de738 ML |
3670 | Do not use weak symbol support, even if it is provided by the linker. |
3671 | By default, G++ uses weak symbols if they are available. This | |
3672 | option exists only for testing, and should not be used by end-users; | |
3673 | it results in inferior code and has no benefits. This option may | |
3674 | be removed in a future release of G++. | |
3675 | ||
d77de738 ML |
3676 | @opindex fext-numeric-literals |
3677 | @opindex fno-ext-numeric-literals | |
ddf6fe37 | 3678 | @item -fext-numeric-literals @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3679 | Accept imaginary, fixed-point, or machine-defined |
3680 | literal number suffixes as GNU extensions. | |
3681 | When this option is turned off these suffixes are treated | |
3682 | as C++11 user-defined literal numeric suffixes. | |
3683 | This is on by default for all pre-C++11 dialects and all GNU dialects: | |
3684 | @option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11}, | |
3685 | @option{-std=gnu++14}. | |
3686 | This option is off by default | |
3687 | for ISO C++11 onwards (@option{-std=c++11}, ...). | |
3688 | ||
d77de738 | 3689 | @opindex nostdinc++ |
ddf6fe37 | 3690 | @item -nostdinc++ |
d77de738 ML |
3691 | Do not search for header files in the standard directories specific to |
3692 | C++, but do still search the other standard directories. (This option | |
3693 | is used when building the C++ library.) | |
3694 | ||
ddf6fe37 AA |
3695 | @opindex flang-info-include-translate |
3696 | @opindex flang-info-include-translate-not | |
d77de738 ML |
3697 | @item -flang-info-include-translate |
3698 | @itemx -flang-info-include-translate-not | |
3699 | @itemx -flang-info-include-translate=@var{header} | |
d77de738 ML |
3700 | Inform of include translation events. The first will note accepted |
3701 | include translations, the second will note declined include | |
3702 | translations. The @var{header} form will inform of include | |
3703 | translations relating to that specific header. If @var{header} is of | |
3704 | the form @code{"user"} or @code{<system>} it will be resolved to a | |
3705 | specific user or system header using the include path. | |
3706 | ||
ddf6fe37 | 3707 | @opindex flang-info-module-cmi |
d77de738 ML |
3708 | @item -flang-info-module-cmi |
3709 | @itemx -flang-info-module-cmi=@var{module} | |
d77de738 ML |
3710 | Inform of Compiled Module Interface pathnames. The first will note |
3711 | all read CMI pathnames. The @var{module} form will not reading a | |
3712 | specific module's CMI. @var{module} may be a named module or a | |
3713 | header-unit (the latter indicated by either being a pathname containing | |
3714 | directory separators or enclosed in @code{<>} or @code{""}). | |
3715 | ||
d77de738 | 3716 | @opindex stdlib |
ddf6fe37 | 3717 | @item -stdlib=@var{libstdc++,libc++} |
d77de738 ML |
3718 | When G++ is configured to support this option, it allows specification of |
3719 | alternate C++ runtime libraries. Two options are available: @var{libstdc++} | |
3720 | (the default, native C++ runtime for G++) and @var{libc++} which is the | |
3721 | C++ runtime installed on some operating systems (e.g. Darwin versions from | |
3722 | Darwin11 onwards). The option switches G++ to use the headers from the | |
3723 | specified library and to emit @code{-lstdc++} or @code{-lc++} respectively, | |
3724 | when a C++ runtime is required for linking. | |
3725 | @end table | |
3726 | ||
3727 | In addition, these warning options have meanings only for C++ programs: | |
3728 | ||
3729 | @table @gcctabopt | |
d77de738 | 3730 | @opindex Wabi-tag |
ddf6fe37 | 3731 | @item -Wabi-tag @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3732 | Warn when a type with an ABI tag is used in a context that does not |
3733 | have that ABI tag. See @ref{C++ Attributes} for more information | |
3734 | about ABI tags. | |
3735 | ||
d77de738 ML |
3736 | @opindex Wcomma-subscript |
3737 | @opindex Wno-comma-subscript | |
ddf6fe37 | 3738 | @item -Wcomma-subscript @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3739 | Warn about uses of a comma expression within a subscripting expression. |
3740 | This usage was deprecated in C++20 and is going to be removed in C++23. | |
3741 | However, a comma expression wrapped in @code{( )} is not deprecated. Example: | |
3742 | ||
3743 | @smallexample | |
3744 | @group | |
3745 | void f(int *a, int b, int c) @{ | |
3746 | a[b,c]; // deprecated in C++20, invalid in C++23 | |
3747 | a[(b,c)]; // OK | |
3748 | @} | |
3749 | @end group | |
3750 | @end smallexample | |
3751 | ||
3752 | In C++23 it is valid to have comma separated expressions in a subscript | |
3753 | when an overloaded subscript operator is found and supports the right | |
3754 | number and types of arguments. G++ will accept the formerly valid syntax | |
3755 | for code that is not valid in C++23 but used to be valid but deprecated | |
3756 | in C++20 with a pedantic warning that can be disabled with | |
3757 | @option{-Wno-comma-subscript}. | |
3758 | ||
3759 | Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated}, | |
3760 | and with @option{-std=c++23} regardless of @option{-Wno-deprecated}. | |
3761 | ||
5fccebdb JM |
3762 | This warning is upgraded to an error by @option{-pedantic-errors} in |
3763 | C++23 mode or later. | |
3764 | ||
d77de738 ML |
3765 | @opindex Wctad-maybe-unsupported |
3766 | @opindex Wno-ctad-maybe-unsupported | |
ddf6fe37 | 3767 | @item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3768 | Warn when performing class template argument deduction (CTAD) on a type with |
3769 | no explicitly written deduction guides. This warning will point out cases | |
3770 | where CTAD succeeded only because the compiler synthesized the implicit | |
3771 | deduction guides, which might not be what the programmer intended. Certain | |
3772 | style guides allow CTAD only on types that specifically "opt-in"; i.e., on | |
3773 | types that are designed to support CTAD. This warning can be suppressed with | |
3774 | the following pattern: | |
3775 | ||
3776 | @smallexample | |
3777 | struct allow_ctad_t; // any name works | |
3778 | template <typename T> struct S @{ | |
3779 | S(T) @{ @} | |
3780 | @}; | |
4ace81b6 SL |
3781 | // Guide with incomplete parameter type will never be considered. |
3782 | S(allow_ctad_t) -> S<void>; | |
d77de738 ML |
3783 | @end smallexample |
3784 | ||
d77de738 ML |
3785 | @opindex Wctor-dtor-privacy |
3786 | @opindex Wno-ctor-dtor-privacy | |
ddf6fe37 | 3787 | @item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3788 | Warn when a class seems unusable because all the constructors or |
3789 | destructors in that class are private, and it has neither friends nor | |
3790 | public static member functions. Also warn if there are no non-private | |
3791 | methods, and there's at least one private member function that isn't | |
3792 | a constructor or destructor. | |
3793 | ||
d77de738 ML |
3794 | @opindex Wdangling-reference |
3795 | @opindex Wno-dangling-reference | |
ddf6fe37 | 3796 | @item -Wdangling-reference @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3797 | Warn when a reference is bound to a temporary whose lifetime has ended. |
3798 | For example: | |
3799 | ||
3800 | @smallexample | |
3801 | int n = 1; | |
3802 | const int& r = std::max(n - 1, n + 1); // r is dangling | |
3803 | @end smallexample | |
3804 | ||
3805 | In the example above, two temporaries are created, one for each | |
3806 | argument, and a reference to one of the temporaries is returned. | |
3807 | However, both temporaries are destroyed at the end of the full | |
3808 | expression, so the reference @code{r} is dangling. This warning | |
3809 | also detects dangling references in member initializer lists: | |
3810 | ||
3811 | @smallexample | |
3812 | const int& f(const int& i) @{ return i; @} | |
3813 | struct S @{ | |
3814 | const int &r; // r is dangling | |
3815 | S() : r(f(10)) @{ @} | |
3816 | @}; | |
3817 | @end smallexample | |
3818 | ||
3819 | Member functions are checked as well, but only their object argument: | |
3820 | ||
3821 | @smallexample | |
3822 | struct S @{ | |
3823 | const S& self () @{ return *this; @} | |
3824 | @}; | |
3825 | const S& s = S().self(); // s is dangling | |
3826 | @end smallexample | |
3827 | ||
3828 | Certain functions are safe in this respect, for example @code{std::use_facet}: | |
3829 | they take and return a reference, but they don't return one of its arguments, | |
3830 | which can fool the warning. Such functions can be excluded from the warning | |
3831 | by wrapping them in a @code{#pragma}: | |
3832 | ||
3833 | @smallexample | |
3834 | #pragma GCC diagnostic push | |
3835 | #pragma GCC diagnostic ignored "-Wdangling-reference" | |
3836 | const T& foo (const T&) @{ @dots{} @} | |
3837 | #pragma GCC diagnostic pop | |
3838 | @end smallexample | |
3839 | ||
ce51e843 ML |
3840 | @option{-Wdangling-reference} also warns about code like |
3841 | ||
3842 | @smallexample | |
3843 | auto p = std::minmax(1, 2); | |
3844 | @end smallexample | |
3845 | ||
3846 | where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and | |
3847 | both references dangle after the end of the full expression that contains | |
3848 | the call to @code{std::minmax}. | |
3849 | ||
d77de738 ML |
3850 | This warning is enabled by @option{-Wall}. |
3851 | ||
d77de738 ML |
3852 | @opindex Wdelete-non-virtual-dtor |
3853 | @opindex Wno-delete-non-virtual-dtor | |
ddf6fe37 | 3854 | @item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3855 | Warn when @code{delete} is used to destroy an instance of a class that |
3856 | has virtual functions and non-virtual destructor. It is unsafe to delete | |
3857 | an instance of a derived class through a pointer to a base class if the | |
3858 | base class does not have a virtual destructor. This warning is enabled | |
3859 | by @option{-Wall}. | |
3860 | ||
d77de738 ML |
3861 | @opindex Wdeprecated-copy |
3862 | @opindex Wno-deprecated-copy | |
ddf6fe37 | 3863 | @item -Wdeprecated-copy @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3864 | Warn that the implicit declaration of a copy constructor or copy |
3865 | assignment operator is deprecated if the class has a user-provided | |
3866 | copy constructor or copy assignment operator, in C++11 and up. This | |
3867 | warning is enabled by @option{-Wextra}. With | |
3868 | @option{-Wdeprecated-copy-dtor}, also deprecate if the class has a | |
3869 | user-provided destructor. | |
3870 | ||
d77de738 ML |
3871 | @opindex Wdeprecated-enum-enum-conversion |
3872 | @opindex Wno-deprecated-enum-enum-conversion | |
ddf6fe37 | 3873 | @item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3874 | Disable the warning about the case when the usual arithmetic conversions |
3875 | are applied on operands where one is of enumeration type and the other is | |
3876 | of a different enumeration type. This conversion was deprecated in C++20. | |
3877 | For example: | |
3878 | ||
3879 | @smallexample | |
3880 | enum E1 @{ e @}; | |
3881 | enum E2 @{ f @}; | |
3882 | int k = f - e; | |
3883 | @end smallexample | |
3884 | ||
3885 | @option{-Wdeprecated-enum-enum-conversion} is enabled by default with | |
3886 | @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled | |
3887 | by @option{-Wenum-conversion}. | |
3888 | ||
d77de738 ML |
3889 | @opindex Wdeprecated-enum-float-conversion |
3890 | @opindex Wno-deprecated-enum-float-conversion | |
ddf6fe37 | 3891 | @item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3892 | Disable the warning about the case when the usual arithmetic conversions |
3893 | are applied on operands where one is of enumeration type and the other is | |
3894 | of a floating-point type. This conversion was deprecated in C++20. For | |
3895 | example: | |
3896 | ||
3897 | @smallexample | |
3898 | enum E1 @{ e @}; | |
3899 | enum E2 @{ f @}; | |
3900 | bool b = e <= 3.7; | |
3901 | @end smallexample | |
3902 | ||
3903 | @option{-Wdeprecated-enum-float-conversion} is enabled by default with | |
3904 | @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled | |
3905 | by @option{-Wenum-conversion}. | |
3906 | ||
b106f11d AC |
3907 | @opindex Welaborated-enum-base |
3908 | @opindex Wno-elaborated-enum-base | |
3909 | @item -Wno-elaborated-enum-base | |
3910 | For C++11 and above, warn if an (invalid) additional enum-base is used | |
3911 | in an elaborated-type-specifier. That is, if an enum with given | |
3912 | underlying type and no enumerator list is used in a declaration other | |
3913 | than just a standalone declaration of the enum. Enabled by default. This | |
3914 | warning is upgraded to an error with -pedantic-errors. | |
3915 | ||
d77de738 ML |
3916 | @opindex Winit-list-lifetime |
3917 | @opindex Wno-init-list-lifetime | |
ddf6fe37 | 3918 | @item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3919 | Do not warn about uses of @code{std::initializer_list} that are likely |
3920 | to result in dangling pointers. Since the underlying array for an | |
3921 | @code{initializer_list} is handled like a normal C++ temporary object, | |
3922 | it is easy to inadvertently keep a pointer to the array past the end | |
3923 | of the array's lifetime. For example: | |
3924 | ||
3925 | @itemize @bullet | |
3926 | @item | |
3927 | If a function returns a temporary @code{initializer_list}, or a local | |
3928 | @code{initializer_list} variable, the array's lifetime ends at the end | |
3929 | of the return statement, so the value returned has a dangling pointer. | |
3930 | ||
3931 | @item | |
3932 | If a new-expression creates an @code{initializer_list}, the array only | |
3933 | lives until the end of the enclosing full-expression, so the | |
3934 | @code{initializer_list} in the heap has a dangling pointer. | |
3935 | ||
3936 | @item | |
3937 | When an @code{initializer_list} variable is assigned from a | |
3938 | brace-enclosed initializer list, the temporary array created for the | |
3939 | right side of the assignment only lives until the end of the | |
3940 | full-expression, so at the next statement the @code{initializer_list} | |
3941 | variable has a dangling pointer. | |
3942 | ||
3943 | @smallexample | |
3944 | // li's initial underlying array lives as long as li | |
3945 | std::initializer_list<int> li = @{ 1,2,3 @}; | |
3946 | // assignment changes li to point to a temporary array | |
3947 | li = @{ 4, 5 @}; | |
3948 | // now the temporary is gone and li has a dangling pointer | |
3949 | int i = li.begin()[0] // undefined behavior | |
3950 | @end smallexample | |
3951 | ||
3952 | @item | |
3953 | When a list constructor stores the @code{begin} pointer from the | |
3954 | @code{initializer_list} argument, this doesn't extend the lifetime of | |
3955 | the array, so if a class variable is constructed from a temporary | |
3956 | @code{initializer_list}, the pointer is left dangling by the end of | |
3957 | the variable declaration statement. | |
3958 | ||
3959 | @end itemize | |
3960 | ||
c85f8dbb MP |
3961 | @opindex Winvalid-constexpr |
3962 | @opindex Wno-invalid-constexpr | |
ddf6fe37 | 3963 | @item -Winvalid-constexpr |
c85f8dbb MP |
3964 | |
3965 | Warn when a function never produces a constant expression. In C++20 | |
3966 | and earlier, for every @code{constexpr} function and function template, | |
3967 | there must be at least one set of function arguments in at least one | |
3968 | instantiation such that an invocation of the function or constructor | |
3969 | could be an evaluated subexpression of a core constant expression. | |
3970 | C++23 removed this restriction, so it's possible to have a function | |
3971 | or a function template marked @code{constexpr} for which no invocation | |
3972 | satisfies the requirements of a core constant expression. | |
3973 | ||
3974 | This warning is enabled as a pedantic warning by default in C++20 and | |
3975 | earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in | |
3976 | which case it will be an ordinary warning. For example: | |
3977 | ||
3978 | @smallexample | |
3979 | void f (int& i); | |
3980 | constexpr void | |
3981 | g (int& i) | |
3982 | @{ | |
4ace81b6 SL |
3983 | // Warns by default in C++20, in C++23 only with -Winvalid-constexpr. |
3984 | f(i); | |
c85f8dbb MP |
3985 | @} |
3986 | @end smallexample | |
3987 | ||
d77de738 ML |
3988 | @opindex Winvalid-imported-macros |
3989 | @opindex Wno-invalid-imported-macros | |
ddf6fe37 | 3990 | @item -Winvalid-imported-macros |
d77de738 ML |
3991 | Verify all imported macro definitions are valid at the end of |
3992 | compilation. This is not enabled by default, as it requires | |
3993 | additional processing to determine. It may be useful when preparing | |
3994 | sets of header-units to ensure consistent macros. | |
3995 | ||
d77de738 ML |
3996 | @opindex Wliteral-suffix |
3997 | @opindex Wno-literal-suffix | |
ddf6fe37 | 3998 | @item -Wno-literal-suffix @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3999 | Do not warn when a string or character literal is followed by a |
4000 | ud-suffix which does not begin with an underscore. As a conforming | |
4001 | extension, GCC treats such suffixes as separate preprocessing tokens | |
4002 | in order to maintain backwards compatibility with code that uses | |
4003 | formatting macros from @code{<inttypes.h>}. For example: | |
4004 | ||
4005 | @smallexample | |
4006 | #define __STDC_FORMAT_MACROS | |
4007 | #include <inttypes.h> | |
4008 | #include <stdio.h> | |
4009 | ||
4010 | int main() @{ | |
4011 | int64_t i64 = 123; | |
4012 | printf("My int64: %" PRId64"\n", i64); | |
4013 | @} | |
4014 | @end smallexample | |
4015 | ||
4016 | In this case, @code{PRId64} is treated as a separate preprocessing token. | |
4017 | ||
4018 | This option also controls warnings when a user-defined literal | |
4019 | operator is declared with a literal suffix identifier that doesn't | |
4020 | begin with an underscore. Literal suffix identifiers that don't begin | |
4021 | with an underscore are reserved for future standardization. | |
4022 | ||
4023 | These warnings are enabled by default. | |
4024 | ||
d77de738 ML |
4025 | @opindex Wnarrowing |
4026 | @opindex Wno-narrowing | |
ddf6fe37 | 4027 | @item -Wno-narrowing @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4028 | For C++11 and later standards, narrowing conversions are diagnosed by default, |
4029 | as required by the standard. A narrowing conversion from a constant produces | |
4030 | an error, and a narrowing conversion from a non-constant produces a warning, | |
4031 | but @option{-Wno-narrowing} suppresses the diagnostic. | |
4032 | Note that this does not affect the meaning of well-formed code; | |
4033 | narrowing conversions are still considered ill-formed in SFINAE contexts. | |
4034 | ||
4035 | With @option{-Wnarrowing} in C++98, warn when a narrowing | |
4036 | conversion prohibited by C++11 occurs within | |
4037 | @samp{@{ @}}, e.g. | |
4038 | ||
4039 | @smallexample | |
4040 | int i = @{ 2.2 @}; // error: narrowing from double to int | |
4041 | @end smallexample | |
4042 | ||
4043 | This flag is included in @option{-Wall} and @option{-Wc++11-compat}. | |
4044 | ||
d77de738 ML |
4045 | @opindex Wnoexcept |
4046 | @opindex Wno-noexcept | |
ddf6fe37 | 4047 | @item -Wnoexcept @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4048 | Warn when a noexcept-expression evaluates to false because of a call |
4049 | to a function that does not have a non-throwing exception | |
4050 | specification (i.e. @code{throw()} or @code{noexcept}) but is known by | |
4051 | the compiler to never throw an exception. | |
4052 | ||
d77de738 ML |
4053 | @opindex Wnoexcept-type |
4054 | @opindex Wno-noexcept-type | |
ddf6fe37 | 4055 | @item -Wnoexcept-type @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4056 | Warn if the C++17 feature making @code{noexcept} part of a function |
4057 | type changes the mangled name of a symbol relative to C++14. Enabled | |
4058 | by @option{-Wabi} and @option{-Wc++17-compat}. | |
4059 | ||
4060 | As an example: | |
4061 | ||
4062 | @smallexample | |
4063 | template <class T> void f(T t) @{ t(); @}; | |
4064 | void g() noexcept; | |
4065 | void h() @{ f(g); @} | |
4066 | @end smallexample | |
4067 | ||
4068 | @noindent | |
4069 | In C++14, @code{f} calls @code{f<void(*)()>}, but in | |
4070 | C++17 it calls @code{f<void(*)()noexcept>}. | |
4071 | ||
d77de738 ML |
4072 | @opindex Wclass-memaccess |
4073 | @opindex Wno-class-memaccess | |
ddf6fe37 | 4074 | @item -Wclass-memaccess @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4075 | Warn when the destination of a call to a raw memory function such as |
4076 | @code{memset} or @code{memcpy} is an object of class type, and when writing | |
4077 | into such an object might bypass the class non-trivial or deleted constructor | |
4078 | or copy assignment, violate const-correctness or encapsulation, or corrupt | |
4079 | virtual table pointers. Modifying the representation of such objects may | |
4080 | violate invariants maintained by member functions of the class. For example, | |
4081 | the call to @code{memset} below is undefined because it modifies a non-trivial | |
4082 | class object and is, therefore, diagnosed. The safe way to either initialize | |
4083 | or clear the storage of objects of such types is by using the appropriate | |
4084 | constructor or assignment operator, if one is available. | |
4085 | @smallexample | |
4086 | std::string str = "abc"; | |
4087 | memset (&str, 0, sizeof str); | |
4088 | @end smallexample | |
4089 | The @option{-Wclass-memaccess} option is enabled by @option{-Wall}. | |
4090 | Explicitly casting the pointer to the class object to @code{void *} or | |
4091 | to a type that can be safely accessed by the raw memory function suppresses | |
4092 | the warning. | |
4093 | ||
d77de738 ML |
4094 | @opindex Wnon-virtual-dtor |
4095 | @opindex Wno-non-virtual-dtor | |
ddf6fe37 | 4096 | @item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4097 | Warn when a class has virtual functions and an accessible non-virtual |
4098 | destructor itself or in an accessible polymorphic base class, in which | |
4099 | case it is possible but unsafe to delete an instance of a derived | |
4100 | class through a pointer to the class itself or base class. This | |
4101 | warning is automatically enabled if @option{-Weffc++} is specified. | |
51f28e3a JW |
4102 | The @option{-Wdelete-non-virtual-dtor} option (enabled by @option{-Wall}) |
4103 | should be preferred because it warns about the unsafe cases without false | |
4104 | positives. | |
d77de738 | 4105 | |
d77de738 ML |
4106 | @opindex Wregister |
4107 | @opindex Wno-register | |
ddf6fe37 | 4108 | @item -Wregister @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4109 | Warn on uses of the @code{register} storage class specifier, except |
4110 | when it is part of the GNU @ref{Explicit Register Variables} extension. | |
4111 | The use of the @code{register} keyword as storage class specifier has | |
4112 | been deprecated in C++11 and removed in C++17. | |
4113 | Enabled by default with @option{-std=c++17}. | |
4114 | ||
d77de738 ML |
4115 | @opindex Wreorder |
4116 | @opindex Wno-reorder | |
4117 | @cindex reordering, warning | |
4118 | @cindex warning for reordering of member initializers | |
f33d7a88 | 4119 | @item -Wreorder @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4120 | Warn when the order of member initializers given in the code does not |
4121 | match the order in which they must be executed. For instance: | |
4122 | ||
4123 | @smallexample | |
4124 | struct A @{ | |
4125 | int i; | |
4126 | int j; | |
4127 | A(): j (0), i (1) @{ @} | |
4128 | @}; | |
4129 | @end smallexample | |
4130 | ||
4131 | @noindent | |
4132 | The compiler rearranges the member initializers for @code{i} | |
4133 | and @code{j} to match the declaration order of the members, emitting | |
4134 | a warning to that effect. This warning is enabled by @option{-Wall}. | |
4135 | ||
d77de738 ML |
4136 | @opindex Wpessimizing-move |
4137 | @opindex Wno-pessimizing-move | |
ddf6fe37 | 4138 | @item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4139 | This warning warns when a call to @code{std::move} prevents copy |
4140 | elision. A typical scenario when copy elision can occur is when returning in | |
4141 | a function with a class return type, when the expression being returned is the | |
4142 | name of a non-volatile automatic object, and is not a function parameter, and | |
4143 | has the same type as the function return type. | |
4144 | ||
4145 | @smallexample | |
4146 | struct T @{ | |
4147 | @dots{} | |
4148 | @}; | |
4149 | T fn() | |
4150 | @{ | |
4151 | T t; | |
4152 | @dots{} | |
4153 | return std::move (t); | |
4154 | @} | |
4155 | @end smallexample | |
4156 | ||
4157 | But in this example, the @code{std::move} call prevents copy elision. | |
4158 | ||
4159 | This warning is enabled by @option{-Wall}. | |
4160 | ||
d77de738 ML |
4161 | @opindex Wredundant-move |
4162 | @opindex Wno-redundant-move | |
ddf6fe37 | 4163 | @item -Wno-redundant-move @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4164 | This warning warns about redundant calls to @code{std::move}; that is, when |
4165 | a move operation would have been performed even without the @code{std::move} | |
4166 | call. This happens because the compiler is forced to treat the object as if | |
4167 | it were an rvalue in certain situations such as returning a local variable, | |
4168 | where copy elision isn't applicable. Consider: | |
4169 | ||
4170 | @smallexample | |
4171 | struct T @{ | |
4172 | @dots{} | |
4173 | @}; | |
4174 | T fn(T t) | |
4175 | @{ | |
4176 | @dots{} | |
4177 | return std::move (t); | |
4178 | @} | |
4179 | @end smallexample | |
4180 | ||
4181 | Here, the @code{std::move} call is redundant. Because G++ implements Core | |
4182 | Issue 1579, another example is: | |
4183 | ||
4184 | @smallexample | |
4185 | struct T @{ // convertible to U | |
4186 | @dots{} | |
4187 | @}; | |
4188 | struct U @{ | |
4189 | @dots{} | |
4190 | @}; | |
4191 | U fn() | |
4192 | @{ | |
4193 | T t; | |
4194 | @dots{} | |
4195 | return std::move (t); | |
4196 | @} | |
4197 | @end smallexample | |
4198 | In this example, copy elision isn't applicable because the type of the | |
4199 | expression being returned and the function return type differ, yet G++ | |
4200 | treats the return value as if it were designated by an rvalue. | |
4201 | ||
4202 | This warning is enabled by @option{-Wextra}. | |
4203 | ||
d77de738 ML |
4204 | @opindex Wrange-loop-construct |
4205 | @opindex Wno-range-loop-construct | |
ddf6fe37 | 4206 | @item -Wrange-loop-construct @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4207 | This warning warns when a C++ range-based for-loop is creating an unnecessary |
4208 | copy. This can happen when the range declaration is not a reference, but | |
4209 | probably should be. For example: | |
4210 | ||
4211 | @smallexample | |
4212 | struct S @{ char arr[128]; @}; | |
4213 | void fn () @{ | |
4214 | S arr[5]; | |
4215 | for (const auto x : arr) @{ @dots{} @} | |
4216 | @} | |
4217 | @end smallexample | |
4218 | ||
4219 | It does not warn when the type being copied is a trivially-copyable type whose | |
4220 | size is less than 64 bytes. | |
4221 | ||
4222 | This warning also warns when a loop variable in a range-based for-loop is | |
4223 | initialized with a value of a different type resulting in a copy. For example: | |
4224 | ||
4225 | @smallexample | |
4226 | void fn() @{ | |
4227 | int arr[10]; | |
4228 | for (const double &x : arr) @{ @dots{} @} | |
4229 | @} | |
4230 | @end smallexample | |
4231 | ||
4232 | In the example above, in every iteration of the loop a temporary value of | |
4233 | type @code{double} is created and destroyed, to which the reference | |
4234 | @code{const double &} is bound. | |
4235 | ||
4236 | This warning is enabled by @option{-Wall}. | |
4237 | ||
d77de738 ML |
4238 | @opindex Wredundant-tags |
4239 | @opindex Wno-redundant-tags | |
ddf6fe37 | 4240 | @item -Wredundant-tags @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4241 | Warn about redundant class-key and enum-key in references to class types |
4242 | and enumerated types in contexts where the key can be eliminated without | |
4243 | causing an ambiguity. For example: | |
4244 | ||
4245 | @smallexample | |
4246 | struct foo; | |
4247 | struct foo *p; // warn that keyword struct can be eliminated | |
4248 | @end smallexample | |
4249 | ||
4250 | @noindent | |
4251 | On the other hand, in this example there is no warning: | |
4252 | ||
4253 | @smallexample | |
4254 | struct foo; | |
4255 | void foo (); // "hides" struct foo | |
4256 | void bar (struct foo&); // no warning, keyword struct is necessary | |
4257 | @end smallexample | |
4258 | ||
d77de738 ML |
4259 | @opindex Wsubobject-linkage |
4260 | @opindex Wno-subobject-linkage | |
ddf6fe37 | 4261 | @item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4262 | Do not warn |
4263 | if a class type has a base or a field whose type uses the anonymous | |
4264 | namespace or depends on a type with no linkage. If a type A depends on | |
4265 | a type B with no or internal linkage, defining it in multiple | |
4266 | translation units would be an ODR violation because the meaning of B | |
4267 | is different in each translation unit. If A only appears in a single | |
4268 | translation unit, the best way to silence the warning is to give it | |
4269 | internal linkage by putting it in an anonymous namespace as well. The | |
4270 | compiler doesn't give this warning for types defined in the main .C | |
4271 | file, as those are unlikely to have multiple definitions. | |
4272 | @option{-Wsubobject-linkage} is enabled by default. | |
4273 | ||
d77de738 ML |
4274 | @opindex Weffc++ |
4275 | @opindex Wno-effc++ | |
ddf6fe37 | 4276 | @item -Weffc++ @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4277 | Warn about violations of the following style guidelines from Scott Meyers' |
4278 | @cite{Effective C++} series of books: | |
4279 | ||
4280 | @itemize @bullet | |
4281 | @item | |
4282 | Define a copy constructor and an assignment operator for classes | |
4283 | with dynamically-allocated memory. | |
4284 | ||
4285 | @item | |
4286 | Prefer initialization to assignment in constructors. | |
4287 | ||
4288 | @item | |
4289 | Have @code{operator=} return a reference to @code{*this}. | |
4290 | ||
4291 | @item | |
4292 | Don't try to return a reference when you must return an object. | |
4293 | ||
4294 | @item | |
4295 | Distinguish between prefix and postfix forms of increment and | |
4296 | decrement operators. | |
4297 | ||
4298 | @item | |
4299 | Never overload @code{&&}, @code{||}, or @code{,}. | |
4300 | ||
4301 | @end itemize | |
4302 | ||
4303 | This option also enables @option{-Wnon-virtual-dtor}, which is also | |
4304 | one of the effective C++ recommendations. However, the check is | |
4305 | extended to warn about the lack of virtual destructor in accessible | |
4306 | non-polymorphic bases classes too. | |
4307 | ||
4308 | When selecting this option, be aware that the standard library | |
4309 | headers do not obey all of these guidelines; use @samp{grep -v} | |
4310 | to filter out those warnings. | |
4311 | ||
d77de738 ML |
4312 | @opindex Wexceptions |
4313 | @opindex Wno-exceptions | |
ddf6fe37 | 4314 | @item -Wno-exceptions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4315 | Disable the warning about the case when an exception handler is shadowed by |
4316 | another handler, which can point out a wrong ordering of exception handlers. | |
4317 | ||
d77de738 ML |
4318 | @opindex Wstrict-null-sentinel |
4319 | @opindex Wno-strict-null-sentinel | |
ddf6fe37 | 4320 | @item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4321 | Warn about the use of an uncasted @code{NULL} as sentinel. When |
4322 | compiling only with GCC this is a valid sentinel, as @code{NULL} is defined | |
4323 | to @code{__null}. Although it is a null pointer constant rather than a | |
4324 | null pointer, it is guaranteed to be of the same size as a pointer. | |
4325 | But this use is not portable across different compilers. | |
4326 | ||
d77de738 ML |
4327 | @opindex Wno-non-template-friend |
4328 | @opindex Wnon-template-friend | |
ddf6fe37 | 4329 | @item -Wno-non-template-friend @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4330 | Disable warnings when non-template friend functions are declared |
4331 | within a template. In very old versions of GCC that predate implementation | |
4332 | of the ISO standard, declarations such as | |
4333 | @samp{friend int foo(int)}, where the name of the friend is an unqualified-id, | |
4334 | could be interpreted as a particular specialization of a template | |
4335 | function; the warning exists to diagnose compatibility problems, | |
4336 | and is enabled by default. | |
4337 | ||
d77de738 ML |
4338 | @opindex Wold-style-cast |
4339 | @opindex Wno-old-style-cast | |
ddf6fe37 | 4340 | @item -Wold-style-cast @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4341 | Warn if an old-style (C-style) cast to a non-void type is used within |
4342 | a C++ program. The new-style casts (@code{dynamic_cast}, | |
4343 | @code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are | |
4344 | less vulnerable to unintended effects and much easier to search for. | |
4345 | ||
d77de738 ML |
4346 | @opindex Woverloaded-virtual |
4347 | @opindex Wno-overloaded-virtual | |
4348 | @cindex overloaded virtual function, warning | |
4349 | @cindex warning for overloaded virtual function | |
f33d7a88 AA |
4350 | @item -Woverloaded-virtual @r{(C++ and Objective-C++ only)} |
4351 | @itemx -Woverloaded-virtual=@var{n} | |
d77de738 ML |
4352 | Warn when a function declaration hides virtual functions from a |
4353 | base class. For example, in: | |
4354 | ||
4355 | @smallexample | |
4356 | struct A @{ | |
4357 | virtual void f(); | |
4358 | @}; | |
4359 | ||
4360 | struct B: public A @{ | |
4361 | void f(int); // does not override | |
4362 | @}; | |
4363 | @end smallexample | |
4364 | ||
4365 | the @code{A} class version of @code{f} is hidden in @code{B}, and code | |
4366 | like: | |
4367 | ||
4368 | @smallexample | |
4369 | B* b; | |
4370 | b->f(); | |
4371 | @end smallexample | |
4372 | ||
4373 | @noindent | |
4374 | fails to compile. | |
4375 | ||
d82490d5 JW |
4376 | In cases where the different signatures are not an accident, the |
4377 | simplest solution is to add a using-declaration to the derived class | |
4378 | to un-hide the base function, e.g. add @code{using A::f;} to @code{B}. | |
4379 | ||
d77de738 ML |
4380 | The optional level suffix controls the behavior when all the |
4381 | declarations in the derived class override virtual functions in the | |
4382 | base class, even if not all of the base functions are overridden: | |
4383 | ||
4384 | @smallexample | |
4385 | struct C @{ | |
4386 | virtual void f(); | |
4387 | virtual void f(int); | |
4388 | @}; | |
4389 | ||
4390 | struct D: public C @{ | |
4391 | void f(int); // does override | |
4392 | @} | |
4393 | @end smallexample | |
4394 | ||
4395 | This pattern is less likely to be a mistake; if D is only used | |
4396 | virtually, the user might have decided that the base class semantics | |
4397 | for some of the overloads are fine. | |
4398 | ||
4399 | At level 1, this case does not warn; at level 2, it does. | |
4400 | @option{-Woverloaded-virtual} by itself selects level 2. Level 1 is | |
4401 | included in @option{-Wall}. | |
4402 | ||
d77de738 ML |
4403 | @opindex Wno-pmf-conversions |
4404 | @opindex Wpmf-conversions | |
ddf6fe37 | 4405 | @item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4406 | Disable the diagnostic for converting a bound pointer to member function |
4407 | to a plain pointer. | |
4408 | ||
d77de738 ML |
4409 | @opindex Wsign-promo |
4410 | @opindex Wno-sign-promo | |
ddf6fe37 | 4411 | @item -Wsign-promo @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4412 | Warn when overload resolution chooses a promotion from unsigned or |
4413 | enumerated type to a signed type, over a conversion to an unsigned type of | |
4414 | the same size. Previous versions of G++ tried to preserve | |
4415 | unsignedness, but the standard mandates the current behavior. | |
4416 | ||
d77de738 ML |
4417 | @opindex Wtemplates |
4418 | @opindex Wno-templates | |
ddf6fe37 | 4419 | @item -Wtemplates @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4420 | Warn when a primary template declaration is encountered. Some coding |
4421 | rules disallow templates, and this may be used to enforce that rule. | |
4422 | The warning is inactive inside a system header file, such as the STL, so | |
4423 | one can still use the STL. One may also instantiate or specialize | |
4424 | templates. | |
4425 | ||
d77de738 ML |
4426 | @opindex Wmismatched-new-delete |
4427 | @opindex Wno-mismatched-new-delete | |
ddf6fe37 | 4428 | @item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4429 | Warn for mismatches between calls to @code{operator new} or @code{operator |
4430 | delete} and the corresponding call to the allocation or deallocation function. | |
4431 | This includes invocations of C++ @code{operator delete} with pointers | |
4432 | returned from either mismatched forms of @code{operator new}, or from other | |
4433 | functions that allocate objects for which the @code{operator delete} isn't | |
4434 | a suitable deallocator, as well as calls to other deallocation functions | |
4435 | with pointers returned from @code{operator new} for which the deallocation | |
4436 | function isn't suitable. | |
4437 | ||
4438 | For example, the @code{delete} expression in the function below is diagnosed | |
4439 | because it doesn't match the array form of the @code{new} expression | |
4440 | the pointer argument was returned from. Similarly, the call to @code{free} | |
4441 | is also diagnosed. | |
4442 | ||
4443 | @smallexample | |
4444 | void f () | |
4445 | @{ | |
4446 | int *a = new int[n]; | |
4447 | delete a; // warning: mismatch in array forms of expressions | |
4448 | ||
4449 | char *p = new char[n]; | |
4450 | free (p); // warning: mismatch between new and free | |
4451 | @} | |
4452 | @end smallexample | |
4453 | ||
4454 | The related option @option{-Wmismatched-dealloc} diagnoses mismatches | |
4455 | involving allocation and deallocation functions other than @code{operator | |
4456 | new} and @code{operator delete}. | |
4457 | ||
4458 | @option{-Wmismatched-new-delete} is included in @option{-Wall}. | |
4459 | ||
d77de738 ML |
4460 | @opindex Wmismatched-tags |
4461 | @opindex Wno-mismatched-tags | |
ddf6fe37 | 4462 | @item -Wmismatched-tags @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4463 | Warn for declarations of structs, classes, and class templates and their |
4464 | specializations with a class-key that does not match either the definition | |
4465 | or the first declaration if no definition is provided. | |
4466 | ||
4467 | For example, the declaration of @code{struct Object} in the argument list | |
4468 | of @code{draw} triggers the warning. To avoid it, either remove the redundant | |
4469 | class-key @code{struct} or replace it with @code{class} to match its definition. | |
4470 | @smallexample | |
4471 | class Object @{ | |
4472 | public: | |
4473 | virtual ~Object () = 0; | |
4474 | @}; | |
4475 | void draw (struct Object*); | |
4476 | @end smallexample | |
4477 | ||
4478 | It is not wrong to declare a class with the class-key @code{struct} as | |
4479 | the example above shows. The @option{-Wmismatched-tags} option is intended | |
4480 | to help achieve a consistent style of class declarations. In code that is | |
4481 | intended to be portable to Windows-based compilers the warning helps prevent | |
4482 | unresolved references due to the difference in the mangling of symbols | |
4483 | declared with different class-keys. The option can be used either on its | |
4484 | own or in conjunction with @option{-Wredundant-tags}. | |
4485 | ||
d77de738 ML |
4486 | @opindex Wmultiple-inheritance |
4487 | @opindex Wno-multiple-inheritance | |
ddf6fe37 | 4488 | @item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4489 | Warn when a class is defined with multiple direct base classes. Some |
4490 | coding rules disallow multiple inheritance, and this may be used to | |
4491 | enforce that rule. The warning is inactive inside a system header file, | |
4492 | such as the STL, so one can still use the STL. One may also define | |
4493 | classes that indirectly use multiple inheritance. | |
4494 | ||
d77de738 ML |
4495 | @opindex Wvirtual-inheritance |
4496 | @opindex Wno-virtual-inheritance | |
ddf6fe37 | 4497 | @item -Wvirtual-inheritance |
d77de738 ML |
4498 | Warn when a class is defined with a virtual direct base class. Some |
4499 | coding rules disallow multiple inheritance, and this may be used to | |
4500 | enforce that rule. The warning is inactive inside a system header file, | |
4501 | such as the STL, so one can still use the STL. One may also define | |
4502 | classes that indirectly use virtual inheritance. | |
4503 | ||
d77de738 ML |
4504 | @opindex Wvirtual-move-assign |
4505 | @opindex Wno-virtual-move-assign | |
ddf6fe37 | 4506 | @item -Wno-virtual-move-assign |
d77de738 ML |
4507 | Suppress warnings about inheriting from a virtual base with a |
4508 | non-trivial C++11 move assignment operator. This is dangerous because | |
4509 | if the virtual base is reachable along more than one path, it is | |
4510 | moved multiple times, which can mean both objects end up in the | |
4511 | moved-from state. If the move assignment operator is written to avoid | |
4512 | moving from a moved-from object, this warning can be disabled. | |
4513 | ||
d77de738 ML |
4514 | @opindex Wnamespaces |
4515 | @opindex Wno-namespaces | |
ddf6fe37 | 4516 | @item -Wnamespaces |
d77de738 ML |
4517 | Warn when a namespace definition is opened. Some coding rules disallow |
4518 | namespaces, and this may be used to enforce that rule. The warning is | |
4519 | inactive inside a system header file, such as the STL, so one can still | |
4520 | use the STL. One may also use using directives and qualified names. | |
4521 | ||
d77de738 ML |
4522 | @opindex Wterminate |
4523 | @opindex Wno-terminate | |
ddf6fe37 | 4524 | @item -Wno-terminate @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4525 | Disable the warning about a throw-expression that will immediately |
4526 | result in a call to @code{terminate}. | |
4527 | ||
d77de738 ML |
4528 | @opindex Wvexing-parse |
4529 | @opindex Wno-vexing-parse | |
ddf6fe37 | 4530 | @item -Wno-vexing-parse @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4531 | Warn about the most vexing parse syntactic ambiguity. This warns about |
4532 | the cases when a declaration looks like a variable definition, but the | |
4533 | C++ language requires it to be interpreted as a function declaration. | |
4534 | For instance: | |
4535 | ||
4536 | @smallexample | |
4537 | void f(double a) @{ | |
4538 | int i(); // extern int i (void); | |
4539 | int n(int(a)); // extern int n (int); | |
4540 | @} | |
4541 | @end smallexample | |
4542 | ||
4543 | Another example: | |
4544 | ||
4545 | @smallexample | |
4546 | struct S @{ S(int); @}; | |
4547 | void f(double a) @{ | |
4548 | S x(int(a)); // extern struct S x (int); | |
4549 | S y(int()); // extern struct S y (int (*) (void)); | |
4550 | S z(); // extern struct S z (void); | |
4551 | @} | |
4552 | @end smallexample | |
4553 | ||
4554 | The warning will suggest options how to deal with such an ambiguity; e.g., | |
4555 | it can suggest removing the parentheses or using braces instead. | |
4556 | ||
4557 | This warning is enabled by default. | |
4558 | ||
d77de738 ML |
4559 | @opindex Wno-class-conversion |
4560 | @opindex Wclass-conversion | |
ddf6fe37 | 4561 | @item -Wno-class-conversion @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4562 | Do not warn when a conversion function converts an |
4563 | object to the same type, to a base class of that type, or to void; such | |
4564 | a conversion function will never be called. | |
4565 | ||
d77de738 ML |
4566 | @opindex Wvolatile |
4567 | @opindex Wno-volatile | |
ddf6fe37 | 4568 | @item -Wvolatile @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4569 | Warn about deprecated uses of the @code{volatile} qualifier. This includes |
4570 | postfix and prefix @code{++} and @code{--} expressions of | |
4571 | @code{volatile}-qualified types, using simple assignments where the left | |
4572 | operand is a @code{volatile}-qualified non-class type for their value, | |
4573 | compound assignments where the left operand is a @code{volatile}-qualified | |
4574 | non-class type, @code{volatile}-qualified function return type, | |
4575 | @code{volatile}-qualified parameter type, and structured bindings of a | |
4576 | @code{volatile}-qualified type. This usage was deprecated in C++20. | |
4577 | ||
4578 | Enabled by default with @option{-std=c++20}. | |
4579 | ||
d77de738 ML |
4580 | @opindex Wzero-as-null-pointer-constant |
4581 | @opindex Wno-zero-as-null-pointer-constant | |
ddf6fe37 | 4582 | @item -Wzero-as-null-pointer-constant @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4583 | Warn when a literal @samp{0} is used as null pointer constant. This can |
4584 | be useful to facilitate the conversion to @code{nullptr} in C++11. | |
4585 | ||
d77de738 ML |
4586 | @opindex Waligned-new |
4587 | @opindex Wno-aligned-new | |
ddf6fe37 | 4588 | @item -Waligned-new |
d77de738 ML |
4589 | Warn about a new-expression of a type that requires greater alignment |
4590 | than the @code{alignof(std::max_align_t)} but uses an allocation | |
4591 | function without an explicit alignment parameter. This option is | |
4592 | enabled by @option{-Wall}. | |
4593 | ||
4594 | Normally this only warns about global allocation functions, but | |
4595 | @option{-Waligned-new=all} also warns about class member allocation | |
4596 | functions. | |
4597 | ||
d77de738 ML |
4598 | @opindex Wplacement-new |
4599 | @opindex Wno-placement-new | |
ddf6fe37 AA |
4600 | @item -Wno-placement-new |
4601 | @itemx -Wplacement-new=@var{n} | |
d77de738 ML |
4602 | Warn about placement new expressions with undefined behavior, such as |
4603 | constructing an object in a buffer that is smaller than the type of | |
4604 | the object. For example, the placement new expression below is diagnosed | |
4605 | because it attempts to construct an array of 64 integers in a buffer only | |
4606 | 64 bytes large. | |
4607 | @smallexample | |
4608 | char buf [64]; | |
4609 | new (buf) int[64]; | |
4610 | @end smallexample | |
4611 | This warning is enabled by default. | |
4612 | ||
4613 | @table @gcctabopt | |
4614 | @item -Wplacement-new=1 | |
4615 | This is the default warning level of @option{-Wplacement-new}. At this | |
4616 | level the warning is not issued for some strictly undefined constructs that | |
4617 | GCC allows as extensions for compatibility with legacy code. For example, | |
4618 | the following @code{new} expression is not diagnosed at this level even | |
4619 | though it has undefined behavior according to the C++ standard because | |
4620 | it writes past the end of the one-element array. | |
4621 | @smallexample | |
4622 | struct S @{ int n, a[1]; @}; | |
4623 | S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]); | |
4624 | new (s->a)int [32](); | |
4625 | @end smallexample | |
4626 | ||
4627 | @item -Wplacement-new=2 | |
4628 | At this level, in addition to diagnosing all the same constructs as at level | |
4629 | 1, a diagnostic is also issued for placement new expressions that construct | |
4630 | an object in the last member of structure whose type is an array of a single | |
4631 | element and whose size is less than the size of the object being constructed. | |
4632 | While the previous example would be diagnosed, the following construct makes | |
4633 | use of the flexible member array extension to avoid the warning at level 2. | |
4634 | @smallexample | |
4635 | struct S @{ int n, a[]; @}; | |
4636 | S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]); | |
4637 | new (s->a)int [32](); | |
4638 | @end smallexample | |
4639 | ||
4640 | @end table | |
4641 | ||
d77de738 ML |
4642 | @opindex Wcatch-value |
4643 | @opindex Wno-catch-value | |
ddf6fe37 AA |
4644 | @item -Wcatch-value |
4645 | @itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)} | |
d77de738 ML |
4646 | Warn about catch handlers that do not catch via reference. |
4647 | With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short) | |
4648 | warn about polymorphic class types that are caught by value. | |
4649 | With @option{-Wcatch-value=2} warn about all class types that are caught | |
4650 | by value. With @option{-Wcatch-value=3} warn about all types that are | |
4651 | not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}. | |
4652 | ||
d77de738 ML |
4653 | @opindex Wconditionally-supported |
4654 | @opindex Wno-conditionally-supported | |
ddf6fe37 | 4655 | @item -Wconditionally-supported @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4656 | Warn for conditionally-supported (C++11 [intro.defs]) constructs. |
4657 | ||
d77de738 ML |
4658 | @opindex Wdelete-incomplete |
4659 | @opindex Wno-delete-incomplete | |
ddf6fe37 | 4660 | @item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4661 | Do not warn when deleting a pointer to incomplete type, which may cause |
4662 | undefined behavior at runtime. This warning is enabled by default. | |
4663 | ||
d77de738 ML |
4664 | @opindex Wextra-semi |
4665 | @opindex Wno-extra-semi | |
ddf6fe37 | 4666 | @item -Wextra-semi @r{(C++, Objective-C++ only)} |
d77de738 ML |
4667 | Warn about redundant semicolons after in-class function definitions. |
4668 | ||
d77de738 ML |
4669 | @opindex Winaccessible-base |
4670 | @opindex Wno-inaccessible-base | |
ddf6fe37 | 4671 | @item -Wno-inaccessible-base @r{(C++, Objective-C++ only)} |
d77de738 ML |
4672 | This option controls warnings |
4673 | when a base class is inaccessible in a class derived from it due to | |
4674 | ambiguity. The warning is enabled by default. | |
4675 | Note that the warning for ambiguous virtual | |
4676 | bases is enabled by the @option{-Wextra} option. | |
4677 | @smallexample | |
4678 | @group | |
4679 | struct A @{ int a; @}; | |
4680 | ||
4681 | struct B : A @{ @}; | |
4682 | ||
4683 | struct C : B, A @{ @}; | |
4684 | @end group | |
4685 | @end smallexample | |
4686 | ||
d77de738 ML |
4687 | @opindex Winherited-variadic-ctor |
4688 | @opindex Wno-inherited-variadic-ctor | |
ddf6fe37 | 4689 | @item -Wno-inherited-variadic-ctor |
d77de738 ML |
4690 | Suppress warnings about use of C++11 inheriting constructors when the |
4691 | base class inherited from has a C variadic constructor; the warning is | |
4692 | on by default because the ellipsis is not inherited. | |
4693 | ||
d77de738 ML |
4694 | @opindex Wno-invalid-offsetof |
4695 | @opindex Winvalid-offsetof | |
ddf6fe37 | 4696 | @item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4697 | Suppress warnings from applying the @code{offsetof} macro to a non-POD |
4698 | type. According to the 2014 ISO C++ standard, applying @code{offsetof} | |
4699 | to a non-standard-layout type is undefined. In existing C++ implementations, | |
4700 | however, @code{offsetof} typically gives meaningful results. | |
4701 | This flag is for users who are aware that they are | |
4702 | writing nonportable code and who have deliberately chosen to ignore the | |
4703 | warning about it. | |
4704 | ||
4705 | The restrictions on @code{offsetof} may be relaxed in a future version | |
4706 | of the C++ standard. | |
4707 | ||
d77de738 ML |
4708 | @opindex Wsized-deallocation |
4709 | @opindex Wno-sized-deallocation | |
ddf6fe37 | 4710 | @item -Wsized-deallocation @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4711 | Warn about a definition of an unsized deallocation function |
4712 | @smallexample | |
4713 | void operator delete (void *) noexcept; | |
4714 | void operator delete[] (void *) noexcept; | |
4715 | @end smallexample | |
4716 | without a definition of the corresponding sized deallocation function | |
4717 | @smallexample | |
4718 | void operator delete (void *, std::size_t) noexcept; | |
4719 | void operator delete[] (void *, std::size_t) noexcept; | |
4720 | @end smallexample | |
4721 | or vice versa. Enabled by @option{-Wextra} along with | |
4722 | @option{-fsized-deallocation}. | |
4723 | ||
d77de738 ML |
4724 | @opindex Wno-suggest-final-types |
4725 | @opindex Wsuggest-final-types | |
ddf6fe37 | 4726 | @item -Wsuggest-final-types |
d77de738 ML |
4727 | Warn about types with virtual methods where code quality would be improved |
4728 | if the type were declared with the C++11 @code{final} specifier, | |
4729 | or, if possible, | |
4730 | declared in an anonymous namespace. This allows GCC to more aggressively | |
4731 | devirtualize the polymorphic calls. This warning is more effective with | |
4732 | link-time optimization, | |
4733 | where the information about the class hierarchy graph is | |
4734 | more complete. | |
4735 | ||
d77de738 ML |
4736 | @opindex Wno-suggest-final-methods |
4737 | @opindex Wsuggest-final-methods | |
ddf6fe37 | 4738 | @item -Wsuggest-final-methods |
d77de738 ML |
4739 | Warn about virtual methods where code quality would be improved if the method |
4740 | were declared with the C++11 @code{final} specifier, | |
4741 | or, if possible, its type were | |
4742 | declared in an anonymous namespace or with the @code{final} specifier. | |
4743 | This warning is | |
4744 | more effective with link-time optimization, where the information about the | |
4745 | class hierarchy graph is more complete. It is recommended to first consider | |
4746 | suggestions of @option{-Wsuggest-final-types} and then rebuild with new | |
4747 | annotations. | |
4748 | ||
d77de738 ML |
4749 | @opindex Wsuggest-override |
4750 | @opindex Wno-suggest-override | |
ddf6fe37 | 4751 | @item -Wsuggest-override |
d77de738 ML |
4752 | Warn about overriding virtual functions that are not marked with the |
4753 | @code{override} keyword. | |
4754 | ||
d77de738 ML |
4755 | @opindex Wuse-after-free |
4756 | @opindex Wno-use-after-free | |
ddf6fe37 AA |
4757 | @item -Wuse-after-free |
4758 | @itemx -Wuse-after-free=@var{n} | |
d77de738 ML |
4759 | Warn about uses of pointers to dynamically allocated objects that have |
4760 | been rendered indeterminate by a call to a deallocation function. | |
4761 | The warning is enabled at all optimization levels but may yield different | |
4762 | results with optimization than without. | |
4763 | ||
4764 | @table @gcctabopt | |
4765 | @item -Wuse-after-free=1 | |
4766 | At level 1 the warning attempts to diagnose only unconditional uses | |
4767 | of pointers made indeterminate by a deallocation call or a successful | |
4768 | call to @code{realloc}, regardless of whether or not the call resulted | |
4769 | in an actual reallocatio of memory. This includes double-@code{free} | |
4770 | calls as well as uses in arithmetic and relational expressions. Although | |
4771 | undefined, uses of indeterminate pointers in equality (or inequality) | |
4772 | expressions are not diagnosed at this level. | |
4773 | @item -Wuse-after-free=2 | |
4774 | At level 2, in addition to unconditional uses, the warning also diagnoses | |
4775 | conditional uses of pointers made indeterminate by a deallocation call. | |
4776 | As at level 2, uses in equality (or inequality) expressions are not | |
4777 | diagnosed. For example, the second call to @code{free} in the following | |
4778 | function is diagnosed at this level: | |
4779 | @smallexample | |
4780 | struct A @{ int refcount; void *data; @}; | |
4781 | ||
4782 | void release (struct A *p) | |
4783 | @{ | |
4784 | int refcount = --p->refcount; | |
4785 | free (p); | |
4786 | if (refcount == 0) | |
4787 | free (p->data); // warning: p may be used after free | |
4788 | @} | |
4789 | @end smallexample | |
4790 | @item -Wuse-after-free=3 | |
4791 | At level 3, the warning also diagnoses uses of indeterminate pointers in | |
4792 | equality expressions. All uses of indeterminate pointers are undefined | |
4793 | but equality tests sometimes appear after calls to @code{realloc} as | |
4794 | an attempt to determine whether the call resulted in relocating the object | |
4795 | to a different address. They are diagnosed at a separate level to aid | |
4796 | legacy code gradually transition to safe alternatives. For example, | |
4797 | the equality test in the function below is diagnosed at this level: | |
4798 | @smallexample | |
4799 | void adjust_pointers (int**, int); | |
4800 | ||
4801 | void grow (int **p, int n) | |
4802 | @{ | |
4803 | int **q = (int**)realloc (p, n *= 2); | |
4804 | if (q == p) | |
4805 | return; | |
4806 | adjust_pointers ((int**)q, n); | |
4807 | @} | |
4808 | @end smallexample | |
4809 | To avoid the warning at this level, store offsets into allocated memory | |
4810 | instead of pointers. This approach obviates needing to adjust the stored | |
4811 | pointers after reallocation. | |
4812 | @end table | |
4813 | ||
4814 | @option{-Wuse-after-free=2} is included in @option{-Wall}. | |
4815 | ||
d77de738 ML |
4816 | @opindex Wuseless-cast |
4817 | @opindex Wno-useless-cast | |
68783211 | 4818 | @item -Wuseless-cast @r{(C, Objective-C, C++ and Objective-C++ only)} |
d77de738 ML |
4819 | Warn when an expression is cast to its own type. This warning does not |
4820 | occur when a class object is converted to a non-reference type as that | |
4821 | is a way to create a temporary: | |
4822 | ||
4823 | @smallexample | |
4824 | struct S @{ @}; | |
4825 | void g (S&&); | |
4826 | void f (S&& arg) | |
4827 | @{ | |
4828 | g (S(arg)); // make arg prvalue so that it can bind to S&& | |
4829 | @} | |
4830 | @end smallexample | |
4831 | ||
d77de738 ML |
4832 | @opindex Wconversion-null |
4833 | @opindex Wno-conversion-null | |
ddf6fe37 | 4834 | @item -Wno-conversion-null @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4835 | Do not warn for conversions between @code{NULL} and non-pointer |
4836 | types. @option{-Wconversion-null} is enabled by default. | |
4837 | ||
4838 | @end table | |
4839 | ||
4840 | @node Objective-C and Objective-C++ Dialect Options | |
4841 | @section Options Controlling Objective-C and Objective-C++ Dialects | |
4842 | ||
4843 | @cindex compiler options, Objective-C and Objective-C++ | |
4844 | @cindex Objective-C and Objective-C++ options, command-line | |
4845 | @cindex options, Objective-C and Objective-C++ | |
4846 | (NOTE: This manual does not describe the Objective-C and Objective-C++ | |
4847 | languages themselves. @xref{Standards,,Language Standards | |
4848 | Supported by GCC}, for references.) | |
4849 | ||
4850 | This section describes the command-line options that are only meaningful | |
4851 | for Objective-C and Objective-C++ programs. You can also use most of | |
4852 | the language-independent GNU compiler options. | |
4853 | For example, you might compile a file @file{some_class.m} like this: | |
4854 | ||
4855 | @smallexample | |
4856 | gcc -g -fgnu-runtime -O -c some_class.m | |
4857 | @end smallexample | |
4858 | ||
4859 | @noindent | |
4860 | In this example, @option{-fgnu-runtime} is an option meant only for | |
4861 | Objective-C and Objective-C++ programs; you can use the other options with | |
4862 | any language supported by GCC@. | |
4863 | ||
4864 | Note that since Objective-C is an extension of the C language, Objective-C | |
4865 | compilations may also use options specific to the C front-end (e.g., | |
4866 | @option{-Wtraditional}). Similarly, Objective-C++ compilations may use | |
4867 | C++-specific options (e.g., @option{-Wabi}). | |
4868 | ||
4869 | Here is a list of options that are @emph{only} for compiling Objective-C | |
4870 | and Objective-C++ programs: | |
4871 | ||
4872 | @table @gcctabopt | |
d77de738 | 4873 | @opindex fconstant-string-class |
ddf6fe37 | 4874 | @item -fconstant-string-class=@var{class-name} |
d77de738 ML |
4875 | Use @var{class-name} as the name of the class to instantiate for each |
4876 | literal string specified with the syntax @code{@@"@dots{}"}. The default | |
4877 | class name is @code{NXConstantString} if the GNU runtime is being used, and | |
cdd4b3c0 | 4878 | @code{NSConstantString} if the NeXT runtime is being used (see below). On |
a335cf24 | 4879 | Darwin / macOS platforms, the @option{-fconstant-cfstrings} option, if |
cdd4b3c0 IS |
4880 | also present, overrides the @option{-fconstant-string-class} setting and cause |
4881 | @code{@@"@dots{}"} literals to be laid out as constant CoreFoundation strings. | |
4882 | Note that @option{-fconstant-cfstrings} is an alias for the target-specific | |
4883 | @option{-mconstant-cfstrings} equivalent. | |
d77de738 | 4884 | |
d77de738 | 4885 | @opindex fgnu-runtime |
ddf6fe37 | 4886 | @item -fgnu-runtime |
d77de738 ML |
4887 | Generate object code compatible with the standard GNU Objective-C |
4888 | runtime. This is the default for most types of systems. | |
4889 | ||
d77de738 | 4890 | @opindex fnext-runtime |
ddf6fe37 | 4891 | @item -fnext-runtime |
d77de738 | 4892 | Generate output compatible with the NeXT runtime. This is the default |
a335cf24 | 4893 | for NeXT-based systems, including Darwin / macOS. The macro |
d77de738 ML |
4894 | @code{__NEXT_RUNTIME__} is predefined if (and only if) this option is |
4895 | used. | |
4896 | ||
d77de738 ML |
4897 | @opindex fno-nil-receivers |
4898 | @opindex fnil-receivers | |
ddf6fe37 | 4899 | @item -fno-nil-receivers |
d77de738 ML |
4900 | Assume that all Objective-C message dispatches (@code{[receiver |
4901 | message:arg]}) in this translation unit ensure that the receiver is | |
4902 | not @code{nil}. This allows for more efficient entry points in the | |
4903 | runtime to be used. This option is only available in conjunction with | |
4904 | the NeXT runtime and ABI version 0 or 1. | |
4905 | ||
d77de738 | 4906 | @opindex fobjc-abi-version |
ddf6fe37 | 4907 | @item -fobjc-abi-version=@var{n} |
d77de738 ML |
4908 | Use version @var{n} of the Objective-C ABI for the selected runtime. |
4909 | This option is currently supported only for the NeXT runtime. In that | |
4910 | case, Version 0 is the traditional (32-bit) ABI without support for | |
4911 | properties and other Objective-C 2.0 additions. Version 1 is the | |
4912 | traditional (32-bit) ABI with support for properties and other | |
4913 | Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If | |
4914 | nothing is specified, the default is Version 0 on 32-bit target | |
4915 | machines, and Version 2 on 64-bit target machines. | |
4916 | ||
d77de738 | 4917 | @opindex fobjc-call-cxx-cdtors |
ddf6fe37 | 4918 | @item -fobjc-call-cxx-cdtors |
d77de738 ML |
4919 | For each Objective-C class, check if any of its instance variables is a |
4920 | C++ object with a non-trivial default constructor. If so, synthesize a | |
4921 | special @code{- (id) .cxx_construct} instance method which runs | |
4922 | non-trivial default constructors on any such instance variables, in order, | |
4923 | and then return @code{self}. Similarly, check if any instance variable | |
4924 | is a C++ object with a non-trivial destructor, and if so, synthesize a | |
4925 | special @code{- (void) .cxx_destruct} method which runs | |
4926 | all such default destructors, in reverse order. | |
4927 | ||
4928 | The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct} | |
4929 | methods thusly generated only operate on instance variables | |
4930 | declared in the current Objective-C class, and not those inherited | |
4931 | from superclasses. It is the responsibility of the Objective-C | |
4932 | runtime to invoke all such methods in an object's inheritance | |
4933 | hierarchy. The @code{- (id) .cxx_construct} methods are invoked | |
4934 | by the runtime immediately after a new object instance is allocated; | |
4935 | the @code{- (void) .cxx_destruct} methods are invoked immediately | |
4936 | before the runtime deallocates an object instance. | |
4937 | ||
4938 | As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has | |
4939 | support for invoking the @code{- (id) .cxx_construct} and | |
4940 | @code{- (void) .cxx_destruct} methods. | |
4941 | ||
d77de738 | 4942 | @opindex fobjc-direct-dispatch |
ddf6fe37 | 4943 | @item -fobjc-direct-dispatch |
d77de738 ML |
4944 | Allow fast jumps to the message dispatcher. On Darwin this is |
4945 | accomplished via the comm page. | |
4946 | ||
d77de738 | 4947 | @opindex fobjc-exceptions |
ddf6fe37 | 4948 | @item -fobjc-exceptions |
d77de738 ML |
4949 | Enable syntactic support for structured exception handling in |
4950 | Objective-C, similar to what is offered by C++. This option | |
4951 | is required to use the Objective-C keywords @code{@@try}, | |
4952 | @code{@@throw}, @code{@@catch}, @code{@@finally} and | |
4953 | @code{@@synchronized}. This option is available with both the GNU | |
4954 | runtime and the NeXT runtime (but not available in conjunction with | |
4955 | the NeXT runtime on Mac OS X 10.2 and earlier). | |
4956 | ||
d77de738 | 4957 | @opindex fobjc-gc |
ddf6fe37 | 4958 | @item -fobjc-gc |
d77de738 ML |
4959 | Enable garbage collection (GC) in Objective-C and Objective-C++ |
4960 | programs. This option is only available with the NeXT runtime; the | |
4961 | GNU runtime has a different garbage collection implementation that | |
4962 | does not require special compiler flags. | |
4963 | ||
d77de738 | 4964 | @opindex fobjc-nilcheck |
ddf6fe37 | 4965 | @item -fobjc-nilcheck |
d77de738 ML |
4966 | For the NeXT runtime with version 2 of the ABI, check for a nil |
4967 | receiver in method invocations before doing the actual method call. | |
4968 | This is the default and can be disabled using | |
4969 | @option{-fno-objc-nilcheck}. Class methods and super calls are never | |
4970 | checked for nil in this way no matter what this flag is set to. | |
4971 | Currently this flag does nothing when the GNU runtime, or an older | |
4972 | version of the NeXT runtime ABI, is used. | |
4973 | ||
d77de738 | 4974 | @opindex fobjc-std |
ddf6fe37 | 4975 | @item -fobjc-std=objc1 |
d77de738 ML |
4976 | Conform to the language syntax of Objective-C 1.0, the language |
4977 | recognized by GCC 4.0. This only affects the Objective-C additions to | |
4978 | the C/C++ language; it does not affect conformance to C/C++ standards, | |
4979 | which is controlled by the separate C/C++ dialect option flags. When | |
4980 | this option is used with the Objective-C or Objective-C++ compiler, | |
4981 | any Objective-C syntax that is not recognized by GCC 4.0 is rejected. | |
4982 | This is useful if you need to make sure that your Objective-C code can | |
4983 | be compiled with older versions of GCC@. | |
4984 | ||
d77de738 | 4985 | @opindex freplace-objc-classes |
ddf6fe37 | 4986 | @item -freplace-objc-classes |
d77de738 ML |
4987 | Emit a special marker instructing @command{ld(1)} not to statically link in |
4988 | the resulting object file, and allow @command{dyld(1)} to load it in at | |
4989 | run time instead. This is used in conjunction with the Fix-and-Continue | |
4990 | debugging mode, where the object file in question may be recompiled and | |
4991 | dynamically reloaded in the course of program execution, without the need | |
4992 | to restart the program itself. Currently, Fix-and-Continue functionality | |
4993 | is only available in conjunction with the NeXT runtime on Mac OS X 10.3 | |
4994 | and later. | |
4995 | ||
d77de738 | 4996 | @opindex fzero-link |
ddf6fe37 | 4997 | @item -fzero-link |
d77de738 ML |
4998 | When compiling for the NeXT runtime, the compiler ordinarily replaces calls |
4999 | to @code{objc_getClass("@dots{}")} (when the name of the class is known at | |
5000 | compile time) with static class references that get initialized at load time, | |
5001 | which improves run-time performance. Specifying the @option{-fzero-link} flag | |
5002 | suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")} | |
5003 | to be retained. This is useful in Zero-Link debugging mode, since it allows | |
5004 | for individual class implementations to be modified during program execution. | |
5005 | The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")} | |
5006 | regardless of command-line options. | |
5007 | ||
d77de738 ML |
5008 | @opindex fno-local-ivars |
5009 | @opindex flocal-ivars | |
ddf6fe37 | 5010 | @item -fno-local-ivars |
d77de738 ML |
5011 | By default instance variables in Objective-C can be accessed as if |
5012 | they were local variables from within the methods of the class they're | |
5013 | declared in. This can lead to shadowing between instance variables | |
5014 | and other variables declared either locally inside a class method or | |
5015 | globally with the same name. Specifying the @option{-fno-local-ivars} | |
5016 | flag disables this behavior thus avoiding variable shadowing issues. | |
5017 | ||
d77de738 | 5018 | @opindex fivar-visibility |
ddf6fe37 | 5019 | @item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]} |
d77de738 ML |
5020 | Set the default instance variable visibility to the specified option |
5021 | so that instance variables declared outside the scope of any access | |
5022 | modifier directives default to the specified visibility. | |
5023 | ||
d77de738 | 5024 | @opindex gen-decls |
ddf6fe37 | 5025 | @item -gen-decls |
d77de738 ML |
5026 | Dump interface declarations for all classes seen in the source file to a |
5027 | file named @file{@var{sourcename}.decl}. | |
5028 | ||
d77de738 ML |
5029 | @opindex Wassign-intercept |
5030 | @opindex Wno-assign-intercept | |
ddf6fe37 | 5031 | @item -Wassign-intercept @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5032 | Warn whenever an Objective-C assignment is being intercepted by the |
5033 | garbage collector. | |
5034 | ||
d77de738 ML |
5035 | @opindex Wproperty-assign-default |
5036 | @opindex Wno-property-assign-default | |
ddf6fe37 | 5037 | @item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5038 | Do not warn if a property for an Objective-C object has no assign |
5039 | semantics specified. | |
5040 | ||
d77de738 ML |
5041 | @opindex Wno-protocol |
5042 | @opindex Wprotocol | |
ddf6fe37 | 5043 | @item -Wno-protocol @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5044 | If a class is declared to implement a protocol, a warning is issued for |
5045 | every method in the protocol that is not implemented by the class. The | |
5046 | default behavior is to issue a warning for every method not explicitly | |
5047 | implemented in the class, even if a method implementation is inherited | |
5048 | from the superclass. If you use the @option{-Wno-protocol} option, then | |
5049 | methods inherited from the superclass are considered to be implemented, | |
5050 | and no warning is issued for them. | |
5051 | ||
d77de738 | 5052 | @opindex Wobjc-root-class |
ddf6fe37 | 5053 | @item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5054 | Warn if a class interface lacks a superclass. Most classes will inherit |
5055 | from @code{NSObject} (or @code{Object}) for example. When declaring | |
5056 | classes intended to be root classes, the warning can be suppressed by | |
5057 | marking their interfaces with @code{__attribute__((objc_root_class))}. | |
5058 | ||
d77de738 ML |
5059 | @opindex Wselector |
5060 | @opindex Wno-selector | |
ddf6fe37 | 5061 | @item -Wselector @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5062 | Warn if multiple methods of different types for the same selector are |
5063 | found during compilation. The check is performed on the list of methods | |
5064 | in the final stage of compilation. Additionally, a check is performed | |
5065 | for each selector appearing in a @code{@@selector(@dots{})} | |
5066 | expression, and a corresponding method for that selector has been found | |
5067 | during compilation. Because these checks scan the method table only at | |
5068 | the end of compilation, these warnings are not produced if the final | |
5069 | stage of compilation is not reached, for example because an error is | |
5070 | found during compilation, or because the @option{-fsyntax-only} option is | |
5071 | being used. | |
5072 | ||
d77de738 ML |
5073 | @opindex Wstrict-selector-match |
5074 | @opindex Wno-strict-selector-match | |
ddf6fe37 | 5075 | @item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5076 | Warn if multiple methods with differing argument and/or return types are |
5077 | found for a given selector when attempting to send a message using this | |
5078 | selector to a receiver of type @code{id} or @code{Class}. When this flag | |
5079 | is off (which is the default behavior), the compiler omits such warnings | |
5080 | if any differences found are confined to types that share the same size | |
5081 | and alignment. | |
5082 | ||
d77de738 ML |
5083 | @opindex Wundeclared-selector |
5084 | @opindex Wno-undeclared-selector | |
ddf6fe37 | 5085 | @item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5086 | Warn if a @code{@@selector(@dots{})} expression referring to an |
5087 | undeclared selector is found. A selector is considered undeclared if no | |
5088 | method with that name has been declared before the | |
5089 | @code{@@selector(@dots{})} expression, either explicitly in an | |
5090 | @code{@@interface} or @code{@@protocol} declaration, or implicitly in | |
5091 | an @code{@@implementation} section. This option always performs its | |
5092 | checks as soon as a @code{@@selector(@dots{})} expression is found, | |
5093 | while @option{-Wselector} only performs its checks in the final stage of | |
5094 | compilation. This also enforces the coding style convention | |
5095 | that methods and selectors must be declared before being used. | |
5096 | ||
d77de738 | 5097 | @opindex print-objc-runtime-info |
ddf6fe37 | 5098 | @item -print-objc-runtime-info |
d77de738 ML |
5099 | Generate C header describing the largest structure that is passed by |
5100 | value, if any. | |
5101 | ||
5102 | @end table | |
5103 | ||
5104 | @node Diagnostic Message Formatting Options | |
5105 | @section Options to Control Diagnostic Messages Formatting | |
5106 | @cindex options to control diagnostics formatting | |
5107 | @cindex diagnostic messages | |
5108 | @cindex message formatting | |
5109 | ||
5110 | Traditionally, diagnostic messages have been formatted irrespective of | |
5111 | the output device's aspect (e.g.@: its width, @dots{}). You can use the | |
5112 | options described below | |
5113 | to control the formatting algorithm for diagnostic messages, | |
5114 | e.g.@: how many characters per line, how often source location | |
5115 | information should be reported. Note that some language front ends may not | |
5116 | honor these options. | |
5117 | ||
5118 | @table @gcctabopt | |
d77de738 | 5119 | @opindex fmessage-length |
ddf6fe37 | 5120 | @item -fmessage-length=@var{n} |
d77de738 ML |
5121 | Try to format error messages so that they fit on lines of about |
5122 | @var{n} characters. If @var{n} is zero, then no line-wrapping is | |
5123 | done; each error message appears on a single line. This is the | |
5124 | default for all front ends. | |
5125 | ||
5126 | Note - this option also affects the display of the @samp{#error} and | |
5127 | @samp{#warning} pre-processor directives, and the @samp{deprecated} | |
5128 | function/type/variable attribute. It does not however affect the | |
5129 | @samp{pragma GCC warning} and @samp{pragma GCC error} pragmas. | |
5130 | ||
5131 | @item -fdiagnostics-plain-output | |
5132 | This option requests that diagnostic output look as plain as possible, which | |
5133 | may be useful when running @command{dejagnu} or other utilities that need to | |
5134 | parse diagnostics output and prefer that it remain more stable over time. | |
5135 | @option{-fdiagnostics-plain-output} is currently equivalent to the following | |
5136 | options: | |
43b72ede AA |
5137 | @gccoptlist{-fno-diagnostics-show-caret |
5138 | -fno-diagnostics-show-line-numbers | |
5139 | -fdiagnostics-color=never | |
5140 | -fdiagnostics-urls=never | |
4f01ae37 DM |
5141 | -fdiagnostics-path-format=separate-events |
5142 | -fdiagnostics-text-art-charset=none} | |
d77de738 ML |
5143 | In the future, if GCC changes the default appearance of its diagnostics, the |
5144 | corresponding option to disable the new behavior will be added to this list. | |
5145 | ||
d77de738 | 5146 | @opindex fdiagnostics-show-location |
ddf6fe37 | 5147 | @item -fdiagnostics-show-location=once |
d77de738 ML |
5148 | Only meaningful in line-wrapping mode. Instructs the diagnostic messages |
5149 | reporter to emit source location information @emph{once}; that is, in | |
5150 | case the message is too long to fit on a single physical line and has to | |
5151 | be wrapped, the source location won't be emitted (as prefix) again, | |
5152 | over and over, in subsequent continuation lines. This is the default | |
5153 | behavior. | |
5154 | ||
5155 | @item -fdiagnostics-show-location=every-line | |
5156 | Only meaningful in line-wrapping mode. Instructs the diagnostic | |
5157 | messages reporter to emit the same source location information (as | |
5158 | prefix) for physical lines that result from the process of breaking | |
5159 | a message which is too long to fit on a single line. | |
5160 | ||
ddf6fe37 | 5161 | @opindex fdiagnostics-color |
d77de738 ML |
5162 | @cindex highlight, color |
5163 | @vindex GCC_COLORS @r{environment variable} | |
f33d7a88 AA |
5164 | @item -fdiagnostics-color[=@var{WHEN}] |
5165 | @itemx -fno-diagnostics-color | |
d77de738 ML |
5166 | Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always}, |
5167 | or @samp{auto}. The default depends on how the compiler has been configured, | |
5168 | it can be any of the above @var{WHEN} options or also @samp{never} | |
5169 | if @env{GCC_COLORS} environment variable isn't present in the environment, | |
5170 | and @samp{auto} otherwise. | |
5171 | @samp{auto} makes GCC use color only when the standard error is a terminal, | |
5172 | and when not executing in an emacs shell. | |
5173 | The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are | |
5174 | aliases for @option{-fdiagnostics-color=always} and | |
5175 | @option{-fdiagnostics-color=never}, respectively. | |
5176 | ||
5177 | The colors are defined by the environment variable @env{GCC_COLORS}. | |
5178 | Its value is a colon-separated list of capabilities and Select Graphic | |
5179 | Rendition (SGR) substrings. SGR commands are interpreted by the | |
5180 | terminal or terminal emulator. (See the section in the documentation | |
5181 | of your text terminal for permitted values and their meanings as | |
5182 | character attributes.) These substring values are integers in decimal | |
5183 | representation and can be concatenated with semicolons. | |
5184 | Common values to concatenate include | |
5185 | @samp{1} for bold, | |
5186 | @samp{4} for underline, | |
5187 | @samp{5} for blink, | |
5188 | @samp{7} for inverse, | |
5189 | @samp{39} for default foreground color, | |
5190 | @samp{30} to @samp{37} for foreground colors, | |
5191 | @samp{90} to @samp{97} for 16-color mode foreground colors, | |
5192 | @samp{38;5;0} to @samp{38;5;255} | |
5193 | for 88-color and 256-color modes foreground colors, | |
5194 | @samp{49} for default background color, | |
5195 | @samp{40} to @samp{47} for background colors, | |
5196 | @samp{100} to @samp{107} for 16-color mode background colors, | |
5197 | and @samp{48;5;0} to @samp{48;5;255} | |
5198 | for 88-color and 256-color modes background colors. | |
5199 | ||
5200 | The default @env{GCC_COLORS} is | |
5201 | @smallexample | |
5202 | error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\ | |
5203 | quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\ | |
5204 | diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\ | |
5205 | type-diff=01;32:fnname=01;32:targs=35 | |
5206 | @end smallexample | |
5207 | @noindent | |
5208 | where @samp{01;31} is bold red, @samp{01;35} is bold magenta, | |
5209 | @samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue, | |
5210 | @samp{01} is bold, and @samp{31} is red. | |
5211 | Setting @env{GCC_COLORS} to the empty string disables colors. | |
5212 | Supported capabilities are as follows. | |
5213 | ||
5214 | @table @code | |
d77de738 | 5215 | @vindex error GCC_COLORS @r{capability} |
f33d7a88 | 5216 | @item error= |
d77de738 ML |
5217 | SGR substring for error: markers. |
5218 | ||
d77de738 | 5219 | @vindex warning GCC_COLORS @r{capability} |
f33d7a88 | 5220 | @item warning= |
d77de738 ML |
5221 | SGR substring for warning: markers. |
5222 | ||
d77de738 | 5223 | @vindex note GCC_COLORS @r{capability} |
f33d7a88 | 5224 | @item note= |
d77de738 ML |
5225 | SGR substring for note: markers. |
5226 | ||
d77de738 | 5227 | @vindex path GCC_COLORS @r{capability} |
f33d7a88 | 5228 | @item path= |
d77de738 ML |
5229 | SGR substring for colorizing paths of control-flow events as printed |
5230 | via @option{-fdiagnostics-path-format=}, such as the identifiers of | |
5231 | individual events and lines indicating interprocedural calls and returns. | |
5232 | ||
d77de738 | 5233 | @vindex range1 GCC_COLORS @r{capability} |
f33d7a88 | 5234 | @item range1= |
d77de738 ML |
5235 | SGR substring for first additional range. |
5236 | ||
d77de738 | 5237 | @vindex range2 GCC_COLORS @r{capability} |
f33d7a88 | 5238 | @item range2= |
d77de738 ML |
5239 | SGR substring for second additional range. |
5240 | ||
d77de738 | 5241 | @vindex locus GCC_COLORS @r{capability} |
f33d7a88 | 5242 | @item locus= |
d77de738 ML |
5243 | SGR substring for location information, @samp{file:line} or |
5244 | @samp{file:line:column} etc. | |
5245 | ||
d77de738 | 5246 | @vindex quote GCC_COLORS @r{capability} |
f33d7a88 | 5247 | @item quote= |
d77de738 ML |
5248 | SGR substring for information printed within quotes. |
5249 | ||
d77de738 | 5250 | @vindex fnname GCC_COLORS @r{capability} |
f33d7a88 | 5251 | @item fnname= |
d77de738 ML |
5252 | SGR substring for names of C++ functions. |
5253 | ||
d77de738 | 5254 | @vindex targs GCC_COLORS @r{capability} |
f33d7a88 | 5255 | @item targs= |
d77de738 ML |
5256 | SGR substring for C++ function template parameter bindings. |
5257 | ||
d77de738 | 5258 | @vindex fixit-insert GCC_COLORS @r{capability} |
f33d7a88 | 5259 | @item fixit-insert= |
d77de738 ML |
5260 | SGR substring for fix-it hints suggesting text to |
5261 | be inserted or replaced. | |
5262 | ||
d77de738 | 5263 | @vindex fixit-delete GCC_COLORS @r{capability} |
f33d7a88 | 5264 | @item fixit-delete= |
d77de738 ML |
5265 | SGR substring for fix-it hints suggesting text to |
5266 | be deleted. | |
5267 | ||
d77de738 | 5268 | @vindex diff-filename GCC_COLORS @r{capability} |
f33d7a88 | 5269 | @item diff-filename= |
d77de738 ML |
5270 | SGR substring for filename headers within generated patches. |
5271 | ||
d77de738 | 5272 | @vindex diff-hunk GCC_COLORS @r{capability} |
f33d7a88 | 5273 | @item diff-hunk= |
d77de738 ML |
5274 | SGR substring for the starts of hunks within generated patches. |
5275 | ||
d77de738 | 5276 | @vindex diff-delete GCC_COLORS @r{capability} |
f33d7a88 | 5277 | @item diff-delete= |
d77de738 ML |
5278 | SGR substring for deleted lines within generated patches. |
5279 | ||
d77de738 | 5280 | @vindex diff-insert GCC_COLORS @r{capability} |
f33d7a88 | 5281 | @item diff-insert= |
d77de738 ML |
5282 | SGR substring for inserted lines within generated patches. |
5283 | ||
d77de738 | 5284 | @vindex type-diff GCC_COLORS @r{capability} |
f33d7a88 | 5285 | @item type-diff= |
d77de738 ML |
5286 | SGR substring for highlighting mismatching types within template |
5287 | arguments in the C++ frontend. | |
5288 | @end table | |
5289 | ||
d77de738 ML |
5290 | @opindex fdiagnostics-urls |
5291 | @cindex urls | |
5292 | @vindex GCC_URLS @r{environment variable} | |
5293 | @vindex TERM_URLS @r{environment variable} | |
f33d7a88 | 5294 | @item -fdiagnostics-urls[=@var{WHEN}] |
d77de738 ML |
5295 | Use escape sequences to embed URLs in diagnostics. For example, when |
5296 | @option{-fdiagnostics-show-option} emits text showing the command-line | |
5297 | option controlling a diagnostic, embed a URL for documentation of that | |
5298 | option. | |
5299 | ||
5300 | @var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}. | |
5301 | @samp{auto} makes GCC use URL escape sequences only when the standard error | |
5302 | is a terminal, and when not executing in an emacs shell or any graphical | |
5303 | terminal which is known to be incompatible with this feature, see below. | |
5304 | ||
5305 | The default depends on how the compiler has been configured. | |
5306 | It can be any of the above @var{WHEN} options. | |
5307 | ||
5308 | GCC can also be configured (via the | |
5309 | @option{--with-diagnostics-urls=auto-if-env} configure-time option) | |
5310 | so that the default is affected by environment variables. | |
5311 | Under such a configuration, GCC defaults to using @samp{auto} | |
5312 | if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are | |
5313 | present and non-empty in the environment of the compiler, or @samp{never} | |
5314 | if neither are. | |
5315 | ||
5316 | However, even with @option{-fdiagnostics-urls=always} the behavior is | |
5317 | dependent on those environment variables: | |
5318 | If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in | |
5319 | diagnostics. If set to @samp{st}, URLs use ST escape sequences. | |
5320 | If set to @samp{bel}, the default, URLs use BEL escape sequences. | |
5321 | Any other non-empty value enables the feature. | |
5322 | If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback. | |
5323 | Note: ST is an ANSI escape sequence, string terminator @samp{ESC \}, | |
5324 | BEL is an ASCII character, CTRL-G that usually sounds like a beep. | |
5325 | ||
5326 | At this time GCC tries to detect also a few terminals that are known to | |
5327 | not implement the URL feature, and have bugs or at least had bugs in | |
5328 | some versions that are still in use, where the URL escapes are likely | |
5329 | to misbehave, i.e. print garbage on the screen. | |
5330 | That list is currently xfce4-terminal, certain known to be buggy | |
5331 | gnome-terminal versions, the linux console, and mingw. | |
5332 | This check can be skipped with the @option{-fdiagnostics-urls=always}. | |
5333 | ||
d77de738 ML |
5334 | @opindex fno-diagnostics-show-option |
5335 | @opindex fdiagnostics-show-option | |
ddf6fe37 | 5336 | @item -fno-diagnostics-show-option |
d77de738 ML |
5337 | By default, each diagnostic emitted includes text indicating the |
5338 | command-line option that directly controls the diagnostic (if such an | |
5339 | option is known to the diagnostic machinery). Specifying the | |
5340 | @option{-fno-diagnostics-show-option} flag suppresses that behavior. | |
5341 | ||
d77de738 ML |
5342 | @opindex fno-diagnostics-show-caret |
5343 | @opindex fdiagnostics-show-caret | |
ddf6fe37 | 5344 | @item -fno-diagnostics-show-caret |
d77de738 ML |
5345 | By default, each diagnostic emitted includes the original source line |
5346 | and a caret @samp{^} indicating the column. This option suppresses this | |
5347 | information. The source line is truncated to @var{n} characters, if | |
5348 | the @option{-fmessage-length=n} option is given. When the output is done | |
5349 | to the terminal, the width is limited to the width given by the | |
5350 | @env{COLUMNS} environment variable or, if not set, to the terminal width. | |
5351 | ||
d77de738 ML |
5352 | @opindex fno-diagnostics-show-labels |
5353 | @opindex fdiagnostics-show-labels | |
ddf6fe37 | 5354 | @item -fno-diagnostics-show-labels |
d77de738 ML |
5355 | By default, when printing source code (via @option{-fdiagnostics-show-caret}), |
5356 | diagnostics can label ranges of source code with pertinent information, such | |
5357 | as the types of expressions: | |
5358 | ||
5359 | @smallexample | |
5360 | printf ("foo %s bar", long_i + long_j); | |
5361 | ~^ ~~~~~~~~~~~~~~~ | |
5362 | | | | |
5363 | char * long int | |
5364 | @end smallexample | |
5365 | ||
5366 | This option suppresses the printing of these labels (in the example above, | |
5367 | the vertical bars and the ``char *'' and ``long int'' text). | |
5368 | ||
d77de738 ML |
5369 | @opindex fno-diagnostics-show-cwe |
5370 | @opindex fdiagnostics-show-cwe | |
ddf6fe37 | 5371 | @item -fno-diagnostics-show-cwe |
d77de738 ML |
5372 | Diagnostic messages can optionally have an associated |
5373 | @uref{https://cwe.mitre.org/index.html, CWE} identifier. | |
5374 | GCC itself only provides such metadata for some of the @option{-fanalyzer} | |
5375 | diagnostics. GCC plugins may also provide diagnostics with such metadata. | |
5376 | By default, if this information is present, it will be printed with | |
5377 | the diagnostic. This option suppresses the printing of this metadata. | |
5378 | ||
d77de738 ML |
5379 | @opindex fno-diagnostics-show-rules |
5380 | @opindex fdiagnostics-show-rules | |
ddf6fe37 | 5381 | @item -fno-diagnostics-show-rules |
d77de738 ML |
5382 | Diagnostic messages can optionally have rules associated with them, such |
5383 | as from a coding standard, or a specification. | |
5384 | GCC itself does not do this for any of its diagnostics, but plugins may do so. | |
5385 | By default, if this information is present, it will be printed with | |
5386 | the diagnostic. This option suppresses the printing of this metadata. | |
5387 | ||
d77de738 ML |
5388 | @opindex fno-diagnostics-show-line-numbers |
5389 | @opindex fdiagnostics-show-line-numbers | |
ddf6fe37 | 5390 | @item -fno-diagnostics-show-line-numbers |
d77de738 ML |
5391 | By default, when printing source code (via @option{-fdiagnostics-show-caret}), |
5392 | a left margin is printed, showing line numbers. This option suppresses this | |
5393 | left margin. | |
5394 | ||
d77de738 | 5395 | @opindex fdiagnostics-minimum-margin-width |
ddf6fe37 | 5396 | @item -fdiagnostics-minimum-margin-width=@var{width} |
d77de738 ML |
5397 | This option controls the minimum width of the left margin printed by |
5398 | @option{-fdiagnostics-show-line-numbers}. It defaults to 6. | |
5399 | ||
d77de738 | 5400 | @opindex fdiagnostics-parseable-fixits |
ddf6fe37 | 5401 | @item -fdiagnostics-parseable-fixits |
d77de738 ML |
5402 | Emit fix-it hints in a machine-parseable format, suitable for consumption |
5403 | by IDEs. For each fix-it, a line will be printed after the relevant | |
5404 | diagnostic, starting with the string ``fix-it:''. For example: | |
5405 | ||
5406 | @smallexample | |
5407 | fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all" | |
5408 | @end smallexample | |
5409 | ||
5410 | The location is expressed as a half-open range, expressed as a count of | |
5411 | bytes, starting at byte 1 for the initial column. In the above example, | |
5412 | bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the | |
5413 | given string: | |
5414 | ||
5415 | @smallexample | |
5416 | 00000000011111111112222222222 | |
5417 | 12345678901234567890123456789 | |
5418 | gtk_widget_showall (dlg); | |
5419 | ^^^^^^^^^^^^^^^^^^ | |
5420 | gtk_widget_show_all | |
5421 | @end smallexample | |
5422 | ||
5423 | The filename and replacement string escape backslash as ``\\", tab as ``\t'', | |
5424 | newline as ``\n'', double quotes as ``\"'', non-printable characters as octal | |
5425 | (e.g. vertical tab as ``\013''). | |
5426 | ||
5427 | An empty replacement string indicates that the given range is to be removed. | |
5428 | An empty range (e.g. ``45:3-45:3'') indicates that the string is to | |
5429 | be inserted at the given position. | |
5430 | ||
d77de738 | 5431 | @opindex fdiagnostics-generate-patch |
ddf6fe37 | 5432 | @item -fdiagnostics-generate-patch |
d77de738 ML |
5433 | Print fix-it hints to stderr in unified diff format, after any diagnostics |
5434 | are printed. For example: | |
5435 | ||
5436 | @smallexample | |
5437 | --- test.c | |
5438 | +++ test.c | |
5439 | @@ -42,5 +42,5 @@ | |
5440 | ||
5441 | void show_cb(GtkDialog *dlg) | |
5442 | @{ | |
5443 | - gtk_widget_showall(dlg); | |
5444 | + gtk_widget_show_all(dlg); | |
5445 | @} | |
5446 | ||
5447 | @end smallexample | |
5448 | ||
5449 | The diff may or may not be colorized, following the same rules | |
5450 | as for diagnostics (see @option{-fdiagnostics-color}). | |
5451 | ||
d77de738 | 5452 | @opindex fdiagnostics-show-template-tree |
ddf6fe37 | 5453 | @item -fdiagnostics-show-template-tree |
d77de738 ML |
5454 | |
5455 | In the C++ frontend, when printing diagnostics showing mismatching | |
5456 | template types, such as: | |
5457 | ||
5458 | @smallexample | |
5459 | could not convert 'std::map<int, std::vector<double> >()' | |
5460 | from 'map<[...],vector<double>>' to 'map<[...],vector<float>> | |
5461 | @end smallexample | |
5462 | ||
5463 | the @option{-fdiagnostics-show-template-tree} flag enables printing a | |
5464 | tree-like structure showing the common and differing parts of the types, | |
5465 | such as: | |
5466 | ||
5467 | @smallexample | |
5468 | map< | |
5469 | [...], | |
5470 | vector< | |
5471 | [double != float]>> | |
5472 | @end smallexample | |
5473 | ||
5474 | The parts that differ are highlighted with color (``double'' and | |
5475 | ``float'' in this case). | |
5476 | ||
d77de738 ML |
5477 | @opindex fno-elide-type |
5478 | @opindex felide-type | |
ddf6fe37 | 5479 | @item -fno-elide-type |
d77de738 ML |
5480 | By default when the C++ frontend prints diagnostics showing mismatching |
5481 | template types, common parts of the types are printed as ``[...]'' to | |
5482 | simplify the error message. For example: | |
5483 | ||
5484 | @smallexample | |
5485 | could not convert 'std::map<int, std::vector<double> >()' | |
5486 | from 'map<[...],vector<double>>' to 'map<[...],vector<float>> | |
5487 | @end smallexample | |
5488 | ||
5489 | Specifying the @option{-fno-elide-type} flag suppresses that behavior. | |
5490 | This flag also affects the output of the | |
5491 | @option{-fdiagnostics-show-template-tree} flag. | |
5492 | ||
d77de738 | 5493 | @opindex fdiagnostics-path-format |
ddf6fe37 | 5494 | @item -fdiagnostics-path-format=@var{KIND} |
d77de738 ML |
5495 | Specify how to print paths of control-flow events for diagnostics that |
5496 | have such a path associated with them. | |
5497 | ||
5498 | @var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events}, | |
5499 | the default. | |
5500 | ||
5501 | @samp{none} means to not print diagnostic paths. | |
5502 | ||
5503 | @samp{separate-events} means to print a separate ``note'' diagnostic for | |
5504 | each event within the diagnostic. For example: | |
5505 | ||
5506 | @smallexample | |
5507 | test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter | |
5508 | test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL | |
5509 | test.c:27:3: note: (2) when 'i < count' | |
5510 | test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1 | |
5511 | @end smallexample | |
5512 | ||
5513 | @samp{inline-events} means to print the events ``inline'' within the source | |
5514 | code. This view attempts to consolidate the events into runs of | |
5515 | sufficiently-close events, printing them as labelled ranges within the source. | |
5516 | ||
5517 | For example, the same events as above might be printed as: | |
5518 | ||
5519 | @smallexample | |
5520 | 'test': events 1-3 | |
5521 | | | |
5522 | | 25 | list = PyList_New(0); | |
5523 | | | ^~~~~~~~~~~~~ | |
5524 | | | | | |
5525 | | | (1) when 'PyList_New' fails, returning NULL | |
5526 | | 26 | | |
5527 | | 27 | for (i = 0; i < count; i++) @{ | |
5528 | | | ~~~ | |
5529 | | | | | |
5530 | | | (2) when 'i < count' | |
5531 | | 28 | item = PyLong_FromLong(random()); | |
5532 | | 29 | PyList_Append(list, item); | |
5533 | | | ~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5534 | | | | | |
5535 | | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1 | |
5536 | | | |
5537 | @end smallexample | |
5538 | ||
5539 | Interprocedural control flow is shown by grouping the events by stack frame, | |
5540 | and using indentation to show how stack frames are nested, pushed, and popped. | |
5541 | ||
5542 | For example: | |
5543 | ||
5544 | @smallexample | |
5545 | 'test': events 1-2 | |
5546 | | | |
5547 | | 133 | @{ | |
5548 | | | ^ | |
5549 | | | | | |
5550 | | | (1) entering 'test' | |
5551 | | 134 | boxed_int *obj = make_boxed_int (i); | |
5552 | | | ~~~~~~~~~~~~~~~~~~ | |
5553 | | | | | |
5554 | | | (2) calling 'make_boxed_int' | |
5555 | | | |
5556 | +--> 'make_boxed_int': events 3-4 | |
5557 | | | |
5558 | | 120 | @{ | |
5559 | | | ^ | |
5560 | | | | | |
5561 | | | (3) entering 'make_boxed_int' | |
5562 | | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int)); | |
5563 | | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5564 | | | | | |
5565 | | | (4) calling 'wrapped_malloc' | |
5566 | | | |
5567 | +--> 'wrapped_malloc': events 5-6 | |
5568 | | | |
5569 | | 7 | @{ | |
5570 | | | ^ | |
5571 | | | | | |
5572 | | | (5) entering 'wrapped_malloc' | |
5573 | | 8 | return malloc (size); | |
5574 | | | ~~~~~~~~~~~~~ | |
5575 | | | | | |
5576 | | | (6) calling 'malloc' | |
5577 | | | |
5578 | <-------------+ | |
5579 | | | |
5580 | 'test': event 7 | |
5581 | | | |
5582 | | 138 | free_boxed_int (obj); | |
5583 | | | ^~~~~~~~~~~~~~~~~~~~ | |
5584 | | | | | |
5585 | | | (7) calling 'free_boxed_int' | |
5586 | | | |
5587 | (etc) | |
5588 | @end smallexample | |
5589 | ||
d77de738 | 5590 | @opindex fdiagnostics-show-path-depths |
ddf6fe37 | 5591 | @item -fdiagnostics-show-path-depths |
d77de738 ML |
5592 | This option provides additional information when printing control-flow paths |
5593 | associated with a diagnostic. | |
5594 | ||
5595 | If this is option is provided then the stack depth will be printed for | |
5596 | each run of events within @option{-fdiagnostics-path-format=inline-events}. | |
5597 | If provided with @option{-fdiagnostics-path-format=separate-events}, then | |
5598 | the stack depth and function declaration will be appended when printing | |
5599 | each event. | |
5600 | ||
5601 | This is intended for use by GCC developers and plugin developers when | |
5602 | debugging diagnostics that report interprocedural control flow. | |
5603 | ||
d77de738 ML |
5604 | @opindex fno-show-column |
5605 | @opindex fshow-column | |
ddf6fe37 | 5606 | @item -fno-show-column |
d77de738 ML |
5607 | Do not print column numbers in diagnostics. This may be necessary if |
5608 | diagnostics are being scanned by a program that does not understand the | |
5609 | column numbers, such as @command{dejagnu}. | |
5610 | ||
d77de738 | 5611 | @opindex fdiagnostics-column-unit |
ddf6fe37 | 5612 | @item -fdiagnostics-column-unit=@var{UNIT} |
d77de738 ML |
5613 | Select the units for the column number. This affects traditional diagnostics |
5614 | (in the absence of @option{-fno-show-column}), as well as JSON format | |
5615 | diagnostics if requested. | |
5616 | ||
5617 | The default @var{UNIT}, @samp{display}, considers the number of display | |
5618 | columns occupied by each character. This may be larger than the number | |
5619 | of bytes required to encode the character, in the case of tab | |
5620 | characters, or it may be smaller, in the case of multibyte characters. | |
5621 | For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one | |
5622 | display column, and its UTF-8 encoding requires two bytes; the character | |
5623 | ``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and | |
5624 | its UTF-8 encoding requires four bytes. | |
5625 | ||
5626 | Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte | |
5627 | count in all cases, as was traditionally output by GCC prior to version 11.1.0. | |
5628 | ||
d77de738 | 5629 | @opindex fdiagnostics-column-origin |
ddf6fe37 | 5630 | @item -fdiagnostics-column-origin=@var{ORIGIN} |
d77de738 ML |
5631 | Select the origin for column numbers, i.e. the column number assigned to the |
5632 | first column. The default value of 1 corresponds to traditional GCC | |
5633 | behavior and to the GNU style guide. Some utilities may perform better with an | |
5634 | origin of 0; any non-negative value may be specified. | |
5635 | ||
d77de738 | 5636 | @opindex fdiagnostics-escape-format |
ddf6fe37 | 5637 | @item -fdiagnostics-escape-format=@var{FORMAT} |
d77de738 ML |
5638 | When GCC prints pertinent source lines for a diagnostic it normally attempts |
5639 | to print the source bytes directly. However, some diagnostics relate to encoding | |
5640 | issues in the source file, such as malformed UTF-8, or issues with Unicode | |
5641 | normalization. These diagnostics are flagged so that GCC will escape bytes | |
5642 | that are not printable ASCII when printing their pertinent source lines. | |
5643 | ||
5644 | This option controls how such bytes should be escaped. | |
5645 | ||
5646 | The default @var{FORMAT}, @samp{unicode} displays Unicode characters that | |
5647 | are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not | |
5648 | correspond to a Unicode character validly-encoded in UTF-8-encoded will be | |
5649 | displayed as hexadecimal in the form @samp{<XX>}. | |
5650 | ||
5651 | For example, a source line containing the string @samp{before} followed by the | |
5652 | Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding | |
5653 | 0xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by | |
5654 | the string @samp{after} will be printed for such a diagnostic as: | |
5655 | ||
5656 | @smallexample | |
5657 | before<U+03C0><BF>after | |
5658 | @end smallexample | |
5659 | ||
5660 | Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes | |
5661 | in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII | |
5662 | Unicode characters. For the example above, the following will be printed: | |
5663 | ||
5664 | @smallexample | |
5665 | before<CF><80><BF>after | |
5666 | @end smallexample | |
5667 | ||
4f01ae37 DM |
5668 | @opindex fdiagnostics-text-art-charset |
5669 | @item -fdiagnostics-text-art-charset=@var{CHARSET} | |
5670 | Some diagnostics can contain ``text art'' diagrams: visualizations created | |
5671 | from text, intended to be viewed in a monospaced font. | |
5672 | ||
5673 | This option selects which characters should be used for printing such | |
5674 | diagrams, if any. @var{CHARSET} is @samp{none}, @samp{ascii}, @samp{unicode}, | |
5675 | or @samp{emoji}. | |
5676 | ||
5677 | The @samp{none} value suppresses the printing of such diagrams. | |
5678 | The @samp{ascii} value will ensure that such diagrams are pure ASCII | |
5679 | (``ASCII art''). The @samp{unicode} value will allow for conservative use of | |
5680 | unicode drawing characters (such as box-drawing characters). The @samp{emoji} | |
5681 | value further adds the possibility of emoji in the output (such as emitting | |
5682 | U+26A0 WARNING SIGN followed by U+FE0F VARIATION SELECTOR-16 to select the | |
5683 | emoji variant of the character). | |
5684 | ||
04013e44 DM |
5685 | The default is @samp{emoji}, except when the environment variable @env{LANG} |
5686 | is set to @samp{C}, in which case the default is @samp{ascii}. | |
4f01ae37 | 5687 | |
d77de738 | 5688 | @opindex fdiagnostics-format |
ddf6fe37 | 5689 | @item -fdiagnostics-format=@var{FORMAT} |
d77de738 ML |
5690 | Select a different format for printing diagnostics. |
5691 | @var{FORMAT} is @samp{text}, @samp{sarif-stderr}, @samp{sarif-file}, | |
5692 | @samp{json}, @samp{json-stderr}, or @samp{json-file}. | |
5693 | ||
5694 | The default is @samp{text}. | |
5695 | ||
5696 | The @samp{sarif-stderr} and @samp{sarif-file} formats both emit | |
5697 | diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file | |
5698 | named @file{@var{source}.sarif}, respectively. | |
5699 | ||
5700 | The @samp{json} format is a synonym for @samp{json-stderr}. | |
5701 | The @samp{json-stderr} and @samp{json-file} formats are identical, apart from | |
5702 | where the JSON is emitted to - with the former, the JSON is emitted to stderr, | |
5703 | whereas with @samp{json-file} it is written to @file{@var{source}.gcc.json}. | |
5704 | ||
5705 | The emitted JSON consists of a top-level JSON array containing JSON objects | |
5706 | representing the diagnostics. The JSON is emitted as one line, without | |
5707 | formatting; the examples below have been formatted for clarity. | |
5708 | ||
5709 | Diagnostics can have child diagnostics. For example, this error and note: | |
5710 | ||
5711 | @smallexample | |
5712 | misleading-indentation.c:15:3: warning: this 'if' clause does not | |
5713 | guard... [-Wmisleading-indentation] | |
5714 | 15 | if (flag) | |
5715 | | ^~ | |
5716 | misleading-indentation.c:17:5: note: ...this statement, but the latter | |
5717 | is misleadingly indented as if it were guarded by the 'if' | |
5718 | 17 | y = 2; | |
5719 | | ^ | |
5720 | @end smallexample | |
5721 | ||
5722 | @noindent | |
5723 | might be printed in JSON form (after formatting) like this: | |
5724 | ||
5725 | @smallexample | |
5726 | [ | |
5727 | @{ | |
5728 | "kind": "warning", | |
5729 | "locations": [ | |
5730 | @{ | |
5731 | "caret": @{ | |
5732 | "display-column": 3, | |
5733 | "byte-column": 3, | |
5734 | "column": 3, | |
5735 | "file": "misleading-indentation.c", | |
5736 | "line": 15 | |
5737 | @}, | |
5738 | "finish": @{ | |
5739 | "display-column": 4, | |
5740 | "byte-column": 4, | |
5741 | "column": 4, | |
5742 | "file": "misleading-indentation.c", | |
5743 | "line": 15 | |
5744 | @} | |
5745 | @} | |
5746 | ], | |
5747 | "message": "this \u2018if\u2019 clause does not guard...", | |
5748 | "option": "-Wmisleading-indentation", | |
5749 | "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation", | |
5750 | "children": [ | |
5751 | @{ | |
5752 | "kind": "note", | |
5753 | "locations": [ | |
5754 | @{ | |
5755 | "caret": @{ | |
5756 | "display-column": 5, | |
5757 | "byte-column": 5, | |
5758 | "column": 5, | |
5759 | "file": "misleading-indentation.c", | |
5760 | "line": 17 | |
5761 | @} | |
5762 | @} | |
5763 | ], | |
5764 | "escape-source": false, | |
5765 | "message": "...this statement, but the latter is @dots{}" | |
5766 | @} | |
5767 | ] | |
5768 | "escape-source": false, | |
5769 | "column-origin": 1, | |
5770 | @} | |
5771 | ] | |
5772 | @end smallexample | |
5773 | ||
5774 | @noindent | |
5775 | where the @code{note} is a child of the @code{warning}. | |
5776 | ||
5777 | A diagnostic has a @code{kind}. If this is @code{warning}, then there is | |
5778 | an @code{option} key describing the command-line option controlling the | |
5779 | warning. | |
5780 | ||
5781 | A diagnostic can contain zero or more locations. Each location has an | |
5782 | optional @code{label} string and up to three positions within it: a | |
5783 | @code{caret} position and optional @code{start} and @code{finish} positions. | |
5784 | A position is described by a @code{file} name, a @code{line} number, and | |
5785 | three numbers indicating a column position: | |
5786 | @itemize @bullet | |
5787 | ||
5788 | @item | |
5789 | @code{display-column} counts display columns, accounting for tabs and | |
5790 | multibyte characters. | |
5791 | ||
5792 | @item | |
5793 | @code{byte-column} counts raw bytes. | |
5794 | ||
5795 | @item | |
5796 | @code{column} is equal to one of | |
5797 | the previous two, as dictated by the @option{-fdiagnostics-column-unit} | |
5798 | option. | |
5799 | ||
5800 | @end itemize | |
5801 | All three columns are relative to the origin specified by | |
5802 | @option{-fdiagnostics-column-origin}, which is typically equal to 1 but may | |
5803 | be set, for instance, to 0 for compatibility with other utilities that | |
5804 | number columns from 0. The column origin is recorded in the JSON output in | |
5805 | the @code{column-origin} tag. In the remaining examples below, the extra | |
5806 | column number outputs have been omitted for brevity. | |
5807 | ||
5808 | For example, this error: | |
5809 | ||
5810 | @smallexample | |
5811 | bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' @{aka | |
5812 | 'struct s'@} and 'T' @{aka 'struct t'@}) | |
5813 | 64 | return callee_4a () + callee_4b (); | |
5814 | | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~ | |
5815 | | | | | |
5816 | | | T @{aka struct t@} | |
5817 | | S @{aka struct s@} | |
5818 | @end smallexample | |
5819 | ||
5820 | @noindent | |
5821 | has three locations. Its primary location is at the ``+'' token at column | |
5822 | 23. It has two secondary locations, describing the left and right-hand sides | |
5823 | of the expression, which have labels. It might be printed in JSON form as: | |
5824 | ||
5825 | @smallexample | |
5826 | @{ | |
5827 | "children": [], | |
5828 | "kind": "error", | |
5829 | "locations": [ | |
5830 | @{ | |
5831 | "caret": @{ | |
5832 | "column": 23, "file": "bad-binary-ops.c", "line": 64 | |
5833 | @} | |
5834 | @}, | |
5835 | @{ | |
5836 | "caret": @{ | |
5837 | "column": 10, "file": "bad-binary-ops.c", "line": 64 | |
5838 | @}, | |
5839 | "finish": @{ | |
5840 | "column": 21, "file": "bad-binary-ops.c", "line": 64 | |
5841 | @}, | |
5842 | "label": "S @{aka struct s@}" | |
5843 | @}, | |
5844 | @{ | |
5845 | "caret": @{ | |
5846 | "column": 25, "file": "bad-binary-ops.c", "line": 64 | |
5847 | @}, | |
5848 | "finish": @{ | |
5849 | "column": 36, "file": "bad-binary-ops.c", "line": 64 | |
5850 | @}, | |
5851 | "label": "T @{aka struct t@}" | |
5852 | @} | |
5853 | ], | |
5854 | "escape-source": false, | |
5855 | "message": "invalid operands to binary + @dots{}" | |
5856 | @} | |
5857 | @end smallexample | |
5858 | ||
5859 | If a diagnostic contains fix-it hints, it has a @code{fixits} array, | |
5860 | consisting of half-open intervals, similar to the output of | |
5861 | @option{-fdiagnostics-parseable-fixits}. For example, this diagnostic | |
5862 | with a replacement fix-it hint: | |
5863 | ||
5864 | @smallexample | |
5865 | demo.c:8:15: error: 'struct s' has no member named 'colour'; did you | |
5866 | mean 'color'? | |
5867 | 8 | return ptr->colour; | |
5868 | | ^~~~~~ | |
5869 | | color | |
5870 | @end smallexample | |
5871 | ||
5872 | @noindent | |
5873 | might be printed in JSON form as: | |
5874 | ||
5875 | @smallexample | |
5876 | @{ | |
5877 | "children": [], | |
5878 | "fixits": [ | |
5879 | @{ | |
5880 | "next": @{ | |
5881 | "column": 21, | |
5882 | "file": "demo.c", | |
5883 | "line": 8 | |
5884 | @}, | |
5885 | "start": @{ | |
5886 | "column": 15, | |
5887 | "file": "demo.c", | |
5888 | "line": 8 | |
5889 | @}, | |
5890 | "string": "color" | |
5891 | @} | |
5892 | ], | |
5893 | "kind": "error", | |
5894 | "locations": [ | |
5895 | @{ | |
5896 | "caret": @{ | |
5897 | "column": 15, | |
5898 | "file": "demo.c", | |
5899 | "line": 8 | |
5900 | @}, | |
5901 | "finish": @{ | |
5902 | "column": 20, | |
5903 | "file": "demo.c", | |
5904 | "line": 8 | |
5905 | @} | |
5906 | @} | |
5907 | ], | |
5908 | "escape-source": false, | |
5909 | "message": "\u2018struct s\u2019 has no member named @dots{}" | |
5910 | @} | |
5911 | @end smallexample | |
5912 | ||
5913 | @noindent | |
5914 | where the fix-it hint suggests replacing the text from @code{start} up | |
5915 | to but not including @code{next} with @code{string}'s value. Deletions | |
5916 | are expressed via an empty value for @code{string}, insertions by | |
5917 | having @code{start} equal @code{next}. | |
5918 | ||
5919 | If the diagnostic has a path of control-flow events associated with it, | |
5920 | it has a @code{path} array of objects representing the events. Each | |
5921 | event object has a @code{description} string, a @code{location} object, | |
5922 | along with a @code{function} string and a @code{depth} number for | |
5923 | representing interprocedural paths. The @code{function} represents the | |
5924 | current function at that event, and the @code{depth} represents the | |
5925 | stack depth relative to some baseline: the higher, the more frames are | |
5926 | within the stack. | |
5927 | ||
5928 | For example, the intraprocedural example shown for | |
5929 | @option{-fdiagnostics-path-format=} might have this JSON for its path: | |
5930 | ||
5931 | @smallexample | |
5932 | "path": [ | |
5933 | @{ | |
5934 | "depth": 0, | |
5935 | "description": "when 'PyList_New' fails, returning NULL", | |
5936 | "function": "test", | |
5937 | "location": @{ | |
5938 | "column": 10, | |
5939 | "file": "test.c", | |
5940 | "line": 25 | |
5941 | @} | |
5942 | @}, | |
5943 | @{ | |
5944 | "depth": 0, | |
5945 | "description": "when 'i < count'", | |
5946 | "function": "test", | |
5947 | "location": @{ | |
5948 | "column": 3, | |
5949 | "file": "test.c", | |
5950 | "line": 27 | |
5951 | @} | |
5952 | @}, | |
5953 | @{ | |
5954 | "depth": 0, | |
5955 | "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1", | |
5956 | "function": "test", | |
5957 | "location": @{ | |
5958 | "column": 5, | |
5959 | "file": "test.c", | |
5960 | "line": 29 | |
5961 | @} | |
5962 | @} | |
5963 | ] | |
5964 | @end smallexample | |
5965 | ||
5966 | Diagnostics have a boolean attribute @code{escape-source}, hinting whether | |
5967 | non-ASCII bytes should be escaped when printing the pertinent lines of | |
5968 | source code (@code{true} for diagnostics involving source encoding issues). | |
5969 | ||
5970 | @end table | |
5971 | ||
5972 | @node Warning Options | |
5973 | @section Options to Request or Suppress Warnings | |
5974 | @cindex options to control warnings | |
5975 | @cindex warning messages | |
5976 | @cindex messages, warning | |
5977 | @cindex suppressing warnings | |
5978 | ||
5979 | Warnings are diagnostic messages that report constructions that | |
5980 | are not inherently erroneous but that are risky or suggest there | |
5981 | may have been an error. | |
5982 | ||
5983 | The following language-independent options do not enable specific | |
5984 | warnings but control the kinds of diagnostics produced by GCC@. | |
5985 | ||
5986 | @table @gcctabopt | |
5987 | @cindex syntax checking | |
d77de738 | 5988 | @opindex fsyntax-only |
ddf6fe37 | 5989 | @item -fsyntax-only |
d77de738 ML |
5990 | Check the code for syntax errors, but don't do anything beyond that. |
5991 | ||
d77de738 | 5992 | @opindex fmax-errors |
ddf6fe37 | 5993 | @item -fmax-errors=@var{n} |
d77de738 ML |
5994 | Limits the maximum number of error messages to @var{n}, at which point |
5995 | GCC bails out rather than attempting to continue processing the source | |
5996 | code. If @var{n} is 0 (the default), there is no limit on the number | |
5997 | of error messages produced. If @option{-Wfatal-errors} is also | |
5998 | specified, then @option{-Wfatal-errors} takes precedence over this | |
5999 | option. | |
6000 | ||
d77de738 | 6001 | @opindex w |
ddf6fe37 | 6002 | @item -w |
d77de738 ML |
6003 | Inhibit all warning messages. |
6004 | ||
d77de738 ML |
6005 | @opindex Werror |
6006 | @opindex Wno-error | |
ddf6fe37 | 6007 | @item -Werror |
d77de738 ML |
6008 | Make all warnings into errors. |
6009 | ||
d77de738 ML |
6010 | @opindex Werror= |
6011 | @opindex Wno-error= | |
ddf6fe37 | 6012 | @item -Werror= |
d77de738 ML |
6013 | Make the specified warning into an error. The specifier for a warning |
6014 | is appended; for example @option{-Werror=switch} turns the warnings | |
6015 | controlled by @option{-Wswitch} into errors. This switch takes a | |
6016 | negative form, to be used to negate @option{-Werror} for specific | |
6017 | warnings; for example @option{-Wno-error=switch} makes | |
6018 | @option{-Wswitch} warnings not be errors, even when @option{-Werror} | |
6019 | is in effect. | |
6020 | ||
6021 | The warning message for each controllable warning includes the | |
6022 | option that controls the warning. That option can then be used with | |
6023 | @option{-Werror=} and @option{-Wno-error=} as described above. | |
6024 | (Printing of the option in the warning message can be disabled using the | |
6025 | @option{-fno-diagnostics-show-option} flag.) | |
6026 | ||
6027 | Note that specifying @option{-Werror=}@var{foo} automatically implies | |
6028 | @option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not | |
6029 | imply anything. | |
6030 | ||
d77de738 ML |
6031 | @opindex Wfatal-errors |
6032 | @opindex Wno-fatal-errors | |
ddf6fe37 | 6033 | @item -Wfatal-errors |
d77de738 ML |
6034 | This option causes the compiler to abort compilation on the first error |
6035 | occurred rather than trying to keep going and printing further error | |
6036 | messages. | |
6037 | ||
6038 | @end table | |
6039 | ||
6040 | You can request many specific warnings with options beginning with | |
6041 | @samp{-W}, for example @option{-Wimplicit} to request warnings on | |
6042 | implicit declarations. Each of these specific warning options also | |
6043 | has a negative form beginning @samp{-Wno-} to turn off warnings; for | |
6044 | example, @option{-Wno-implicit}. This manual lists only one of the | |
6045 | two forms, whichever is not the default. For further | |
6046 | language-specific options also refer to @ref{C++ Dialect Options} and | |
6047 | @ref{Objective-C and Objective-C++ Dialect Options}. | |
6048 | Additional warnings can be produced by enabling the static analyzer; | |
6049 | @xref{Static Analyzer Options}. | |
6050 | ||
6051 | Some options, such as @option{-Wall} and @option{-Wextra}, turn on other | |
6052 | options, such as @option{-Wunused}, which may turn on further options, | |
6053 | such as @option{-Wunused-value}. The combined effect of positive and | |
6054 | negative forms is that more specific options have priority over less | |
6055 | specific ones, independently of their position in the command-line. For | |
6056 | options of the same specificity, the last one takes effect. Options | |
6057 | enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect | |
6058 | as if they appeared at the end of the command-line. | |
6059 | ||
6060 | When an unrecognized warning option is requested (e.g., | |
6061 | @option{-Wunknown-warning}), GCC emits a diagnostic stating | |
6062 | that the option is not recognized. However, if the @option{-Wno-} form | |
6063 | is used, the behavior is slightly different: no diagnostic is | |
6064 | produced for @option{-Wno-unknown-warning} unless other diagnostics | |
6065 | are being produced. This allows the use of new @option{-Wno-} options | |
6066 | with old compilers, but if something goes wrong, the compiler | |
6067 | warns that an unrecognized option is present. | |
6068 | ||
6069 | The effectiveness of some warnings depends on optimizations also being | |
6070 | enabled. For example @option{-Wsuggest-final-types} is more effective | |
6071 | with link-time optimization and some instances of other warnings may | |
6072 | not be issued at all unless optimization is enabled. While optimization | |
6073 | in general improves the efficacy of control and data flow sensitive | |
6074 | warnings, in some cases it may also cause false positives. | |
6075 | ||
6076 | @table @gcctabopt | |
d77de738 ML |
6077 | @opindex pedantic |
6078 | @opindex Wpedantic | |
6079 | @opindex Wno-pedantic | |
ddf6fe37 AA |
6080 | @item -Wpedantic |
6081 | @itemx -pedantic | |
d77de738 | 6082 | Issue all the warnings demanded by strict ISO C and ISO C++; |
5fccebdb JM |
6083 | diagnose all programs that use forbidden extensions, and some other |
6084 | programs that do not follow ISO C and ISO C++. This follows the version | |
6085 | of the ISO C or C++ standard specified by any @option{-std} option used. | |
d77de738 ML |
6086 | |
6087 | Valid ISO C and ISO C++ programs should compile properly with or without | |
6088 | this option (though a rare few require @option{-ansi} or a | |
5fccebdb | 6089 | @option{-std} option specifying the version of the standard)@. However, |
d77de738 | 6090 | without this option, certain GNU extensions and traditional C and C++ |
5fccebdb JM |
6091 | features are supported as well. With this option, they are diagnosed |
6092 | (or rejected with @option{-pedantic-errors}). | |
d77de738 ML |
6093 | |
6094 | @option{-Wpedantic} does not cause warning messages for use of the | |
6095 | alternate keywords whose names begin and end with @samp{__}. This alternate | |
6096 | format can also be used to disable warnings for non-ISO @samp{__intN} types, | |
6097 | i.e. @samp{__intN__}. | |
6098 | Pedantic warnings are also disabled in the expression that follows | |
6099 | @code{__extension__}. However, only system header files should use | |
6100 | these escape routes; application programs should avoid them. | |
6101 | @xref{Alternate Keywords}. | |
6102 | ||
5fccebdb JM |
6103 | Some warnings about non-conforming programs are controlled by options |
6104 | other than @option{-Wpedantic}; in many cases they are implied by | |
6105 | @option{-Wpedantic} but can be disabled separately by their specific | |
6106 | option, e.g. @option{-Wpedantic -Wno-pointer-sign}. | |
d77de738 ML |
6107 | |
6108 | Where the standard specified with @option{-std} represents a GNU | |
6109 | extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a | |
6110 | corresponding @dfn{base standard}, the version of ISO C on which the GNU | |
6111 | extended dialect is based. Warnings from @option{-Wpedantic} are given | |
6112 | where they are required by the base standard. (It does not make sense | |
6113 | for such warnings to be given only for features not in the specified GNU | |
6114 | C dialect, since by definition the GNU dialects of C include all | |
6115 | features the compiler supports with the given option, and there would be | |
6116 | nothing to warn about.) | |
6117 | ||
d77de738 | 6118 | @opindex pedantic-errors |
ddf6fe37 | 6119 | @item -pedantic-errors |
d77de738 ML |
6120 | Give an error whenever the @dfn{base standard} (see @option{-Wpedantic}) |
6121 | requires a diagnostic, in some cases where there is undefined behavior | |
6122 | at compile-time and in some other cases that do not prevent compilation | |
6123 | of programs that are valid according to the standard. This is not | |
5fccebdb JM |
6124 | equivalent to @option{-Werror=pedantic}: the latter option is unlikely to be |
6125 | useful, as it only makes errors of the diagnostics that are controlled by | |
6126 | @option{-Wpedantic}, whereas this option also affects required diagnostics that | |
6127 | are always enabled or controlled by options other than @option{-Wpedantic}. | |
6128 | ||
6129 | If you want the required diagnostics that are warnings by default to | |
6130 | be errors instead, but don't also want to enable the @option{-Wpedantic} | |
6131 | diagnostics, you can specify @option{-pedantic-errors -Wno-pedantic} | |
6132 | (or @option{-pedantic-errors -Wno-error=pedantic} to enable them but | |
6133 | only as warnings). | |
6134 | ||
6135 | Some required diagnostics are errors by default, but can be reduced to | |
6136 | warnings using @option{-fpermissive} or their specific warning option, | |
6137 | e.g. @option{-Wno-error=narrowing}. | |
6138 | ||
6139 | Some diagnostics for non-ISO practices are controlled by specific | |
6140 | warning options other than @option{-Wpedantic}, but are also made | |
6141 | errors by @option{-pedantic-errors}. For instance: | |
6142 | ||
6143 | @gccoptlist{ | |
6144 | -Wattributes @r{(for standard attributes)} | |
6145 | -Wchanges-meaning @r{(C++)} | |
6146 | -Wcomma-subscript @r{(C++23 or later)} | |
6147 | -Wdeclaration-after-statement @r{(C90 or earlier)} | |
b106f11d | 6148 | -Welaborated-enum-base @r{(C++11 or later)} |
5fccebdb JM |
6149 | -Wimplicit-int @r{(C99 or later)} |
6150 | -Wimplicit-function-declaration @r{(C99 or later)} | |
6151 | -Wincompatible-pointer-types | |
6152 | -Wint-conversion | |
6153 | -Wlong-long @r{(C90 or earlier)} | |
6154 | -Wmain | |
6155 | -Wnarrowing @r{(C++11 or later)} | |
6156 | -Wpointer-arith | |
6157 | -Wpointer-sign | |
6158 | -Wincompatible-pointer-types | |
6159 | -Wregister @r{(C++17 or later)} | |
6160 | -Wvla @r{(C90 or earlier)} | |
6161 | -Wwrite-strings @r{(C++11 or later)} | |
6162 | } | |
d77de738 | 6163 | |
ef10cb86 JM |
6164 | @opindex fpermissive |
6165 | @item -fpermissive | |
6166 | Downgrade some required diagnostics about nonconformant code from | |
6167 | errors to warnings. Thus, using @option{-fpermissive} allows some | |
6168 | nonconforming code to compile. Some C++ diagnostics are controlled | |
6169 | only by this flag, but it also downgrades some diagnostics that have | |
6170 | their own flag: | |
6171 | ||
6172 | @gccoptlist{ | |
6173 | -Wnarrowing @r{(C++)} | |
6174 | } | |
6175 | ||
d77de738 ML |
6176 | @opindex Wall |
6177 | @opindex Wno-all | |
ddf6fe37 | 6178 | @item -Wall |
d77de738 ML |
6179 | This enables all the warnings about constructions that some users |
6180 | consider questionable, and that are easy to avoid (or modify to | |
6181 | prevent the warning), even in conjunction with macros. This also | |
6182 | enables some language-specific warnings described in @ref{C++ Dialect | |
6183 | Options} and @ref{Objective-C and Objective-C++ Dialect Options}. | |
6184 | ||
6185 | @option{-Wall} turns on the following warning flags: | |
6186 | ||
43b72ede AA |
6187 | @gccoptlist{-Waddress |
6188 | -Warray-bounds=1 @r{(only with} @option{-O2}@r{)} | |
6189 | -Warray-compare | |
6190 | -Warray-parameter=2 @r{(C and Objective-C only)} | |
6191 | -Wbool-compare | |
6192 | -Wbool-operation | |
6193 | -Wc++11-compat -Wc++14-compat | |
6194 | -Wcatch-value @r{(C++ and Objective-C++ only)} | |
6195 | -Wchar-subscripts | |
6196 | -Wcomment | |
6197 | -Wdangling-pointer=2 | |
6198 | -Wduplicate-decl-specifier @r{(C and Objective-C only)} | |
6199 | -Wenum-compare @r{(in C/ObjC; this is on by default in C++)} | |
6200 | -Wenum-int-mismatch @r{(C and Objective-C only)} | |
6201 | -Wformat | |
6202 | -Wformat-overflow | |
6203 | -Wformat-truncation | |
6204 | -Wint-in-bool-context | |
6205 | -Wimplicit @r{(C and Objective-C only)} | |
6206 | -Wimplicit-int @r{(C and Objective-C only)} | |
6207 | -Wimplicit-function-declaration @r{(C and Objective-C only)} | |
6208 | -Winit-self @r{(only for C++)} | |
6209 | -Wlogical-not-parentheses | |
6210 | -Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)} | |
6211 | -Wmaybe-uninitialized | |
6212 | -Wmemset-elt-size | |
6213 | -Wmemset-transposed-args | |
6214 | -Wmisleading-indentation @r{(only for C/C++)} | |
6215 | -Wmismatched-dealloc | |
6216 | -Wmismatched-new-delete @r{(only for C/C++)} | |
6217 | -Wmissing-attributes | |
6218 | -Wmissing-braces @r{(only for C/ObjC)} | |
6219 | -Wmultistatement-macros | |
6220 | -Wnarrowing @r{(only for C++)} | |
6221 | -Wnonnull | |
6222 | -Wnonnull-compare | |
6223 | -Wopenmp-simd | |
6224 | -Wparentheses | |
6225 | -Wpessimizing-move @r{(only for C++)} | |
6226 | -Wpointer-sign | |
6227 | -Wrange-loop-construct @r{(only for C++)} | |
6228 | -Wreorder | |
6229 | -Wrestrict | |
6230 | -Wreturn-type | |
6231 | -Wself-move @r{(only for C++)} | |
6232 | -Wsequence-point | |
6233 | -Wsign-compare @r{(only in C++)} | |
6234 | -Wsizeof-array-div | |
6235 | -Wsizeof-pointer-div | |
6236 | -Wsizeof-pointer-memaccess | |
6237 | -Wstrict-aliasing | |
6238 | -Wstrict-overflow=1 | |
6239 | -Wswitch | |
6240 | -Wtautological-compare | |
6241 | -Wtrigraphs | |
6242 | -Wuninitialized | |
6243 | -Wunknown-pragmas | |
6244 | -Wunused-function | |
6245 | -Wunused-label | |
6246 | -Wunused-value | |
6247 | -Wunused-variable | |
6248 | -Wuse-after-free=2 | |
6249 | -Wvla-parameter @r{(C and Objective-C only)} | |
6250 | -Wvolatile-register-var | |
d77de738 ML |
6251 | -Wzero-length-bounds} |
6252 | ||
6253 | Note that some warning flags are not implied by @option{-Wall}. Some of | |
6254 | them warn about constructions that users generally do not consider | |
6255 | questionable, but which occasionally you might wish to check for; | |
6256 | others warn about constructions that are necessary or hard to avoid in | |
6257 | some cases, and there is no simple way to modify the code to suppress | |
6258 | the warning. Some of them are enabled by @option{-Wextra} but many of | |
6259 | them must be enabled individually. | |
6260 | ||
d77de738 ML |
6261 | @opindex W |
6262 | @opindex Wextra | |
6263 | @opindex Wno-extra | |
ddf6fe37 | 6264 | @item -Wextra |
d77de738 ML |
6265 | This enables some extra warning flags that are not enabled by |
6266 | @option{-Wall}. (This option used to be called @option{-W}. The older | |
6267 | name is still supported, but the newer name is more descriptive.) | |
6268 | ||
43b72ede AA |
6269 | @gccoptlist{-Wclobbered |
6270 | -Wcast-function-type | |
6271 | -Wdeprecated-copy @r{(C++ only)} | |
6272 | -Wempty-body | |
6273 | -Wenum-conversion @r{(C only)} | |
6274 | -Wignored-qualifiers | |
6275 | -Wimplicit-fallthrough=3 | |
6276 | -Wmissing-field-initializers | |
6277 | -Wmissing-parameter-type @r{(C only)} | |
6278 | -Wold-style-declaration @r{(C only)} | |
6279 | -Woverride-init | |
6280 | -Wsign-compare @r{(C only)} | |
6281 | -Wstring-compare | |
6282 | -Wredundant-move @r{(only for C++)} | |
6283 | -Wtype-limits | |
6284 | -Wuninitialized | |
6285 | -Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)} | |
6286 | -Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)} | |
d77de738 ML |
6287 | -Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}} |
6288 | ||
6289 | ||
6290 | The option @option{-Wextra} also prints warning messages for the | |
6291 | following cases: | |
6292 | ||
6293 | @itemize @bullet | |
6294 | ||
6295 | @item | |
6296 | A pointer is compared against integer zero with @code{<}, @code{<=}, | |
6297 | @code{>}, or @code{>=}. | |
6298 | ||
6299 | @item | |
6300 | (C++ only) An enumerator and a non-enumerator both appear in a | |
6301 | conditional expression. | |
6302 | ||
6303 | @item | |
6304 | (C++ only) Ambiguous virtual bases. | |
6305 | ||
6306 | @item | |
6307 | (C++ only) Subscripting an array that has been declared @code{register}. | |
6308 | ||
6309 | @item | |
6310 | (C++ only) Taking the address of a variable that has been declared | |
6311 | @code{register}. | |
6312 | ||
6313 | @item | |
6314 | (C++ only) A base class is not initialized in the copy constructor | |
6315 | of a derived class. | |
6316 | ||
6317 | @end itemize | |
6318 | ||
d77de738 ML |
6319 | @opindex Wabi |
6320 | @opindex Wno-abi | |
ddf6fe37 | 6321 | @item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)} |
d77de738 ML |
6322 | |
6323 | Warn about code affected by ABI changes. This includes code that may | |
6324 | not be compatible with the vendor-neutral C++ ABI as well as the psABI | |
6325 | for the particular target. | |
6326 | ||
6327 | Since G++ now defaults to updating the ABI with each major release, | |
6328 | normally @option{-Wabi} warns only about C++ ABI compatibility | |
6329 | problems if there is a check added later in a release series for an | |
6330 | ABI issue discovered since the initial release. @option{-Wabi} warns | |
6331 | about more things if an older ABI version is selected (with | |
6332 | @option{-fabi-version=@var{n}}). | |
6333 | ||
6334 | @option{-Wabi} can also be used with an explicit version number to | |
6335 | warn about C++ ABI compatibility with a particular @option{-fabi-version} | |
6336 | level, e.g.@: @option{-Wabi=2} to warn about changes relative to | |
6337 | @option{-fabi-version=2}. | |
6338 | ||
6339 | If an explicit version number is provided and | |
6340 | @option{-fabi-compat-version} is not specified, the version number | |
6341 | from this option is used for compatibility aliases. If no explicit | |
6342 | version number is provided with this option, but | |
6343 | @option{-fabi-compat-version} is specified, that version number is | |
6344 | used for C++ ABI warnings. | |
6345 | ||
6346 | Although an effort has been made to warn about | |
6347 | all such cases, there are probably some cases that are not warned about, | |
6348 | even though G++ is generating incompatible code. There may also be | |
6349 | cases where warnings are emitted even though the code that is generated | |
6350 | is compatible. | |
6351 | ||
6352 | You should rewrite your code to avoid these warnings if you are | |
6353 | concerned about the fact that code generated by G++ may not be binary | |
6354 | compatible with code generated by other compilers. | |
6355 | ||
6356 | Known incompatibilities in @option{-fabi-version=2} (which was the | |
6357 | default from GCC 3.4 to 4.9) include: | |
6358 | ||
6359 | @itemize @bullet | |
6360 | ||
6361 | @item | |
6362 | A template with a non-type template parameter of reference type was | |
6363 | mangled incorrectly: | |
6364 | @smallexample | |
6365 | extern int N; | |
6366 | template <int &> struct S @{@}; | |
6367 | void n (S<N>) @{2@} | |
6368 | @end smallexample | |
6369 | ||
6370 | This was fixed in @option{-fabi-version=3}. | |
6371 | ||
6372 | @item | |
6373 | SIMD vector types declared using @code{__attribute ((vector_size))} were | |
6374 | mangled in a non-standard way that does not allow for overloading of | |
6375 | functions taking vectors of different sizes. | |
6376 | ||
6377 | The mangling was changed in @option{-fabi-version=4}. | |
6378 | ||
6379 | @item | |
6380 | @code{__attribute ((const))} and @code{noreturn} were mangled as type | |
6381 | qualifiers, and @code{decltype} of a plain declaration was folded away. | |
6382 | ||
6383 | These mangling issues were fixed in @option{-fabi-version=5}. | |
6384 | ||
6385 | @item | |
6386 | Scoped enumerators passed as arguments to a variadic function are | |
6387 | promoted like unscoped enumerators, causing @code{va_arg} to complain. | |
6388 | On most targets this does not actually affect the parameter passing | |
6389 | ABI, as there is no way to pass an argument smaller than @code{int}. | |
6390 | ||
6391 | Also, the ABI changed the mangling of template argument packs, | |
6392 | @code{const_cast}, @code{static_cast}, prefix increment/decrement, and | |
6393 | a class scope function used as a template argument. | |
6394 | ||
6395 | These issues were corrected in @option{-fabi-version=6}. | |
6396 | ||
6397 | @item | |
6398 | Lambdas in default argument scope were mangled incorrectly, and the | |
6399 | ABI changed the mangling of @code{nullptr_t}. | |
6400 | ||
6401 | These issues were corrected in @option{-fabi-version=7}. | |
6402 | ||
6403 | @item | |
6404 | When mangling a function type with function-cv-qualifiers, the | |
6405 | un-qualified function type was incorrectly treated as a substitution | |
6406 | candidate. | |
6407 | ||
6408 | This was fixed in @option{-fabi-version=8}, the default for GCC 5.1. | |
6409 | ||
6410 | @item | |
6411 | @code{decltype(nullptr)} incorrectly had an alignment of 1, leading to | |
6412 | unaligned accesses. Note that this did not affect the ABI of a | |
6413 | function with a @code{nullptr_t} parameter, as parameters have a | |
6414 | minimum alignment. | |
6415 | ||
6416 | This was fixed in @option{-fabi-version=9}, the default for GCC 5.2. | |
6417 | ||
6418 | @item | |
6419 | Target-specific attributes that affect the identity of a type, such as | |
6420 | ia32 calling conventions on a function type (stdcall, regparm, etc.), | |
6421 | did not affect the mangled name, leading to name collisions when | |
6422 | function pointers were used as template arguments. | |
6423 | ||
6424 | This was fixed in @option{-fabi-version=10}, the default for GCC 6.1. | |
6425 | ||
6426 | @end itemize | |
6427 | ||
6428 | This option also enables warnings about psABI-related changes. | |
6429 | The known psABI changes at this point include: | |
6430 | ||
6431 | @itemize @bullet | |
6432 | ||
6433 | @item | |
6434 | For SysV/x86-64, unions with @code{long double} members are | |
6435 | passed in memory as specified in psABI. Prior to GCC 4.4, this was not | |
6436 | the case. For example: | |
6437 | ||
6438 | @smallexample | |
6439 | union U @{ | |
6440 | long double ld; | |
6441 | int i; | |
6442 | @}; | |
6443 | @end smallexample | |
6444 | ||
6445 | @noindent | |
6446 | @code{union U} is now always passed in memory. | |
6447 | ||
6448 | @end itemize | |
6449 | ||
e2f939d3 JM |
6450 | @item -Wno-changes-meaning @r{(C++ and Objective-C++ only)} |
6451 | C++ requires that unqualified uses of a name within a class have the | |
6452 | same meaning in the complete scope of the class, so declaring the name | |
6453 | after using it is ill-formed: | |
6454 | @smallexample | |
6455 | struct A; | |
6456 | struct B1 @{ A a; typedef A A; @}; // warning, 'A' changes meaning | |
6457 | struct B2 @{ A a; struct A @{ @}; @}; // error, 'A' changes meaning | |
6458 | @end smallexample | |
6459 | By default, the B1 case is only a warning because the two declarations | |
6460 | have the same type, while the B2 case is an error. Both diagnostics | |
6461 | can be disabled with @option{-Wno-changes-meaning}. Alternately, the | |
6462 | error case can be reduced to a warning with | |
6463 | @option{-Wno-error=changes-meaning} or @option{-fpermissive}. | |
6464 | ||
6465 | Both diagnostics are also suppressed by @option{-fms-extensions}. | |
6466 | ||
d77de738 ML |
6467 | @opindex Wchar-subscripts |
6468 | @opindex Wno-char-subscripts | |
ddf6fe37 | 6469 | @item -Wchar-subscripts |
d77de738 ML |
6470 | Warn if an array subscript has type @code{char}. This is a common cause |
6471 | of error, as programmers often forget that this type is signed on some | |
6472 | machines. | |
6473 | This warning is enabled by @option{-Wall}. | |
6474 | ||
d77de738 ML |
6475 | @opindex Wno-coverage-mismatch |
6476 | @opindex Wcoverage-mismatch | |
ddf6fe37 | 6477 | @item -Wno-coverage-mismatch |
d77de738 ML |
6478 | Warn if feedback profiles do not match when using the |
6479 | @option{-fprofile-use} option. | |
6480 | If a source file is changed between compiling with @option{-fprofile-generate} | |
6481 | and with @option{-fprofile-use}, the files with the profile feedback can fail | |
6482 | to match the source file and GCC cannot use the profile feedback | |
6483 | information. By default, this warning is enabled and is treated as an | |
6484 | error. @option{-Wno-coverage-mismatch} can be used to disable the | |
6485 | warning or @option{-Wno-error=coverage-mismatch} can be used to | |
6486 | disable the error. Disabling the error for this warning can result in | |
6487 | poorly optimized code and is useful only in the | |
6488 | case of very minor changes such as bug fixes to an existing code-base. | |
6489 | Completely disabling the warning is not recommended. | |
6490 | ||
d77de738 ML |
6491 | @opindex Wno-coverage-invalid-line-number |
6492 | @opindex Wcoverage-invalid-line-number | |
ddf6fe37 | 6493 | @item -Wno-coverage-invalid-line-number |
d77de738 ML |
6494 | Warn in case a function ends earlier than it begins due |
6495 | to an invalid linenum macros. The warning is emitted only | |
6496 | with @option{--coverage} enabled. | |
6497 | ||
6498 | By default, this warning is enabled and is treated as an | |
6499 | error. @option{-Wno-coverage-invalid-line-number} can be used to disable the | |
6500 | warning or @option{-Wno-error=coverage-invalid-line-number} can be used to | |
6501 | disable the error. | |
6502 | ||
d77de738 ML |
6503 | @opindex Wno-cpp |
6504 | @opindex Wcpp | |
ddf6fe37 | 6505 | @item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)} |
d77de738 ML |
6506 | Suppress warning messages emitted by @code{#warning} directives. |
6507 | ||
d77de738 ML |
6508 | @opindex Wdouble-promotion |
6509 | @opindex Wno-double-promotion | |
ddf6fe37 | 6510 | @item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
6511 | Give a warning when a value of type @code{float} is implicitly |
6512 | promoted to @code{double}. CPUs with a 32-bit ``single-precision'' | |
6513 | floating-point unit implement @code{float} in hardware, but emulate | |
6514 | @code{double} in software. On such a machine, doing computations | |
6515 | using @code{double} values is much more expensive because of the | |
6516 | overhead required for software emulation. | |
6517 | ||
6518 | It is easy to accidentally do computations with @code{double} because | |
6519 | floating-point literals are implicitly of type @code{double}. For | |
6520 | example, in: | |
6521 | @smallexample | |
6522 | @group | |
6523 | float area(float radius) | |
6524 | @{ | |
6525 | return 3.14159 * radius * radius; | |
6526 | @} | |
6527 | @end group | |
6528 | @end smallexample | |
6529 | the compiler performs the entire computation with @code{double} | |
6530 | because the floating-point literal is a @code{double}. | |
6531 | ||
d77de738 ML |
6532 | @opindex Wduplicate-decl-specifier |
6533 | @opindex Wno-duplicate-decl-specifier | |
ddf6fe37 | 6534 | @item -Wduplicate-decl-specifier @r{(C and Objective-C only)} |
d77de738 ML |
6535 | Warn if a declaration has duplicate @code{const}, @code{volatile}, |
6536 | @code{restrict} or @code{_Atomic} specifier. This warning is enabled by | |
6537 | @option{-Wall}. | |
6538 | ||
d77de738 ML |
6539 | @opindex Wformat |
6540 | @opindex Wno-format | |
6541 | @opindex ffreestanding | |
6542 | @opindex fno-builtin | |
6543 | @opindex Wformat= | |
ddf6fe37 AA |
6544 | @item -Wformat |
6545 | @itemx -Wformat=@var{n} | |
d77de738 ML |
6546 | Check calls to @code{printf} and @code{scanf}, etc., to make sure that |
6547 | the arguments supplied have types appropriate to the format string | |
6548 | specified, and that the conversions specified in the format string make | |
6549 | sense. This includes standard functions, and others specified by format | |
6550 | attributes (@pxref{Function Attributes}), in the @code{printf}, | |
6551 | @code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension, | |
6552 | not in the C standard) families (or other target-specific families). | |
6553 | Which functions are checked without format attributes having been | |
6554 | specified depends on the standard version selected, and such checks of | |
6555 | functions without the attribute specified are disabled by | |
6556 | @option{-ffreestanding} or @option{-fno-builtin}. | |
6557 | ||
6558 | The formats are checked against the format features supported by GNU | |
6559 | libc version 2.2. These include all ISO C90 and C99 features, as well | |
6560 | as features from the Single Unix Specification and some BSD and GNU | |
6561 | extensions. Other library implementations may not support all these | |
6562 | features; GCC does not support warning about features that go beyond a | |
6563 | particular library's limitations. However, if @option{-Wpedantic} is used | |
6564 | with @option{-Wformat}, warnings are given about format features not | |
6565 | in the selected standard version (but not for @code{strfmon} formats, | |
6566 | since those are not in any version of the C standard). @xref{C Dialect | |
6567 | Options,,Options Controlling C Dialect}. | |
6568 | ||
6569 | @table @gcctabopt | |
d77de738 ML |
6570 | @opindex Wformat |
6571 | @opindex Wformat=1 | |
ddf6fe37 AA |
6572 | @item -Wformat=1 |
6573 | @itemx -Wformat | |
d77de738 ML |
6574 | Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and |
6575 | @option{-Wno-format} is equivalent to @option{-Wformat=0}. Since | |
6576 | @option{-Wformat} also checks for null format arguments for several | |
6577 | functions, @option{-Wformat} also implies @option{-Wnonnull}. Some | |
6578 | aspects of this level of format checking can be disabled by the | |
6579 | options: @option{-Wno-format-contains-nul}, | |
6580 | @option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}. | |
6581 | @option{-Wformat} is enabled by @option{-Wall}. | |
6582 | ||
d77de738 | 6583 | @opindex Wformat=2 |
ddf6fe37 | 6584 | @item -Wformat=2 |
d77de738 ML |
6585 | Enable @option{-Wformat} plus additional format checks. Currently |
6586 | equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security | |
6587 | -Wformat-y2k}. | |
6588 | @end table | |
6589 | ||
d77de738 ML |
6590 | @opindex Wno-format-contains-nul |
6591 | @opindex Wformat-contains-nul | |
ddf6fe37 | 6592 | @item -Wno-format-contains-nul |
d77de738 ML |
6593 | If @option{-Wformat} is specified, do not warn about format strings that |
6594 | contain NUL bytes. | |
6595 | ||
d77de738 ML |
6596 | @opindex Wno-format-extra-args |
6597 | @opindex Wformat-extra-args | |
ddf6fe37 | 6598 | @item -Wno-format-extra-args |
d77de738 ML |
6599 | If @option{-Wformat} is specified, do not warn about excess arguments to a |
6600 | @code{printf} or @code{scanf} format function. The C standard specifies | |
6601 | that such arguments are ignored. | |
6602 | ||
6603 | Where the unused arguments lie between used arguments that are | |
6604 | specified with @samp{$} operand number specifications, normally | |
6605 | warnings are still given, since the implementation could not know what | |
6606 | type to pass to @code{va_arg} to skip the unused arguments. However, | |
6607 | in the case of @code{scanf} formats, this option suppresses the | |
6608 | warning if the unused arguments are all pointers, since the Single | |
6609 | Unix Specification says that such unused arguments are allowed. | |
6610 | ||
d77de738 ML |
6611 | @opindex Wformat-overflow |
6612 | @opindex Wno-format-overflow | |
ddf6fe37 AA |
6613 | @item -Wformat-overflow |
6614 | @itemx -Wformat-overflow=@var{level} | |
d77de738 ML |
6615 | Warn about calls to formatted input/output functions such as @code{sprintf} |
6616 | and @code{vsprintf} that might overflow the destination buffer. When the | |
6617 | exact number of bytes written by a format directive cannot be determined | |
6618 | at compile-time it is estimated based on heuristics that depend on the | |
6619 | @var{level} argument and on optimization. While enabling optimization | |
6620 | will in most cases improve the accuracy of the warning, it may also | |
6621 | result in false positives. | |
6622 | ||
6623 | @table @gcctabopt | |
d77de738 ML |
6624 | @opindex Wformat-overflow |
6625 | @opindex Wno-format-overflow | |
ddf6fe37 AA |
6626 | @item -Wformat-overflow |
6627 | @itemx -Wformat-overflow=1 | |
d77de738 ML |
6628 | Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat} |
6629 | employs a conservative approach that warns only about calls that most | |
6630 | likely overflow the buffer. At this level, numeric arguments to format | |
6631 | directives with unknown values are assumed to have the value of one, and | |
6632 | strings of unknown length to be empty. Numeric arguments that are known | |
6633 | to be bounded to a subrange of their type, or string arguments whose output | |
6634 | is bounded either by their directive's precision or by a finite set of | |
6635 | string literals, are assumed to take on the value within the range that | |
6636 | results in the most bytes on output. For example, the call to @code{sprintf} | |
6637 | below is diagnosed because even with both @var{a} and @var{b} equal to zero, | |
6638 | the terminating NUL character (@code{'\0'}) appended by the function | |
6639 | to the destination buffer will be written past its end. Increasing | |
6640 | the size of the buffer by a single byte is sufficient to avoid the | |
6641 | warning, though it may not be sufficient to avoid the overflow. | |
6642 | ||
6643 | @smallexample | |
6644 | void f (int a, int b) | |
6645 | @{ | |
6646 | char buf [13]; | |
6647 | sprintf (buf, "a = %i, b = %i\n", a, b); | |
6648 | @} | |
6649 | @end smallexample | |
6650 | ||
6651 | @item -Wformat-overflow=2 | |
6652 | Level @var{2} warns also about calls that might overflow the destination | |
6653 | buffer given an argument of sufficient length or magnitude. At level | |
6654 | @var{2}, unknown numeric arguments are assumed to have the minimum | |
6655 | representable value for signed types with a precision greater than 1, and | |
6656 | the maximum representable value otherwise. Unknown string arguments whose | |
6657 | length cannot be assumed to be bounded either by the directive's precision, | |
6658 | or by a finite set of string literals they may evaluate to, or the character | |
6659 | array they may point to, are assumed to be 1 character long. | |
6660 | ||
6661 | At level @var{2}, the call in the example above is again diagnosed, but | |
6662 | this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first | |
6663 | @code{%i} directive will write some of its digits beyond the end of | |
6664 | the destination buffer. To make the call safe regardless of the values | |
6665 | of the two variables, the size of the destination buffer must be increased | |
6666 | to at least 34 bytes. GCC includes the minimum size of the buffer in | |
6667 | an informational note following the warning. | |
6668 | ||
6669 | An alternative to increasing the size of the destination buffer is to | |
6670 | constrain the range of formatted values. The maximum length of string | |
6671 | arguments can be bounded by specifying the precision in the format | |
6672 | directive. When numeric arguments of format directives can be assumed | |
6673 | to be bounded by less than the precision of their type, choosing | |
6674 | an appropriate length modifier to the format specifier will reduce | |
6675 | the required buffer size. For example, if @var{a} and @var{b} in the | |
6676 | example above can be assumed to be within the precision of | |
6677 | the @code{short int} type then using either the @code{%hi} format | |
6678 | directive or casting the argument to @code{short} reduces the maximum | |
6679 | required size of the buffer to 24 bytes. | |
6680 | ||
6681 | @smallexample | |
6682 | void f (int a, int b) | |
6683 | @{ | |
6684 | char buf [23]; | |
6685 | sprintf (buf, "a = %hi, b = %i\n", a, (short)b); | |
6686 | @} | |
6687 | @end smallexample | |
6688 | @end table | |
6689 | ||
d77de738 ML |
6690 | @opindex Wno-format-zero-length |
6691 | @opindex Wformat-zero-length | |
ddf6fe37 | 6692 | @item -Wno-format-zero-length |
d77de738 ML |
6693 | If @option{-Wformat} is specified, do not warn about zero-length formats. |
6694 | The C standard specifies that zero-length formats are allowed. | |
6695 | ||
d77de738 ML |
6696 | @opindex Wformat-nonliteral |
6697 | @opindex Wno-format-nonliteral | |
ddf6fe37 | 6698 | @item -Wformat-nonliteral |
d77de738 ML |
6699 | If @option{-Wformat} is specified, also warn if the format string is not a |
6700 | string literal and so cannot be checked, unless the format function | |
6701 | takes its format arguments as a @code{va_list}. | |
6702 | ||
d77de738 ML |
6703 | @opindex Wformat-security |
6704 | @opindex Wno-format-security | |
ddf6fe37 | 6705 | @item -Wformat-security |
d77de738 ML |
6706 | If @option{-Wformat} is specified, also warn about uses of format |
6707 | functions that represent possible security problems. At present, this | |
6708 | warns about calls to @code{printf} and @code{scanf} functions where the | |
6709 | format string is not a string literal and there are no format arguments, | |
6710 | as in @code{printf (foo);}. This may be a security hole if the format | |
6711 | string came from untrusted input and contains @samp{%n}. (This is | |
6712 | currently a subset of what @option{-Wformat-nonliteral} warns about, but | |
6713 | in future warnings may be added to @option{-Wformat-security} that are not | |
6714 | included in @option{-Wformat-nonliteral}.) | |
6715 | ||
d77de738 ML |
6716 | @opindex Wformat-signedness |
6717 | @opindex Wno-format-signedness | |
ddf6fe37 | 6718 | @item -Wformat-signedness |
d77de738 ML |
6719 | If @option{-Wformat} is specified, also warn if the format string |
6720 | requires an unsigned argument and the argument is signed and vice versa. | |
6721 | ||
d77de738 ML |
6722 | @opindex Wformat-truncation |
6723 | @opindex Wno-format-truncation | |
ddf6fe37 AA |
6724 | @item -Wformat-truncation |
6725 | @itemx -Wformat-truncation=@var{level} | |
d77de738 ML |
6726 | Warn about calls to formatted input/output functions such as @code{snprintf} |
6727 | and @code{vsnprintf} that might result in output truncation. When the exact | |
6728 | number of bytes written by a format directive cannot be determined at | |
6729 | compile-time it is estimated based on heuristics that depend on | |
6730 | the @var{level} argument and on optimization. While enabling optimization | |
6731 | will in most cases improve the accuracy of the warning, it may also result | |
6732 | in false positives. Except as noted otherwise, the option uses the same | |
6733 | logic @option{-Wformat-overflow}. | |
6734 | ||
6735 | @table @gcctabopt | |
d77de738 ML |
6736 | @opindex Wformat-truncation |
6737 | @opindex Wno-format-truncation | |
ddf6fe37 AA |
6738 | @item -Wformat-truncation |
6739 | @itemx -Wformat-truncation=1 | |
d77de738 ML |
6740 | Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat} |
6741 | employs a conservative approach that warns only about calls to bounded | |
6742 | functions whose return value is unused and that will most likely result | |
6743 | in output truncation. | |
6744 | ||
6745 | @item -Wformat-truncation=2 | |
6746 | Level @var{2} warns also about calls to bounded functions whose return | |
6747 | value is used and that might result in truncation given an argument of | |
6748 | sufficient length or magnitude. | |
6749 | @end table | |
6750 | ||
d77de738 ML |
6751 | @opindex Wformat-y2k |
6752 | @opindex Wno-format-y2k | |
ddf6fe37 | 6753 | @item -Wformat-y2k |
d77de738 ML |
6754 | If @option{-Wformat} is specified, also warn about @code{strftime} |
6755 | formats that may yield only a two-digit year. | |
6756 | ||
d77de738 ML |
6757 | @opindex Wnonnull |
6758 | @opindex Wno-nonnull | |
ddf6fe37 | 6759 | @item -Wnonnull |
d77de738 ML |
6760 | Warn about passing a null pointer for arguments marked as |
6761 | requiring a non-null value by the @code{nonnull} function attribute. | |
6762 | ||
6763 | @option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It | |
6764 | can be disabled with the @option{-Wno-nonnull} option. | |
6765 | ||
d77de738 ML |
6766 | @opindex Wnonnull-compare |
6767 | @opindex Wno-nonnull-compare | |
ddf6fe37 | 6768 | @item -Wnonnull-compare |
d77de738 ML |
6769 | Warn when comparing an argument marked with the @code{nonnull} |
6770 | function attribute against null inside the function. | |
6771 | ||
6772 | @option{-Wnonnull-compare} is included in @option{-Wall}. It | |
6773 | can be disabled with the @option{-Wno-nonnull-compare} option. | |
6774 | ||
d77de738 ML |
6775 | @opindex Wnull-dereference |
6776 | @opindex Wno-null-dereference | |
ddf6fe37 | 6777 | @item -Wnull-dereference |
d77de738 ML |
6778 | Warn if the compiler detects paths that trigger erroneous or |
6779 | undefined behavior due to dereferencing a null pointer. This option | |
6780 | is only active when @option{-fdelete-null-pointer-checks} is active, | |
6781 | which is enabled by optimizations in most targets. The precision of | |
6782 | the warnings depends on the optimization options used. | |
6783 | ||
2ae5384d JM |
6784 | @opindex Wnrvo |
6785 | @opindex Wno-nrvo | |
6786 | @item -Wnrvo @r{(C++ and Objective-C++ only)} | |
6787 | Warn if the compiler does not elide the copy from a local variable to | |
6788 | the return value of a function in a context where it is allowed by | |
6789 | [class.copy.elision]. This elision is commonly known as the Named | |
6790 | Return Value Optimization. For instance, in the example below the | |
72cfa0f7 | 6791 | compiler cannot elide copies from both v1 and v2, so it elides neither. |
2ae5384d JM |
6792 | |
6793 | @smallexample | |
6794 | std::vector<int> f() | |
6795 | @{ | |
6796 | std::vector<int> v1, v2; | |
6797 | // ... | |
6798 | if (cond) return v1; | |
6799 | else return v2; // warning: not eliding copy | |
6800 | @} | |
6801 | @end smallexample | |
6802 | ||
d77de738 ML |
6803 | @opindex Winfinite-recursion |
6804 | @opindex Wno-infinite-recursion | |
ddf6fe37 | 6805 | @item -Winfinite-recursion |
d77de738 ML |
6806 | Warn about infinitely recursive calls. The warning is effective at all |
6807 | optimization levels but requires optimization in order to detect infinite | |
6808 | recursion in calls between two or more functions. | |
6809 | @option{-Winfinite-recursion} is included in @option{-Wall}. | |
6810 | ||
ce51e843 ML |
6811 | Compare with @option{-Wanalyzer-infinite-recursion} which provides a |
6812 | similar diagnostic, but is implemented in a different way (as part of | |
6813 | @option{-fanalyzer}). | |
6814 | ||
d77de738 ML |
6815 | @opindex Winit-self |
6816 | @opindex Wno-init-self | |
ddf6fe37 | 6817 | @item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
6818 | Warn about uninitialized variables that are initialized with themselves. |
6819 | Note this option can only be used with the @option{-Wuninitialized} option. | |
6820 | ||
6821 | For example, GCC warns about @code{i} being uninitialized in the | |
6822 | following snippet only when @option{-Winit-self} has been specified: | |
6823 | @smallexample | |
6824 | @group | |
6825 | int f() | |
6826 | @{ | |
6827 | int i = i; | |
6828 | return i; | |
6829 | @} | |
6830 | @end group | |
6831 | @end smallexample | |
6832 | ||
6833 | This warning is enabled by @option{-Wall} in C++. | |
6834 | ||
d77de738 ML |
6835 | @opindex Wimplicit-int |
6836 | @opindex Wno-implicit-int | |
ddf6fe37 | 6837 | @item -Wno-implicit-int @r{(C and Objective-C only)} |
d77de738 ML |
6838 | This option controls warnings when a declaration does not specify a type. |
6839 | This warning is enabled by default in C99 and later dialects of C, | |
6840 | and also by @option{-Wall}. | |
6841 | ||
5fccebdb JM |
6842 | This warning is upgraded to an error by @option{-pedantic-errors}. |
6843 | ||
d77de738 ML |
6844 | @opindex Wimplicit-function-declaration |
6845 | @opindex Wno-implicit-function-declaration | |
ddf6fe37 | 6846 | @item -Wno-implicit-function-declaration @r{(C and Objective-C only)} |
d77de738 ML |
6847 | This option controls warnings when a function is used before being declared. |
6848 | This warning is enabled by default in C99 and later dialects of C, | |
6849 | and also by @option{-Wall}. | |
5fccebdb JM |
6850 | |
6851 | This warning is upgraded to an error by @option{-pedantic-errors}. | |
d77de738 | 6852 | |
d77de738 ML |
6853 | @opindex Wimplicit |
6854 | @opindex Wno-implicit | |
ddf6fe37 | 6855 | @item -Wimplicit @r{(C and Objective-C only)} |
d77de738 ML |
6856 | Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}. |
6857 | This warning is enabled by @option{-Wall}. | |
6858 | ||
d77de738 ML |
6859 | @opindex Wimplicit-fallthrough |
6860 | @opindex Wno-implicit-fallthrough | |
ddf6fe37 | 6861 | @item -Wimplicit-fallthrough |
d77de738 ML |
6862 | @option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3} |
6863 | and @option{-Wno-implicit-fallthrough} is the same as | |
6864 | @option{-Wimplicit-fallthrough=0}. | |
6865 | ||
d77de738 | 6866 | @opindex Wimplicit-fallthrough= |
ddf6fe37 | 6867 | @item -Wimplicit-fallthrough=@var{n} |
d77de738 ML |
6868 | Warn when a switch case falls through. For example: |
6869 | ||
6870 | @smallexample | |
6871 | @group | |
6872 | switch (cond) | |
6873 | @{ | |
6874 | case 1: | |
6875 | a = 1; | |
6876 | break; | |
6877 | case 2: | |
6878 | a = 2; | |
6879 | case 3: | |
6880 | a = 3; | |
6881 | break; | |
6882 | @} | |
6883 | @end group | |
6884 | @end smallexample | |
6885 | ||
6886 | This warning does not warn when the last statement of a case cannot | |
6887 | fall through, e.g. when there is a return statement or a call to function | |
6888 | declared with the noreturn attribute. @option{-Wimplicit-fallthrough=} | |
6889 | also takes into account control flow statements, such as ifs, and only | |
6890 | warns when appropriate. E.g.@: | |
6891 | ||
6892 | @smallexample | |
6893 | @group | |
6894 | switch (cond) | |
6895 | @{ | |
6896 | case 1: | |
6897 | if (i > 3) @{ | |
6898 | bar (5); | |
6899 | break; | |
6900 | @} else if (i < 1) @{ | |
6901 | bar (0); | |
6902 | @} else | |
6903 | return; | |
6904 | default: | |
6905 | @dots{} | |
6906 | @} | |
6907 | @end group | |
6908 | @end smallexample | |
6909 | ||
6910 | Since there are occasions where a switch case fall through is desirable, | |
6911 | GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is | |
6912 | to be used along with a null statement to suppress this warning that | |
6913 | would normally occur: | |
6914 | ||
6915 | @smallexample | |
6916 | @group | |
6917 | switch (cond) | |
6918 | @{ | |
6919 | case 1: | |
6920 | bar (0); | |
6921 | __attribute__ ((fallthrough)); | |
6922 | default: | |
6923 | @dots{} | |
6924 | @} | |
6925 | @end group | |
6926 | @end smallexample | |
6927 | ||
6928 | C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough} | |
6929 | warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11 | |
6930 | or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension. | |
6931 | Instead of these attributes, it is also possible to add a fallthrough comment | |
6932 | to silence the warning. The whole body of the C or C++ style comment should | |
6933 | match the given regular expressions listed below. The option argument @var{n} | |
6934 | specifies what kind of comments are accepted: | |
6935 | ||
6936 | @itemize @bullet | |
6937 | ||
6938 | @item @option{-Wimplicit-fallthrough=0} disables the warning altogether. | |
6939 | ||
6940 | @item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular | |
6941 | expression, any comment is used as fallthrough comment. | |
6942 | ||
6943 | @item @option{-Wimplicit-fallthrough=2} case insensitively matches | |
6944 | @code{.*falls?[ \t-]*thr(ough|u).*} regular expression. | |
6945 | ||
6946 | @item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the | |
6947 | following regular expressions: | |
6948 | ||
6949 | @itemize @bullet | |
6950 | ||
6951 | @item @code{-fallthrough} | |
6952 | ||
6953 | @item @code{@@fallthrough@@} | |
6954 | ||
6955 | @item @code{lint -fallthrough[ \t]*} | |
6956 | ||
6957 | @item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?} | |
6958 | ||
6959 | @item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?} | |
6960 | ||
6961 | @item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?} | |
6962 | ||
6963 | @end itemize | |
6964 | ||
6965 | @item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the | |
6966 | following regular expressions: | |
6967 | ||
6968 | @itemize @bullet | |
6969 | ||
6970 | @item @code{-fallthrough} | |
6971 | ||
6972 | @item @code{@@fallthrough@@} | |
6973 | ||
6974 | @item @code{lint -fallthrough[ \t]*} | |
6975 | ||
6976 | @item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*} | |
6977 | ||
6978 | @end itemize | |
6979 | ||
6980 | @item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as | |
6981 | fallthrough comments, only attributes disable the warning. | |
6982 | ||
6983 | @end itemize | |
6984 | ||
6985 | The comment needs to be followed after optional whitespace and other comments | |
6986 | by @code{case} or @code{default} keywords or by a user label that precedes some | |
6987 | @code{case} or @code{default} label. | |
6988 | ||
6989 | @smallexample | |
6990 | @group | |
6991 | switch (cond) | |
6992 | @{ | |
6993 | case 1: | |
6994 | bar (0); | |
6995 | /* FALLTHRU */ | |
6996 | default: | |
6997 | @dots{} | |
6998 | @} | |
6999 | @end group | |
7000 | @end smallexample | |
7001 | ||
7002 | The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}. | |
7003 | ||
d77de738 ML |
7004 | @opindex Wif-not-aligned |
7005 | @opindex Wno-if-not-aligned | |
ddf6fe37 | 7006 | @item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
7007 | Control if warnings triggered by the @code{warn_if_not_aligned} attribute |
7008 | should be issued. These warnings are enabled by default. | |
7009 | ||
d77de738 ML |
7010 | @opindex Wignored-qualifiers |
7011 | @opindex Wno-ignored-qualifiers | |
ddf6fe37 | 7012 | @item -Wignored-qualifiers @r{(C and C++ only)} |
d77de738 ML |
7013 | Warn if the return type of a function has a type qualifier |
7014 | such as @code{const}. For ISO C such a type qualifier has no effect, | |
7015 | since the value returned by a function is not an lvalue. | |
7016 | For C++, the warning is only emitted for scalar types or @code{void}. | |
7017 | ISO C prohibits qualified @code{void} return types on function | |
7018 | definitions, so such return types always receive a warning | |
7019 | even without this option. | |
7020 | ||
7021 | This warning is also enabled by @option{-Wextra}. | |
7022 | ||
d77de738 ML |
7023 | @opindex Wignored-attributes |
7024 | @opindex Wno-ignored-attributes | |
ddf6fe37 | 7025 | @item -Wno-ignored-attributes @r{(C and C++ only)} |
d77de738 ML |
7026 | This option controls warnings when an attribute is ignored. |
7027 | This is different from the | |
7028 | @option{-Wattributes} option in that it warns whenever the compiler decides | |
7029 | to drop an attribute, not that the attribute is either unknown, used in a | |
7030 | wrong place, etc. This warning is enabled by default. | |
7031 | ||
d77de738 ML |
7032 | @opindex Wmain |
7033 | @opindex Wno-main | |
ddf6fe37 | 7034 | @item -Wmain |
d77de738 ML |
7035 | Warn if the type of @code{main} is suspicious. @code{main} should be |
7036 | a function with external linkage, returning int, taking either zero | |
7037 | arguments, two, or three arguments of appropriate types. This warning | |
7038 | is enabled by default in C++ and is enabled by either @option{-Wall} | |
7039 | or @option{-Wpedantic}. | |
7040 | ||
5fccebdb JM |
7041 | This warning is upgraded to an error by @option{-pedantic-errors}. |
7042 | ||
d77de738 ML |
7043 | @opindex Wmisleading-indentation |
7044 | @opindex Wno-misleading-indentation | |
ddf6fe37 | 7045 | @item -Wmisleading-indentation @r{(C and C++ only)} |
d77de738 ML |
7046 | Warn when the indentation of the code does not reflect the block structure. |
7047 | Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and | |
7048 | @code{for} clauses with a guarded statement that does not use braces, | |
7049 | followed by an unguarded statement with the same indentation. | |
7050 | ||
7051 | In the following example, the call to ``bar'' is misleadingly indented as | |
7052 | if it were guarded by the ``if'' conditional. | |
7053 | ||
7054 | @smallexample | |
7055 | if (some_condition ()) | |
7056 | foo (); | |
7057 | bar (); /* Gotcha: this is not guarded by the "if". */ | |
7058 | @end smallexample | |
7059 | ||
7060 | In the case of mixed tabs and spaces, the warning uses the | |
7061 | @option{-ftabstop=} option to determine if the statements line up | |
7062 | (defaulting to 8). | |
7063 | ||
7064 | The warning is not issued for code involving multiline preprocessor logic | |
7065 | such as the following example. | |
7066 | ||
7067 | @smallexample | |
7068 | if (flagA) | |
7069 | foo (0); | |
7070 | #if SOME_CONDITION_THAT_DOES_NOT_HOLD | |
7071 | if (flagB) | |
7072 | #endif | |
7073 | foo (1); | |
7074 | @end smallexample | |
7075 | ||
7076 | The warning is not issued after a @code{#line} directive, since this | |
7077 | typically indicates autogenerated code, and no assumptions can be made | |
7078 | about the layout of the file that the directive references. | |
7079 | ||
7080 | This warning is enabled by @option{-Wall} in C and C++. | |
7081 | ||
d77de738 ML |
7082 | @opindex Wmissing-attributes |
7083 | @opindex Wno-missing-attributes | |
ddf6fe37 | 7084 | @item -Wmissing-attributes |
d77de738 ML |
7085 | Warn when a declaration of a function is missing one or more attributes |
7086 | that a related function is declared with and whose absence may adversely | |
7087 | affect the correctness or efficiency of generated code. For example, | |
7088 | the warning is issued for declarations of aliases that use attributes | |
7089 | to specify less restrictive requirements than those of their targets. | |
7090 | This typically represents a potential optimization opportunity. | |
7091 | By contrast, the @option{-Wattribute-alias=2} option controls warnings | |
7092 | issued when the alias is more restrictive than the target, which could | |
7093 | lead to incorrect code generation. | |
7094 | Attributes considered include @code{alloc_align}, @code{alloc_size}, | |
7095 | @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc}, | |
7096 | @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure}, | |
7097 | @code{returns_nonnull}, and @code{returns_twice}. | |
7098 | ||
7099 | In C++, the warning is issued when an explicit specialization of a primary | |
7100 | template declared with attribute @code{alloc_align}, @code{alloc_size}, | |
7101 | @code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc}, | |
7102 | or @code{nonnull} is declared without it. Attributes @code{deprecated}, | |
7103 | @code{error}, and @code{warning} suppress the warning. | |
7104 | (@pxref{Function Attributes}). | |
7105 | ||
7106 | You can use the @code{copy} attribute to apply the same | |
7107 | set of attributes to a declaration as that on another declaration without | |
7108 | explicitly enumerating the attributes. This attribute can be applied | |
7109 | to declarations of functions (@pxref{Common Function Attributes}), | |
7110 | variables (@pxref{Common Variable Attributes}), or types | |
7111 | (@pxref{Common Type Attributes}). | |
7112 | ||
7113 | @option{-Wmissing-attributes} is enabled by @option{-Wall}. | |
7114 | ||
7115 | For example, since the declaration of the primary function template | |
7116 | below makes use of both attribute @code{malloc} and @code{alloc_size} | |
7117 | the declaration of the explicit specialization of the template is | |
7118 | diagnosed because it is missing one of the attributes. | |
7119 | ||
7120 | @smallexample | |
7121 | template <class T> | |
7122 | T* __attribute__ ((malloc, alloc_size (1))) | |
7123 | allocate (size_t); | |
7124 | ||
7125 | template <> | |
7126 | void* __attribute__ ((malloc)) // missing alloc_size | |
7127 | allocate<void> (size_t); | |
7128 | @end smallexample | |
7129 | ||
d77de738 ML |
7130 | @opindex Wmissing-braces |
7131 | @opindex Wno-missing-braces | |
ddf6fe37 | 7132 | @item -Wmissing-braces |
d77de738 ML |
7133 | Warn if an aggregate or union initializer is not fully bracketed. In |
7134 | the following example, the initializer for @code{a} is not fully | |
7135 | bracketed, but that for @code{b} is fully bracketed. | |
7136 | ||
7137 | @smallexample | |
7138 | int a[2][2] = @{ 0, 1, 2, 3 @}; | |
7139 | int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @}; | |
7140 | @end smallexample | |
7141 | ||
7142 | This warning is enabled by @option{-Wall}. | |
7143 | ||
d77de738 ML |
7144 | @opindex Wmissing-include-dirs |
7145 | @opindex Wno-missing-include-dirs | |
ddf6fe37 | 7146 | @item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)} |
72cfa0f7 | 7147 | Warn if a user-supplied include directory does not exist. This option is disabled |
d77de738 ML |
7148 | by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially |
7149 | enabled by default by warning for -I and -J, only. | |
7150 | ||
d77de738 ML |
7151 | @opindex Wmissing-profile |
7152 | @opindex Wno-missing-profile | |
ddf6fe37 | 7153 | @item -Wno-missing-profile |
d77de738 ML |
7154 | This option controls warnings if feedback profiles are missing when using the |
7155 | @option{-fprofile-use} option. | |
7156 | This option diagnoses those cases where a new function or a new file is added | |
7157 | between compiling with @option{-fprofile-generate} and with | |
7158 | @option{-fprofile-use}, without regenerating the profiles. | |
7159 | In these cases, the profile feedback data files do not contain any | |
7160 | profile feedback information for | |
7161 | the newly added function or file respectively. Also, in the case when profile | |
7162 | count data (.gcda) files are removed, GCC cannot use any profile feedback | |
7163 | information. In all these cases, warnings are issued to inform you that a | |
7164 | profile generation step is due. | |
7165 | Ignoring the warning can result in poorly optimized code. | |
7166 | @option{-Wno-missing-profile} can be used to | |
7167 | disable the warning, but this is not recommended and should be done only | |
7168 | when non-existent profile data is justified. | |
7169 | ||
d77de738 ML |
7170 | @opindex Wmismatched-dealloc |
7171 | @opindex Wno-mismatched-dealloc | |
ddf6fe37 | 7172 | @item -Wmismatched-dealloc |
d77de738 ML |
7173 | |
7174 | Warn for calls to deallocation functions with pointer arguments returned | |
7175 | from from allocations functions for which the former isn't a suitable | |
7176 | deallocator. A pair of functions can be associated as matching allocators | |
7177 | and deallocators by use of attribute @code{malloc}. Unless disabled by | |
7178 | the @option{-fno-builtin} option the standard functions @code{calloc}, | |
7179 | @code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding | |
7180 | forms of C++ @code{operator new} and @code{operator delete} are implicitly | |
7181 | associated as matching allocators and deallocators. In the following | |
7182 | example @code{mydealloc} is the deallocator for pointers returned from | |
7183 | @code{myalloc}. | |
7184 | ||
7185 | @smallexample | |
7186 | void mydealloc (void*); | |
7187 | ||
7188 | __attribute__ ((malloc (mydealloc, 1))) void* | |
7189 | myalloc (size_t); | |
7190 | ||
7191 | void f (void) | |
7192 | @{ | |
7193 | void *p = myalloc (32); | |
7194 | // @dots{}use p@dots{} | |
7195 | free (p); // warning: not a matching deallocator for myalloc | |
7196 | mydealloc (p); // ok | |
7197 | @} | |
7198 | @end smallexample | |
7199 | ||
7200 | In C++, the related option @option{-Wmismatched-new-delete} diagnoses | |
7201 | mismatches involving either @code{operator new} or @code{operator delete}. | |
7202 | ||
7203 | Option @option{-Wmismatched-dealloc} is included in @option{-Wall}. | |
7204 | ||
d77de738 ML |
7205 | @opindex Wmultistatement-macros |
7206 | @opindex Wno-multistatement-macros | |
ddf6fe37 | 7207 | @item -Wmultistatement-macros |
d77de738 ML |
7208 | Warn about unsafe multiple statement macros that appear to be guarded |
7209 | by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or | |
7210 | @code{while}, in which only the first statement is actually guarded after | |
7211 | the macro is expanded. | |
7212 | ||
7213 | For example: | |
7214 | ||
7215 | @smallexample | |
7216 | #define DOIT x++; y++ | |
7217 | if (c) | |
7218 | DOIT; | |
7219 | @end smallexample | |
7220 | ||
7221 | will increment @code{y} unconditionally, not just when @code{c} holds. | |
7222 | The can usually be fixed by wrapping the macro in a do-while loop: | |
7223 | @smallexample | |
7224 | #define DOIT do @{ x++; y++; @} while (0) | |
7225 | if (c) | |
7226 | DOIT; | |
7227 | @end smallexample | |
7228 | ||
7229 | This warning is enabled by @option{-Wall} in C and C++. | |
7230 | ||
d77de738 ML |
7231 | @opindex Wparentheses |
7232 | @opindex Wno-parentheses | |
ddf6fe37 | 7233 | @item -Wparentheses |
d77de738 ML |
7234 | Warn if parentheses are omitted in certain contexts, such |
7235 | as when there is an assignment in a context where a truth value | |
7236 | is expected, or when operators are nested whose precedence people | |
7237 | often get confused about. | |
7238 | ||
7239 | Also warn if a comparison like @code{x<=y<=z} appears; this is | |
7240 | equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different | |
7241 | interpretation from that of ordinary mathematical notation. | |
7242 | ||
7243 | Also warn for dangerous uses of the GNU extension to | |
7244 | @code{?:} with omitted middle operand. When the condition | |
7245 | in the @code{?}: operator is a boolean expression, the omitted value is | |
7246 | always 1. Often programmers expect it to be a value computed | |
7247 | inside the conditional expression instead. | |
7248 | ||
7249 | For C++ this also warns for some cases of unnecessary parentheses in | |
7250 | declarations, which can indicate an attempt at a function call instead | |
7251 | of a declaration: | |
7252 | @smallexample | |
7253 | @{ | |
7254 | // Declares a local variable called mymutex. | |
7255 | std::unique_lock<std::mutex> (mymutex); | |
7256 | // User meant std::unique_lock<std::mutex> lock (mymutex); | |
7257 | @} | |
7258 | @end smallexample | |
7259 | ||
7260 | This warning is enabled by @option{-Wall}. | |
7261 | ||
d77de738 ML |
7262 | @opindex Wself-move |
7263 | @opindex Wno-self-move | |
ddf6fe37 | 7264 | @item -Wno-self-move @r{(C++ and Objective-C++ only)} |
d77de738 ML |
7265 | This warning warns when a value is moved to itself with @code{std::move}. |
7266 | Such a @code{std::move} typically has no effect. | |
7267 | ||
7268 | @smallexample | |
7269 | struct T @{ | |
7270 | @dots{} | |
7271 | @}; | |
7272 | void fn() | |
7273 | @{ | |
7274 | T t; | |
7275 | @dots{} | |
7276 | t = std::move (t); | |
7277 | @} | |
7278 | @end smallexample | |
7279 | ||
7280 | This warning is enabled by @option{-Wall}. | |
7281 | ||
d77de738 ML |
7282 | @opindex Wsequence-point |
7283 | @opindex Wno-sequence-point | |
ddf6fe37 | 7284 | @item -Wsequence-point |
d77de738 ML |
7285 | Warn about code that may have undefined semantics because of violations |
7286 | of sequence point rules in the C and C++ standards. | |
7287 | ||
7288 | The C and C++ standards define the order in which expressions in a C/C++ | |
7289 | program are evaluated in terms of @dfn{sequence points}, which represent | |
7290 | a partial ordering between the execution of parts of the program: those | |
7291 | executed before the sequence point, and those executed after it. These | |
7292 | occur after the evaluation of a full expression (one which is not part | |
7293 | of a larger expression), after the evaluation of the first operand of a | |
7294 | @code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a | |
7295 | function is called (but after the evaluation of its arguments and the | |
7296 | expression denoting the called function), and in certain other places. | |
7297 | Other than as expressed by the sequence point rules, the order of | |
7298 | evaluation of subexpressions of an expression is not specified. All | |
7299 | these rules describe only a partial order rather than a total order, | |
7300 | since, for example, if two functions are called within one expression | |
7301 | with no sequence point between them, the order in which the functions | |
7302 | are called is not specified. However, the standards committee have | |
7303 | ruled that function calls do not overlap. | |
7304 | ||
7305 | It is not specified when between sequence points modifications to the | |
7306 | values of objects take effect. Programs whose behavior depends on this | |
7307 | have undefined behavior; the C and C++ standards specify that ``Between | |
7308 | the previous and next sequence point an object shall have its stored | |
7309 | value modified at most once by the evaluation of an expression. | |
7310 | Furthermore, the prior value shall be read only to determine the value | |
7311 | to be stored.''. If a program breaks these rules, the results on any | |
7312 | particular implementation are entirely unpredictable. | |
7313 | ||
7314 | Examples of code with undefined behavior are @code{a = a++;}, @code{a[n] | |
7315 | = b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not | |
7316 | diagnosed by this option, and it may give an occasional false positive | |
7317 | result, but in general it has been found fairly effective at detecting | |
7318 | this sort of problem in programs. | |
7319 | ||
7320 | The C++17 standard will define the order of evaluation of operands in | |
7321 | more cases: in particular it requires that the right-hand side of an | |
7322 | assignment be evaluated before the left-hand side, so the above | |
7323 | examples are no longer undefined. But this option will still warn | |
7324 | about them, to help people avoid writing code that is undefined in C | |
7325 | and earlier revisions of C++. | |
7326 | ||
7327 | The standard is worded confusingly, therefore there is some debate | |
7328 | over the precise meaning of the sequence point rules in subtle cases. | |
7329 | Links to discussions of the problem, including proposed formal | |
7330 | definitions, may be found on the GCC readings page, at | |
7331 | @uref{https://gcc.gnu.org/@/readings.html}. | |
7332 | ||
7333 | This warning is enabled by @option{-Wall} for C and C++. | |
7334 | ||
d77de738 ML |
7335 | @opindex Wno-return-local-addr |
7336 | @opindex Wreturn-local-addr | |
ddf6fe37 | 7337 | @item -Wno-return-local-addr |
d77de738 ML |
7338 | Do not warn about returning a pointer (or in C++, a reference) to a |
7339 | variable that goes out of scope after the function returns. | |
7340 | ||
d77de738 ML |
7341 | @opindex Wreturn-type |
7342 | @opindex Wno-return-type | |
ddf6fe37 | 7343 | @item -Wreturn-type |
d77de738 ML |
7344 | Warn whenever a function is defined with a return type that defaults |
7345 | to @code{int}. Also warn about any @code{return} statement with no | |
7346 | return value in a function whose return type is not @code{void} | |
7347 | (falling off the end of the function body is considered returning | |
7348 | without a value). | |
7349 | ||
7350 | For C only, warn about a @code{return} statement with an expression in a | |
7351 | function whose return type is @code{void}, unless the expression type is | |
7352 | also @code{void}. As a GNU extension, the latter case is accepted | |
7353 | without a warning unless @option{-Wpedantic} is used. Attempting | |
7354 | to use the return value of a non-@code{void} function other than @code{main} | |
7355 | that flows off the end by reaching the closing curly brace that terminates | |
7356 | the function is undefined. | |
7357 | ||
7358 | Unlike in C, in C++, flowing off the end of a non-@code{void} function other | |
7359 | than @code{main} results in undefined behavior even when the value of | |
7360 | the function is not used. | |
7361 | ||
7362 | This warning is enabled by default in C++ and by @option{-Wall} otherwise. | |
7363 | ||
d77de738 ML |
7364 | @opindex Wshift-count-negative |
7365 | @opindex Wno-shift-count-negative | |
ddf6fe37 | 7366 | @item -Wno-shift-count-negative |
d77de738 ML |
7367 | Controls warnings if a shift count is negative. |
7368 | This warning is enabled by default. | |
7369 | ||
d77de738 ML |
7370 | @opindex Wshift-count-overflow |
7371 | @opindex Wno-shift-count-overflow | |
ddf6fe37 | 7372 | @item -Wno-shift-count-overflow |
d77de738 ML |
7373 | Controls warnings if a shift count is greater than or equal to the bit width |
7374 | of the type. This warning is enabled by default. | |
7375 | ||
d77de738 ML |
7376 | @opindex Wshift-negative-value |
7377 | @opindex Wno-shift-negative-value | |
ddf6fe37 | 7378 | @item -Wshift-negative-value |
d77de738 ML |
7379 | Warn if left shifting a negative value. This warning is enabled by |
7380 | @option{-Wextra} in C99 (and newer) and C++11 to C++17 modes. | |
7381 | ||
d77de738 ML |
7382 | @opindex Wshift-overflow |
7383 | @opindex Wno-shift-overflow | |
ddf6fe37 AA |
7384 | @item -Wno-shift-overflow |
7385 | @itemx -Wshift-overflow=@var{n} | |
d77de738 ML |
7386 | These options control warnings about left shift overflows. |
7387 | ||
7388 | @table @gcctabopt | |
7389 | @item -Wshift-overflow=1 | |
7390 | This is the warning level of @option{-Wshift-overflow} and is enabled | |
7391 | by default in C99 and C++11 modes (and newer). This warning level does | |
7392 | not warn about left-shifting 1 into the sign bit. (However, in C, such | |
7393 | an overflow is still rejected in contexts where an integer constant expression | |
7394 | is required.) No warning is emitted in C++20 mode (and newer), as signed left | |
7395 | shifts always wrap. | |
7396 | ||
7397 | @item -Wshift-overflow=2 | |
7398 | This warning level also warns about left-shifting 1 into the sign bit, | |
7399 | unless C++14 mode (or newer) is active. | |
7400 | @end table | |
7401 | ||
d77de738 ML |
7402 | @opindex Wswitch |
7403 | @opindex Wno-switch | |
ddf6fe37 | 7404 | @item -Wswitch |
d77de738 ML |
7405 | Warn whenever a @code{switch} statement has an index of enumerated type |
7406 | and lacks a @code{case} for one or more of the named codes of that | |
7407 | enumeration. (The presence of a @code{default} label prevents this | |
7408 | warning.) @code{case} labels outside the enumeration range also | |
7409 | provoke warnings when this option is used (even if there is a | |
7410 | @code{default} label). | |
7411 | This warning is enabled by @option{-Wall}. | |
7412 | ||
d77de738 ML |
7413 | @opindex Wswitch-default |
7414 | @opindex Wno-switch-default | |
ddf6fe37 | 7415 | @item -Wswitch-default |
d77de738 ML |
7416 | Warn whenever a @code{switch} statement does not have a @code{default} |
7417 | case. | |
7418 | ||
d77de738 ML |
7419 | @opindex Wswitch-enum |
7420 | @opindex Wno-switch-enum | |
ddf6fe37 | 7421 | @item -Wswitch-enum |
d77de738 ML |
7422 | Warn whenever a @code{switch} statement has an index of enumerated type |
7423 | and lacks a @code{case} for one or more of the named codes of that | |
7424 | enumeration. @code{case} labels outside the enumeration range also | |
7425 | provoke warnings when this option is used. The only difference | |
7426 | between @option{-Wswitch} and this option is that this option gives a | |
7427 | warning about an omitted enumeration code even if there is a | |
7428 | @code{default} label. | |
7429 | ||
d77de738 ML |
7430 | @opindex Wswitch-bool |
7431 | @opindex Wno-switch-bool | |
ddf6fe37 | 7432 | @item -Wno-switch-bool |
d77de738 ML |
7433 | Do not warn when a @code{switch} statement has an index of boolean type |
7434 | and the case values are outside the range of a boolean type. | |
7435 | It is possible to suppress this warning by casting the controlling | |
7436 | expression to a type other than @code{bool}. For example: | |
7437 | @smallexample | |
7438 | @group | |
7439 | switch ((int) (a == 4)) | |
7440 | @{ | |
7441 | @dots{} | |
7442 | @} | |
7443 | @end group | |
7444 | @end smallexample | |
7445 | This warning is enabled by default for C and C++ programs. | |
7446 | ||
d77de738 ML |
7447 | @opindex Wswitch-outside-range |
7448 | @opindex Wno-switch-outside-range | |
ddf6fe37 | 7449 | @item -Wno-switch-outside-range |
d77de738 ML |
7450 | This option controls warnings when a @code{switch} case has a value |
7451 | that is outside of its | |
7452 | respective type range. This warning is enabled by default for | |
7453 | C and C++ programs. | |
7454 | ||
d77de738 ML |
7455 | @opindex Wswitch-unreachable |
7456 | @opindex Wno-switch-unreachable | |
ddf6fe37 | 7457 | @item -Wno-switch-unreachable |
d77de738 ML |
7458 | Do not warn when a @code{switch} statement contains statements between the |
7459 | controlling expression and the first case label, which will never be | |
7460 | executed. For example: | |
7461 | @smallexample | |
7462 | @group | |
7463 | switch (cond) | |
7464 | @{ | |
7465 | i = 15; | |
7466 | @dots{} | |
7467 | case 5: | |
7468 | @dots{} | |
7469 | @} | |
7470 | @end group | |
7471 | @end smallexample | |
7472 | @option{-Wswitch-unreachable} does not warn if the statement between the | |
7473 | controlling expression and the first case label is just a declaration: | |
7474 | @smallexample | |
7475 | @group | |
7476 | switch (cond) | |
7477 | @{ | |
7478 | int i; | |
7479 | @dots{} | |
7480 | case 5: | |
7481 | i = 5; | |
7482 | @dots{} | |
7483 | @} | |
7484 | @end group | |
7485 | @end smallexample | |
7486 | This warning is enabled by default for C and C++ programs. | |
7487 | ||
d77de738 ML |
7488 | @opindex Wsync-nand |
7489 | @opindex Wno-sync-nand | |
ddf6fe37 | 7490 | @item -Wsync-nand @r{(C and C++ only)} |
d77de738 ML |
7491 | Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch} |
7492 | built-in functions are used. These functions changed semantics in GCC 4.4. | |
7493 | ||
d77de738 ML |
7494 | @opindex Wtrivial-auto-var-init |
7495 | @opindex Wno-trivial-auto-var-init | |
ddf6fe37 | 7496 | @item -Wtrivial-auto-var-init |
d77de738 ML |
7497 | Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic |
7498 | variable. A common situation is an automatic variable that is declared | |
7499 | between the controlling expression and the first case label of a @code{switch} | |
7500 | statement. | |
7501 | ||
d77de738 ML |
7502 | @opindex Wunused-but-set-parameter |
7503 | @opindex Wno-unused-but-set-parameter | |
ddf6fe37 | 7504 | @item -Wunused-but-set-parameter |
d77de738 ML |
7505 | Warn whenever a function parameter is assigned to, but otherwise unused |
7506 | (aside from its declaration). | |
7507 | ||
7508 | To suppress this warning use the @code{unused} attribute | |
7509 | (@pxref{Variable Attributes}). | |
7510 | ||
7511 | This warning is also enabled by @option{-Wunused} together with | |
7512 | @option{-Wextra}. | |
7513 | ||
d77de738 ML |
7514 | @opindex Wunused-but-set-variable |
7515 | @opindex Wno-unused-but-set-variable | |
ddf6fe37 | 7516 | @item -Wunused-but-set-variable |
d77de738 ML |
7517 | Warn whenever a local variable is assigned to, but otherwise unused |
7518 | (aside from its declaration). | |
7519 | This warning is enabled by @option{-Wall}. | |
7520 | ||
7521 | To suppress this warning use the @code{unused} attribute | |
7522 | (@pxref{Variable Attributes}). | |
7523 | ||
7524 | This warning is also enabled by @option{-Wunused}, which is enabled | |
7525 | by @option{-Wall}. | |
7526 | ||
d77de738 ML |
7527 | @opindex Wunused-function |
7528 | @opindex Wno-unused-function | |
ddf6fe37 | 7529 | @item -Wunused-function |
d77de738 ML |
7530 | Warn whenever a static function is declared but not defined or a |
7531 | non-inline static function is unused. | |
7532 | This warning is enabled by @option{-Wall}. | |
7533 | ||
d77de738 ML |
7534 | @opindex Wunused-label |
7535 | @opindex Wno-unused-label | |
ddf6fe37 | 7536 | @item -Wunused-label |
d77de738 ML |
7537 | Warn whenever a label is declared but not used. |
7538 | This warning is enabled by @option{-Wall}. | |
7539 | ||
7540 | To suppress this warning use the @code{unused} attribute | |
7541 | (@pxref{Variable Attributes}). | |
7542 | ||
d77de738 ML |
7543 | @opindex Wunused-local-typedefs |
7544 | @opindex Wno-unused-local-typedefs | |
ddf6fe37 | 7545 | @item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)} |
d77de738 ML |
7546 | Warn when a typedef locally defined in a function is not used. |
7547 | This warning is enabled by @option{-Wall}. | |
7548 | ||
d77de738 ML |
7549 | @opindex Wunused-parameter |
7550 | @opindex Wno-unused-parameter | |
ddf6fe37 | 7551 | @item -Wunused-parameter |
d77de738 ML |
7552 | Warn whenever a function parameter is unused aside from its declaration. |
7553 | ||
7554 | To suppress this warning use the @code{unused} attribute | |
7555 | (@pxref{Variable Attributes}). | |
7556 | ||
d77de738 ML |
7557 | @opindex Wunused-result |
7558 | @opindex Wno-unused-result | |
ddf6fe37 | 7559 | @item -Wno-unused-result |
d77de738 ML |
7560 | Do not warn if a caller of a function marked with attribute |
7561 | @code{warn_unused_result} (@pxref{Function Attributes}) does not use | |
7562 | its return value. The default is @option{-Wunused-result}. | |
7563 | ||
d77de738 ML |
7564 | @opindex Wunused-variable |
7565 | @opindex Wno-unused-variable | |
ddf6fe37 | 7566 | @item -Wunused-variable |
d77de738 ML |
7567 | Warn whenever a local or static variable is unused aside from its |
7568 | declaration. This option implies @option{-Wunused-const-variable=1} for C, | |
7569 | but not for C++. This warning is enabled by @option{-Wall}. | |
7570 | ||
7571 | To suppress this warning use the @code{unused} attribute | |
7572 | (@pxref{Variable Attributes}). | |
7573 | ||
d77de738 ML |
7574 | @opindex Wunused-const-variable |
7575 | @opindex Wno-unused-const-variable | |
ddf6fe37 AA |
7576 | @item -Wunused-const-variable |
7577 | @itemx -Wunused-const-variable=@var{n} | |
d77de738 ML |
7578 | Warn whenever a constant static variable is unused aside from its declaration. |
7579 | @option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable} | |
7580 | for C, but not for C++. In C this declares variable storage, but in C++ this | |
7581 | is not an error since const variables take the place of @code{#define}s. | |
7582 | ||
7583 | To suppress this warning use the @code{unused} attribute | |
7584 | (@pxref{Variable Attributes}). | |
7585 | ||
7586 | @table @gcctabopt | |
7587 | @item -Wunused-const-variable=1 | |
7588 | This is the warning level that is enabled by @option{-Wunused-variable} for | |
7589 | C. It warns only about unused static const variables defined in the main | |
7590 | compilation unit, but not about static const variables declared in any | |
7591 | header included. | |
7592 | ||
7593 | @item -Wunused-const-variable=2 | |
7594 | This warning level also warns for unused constant static variables in | |
7595 | headers (excluding system headers). This is the warning level of | |
7596 | @option{-Wunused-const-variable} and must be explicitly requested since | |
7597 | in C++ this isn't an error and in C it might be harder to clean up all | |
7598 | headers included. | |
7599 | @end table | |
7600 | ||
d77de738 ML |
7601 | @opindex Wunused-value |
7602 | @opindex Wno-unused-value | |
ddf6fe37 | 7603 | @item -Wunused-value |
d77de738 ML |
7604 | Warn whenever a statement computes a result that is explicitly not |
7605 | used. To suppress this warning cast the unused expression to | |
7606 | @code{void}. This includes an expression-statement or the left-hand | |
7607 | side of a comma expression that contains no side effects. For example, | |
7608 | an expression such as @code{x[i,j]} causes a warning, while | |
7609 | @code{x[(void)i,j]} does not. | |
7610 | ||
7611 | This warning is enabled by @option{-Wall}. | |
7612 | ||
d77de738 ML |
7613 | @opindex Wunused |
7614 | @opindex Wno-unused | |
ddf6fe37 | 7615 | @item -Wunused |
d77de738 ML |
7616 | All the above @option{-Wunused} options combined. |
7617 | ||
7618 | In order to get a warning about an unused function parameter, you must | |
7619 | either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies | |
7620 | @option{-Wunused}), or separately specify @option{-Wunused-parameter}. | |
7621 | ||
d77de738 ML |
7622 | @opindex Wuninitialized |
7623 | @opindex Wno-uninitialized | |
ddf6fe37 | 7624 | @item -Wuninitialized |
d77de738 ML |
7625 | Warn if an object with automatic or allocated storage duration is used |
7626 | without having been initialized. In C++, also warn if a non-static | |
7627 | reference or non-static @code{const} member appears in a class without | |
7628 | constructors. | |
7629 | ||
7630 | In addition, passing a pointer (or in C++, a reference) to an uninitialized | |
7631 | object to a @code{const}-qualified argument of a built-in function known to | |
7632 | read the object is also diagnosed by this warning. | |
7633 | (@option{-Wmaybe-uninitialized} is issued for ordinary functions.) | |
7634 | ||
7635 | If you want to warn about code that uses the uninitialized value of the | |
7636 | variable in its own initializer, use the @option{-Winit-self} option. | |
7637 | ||
7638 | These warnings occur for individual uninitialized elements of | |
7639 | structure, union or array variables as well as for variables that are | |
7640 | uninitialized as a whole. They do not occur for variables or elements | |
7641 | declared @code{volatile}. Because these warnings depend on | |
7642 | optimization, the exact variables or elements for which there are | |
7643 | warnings depend on the precise optimization options and version of GCC | |
7644 | used. | |
7645 | ||
7646 | Note that there may be no warning about a variable that is used only | |
7647 | to compute a value that itself is never used, because such | |
7648 | computations may be deleted by data flow analysis before the warnings | |
7649 | are printed. | |
7650 | ||
7651 | In C++, this warning also warns about using uninitialized objects in | |
7652 | member-initializer-lists. For example, GCC warns about @code{b} being | |
7653 | uninitialized in the following snippet: | |
7654 | ||
7655 | @smallexample | |
7656 | struct A @{ | |
7657 | int a; | |
7658 | int b; | |
7659 | A() : a(b) @{ @} | |
7660 | @}; | |
7661 | @end smallexample | |
7662 | ||
d77de738 ML |
7663 | @opindex Winvalid-memory-model |
7664 | @opindex Wno-invalid-memory-model | |
ddf6fe37 | 7665 | @item -Wno-invalid-memory-model |
d77de738 ML |
7666 | This option controls warnings |
7667 | for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins}, | |
7668 | and the C11 atomic generic functions with a memory consistency argument | |
7669 | that is either invalid for the operation or outside the range of values | |
7670 | of the @code{memory_order} enumeration. For example, since the | |
7671 | @code{__atomic_store} and @code{__atomic_store_n} built-ins are only | |
7672 | defined for the relaxed, release, and sequentially consistent memory | |
7673 | orders the following code is diagnosed: | |
7674 | ||
7675 | @smallexample | |
7676 | void store (int *i) | |
7677 | @{ | |
7678 | __atomic_store_n (i, 0, memory_order_consume); | |
7679 | @} | |
7680 | @end smallexample | |
7681 | ||
7682 | @option{-Winvalid-memory-model} is enabled by default. | |
7683 | ||
d77de738 ML |
7684 | @opindex Wmaybe-uninitialized |
7685 | @opindex Wno-maybe-uninitialized | |
ddf6fe37 | 7686 | @item -Wmaybe-uninitialized |
d77de738 ML |
7687 | For an object with automatic or allocated storage duration, if there exists |
7688 | a path from the function entry to a use of the object that is initialized, | |
7689 | but there exist some other paths for which the object is not initialized, | |
7690 | the compiler emits a warning if it cannot prove the uninitialized paths | |
7691 | are not executed at run time. | |
7692 | ||
7693 | In addition, passing a pointer (or in C++, a reference) to an uninitialized | |
7694 | object to a @code{const}-qualified function argument is also diagnosed by | |
7695 | this warning. (@option{-Wuninitialized} is issued for built-in functions | |
7696 | known to read the object.) Annotating the function with attribute | |
7697 | @code{access (none)} indicates that the argument isn't used to access | |
7698 | the object and avoids the warning (@pxref{Common Function Attributes}). | |
7699 | ||
7700 | These warnings are only possible in optimizing compilation, because otherwise | |
7701 | GCC does not keep track of the state of variables. | |
7702 | ||
7703 | These warnings are made optional because GCC may not be able to determine when | |
7704 | the code is correct in spite of appearing to have an error. Here is one | |
7705 | example of how this can happen: | |
7706 | ||
7707 | @smallexample | |
7708 | @group | |
7709 | @{ | |
7710 | int x; | |
7711 | switch (y) | |
7712 | @{ | |
7713 | case 1: x = 1; | |
7714 | break; | |
7715 | case 2: x = 4; | |
7716 | break; | |
7717 | case 3: x = 5; | |
7718 | @} | |
7719 | foo (x); | |
7720 | @} | |
7721 | @end group | |
7722 | @end smallexample | |
7723 | ||
7724 | @noindent | |
7725 | If the value of @code{y} is always 1, 2 or 3, then @code{x} is | |
7726 | always initialized, but GCC doesn't know this. To suppress the | |
7727 | warning, you need to provide a default case with assert(0) or | |
7728 | similar code. | |
7729 | ||
7730 | @cindex @code{longjmp} warnings | |
7731 | This option also warns when a non-volatile automatic variable might be | |
7732 | changed by a call to @code{longjmp}. | |
7733 | The compiler sees only the calls to @code{setjmp}. It cannot know | |
7734 | where @code{longjmp} will be called; in fact, a signal handler could | |
7735 | call it at any point in the code. As a result, you may get a warning | |
7736 | even when there is in fact no problem because @code{longjmp} cannot | |
7737 | in fact be called at the place that would cause a problem. | |
7738 | ||
7739 | Some spurious warnings can be avoided if you declare all the functions | |
7740 | you use that never return as @code{noreturn}. @xref{Function | |
7741 | Attributes}. | |
7742 | ||
7743 | This warning is enabled by @option{-Wall} or @option{-Wextra}. | |
7744 | ||
d77de738 ML |
7745 | @opindex Wunknown-pragmas |
7746 | @opindex Wno-unknown-pragmas | |
7747 | @cindex warning for unknown pragmas | |
7748 | @cindex unknown pragmas, warning | |
7749 | @cindex pragmas, warning of unknown | |
f33d7a88 | 7750 | @item -Wunknown-pragmas |
d77de738 ML |
7751 | Warn when a @code{#pragma} directive is encountered that is not understood by |
7752 | GCC@. If this command-line option is used, warnings are even issued | |
7753 | for unknown pragmas in system header files. This is not the case if | |
7754 | the warnings are only enabled by the @option{-Wall} command-line option. | |
7755 | ||
d77de738 ML |
7756 | @opindex Wno-pragmas |
7757 | @opindex Wpragmas | |
ddf6fe37 | 7758 | @item -Wno-pragmas |
d77de738 ML |
7759 | Do not warn about misuses of pragmas, such as incorrect parameters, |
7760 | invalid syntax, or conflicts between pragmas. See also | |
7761 | @option{-Wunknown-pragmas}. | |
7762 | ||
d77de738 ML |
7763 | @opindex Wno-prio-ctor-dtor |
7764 | @opindex Wprio-ctor-dtor | |
ddf6fe37 | 7765 | @item -Wno-prio-ctor-dtor |
d77de738 ML |
7766 | Do not warn if a priority from 0 to 100 is used for constructor or destructor. |
7767 | The use of constructor and destructor attributes allow you to assign a | |
7768 | priority to the constructor/destructor to control its order of execution | |
7769 | before @code{main} is called or after it returns. The priority values must be | |
7770 | greater than 100 as the compiler reserves priority values between 0--100 for | |
7771 | the implementation. | |
7772 | ||
d77de738 ML |
7773 | @opindex Wstrict-aliasing |
7774 | @opindex Wno-strict-aliasing | |
ddf6fe37 | 7775 | @item -Wstrict-aliasing |
d77de738 ML |
7776 | This option is only active when @option{-fstrict-aliasing} is active. |
7777 | It warns about code that might break the strict aliasing rules that the | |
7778 | compiler is using for optimization. The warning does not catch all | |
7779 | cases, but does attempt to catch the more common pitfalls. It is | |
7780 | included in @option{-Wall}. | |
7781 | It is equivalent to @option{-Wstrict-aliasing=3} | |
7782 | ||
d77de738 | 7783 | @opindex Wstrict-aliasing=n |
ddf6fe37 | 7784 | @item -Wstrict-aliasing=n |
d77de738 ML |
7785 | This option is only active when @option{-fstrict-aliasing} is active. |
7786 | It warns about code that might break the strict aliasing rules that the | |
7787 | compiler is using for optimization. | |
7788 | Higher levels correspond to higher accuracy (fewer false positives). | |
7789 | Higher levels also correspond to more effort, similar to the way @option{-O} | |
7790 | works. | |
7791 | @option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}. | |
7792 | ||
7793 | Level 1: Most aggressive, quick, least accurate. | |
7794 | Possibly useful when higher levels | |
7795 | do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few | |
7796 | false negatives. However, it has many false positives. | |
7797 | Warns for all pointer conversions between possibly incompatible types, | |
7798 | even if never dereferenced. Runs in the front end only. | |
7799 | ||
7800 | Level 2: Aggressive, quick, not too precise. | |
7801 | May still have many false positives (not as many as level 1 though), | |
7802 | and few false negatives (but possibly more than level 1). | |
7803 | Unlike level 1, it only warns when an address is taken. Warns about | |
7804 | incomplete types. Runs in the front end only. | |
7805 | ||
7806 | Level 3 (default for @option{-Wstrict-aliasing}): | |
7807 | Should have very few false positives and few false | |
7808 | negatives. Slightly slower than levels 1 or 2 when optimization is enabled. | |
7809 | Takes care of the common pun+dereference pattern in the front end: | |
7810 | @code{*(int*)&some_float}. | |
7811 | If optimization is enabled, it also runs in the back end, where it deals | |
7812 | with multiple statement cases using flow-sensitive points-to information. | |
7813 | Only warns when the converted pointer is dereferenced. | |
7814 | Does not warn about incomplete types. | |
7815 | ||
d77de738 ML |
7816 | @opindex Wstrict-overflow |
7817 | @opindex Wno-strict-overflow | |
ddf6fe37 AA |
7818 | @item -Wstrict-overflow |
7819 | @itemx -Wstrict-overflow=@var{n} | |
d77de738 ML |
7820 | This option is only active when signed overflow is undefined. |
7821 | It warns about cases where the compiler optimizes based on the | |
7822 | assumption that signed overflow does not occur. Note that it does not | |
7823 | warn about all cases where the code might overflow: it only warns | |
7824 | about cases where the compiler implements some optimization. Thus | |
7825 | this warning depends on the optimization level. | |
7826 | ||
7827 | An optimization that assumes that signed overflow does not occur is | |
7828 | perfectly safe if the values of the variables involved are such that | |
7829 | overflow never does, in fact, occur. Therefore this warning can | |
7830 | easily give a false positive: a warning about code that is not | |
7831 | actually a problem. To help focus on important issues, several | |
7832 | warning levels are defined. No warnings are issued for the use of | |
7833 | undefined signed overflow when estimating how many iterations a loop | |
7834 | requires, in particular when determining whether a loop will be | |
7835 | executed at all. | |
7836 | ||
7837 | @table @gcctabopt | |
7838 | @item -Wstrict-overflow=1 | |
7839 | Warn about cases that are both questionable and easy to avoid. For | |
7840 | example the compiler simplifies | |
7841 | @code{x + 1 > x} to @code{1}. This level of | |
7842 | @option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels | |
7843 | are not, and must be explicitly requested. | |
7844 | ||
7845 | @item -Wstrict-overflow=2 | |
7846 | Also warn about other cases where a comparison is simplified to a | |
7847 | constant. For example: @code{abs (x) >= 0}. This can only be | |
7848 | simplified when signed integer overflow is undefined, because | |
7849 | @code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than | |
7850 | zero. @option{-Wstrict-overflow} (with no level) is the same as | |
7851 | @option{-Wstrict-overflow=2}. | |
7852 | ||
7853 | @item -Wstrict-overflow=3 | |
7854 | Also warn about other cases where a comparison is simplified. For | |
7855 | example: @code{x + 1 > 1} is simplified to @code{x > 0}. | |
7856 | ||
7857 | @item -Wstrict-overflow=4 | |
7858 | Also warn about other simplifications not covered by the above cases. | |
7859 | For example: @code{(x * 10) / 5} is simplified to @code{x * 2}. | |
7860 | ||
7861 | @item -Wstrict-overflow=5 | |
7862 | Also warn about cases where the compiler reduces the magnitude of a | |
7863 | constant involved in a comparison. For example: @code{x + 2 > y} is | |
7864 | simplified to @code{x + 1 >= y}. This is reported only at the | |
7865 | highest warning level because this simplification applies to many | |
7866 | comparisons, so this warning level gives a very large number of | |
7867 | false positives. | |
7868 | @end table | |
7869 | ||
d77de738 ML |
7870 | @opindex Wstring-compare |
7871 | @opindex Wno-string-compare | |
ddf6fe37 | 7872 | @item -Wstring-compare |
d77de738 ML |
7873 | Warn for calls to @code{strcmp} and @code{strncmp} whose result is |
7874 | determined to be either zero or non-zero in tests for such equality | |
7875 | owing to the length of one argument being greater than the size of | |
7876 | the array the other argument is stored in (or the bound in the case | |
7877 | of @code{strncmp}). Such calls could be mistakes. For example, | |
7878 | the call to @code{strcmp} below is diagnosed because its result is | |
7879 | necessarily non-zero irrespective of the contents of the array @code{a}. | |
7880 | ||
7881 | @smallexample | |
7882 | extern char a[4]; | |
7883 | void f (char *d) | |
7884 | @{ | |
7885 | strcpy (d, "string"); | |
7886 | @dots{} | |
7887 | if (0 == strcmp (a, d)) // cannot be true | |
7888 | puts ("a and d are the same"); | |
7889 | @} | |
7890 | @end smallexample | |
7891 | ||
7892 | @option{-Wstring-compare} is enabled by @option{-Wextra}. | |
7893 | ||
ddf6fe37 AA |
7894 | @opindex Wstringop-overflow |
7895 | @opindex Wno-stringop-overflow | |
d77de738 ML |
7896 | @item -Wno-stringop-overflow |
7897 | @item -Wstringop-overflow | |
7898 | @itemx -Wstringop-overflow=@var{type} | |
d77de738 ML |
7899 | Warn for calls to string manipulation functions such as @code{memcpy} and |
7900 | @code{strcpy} that are determined to overflow the destination buffer. The | |
7901 | optional argument is one greater than the type of Object Size Checking to | |
7902 | perform to determine the size of the destination. @xref{Object Size Checking}. | |
7903 | The argument is meaningful only for functions that operate on character arrays | |
7904 | but not for raw memory functions like @code{memcpy} which always make use | |
7905 | of Object Size type-0. The option also warns for calls that specify a size | |
7906 | in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes. | |
7907 | The option produces the best results with optimization enabled but can detect | |
7908 | a small subset of simple buffer overflows even without optimization in | |
7909 | calls to the GCC built-in functions like @code{__builtin_memcpy} that | |
7910 | correspond to the standard functions. In any case, the option warns about | |
7911 | just a subset of buffer overflows detected by the corresponding overflow | |
7912 | checking built-ins. For example, the option issues a warning for | |
7913 | the @code{strcpy} call below because it copies at least 5 characters | |
7914 | (the string @code{"blue"} including the terminating NUL) into the buffer | |
7915 | of size 4. | |
7916 | ||
7917 | @smallexample | |
7918 | enum Color @{ blue, purple, yellow @}; | |
7919 | const char* f (enum Color clr) | |
7920 | @{ | |
7921 | static char buf [4]; | |
7922 | const char *str; | |
7923 | switch (clr) | |
7924 | @{ | |
7925 | case blue: str = "blue"; break; | |
7926 | case purple: str = "purple"; break; | |
7927 | case yellow: str = "yellow"; break; | |
7928 | @} | |
7929 | ||
7930 | return strcpy (buf, str); // warning here | |
7931 | @} | |
7932 | @end smallexample | |
7933 | ||
7934 | Option @option{-Wstringop-overflow=2} is enabled by default. | |
7935 | ||
7936 | @table @gcctabopt | |
d77de738 ML |
7937 | @opindex Wstringop-overflow |
7938 | @opindex Wno-stringop-overflow | |
ddf6fe37 AA |
7939 | @item -Wstringop-overflow |
7940 | @itemx -Wstringop-overflow=1 | |
d77de738 ML |
7941 | The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking |
7942 | to determine the sizes of destination objects. At this setting the option | |
7943 | does not warn for writes past the end of subobjects of larger objects accessed | |
7944 | by pointers unless the size of the largest surrounding object is known. When | |
7945 | the destination may be one of several objects it is assumed to be the largest | |
7946 | one of them. On Linux systems, when optimization is enabled at this setting | |
7947 | the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro | |
7948 | is defined to a non-zero value. | |
7949 | ||
7950 | @item -Wstringop-overflow=2 | |
7951 | The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking | |
7952 | to determine the sizes of destination objects. At this setting the option | |
7953 | warns about overflows when writing to members of the largest complete | |
7954 | objects whose exact size is known. However, it does not warn for excessive | |
7955 | writes to the same members of unknown objects referenced by pointers since | |
7956 | they may point to arrays containing unknown numbers of elements. This is | |
7957 | the default setting of the option. | |
7958 | ||
7959 | @item -Wstringop-overflow=3 | |
7960 | The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking | |
7961 | to determine the sizes of destination objects. At this setting the option | |
7962 | warns about overflowing the smallest object or data member. This is the | |
7963 | most restrictive setting of the option that may result in warnings for safe | |
7964 | code. | |
7965 | ||
7966 | @item -Wstringop-overflow=4 | |
7967 | The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking | |
7968 | to determine the sizes of destination objects. At this setting the option | |
7969 | warns about overflowing any data members, and when the destination is | |
7970 | one of several objects it uses the size of the largest of them to decide | |
7971 | whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this | |
7972 | setting of the option may result in warnings for benign code. | |
7973 | @end table | |
7974 | ||
d77de738 ML |
7975 | @opindex Wstringop-overread |
7976 | @opindex Wno-stringop-overread | |
ddf6fe37 | 7977 | @item -Wno-stringop-overread |
d77de738 ML |
7978 | Warn for calls to string manipulation functions such as @code{memchr}, or |
7979 | @code{strcpy} that are determined to read past the end of the source | |
7980 | sequence. | |
7981 | ||
7982 | Option @option{-Wstringop-overread} is enabled by default. | |
7983 | ||
d77de738 ML |
7984 | @opindex Wstringop-truncation |
7985 | @opindex Wno-stringop-truncation | |
ddf6fe37 | 7986 | @item -Wno-stringop-truncation |
d77de738 ML |
7987 | Do not warn for calls to bounded string manipulation functions |
7988 | such as @code{strncat}, | |
7989 | @code{strncpy}, and @code{stpncpy} that may either truncate the copied string | |
7990 | or leave the destination unchanged. | |
7991 | ||
7992 | In the following example, the call to @code{strncat} specifies a bound that | |
7993 | is less than the length of the source string. As a result, the copy of | |
7994 | the source will be truncated and so the call is diagnosed. To avoid the | |
7995 | warning use @code{bufsize - strlen (buf) - 1)} as the bound. | |
7996 | ||
7997 | @smallexample | |
7998 | void append (char *buf, size_t bufsize) | |
7999 | @{ | |
8000 | strncat (buf, ".txt", 3); | |
8001 | @} | |
8002 | @end smallexample | |
8003 | ||
8004 | As another example, the following call to @code{strncpy} results in copying | |
8005 | to @code{d} just the characters preceding the terminating NUL, without | |
8006 | appending the NUL to the end. Assuming the result of @code{strncpy} is | |
8007 | necessarily a NUL-terminated string is a common mistake, and so the call | |
8008 | is diagnosed. To avoid the warning when the result is not expected to be | |
8009 | NUL-terminated, call @code{memcpy} instead. | |
8010 | ||
8011 | @smallexample | |
8012 | void copy (char *d, const char *s) | |
8013 | @{ | |
8014 | strncpy (d, s, strlen (s)); | |
8015 | @} | |
8016 | @end smallexample | |
8017 | ||
8018 | In the following example, the call to @code{strncpy} specifies the size | |
8019 | of the destination buffer as the bound. If the length of the source | |
8020 | string is equal to or greater than this size the result of the copy will | |
8021 | not be NUL-terminated. Therefore, the call is also diagnosed. To avoid | |
8022 | the warning, specify @code{sizeof buf - 1} as the bound and set the last | |
8023 | element of the buffer to @code{NUL}. | |
8024 | ||
8025 | @smallexample | |
8026 | void copy (const char *s) | |
8027 | @{ | |
8028 | char buf[80]; | |
8029 | strncpy (buf, s, sizeof buf); | |
8030 | @dots{} | |
8031 | @} | |
8032 | @end smallexample | |
8033 | ||
8034 | In situations where a character array is intended to store a sequence | |
8035 | of bytes with no terminating @code{NUL} such an array may be annotated | |
8036 | with attribute @code{nonstring} to avoid this warning. Such arrays, | |
8037 | however, are not suitable arguments to functions that expect | |
8038 | @code{NUL}-terminated strings. To help detect accidental misuses of | |
8039 | such arrays GCC issues warnings unless it can prove that the use is | |
8040 | safe. @xref{Common Variable Attributes}. | |
8041 | ||
2a27ae32 QZ |
8042 | @opindex Wstrict-flex-arrays |
8043 | @opindex Wno-strict-flex-arrays | |
ddf6fe37 | 8044 | @item -Wstrict-flex-arrays |
2a27ae32 QZ |
8045 | Warn about inproper usages of flexible array members |
8046 | according to the @var{level} of the @code{strict_flex_array (@var{level})} | |
8047 | attribute attached to the trailing array field of a structure if it's | |
8048 | available, otherwise according to the @var{level} of the option | |
8049 | @option{-fstrict-flex-arrays=@var{level}}. | |
8050 | ||
8051 | This option is effective only when @var{level} is bigger than 0. Otherwise, | |
8052 | it will be ignored with a warning. | |
8053 | ||
8054 | when @var{level}=1, warnings will be issued for a trailing array reference | |
8055 | of a structure that have 2 or more elements if the trailing array is referenced | |
8056 | as a flexible array member. | |
8057 | ||
8058 | when @var{level}=2, in addition to @var{level}=1, additional warnings will be | |
8059 | issued for a trailing one-element array reference of a structure | |
8060 | if the array is referenced as a flexible array member. | |
8061 | ||
8062 | when @var{level}=3, in addition to @var{level}=2, additional warnings will be | |
8063 | issued for a trailing zero-length array reference of a structure | |
8064 | if the array is referenced as a flexible array member. | |
8065 | ||
8066 | ||
d77de738 ML |
8067 | @opindex Wsuggest-attribute= |
8068 | @opindex Wno-suggest-attribute= | |
ddf6fe37 | 8069 | @item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]} |
d77de738 ML |
8070 | Warn for cases where adding an attribute may be beneficial. The |
8071 | attributes currently supported are listed below. | |
8072 | ||
8073 | @table @gcctabopt | |
d77de738 ML |
8074 | @opindex Wsuggest-attribute=pure |
8075 | @opindex Wno-suggest-attribute=pure | |
8076 | @opindex Wsuggest-attribute=const | |
8077 | @opindex Wno-suggest-attribute=const | |
8078 | @opindex Wsuggest-attribute=noreturn | |
8079 | @opindex Wno-suggest-attribute=noreturn | |
8080 | @opindex Wmissing-noreturn | |
8081 | @opindex Wno-missing-noreturn | |
8082 | @opindex Wsuggest-attribute=malloc | |
8083 | @opindex Wno-suggest-attribute=malloc | |
ddf6fe37 AA |
8084 | @item -Wsuggest-attribute=pure |
8085 | @itemx -Wsuggest-attribute=const | |
8086 | @itemx -Wsuggest-attribute=noreturn | |
8087 | @itemx -Wmissing-noreturn | |
8088 | @itemx -Wsuggest-attribute=malloc | |
d77de738 ML |
8089 | |
8090 | Warn about functions that might be candidates for attributes | |
8091 | @code{pure}, @code{const} or @code{noreturn} or @code{malloc}. The compiler | |
8092 | only warns for functions visible in other compilation units or (in the case of | |
8093 | @code{pure} and @code{const}) if it cannot prove that the function returns | |
8094 | normally. A function returns normally if it doesn't contain an infinite loop or | |
8095 | return abnormally by throwing, calling @code{abort} or trapping. This analysis | |
8096 | requires option @option{-fipa-pure-const}, which is enabled by default at | |
8097 | @option{-O} and higher. Higher optimization levels improve the accuracy | |
8098 | of the analysis. | |
8099 | ||
d77de738 ML |
8100 | @opindex Wsuggest-attribute=format |
8101 | @opindex Wmissing-format-attribute | |
8102 | @opindex Wno-suggest-attribute=format | |
8103 | @opindex Wno-missing-format-attribute | |
8104 | @opindex Wformat | |
8105 | @opindex Wno-format | |
ddf6fe37 AA |
8106 | @item -Wsuggest-attribute=format |
8107 | @itemx -Wmissing-format-attribute | |
d77de738 ML |
8108 | |
8109 | Warn about function pointers that might be candidates for @code{format} | |
8110 | attributes. Note these are only possible candidates, not absolute ones. | |
8111 | GCC guesses that function pointers with @code{format} attributes that | |
8112 | are used in assignment, initialization, parameter passing or return | |
8113 | statements should have a corresponding @code{format} attribute in the | |
8114 | resulting type. I.e.@: the left-hand side of the assignment or | |
8115 | initialization, the type of the parameter variable, or the return type | |
8116 | of the containing function respectively should also have a @code{format} | |
8117 | attribute to avoid the warning. | |
8118 | ||
8119 | GCC also warns about function definitions that might be | |
8120 | candidates for @code{format} attributes. Again, these are only | |
8121 | possible candidates. GCC guesses that @code{format} attributes | |
8122 | might be appropriate for any function that calls a function like | |
8123 | @code{vprintf} or @code{vscanf}, but this might not always be the | |
8124 | case, and some functions for which @code{format} attributes are | |
8125 | appropriate may not be detected. | |
8126 | ||
d77de738 ML |
8127 | @opindex Wsuggest-attribute=cold |
8128 | @opindex Wno-suggest-attribute=cold | |
ddf6fe37 | 8129 | @item -Wsuggest-attribute=cold |
d77de738 ML |
8130 | |
8131 | Warn about functions that might be candidates for @code{cold} attribute. This | |
8132 | is based on static detection and generally only warns about functions which | |
8133 | always leads to a call to another @code{cold} function such as wrappers of | |
8134 | C++ @code{throw} or fatal error reporting functions leading to @code{abort}. | |
8135 | @end table | |
8136 | ||
d77de738 ML |
8137 | @opindex Wno-alloc-zero |
8138 | @opindex Walloc-zero | |
ddf6fe37 | 8139 | @item -Walloc-zero |
d77de738 ML |
8140 | Warn about calls to allocation functions decorated with attribute |
8141 | @code{alloc_size} that specify zero bytes, including those to the built-in | |
8142 | forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc}, | |
8143 | @code{malloc}, and @code{realloc}. Because the behavior of these functions | |
8144 | when called with a zero size differs among implementations (and in the case | |
8145 | of @code{realloc} has been deprecated) relying on it may result in subtle | |
8146 | portability bugs and should be avoided. | |
8147 | ||
d77de738 ML |
8148 | @opindex Walloc-size-larger-than= |
8149 | @opindex Wno-alloc-size-larger-than | |
ddf6fe37 | 8150 | @item -Walloc-size-larger-than=@var{byte-size} |
d77de738 ML |
8151 | Warn about calls to functions decorated with attribute @code{alloc_size} |
8152 | that attempt to allocate objects larger than the specified number of bytes, | |
8153 | or where the result of the size computation in an integer type with infinite | |
8154 | precision would exceed the value of @samp{PTRDIFF_MAX} on the target. | |
8155 | @option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default. | |
8156 | Warnings controlled by the option can be disabled either by specifying | |
8157 | @var{byte-size} of @samp{SIZE_MAX} or more or by | |
8158 | @option{-Wno-alloc-size-larger-than}. | |
8159 | @xref{Function Attributes}. | |
8160 | ||
d77de738 | 8161 | @opindex Wno-alloc-size-larger-than |
ddf6fe37 | 8162 | @item -Wno-alloc-size-larger-than |
d77de738 ML |
8163 | Disable @option{-Walloc-size-larger-than=} warnings. The option is |
8164 | equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or | |
8165 | larger. | |
8166 | ||
d77de738 ML |
8167 | @opindex Wno-alloca |
8168 | @opindex Walloca | |
ddf6fe37 | 8169 | @item -Walloca |
d77de738 ML |
8170 | This option warns on all uses of @code{alloca} in the source. |
8171 | ||
d77de738 ML |
8172 | @opindex Walloca-larger-than= |
8173 | @opindex Wno-alloca-larger-than | |
ddf6fe37 | 8174 | @item -Walloca-larger-than=@var{byte-size} |
d77de738 ML |
8175 | This option warns on calls to @code{alloca} with an integer argument whose |
8176 | value is either zero, or that is not bounded by a controlling predicate | |
8177 | that limits its value to at most @var{byte-size}. It also warns for calls | |
8178 | to @code{alloca} where the bound value is unknown. Arguments of non-integer | |
8179 | types are considered unbounded even if they appear to be constrained to | |
8180 | the expected range. | |
8181 | ||
8182 | For example, a bounded case of @code{alloca} could be: | |
8183 | ||
8184 | @smallexample | |
8185 | void func (size_t n) | |
8186 | @{ | |
8187 | void *p; | |
8188 | if (n <= 1000) | |
8189 | p = alloca (n); | |
8190 | else | |
8191 | p = malloc (n); | |
8192 | f (p); | |
8193 | @} | |
8194 | @end smallexample | |
8195 | ||
8196 | In the above example, passing @code{-Walloca-larger-than=1000} would not | |
8197 | issue a warning because the call to @code{alloca} is known to be at most | |
8198 | 1000 bytes. However, if @code{-Walloca-larger-than=500} were passed, | |
8199 | the compiler would emit a warning. | |
8200 | ||
8201 | Unbounded uses, on the other hand, are uses of @code{alloca} with no | |
8202 | controlling predicate constraining its integer argument. For example: | |
8203 | ||
8204 | @smallexample | |
8205 | void func () | |
8206 | @{ | |
8207 | void *p = alloca (n); | |
8208 | f (p); | |
8209 | @} | |
8210 | @end smallexample | |
8211 | ||
8212 | If @code{-Walloca-larger-than=500} were passed, the above would trigger | |
8213 | a warning, but this time because of the lack of bounds checking. | |
8214 | ||
8215 | Note, that even seemingly correct code involving signed integers could | |
8216 | cause a warning: | |
8217 | ||
8218 | @smallexample | |
8219 | void func (signed int n) | |
8220 | @{ | |
8221 | if (n < 500) | |
8222 | @{ | |
8223 | p = alloca (n); | |
8224 | f (p); | |
8225 | @} | |
8226 | @} | |
8227 | @end smallexample | |
8228 | ||
8229 | In the above example, @var{n} could be negative, causing a larger than | |
8230 | expected argument to be implicitly cast into the @code{alloca} call. | |
8231 | ||
8232 | This option also warns when @code{alloca} is used in a loop. | |
8233 | ||
8234 | @option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default | |
8235 | but is usually only effective when @option{-ftree-vrp} is active (default | |
8236 | for @option{-O2} and above). | |
8237 | ||
8238 | See also @option{-Wvla-larger-than=}@samp{byte-size}. | |
8239 | ||
d77de738 | 8240 | @opindex Wno-alloca-larger-than |
ddf6fe37 | 8241 | @item -Wno-alloca-larger-than |
d77de738 ML |
8242 | Disable @option{-Walloca-larger-than=} warnings. The option is |
8243 | equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger. | |
8244 | ||
d77de738 ML |
8245 | @opindex Warith-conversion |
8246 | @opindex Wno-arith-conversion | |
ddf6fe37 | 8247 | @item -Warith-conversion |
d77de738 ML |
8248 | Do warn about implicit conversions from arithmetic operations even |
8249 | when conversion of the operands to the same type cannot change their | |
8250 | values. This affects warnings from @option{-Wconversion}, | |
8251 | @option{-Wfloat-conversion}, and @option{-Wsign-conversion}. | |
8252 | ||
8253 | @smallexample | |
8254 | @group | |
8255 | void f (char c, int i) | |
8256 | @{ | |
8257 | c = c + i; // warns with @option{-Wconversion} | |
8258 | c = c + 1; // only warns with @option{-Warith-conversion} | |
8259 | @} | |
8260 | @end group | |
8261 | @end smallexample | |
8262 | ||
d77de738 ML |
8263 | @opindex Wno-array-bounds |
8264 | @opindex Warray-bounds | |
ddf6fe37 AA |
8265 | @item -Warray-bounds |
8266 | @itemx -Warray-bounds=@var{n} | |
d77de738 ML |
8267 | Warn about out of bounds subscripts or offsets into arrays. This warning |
8268 | is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp} | |
8269 | is active (the default for @option{-O2} and above) but a subset of instances | |
8270 | are issued even without optimization. | |
8271 | ||
710c9676 QZ |
8272 | By default, the trailing array of a structure will be treated as a flexible |
8273 | array member by @option{-Warray-bounds} or @option{-Warray-bounds=@var{n}} | |
8274 | if it is declared as either a flexible array member per C99 standard onwards | |
8275 | (@samp{[]}), a GCC zero-length array extension (@samp{[0]}), or an one-element | |
8276 | array (@samp{[1]}). As a result, out of bounds subscripts or offsets into | |
8277 | zero-length arrays or one-element arrays are not warned by default. | |
8278 | ||
8279 | You can add the option @option{-fstrict-flex-arrays} or | |
8280 | @option{-fstrict-flex-arrays=@var{level}} to control how this | |
8281 | option treat trailing array of a structure as a flexible array member: | |
8282 | ||
8283 | when @var{level}<=1, no change to the default behavior. | |
8284 | ||
8285 | when @var{level}=2, additional warnings will be issued for out of bounds | |
8286 | subscripts or offsets into one-element arrays; | |
8287 | ||
8288 | when @var{level}=3, in addition to @var{level}=2, additional warnings will be | |
8289 | issued for out of bounds subscripts or offsets into zero-length arrays. | |
8290 | ||
d77de738 ML |
8291 | @table @gcctabopt |
8292 | @item -Warray-bounds=1 | |
8293 | This is the default warning level of @option{-Warray-bounds} and is enabled | |
8294 | by @option{-Wall}; higher levels are not, and must be explicitly requested. | |
8295 | ||
8296 | @item -Warray-bounds=2 | |
710c9676 QZ |
8297 | This warning level also warns about the intermediate results of pointer |
8298 | arithmetic that may yield out of bounds values. This warning level may | |
8299 | give a larger number of false positives and is deactivated by default. | |
d77de738 ML |
8300 | @end table |
8301 | ||
d77de738 ML |
8302 | @opindex Warray-compare |
8303 | @opindex Wno-array-compare | |
ddf6fe37 | 8304 | @item -Warray-compare |
d77de738 ML |
8305 | Warn about equality and relational comparisons between two operands of array |
8306 | type. This comparison was deprecated in C++20. For example: | |
8307 | ||
8308 | @smallexample | |
8309 | int arr1[5]; | |
8310 | int arr2[5]; | |
8311 | bool same = arr1 == arr2; | |
8312 | @end smallexample | |
8313 | ||
8314 | @option{-Warray-compare} is enabled by @option{-Wall}. | |
8315 | ||
ddf6fe37 | 8316 | @opindex Wno-array-parameter |
d77de738 ML |
8317 | @item -Warray-parameter |
8318 | @itemx -Warray-parameter=@var{n} | |
d77de738 ML |
8319 | Warn about redeclarations of functions involving arguments of array or |
8320 | pointer types of inconsistent kinds or forms, and enable the detection | |
8321 | of out-of-bounds accesses to such parameters by warnings such as | |
8322 | @option{-Warray-bounds}. | |
8323 | ||
8324 | If the first function declaration uses the array form the bound specified | |
8325 | in the array is assumed to be the minimum number of elements expected to | |
8326 | be provided in calls to the function and the maximum number of elements | |
8327 | accessed by it. Failing to provide arguments of sufficient size or accessing | |
8328 | more than the maximum number of elements may be diagnosed by warnings such | |
8329 | as @option{-Warray-bounds}. At level 1 the warning diagnoses inconsistencies | |
8330 | involving array parameters declared using the @code{T[static N]} form. | |
8331 | ||
8332 | For example, the warning triggers for the following redeclarations because | |
8333 | the first one allows an array of any size to be passed to @code{f} while | |
8334 | the second one with the keyword @code{static} specifies that the array | |
8335 | argument must have at least four elements. | |
8336 | ||
8337 | @smallexample | |
8338 | void f (int[static 4]); | |
8339 | void f (int[]); // warning (inconsistent array form) | |
8340 | ||
8341 | void g (void) | |
8342 | @{ | |
8343 | int *p = (int *)malloc (4); | |
8344 | f (p); // warning (array too small) | |
8345 | @dots{} | |
8346 | @} | |
8347 | @end smallexample | |
8348 | ||
8349 | At level 2 the warning also triggers for redeclarations involving any other | |
8350 | inconsistency in array or pointer argument forms denoting array sizes. | |
8351 | Pointers and arrays of unspecified bound are considered equivalent and do | |
8352 | not trigger a warning. | |
8353 | ||
8354 | @smallexample | |
8355 | void g (int*); | |
8356 | void g (int[]); // no warning | |
8357 | void g (int[8]); // warning (inconsistent array bound) | |
8358 | @end smallexample | |
8359 | ||
8360 | @option{-Warray-parameter=2} is included in @option{-Wall}. The | |
8361 | @option{-Wvla-parameter} option triggers warnings for similar inconsistencies | |
8362 | involving Variable Length Array arguments. | |
8363 | ||
d77de738 ML |
8364 | @opindex Wattribute-alias |
8365 | @opindex Wno-attribute-alias | |
ddf6fe37 AA |
8366 | @item -Wattribute-alias=@var{n} |
8367 | @itemx -Wno-attribute-alias | |
d77de738 ML |
8368 | Warn about declarations using the @code{alias} and similar attributes whose |
8369 | target is incompatible with the type of the alias. | |
8370 | @xref{Function Attributes,,Declaring Attributes of Functions}. | |
8371 | ||
8372 | @table @gcctabopt | |
8373 | @item -Wattribute-alias=1 | |
8374 | The default warning level of the @option{-Wattribute-alias} option diagnoses | |
8375 | incompatibilities between the type of the alias declaration and that of its | |
8376 | target. Such incompatibilities are typically indicative of bugs. | |
8377 | ||
8378 | @item -Wattribute-alias=2 | |
8379 | ||
8380 | At this level @option{-Wattribute-alias} also diagnoses cases where | |
8381 | the attributes of the alias declaration are more restrictive than the | |
8382 | attributes applied to its target. These mismatches can potentially | |
8383 | result in incorrect code generation. In other cases they may be | |
8384 | benign and could be resolved simply by adding the missing attribute to | |
8385 | the target. For comparison, see the @option{-Wmissing-attributes} | |
8386 | option, which controls diagnostics when the alias declaration is less | |
8387 | restrictive than the target, rather than more restrictive. | |
8388 | ||
8389 | Attributes considered include @code{alloc_align}, @code{alloc_size}, | |
8390 | @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc}, | |
8391 | @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure}, | |
8392 | @code{returns_nonnull}, and @code{returns_twice}. | |
8393 | @end table | |
8394 | ||
8395 | @option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}. | |
8396 | This is the default. You can disable these warnings with either | |
8397 | @option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}. | |
8398 | ||
d77de738 ML |
8399 | @opindex Wbidi-chars= |
8400 | @opindex Wbidi-chars | |
8401 | @opindex Wno-bidi-chars | |
ddf6fe37 | 8402 | @item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]} |
d77de738 ML |
8403 | Warn about possibly misleading UTF-8 bidirectional control characters in |
8404 | comments, string literals, character constants, and identifiers. Such | |
8405 | characters can change left-to-right writing direction into right-to-left | |
8406 | (and vice versa), which can cause confusion between the logical order and | |
8407 | visual order. This may be dangerous; for instance, it may seem that a piece | |
8408 | of code is not commented out, whereas it in fact is. | |
8409 | ||
8410 | There are three levels of warning supported by GCC@. The default is | |
8411 | @option{-Wbidi-chars=unpaired}, which warns about improperly terminated | |
8412 | bidi contexts. @option{-Wbidi-chars=none} turns the warning off. | |
8413 | @option{-Wbidi-chars=any} warns about any use of bidirectional control | |
8414 | characters. | |
8415 | ||
8416 | By default, this warning does not warn about UCNs. It is, however, possible | |
8417 | to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or | |
8418 | @option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid, | |
8419 | and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous | |
8420 | @option{-Wbidi-chars=any} was specified. | |
8421 | ||
d77de738 ML |
8422 | @opindex Wno-bool-compare |
8423 | @opindex Wbool-compare | |
ddf6fe37 | 8424 | @item -Wbool-compare |
d77de738 ML |
8425 | Warn about boolean expression compared with an integer value different from |
8426 | @code{true}/@code{false}. For instance, the following comparison is | |
8427 | always false: | |
8428 | @smallexample | |
8429 | int n = 5; | |
8430 | @dots{} | |
8431 | if ((n > 1) == 2) @{ @dots{} @} | |
8432 | @end smallexample | |
8433 | This warning is enabled by @option{-Wall}. | |
8434 | ||
d77de738 ML |
8435 | @opindex Wno-bool-operation |
8436 | @opindex Wbool-operation | |
ddf6fe37 | 8437 | @item -Wbool-operation |
d77de738 ML |
8438 | Warn about suspicious operations on expressions of a boolean type. For |
8439 | instance, bitwise negation of a boolean is very likely a bug in the program. | |
8440 | For C, this warning also warns about incrementing or decrementing a boolean, | |
8441 | which rarely makes sense. (In C++, decrementing a boolean is always invalid. | |
8442 | Incrementing a boolean is invalid in C++17, and deprecated otherwise.) | |
8443 | ||
8444 | This warning is enabled by @option{-Wall}. | |
8445 | ||
d77de738 ML |
8446 | @opindex Wno-duplicated-branches |
8447 | @opindex Wduplicated-branches | |
ddf6fe37 | 8448 | @item -Wduplicated-branches |
d77de738 ML |
8449 | Warn when an if-else has identical branches. This warning detects cases like |
8450 | @smallexample | |
8451 | if (p != NULL) | |
8452 | return 0; | |
8453 | else | |
8454 | return 0; | |
8455 | @end smallexample | |
8456 | It doesn't warn when both branches contain just a null statement. This warning | |
8457 | also warn for conditional operators: | |
8458 | @smallexample | |
8459 | int i = x ? *p : *p; | |
8460 | @end smallexample | |
8461 | ||
d77de738 ML |
8462 | @opindex Wno-duplicated-cond |
8463 | @opindex Wduplicated-cond | |
ddf6fe37 | 8464 | @item -Wduplicated-cond |
d77de738 ML |
8465 | Warn about duplicated conditions in an if-else-if chain. For instance, |
8466 | warn for the following code: | |
8467 | @smallexample | |
8468 | if (p->q != NULL) @{ @dots{} @} | |
8469 | else if (p->q != NULL) @{ @dots{} @} | |
8470 | @end smallexample | |
8471 | ||
d77de738 ML |
8472 | @opindex Wno-frame-address |
8473 | @opindex Wframe-address | |
ddf6fe37 | 8474 | @item -Wframe-address |
d77de738 ML |
8475 | Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address} |
8476 | is called with an argument greater than 0. Such calls may return indeterminate | |
8477 | values or crash the program. The warning is included in @option{-Wall}. | |
8478 | ||
d77de738 ML |
8479 | @opindex Wno-discarded-qualifiers |
8480 | @opindex Wdiscarded-qualifiers | |
ddf6fe37 | 8481 | @item -Wno-discarded-qualifiers @r{(C and Objective-C only)} |
d77de738 ML |
8482 | Do not warn if type qualifiers on pointers are being discarded. |
8483 | Typically, the compiler warns if a @code{const char *} variable is | |
8484 | passed to a function that takes a @code{char *} parameter. This option | |
8485 | can be used to suppress such a warning. | |
8486 | ||
d77de738 ML |
8487 | @opindex Wno-discarded-array-qualifiers |
8488 | @opindex Wdiscarded-array-qualifiers | |
ddf6fe37 | 8489 | @item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)} |
d77de738 ML |
8490 | Do not warn if type qualifiers on arrays which are pointer targets |
8491 | are being discarded. Typically, the compiler warns if a | |
8492 | @code{const int (*)[]} variable is passed to a function that | |
8493 | takes a @code{int (*)[]} parameter. This option can be used to | |
8494 | suppress such a warning. | |
8495 | ||
d77de738 ML |
8496 | @opindex Wno-incompatible-pointer-types |
8497 | @opindex Wincompatible-pointer-types | |
ddf6fe37 | 8498 | @item -Wno-incompatible-pointer-types @r{(C and Objective-C only)} |
d77de738 ML |
8499 | Do not warn when there is a conversion between pointers that have incompatible |
8500 | types. This warning is for cases not covered by @option{-Wno-pointer-sign}, | |
8501 | which warns for pointer argument passing or assignment with different | |
8502 | signedness. | |
8503 | ||
5fccebdb JM |
8504 | This warning is upgraded to an error by @option{-pedantic-errors}. |
8505 | ||
d77de738 ML |
8506 | @opindex Wno-int-conversion |
8507 | @opindex Wint-conversion | |
ddf6fe37 | 8508 | @item -Wno-int-conversion @r{(C and Objective-C only)} |
d77de738 ML |
8509 | Do not warn about incompatible integer to pointer and pointer to integer |
8510 | conversions. This warning is about implicit conversions; for explicit | |
8511 | conversions the warnings @option{-Wno-int-to-pointer-cast} and | |
8512 | @option{-Wno-pointer-to-int-cast} may be used. | |
8513 | ||
5fccebdb JM |
8514 | This warning is upgraded to an error by @option{-pedantic-errors}. |
8515 | ||
d77de738 ML |
8516 | @opindex Wzero-length-bounds |
8517 | @opindex Wzero-length-bounds | |
ddf6fe37 | 8518 | @item -Wzero-length-bounds |
d77de738 ML |
8519 | Warn about accesses to elements of zero-length array members that might |
8520 | overlap other members of the same object. Declaring interior zero-length | |
8e9c65d3 | 8521 | arrays is discouraged because accesses to them are undefined. |
d77de738 ML |
8522 | @xref{Zero Length}. |
8523 | ||
8524 | For example, the first two stores in function @code{bad} are diagnosed | |
8525 | because the array elements overlap the subsequent members @code{b} and | |
8526 | @code{c}. The third store is diagnosed by @option{-Warray-bounds} | |
8527 | because it is beyond the bounds of the enclosing object. | |
8528 | ||
8529 | @smallexample | |
8530 | struct X @{ int a[0]; int b, c; @}; | |
8531 | struct X x; | |
8532 | ||
8533 | void bad (void) | |
8534 | @{ | |
8535 | x.a[0] = 0; // -Wzero-length-bounds | |
8536 | x.a[1] = 1; // -Wzero-length-bounds | |
8537 | x.a[2] = 2; // -Warray-bounds | |
8538 | @} | |
8539 | @end smallexample | |
8540 | ||
8541 | Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}. | |
8542 | ||
d77de738 ML |
8543 | @opindex Wno-div-by-zero |
8544 | @opindex Wdiv-by-zero | |
ddf6fe37 | 8545 | @item -Wno-div-by-zero |
d77de738 ML |
8546 | Do not warn about compile-time integer division by zero. Floating-point |
8547 | division by zero is not warned about, as it can be a legitimate way of | |
8548 | obtaining infinities and NaNs. | |
8549 | ||
d77de738 ML |
8550 | @opindex Wsystem-headers |
8551 | @opindex Wno-system-headers | |
8552 | @cindex warnings from system headers | |
8553 | @cindex system headers, warnings from | |
f33d7a88 | 8554 | @item -Wsystem-headers |
d77de738 ML |
8555 | Print warning messages for constructs found in system header files. |
8556 | Warnings from system headers are normally suppressed, on the assumption | |
8557 | that they usually do not indicate real problems and would only make the | |
8558 | compiler output harder to read. Using this command-line option tells | |
8559 | GCC to emit warnings from system headers as if they occurred in user | |
8560 | code. However, note that using @option{-Wall} in conjunction with this | |
8561 | option does @emph{not} warn about unknown pragmas in system | |
8562 | headers---for that, @option{-Wunknown-pragmas} must also be used. | |
8563 | ||
d77de738 ML |
8564 | @opindex Wtautological-compare |
8565 | @opindex Wno-tautological-compare | |
ddf6fe37 | 8566 | @item -Wtautological-compare |
d77de738 ML |
8567 | Warn if a self-comparison always evaluates to true or false. This |
8568 | warning detects various mistakes such as: | |
8569 | @smallexample | |
8570 | int i = 1; | |
8571 | @dots{} | |
8572 | if (i > i) @{ @dots{} @} | |
8573 | @end smallexample | |
8574 | ||
8575 | This warning also warns about bitwise comparisons that always evaluate | |
8576 | to true or false, for instance: | |
8577 | @smallexample | |
8578 | if ((a & 16) == 10) @{ @dots{} @} | |
8579 | @end smallexample | |
8580 | will always be false. | |
8581 | ||
8582 | This warning is enabled by @option{-Wall}. | |
8583 | ||
d77de738 ML |
8584 | @opindex Wtrampolines |
8585 | @opindex Wno-trampolines | |
ddf6fe37 | 8586 | @item -Wtrampolines |
d77de738 ML |
8587 | Warn about trampolines generated for pointers to nested functions. |
8588 | A trampoline is a small piece of data or code that is created at run | |
8589 | time on the stack when the address of a nested function is taken, and is | |
8590 | used to call the nested function indirectly. For some targets, it is | |
8591 | made up of data only and thus requires no special treatment. But, for | |
8592 | most targets, it is made up of code and thus requires the stack to be | |
8593 | made executable in order for the program to work properly. | |
8594 | ||
d77de738 ML |
8595 | @opindex Wfloat-equal |
8596 | @opindex Wno-float-equal | |
ddf6fe37 | 8597 | @item -Wfloat-equal |
d77de738 ML |
8598 | Warn if floating-point values are used in equality comparisons. |
8599 | ||
8600 | The idea behind this is that sometimes it is convenient (for the | |
8601 | programmer) to consider floating-point values as approximations to | |
8602 | infinitely precise real numbers. If you are doing this, then you need | |
8603 | to compute (by analyzing the code, or in some other way) the maximum or | |
8604 | likely maximum error that the computation introduces, and allow for it | |
8605 | when performing comparisons (and when producing output, but that's a | |
8606 | different problem). In particular, instead of testing for equality, you | |
8607 | should check to see whether the two values have ranges that overlap; and | |
8608 | this is done with the relational operators, so equality comparisons are | |
8609 | probably mistaken. | |
8610 | ||
d77de738 ML |
8611 | @opindex Wtraditional |
8612 | @opindex Wno-traditional | |
ddf6fe37 | 8613 | @item -Wtraditional @r{(C and Objective-C only)} |
d77de738 ML |
8614 | Warn about certain constructs that behave differently in traditional and |
8615 | ISO C@. Also warn about ISO C constructs that have no traditional C | |
8616 | equivalent, and/or problematic constructs that should be avoided. | |
8617 | ||
8618 | @itemize @bullet | |
8619 | @item | |
8620 | Macro parameters that appear within string literals in the macro body. | |
8621 | In traditional C macro replacement takes place within string literals, | |
8622 | but in ISO C it does not. | |
8623 | ||
8624 | @item | |
8625 | In traditional C, some preprocessor directives did not exist. | |
8626 | Traditional preprocessors only considered a line to be a directive | |
8627 | if the @samp{#} appeared in column 1 on the line. Therefore | |
8628 | @option{-Wtraditional} warns about directives that traditional C | |
8629 | understands but ignores because the @samp{#} does not appear as the | |
8630 | first character on the line. It also suggests you hide directives like | |
8631 | @code{#pragma} not understood by traditional C by indenting them. Some | |
8632 | traditional implementations do not recognize @code{#elif}, so this option | |
8633 | suggests avoiding it altogether. | |
8634 | ||
8635 | @item | |
8636 | A function-like macro that appears without arguments. | |
8637 | ||
8638 | @item | |
8639 | The unary plus operator. | |
8640 | ||
8641 | @item | |
8642 | The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point | |
8643 | constant suffixes. (Traditional C does support the @samp{L} suffix on integer | |
8644 | constants.) Note, these suffixes appear in macros defined in the system | |
8645 | headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}. | |
8646 | Use of these macros in user code might normally lead to spurious | |
8647 | warnings, however GCC's integrated preprocessor has enough context to | |
8648 | avoid warning in these cases. | |
8649 | ||
8650 | @item | |
8651 | A function declared external in one block and then used after the end of | |
8652 | the block. | |
8653 | ||
8654 | @item | |
8655 | A @code{switch} statement has an operand of type @code{long}. | |
8656 | ||
8657 | @item | |
8658 | A non-@code{static} function declaration follows a @code{static} one. | |
8659 | This construct is not accepted by some traditional C compilers. | |
8660 | ||
8661 | @item | |
8662 | The ISO type of an integer constant has a different width or | |
8663 | signedness from its traditional type. This warning is only issued if | |
8664 | the base of the constant is ten. I.e.@: hexadecimal or octal values, which | |
8665 | typically represent bit patterns, are not warned about. | |
8666 | ||
8667 | @item | |
8668 | Usage of ISO string concatenation is detected. | |
8669 | ||
8670 | @item | |
8671 | Initialization of automatic aggregates. | |
8672 | ||
8673 | @item | |
8674 | Identifier conflicts with labels. Traditional C lacks a separate | |
8675 | namespace for labels. | |
8676 | ||
8677 | @item | |
8678 | Initialization of unions. If the initializer is zero, the warning is | |
8679 | omitted. This is done under the assumption that the zero initializer in | |
8680 | user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing | |
8681 | initializer warnings and relies on default initialization to zero in the | |
8682 | traditional C case. | |
8683 | ||
8684 | @item | |
8685 | Conversions by prototypes between fixed/floating-point values and vice | |
8686 | versa. The absence of these prototypes when compiling with traditional | |
8687 | C causes serious problems. This is a subset of the possible | |
8688 | conversion warnings; for the full set use @option{-Wtraditional-conversion}. | |
8689 | ||
8690 | @item | |
8691 | Use of ISO C style function definitions. This warning intentionally is | |
8692 | @emph{not} issued for prototype declarations or variadic functions | |
8693 | because these ISO C features appear in your code when using | |
8694 | libiberty's traditional C compatibility macros, @code{PARAMS} and | |
8695 | @code{VPARAMS}. This warning is also bypassed for nested functions | |
8696 | because that feature is already a GCC extension and thus not relevant to | |
8697 | traditional C compatibility. | |
8698 | @end itemize | |
8699 | ||
d77de738 ML |
8700 | @opindex Wtraditional-conversion |
8701 | @opindex Wno-traditional-conversion | |
ddf6fe37 | 8702 | @item -Wtraditional-conversion @r{(C and Objective-C only)} |
d77de738 ML |
8703 | Warn if a prototype causes a type conversion that is different from what |
8704 | would happen to the same argument in the absence of a prototype. This | |
8705 | includes conversions of fixed point to floating and vice versa, and | |
8706 | conversions changing the width or signedness of a fixed-point argument | |
8707 | except when the same as the default promotion. | |
8708 | ||
d77de738 ML |
8709 | @opindex Wdeclaration-after-statement |
8710 | @opindex Wno-declaration-after-statement | |
ddf6fe37 | 8711 | @item -Wdeclaration-after-statement @r{(C and Objective-C only)} |
d77de738 ML |
8712 | Warn when a declaration is found after a statement in a block. This |
8713 | construct, known from C++, was introduced with ISO C99 and is by default | |
8714 | allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}. | |
8715 | ||
5fccebdb JM |
8716 | This warning is upgraded to an error by @option{-pedantic-errors}. |
8717 | ||
d77de738 ML |
8718 | @opindex Wshadow |
8719 | @opindex Wno-shadow | |
ddf6fe37 | 8720 | @item -Wshadow |
d77de738 ML |
8721 | Warn whenever a local variable or type declaration shadows another |
8722 | variable, parameter, type, class member (in C++), or instance variable | |
8723 | (in Objective-C) or whenever a built-in function is shadowed. Note | |
8724 | that in C++, the compiler warns if a local variable shadows an | |
8725 | explicit typedef, but not if it shadows a struct/class/enum. | |
8726 | If this warning is enabled, it includes also all instances of | |
8727 | local shadowing. This means that @option{-Wno-shadow=local} | |
8728 | and @option{-Wno-shadow=compatible-local} are ignored when | |
8729 | @option{-Wshadow} is used. | |
8730 | Same as @option{-Wshadow=global}. | |
8731 | ||
d77de738 ML |
8732 | @opindex Wno-shadow-ivar |
8733 | @opindex Wshadow-ivar | |
ddf6fe37 | 8734 | @item -Wno-shadow-ivar @r{(Objective-C only)} |
d77de738 ML |
8735 | Do not warn whenever a local variable shadows an instance variable in an |
8736 | Objective-C method. | |
8737 | ||
d77de738 | 8738 | @opindex Wshadow=global |
ddf6fe37 | 8739 | @item -Wshadow=global |
d77de738 ML |
8740 | Warn for any shadowing. |
8741 | Same as @option{-Wshadow}. | |
8742 | ||
d77de738 | 8743 | @opindex Wshadow=local |
ddf6fe37 | 8744 | @item -Wshadow=local |
d77de738 ML |
8745 | Warn when a local variable shadows another local variable or parameter. |
8746 | ||
d77de738 | 8747 | @opindex Wshadow=compatible-local |
ddf6fe37 | 8748 | @item -Wshadow=compatible-local |
d77de738 ML |
8749 | Warn when a local variable shadows another local variable or parameter |
8750 | whose type is compatible with that of the shadowing variable. In C++, | |
8751 | type compatibility here means the type of the shadowing variable can be | |
8752 | converted to that of the shadowed variable. The creation of this flag | |
8753 | (in addition to @option{-Wshadow=local}) is based on the idea that when | |
8754 | a local variable shadows another one of incompatible type, it is most | |
8755 | likely intentional, not a bug or typo, as shown in the following example: | |
8756 | ||
8757 | @smallexample | |
8758 | @group | |
8759 | for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i) | |
8760 | @{ | |
8761 | for (int i = 0; i < N; ++i) | |
8762 | @{ | |
8763 | ... | |
8764 | @} | |
8765 | ... | |
8766 | @} | |
8767 | @end group | |
8768 | @end smallexample | |
8769 | ||
8770 | Since the two variable @code{i} in the example above have incompatible types, | |
8771 | enabling only @option{-Wshadow=compatible-local} does not emit a warning. | |
8772 | Because their types are incompatible, if a programmer accidentally uses one | |
8773 | in place of the other, type checking is expected to catch that and emit an | |
8774 | error or warning. Use of this flag instead of @option{-Wshadow=local} can | |
8775 | possibly reduce the number of warnings triggered by intentional shadowing. | |
8776 | Note that this also means that shadowing @code{const char *i} by | |
8777 | @code{char *i} does not emit a warning. | |
8778 | ||
8779 | This warning is also enabled by @option{-Wshadow=local}. | |
8780 | ||
d77de738 ML |
8781 | @opindex Wlarger-than= |
8782 | @opindex Wlarger-than-@var{byte-size} | |
ddf6fe37 | 8783 | @item -Wlarger-than=@var{byte-size} |
d77de738 ML |
8784 | Warn whenever an object is defined whose size exceeds @var{byte-size}. |
8785 | @option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default. | |
8786 | Warnings controlled by the option can be disabled either by specifying | |
8787 | @var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}. | |
8788 | ||
8789 | Also warn for calls to bounded functions such as @code{memchr} or | |
8790 | @code{strnlen} that specify a bound greater than the largest possible | |
8791 | object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings | |
8792 | can only be disabled by @option{-Wno-larger-than}. | |
8793 | ||
d77de738 | 8794 | @opindex Wno-larger-than |
ddf6fe37 | 8795 | @item -Wno-larger-than |
d77de738 ML |
8796 | Disable @option{-Wlarger-than=} warnings. The option is equivalent |
8797 | to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger. | |
8798 | ||
d77de738 ML |
8799 | @opindex Wframe-larger-than= |
8800 | @opindex Wno-frame-larger-than | |
ddf6fe37 | 8801 | @item -Wframe-larger-than=@var{byte-size} |
d77de738 ML |
8802 | Warn if the size of a function frame exceeds @var{byte-size}. |
8803 | The computation done to determine the stack frame size is approximate | |
8804 | and not conservative. | |
8805 | The actual requirements may be somewhat greater than @var{byte-size} | |
8806 | even if you do not get a warning. In addition, any space allocated | |
8807 | via @code{alloca}, variable-length arrays, or related constructs | |
8808 | is not included by the compiler when determining | |
8809 | whether or not to issue a warning. | |
8810 | @option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default. | |
8811 | Warnings controlled by the option can be disabled either by specifying | |
8812 | @var{byte-size} of @samp{SIZE_MAX} or more or by | |
8813 | @option{-Wno-frame-larger-than}. | |
8814 | ||
d77de738 | 8815 | @opindex Wno-frame-larger-than |
ddf6fe37 | 8816 | @item -Wno-frame-larger-than |
d77de738 ML |
8817 | Disable @option{-Wframe-larger-than=} warnings. The option is equivalent |
8818 | to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger. | |
8819 | ||
d77de738 ML |
8820 | @opindex Wfree-nonheap-object |
8821 | @opindex Wno-free-nonheap-object | |
ddf6fe37 | 8822 | @item -Wfree-nonheap-object |
d77de738 ML |
8823 | Warn when attempting to deallocate an object that was either not allocated |
8824 | on the heap, or by using a pointer that was not returned from a prior call | |
8825 | to the corresponding allocation function. For example, because the call | |
8826 | to @code{stpcpy} returns a pointer to the terminating nul character and | |
8827 | not to the beginning of the object, the call to @code{free} below is | |
8828 | diagnosed. | |
8829 | ||
8830 | @smallexample | |
8831 | void f (char *p) | |
8832 | @{ | |
8833 | p = stpcpy (p, "abc"); | |
8834 | // ... | |
8835 | free (p); // warning | |
8836 | @} | |
8837 | @end smallexample | |
8838 | ||
8839 | @option{-Wfree-nonheap-object} is included in @option{-Wall}. | |
8840 | ||
d77de738 ML |
8841 | @opindex Wstack-usage |
8842 | @opindex Wno-stack-usage | |
ddf6fe37 | 8843 | @item -Wstack-usage=@var{byte-size} |
d77de738 ML |
8844 | Warn if the stack usage of a function might exceed @var{byte-size}. |
8845 | The computation done to determine the stack usage is conservative. | |
8846 | Any space allocated via @code{alloca}, variable-length arrays, or related | |
8847 | constructs is included by the compiler when determining whether or not to | |
8848 | issue a warning. | |
8849 | ||
8850 | The message is in keeping with the output of @option{-fstack-usage}. | |
8851 | ||
8852 | @itemize | |
8853 | @item | |
8854 | If the stack usage is fully static but exceeds the specified amount, it's: | |
8855 | ||
8856 | @smallexample | |
8857 | warning: stack usage is 1120 bytes | |
8858 | @end smallexample | |
8859 | @item | |
8860 | If the stack usage is (partly) dynamic but bounded, it's: | |
8861 | ||
8862 | @smallexample | |
8863 | warning: stack usage might be 1648 bytes | |
8864 | @end smallexample | |
8865 | @item | |
8866 | If the stack usage is (partly) dynamic and not bounded, it's: | |
8867 | ||
8868 | @smallexample | |
8869 | warning: stack usage might be unbounded | |
8870 | @end smallexample | |
8871 | @end itemize | |
8872 | ||
8873 | @option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default. | |
8874 | Warnings controlled by the option can be disabled either by specifying | |
8875 | @var{byte-size} of @samp{SIZE_MAX} or more or by | |
8876 | @option{-Wno-stack-usage}. | |
8877 | ||
d77de738 | 8878 | @opindex Wno-stack-usage |
ddf6fe37 | 8879 | @item -Wno-stack-usage |
d77de738 ML |
8880 | Disable @option{-Wstack-usage=} warnings. The option is equivalent |
8881 | to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger. | |
8882 | ||
d77de738 ML |
8883 | @opindex Wunsafe-loop-optimizations |
8884 | @opindex Wno-unsafe-loop-optimizations | |
ddf6fe37 | 8885 | @item -Wunsafe-loop-optimizations |
d77de738 ML |
8886 | Warn if the loop cannot be optimized because the compiler cannot |
8887 | assume anything on the bounds of the loop indices. With | |
8888 | @option{-funsafe-loop-optimizations} warn if the compiler makes | |
8889 | such assumptions. | |
8890 | ||
d77de738 ML |
8891 | @opindex Wno-pedantic-ms-format |
8892 | @opindex Wpedantic-ms-format | |
ddf6fe37 | 8893 | @item -Wno-pedantic-ms-format @r{(MinGW targets only)} |
d77de738 ML |
8894 | When used in combination with @option{-Wformat} |
8895 | and @option{-pedantic} without GNU extensions, this option | |
8896 | disables the warnings about non-ISO @code{printf} / @code{scanf} format | |
8897 | width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets, | |
8898 | which depend on the MS runtime. | |
8899 | ||
d77de738 ML |
8900 | @opindex Wpointer-arith |
8901 | @opindex Wno-pointer-arith | |
ddf6fe37 | 8902 | @item -Wpointer-arith |
d77de738 ML |
8903 | Warn about anything that depends on the ``size of'' a function type or |
8904 | of @code{void}. GNU C assigns these types a size of 1, for | |
8905 | convenience in calculations with @code{void *} pointers and pointers | |
8906 | to functions. In C++, warn also when an arithmetic operation involves | |
8907 | @code{NULL}. This warning is also enabled by @option{-Wpedantic}. | |
8908 | ||
5fccebdb JM |
8909 | This warning is upgraded to an error by @option{-pedantic-errors}. |
8910 | ||
d77de738 ML |
8911 | @opindex Wpointer-compare |
8912 | @opindex Wno-pointer-compare | |
ddf6fe37 | 8913 | @item -Wno-pointer-compare |
d77de738 ML |
8914 | Do not warn if a pointer is compared with a zero character constant. |
8915 | This usually | |
8916 | means that the pointer was meant to be dereferenced. For example: | |
8917 | ||
8918 | @smallexample | |
8919 | const char *p = foo (); | |
8920 | if (p == '\0') | |
8921 | return 42; | |
8922 | @end smallexample | |
8923 | ||
8924 | Note that the code above is invalid in C++11. | |
8925 | ||
8926 | This warning is enabled by default. | |
8927 | ||
d77de738 ML |
8928 | @opindex Wtsan |
8929 | @opindex Wno-tsan | |
ddf6fe37 | 8930 | @item -Wtsan |
d77de738 ML |
8931 | Warn about unsupported features in ThreadSanitizer. |
8932 | ||
8933 | ThreadSanitizer does not support @code{std::atomic_thread_fence} and | |
8934 | can report false positives. | |
8935 | ||
8936 | This warning is enabled by default. | |
8937 | ||
d77de738 ML |
8938 | @opindex Wtype-limits |
8939 | @opindex Wno-type-limits | |
ddf6fe37 | 8940 | @item -Wtype-limits |
d77de738 ML |
8941 | Warn if a comparison is always true or always false due to the limited |
8942 | range of the data type, but do not warn for constant expressions. For | |
8943 | example, warn if an unsigned variable is compared against zero with | |
8944 | @code{<} or @code{>=}. This warning is also enabled by | |
8945 | @option{-Wextra}. | |
8946 | ||
d77de738 ML |
8947 | @opindex Wabsolute-value |
8948 | @opindex Wno-absolute-value | |
ddf6fe37 | 8949 | @item -Wabsolute-value @r{(C and Objective-C only)} |
d77de738 ML |
8950 | Warn for calls to standard functions that compute the absolute value |
8951 | of an argument when a more appropriate standard function is available. | |
8952 | For example, calling @code{abs(3.14)} triggers the warning because the | |
8953 | appropriate function to call to compute the absolute value of a double | |
8954 | argument is @code{fabs}. The option also triggers warnings when the | |
8955 | argument in a call to such a function has an unsigned type. This | |
8956 | warning can be suppressed with an explicit type cast and it is also | |
8957 | enabled by @option{-Wextra}. | |
8958 | ||
8959 | @include cppwarnopts.texi | |
8960 | ||
d77de738 ML |
8961 | @opindex Wbad-function-cast |
8962 | @opindex Wno-bad-function-cast | |
ddf6fe37 | 8963 | @item -Wbad-function-cast @r{(C and Objective-C only)} |
d77de738 ML |
8964 | Warn when a function call is cast to a non-matching type. |
8965 | For example, warn if a call to a function returning an integer type | |
8966 | is cast to a pointer type. | |
8967 | ||
d77de738 ML |
8968 | @opindex Wc90-c99-compat |
8969 | @opindex Wno-c90-c99-compat | |
ddf6fe37 | 8970 | @item -Wc90-c99-compat @r{(C and Objective-C only)} |
d77de738 ML |
8971 | Warn about features not present in ISO C90, but present in ISO C99. |
8972 | For instance, warn about use of variable length arrays, @code{long long} | |
8973 | type, @code{bool} type, compound literals, designated initializers, and so | |
8974 | on. This option is independent of the standards mode. Warnings are disabled | |
8975 | in the expression that follows @code{__extension__}. | |
8976 | ||
d77de738 ML |
8977 | @opindex Wc99-c11-compat |
8978 | @opindex Wno-c99-c11-compat | |
ddf6fe37 | 8979 | @item -Wc99-c11-compat @r{(C and Objective-C only)} |
d77de738 ML |
8980 | Warn about features not present in ISO C99, but present in ISO C11. |
8981 | For instance, warn about use of anonymous structures and unions, | |
8982 | @code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier, | |
8983 | @code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword, | |
8984 | and so on. This option is independent of the standards mode. Warnings are | |
8985 | disabled in the expression that follows @code{__extension__}. | |
8986 | ||
d77de738 ML |
8987 | @opindex Wc11-c2x-compat |
8988 | @opindex Wno-c11-c2x-compat | |
ddf6fe37 | 8989 | @item -Wc11-c2x-compat @r{(C and Objective-C only)} |
d77de738 ML |
8990 | Warn about features not present in ISO C11, but present in ISO C2X. |
8991 | For instance, warn about omitting the string in @code{_Static_assert}, | |
8992 | use of @samp{[[]]} syntax for attributes, use of decimal | |
8993 | floating-point types, and so on. This option is independent of the | |
8994 | standards mode. Warnings are disabled in the expression that follows | |
8995 | @code{__extension__}. | |
8996 | ||
5fccebdb JM |
8997 | When not compiling in C2X mode, these warnings are upgraded to errors |
8998 | by @option{-pedantic-errors}. | |
8999 | ||
d77de738 ML |
9000 | @opindex Wc++-compat |
9001 | @opindex Wno-c++-compat | |
ddf6fe37 | 9002 | @item -Wc++-compat @r{(C and Objective-C only)} |
d77de738 ML |
9003 | Warn about ISO C constructs that are outside of the common subset of |
9004 | ISO C and ISO C++, e.g.@: request for implicit conversion from | |
9005 | @code{void *} to a pointer to non-@code{void} type. | |
9006 | ||
d77de738 ML |
9007 | @opindex Wc++11-compat |
9008 | @opindex Wno-c++11-compat | |
ddf6fe37 | 9009 | @item -Wc++11-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9010 | Warn about C++ constructs whose meaning differs between ISO C++ 1998 |
9011 | and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords | |
9012 | in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is | |
9013 | enabled by @option{-Wall}. | |
9014 | ||
d77de738 ML |
9015 | @opindex Wc++14-compat |
9016 | @opindex Wno-c++14-compat | |
ddf6fe37 | 9017 | @item -Wc++14-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9018 | Warn about C++ constructs whose meaning differs between ISO C++ 2011 |
9019 | and ISO C++ 2014. This warning is enabled by @option{-Wall}. | |
9020 | ||
d77de738 ML |
9021 | @opindex Wc++17-compat |
9022 | @opindex Wno-c++17-compat | |
ddf6fe37 | 9023 | @item -Wc++17-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9024 | Warn about C++ constructs whose meaning differs between ISO C++ 2014 |
9025 | and ISO C++ 2017. This warning is enabled by @option{-Wall}. | |
9026 | ||
d77de738 ML |
9027 | @opindex Wc++20-compat |
9028 | @opindex Wno-c++20-compat | |
ddf6fe37 | 9029 | @item -Wc++20-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9030 | Warn about C++ constructs whose meaning differs between ISO C++ 2017 |
9031 | and ISO C++ 2020. This warning is enabled by @option{-Wall}. | |
9032 | ||
d77de738 ML |
9033 | @opindex Wc++11-extensions |
9034 | @opindex Wno-c++11-extensions | |
ddf6fe37 | 9035 | @item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9036 | Do not warn about C++11 constructs in code being compiled using |
9037 | an older C++ standard. Even without this option, some C++11 constructs | |
9038 | will only be diagnosed if @option{-Wpedantic} is used. | |
9039 | ||
d77de738 ML |
9040 | @opindex Wc++14-extensions |
9041 | @opindex Wno-c++14-extensions | |
ddf6fe37 | 9042 | @item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9043 | Do not warn about C++14 constructs in code being compiled using |
9044 | an older C++ standard. Even without this option, some C++14 constructs | |
9045 | will only be diagnosed if @option{-Wpedantic} is used. | |
9046 | ||
d77de738 ML |
9047 | @opindex Wc++17-extensions |
9048 | @opindex Wno-c++17-extensions | |
ddf6fe37 | 9049 | @item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9050 | Do not warn about C++17 constructs in code being compiled using |
9051 | an older C++ standard. Even without this option, some C++17 constructs | |
9052 | will only be diagnosed if @option{-Wpedantic} is used. | |
9053 | ||
d77de738 ML |
9054 | @opindex Wc++20-extensions |
9055 | @opindex Wno-c++20-extensions | |
ddf6fe37 | 9056 | @item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9057 | Do not warn about C++20 constructs in code being compiled using |
9058 | an older C++ standard. Even without this option, some C++20 constructs | |
9059 | will only be diagnosed if @option{-Wpedantic} is used. | |
9060 | ||
d77de738 ML |
9061 | @opindex Wc++23-extensions |
9062 | @opindex Wno-c++23-extensions | |
ddf6fe37 | 9063 | @item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9064 | Do not warn about C++23 constructs in code being compiled using |
9065 | an older C++ standard. Even without this option, some C++23 constructs | |
9066 | will only be diagnosed if @option{-Wpedantic} is used. | |
9067 | ||
d77de738 ML |
9068 | @opindex Wcast-qual |
9069 | @opindex Wno-cast-qual | |
ddf6fe37 | 9070 | @item -Wcast-qual |
d77de738 ML |
9071 | Warn whenever a pointer is cast so as to remove a type qualifier from |
9072 | the target type. For example, warn if a @code{const char *} is cast | |
9073 | to an ordinary @code{char *}. | |
9074 | ||
9075 | Also warn when making a cast that introduces a type qualifier in an | |
9076 | unsafe way. For example, casting @code{char **} to @code{const char **} | |
9077 | is unsafe, as in this example: | |
9078 | ||
9079 | @smallexample | |
9080 | /* p is char ** value. */ | |
9081 | const char **q = (const char **) p; | |
9082 | /* Assignment of readonly string to const char * is OK. */ | |
9083 | *q = "string"; | |
9084 | /* Now char** pointer points to read-only memory. */ | |
9085 | **p = 'b'; | |
9086 | @end smallexample | |
9087 | ||
d77de738 ML |
9088 | @opindex Wcast-align |
9089 | @opindex Wno-cast-align | |
ddf6fe37 | 9090 | @item -Wcast-align |
d77de738 ML |
9091 | Warn whenever a pointer is cast such that the required alignment of the |
9092 | target is increased. For example, warn if a @code{char *} is cast to | |
9093 | an @code{int *} on machines where integers can only be accessed at | |
9094 | two- or four-byte boundaries. | |
9095 | ||
d77de738 | 9096 | @opindex Wcast-align=strict |
ddf6fe37 | 9097 | @item -Wcast-align=strict |
d77de738 ML |
9098 | Warn whenever a pointer is cast such that the required alignment of the |
9099 | target is increased. For example, warn if a @code{char *} is cast to | |
9100 | an @code{int *} regardless of the target machine. | |
9101 | ||
d77de738 ML |
9102 | @opindex Wcast-function-type |
9103 | @opindex Wno-cast-function-type | |
ddf6fe37 | 9104 | @item -Wcast-function-type |
d77de738 ML |
9105 | Warn when a function pointer is cast to an incompatible function pointer. |
9106 | In a cast involving function types with a variable argument list only | |
9107 | the types of initial arguments that are provided are considered. | |
9108 | Any parameter of pointer-type matches any other pointer-type. Any benign | |
9109 | differences in integral types are ignored, like @code{int} vs.@: @code{long} | |
9110 | on ILP32 targets. Likewise type qualifiers are ignored. The function | |
9111 | type @code{void (*) (void)} is special and matches everything, which can | |
9112 | be used to suppress this warning. | |
9113 | In a cast involving pointer to member types this warning warns whenever | |
9114 | the type cast is changing the pointer to member type. | |
9115 | This warning is enabled by @option{-Wextra}. | |
9116 | ||
d77de738 ML |
9117 | @opindex Wwrite-strings |
9118 | @opindex Wno-write-strings | |
ddf6fe37 | 9119 | @item -Wwrite-strings |
d77de738 ML |
9120 | When compiling C, give string constants the type @code{const |
9121 | char[@var{length}]} so that copying the address of one into a | |
9122 | non-@code{const} @code{char *} pointer produces a warning. These | |
9123 | warnings help you find at compile time code that can try to write | |
9124 | into a string constant, but only if you have been very careful about | |
9125 | using @code{const} in declarations and prototypes. Otherwise, it is | |
9126 | just a nuisance. This is why we did not make @option{-Wall} request | |
9127 | these warnings. | |
9128 | ||
9129 | When compiling C++, warn about the deprecated conversion from string | |
9130 | literals to @code{char *}. This warning is enabled by default for C++ | |
9131 | programs. | |
9132 | ||
5fccebdb JM |
9133 | This warning is upgraded to an error by @option{-pedantic-errors} in |
9134 | C++11 mode or later. | |
9135 | ||
d77de738 ML |
9136 | @opindex Wclobbered |
9137 | @opindex Wno-clobbered | |
f33d7a88 | 9138 | @item -Wclobbered |
d77de738 ML |
9139 | Warn for variables that might be changed by @code{longjmp} or |
9140 | @code{vfork}. This warning is also enabled by @option{-Wextra}. | |
9141 | ||
320dc51c TS |
9142 | @opindex Wcomplain-wrong-lang |
9143 | @opindex Wno-complain-wrong-lang | |
f33d7a88 | 9144 | @item -Wno-complain-wrong-lang |
320dc51c TS |
9145 | By default, language front ends complain when a command-line option is |
9146 | valid, but not applicable to that front end. | |
9147 | This may be disabled with @option{-Wno-complain-wrong-lang}, | |
9148 | which is mostly useful when invoking a single compiler driver for | |
9149 | multiple source files written in different languages, for example: | |
9150 | ||
9151 | @smallexample | |
9152 | $ g++ -fno-rtti a.cc b.f90 | |
9153 | @end smallexample | |
9154 | ||
9155 | The driver @file{g++} invokes the C++ front end to compile @file{a.cc} | |
9156 | and the Fortran front end to compile @file{b.f90}. | |
9157 | The latter front end diagnoses | |
9158 | @samp{f951: Warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for Fortran}, | |
9159 | which may be disabled with @option{-Wno-complain-wrong-lang}. | |
9160 | ||
e1f45bea JM |
9161 | @opindex Wcompare-distinct-pointer-types |
9162 | @item -Wcompare-distinct-pointer-types @r{(C and Objective-C only)} | |
9163 | Warn if pointers of distinct types are compared without a cast. This | |
9164 | warning is enabled by default. | |
9165 | ||
d77de738 ML |
9166 | @opindex Wconversion |
9167 | @opindex Wno-conversion | |
f33d7a88 | 9168 | @item -Wconversion |
d77de738 ML |
9169 | Warn for implicit conversions that may alter a value. This includes |
9170 | conversions between real and integer, like @code{abs (x)} when | |
9171 | @code{x} is @code{double}; conversions between signed and unsigned, | |
9172 | like @code{unsigned ui = -1}; and conversions to smaller types, like | |
9173 | @code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs | |
9174 | ((int) x)} and @code{ui = (unsigned) -1}, or if the value is not | |
9175 | changed by the conversion like in @code{abs (2.0)}. Warnings about | |
9176 | conversions between signed and unsigned integers can be disabled by | |
9177 | using @option{-Wno-sign-conversion}. | |
9178 | ||
9179 | For C++, also warn for confusing overload resolution for user-defined | |
9180 | conversions; and conversions that never use a type conversion | |
9181 | operator: conversions to @code{void}, the same type, a base class or a | |
9182 | reference to them. Warnings about conversions between signed and | |
9183 | unsigned integers are disabled by default in C++ unless | |
9184 | @option{-Wsign-conversion} is explicitly enabled. | |
9185 | ||
9186 | Warnings about conversion from arithmetic on a small type back to that | |
9187 | type are only given with @option{-Warith-conversion}. | |
9188 | ||
d77de738 ML |
9189 | @opindex Wdangling-else |
9190 | @opindex Wno-dangling-else | |
ddf6fe37 | 9191 | @item -Wdangling-else |
d77de738 ML |
9192 | Warn about constructions where there may be confusion to which |
9193 | @code{if} statement an @code{else} branch belongs. Here is an example of | |
9194 | such a case: | |
9195 | ||
9196 | @smallexample | |
9197 | @group | |
9198 | @{ | |
9199 | if (a) | |
9200 | if (b) | |
9201 | foo (); | |
9202 | else | |
9203 | bar (); | |
9204 | @} | |
9205 | @end group | |
9206 | @end smallexample | |
9207 | ||
9208 | In C/C++, every @code{else} branch belongs to the innermost possible | |
9209 | @code{if} statement, which in this example is @code{if (b)}. This is | |
9210 | often not what the programmer expected, as illustrated in the above | |
9211 | example by indentation the programmer chose. When there is the | |
9212 | potential for this confusion, GCC issues a warning when this flag | |
9213 | is specified. To eliminate the warning, add explicit braces around | |
9214 | the innermost @code{if} statement so there is no way the @code{else} | |
9215 | can belong to the enclosing @code{if}. The resulting code | |
9216 | looks like this: | |
9217 | ||
9218 | @smallexample | |
9219 | @group | |
9220 | @{ | |
9221 | if (a) | |
9222 | @{ | |
9223 | if (b) | |
9224 | foo (); | |
9225 | else | |
9226 | bar (); | |
9227 | @} | |
9228 | @} | |
9229 | @end group | |
9230 | @end smallexample | |
9231 | ||
9232 | This warning is enabled by @option{-Wparentheses}. | |
9233 | ||
d77de738 ML |
9234 | @opindex Wdangling-pointer |
9235 | @opindex Wno-dangling-pointer | |
ddf6fe37 AA |
9236 | @item -Wdangling-pointer |
9237 | @itemx -Wdangling-pointer=@var{n} | |
d77de738 ML |
9238 | Warn about uses of pointers (or C++ references) to objects with automatic |
9239 | storage duration after their lifetime has ended. This includes local | |
9240 | variables declared in nested blocks, compound literals and other unnamed | |
9241 | temporary objects. In addition, warn about storing the address of such | |
9242 | objects in escaped pointers. The warning is enabled at all optimization | |
9243 | levels but may yield different results with optimization than without. | |
9244 | ||
9245 | @table @gcctabopt | |
9246 | @item -Wdangling-pointer=1 | |
9247 | At level 1 the warning diagnoses only unconditional uses of dangling pointers. | |
9248 | For example | |
9249 | @smallexample | |
9250 | int f (int c1, int c2, x) | |
9251 | @{ | |
9252 | char *p = strchr ((char[])@{ c1, c2 @}, c3); | |
4ace81b6 SL |
9253 | // warning: dangling pointer to a compound literal |
9254 | return p ? *p : 'x'; | |
d77de738 ML |
9255 | @} |
9256 | @end smallexample | |
9257 | In the following function the store of the address of the local variable | |
9258 | @code{x} in the escaped pointer @code{*p} also triggers the warning. | |
9259 | @smallexample | |
9260 | void g (int **p) | |
9261 | @{ | |
9262 | int x = 7; | |
4ace81b6 SL |
9263 | // warning: storing the address of a local variable in *p |
9264 | *p = &x; | |
d77de738 ML |
9265 | @} |
9266 | @end smallexample | |
9267 | ||
9268 | @item -Wdangling-pointer=2 | |
9269 | At level 2, in addition to unconditional uses the warning also diagnoses | |
9270 | conditional uses of dangling pointers. | |
9271 | ||
9272 | For example, because the array @var{a} in the following function is out of | |
9273 | scope when the pointer @var{s} that was set to point is used, the warning | |
9274 | triggers at this level. | |
9275 | ||
9276 | @smallexample | |
9277 | void f (char *s) | |
9278 | @{ | |
9279 | if (!s) | |
9280 | @{ | |
9281 | char a[12] = "tmpname"; | |
9282 | s = a; | |
9283 | @} | |
4ace81b6 SL |
9284 | // warning: dangling pointer to a may be used |
9285 | strcat (s, ".tmp"); | |
d77de738 ML |
9286 | ... |
9287 | @} | |
9288 | @end smallexample | |
9289 | @end table | |
9290 | ||
9291 | @option{-Wdangling-pointer=2} is included in @option{-Wall}. | |
9292 | ||
d77de738 ML |
9293 | @opindex Wdate-time |
9294 | @opindex Wno-date-time | |
ddf6fe37 | 9295 | @item -Wdate-time |
d77de738 ML |
9296 | Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__} |
9297 | are encountered as they might prevent bit-wise-identical reproducible | |
9298 | compilations. | |
9299 | ||
d77de738 ML |
9300 | @opindex Wempty-body |
9301 | @opindex Wno-empty-body | |
ddf6fe37 | 9302 | @item -Wempty-body |
d77de738 ML |
9303 | Warn if an empty body occurs in an @code{if}, @code{else} or @code{do |
9304 | while} statement. This warning is also enabled by @option{-Wextra}. | |
9305 | ||
d77de738 ML |
9306 | @opindex Wendif-labels |
9307 | @opindex Wno-endif-labels | |
ddf6fe37 | 9308 | @item -Wno-endif-labels |
d77de738 ML |
9309 | Do not warn about stray tokens after @code{#else} and @code{#endif}. |
9310 | ||
d77de738 ML |
9311 | @opindex Wenum-compare |
9312 | @opindex Wno-enum-compare | |
ddf6fe37 | 9313 | @item -Wenum-compare |
d77de738 ML |
9314 | Warn about a comparison between values of different enumerated types. |
9315 | In C++ enumerated type mismatches in conditional expressions are also | |
9316 | diagnosed and the warning is enabled by default. In C this warning is | |
9317 | enabled by @option{-Wall}. | |
9318 | ||
d77de738 ML |
9319 | @opindex Wenum-conversion |
9320 | @opindex Wno-enum-conversion | |
ddf6fe37 | 9321 | @item -Wenum-conversion |
d77de738 ML |
9322 | Warn when a value of enumerated type is implicitly converted to a |
9323 | different enumerated type. This warning is enabled by @option{-Wextra} | |
9324 | in C@. | |
9325 | ||
d77de738 ML |
9326 | @opindex Wenum-int-mismatch |
9327 | @opindex Wno-enum-int-mismatch | |
ddf6fe37 | 9328 | @item -Wenum-int-mismatch @r{(C and Objective-C only)} |
d77de738 ML |
9329 | Warn about mismatches between an enumerated type and an integer type in |
9330 | declarations. For example: | |
9331 | ||
9332 | @smallexample | |
9333 | enum E @{ l = -1, z = 0, g = 1 @}; | |
9334 | int foo(void); | |
9335 | enum E foo(void); | |
9336 | @end smallexample | |
9337 | ||
9338 | In C, an enumerated type is compatible with @code{char}, a signed | |
9339 | integer type, or an unsigned integer type. However, since the choice | |
9340 | of the underlying type of an enumerated type is implementation-defined, | |
9341 | such mismatches may cause portability issues. In C++, such mismatches | |
9342 | are an error. In C, this warning is enabled by @option{-Wall} and | |
9343 | @option{-Wc++-compat}. | |
9344 | ||
d77de738 ML |
9345 | @opindex Wjump-misses-init |
9346 | @opindex Wno-jump-misses-init | |
ddf6fe37 | 9347 | @item -Wjump-misses-init @r{(C, Objective-C only)} |
d77de738 ML |
9348 | Warn if a @code{goto} statement or a @code{switch} statement jumps |
9349 | forward across the initialization of a variable, or jumps backward to a | |
9350 | label after the variable has been initialized. This only warns about | |
9351 | variables that are initialized when they are declared. This warning is | |
9352 | only supported for C and Objective-C; in C++ this sort of branch is an | |
9353 | error in any case. | |
9354 | ||
9355 | @option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It | |
9356 | can be disabled with the @option{-Wno-jump-misses-init} option. | |
9357 | ||
d77de738 ML |
9358 | @opindex Wsign-compare |
9359 | @opindex Wno-sign-compare | |
9360 | @cindex warning for comparison of signed and unsigned values | |
9361 | @cindex comparison of signed and unsigned values, warning | |
9362 | @cindex signed and unsigned values, comparison warning | |
f33d7a88 | 9363 | @item -Wsign-compare |
d77de738 ML |
9364 | Warn when a comparison between signed and unsigned values could produce |
9365 | an incorrect result when the signed value is converted to unsigned. | |
9366 | In C++, this warning is also enabled by @option{-Wall}. In C, it is | |
9367 | also enabled by @option{-Wextra}. | |
9368 | ||
d77de738 ML |
9369 | @opindex Wsign-conversion |
9370 | @opindex Wno-sign-conversion | |
ddf6fe37 | 9371 | @item -Wsign-conversion |
d77de738 ML |
9372 | Warn for implicit conversions that may change the sign of an integer |
9373 | value, like assigning a signed integer expression to an unsigned | |
9374 | integer variable. An explicit cast silences the warning. In C, this | |
9375 | option is enabled also by @option{-Wconversion}. | |
9376 | ||
44e3f39a QZ |
9377 | @opindex Wflex-array-member-not-at-end |
9378 | @opindex Wno-flex-array-member-not-at-end | |
9379 | @item -Wflex-array-member-not-at-end @r{(C and C++ only)} | |
9380 | Warn when a structure containing a C99 flexible array member as the last | |
9381 | field is not at the end of another structure. | |
9382 | This warning warns e.g. about | |
9383 | ||
9384 | @smallexample | |
9385 | struct flex @{ int length; char data[]; @}; | |
9386 | struct mid_flex @{ int m; struct flex flex_data; int n; @}; | |
9387 | @end smallexample | |
9388 | ||
d77de738 ML |
9389 | @opindex Wfloat-conversion |
9390 | @opindex Wno-float-conversion | |
ddf6fe37 | 9391 | @item -Wfloat-conversion |
d77de738 ML |
9392 | Warn for implicit conversions that reduce the precision of a real value. |
9393 | This includes conversions from real to integer, and from higher precision | |
9394 | real to lower precision real values. This option is also enabled by | |
9395 | @option{-Wconversion}. | |
9396 | ||
d77de738 ML |
9397 | @opindex Wno-scalar-storage-order |
9398 | @opindex Wscalar-storage-order | |
ddf6fe37 | 9399 | @item -Wno-scalar-storage-order |
d77de738 ML |
9400 | Do not warn on suspicious constructs involving reverse scalar storage order. |
9401 | ||
d77de738 ML |
9402 | @opindex Wsizeof-array-div |
9403 | @opindex Wno-sizeof-array-div | |
ddf6fe37 | 9404 | @item -Wsizeof-array-div |
d77de738 ML |
9405 | Warn about divisions of two sizeof operators when the first one is applied |
9406 | to an array and the divisor does not equal the size of the array element. | |
9407 | In such a case, the computation will not yield the number of elements in the | |
9408 | array, which is likely what the user intended. This warning warns e.g. about | |
9409 | @smallexample | |
9410 | int fn () | |
9411 | @{ | |
9412 | int arr[10]; | |
9413 | return sizeof (arr) / sizeof (short); | |
9414 | @} | |
9415 | @end smallexample | |
9416 | ||
9417 | This warning is enabled by @option{-Wall}. | |
9418 | ||
d77de738 ML |
9419 | @opindex Wsizeof-pointer-div |
9420 | @opindex Wno-sizeof-pointer-div | |
ddf6fe37 | 9421 | @item -Wsizeof-pointer-div |
d77de738 ML |
9422 | Warn for suspicious divisions of two sizeof expressions that divide |
9423 | the pointer size by the element size, which is the usual way to compute | |
9424 | the array size but won't work out correctly with pointers. This warning | |
9425 | warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is | |
9426 | not an array, but a pointer. This warning is enabled by @option{-Wall}. | |
9427 | ||
d77de738 ML |
9428 | @opindex Wsizeof-pointer-memaccess |
9429 | @opindex Wno-sizeof-pointer-memaccess | |
ddf6fe37 | 9430 | @item -Wsizeof-pointer-memaccess |
d77de738 ML |
9431 | Warn for suspicious length parameters to certain string and memory built-in |
9432 | functions if the argument uses @code{sizeof}. This warning triggers for | |
9433 | example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not | |
9434 | an array, but a pointer, and suggests a possible fix, or about | |
9435 | @code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess} | |
9436 | also warns about calls to bounded string copy functions like @code{strncat} | |
9437 | or @code{strncpy} that specify as the bound a @code{sizeof} expression of | |
9438 | the source array. For example, in the following function the call to | |
9439 | @code{strncat} specifies the size of the source string as the bound. That | |
9440 | is almost certainly a mistake and so the call is diagnosed. | |
9441 | @smallexample | |
9442 | void make_file (const char *name) | |
9443 | @{ | |
9444 | char path[PATH_MAX]; | |
9445 | strncpy (path, name, sizeof path - 1); | |
9446 | strncat (path, ".text", sizeof ".text"); | |
9447 | @dots{} | |
9448 | @} | |
9449 | @end smallexample | |
9450 | ||
9451 | The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}. | |
9452 | ||
d77de738 ML |
9453 | @opindex Wsizeof-array-argument |
9454 | @opindex Wno-sizeof-array-argument | |
ddf6fe37 | 9455 | @item -Wno-sizeof-array-argument |
d77de738 ML |
9456 | Do not warn when the @code{sizeof} operator is applied to a parameter that is |
9457 | declared as an array in a function definition. This warning is enabled by | |
9458 | default for C and C++ programs. | |
9459 | ||
d77de738 ML |
9460 | @opindex Wmemset-elt-size |
9461 | @opindex Wno-memset-elt-size | |
ddf6fe37 | 9462 | @item -Wmemset-elt-size |
d77de738 ML |
9463 | Warn for suspicious calls to the @code{memset} built-in function, if the |
9464 | first argument references an array, and the third argument is a number | |
9465 | equal to the number of elements, but not equal to the size of the array | |
9466 | in memory. This indicates that the user has omitted a multiplication by | |
9467 | the element size. This warning is enabled by @option{-Wall}. | |
9468 | ||
d77de738 ML |
9469 | @opindex Wmemset-transposed-args |
9470 | @opindex Wno-memset-transposed-args | |
ddf6fe37 | 9471 | @item -Wmemset-transposed-args |
d77de738 ML |
9472 | Warn for suspicious calls to the @code{memset} built-in function where |
9473 | the second argument is not zero and the third argument is zero. For | |
9474 | example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because | |
9475 | @code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic | |
9476 | is only emitted if the third argument is a literal zero. Otherwise, if | |
9477 | it is an expression that is folded to zero, or a cast of zero to some | |
9478 | type, it is far less likely that the arguments have been mistakenly | |
9479 | transposed and no warning is emitted. This warning is enabled | |
9480 | by @option{-Wall}. | |
9481 | ||
d77de738 ML |
9482 | @opindex Waddress |
9483 | @opindex Wno-address | |
ddf6fe37 | 9484 | @item -Waddress |
d77de738 ML |
9485 | Warn about suspicious uses of address expressions. These include comparing |
9486 | the address of a function or a declared object to the null pointer constant | |
9487 | such as in | |
9488 | @smallexample | |
9489 | void f (void); | |
9490 | void g (void) | |
9491 | @{ | |
9492 | if (!f) // warning: expression evaluates to false | |
9493 | abort (); | |
9494 | @} | |
9495 | @end smallexample | |
9496 | comparisons of a pointer to a string literal, such as in | |
9497 | @smallexample | |
9498 | void f (const char *x) | |
9499 | @{ | |
9500 | if (x == "abc") // warning: expression evaluates to false | |
9501 | puts ("equal"); | |
9502 | @} | |
9503 | @end smallexample | |
9504 | and tests of the results of pointer addition or subtraction for equality | |
9505 | to null, such as in | |
9506 | @smallexample | |
9507 | void f (const int *p, int i) | |
9508 | @{ | |
9509 | return p + i == NULL; | |
9510 | @} | |
9511 | @end smallexample | |
9512 | Such uses typically indicate a programmer error: the address of most | |
9513 | functions and objects necessarily evaluates to true (the exception are | |
9514 | weak symbols), so their use in a conditional might indicate missing | |
9515 | parentheses in a function call or a missing dereference in an array | |
9516 | expression. The subset of the warning for object pointers can be | |
9517 | suppressed by casting the pointer operand to an integer type such | |
9518 | as @code{intptr_t} or @code{uintptr_t}. | |
9519 | Comparisons against string literals result in unspecified behavior | |
9520 | and are not portable, and suggest the intent was to call @code{strcmp}. | |
9521 | The warning is suppressed if the suspicious expression is the result | |
9522 | of macro expansion. | |
9523 | @option{-Waddress} warning is enabled by @option{-Wall}. | |
9524 | ||
d77de738 ML |
9525 | @opindex Waddress-of-packed-member |
9526 | @opindex Wno-address-of-packed-member | |
ddf6fe37 | 9527 | @item -Wno-address-of-packed-member |
d77de738 ML |
9528 | Do not warn when the address of packed member of struct or union is taken, |
9529 | which usually results in an unaligned pointer value. This is | |
9530 | enabled by default. | |
9531 | ||
d77de738 ML |
9532 | @opindex Wlogical-op |
9533 | @opindex Wno-logical-op | |
ddf6fe37 | 9534 | @item -Wlogical-op |
d77de738 ML |
9535 | Warn about suspicious uses of logical operators in expressions. |
9536 | This includes using logical operators in contexts where a | |
9537 | bit-wise operator is likely to be expected. Also warns when | |
9538 | the operands of a logical operator are the same: | |
9539 | @smallexample | |
9540 | extern int a; | |
9541 | if (a < 0 && a < 0) @{ @dots{} @} | |
9542 | @end smallexample | |
9543 | ||
d77de738 ML |
9544 | @opindex Wlogical-not-parentheses |
9545 | @opindex Wno-logical-not-parentheses | |
ddf6fe37 | 9546 | @item -Wlogical-not-parentheses |
d77de738 ML |
9547 | Warn about logical not used on the left hand side operand of a comparison. |
9548 | This option does not warn if the right operand is considered to be a boolean | |
9549 | expression. Its purpose is to detect suspicious code like the following: | |
9550 | @smallexample | |
9551 | int a; | |
9552 | @dots{} | |
9553 | if (!a > 1) @{ @dots{} @} | |
9554 | @end smallexample | |
9555 | ||
9556 | It is possible to suppress the warning by wrapping the LHS into | |
9557 | parentheses: | |
9558 | @smallexample | |
9559 | if ((!a) > 1) @{ @dots{} @} | |
9560 | @end smallexample | |
9561 | ||
9562 | This warning is enabled by @option{-Wall}. | |
9563 | ||
d77de738 ML |
9564 | @opindex Waggregate-return |
9565 | @opindex Wno-aggregate-return | |
ddf6fe37 | 9566 | @item -Waggregate-return |
d77de738 ML |
9567 | Warn if any functions that return structures or unions are defined or |
9568 | called. (In languages where you can return an array, this also elicits | |
9569 | a warning.) | |
9570 | ||
d77de738 ML |
9571 | @opindex Wno-aggressive-loop-optimizations |
9572 | @opindex Waggressive-loop-optimizations | |
ddf6fe37 | 9573 | @item -Wno-aggressive-loop-optimizations |
d77de738 ML |
9574 | Warn if in a loop with constant number of iterations the compiler detects |
9575 | undefined behavior in some statement during one or more of the iterations. | |
9576 | ||
d77de738 ML |
9577 | @opindex Wno-attributes |
9578 | @opindex Wattributes | |
ddf6fe37 | 9579 | @item -Wno-attributes |
d77de738 ML |
9580 | Do not warn if an unexpected @code{__attribute__} is used, such as |
9581 | unrecognized attributes, function attributes applied to variables, | |
9582 | etc. This does not stop errors for incorrect use of supported | |
9583 | attributes. | |
9584 | ||
5fccebdb JM |
9585 | Warnings about ill-formed uses of standard attributes are upgraded to |
9586 | errors by @option{-pedantic-errors}. | |
9587 | ||
d77de738 ML |
9588 | Additionally, using @option{-Wno-attributes=}, it is possible to suppress |
9589 | warnings about unknown scoped attributes (in C++11 and C2X). For example, | |
9590 | @option{-Wno-attributes=vendor::attr} disables warning about the following | |
9591 | declaration: | |
9592 | ||
9593 | @smallexample | |
9594 | [[vendor::attr]] void f(); | |
9595 | @end smallexample | |
9596 | ||
9597 | It is also possible to disable warning about all attributes in a namespace | |
9598 | using @option{-Wno-attributes=vendor::} which prevents warning about both | |
9599 | of these declarations: | |
9600 | ||
9601 | @smallexample | |
9602 | [[vendor::safe]] void f(); | |
9603 | [[vendor::unsafe]] void f2(); | |
9604 | @end smallexample | |
9605 | ||
9606 | Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}. | |
9607 | ||
d77de738 ML |
9608 | @opindex Wno-builtin-declaration-mismatch |
9609 | @opindex Wbuiltin-declaration-mismatch | |
ddf6fe37 | 9610 | @item -Wno-builtin-declaration-mismatch |
d77de738 ML |
9611 | Warn if a built-in function is declared with an incompatible signature |
9612 | or as a non-function, or when a built-in function declared with a type | |
9613 | that does not include a prototype is called with arguments whose promoted | |
9614 | types do not match those expected by the function. When @option{-Wextra} | |
9615 | is specified, also warn when a built-in function that takes arguments is | |
9616 | declared without a prototype. The @option{-Wbuiltin-declaration-mismatch} | |
9617 | warning is enabled by default. To avoid the warning include the appropriate | |
9618 | header to bring the prototypes of built-in functions into scope. | |
9619 | ||
9620 | For example, the call to @code{memset} below is diagnosed by the warning | |
9621 | because the function expects a value of type @code{size_t} as its argument | |
9622 | but the type of @code{32} is @code{int}. With @option{-Wextra}, | |
9623 | the declaration of the function is diagnosed as well. | |
9624 | @smallexample | |
9625 | extern void* memset (); | |
9626 | void f (void *d) | |
9627 | @{ | |
9628 | memset (d, '\0', 32); | |
9629 | @} | |
9630 | @end smallexample | |
9631 | ||
d77de738 ML |
9632 | @opindex Wno-builtin-macro-redefined |
9633 | @opindex Wbuiltin-macro-redefined | |
ddf6fe37 | 9634 | @item -Wno-builtin-macro-redefined |
d77de738 ML |
9635 | Do not warn if certain built-in macros are redefined. This suppresses |
9636 | warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__}, | |
9637 | @code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}. | |
9638 | ||
d77de738 ML |
9639 | @opindex Wstrict-prototypes |
9640 | @opindex Wno-strict-prototypes | |
ddf6fe37 | 9641 | @item -Wstrict-prototypes @r{(C and Objective-C only)} |
d77de738 ML |
9642 | Warn if a function is declared or defined without specifying the |
9643 | argument types. (An old-style function definition is permitted without | |
9644 | a warning if preceded by a declaration that specifies the argument | |
9645 | types.) | |
9646 | ||
d77de738 ML |
9647 | @opindex Wold-style-declaration |
9648 | @opindex Wno-old-style-declaration | |
ddf6fe37 | 9649 | @item -Wold-style-declaration @r{(C and Objective-C only)} |
d77de738 ML |
9650 | Warn for obsolescent usages, according to the C Standard, in a |
9651 | declaration. For example, warn if storage-class specifiers like | |
9652 | @code{static} are not the first things in a declaration. This warning | |
9653 | is also enabled by @option{-Wextra}. | |
9654 | ||
d77de738 ML |
9655 | @opindex Wold-style-definition |
9656 | @opindex Wno-old-style-definition | |
ddf6fe37 | 9657 | @item -Wold-style-definition @r{(C and Objective-C only)} |
d77de738 ML |
9658 | Warn if an old-style function definition is used. A warning is given |
9659 | even if there is a previous prototype. A definition using @samp{()} | |
9660 | is not considered an old-style definition in C2X mode, because it is | |
9661 | equivalent to @samp{(void)} in that case, but is considered an | |
9662 | old-style definition for older standards. | |
9663 | ||
d77de738 ML |
9664 | @opindex Wmissing-parameter-type |
9665 | @opindex Wno-missing-parameter-type | |
ddf6fe37 | 9666 | @item -Wmissing-parameter-type @r{(C and Objective-C only)} |
d77de738 ML |
9667 | A function parameter is declared without a type specifier in K&R-style |
9668 | functions: | |
9669 | ||
9670 | @smallexample | |
9671 | void foo(bar) @{ @} | |
9672 | @end smallexample | |
9673 | ||
9674 | This warning is also enabled by @option{-Wextra}. | |
9675 | ||
d77de738 ML |
9676 | @opindex Wmissing-prototypes |
9677 | @opindex Wno-missing-prototypes | |
ddf6fe37 | 9678 | @item -Wmissing-prototypes @r{(C and Objective-C only)} |
d77de738 ML |
9679 | Warn if a global function is defined without a previous prototype |
9680 | declaration. This warning is issued even if the definition itself | |
9681 | provides a prototype. Use this option to detect global functions | |
9682 | that do not have a matching prototype declaration in a header file. | |
9683 | This option is not valid for C++ because all function declarations | |
9684 | provide prototypes and a non-matching declaration declares an | |
9685 | overload rather than conflict with an earlier declaration. | |
9686 | Use @option{-Wmissing-declarations} to detect missing declarations in C++. | |
9687 | ||
ffc74822 HM |
9688 | @opindex Wmissing-variable-declarations |
9689 | @opindex Wno-missing-variable-declarations | |
9690 | @item -Wmissing-variable-declarations @r{(C and Objective-C only)} | |
9691 | Warn if a global variable is defined without a previous declaration. | |
9692 | Use this option to detect global variables that do not have a matching | |
9693 | extern declaration in a header file. | |
9694 | ||
d77de738 ML |
9695 | @opindex Wmissing-declarations |
9696 | @opindex Wno-missing-declarations | |
ddf6fe37 | 9697 | @item -Wmissing-declarations |
d77de738 ML |
9698 | Warn if a global function is defined without a previous declaration. |
9699 | Do so even if the definition itself provides a prototype. | |
9700 | Use this option to detect global functions that are not declared in | |
9701 | header files. In C, no warnings are issued for functions with previous | |
9702 | non-prototype declarations; use @option{-Wmissing-prototypes} to detect | |
9703 | missing prototypes. In C++, no warnings are issued for function templates, | |
9704 | or for inline functions, or for functions in anonymous namespaces. | |
9705 | ||
d77de738 ML |
9706 | @opindex Wmissing-field-initializers |
9707 | @opindex Wno-missing-field-initializers | |
9708 | @opindex W | |
9709 | @opindex Wextra | |
9710 | @opindex Wno-extra | |
ddf6fe37 | 9711 | @item -Wmissing-field-initializers |
d77de738 ML |
9712 | Warn if a structure's initializer has some fields missing. For |
9713 | example, the following code causes such a warning, because | |
9714 | @code{x.h} is implicitly zero: | |
9715 | ||
9716 | @smallexample | |
9717 | struct s @{ int f, g, h; @}; | |
9718 | struct s x = @{ 3, 4 @}; | |
9719 | @end smallexample | |
9720 | ||
0f8f1dee MP |
9721 | @c It's unclear if this behavior is desirable. See PR39589 and PR96868. |
9722 | In C this option does not warn about designated initializers, so the | |
9723 | following modification does not trigger a warning: | |
d77de738 ML |
9724 | |
9725 | @smallexample | |
9726 | struct s @{ int f, g, h; @}; | |
9727 | struct s x = @{ .f = 3, .g = 4 @}; | |
9728 | @end smallexample | |
9729 | ||
9730 | In C this option does not warn about the universal zero initializer | |
9731 | @samp{@{ 0 @}}: | |
9732 | ||
9733 | @smallexample | |
9734 | struct s @{ int f, g, h; @}; | |
9735 | struct s x = @{ 0 @}; | |
9736 | @end smallexample | |
9737 | ||
9738 | Likewise, in C++ this option does not warn about the empty @{ @} | |
9739 | initializer, for example: | |
9740 | ||
9741 | @smallexample | |
9742 | struct s @{ int f, g, h; @}; | |
9743 | s x = @{ @}; | |
9744 | @end smallexample | |
9745 | ||
9746 | This warning is included in @option{-Wextra}. To get other @option{-Wextra} | |
9747 | warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}. | |
9748 | ||
d77de738 ML |
9749 | @opindex Wmissing-requires |
9750 | @opindex Wno-missing-requires | |
ddf6fe37 | 9751 | @item -Wno-missing-requires |
d77de738 ML |
9752 | |
9753 | By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement: | |
9754 | ||
9755 | @smallexample | |
9756 | bool satisfied = requires @{ C<T> @}; | |
9757 | @end smallexample | |
9758 | ||
9759 | Here @samp{satisfied} will be true if @samp{C<T>} is a valid | |
9760 | expression, which it is for all T. Presumably the user meant to write | |
9761 | ||
9762 | @smallexample | |
9763 | bool satisfied = requires @{ requires C<T> @}; | |
9764 | @end smallexample | |
9765 | ||
9766 | so @samp{satisfied} is only true if concept @samp{C} is satisfied for | |
9767 | type @samp{T}. | |
9768 | ||
9769 | This warning can be disabled with @option{-Wno-missing-requires}. | |
9770 | ||
d77de738 ML |
9771 | @opindex Wmissing-template-keyword |
9772 | @opindex Wno-missing-template-keyword | |
ddf6fe37 | 9773 | @item -Wno-missing-template-keyword |
d77de738 ML |
9774 | |
9775 | The member access tokens ., -> and :: must be followed by the @code{template} | |
9776 | keyword if the parent object is dependent and the member being named is a | |
9777 | template. | |
9778 | ||
9779 | @smallexample | |
9780 | template <class X> | |
9781 | void DoStuff (X x) | |
9782 | @{ | |
9783 | x.template DoSomeOtherStuff<X>(); // Good. | |
9784 | x.DoMoreStuff<X>(); // Warning, x is dependent. | |
9785 | @} | |
9786 | @end smallexample | |
9787 | ||
9788 | In rare cases it is possible to get false positives. To silence this, wrap | |
9789 | the expression in parentheses. For example, the following is treated as a | |
9790 | template, even where m and N are integers: | |
9791 | ||
9792 | @smallexample | |
9793 | void NotATemplate (my_class t) | |
9794 | @{ | |
9795 | int N = 5; | |
9796 | ||
9797 | bool test = t.m < N > (0); // Treated as a template. | |
9798 | test = (t.m < N) > (0); // Same meaning, but not treated as a template. | |
9799 | @} | |
9800 | @end smallexample | |
9801 | ||
9802 | This warning can be disabled with @option{-Wno-missing-template-keyword}. | |
9803 | ||
d77de738 ML |
9804 | @opindex Wno-multichar |
9805 | @opindex Wmultichar | |
ddf6fe37 | 9806 | @item -Wno-multichar |
d77de738 ML |
9807 | Do not warn if a multicharacter constant (@samp{'FOOF'}) is used. |
9808 | Usually they indicate a typo in the user's code, as they have | |
9809 | implementation-defined values, and should not be used in portable code. | |
9810 | ||
d77de738 ML |
9811 | @opindex Wnormalized= |
9812 | @opindex Wnormalized | |
9813 | @opindex Wno-normalized | |
9814 | @cindex NFC | |
9815 | @cindex NFKC | |
9816 | @cindex character set, input normalization | |
f33d7a88 | 9817 | @item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} |
d77de738 ML |
9818 | In ISO C and ISO C++, two identifiers are different if they are |
9819 | different sequences of characters. However, sometimes when characters | |
9820 | outside the basic ASCII character set are used, you can have two | |
9821 | different character sequences that look the same. To avoid confusion, | |
9822 | the ISO 10646 standard sets out some @dfn{normalization rules} which | |
9823 | when applied ensure that two sequences that look the same are turned into | |
9824 | the same sequence. GCC can warn you if you are using identifiers that | |
9825 | have not been normalized; this option controls that warning. | |
9826 | ||
9827 | There are four levels of warning supported by GCC@. The default is | |
9828 | @option{-Wnormalized=nfc}, which warns about any identifier that is | |
9829 | not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the | |
9830 | recommended form for most uses. It is equivalent to | |
9831 | @option{-Wnormalized}. | |
9832 | ||
9833 | Unfortunately, there are some characters allowed in identifiers by | |
9834 | ISO C and ISO C++ that, when turned into NFC, are not allowed in | |
9835 | identifiers. That is, there's no way to use these symbols in portable | |
9836 | ISO C or C++ and have all your identifiers in NFC@. | |
9837 | @option{-Wnormalized=id} suppresses the warning for these characters. | |
9838 | It is hoped that future versions of the standards involved will correct | |
9839 | this, which is why this option is not the default. | |
9840 | ||
9841 | You can switch the warning off for all characters by writing | |
9842 | @option{-Wnormalized=none} or @option{-Wno-normalized}. You should | |
9843 | only do this if you are using some other normalization scheme (like | |
9844 | ``D''), because otherwise you can easily create bugs that are | |
9845 | literally impossible to see. | |
9846 | ||
9847 | Some characters in ISO 10646 have distinct meanings but look identical | |
9848 | in some fonts or display methodologies, especially once formatting has | |
9849 | been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL | |
9850 | LETTER N'', displays just like a regular @code{n} that has been | |
9851 | placed in a superscript. ISO 10646 defines the @dfn{NFKC} | |
9852 | normalization scheme to convert all these into a standard form as | |
9853 | well, and GCC warns if your code is not in NFKC if you use | |
9854 | @option{-Wnormalized=nfkc}. This warning is comparable to warning | |
9855 | about every identifier that contains the letter O because it might be | |
9856 | confused with the digit 0, and so is not the default, but may be | |
9857 | useful as a local coding convention if the programming environment | |
9858 | cannot be fixed to display these characters distinctly. | |
9859 | ||
d77de738 ML |
9860 | @opindex Wno-attribute-warning |
9861 | @opindex Wattribute-warning | |
ddf6fe37 | 9862 | @item -Wno-attribute-warning |
d77de738 ML |
9863 | Do not warn about usage of functions (@pxref{Function Attributes}) |
9864 | declared with @code{warning} attribute. By default, this warning is | |
9865 | enabled. @option{-Wno-attribute-warning} can be used to disable the | |
9866 | warning or @option{-Wno-error=attribute-warning} can be used to | |
9867 | disable the error when compiled with @option{-Werror} flag. | |
9868 | ||
d77de738 ML |
9869 | @opindex Wno-deprecated |
9870 | @opindex Wdeprecated | |
ddf6fe37 | 9871 | @item -Wno-deprecated |
d77de738 ML |
9872 | Do not warn about usage of deprecated features. @xref{Deprecated Features}. |
9873 | ||
d77de738 ML |
9874 | @opindex Wno-deprecated-declarations |
9875 | @opindex Wdeprecated-declarations | |
ddf6fe37 | 9876 | @item -Wno-deprecated-declarations |
d77de738 ML |
9877 | Do not warn about uses of functions (@pxref{Function Attributes}), |
9878 | variables (@pxref{Variable Attributes}), and types (@pxref{Type | |
9879 | Attributes}) marked as deprecated by using the @code{deprecated} | |
9880 | attribute. | |
9881 | ||
d77de738 ML |
9882 | @opindex Wno-overflow |
9883 | @opindex Woverflow | |
ddf6fe37 | 9884 | @item -Wno-overflow |
d77de738 ML |
9885 | Do not warn about compile-time overflow in constant expressions. |
9886 | ||
d77de738 ML |
9887 | @opindex Wno-odr |
9888 | @opindex Wodr | |
ddf6fe37 | 9889 | @item -Wno-odr |
d77de738 ML |
9890 | Warn about One Definition Rule violations during link-time optimization. |
9891 | Enabled by default. | |
9892 | ||
d77de738 ML |
9893 | @opindex Wopenacc-parallelism |
9894 | @opindex Wno-openacc-parallelism | |
9895 | @cindex OpenACC accelerator programming | |
f33d7a88 | 9896 | @item -Wopenacc-parallelism |
d77de738 ML |
9897 | Warn about potentially suboptimal choices related to OpenACC parallelism. |
9898 | ||
d77de738 ML |
9899 | @opindex Wopenmp-simd |
9900 | @opindex Wno-openmp-simd | |
ddf6fe37 | 9901 | @item -Wopenmp-simd |
d77de738 ML |
9902 | Warn if the vectorizer cost model overrides the OpenMP |
9903 | simd directive set by user. The @option{-fsimd-cost-model=unlimited} | |
9904 | option can be used to relax the cost model. | |
9905 | ||
d77de738 ML |
9906 | @opindex Woverride-init |
9907 | @opindex Wno-override-init | |
9908 | @opindex W | |
9909 | @opindex Wextra | |
9910 | @opindex Wno-extra | |
ddf6fe37 | 9911 | @item -Woverride-init @r{(C and Objective-C only)} |
d77de738 ML |
9912 | Warn if an initialized field without side effects is overridden when |
9913 | using designated initializers (@pxref{Designated Inits, , Designated | |
9914 | Initializers}). | |
9915 | ||
9916 | This warning is included in @option{-Wextra}. To get other | |
9917 | @option{-Wextra} warnings without this one, use @option{-Wextra | |
9918 | -Wno-override-init}. | |
9919 | ||
d77de738 ML |
9920 | @opindex Woverride-init-side-effects |
9921 | @opindex Wno-override-init-side-effects | |
ddf6fe37 | 9922 | @item -Wno-override-init-side-effects @r{(C and Objective-C only)} |
d77de738 ML |
9923 | Do not warn if an initialized field with side effects is overridden when |
9924 | using designated initializers (@pxref{Designated Inits, , Designated | |
9925 | Initializers}). This warning is enabled by default. | |
9926 | ||
d77de738 ML |
9927 | @opindex Wpacked |
9928 | @opindex Wno-packed | |
ddf6fe37 | 9929 | @item -Wpacked |
d77de738 ML |
9930 | Warn if a structure is given the packed attribute, but the packed |
9931 | attribute has no effect on the layout or size of the structure. | |
9932 | Such structures may be mis-aligned for little benefit. For | |
9933 | instance, in this code, the variable @code{f.x} in @code{struct bar} | |
9934 | is misaligned even though @code{struct bar} does not itself | |
9935 | have the packed attribute: | |
9936 | ||
9937 | @smallexample | |
9938 | @group | |
9939 | struct foo @{ | |
9940 | int x; | |
9941 | char a, b, c, d; | |
9942 | @} __attribute__((packed)); | |
9943 | struct bar @{ | |
9944 | char z; | |
9945 | struct foo f; | |
9946 | @}; | |
9947 | @end group | |
9948 | @end smallexample | |
9949 | ||
d77de738 ML |
9950 | @opindex Wpacked-bitfield-compat |
9951 | @opindex Wno-packed-bitfield-compat | |
ddf6fe37 | 9952 | @item -Wnopacked-bitfield-compat |
d77de738 ML |
9953 | The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute |
9954 | on bit-fields of type @code{char}. This was fixed in GCC 4.4 but | |
9955 | the change can lead to differences in the structure layout. GCC | |
9956 | informs you when the offset of such a field has changed in GCC 4.4. | |
9957 | For example there is no longer a 4-bit padding between field @code{a} | |
9958 | and @code{b} in this structure: | |
9959 | ||
9960 | @smallexample | |
9961 | struct foo | |
9962 | @{ | |
9963 | char a:4; | |
9964 | char b:8; | |
9965 | @} __attribute__ ((packed)); | |
9966 | @end smallexample | |
9967 | ||
9968 | This warning is enabled by default. Use | |
9969 | @option{-Wno-packed-bitfield-compat} to disable this warning. | |
9970 | ||
d77de738 ML |
9971 | @opindex Wpacked-not-aligned |
9972 | @opindex Wno-packed-not-aligned | |
ddf6fe37 | 9973 | @item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
9974 | Warn if a structure field with explicitly specified alignment in a |
9975 | packed struct or union is misaligned. For example, a warning will | |
9976 | be issued on @code{struct S}, like, @code{warning: alignment 1 of | |
9977 | 'struct S' is less than 8}, in this code: | |
9978 | ||
9979 | @smallexample | |
9980 | @group | |
9981 | struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @}; | |
9982 | struct __attribute__ ((packed)) S @{ | |
9983 | struct S8 s8; | |
9984 | @}; | |
9985 | @end group | |
9986 | @end smallexample | |
9987 | ||
9988 | This warning is enabled by @option{-Wall}. | |
9989 | ||
d77de738 ML |
9990 | @opindex Wpadded |
9991 | @opindex Wno-padded | |
ddf6fe37 | 9992 | @item -Wpadded |
d77de738 ML |
9993 | Warn if padding is included in a structure, either to align an element |
9994 | of the structure or to align the whole structure. Sometimes when this | |
9995 | happens it is possible to rearrange the fields of the structure to | |
9996 | reduce the padding and so make the structure smaller. | |
9997 | ||
d77de738 ML |
9998 | @opindex Wredundant-decls |
9999 | @opindex Wno-redundant-decls | |
ddf6fe37 | 10000 | @item -Wredundant-decls |
d77de738 ML |
10001 | Warn if anything is declared more than once in the same scope, even in |
10002 | cases where multiple declaration is valid and changes nothing. | |
10003 | ||
d77de738 ML |
10004 | @opindex Wrestrict |
10005 | @opindex Wno-restrict | |
ddf6fe37 | 10006 | @item -Wrestrict |
d77de738 ML |
10007 | Warn when an object referenced by a @code{restrict}-qualified parameter |
10008 | (or, in C++, a @code{__restrict}-qualified parameter) is aliased by another | |
10009 | argument, or when copies between such objects overlap. For example, | |
10010 | the call to the @code{strcpy} function below attempts to truncate the string | |
10011 | by replacing its initial characters with the last four. However, because | |
10012 | the call writes the terminating NUL into @code{a[4]}, the copies overlap and | |
10013 | the call is diagnosed. | |
10014 | ||
10015 | @smallexample | |
10016 | void foo (void) | |
10017 | @{ | |
10018 | char a[] = "abcd1234"; | |
10019 | strcpy (a, a + 4); | |
10020 | @dots{} | |
10021 | @} | |
10022 | @end smallexample | |
10023 | The @option{-Wrestrict} option detects some instances of simple overlap | |
10024 | even without optimization but works best at @option{-O2} and above. It | |
10025 | is included in @option{-Wall}. | |
10026 | ||
d77de738 ML |
10027 | @opindex Wnested-externs |
10028 | @opindex Wno-nested-externs | |
ddf6fe37 | 10029 | @item -Wnested-externs @r{(C and Objective-C only)} |
d77de738 ML |
10030 | Warn if an @code{extern} declaration is encountered within a function. |
10031 | ||
d77de738 ML |
10032 | @opindex Winline |
10033 | @opindex Wno-inline | |
ddf6fe37 | 10034 | @item -Winline |
d77de738 ML |
10035 | Warn if a function that is declared as inline cannot be inlined. |
10036 | Even with this option, the compiler does not warn about failures to | |
10037 | inline functions declared in system headers. | |
10038 | ||
10039 | The compiler uses a variety of heuristics to determine whether or not | |
10040 | to inline a function. For example, the compiler takes into account | |
10041 | the size of the function being inlined and the amount of inlining | |
10042 | that has already been done in the current function. Therefore, | |
10043 | seemingly insignificant changes in the source program can cause the | |
10044 | warnings produced by @option{-Winline} to appear or disappear. | |
10045 | ||
d77de738 | 10046 | @opindex Winterference-size |
ddf6fe37 | 10047 | @item -Winterference-size |
d77de738 ML |
10048 | Warn about use of C++17 @code{std::hardware_destructive_interference_size} |
10049 | without specifying its value with @option{--param destructive-interference-size}. | |
10050 | Also warn about questionable values for that option. | |
10051 | ||
10052 | This variable is intended to be used for controlling class layout, to | |
10053 | avoid false sharing in concurrent code: | |
10054 | ||
10055 | @smallexample | |
10056 | struct independent_fields @{ | |
4ace81b6 SL |
10057 | alignas(std::hardware_destructive_interference_size) |
10058 | std::atomic<int> one; | |
10059 | alignas(std::hardware_destructive_interference_size) | |
10060 | std::atomic<int> two; | |
d77de738 ML |
10061 | @}; |
10062 | @end smallexample | |
10063 | ||
10064 | Here @samp{one} and @samp{two} are intended to be far enough apart | |
10065 | that stores to one won't require accesses to the other to reload the | |
10066 | cache line. | |
10067 | ||
10068 | By default, @option{--param destructive-interference-size} and | |
10069 | @option{--param constructive-interference-size} are set based on the | |
10070 | current @option{-mtune} option, typically to the L1 cache line size | |
10071 | for the particular target CPU, sometimes to a range if tuning for a | |
10072 | generic target. So all translation units that depend on ABI | |
10073 | compatibility for the use of these variables must be compiled with | |
10074 | the same @option{-mtune} (or @option{-mcpu}). | |
10075 | ||
10076 | If ABI stability is important, such as if the use is in a header for a | |
10077 | library, you should probably not use the hardware interference size | |
10078 | variables at all. Alternatively, you can force a particular value | |
10079 | with @option{--param}. | |
10080 | ||
10081 | If you are confident that your use of the variable does not affect ABI | |
10082 | outside a single build of your project, you can turn off the warning | |
10083 | with @option{-Wno-interference-size}. | |
10084 | ||
d77de738 ML |
10085 | @opindex Wint-in-bool-context |
10086 | @opindex Wno-int-in-bool-context | |
ddf6fe37 | 10087 | @item -Wint-in-bool-context |
d77de738 ML |
10088 | Warn for suspicious use of integer values where boolean values are expected, |
10089 | such as conditional expressions (?:) using non-boolean integer constants in | |
10090 | boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed | |
10091 | integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise | |
10092 | for all kinds of multiplications regardless of the data type. | |
10093 | This warning is enabled by @option{-Wall}. | |
10094 | ||
d77de738 ML |
10095 | @opindex Wno-int-to-pointer-cast |
10096 | @opindex Wint-to-pointer-cast | |
ddf6fe37 | 10097 | @item -Wno-int-to-pointer-cast |
d77de738 ML |
10098 | Suppress warnings from casts to pointer type of an integer of a |
10099 | different size. In C++, casting to a pointer type of smaller size is | |
10100 | an error. @option{Wint-to-pointer-cast} is enabled by default. | |
10101 | ||
10102 | ||
d77de738 ML |
10103 | @opindex Wno-pointer-to-int-cast |
10104 | @opindex Wpointer-to-int-cast | |
ddf6fe37 | 10105 | @item -Wno-pointer-to-int-cast @r{(C and Objective-C only)} |
d77de738 ML |
10106 | Suppress warnings from casts from a pointer to an integer type of a |
10107 | different size. | |
10108 | ||
d77de738 ML |
10109 | @opindex Winvalid-pch |
10110 | @opindex Wno-invalid-pch | |
ddf6fe37 | 10111 | @item -Winvalid-pch |
d77de738 ML |
10112 | Warn if a precompiled header (@pxref{Precompiled Headers}) is found in |
10113 | the search path but cannot be used. | |
10114 | ||
d77de738 ML |
10115 | @opindex Winvalid-utf8 |
10116 | @opindex Wno-invalid-utf8 | |
ddf6fe37 | 10117 | @item -Winvalid-utf8 |
d77de738 ML |
10118 | Warn if an invalid UTF-8 character is found. |
10119 | This warning is on by default for C++23 if @option{-finput-charset=UTF-8} | |
10120 | is used and turned into error with @option{-pedantic-errors}. | |
10121 | ||
d77de738 ML |
10122 | @opindex Wunicode |
10123 | @opindex Wno-unicode | |
ddf6fe37 | 10124 | @item -Wno-unicode |
d77de738 ML |
10125 | Don't diagnose invalid forms of delimited or named escape sequences which are |
10126 | treated as separate tokens. @option{Wunicode} is enabled by default. | |
10127 | ||
d77de738 ML |
10128 | @opindex Wlong-long |
10129 | @opindex Wno-long-long | |
ddf6fe37 | 10130 | @item -Wlong-long |
d77de738 ML |
10131 | Warn if @code{long long} type is used. This is enabled by either |
10132 | @option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98 | |
10133 | modes. To inhibit the warning messages, use @option{-Wno-long-long}. | |
10134 | ||
5fccebdb JM |
10135 | This warning is upgraded to an error by @option{-pedantic-errors}. |
10136 | ||
d77de738 ML |
10137 | @opindex Wvariadic-macros |
10138 | @opindex Wno-variadic-macros | |
ddf6fe37 | 10139 | @item -Wvariadic-macros |
d77de738 ML |
10140 | Warn if variadic macros are used in ISO C90 mode, or if the GNU |
10141 | alternate syntax is used in ISO C99 mode. This is enabled by either | |
10142 | @option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning | |
10143 | messages, use @option{-Wno-variadic-macros}. | |
10144 | ||
d77de738 ML |
10145 | @opindex Wvarargs |
10146 | @opindex Wno-varargs | |
ddf6fe37 | 10147 | @item -Wno-varargs |
d77de738 ML |
10148 | Do not warn upon questionable usage of the macros used to handle variable |
10149 | arguments like @code{va_start}. These warnings are enabled by default. | |
10150 | ||
d77de738 ML |
10151 | @opindex Wvector-operation-performance |
10152 | @opindex Wno-vector-operation-performance | |
ddf6fe37 | 10153 | @item -Wvector-operation-performance |
d77de738 ML |
10154 | Warn if vector operation is not implemented via SIMD capabilities of the |
10155 | architecture. Mainly useful for the performance tuning. | |
10156 | Vector operation can be implemented @code{piecewise}, which means that the | |
10157 | scalar operation is performed on every vector element; | |
10158 | @code{in parallel}, which means that the vector operation is implemented | |
10159 | using scalars of wider type, which normally is more performance efficient; | |
10160 | and @code{as a single scalar}, which means that vector fits into a | |
10161 | scalar type. | |
10162 | ||
d77de738 ML |
10163 | @opindex Wvla |
10164 | @opindex Wno-vla | |
ddf6fe37 | 10165 | @item -Wvla |
d77de738 ML |
10166 | Warn if a variable-length array is used in the code. |
10167 | @option{-Wno-vla} prevents the @option{-Wpedantic} warning of | |
10168 | the variable-length array. | |
10169 | ||
5fccebdb JM |
10170 | This warning is upgraded to an error by @option{-pedantic-errors}. |
10171 | ||
d77de738 ML |
10172 | @opindex Wvla-larger-than= |
10173 | @opindex Wno-vla-larger-than | |
ddf6fe37 | 10174 | @item -Wvla-larger-than=@var{byte-size} |
d77de738 ML |
10175 | If this option is used, the compiler warns for declarations of |
10176 | variable-length arrays whose size is either unbounded, or bounded | |
10177 | by an argument that allows the array size to exceed @var{byte-size} | |
10178 | bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size} | |
10179 | works, but with variable-length arrays. | |
10180 | ||
10181 | Note that GCC may optimize small variable-length arrays of a known | |
10182 | value into plain arrays, so this warning may not get triggered for | |
10183 | such arrays. | |
10184 | ||
10185 | @option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but | |
10186 | is typically only effective when @option{-ftree-vrp} is active (default | |
10187 | for @option{-O2} and above). | |
10188 | ||
10189 | See also @option{-Walloca-larger-than=@var{byte-size}}. | |
10190 | ||
d77de738 | 10191 | @opindex Wno-vla-larger-than |
ddf6fe37 | 10192 | @item -Wno-vla-larger-than |
d77de738 ML |
10193 | Disable @option{-Wvla-larger-than=} warnings. The option is equivalent |
10194 | to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger. | |
10195 | ||
d77de738 | 10196 | @opindex Wno-vla-parameter |
ddf6fe37 | 10197 | @item -Wvla-parameter |
d77de738 ML |
10198 | Warn about redeclarations of functions involving arguments of Variable |
10199 | Length Array types of inconsistent kinds or forms, and enable the detection | |
10200 | of out-of-bounds accesses to such parameters by warnings such as | |
10201 | @option{-Warray-bounds}. | |
10202 | ||
10203 | If the first function declaration uses the VLA form the bound specified | |
10204 | in the array is assumed to be the minimum number of elements expected to | |
10205 | be provided in calls to the function and the maximum number of elements | |
10206 | accessed by it. Failing to provide arguments of sufficient size or | |
10207 | accessing more than the maximum number of elements may be diagnosed. | |
10208 | ||
10209 | For example, the warning triggers for the following redeclarations because | |
10210 | the first one allows an array of any size to be passed to @code{f} while | |
10211 | the second one specifies that the array argument must have at least @code{n} | |
10212 | elements. In addition, calling @code{f} with the associated VLA bound | |
10213 | parameter in excess of the actual VLA bound triggers a warning as well. | |
10214 | ||
10215 | @smallexample | |
10216 | void f (int n, int[n]); | |
4ace81b6 SL |
10217 | // warning: argument 2 previously declared as a VLA |
10218 | void f (int, int[]); | |
d77de738 ML |
10219 | |
10220 | void g (int n) | |
10221 | @{ | |
10222 | if (n > 4) | |
10223 | return; | |
10224 | int a[n]; | |
4ace81b6 SL |
10225 | // warning: access to a by f may be out of bounds |
10226 | f (sizeof a, a); | |
d77de738 ML |
10227 | @dots{} |
10228 | @} | |
10229 | ||
10230 | @end smallexample | |
10231 | ||
10232 | @option{-Wvla-parameter} is included in @option{-Wall}. The | |
10233 | @option{-Warray-parameter} option triggers warnings for similar problems | |
10234 | involving ordinary array arguments. | |
10235 | ||
d77de738 ML |
10236 | @opindex Wvolatile-register-var |
10237 | @opindex Wno-volatile-register-var | |
ddf6fe37 | 10238 | @item -Wvolatile-register-var |
d77de738 ML |
10239 | Warn if a register variable is declared volatile. The volatile |
10240 | modifier does not inhibit all optimizations that may eliminate reads | |
10241 | and/or writes to register variables. This warning is enabled by | |
10242 | @option{-Wall}. | |
10243 | ||
d77de738 ML |
10244 | @opindex Wxor-used-as-pow |
10245 | @opindex Wno-xor-used-as-pow | |
ddf6fe37 | 10246 | @item -Wxor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
10247 | Warn about uses of @code{^}, the exclusive or operator, where it appears |
10248 | the user meant exponentiation. Specifically, the warning occurs when the | |
10249 | left-hand side is the decimal constant 2 or 10 and the right-hand side | |
10250 | is also a decimal constant. | |
10251 | ||
10252 | In C and C++, @code{^} means exclusive or, whereas in some other languages | |
10253 | (e.g. TeX and some versions of BASIC) it means exponentiation. | |
10254 | ||
10255 | This warning is enabled by default. It can be silenced by converting one | |
10256 | of the operands to hexadecimal. | |
10257 | ||
d77de738 ML |
10258 | @opindex Wdisabled-optimization |
10259 | @opindex Wno-disabled-optimization | |
ddf6fe37 | 10260 | @item -Wdisabled-optimization |
d77de738 ML |
10261 | Warn if a requested optimization pass is disabled. This warning does |
10262 | not generally indicate that there is anything wrong with your code; it | |
10263 | merely indicates that GCC's optimizers are unable to handle the code | |
10264 | effectively. Often, the problem is that your code is too big or too | |
10265 | complex; GCC refuses to optimize programs when the optimization | |
10266 | itself is likely to take inordinate amounts of time. | |
10267 | ||
d77de738 ML |
10268 | @opindex Wpointer-sign |
10269 | @opindex Wno-pointer-sign | |
ddf6fe37 | 10270 | @item -Wpointer-sign @r{(C and Objective-C only)} |
d77de738 ML |
10271 | Warn for pointer argument passing or assignment with different signedness. |
10272 | This option is only supported for C and Objective-C@. It is implied by | |
10273 | @option{-Wall} and by @option{-Wpedantic}, which can be disabled with | |
10274 | @option{-Wno-pointer-sign}. | |
10275 | ||
5fccebdb JM |
10276 | This warning is upgraded to an error by @option{-pedantic-errors}. |
10277 | ||
d77de738 ML |
10278 | @opindex Wstack-protector |
10279 | @opindex Wno-stack-protector | |
ddf6fe37 | 10280 | @item -Wstack-protector |
d77de738 ML |
10281 | This option is only active when @option{-fstack-protector} is active. It |
10282 | warns about functions that are not protected against stack smashing. | |
10283 | ||
d77de738 ML |
10284 | @opindex Woverlength-strings |
10285 | @opindex Wno-overlength-strings | |
ddf6fe37 | 10286 | @item -Woverlength-strings |
d77de738 ML |
10287 | Warn about string constants that are longer than the ``minimum |
10288 | maximum'' length specified in the C standard. Modern compilers | |
10289 | generally allow string constants that are much longer than the | |
10290 | standard's minimum limit, but very portable programs should avoid | |
10291 | using longer strings. | |
10292 | ||
10293 | The limit applies @emph{after} string constant concatenation, and does | |
10294 | not count the trailing NUL@. In C90, the limit was 509 characters; in | |
10295 | C99, it was raised to 4095. C++98 does not specify a normative | |
10296 | minimum maximum, so we do not diagnose overlength strings in C++@. | |
10297 | ||
10298 | This option is implied by @option{-Wpedantic}, and can be disabled with | |
10299 | @option{-Wno-overlength-strings}. | |
10300 | ||
d77de738 ML |
10301 | @opindex Wunsuffixed-float-constants |
10302 | @opindex Wno-unsuffixed-float-constants | |
ddf6fe37 | 10303 | @item -Wunsuffixed-float-constants @r{(C and Objective-C only)} |
d77de738 ML |
10304 | |
10305 | Issue a warning for any floating constant that does not have | |
10306 | a suffix. When used together with @option{-Wsystem-headers} it | |
10307 | warns about such constants in system header files. This can be useful | |
10308 | when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma | |
10309 | from the decimal floating-point extension to C99. | |
10310 | ||
d77de738 ML |
10311 | @opindex Wlto-type-mismatch |
10312 | @opindex Wno-lto-type-mismatch | |
ddf6fe37 | 10313 | @item -Wno-lto-type-mismatch |
d77de738 ML |
10314 | |
10315 | During the link-time optimization, do not warn about type mismatches in | |
10316 | global declarations from different compilation units. | |
10317 | Requires @option{-flto} to be enabled. Enabled by default. | |
10318 | ||
d77de738 ML |
10319 | @opindex Wdesignated-init |
10320 | @opindex Wno-designated-init | |
ddf6fe37 | 10321 | @item -Wno-designated-init @r{(C and Objective-C only)} |
d77de738 ML |
10322 | Suppress warnings when a positional initializer is used to initialize |
10323 | a structure that has been marked with the @code{designated_init} | |
10324 | attribute. | |
10325 | ||
10326 | @end table | |
10327 | ||
10328 | @node Static Analyzer Options | |
10329 | @section Options That Control Static Analysis | |
10330 | ||
10331 | @table @gcctabopt | |
d77de738 ML |
10332 | @opindex analyzer |
10333 | @opindex fanalyzer | |
10334 | @opindex fno-analyzer | |
ddf6fe37 | 10335 | @item -fanalyzer |
d77de738 ML |
10336 | This option enables an static analysis of program flow which looks |
10337 | for ``interesting'' interprocedural paths through the | |
10338 | code, and issues warnings for problems found on them. | |
10339 | ||
10340 | This analysis is much more expensive than other GCC warnings. | |
10341 | ||
a90316c6 DM |
10342 | In technical terms, it performs coverage-guided symbolic execution of |
10343 | the code being compiled. It is neither sound nor complete: it can | |
10344 | have false positives and false negatives. It is a bug-finding tool, | |
10345 | rather than a tool for proving program correctness. | |
10346 | ||
10347 | The analyzer is only suitable for use on C code in this release. | |
10348 | ||
d77de738 ML |
10349 | Enabling this option effectively enables the following warnings: |
10350 | ||
43b72ede AA |
10351 | @gccoptlist{ |
10352 | -Wanalyzer-allocation-size | |
10353 | -Wanalyzer-deref-before-check | |
10354 | -Wanalyzer-double-fclose | |
10355 | -Wanalyzer-double-free | |
10356 | -Wanalyzer-exposure-through-output-file | |
10357 | -Wanalyzer-exposure-through-uninit-copy | |
10358 | -Wanalyzer-fd-access-mode-mismatch | |
10359 | -Wanalyzer-fd-double-close | |
10360 | -Wanalyzer-fd-leak | |
10361 | -Wanalyzer-fd-phase-mismatch | |
10362 | -Wanalyzer-fd-type-mismatch | |
10363 | -Wanalyzer-fd-use-after-close | |
10364 | -Wanalyzer-fd-use-without-check | |
10365 | -Wanalyzer-file-leak | |
10366 | -Wanalyzer-free-of-non-heap | |
10367 | -Wanalyzer-imprecise-fp-arithmetic | |
10368 | -Wanalyzer-infinite-recursion | |
10369 | -Wanalyzer-jump-through-null | |
10370 | -Wanalyzer-malloc-leak | |
10371 | -Wanalyzer-mismatching-deallocation | |
10372 | -Wanalyzer-null-argument | |
10373 | -Wanalyzer-null-dereference | |
10374 | -Wanalyzer-out-of-bounds | |
034d99e8 | 10375 | -Wanalyzer-overlapping-buffers |
43b72ede AA |
10376 | -Wanalyzer-possible-null-argument |
10377 | -Wanalyzer-possible-null-dereference | |
10378 | -Wanalyzer-putenv-of-auto-var | |
10379 | -Wanalyzer-shift-count-negative | |
10380 | -Wanalyzer-shift-count-overflow | |
10381 | -Wanalyzer-stale-setjmp-buffer | |
10382 | -Wanalyzer-unsafe-call-within-signal-handler | |
10383 | -Wanalyzer-use-after-free | |
10384 | -Wanalyzer-use-of-pointer-in-stale-stack-frame | |
10385 | -Wanalyzer-use-of-uninitialized-value | |
10386 | -Wanalyzer-va-arg-type-mismatch | |
10387 | -Wanalyzer-va-list-exhausted | |
10388 | -Wanalyzer-va-list-leak | |
10389 | -Wanalyzer-va-list-use-after-va-end | |
10390 | -Wanalyzer-write-to-const | |
10391 | -Wanalyzer-write-to-string-literal | |
d77de738 ML |
10392 | } |
10393 | @ignore | |
43b72ede AA |
10394 | -Wanalyzer-tainted-allocation-size |
10395 | -Wanalyzer-tainted-array-index | |
10396 | -Wanalyzer-tainted-divisor | |
10397 | -Wanalyzer-tainted-offset | |
10398 | -Wanalyzer-tainted-size | |
d77de738 ML |
10399 | @end ignore |
10400 | ||
10401 | This option is only available if GCC was configured with analyzer | |
10402 | support enabled. | |
10403 | ||
d77de738 ML |
10404 | @opindex Wanalyzer-too-complex |
10405 | @opindex Wno-analyzer-too-complex | |
ddf6fe37 | 10406 | @item -Wanalyzer-too-complex |
d77de738 ML |
10407 | If @option{-fanalyzer} is enabled, the analyzer uses various heuristics |
10408 | to attempt to explore the control flow and data flow in the program, | |
10409 | but these can be defeated by sufficiently complicated code. | |
10410 | ||
10411 | By default, the analysis silently stops if the code is too | |
10412 | complicated for the analyzer to fully explore and it reaches an internal | |
10413 | limit. The @option{-Wanalyzer-too-complex} option warns if this occurs. | |
10414 | ||
d77de738 ML |
10415 | @opindex Wanalyzer-allocation-size |
10416 | @opindex Wno-analyzer-allocation-size | |
ddf6fe37 | 10417 | @item -Wno-analyzer-allocation-size |
4ace81b6 SL |
10418 | This warning requires @option{-fanalyzer}, which enables it; |
10419 | to disable it, use @option{-Wno-analyzer-allocation-size}. | |
d77de738 ML |
10420 | |
10421 | This diagnostic warns for paths through the code in which a pointer to | |
10422 | a buffer is assigned to point at a buffer with a size that is not a | |
10423 | multiple of @code{sizeof (*pointer)}. | |
10424 | ||
10425 | See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}. | |
10426 | ||
ce51e843 ML |
10427 | @opindex Wanalyzer-deref-before-check |
10428 | @opindex Wno-analyzer-deref-before-check | |
ddf6fe37 | 10429 | @item -Wno-analyzer-deref-before-check |
ce51e843 ML |
10430 | This warning requires @option{-fanalyzer}, which enables it; use |
10431 | @option{-Wno-analyzer-deref-before-check} | |
10432 | to disable it. | |
10433 | ||
10434 | This diagnostic warns for paths through the code in which a pointer | |
10435 | is checked for @code{NULL} *after* it has already been | |
10436 | dereferenced, suggesting that the pointer could have been NULL. | |
10437 | Such cases suggest that the check for NULL is either redundant, | |
10438 | or that it needs to be moved to before the pointer is dereferenced. | |
10439 | ||
10440 | This diagnostic also considers values passed to a function argument | |
10441 | marked with @code{__attribute__((nonnull))} as requiring a non-NULL | |
10442 | value, and thus will complain if such values are checked for @code{NULL} | |
10443 | after returning from such a function call. | |
10444 | ||
10445 | This diagnostic is unlikely to be reported when any level of optimization | |
10446 | is enabled, as GCC's optimization logic will typically consider such | |
10447 | checks for NULL as being redundant, and optimize them away before the | |
10448 | analyzer "sees" them. Hence optimization should be disabled when | |
10449 | attempting to trigger this diagnostic. | |
10450 | ||
d77de738 ML |
10451 | @opindex Wanalyzer-double-fclose |
10452 | @opindex Wno-analyzer-double-fclose | |
ddf6fe37 | 10453 | @item -Wno-analyzer-double-fclose |
d77de738 ML |
10454 | This warning requires @option{-fanalyzer}, which enables it; use |
10455 | @option{-Wno-analyzer-double-fclose} to disable it. | |
10456 | ||
10457 | This diagnostic warns for paths through the code in which a @code{FILE *} | |
10458 | can have @code{fclose} called on it more than once. | |
10459 | ||
10460 | See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}. | |
10461 | ||
d77de738 ML |
10462 | @opindex Wanalyzer-double-free |
10463 | @opindex Wno-analyzer-double-free | |
ddf6fe37 | 10464 | @item -Wno-analyzer-double-free |
d77de738 ML |
10465 | This warning requires @option{-fanalyzer}, which enables it; use |
10466 | @option{-Wno-analyzer-double-free} to disable it. | |
10467 | ||
10468 | This diagnostic warns for paths through the code in which a pointer | |
10469 | can have a deallocator called on it more than once, either @code{free}, | |
10470 | or a deallocator referenced by attribute @code{malloc}. | |
10471 | ||
10472 | See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}. | |
10473 | ||
d77de738 ML |
10474 | @opindex Wanalyzer-exposure-through-output-file |
10475 | @opindex Wno-analyzer-exposure-through-output-file | |
ddf6fe37 | 10476 | @item -Wno-analyzer-exposure-through-output-file |
d77de738 ML |
10477 | This warning requires @option{-fanalyzer}, which enables it; use |
10478 | @option{-Wno-analyzer-exposure-through-output-file} | |
10479 | to disable it. | |
10480 | ||
10481 | This diagnostic warns for paths through the code in which a | |
10482 | security-sensitive value is written to an output file | |
10483 | (such as writing a password to a log file). | |
10484 | ||
10485 | See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}. | |
10486 | ||
d77de738 ML |
10487 | @opindex Wanalyzer-exposure-through-uninit-copy |
10488 | @opindex Wno-analyzer-exposure-through-uninit-copy | |
ddf6fe37 | 10489 | @item -Wanalyzer-exposure-through-uninit-copy |
d77de738 ML |
10490 | This warning requires both @option{-fanalyzer} and the use of a plugin |
10491 | to specify a function that copies across a ``trust boundary''. Use | |
10492 | @option{-Wno-analyzer-exposure-through-uninit-copy} to disable it. | |
10493 | ||
10494 | This diagnostic warns for ``infoleaks'' - paths through the code in which | |
10495 | uninitialized values are copied across a security boundary | |
10496 | (such as code within an OS kernel that copies a partially-initialized | |
10497 | struct on the stack to user space). | |
10498 | ||
10499 | See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}. | |
10500 | ||
d77de738 ML |
10501 | @opindex Wanalyzer-fd-access-mode-mismatch |
10502 | @opindex Wno-analyzer-fd-access-mode-mismatch | |
ddf6fe37 | 10503 | @item -Wno-analyzer-fd-access-mode-mismatch |
d77de738 ML |
10504 | This warning requires @option{-fanalyzer}, which enables it; use |
10505 | @option{-Wno-analyzer-fd-access-mode-mismatch} | |
10506 | to disable it. | |
10507 | ||
10508 | This diagnostic warns for paths through code in which a | |
10509 | @code{read} on a write-only file descriptor is attempted, or vice versa. | |
10510 | ||
10511 | This diagnostic also warns for code paths in a which a function with attribute | |
10512 | @code{fd_arg_read (N)} is called with a file descriptor opened with | |
10513 | @code{O_WRONLY} at referenced argument @code{N} or a function with attribute | |
10514 | @code{fd_arg_write (N)} is called with a file descriptor opened with | |
10515 | @code{O_RDONLY} at referenced argument @var{N}. | |
10516 | ||
d77de738 ML |
10517 | @opindex Wanalyzer-fd-double-close |
10518 | @opindex Wno-analyzer-fd-double-close | |
ddf6fe37 | 10519 | @item -Wno-analyzer-fd-double-close |
d77de738 ML |
10520 | This warning requires @option{-fanalyzer}, which enables it; use |
10521 | @option{-Wno-analyzer-fd-double-close} | |
10522 | to disable it. | |
10523 | ||
10524 | This diagnostic warns for paths through code in which a | |
10525 | file descriptor can be closed more than once. | |
10526 | ||
10527 | See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}. | |
10528 | ||
d77de738 ML |
10529 | @opindex Wanalyzer-fd-leak |
10530 | @opindex Wno-analyzer-fd-leak | |
ddf6fe37 | 10531 | @item -Wno-analyzer-fd-leak |
d77de738 ML |
10532 | This warning requires @option{-fanalyzer}, which enables it; use |
10533 | @option{-Wno-analyzer-fd-leak} | |
10534 | to disable it. | |
10535 | ||
10536 | This diagnostic warns for paths through code in which an | |
10537 | open file descriptor is leaked. | |
10538 | ||
10539 | See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}. | |
10540 | ||
86a90006 DM |
10541 | @opindex Wanalyzer-fd-phase-mismatch |
10542 | @opindex Wno-analyzer-fd-phase-mismatch | |
ddf6fe37 | 10543 | @item -Wno-analyzer-fd-phase-mismatch |
86a90006 DM |
10544 | This warning requires @option{-fanalyzer}, which enables it; use |
10545 | @option{-Wno-analyzer-fd-phase-mismatch} | |
10546 | to disable it. | |
10547 | ||
10548 | This diagnostic warns for paths through code in which an operation is | |
10549 | attempted in the wrong phase of a file descriptor's lifetime. | |
10550 | For example, it will warn on attempts to call @code{accept} on a stream | |
10551 | socket that has not yet had @code{listen} successfully called on it. | |
10552 | ||
10553 | See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}. | |
10554 | ||
86a90006 DM |
10555 | @opindex Wanalyzer-fd-type-mismatch |
10556 | @opindex Wno-analyzer-fd-type-mismatch | |
ddf6fe37 | 10557 | @item -Wno-analyzer-fd-type-mismatch |
86a90006 DM |
10558 | This warning requires @option{-fanalyzer}, which enables it; use |
10559 | @option{-Wno-analyzer-fd-type-mismatch} | |
10560 | to disable it. | |
10561 | ||
10562 | This diagnostic warns for paths through code in which an | |
10563 | operation is attempted on the wrong type of file descriptor. | |
10564 | For example, it will warn on attempts to use socket operations | |
10565 | on a file descriptor obtained via @code{open}, or when attempting | |
10566 | to use a stream socket operation on a datagram socket. | |
10567 | ||
d77de738 ML |
10568 | @opindex Wanalyzer-fd-use-after-close |
10569 | @opindex Wno-analyzer-fd-use-after-close | |
ddf6fe37 | 10570 | @item -Wno-analyzer-fd-use-after-close |
d77de738 ML |
10571 | This warning requires @option{-fanalyzer}, which enables it; use |
10572 | @option{-Wno-analyzer-fd-use-after-close} | |
10573 | to disable it. | |
10574 | ||
10575 | This diagnostic warns for paths through code in which a | |
10576 | read or write is called on a closed file descriptor. | |
10577 | ||
10578 | This diagnostic also warns for paths through code in which | |
10579 | a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)} | |
10580 | or @code{fd_arg_write (N)} is called with a closed file descriptor at | |
10581 | referenced argument @code{N}. | |
10582 | ||
d77de738 ML |
10583 | @opindex Wanalyzer-fd-use-without-check |
10584 | @opindex Wno-analyzer-fd-use-without-check | |
ddf6fe37 | 10585 | @item -Wno-analyzer-fd-use-without-check |
d77de738 ML |
10586 | This warning requires @option{-fanalyzer}, which enables it; use |
10587 | @option{-Wno-analyzer-fd-use-without-check} | |
10588 | to disable it. | |
10589 | ||
10590 | This diagnostic warns for paths through code in which a | |
10591 | file descriptor is used without being checked for validity. | |
10592 | ||
10593 | This diagnostic also warns for paths through code in which | |
10594 | a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)} | |
10595 | or @code{fd_arg_write (N)} is called with a file descriptor, at referenced | |
10596 | argument @code{N}, without being checked for validity. | |
10597 | ||
d77de738 ML |
10598 | @opindex Wanalyzer-file-leak |
10599 | @opindex Wno-analyzer-file-leak | |
ddf6fe37 | 10600 | @item -Wno-analyzer-file-leak |
d77de738 ML |
10601 | This warning requires @option{-fanalyzer}, which enables it; use |
10602 | @option{-Wno-analyzer-file-leak} | |
10603 | to disable it. | |
10604 | ||
10605 | This diagnostic warns for paths through the code in which a | |
10606 | @code{<stdio.h>} @code{FILE *} stream object is leaked. | |
10607 | ||
10608 | See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}. | |
10609 | ||
d77de738 ML |
10610 | @opindex Wanalyzer-free-of-non-heap |
10611 | @opindex Wno-analyzer-free-of-non-heap | |
ddf6fe37 | 10612 | @item -Wno-analyzer-free-of-non-heap |
d77de738 ML |
10613 | This warning requires @option{-fanalyzer}, which enables it; use |
10614 | @option{-Wno-analyzer-free-of-non-heap} | |
10615 | to disable it. | |
10616 | ||
10617 | This diagnostic warns for paths through the code in which @code{free} | |
10618 | is called on a non-heap pointer (e.g. an on-stack buffer, or a global). | |
10619 | ||
10620 | See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}. | |
10621 | ||
d77de738 ML |
10622 | @opindex Wanalyzer-imprecise-fp-arithmetic |
10623 | @opindex Wno-analyzer-imprecise-fp-arithmetic | |
ddf6fe37 | 10624 | @item -Wno-analyzer-imprecise-fp-arithmetic |
d77de738 ML |
10625 | This warning requires @option{-fanalyzer}, which enables it; use |
10626 | @option{-Wno-analyzer-imprecise-fp-arithmetic} | |
10627 | to disable it. | |
10628 | ||
10629 | This diagnostic warns for paths through the code in which floating-point | |
10630 | arithmetic is used in locations where precise computation is needed. This | |
10631 | diagnostic only warns on use of floating-point operands inside the | |
10632 | calculation of an allocation size at the moment. | |
10633 | ||
ce51e843 ML |
10634 | @opindex Wanalyzer-infinite-recursion |
10635 | @opindex Wno-analyzer-infinite-recursion | |
ddf6fe37 | 10636 | @item -Wno-analyzer-infinite-recursion |
ce51e843 ML |
10637 | This warning requires @option{-fanalyzer}, which enables it; use |
10638 | @option{-Wno-analyzer-infinite-recursion} to disable it. | |
10639 | ||
10640 | This diagnostics warns for paths through the code which appear to | |
10641 | lead to infinite recursion. | |
10642 | ||
10643 | Specifically, when the analyzer "sees" a recursive call, it will compare | |
10644 | the state of memory at the entry to the new frame with that at the entry | |
10645 | to the previous frame of that function on the stack. The warning is | |
10646 | issued if nothing in memory appears to be changing; any changes observed | |
10647 | to parameters or globals are assumed to lead to termination of the | |
10648 | recursion and thus suppress the warning. | |
10649 | ||
10650 | This diagnostic is likely to miss cases of infinite recursion that | |
10651 | are convered to iteration by the optimizer before the analyzer "sees" | |
10652 | them. Hence optimization should be disabled when attempting to trigger | |
10653 | this diagnostic. | |
10654 | ||
10655 | Compare with @option{-Winfinite-recursion}, which provides a similar | |
10656 | diagnostic, but is implemented in a different way. | |
10657 | ||
d77de738 ML |
10658 | @opindex Wanalyzer-jump-through-null |
10659 | @opindex Wno-analyzer-jump-through-null | |
ddf6fe37 | 10660 | @item -Wno-analyzer-jump-through-null |
d77de738 ML |
10661 | This warning requires @option{-fanalyzer}, which enables it; use |
10662 | @option{-Wno-analyzer-jump-through-null} | |
10663 | to disable it. | |
10664 | ||
10665 | This diagnostic warns for paths through the code in which a @code{NULL} | |
10666 | function pointer is called. | |
10667 | ||
d77de738 ML |
10668 | @opindex Wanalyzer-malloc-leak |
10669 | @opindex Wno-analyzer-malloc-leak | |
ddf6fe37 | 10670 | @item -Wno-analyzer-malloc-leak |
d77de738 ML |
10671 | This warning requires @option{-fanalyzer}, which enables it; use |
10672 | @option{-Wno-analyzer-malloc-leak} | |
10673 | to disable it. | |
10674 | ||
10675 | This diagnostic warns for paths through the code in which a | |
10676 | pointer allocated via an allocator is leaked: either @code{malloc}, | |
10677 | or a function marked with attribute @code{malloc}. | |
10678 | ||
10679 | See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}. | |
10680 | ||
d77de738 ML |
10681 | @opindex Wanalyzer-mismatching-deallocation |
10682 | @opindex Wno-analyzer-mismatching-deallocation | |
ddf6fe37 | 10683 | @item -Wno-analyzer-mismatching-deallocation |
d77de738 ML |
10684 | This warning requires @option{-fanalyzer}, which enables it; use |
10685 | @option{-Wno-analyzer-mismatching-deallocation} | |
10686 | to disable it. | |
10687 | ||
10688 | This diagnostic warns for paths through the code in which the | |
10689 | wrong deallocation function is called on a pointer value, based on | |
10690 | which function was used to allocate the pointer value. The diagnostic | |
10691 | will warn about mismatches between @code{free}, scalar @code{delete} | |
10692 | and vector @code{delete[]}, and those marked as allocator/deallocator | |
10693 | pairs using attribute @code{malloc}. | |
10694 | ||
10695 | See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}. | |
10696 | ||
d77de738 ML |
10697 | @opindex Wanalyzer-out-of-bounds |
10698 | @opindex Wno-analyzer-out-of-bounds | |
ddf6fe37 | 10699 | @item -Wno-analyzer-out-of-bounds |
4ace81b6 | 10700 | This warning requires @option{-fanalyzer}, which enables it; use |
d77de738 ML |
10701 | @option{-Wno-analyzer-out-of-bounds} to disable it. |
10702 | ||
4ace81b6 | 10703 | This diagnostic warns for paths through the code in which a buffer is |
d77de738 ML |
10704 | definitely read or written out-of-bounds. The diagnostic applies for |
10705 | cases where the analyzer is able to determine a constant offset and for | |
10706 | accesses past the end of a buffer, also a constant capacity. Further, | |
10707 | the diagnostic does limited checking for accesses past the end when the | |
10708 | offset as well as the capacity is symbolic. | |
10709 | ||
10710 | See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}. | |
10711 | ||
0e466e97 DM |
10712 | For cases where the analyzer is able, it will emit a text art diagram |
10713 | visualizing the spatial relationship between the memory region that the | |
10714 | analyzer predicts would be accessed, versus the range of memory that is | |
10715 | valid to access: whether they overlap, are touching, are close or far | |
10716 | apart; which one is before or after in memory, the relative sizes | |
10717 | involved, the direction of the access (read vs write), and, in some | |
10718 | cases, the values of data involved. This diagram can be suppressed | |
10719 | using @option{-fdiagnostics-text-art-charset=none}. | |
10720 | ||
034d99e8 DM |
10721 | @opindex Wanalyzer-overlapping-buffers |
10722 | @opindex Wno-analyzer-overlapping-buffers | |
10723 | @item -Wno-analyzer-overlapping-buffers | |
10724 | This warning requires @option{-fanalyzer}, which enables it; use | |
10725 | @option{-Wno-analyzer-overlapping-buffers} to disable it. | |
10726 | ||
10727 | This diagnostic warns for paths through the code in which overlapping | |
10728 | buffers are passed to an API for which the behavior on such buffers | |
10729 | is undefined. | |
10730 | ||
10731 | Specifically, the diagnostic occurs on calls to the following functions | |
10732 | @itemize @bullet | |
10733 | @item @code{memcpy} | |
10734 | @item @code{strcat} | |
10735 | @item @code{strcpy} | |
10736 | @end itemize | |
10737 | for cases where the buffers are known to overlap. | |
10738 | ||
d77de738 ML |
10739 | @opindex Wanalyzer-possible-null-argument |
10740 | @opindex Wno-analyzer-possible-null-argument | |
ddf6fe37 | 10741 | @item -Wno-analyzer-possible-null-argument |
d77de738 ML |
10742 | This warning requires @option{-fanalyzer}, which enables it; use |
10743 | @option{-Wno-analyzer-possible-null-argument} to disable it. | |
10744 | ||
10745 | This diagnostic warns for paths through the code in which a | |
10746 | possibly-NULL value is passed to a function argument marked | |
10747 | with @code{__attribute__((nonnull))} as requiring a non-NULL | |
10748 | value. | |
10749 | ||
10750 | See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}. | |
10751 | ||
d77de738 ML |
10752 | @opindex Wanalyzer-possible-null-dereference |
10753 | @opindex Wno-analyzer-possible-null-dereference | |
ddf6fe37 | 10754 | @item -Wno-analyzer-possible-null-dereference |
d77de738 ML |
10755 | This warning requires @option{-fanalyzer}, which enables it; use |
10756 | @option{-Wno-analyzer-possible-null-dereference} to disable it. | |
10757 | ||
10758 | This diagnostic warns for paths through the code in which a | |
10759 | possibly-NULL value is dereferenced. | |
10760 | ||
10761 | See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}. | |
10762 | ||
d77de738 ML |
10763 | @opindex Wanalyzer-null-argument |
10764 | @opindex Wno-analyzer-null-argument | |
ddf6fe37 | 10765 | @item -Wno-analyzer-null-argument |
d77de738 ML |
10766 | This warning requires @option{-fanalyzer}, which enables it; use |
10767 | @option{-Wno-analyzer-null-argument} to disable it. | |
10768 | ||
10769 | This diagnostic warns for paths through the code in which a | |
10770 | value known to be NULL is passed to a function argument marked | |
10771 | with @code{__attribute__((nonnull))} as requiring a non-NULL | |
10772 | value. | |
10773 | ||
10774 | See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}. | |
10775 | ||
d77de738 ML |
10776 | @opindex Wanalyzer-null-dereference |
10777 | @opindex Wno-analyzer-null-dereference | |
ddf6fe37 | 10778 | @item -Wno-analyzer-null-dereference |
d77de738 ML |
10779 | This warning requires @option{-fanalyzer}, which enables it; use |
10780 | @option{-Wno-analyzer-null-dereference} to disable it. | |
10781 | ||
10782 | This diagnostic warns for paths through the code in which a | |
10783 | value known to be NULL is dereferenced. | |
10784 | ||
10785 | See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}. | |
10786 | ||
d77de738 ML |
10787 | @opindex Wanalyzer-putenv-of-auto-var |
10788 | @opindex Wno-analyzer-putenv-of-auto-var | |
ddf6fe37 | 10789 | @item -Wno-analyzer-putenv-of-auto-var |
d77de738 ML |
10790 | This warning requires @option{-fanalyzer}, which enables it; use |
10791 | @option{-Wno-analyzer-putenv-of-auto-var} to disable it. | |
10792 | ||
10793 | This diagnostic warns for paths through the code in which a | |
10794 | call to @code{putenv} is passed a pointer to an automatic variable | |
10795 | or an on-stack buffer. | |
10796 | ||
10797 | 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}. | |
10798 | ||
d77de738 ML |
10799 | @opindex Wanalyzer-shift-count-negative |
10800 | @opindex Wno-analyzer-shift-count-negative | |
ddf6fe37 | 10801 | @item -Wno-analyzer-shift-count-negative |
d77de738 ML |
10802 | This warning requires @option{-fanalyzer}, which enables it; use |
10803 | @option{-Wno-analyzer-shift-count-negative} to disable it. | |
10804 | ||
10805 | This diagnostic warns for paths through the code in which a | |
10806 | shift is attempted with a negative count. It is analogous to | |
10807 | the @option{-Wshift-count-negative} diagnostic implemented in | |
10808 | the C/C++ front ends, but is implemented based on analyzing | |
10809 | interprocedural paths, rather than merely parsing the syntax tree. | |
10810 | However, the analyzer does not prioritize detection of such paths, so | |
10811 | false negatives are more likely relative to other warnings. | |
10812 | ||
d77de738 ML |
10813 | @opindex Wanalyzer-shift-count-overflow |
10814 | @opindex Wno-analyzer-shift-count-overflow | |
ddf6fe37 | 10815 | @item -Wno-analyzer-shift-count-overflow |
d77de738 ML |
10816 | This warning requires @option{-fanalyzer}, which enables it; use |
10817 | @option{-Wno-analyzer-shift-count-overflow} to disable it. | |
10818 | ||
10819 | This diagnostic warns for paths through the code in which a | |
10820 | shift is attempted with a count greater than or equal to the | |
10821 | precision of the operand's type. It is analogous to | |
10822 | the @option{-Wshift-count-overflow} diagnostic implemented in | |
10823 | the C/C++ front ends, but is implemented based on analyzing | |
10824 | interprocedural paths, rather than merely parsing the syntax tree. | |
10825 | However, the analyzer does not prioritize detection of such paths, so | |
10826 | false negatives are more likely relative to other warnings. | |
10827 | ||
d77de738 ML |
10828 | @opindex Wanalyzer-stale-setjmp-buffer |
10829 | @opindex Wno-analyzer-stale-setjmp-buffer | |
ddf6fe37 | 10830 | @item -Wno-analyzer-stale-setjmp-buffer |
d77de738 ML |
10831 | This warning requires @option{-fanalyzer}, which enables it; use |
10832 | @option{-Wno-analyzer-stale-setjmp-buffer} to disable it. | |
10833 | ||
10834 | This diagnostic warns for paths through the code in which | |
10835 | @code{longjmp} is called to rewind to a @code{jmp_buf} relating | |
10836 | to a @code{setjmp} call in a function that has returned. | |
10837 | ||
10838 | When @code{setjmp} is called on a @code{jmp_buf} to record a rewind | |
10839 | location, it records the stack frame. The stack frame becomes invalid | |
10840 | when the function containing the @code{setjmp} call returns. Attempting | |
10841 | to rewind to it via @code{longjmp} would reference a stack frame that | |
10842 | no longer exists, and likely lead to a crash (or worse). | |
10843 | ||
d77de738 ML |
10844 | @opindex Wanalyzer-tainted-allocation-size |
10845 | @opindex Wno-analyzer-tainted-allocation-size | |
ddf6fe37 | 10846 | @item -Wno-analyzer-tainted-allocation-size |
d77de738 ML |
10847 | This warning requires both @option{-fanalyzer} and |
10848 | @option{-fanalyzer-checker=taint} to enable it; | |
10849 | use @option{-Wno-analyzer-tainted-allocation-size} to disable it. | |
10850 | ||
10851 | This diagnostic warns for paths through the code in which a value | |
10852 | that could be under an attacker's control is used as the size | |
10853 | of an allocation without being sanitized, so that an attacker could | |
10854 | inject an excessively large allocation and potentially cause a denial | |
10855 | of service attack. | |
10856 | ||
10857 | See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}. | |
10858 | ||
ce51e843 ML |
10859 | @opindex Wanalyzer-tainted-assertion |
10860 | @opindex Wno-analyzer-tainted-assertion | |
ddf6fe37 | 10861 | @item -Wno-analyzer-tainted-assertion |
ce51e843 ML |
10862 | |
10863 | This warning requires both @option{-fanalyzer} and | |
10864 | @option{-fanalyzer-checker=taint} to enable it; | |
10865 | use @option{-Wno-analyzer-tainted-assertion} to disable it. | |
10866 | ||
10867 | This diagnostic warns for paths through the code in which a value | |
10868 | that could be under an attacker's control is used as part of a | |
10869 | condition without being first sanitized, and that condition guards a | |
10870 | call to a function marked with attribute @code{noreturn} | |
10871 | (such as the function @code{__builtin_unreachable}). Such functions | |
10872 | typically indicate abnormal termination of the program, such as for | |
10873 | assertion failure handlers. For example: | |
10874 | ||
10875 | @smallexample | |
10876 | assert (some_tainted_value < SOME_LIMIT); | |
10877 | @end smallexample | |
10878 | ||
10879 | In such cases: | |
10880 | ||
10881 | @itemize | |
10882 | @item | |
10883 | when assertion-checking is enabled: an attacker could trigger | |
10884 | a denial of service by injecting an assertion failure | |
10885 | ||
10886 | @item | |
10887 | when assertion-checking is disabled, such as by defining @code{NDEBUG}, | |
10888 | an attacker could inject data that subverts the process, since it | |
10889 | presumably violates a precondition that is being assumed by the code. | |
10890 | ||
10891 | @end itemize | |
10892 | ||
10893 | Note that when assertion-checking is disabled, the assertions are | |
10894 | typically removed by the preprocessor before the analyzer has a chance | |
10895 | to "see" them, so this diagnostic can only generate warnings on builds | |
10896 | in which assertion-checking is enabled. | |
10897 | ||
10898 | For the purpose of this warning, any function marked with attribute | |
10899 | @code{noreturn} is considered as a possible assertion failure | |
10900 | handler, including @code{__builtin_unreachable}. Note that these functions | |
10901 | are sometimes removed by the optimizer before the analyzer "sees" them. | |
10902 | Hence optimization should be disabled when attempting to trigger this | |
10903 | diagnostic. | |
10904 | ||
10905 | See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}. | |
10906 | ||
10907 | The warning can also report problematic constructions such as | |
10908 | ||
10909 | @smallexample | |
10910 | switch (some_tainted_value) @{ | |
10911 | case 0: | |
10912 | /* [...etc; various valid cases omitted...] */ | |
10913 | break; | |
10914 | ||
10915 | default: | |
10916 | __builtin_unreachable (); /* BUG: attacker can trigger this */ | |
10917 | @} | |
10918 | @end smallexample | |
10919 | ||
10920 | despite the above not being an assertion failure, strictly speaking. | |
10921 | ||
d77de738 ML |
10922 | @opindex Wanalyzer-tainted-array-index |
10923 | @opindex Wno-analyzer-tainted-array-index | |
ddf6fe37 | 10924 | @item -Wno-analyzer-tainted-array-index |
d77de738 ML |
10925 | This warning requires both @option{-fanalyzer} and |
10926 | @option{-fanalyzer-checker=taint} to enable it; | |
10927 | use @option{-Wno-analyzer-tainted-array-index} to disable it. | |
10928 | ||
10929 | This diagnostic warns for paths through the code in which a value | |
10930 | that could be under an attacker's control is used as the index | |
10931 | of an array access without being sanitized, so that an attacker | |
10932 | could inject an out-of-bounds access. | |
10933 | ||
10934 | See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}. | |
10935 | ||
d77de738 ML |
10936 | @opindex Wanalyzer-tainted-divisor |
10937 | @opindex Wno-analyzer-tainted-divisor | |
ddf6fe37 | 10938 | @item -Wno-analyzer-tainted-divisor |
d77de738 ML |
10939 | This warning requires both @option{-fanalyzer} and |
10940 | @option{-fanalyzer-checker=taint} to enable it; | |
10941 | use @option{-Wno-analyzer-tainted-divisor} to disable it. | |
10942 | ||
10943 | This diagnostic warns for paths through the code in which a value | |
10944 | that could be under an attacker's control is used as the divisor | |
10945 | in a division or modulus operation without being sanitized, so that | |
10946 | an attacker could inject a division-by-zero. | |
10947 | ||
10948 | See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}. | |
10949 | ||
d77de738 ML |
10950 | @opindex Wanalyzer-tainted-offset |
10951 | @opindex Wno-analyzer-tainted-offset | |
ddf6fe37 | 10952 | @item -Wno-analyzer-tainted-offset |
d77de738 ML |
10953 | This warning requires both @option{-fanalyzer} and |
10954 | @option{-fanalyzer-checker=taint} to enable it; | |
10955 | use @option{-Wno-analyzer-tainted-offset} to disable it. | |
10956 | ||
10957 | This diagnostic warns for paths through the code in which a value | |
10958 | that could be under an attacker's control is used as a pointer offset | |
10959 | without being sanitized, so that an attacker could inject an out-of-bounds | |
10960 | access. | |
10961 | ||
10962 | See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}. | |
10963 | ||
d77de738 ML |
10964 | @opindex Wanalyzer-tainted-size |
10965 | @opindex Wno-analyzer-tainted-size | |
ddf6fe37 | 10966 | @item -Wno-analyzer-tainted-size |
d77de738 ML |
10967 | This warning requires both @option{-fanalyzer} and |
10968 | @option{-fanalyzer-checker=taint} to enable it; | |
10969 | use @option{-Wno-analyzer-tainted-size} to disable it. | |
10970 | ||
10971 | This diagnostic warns for paths through the code in which a value | |
10972 | that could be under an attacker's control is used as the size of | |
10973 | an operation such as @code{memset} without being sanitized, so that an | |
10974 | attacker could inject an out-of-bounds access. | |
10975 | ||
10976 | See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}. | |
10977 | ||
d77de738 ML |
10978 | @opindex Wanalyzer-unsafe-call-within-signal-handler |
10979 | @opindex Wno-analyzer-unsafe-call-within-signal-handler | |
ddf6fe37 | 10980 | @item -Wno-analyzer-unsafe-call-within-signal-handler |
d77de738 ML |
10981 | This warning requires @option{-fanalyzer}, which enables it; use |
10982 | @option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it. | |
10983 | ||
10984 | This diagnostic warns for paths through the code in which a | |
10985 | function known to be async-signal-unsafe (such as @code{fprintf}) is | |
10986 | called from a signal handler. | |
10987 | ||
10988 | See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}. | |
10989 | ||
d77de738 ML |
10990 | @opindex Wanalyzer-use-after-free |
10991 | @opindex Wno-analyzer-use-after-free | |
ddf6fe37 | 10992 | @item -Wno-analyzer-use-after-free |
d77de738 ML |
10993 | This warning requires @option{-fanalyzer}, which enables it; use |
10994 | @option{-Wno-analyzer-use-after-free} to disable it. | |
10995 | ||
10996 | This diagnostic warns for paths through the code in which a | |
10997 | pointer is used after a deallocator is called on it: either @code{free}, | |
10998 | or a deallocator referenced by attribute @code{malloc}. | |
10999 | ||
11000 | See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}. | |
11001 | ||
d77de738 ML |
11002 | @opindex Wanalyzer-use-of-pointer-in-stale-stack-frame |
11003 | @opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame | |
ddf6fe37 | 11004 | @item -Wno-analyzer-use-of-pointer-in-stale-stack-frame |
d77de738 ML |
11005 | This warning requires @option{-fanalyzer}, which enables it; use |
11006 | @option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame} | |
11007 | to disable it. | |
11008 | ||
11009 | This diagnostic warns for paths through the code in which a pointer | |
11010 | is dereferenced that points to a variable in a stale stack frame. | |
11011 | ||
d77de738 ML |
11012 | @opindex Wanalyzer-va-arg-type-mismatch |
11013 | @opindex Wno-analyzer-va-arg-type-mismatch | |
ddf6fe37 | 11014 | @item -Wno-analyzer-va-arg-type-mismatch |
d77de738 ML |
11015 | This warning requires @option{-fanalyzer}, which enables it; use |
11016 | @option{-Wno-analyzer-va-arg-type-mismatch} | |
11017 | to disable it. | |
11018 | ||
11019 | This diagnostic warns for interprocedural paths through the code for which | |
11020 | the analyzer detects an attempt to use @code{va_arg} to extract a value | |
11021 | passed to a variadic call, but uses a type that does not match that of | |
11022 | the expression passed to the call. | |
11023 | ||
11024 | See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}. | |
11025 | ||
d77de738 ML |
11026 | @opindex Wanalyzer-va-list-exhausted |
11027 | @opindex Wno-analyzer-va-list-exhausted | |
ddf6fe37 | 11028 | @item -Wno-analyzer-va-list-exhausted |
d77de738 ML |
11029 | This warning requires @option{-fanalyzer}, which enables it; use |
11030 | @option{-Wno-analyzer-va-list-exhausted} | |
11031 | to disable it. | |
11032 | ||
11033 | This diagnostic warns for interprocedural paths through the code for which | |
11034 | the analyzer detects an attempt to use @code{va_arg} to access the next | |
11035 | value passed to a variadic call, but all of the values in the | |
11036 | @code{va_list} have already been consumed. | |
11037 | ||
11038 | See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}. | |
11039 | ||
d77de738 ML |
11040 | @opindex Wanalyzer-va-list-leak |
11041 | @opindex Wno-analyzer-va-list-leak | |
ddf6fe37 | 11042 | @item -Wno-analyzer-va-list-leak |
d77de738 ML |
11043 | This warning requires @option{-fanalyzer}, which enables it; use |
11044 | @option{-Wno-analyzer-va-list-leak} | |
11045 | to disable it. | |
11046 | ||
11047 | This diagnostic warns for interprocedural paths through the code for which | |
11048 | the analyzer detects that @code{va_start} or @code{va_copy} has been called | |
11049 | on a @code{va_list} without a corresponding call to @code{va_end}. | |
11050 | ||
d77de738 ML |
11051 | @opindex Wanalyzer-va-list-use-after-va-end |
11052 | @opindex Wno-analyzer-va-list-use-after-va-end | |
ddf6fe37 | 11053 | @item -Wno-analyzer-va-list-use-after-va-end |
d77de738 ML |
11054 | This warning requires @option{-fanalyzer}, which enables it; use |
11055 | @option{-Wno-analyzer-va-list-use-after-va-end} | |
11056 | to disable it. | |
11057 | ||
11058 | This diagnostic warns for interprocedural paths through the code for which | |
11059 | the analyzer detects an attempt to use a @code{va_list} after | |
11060 | @code{va_end} has been called on it. | |
11061 | @code{va_list}. | |
11062 | ||
d77de738 ML |
11063 | @opindex Wanalyzer-write-to-const |
11064 | @opindex Wno-analyzer-write-to-const | |
ddf6fe37 | 11065 | @item -Wno-analyzer-write-to-const |
d77de738 ML |
11066 | This warning requires @option{-fanalyzer}, which enables it; use |
11067 | @option{-Wno-analyzer-write-to-const} | |
11068 | to disable it. | |
11069 | ||
11070 | This diagnostic warns for paths through the code in which the analyzer | |
11071 | detects an attempt to write through a pointer to a @code{const} object. | |
11072 | However, the analyzer does not prioritize detection of such paths, so | |
11073 | false negatives are more likely relative to other warnings. | |
11074 | ||
d77de738 ML |
11075 | @opindex Wanalyzer-write-to-string-literal |
11076 | @opindex Wno-analyzer-write-to-string-literal | |
ddf6fe37 | 11077 | @item -Wno-analyzer-write-to-string-literal |
d77de738 ML |
11078 | This warning requires @option{-fanalyzer}, which enables it; use |
11079 | @option{-Wno-analyzer-write-to-string-literal} | |
11080 | to disable it. | |
11081 | ||
11082 | This diagnostic warns for paths through the code in which the analyzer | |
11083 | detects an attempt to write through a pointer to a string literal. | |
11084 | However, the analyzer does not prioritize detection of such paths, so | |
11085 | false negatives are more likely relative to other warnings. | |
11086 | ||
d77de738 ML |
11087 | @opindex Wanalyzer-use-of-uninitialized-value |
11088 | @opindex Wno-analyzer-use-of-uninitialized-value | |
ddf6fe37 | 11089 | @item -Wno-analyzer-use-of-uninitialized-value |
d77de738 ML |
11090 | This warning requires @option{-fanalyzer}, which enables it; use |
11091 | @option{-Wno-analyzer-use-of-uninitialized-value} to disable it. | |
11092 | ||
11093 | This diagnostic warns for paths through the code in which an uninitialized | |
11094 | value is used. | |
11095 | ||
11096 | See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}. | |
11097 | ||
11098 | @end table | |
11099 | ||
11100 | The analyzer has hardcoded knowledge about the behavior of the following | |
11101 | memory-management functions: | |
11102 | ||
11103 | @itemize @bullet | |
11104 | @item @code{alloca} | |
11105 | @item The built-in functions @code{__builtin_alloc}, | |
11106 | @code{__builtin_alloc_with_align}, @item @code{__builtin_calloc}, | |
11107 | @code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy}, | |
11108 | @code{__builtin_memcpy_chk}, @code{__builtin_memset}, | |
11109 | @code{__builtin_memset_chk}, @code{__builtin_realloc}, | |
11110 | @code{__builtin_stack_restore}, and @code{__builtin_stack_save} | |
11111 | @item @code{calloc} | |
11112 | @item @code{free} | |
11113 | @item @code{malloc} | |
11114 | @item @code{memset} | |
11115 | @item @code{operator delete} | |
11116 | @item @code{operator delete []} | |
11117 | @item @code{operator new} | |
11118 | @item @code{operator new []} | |
11119 | @item @code{realloc} | |
11120 | @item @code{strdup} | |
11121 | @item @code{strndup} | |
11122 | @end itemize | |
11123 | ||
4ace81b6 | 11124 | @noindent |
d77de738 ML |
11125 | of the following functions for working with file descriptors: |
11126 | ||
11127 | @itemize @bullet | |
11128 | @item @code{open} | |
11129 | @item @code{close} | |
11130 | @item @code{creat} | |
11131 | @item @code{dup}, @code{dup2} and @code{dup3} | |
78a17f44 | 11132 | @item @code{isatty} |
d77de738 ML |
11133 | @item @code{pipe}, and @code{pipe2} |
11134 | @item @code{read} | |
11135 | @item @code{write} | |
86a90006 | 11136 | @item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect} |
d77de738 ML |
11137 | @end itemize |
11138 | ||
4ace81b6 | 11139 | @noindent |
d77de738 ML |
11140 | of the following functions for working with @code{<stdio.h>} streams: |
11141 | @itemize @bullet | |
11142 | @item The built-in functions @code{__builtin_fprintf}, | |
11143 | @code{__builtin_fprintf_unlocked}, @code{__builtin_fputc}, | |
11144 | @code{__builtin_fputc_unlocked}, @code{__builtin_fputs}, | |
11145 | @code{__builtin_fputs_unlocked}, @code{__builtin_fwrite}, | |
11146 | @code{__builtin_fwrite_unlocked}, @code{__builtin_printf}, | |
11147 | @code{__builtin_printf_unlocked}, @code{__builtin_putc}, | |
11148 | @code{__builtin_putchar}, @code{__builtin_putchar_unlocked}, | |
11149 | @code{__builtin_putc_unlocked}, @code{__builtin_puts}, | |
11150 | @code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and | |
11151 | @code{__builtin_vprintf} | |
11152 | @item @code{fopen} | |
11153 | @item @code{fclose} | |
78a17f44 | 11154 | @item @code{ferror} |
d77de738 ML |
11155 | @item @code{fgets} |
11156 | @item @code{fgets_unlocked} | |
78a17f44 | 11157 | @item @code{fileno} |
d77de738 | 11158 | @item @code{fread} |
78a17f44 | 11159 | @item @code{getc} |
d77de738 ML |
11160 | @item @code{getchar} |
11161 | @item @code{fprintf} | |
11162 | @item @code{printf} | |
11163 | @item @code{fwrite} | |
11164 | @end itemize | |
11165 | ||
4ace81b6 | 11166 | @noindent |
d77de738 ML |
11167 | and of the following functions: |
11168 | ||
11169 | @itemize @bullet | |
11170 | @item The built-in functions @code{__builtin_expect}, | |
11171 | @code{__builtin_expect_with_probability}, @code{__builtin_strchr}, | |
11172 | @code{__builtin_strcpy}, @code{__builtin_strcpy_chk}, | |
11173 | @code{__builtin_strlen}, @code{__builtin_va_copy}, and | |
11174 | @code{__builtin_va_start} | |
11175 | @item The GNU extensions @code{error} and @code{error_at_line} | |
11176 | @item @code{getpass} | |
11177 | @item @code{longjmp} | |
11178 | @item @code{putenv} | |
11179 | @item @code{setjmp} | |
11180 | @item @code{siglongjmp} | |
11181 | @item @code{signal} | |
11182 | @item @code{sigsetjmp} | |
bbdc0e0d | 11183 | @item @code{strcat} |
d77de738 ML |
11184 | @item @code{strchr} |
11185 | @item @code{strlen} | |
11186 | @end itemize | |
11187 | ||
11188 | In addition, various functions with an @code{__analyzer_} prefix have | |
11189 | special meaning to the analyzer, described in the GCC Internals manual. | |
11190 | ||
11191 | Pertinent parameters for controlling the exploration are: | |
4ace81b6 SL |
11192 | @itemize @bullet |
11193 | @item @option{--param analyzer-bb-explosion-factor=@var{value}} | |
11194 | @item @option{--param analyzer-max-enodes-per-program-point=@var{value}} | |
11195 | @item @option{--param analyzer-max-recursion-depth=@var{value}} | |
11196 | @item @option{--param analyzer-min-snodes-for-call-summary=@var{value}} | |
11197 | @end itemize | |
d77de738 ML |
11198 | |
11199 | The following options control the analyzer. | |
11200 | ||
11201 | @table @gcctabopt | |
11202 | ||
d77de738 ML |
11203 | @opindex fanalyzer-call-summaries |
11204 | @opindex fno-analyzer-call-summaries | |
ddf6fe37 | 11205 | @item -fanalyzer-call-summaries |
d77de738 ML |
11206 | Simplify interprocedural analysis by computing the effect of certain calls, |
11207 | rather than exploring all paths through the function from callsite to each | |
11208 | possible return. | |
11209 | ||
11210 | If enabled, call summaries are only used for functions with more than one | |
11211 | call site, and that are sufficiently complicated (as per | |
11212 | @option{--param analyzer-min-snodes-for-call-summary=@var{value}}). | |
11213 | ||
d77de738 | 11214 | @opindex fanalyzer-checker |
ddf6fe37 | 11215 | @item -fanalyzer-checker=@var{name} |
d77de738 ML |
11216 | Restrict the analyzer to run just the named checker, and enable it. |
11217 | ||
11218 | Some checkers are disabled by default (even with @option{-fanalyzer}), | |
11219 | such as the @code{taint} checker that implements | |
11220 | @option{-Wanalyzer-tainted-array-index}, and this option is required | |
11221 | to enable them. | |
11222 | ||
11223 | @emph{Note:} currently, @option{-fanalyzer-checker=taint} disables the | |
11224 | following warnings from @option{-fanalyzer}: | |
11225 | ||
43b72ede AA |
11226 | @gccoptlist{ |
11227 | -Wanalyzer-deref-before-check | |
11228 | -Wanalyzer-double-fclose | |
11229 | -Wanalyzer-double-free | |
11230 | -Wanalyzer-exposure-through-output-file | |
11231 | -Wanalyzer-fd-access-mode-mismatch | |
11232 | -Wanalyzer-fd-double-close | |
11233 | -Wanalyzer-fd-leak | |
11234 | -Wanalyzer-fd-use-after-close | |
11235 | -Wanalyzer-fd-use-without-check | |
11236 | -Wanalyzer-file-leak | |
11237 | -Wanalyzer-free-of-non-heap | |
11238 | -Wanalyzer-malloc-leak | |
11239 | -Wanalyzer-mismatching-deallocation | |
11240 | -Wanalyzer-null-argument | |
11241 | -Wanalyzer-null-dereference | |
11242 | -Wanalyzer-possible-null-argument | |
11243 | -Wanalyzer-possible-null-dereference | |
11244 | -Wanalyzer-unsafe-call-within-signal-handler | |
11245 | -Wanalyzer-use-after-free | |
11246 | -Wanalyzer-va-list-leak | |
11247 | -Wanalyzer-va-list-use-after-va-end | |
d77de738 ML |
11248 | } |
11249 | ||
0e466e97 DM |
11250 | @opindex fanalyzer-debug-text-art |
11251 | @opindex fno-analyzer-debug-text-art | |
11252 | @item -fanalyzer-debug-text-art-headings | |
11253 | This option is intended for analyzer developers. If enabled, | |
11254 | the analyzer will add extra annotations to any diagrams it generates. | |
11255 | ||
d77de738 ML |
11256 | @opindex fanalyzer-feasibility |
11257 | @opindex fno-analyzer-feasibility | |
ddf6fe37 | 11258 | @item -fno-analyzer-feasibility |
d77de738 ML |
11259 | This option is intended for analyzer developers. |
11260 | ||
11261 | By default the analyzer verifies that there is a feasible control flow path | |
11262 | for each diagnostic it emits: that the conditions that hold are not mutually | |
11263 | exclusive. Diagnostics for which no feasible path can be found are rejected. | |
11264 | This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for | |
11265 | debugging issues in this code. | |
11266 | ||
d77de738 ML |
11267 | @opindex fanalyzer-fine-grained |
11268 | @opindex fno-analyzer-fine-grained | |
ddf6fe37 | 11269 | @item -fanalyzer-fine-grained |
d77de738 ML |
11270 | This option is intended for analyzer developers. |
11271 | ||
11272 | Internally the analyzer builds an ``exploded graph'' that combines | |
11273 | control flow graphs with data flow information. | |
11274 | ||
11275 | By default, an edge in this graph can contain the effects of a run | |
11276 | of multiple statements within a basic block. With | |
11277 | @option{-fanalyzer-fine-grained}, each statement gets its own edge. | |
11278 | ||
d77de738 ML |
11279 | @opindex fanalyzer-show-duplicate-count |
11280 | @opindex fno-analyzer-show-duplicate-count | |
ddf6fe37 | 11281 | @item -fanalyzer-show-duplicate-count |
d77de738 ML |
11282 | This option is intended for analyzer developers: if multiple diagnostics |
11283 | have been detected as being duplicates of each other, it emits a note when | |
11284 | reporting the best diagnostic, giving the number of additional diagnostics | |
11285 | that were suppressed by the deduplication logic. | |
11286 | ||
ce8cdf5b | 11287 | @opindex fanalyzer-show-events-in-system-headers |
11288 | @opindex fno-analyzer-show-events-in-system-headers | |
11289 | @item -fanalyzer-show-events-in-system-headers | |
11290 | By default the analyzer emits simplified diagnostics paths by hiding | |
11291 | events fully located within a system header. | |
11292 | With @option{-fanalyzer-show-events-in-system-headers} such | |
11293 | events are no longer suppressed. | |
11294 | ||
d77de738 ML |
11295 | @opindex fanalyzer-state-merge |
11296 | @opindex fno-analyzer-state-merge | |
ddf6fe37 | 11297 | @item -fno-analyzer-state-merge |
d77de738 ML |
11298 | This option is intended for analyzer developers. |
11299 | ||
11300 | By default the analyzer attempts to simplify analysis by merging | |
11301 | sufficiently similar states at each program point as it builds its | |
11302 | ``exploded graph''. With @option{-fno-analyzer-state-merge} this | |
11303 | merging can be suppressed, for debugging state-handling issues. | |
11304 | ||
d77de738 ML |
11305 | @opindex fanalyzer-state-purge |
11306 | @opindex fno-analyzer-state-purge | |
ddf6fe37 | 11307 | @item -fno-analyzer-state-purge |
d77de738 ML |
11308 | This option is intended for analyzer developers. |
11309 | ||
11310 | By default the analyzer attempts to simplify analysis by purging | |
11311 | aspects of state at a program point that appear to no longer be relevant | |
11312 | e.g. the values of locals that aren't accessed later in the function | |
11313 | and which aren't relevant to leak analysis. | |
11314 | ||
11315 | With @option{-fno-analyzer-state-purge} this purging of state can | |
11316 | be suppressed, for debugging state-handling issues. | |
11317 | ||
8f636915 DM |
11318 | @opindex fanalyzer-suppress-followups |
11319 | @opindex fno-analyzer-suppress-followups | |
f33d7a88 | 11320 | @item -fno-analyzer-suppress-followups |
8f636915 DM |
11321 | This option is intended for analyzer developers. |
11322 | ||
11323 | By default the analyzer will stop exploring an execution path after | |
11324 | encountering certain diagnostics, in order to avoid potentially issuing a | |
11325 | cascade of follow-up diagnostics. | |
11326 | ||
11327 | The diagnostics that terminate analysis along a path are: | |
11328 | ||
11329 | @itemize | |
11330 | @item @option{-Wanalyzer-null-argument} | |
11331 | @item @option{-Wanalyzer-null-dereference} | |
11332 | @item @option{-Wanalyzer-use-after-free} | |
11333 | @item @option{-Wanalyzer-use-of-pointer-in-stale-stack-frame} | |
11334 | @item @option{-Wanalyzer-use-of-uninitialized-value} | |
11335 | @end itemize | |
11336 | ||
11337 | With @option{-fno-analyzer-suppress-followups} the analyzer will | |
11338 | continue to explore such paths even after such diagnostics, which may | |
11339 | be helpful for debugging issues in the analyzer, or for microbenchmarks | |
11340 | for detecting undefined behavior. | |
11341 | ||
d77de738 ML |
11342 | @opindex fanalyzer-transitivity |
11343 | @opindex fno-analyzer-transitivity | |
ddf6fe37 | 11344 | @item -fanalyzer-transitivity |
d77de738 ML |
11345 | This option enables transitivity of constraints within the analyzer. |
11346 | ||
d77de738 ML |
11347 | @opindex fanalyzer-undo-inlining |
11348 | @opindex fno-analyzer-undo-inlining | |
ddf6fe37 | 11349 | @item -fno-analyzer-undo-inlining |
d77de738 ML |
11350 | This option is intended for analyzer developers. |
11351 | ||
11352 | @option{-fanalyzer} runs relatively late compared to other code analysis | |
11353 | tools, and some optimizations have already been applied to the code. In | |
11354 | particular function inlining may have occurred, leading to the | |
11355 | interprocedural execution paths emitted by the analyzer containing | |
11356 | function frames that don't correspond to those in the original source | |
11357 | code. | |
11358 | ||
11359 | By default the analyzer attempts to reconstruct the original function | |
11360 | frames, and to emit events showing the inlined calls. | |
11361 | ||
11362 | With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct | |
11363 | the original frame information can be be disabled, which may be of help | |
11364 | when debugging issues in the analyzer. | |
11365 | ||
11366 | @item -fanalyzer-verbose-edges | |
11367 | This option is intended for analyzer developers. It enables more | |
11368 | verbose, lower-level detail in the descriptions of control flow | |
11369 | within diagnostic paths. | |
11370 | ||
11371 | @item -fanalyzer-verbose-state-changes | |
11372 | This option is intended for analyzer developers. It enables more | |
11373 | verbose, lower-level detail in the descriptions of events relating | |
11374 | to state machines within diagnostic paths. | |
11375 | ||
11376 | @item -fanalyzer-verbosity=@var{level} | |
11377 | This option controls the complexity of the control flow paths that are | |
11378 | emitted for analyzer diagnostics. | |
11379 | ||
11380 | The @var{level} can be one of: | |
11381 | ||
11382 | @table @samp | |
11383 | @item 0 | |
11384 | At this level, interprocedural call and return events are displayed, | |
11385 | along with the most pertinent state-change events relating to | |
11386 | a diagnostic. For example, for a double-@code{free} diagnostic, | |
11387 | both calls to @code{free} will be shown. | |
11388 | ||
11389 | @item 1 | |
11390 | As per the previous level, but also show events for the entry | |
11391 | to each function. | |
11392 | ||
11393 | @item 2 | |
11394 | As per the previous level, but also show events relating to | |
11395 | control flow that are significant to triggering the issue | |
11396 | (e.g. ``true path taken'' at a conditional). | |
11397 | ||
11398 | This level is the default. | |
11399 | ||
11400 | @item 3 | |
11401 | As per the previous level, but show all control flow events, not | |
11402 | just significant ones. | |
11403 | ||
11404 | @item 4 | |
11405 | This level is intended for analyzer developers; it adds various | |
11406 | other events intended for debugging the analyzer. | |
11407 | ||
11408 | @end table | |
11409 | ||
d77de738 | 11410 | @opindex fdump-analyzer |
ddf6fe37 | 11411 | @item -fdump-analyzer |
d77de738 ML |
11412 | Dump internal details about what the analyzer is doing to |
11413 | @file{@var{file}.analyzer.txt}. | |
4ace81b6 | 11414 | @option{-fdump-analyzer-stderr} overrides this option. |
d77de738 | 11415 | |
d77de738 | 11416 | @opindex fdump-analyzer-stderr |
ddf6fe37 | 11417 | @item -fdump-analyzer-stderr |
d77de738 ML |
11418 | Dump internal details about what the analyzer is doing to stderr. |
11419 | This option overrides @option{-fdump-analyzer}. | |
11420 | ||
d77de738 | 11421 | @opindex fdump-analyzer-callgraph |
ddf6fe37 | 11422 | @item -fdump-analyzer-callgraph |
d77de738 ML |
11423 | Dump a representation of the call graph suitable for viewing with |
11424 | GraphViz to @file{@var{file}.callgraph.dot}. | |
11425 | ||
d77de738 | 11426 | @opindex fdump-analyzer-exploded-graph |
ddf6fe37 | 11427 | @item -fdump-analyzer-exploded-graph |
d77de738 ML |
11428 | Dump a representation of the ``exploded graph'' suitable for viewing with |
11429 | GraphViz to @file{@var{file}.eg.dot}. | |
11430 | Nodes are color-coded based on state-machine states to emphasize | |
11431 | state changes. | |
11432 | ||
d77de738 | 11433 | @opindex dump-analyzer-exploded-nodes |
ddf6fe37 | 11434 | @item -fdump-analyzer-exploded-nodes |
d77de738 ML |
11435 | Emit diagnostics showing where nodes in the ``exploded graph'' are |
11436 | in relation to the program source. | |
11437 | ||
d77de738 | 11438 | @opindex dump-analyzer-exploded-nodes-2 |
ddf6fe37 | 11439 | @item -fdump-analyzer-exploded-nodes-2 |
d77de738 ML |
11440 | Dump a textual representation of the ``exploded graph'' to |
11441 | @file{@var{file}.eg.txt}. | |
11442 | ||
d77de738 | 11443 | @opindex dump-analyzer-exploded-nodes-3 |
ddf6fe37 | 11444 | @item -fdump-analyzer-exploded-nodes-3 |
d77de738 ML |
11445 | Dump a textual representation of the ``exploded graph'' to |
11446 | one dump file per node, to @file{@var{file}.eg-@var{id}.txt}. | |
11447 | This is typically a large number of dump files. | |
11448 | ||
d77de738 | 11449 | @opindex fdump-analyzer-exploded-paths |
ddf6fe37 | 11450 | @item -fdump-analyzer-exploded-paths |
d77de738 ML |
11451 | Dump a textual representation of the ``exploded path'' for each |
11452 | diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}. | |
11453 | ||
d77de738 | 11454 | @opindex dump-analyzer-feasibility |
ddf6fe37 | 11455 | @item -fdump-analyzer-feasibility |
d77de738 ML |
11456 | Dump internal details about the analyzer's search for feasible paths. |
11457 | The details are written in a form suitable for viewing with GraphViz | |
11458 | to filenames of the form @file{@var{file}.*.fg.dot}, | |
11459 | @file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}. | |
11460 | ||
d77de738 | 11461 | @opindex fdump-analyzer-json |
ddf6fe37 | 11462 | @item -fdump-analyzer-json |
d77de738 ML |
11463 | Dump a compressed JSON representation of analyzer internals to |
11464 | @file{@var{file}.analyzer.json.gz}. The precise format is subject | |
11465 | to change. | |
11466 | ||
d77de738 | 11467 | @opindex fdump-analyzer-state-purge |
ddf6fe37 | 11468 | @item -fdump-analyzer-state-purge |
d77de738 ML |
11469 | As per @option{-fdump-analyzer-supergraph}, dump a representation of the |
11470 | ``supergraph'' suitable for viewing with GraphViz, but annotate the | |
11471 | graph with information on what state will be purged at each node. | |
11472 | The graph is written to @file{@var{file}.state-purge.dot}. | |
11473 | ||
d77de738 | 11474 | @opindex fdump-analyzer-supergraph |
ddf6fe37 | 11475 | @item -fdump-analyzer-supergraph |
d77de738 ML |
11476 | Dump representations of the ``supergraph'' suitable for viewing with |
11477 | GraphViz to @file{@var{file}.supergraph.dot} and to | |
11478 | @file{@var{file}.supergraph-eg.dot}. These show all of the | |
11479 | control flow graphs in the program, with interprocedural edges for | |
11480 | calls and returns. The second dump contains annotations showing nodes | |
11481 | in the ``exploded graph'' and diagnostics associated with them. | |
11482 | ||
d77de738 | 11483 | @opindex fdump-analyzer-untracked |
ddf6fe37 | 11484 | @item -fdump-analyzer-untracked |
d77de738 ML |
11485 | Emit custom warnings with internal details intended for analyzer developers. |
11486 | ||
11487 | @end table | |
11488 | ||
11489 | @node Debugging Options | |
11490 | @section Options for Debugging Your Program | |
11491 | @cindex options, debugging | |
11492 | @cindex debugging information options | |
11493 | ||
11494 | To tell GCC to emit extra information for use by a debugger, in almost | |
11495 | all cases you need only to add @option{-g} to your other options. Some debug | |
11496 | formats can co-exist (like DWARF with CTF) when each of them is enabled | |
11497 | explicitly by adding the respective command line option to your other options. | |
11498 | ||
11499 | GCC allows you to use @option{-g} with | |
11500 | @option{-O}. The shortcuts taken by optimized code may occasionally | |
11501 | be surprising: some variables you declared may not exist | |
11502 | at all; flow of control may briefly move where you did not expect it; | |
11503 | some statements may not be executed because they compute constant | |
11504 | results or their values are already at hand; some statements may | |
11505 | execute in different places because they have been moved out of loops. | |
11506 | Nevertheless it is possible to debug optimized output. This makes | |
11507 | it reasonable to use the optimizer for programs that might have bugs. | |
11508 | ||
11509 | If you are not using some other optimization option, consider | |
11510 | using @option{-Og} (@pxref{Optimize Options}) with @option{-g}. | |
11511 | With no @option{-O} option at all, some compiler passes that collect | |
11512 | information useful for debugging do not run at all, so that | |
11513 | @option{-Og} may result in a better debugging experience. | |
11514 | ||
11515 | @table @gcctabopt | |
d77de738 | 11516 | @opindex g |
ddf6fe37 | 11517 | @item -g |
d77de738 ML |
11518 | Produce debugging information in the operating system's native format |
11519 | (stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging | |
11520 | information. | |
11521 | ||
11522 | On most systems that use stabs format, @option{-g} enables use of extra | |
11523 | debugging information that only GDB can use; this extra information | |
11524 | makes debugging work better in GDB but probably makes other debuggers | |
11525 | crash or refuse to read the program. If you want to control for certain whether | |
11526 | to generate the extra information, use @option{-gvms} (see below). | |
11527 | ||
d77de738 | 11528 | @opindex ggdb |
ddf6fe37 | 11529 | @item -ggdb |
d77de738 ML |
11530 | Produce debugging information for use by GDB@. This means to use the |
11531 | most expressive format available (DWARF, stabs, or the native format | |
11532 | if neither of those are supported), including GDB extensions if at all | |
11533 | possible. | |
11534 | ||
ddf6fe37 | 11535 | @opindex gdwarf |
d77de738 ML |
11536 | @item -gdwarf |
11537 | @itemx -gdwarf-@var{version} | |
d77de738 ML |
11538 | Produce debugging information in DWARF format (if that is supported). |
11539 | The value of @var{version} may be either 2, 3, 4 or 5; the default | |
11540 | version for most targets is 5 (with the exception of VxWorks, TPF and | |
a335cf24 | 11541 | Darwin / macOS, which default to version 2, and AIX, which defaults |
d77de738 ML |
11542 | to version 4). |
11543 | ||
11544 | Note that with DWARF Version 2, some ports require and always | |
11545 | use some non-conflicting DWARF 3 extensions in the unwind tables. | |
11546 | ||
11547 | Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments} | |
11548 | for maximum benefit. Version 5 requires GDB 8.0 or higher. | |
11549 | ||
11550 | GCC no longer supports DWARF Version 1, which is substantially | |
11551 | different than Version 2 and later. For historical reasons, some | |
11552 | other DWARF-related options such as | |
11553 | @option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2 | |
11554 | in their names, but apply to all currently-supported versions of DWARF. | |
11555 | ||
d77de738 | 11556 | @opindex gbtf |
ddf6fe37 | 11557 | @item -gbtf |
d77de738 ML |
11558 | Request BTF debug information. BTF is the default debugging format for the |
11559 | eBPF target. On other targets, like x86, BTF debug information can be | |
11560 | generated along with DWARF debug information when both of the debug formats are | |
11561 | enabled explicitly via their respective command line options. | |
11562 | ||
ddf6fe37 | 11563 | @opindex gctf |
d77de738 ML |
11564 | @item -gctf |
11565 | @itemx -gctf@var{level} | |
d77de738 ML |
11566 | Request CTF debug information and use level to specify how much CTF debug |
11567 | information should be produced. If @option{-gctf} is specified | |
11568 | without a value for level, the default level of CTF debug information is 2. | |
11569 | ||
11570 | CTF debug information can be generated along with DWARF debug information when | |
11571 | both of the debug formats are enabled explicitly via their respective command | |
11572 | line options. | |
11573 | ||
11574 | Level 0 produces no CTF debug information at all. Thus, @option{-gctf0} | |
11575 | negates @option{-gctf}. | |
11576 | ||
11577 | Level 1 produces CTF information for tracebacks only. This includes callsite | |
11578 | information, but does not include type information. | |
11579 | ||
11580 | Level 2 produces type information for entities (functions, data objects etc.) | |
11581 | at file-scope or global-scope only. | |
11582 | ||
d77de738 | 11583 | @opindex gvms |
ddf6fe37 | 11584 | @item -gvms |
d77de738 ML |
11585 | Produce debugging information in Alpha/VMS debug format (if that is |
11586 | supported). This is the format used by DEBUG on Alpha/VMS systems. | |
11587 | ||
2f7e7bfa MH |
11588 | @item -gcodeview |
11589 | @opindex gcodeview | |
11590 | Produce debugging information in CodeView debug format (if that is | |
11591 | supported). This is the format used by Microsoft Visual C++ on | |
11592 | Windows. | |
11593 | ||
d77de738 ML |
11594 | @item -g@var{level} |
11595 | @itemx -ggdb@var{level} | |
11596 | @itemx -gvms@var{level} | |
11597 | Request debugging information and also use @var{level} to specify how | |
11598 | much information. The default level is 2. | |
11599 | ||
11600 | Level 0 produces no debug information at all. Thus, @option{-g0} negates | |
11601 | @option{-g}. | |
11602 | ||
11603 | Level 1 produces minimal information, enough for making backtraces in | |
11604 | parts of the program that you don't plan to debug. This includes | |
11605 | descriptions of functions and external variables, and line number | |
11606 | tables, but no information about local variables. | |
11607 | ||
11608 | Level 3 includes extra information, such as all the macro definitions | |
11609 | present in the program. Some debuggers support macro expansion when | |
11610 | you use @option{-g3}. | |
11611 | ||
11612 | If you use multiple @option{-g} options, with or without level numbers, | |
11613 | the last such option is the one that is effective. | |
11614 | ||
11615 | @option{-gdwarf} does not accept a concatenated debug level, to avoid | |
11616 | confusion with @option{-gdwarf-@var{level}}. | |
11617 | Instead use an additional @option{-g@var{level}} option to change the | |
11618 | debug level for DWARF. | |
11619 | ||
d77de738 ML |
11620 | @opindex feliminate-unused-debug-symbols |
11621 | @opindex fno-eliminate-unused-debug-symbols | |
ddf6fe37 | 11622 | @item -fno-eliminate-unused-debug-symbols |
d77de738 ML |
11623 | By default, no debug information is produced for symbols that are not actually |
11624 | used. Use this option if you want debug information for all symbols. | |
11625 | ||
d77de738 | 11626 | @opindex femit-class-debug-always |
ddf6fe37 | 11627 | @item -femit-class-debug-always |
d77de738 ML |
11628 | Instead of emitting debugging information for a C++ class in only one |
11629 | object file, emit it in all object files using the class. This option | |
11630 | should be used only with debuggers that are unable to handle the way GCC | |
11631 | normally emits debugging information for classes because using this | |
11632 | option increases the size of debugging information by as much as a | |
11633 | factor of two. | |
11634 | ||
d77de738 ML |
11635 | @opindex fmerge-debug-strings |
11636 | @opindex fno-merge-debug-strings | |
ddf6fe37 | 11637 | @item -fno-merge-debug-strings |
d77de738 ML |
11638 | Direct the linker to not merge together strings in the debugging |
11639 | information that are identical in different object files. Merging is | |
11640 | not supported by all assemblers or linkers. Merging decreases the size | |
11641 | of the debug information in the output file at the cost of increasing | |
11642 | link processing time. Merging is enabled by default. | |
11643 | ||
d77de738 | 11644 | @opindex fdebug-prefix-map |
ddf6fe37 | 11645 | @item -fdebug-prefix-map=@var{old}=@var{new} |
d77de738 ML |
11646 | When compiling files residing in directory @file{@var{old}}, record |
11647 | debugging information describing them as if the files resided in | |
11648 | directory @file{@var{new}} instead. This can be used to replace a | |
11649 | build-time path with an install-time path in the debug info. It can | |
11650 | also be used to change an absolute path to a relative path by using | |
11651 | @file{.} for @var{new}. This can give more reproducible builds, which | |
11652 | are location independent, but may require an extra command to tell GDB | |
2eb0191a JJ |
11653 | where to find the source files. See also @option{-ffile-prefix-map} |
11654 | and @option{-fcanon-prefix-map}. | |
d77de738 | 11655 | |
d77de738 | 11656 | @opindex fvar-tracking |
ddf6fe37 | 11657 | @item -fvar-tracking |
d77de738 ML |
11658 | Run variable tracking pass. It computes where variables are stored at each |
11659 | position in code. Better debugging information is then generated | |
11660 | (if the debugging information format supports this information). | |
11661 | ||
11662 | It is enabled by default when compiling with optimization (@option{-Os}, | |
11663 | @option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and | |
11664 | the debug info format supports it. | |
11665 | ||
d77de738 ML |
11666 | @opindex fvar-tracking-assignments |
11667 | @opindex fno-var-tracking-assignments | |
ddf6fe37 | 11668 | @item -fvar-tracking-assignments |
d77de738 ML |
11669 | Annotate assignments to user variables early in the compilation and |
11670 | attempt to carry the annotations over throughout the compilation all the | |
11671 | way to the end, in an attempt to improve debug information while | |
11672 | optimizing. Use of @option{-gdwarf-4} is recommended along with it. | |
11673 | ||
11674 | It can be enabled even if var-tracking is disabled, in which case | |
11675 | annotations are created and maintained, but discarded at the end. | |
11676 | By default, this flag is enabled together with @option{-fvar-tracking}, | |
11677 | except when selective scheduling is enabled. | |
11678 | ||
d77de738 | 11679 | @opindex gsplit-dwarf |
ddf6fe37 | 11680 | @item -gsplit-dwarf |
d77de738 ML |
11681 | If DWARF debugging information is enabled, separate as much debugging |
11682 | information as possible into a separate output file with the extension | |
11683 | @file{.dwo}. This option allows the build system to avoid linking files with | |
11684 | debug information. To be useful, this option requires a debugger capable of | |
11685 | reading @file{.dwo} files. | |
11686 | ||
d77de738 ML |
11687 | @opindex gdwarf32 |
11688 | @opindex gdwarf64 | |
ddf6fe37 AA |
11689 | @item -gdwarf32 |
11690 | @itemx -gdwarf64 | |
d77de738 ML |
11691 | If DWARF debugging information is enabled, the @option{-gdwarf32} selects |
11692 | the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit | |
11693 | DWARF format. The default is target specific, on most targets it is | |
11694 | @option{-gdwarf32} though. The 32-bit DWARF format is smaller, but | |
11695 | can't support more than 2GiB of debug information in any of the DWARF | |
11696 | debug information sections. The 64-bit DWARF format allows larger debug | |
11697 | information and might not be well supported by all consumers yet. | |
11698 | ||
d77de738 | 11699 | @opindex gdescribe-dies |
ddf6fe37 | 11700 | @item -gdescribe-dies |
d77de738 ML |
11701 | Add description attributes to some DWARF DIEs that have no name attribute, |
11702 | such as artificial variables, external references and call site | |
11703 | parameter DIEs. | |
11704 | ||
d77de738 | 11705 | @opindex gpubnames |
ddf6fe37 | 11706 | @item -gpubnames |
d77de738 ML |
11707 | Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections. |
11708 | ||
d77de738 | 11709 | @opindex ggnu-pubnames |
ddf6fe37 | 11710 | @item -ggnu-pubnames |
d77de738 ML |
11711 | Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format |
11712 | suitable for conversion into a GDB@ index. This option is only useful | |
11713 | with a linker that can produce GDB@ index version 7. | |
11714 | ||
d77de738 ML |
11715 | @opindex fdebug-types-section |
11716 | @opindex fno-debug-types-section | |
ddf6fe37 | 11717 | @item -fdebug-types-section |
d77de738 ML |
11718 | When using DWARF Version 4 or higher, type DIEs can be put into |
11719 | their own @code{.debug_types} section instead of making them part of the | |
11720 | @code{.debug_info} section. It is more efficient to put them in a separate | |
11721 | comdat section since the linker can then remove duplicates. | |
11722 | But not all DWARF consumers support @code{.debug_types} sections yet | |
11723 | and on some objects @code{.debug_types} produces larger instead of smaller | |
11724 | debugging information. | |
11725 | ||
d77de738 ML |
11726 | @opindex grecord-gcc-switches |
11727 | @opindex gno-record-gcc-switches | |
ddf6fe37 AA |
11728 | @item -grecord-gcc-switches |
11729 | @itemx -gno-record-gcc-switches | |
d77de738 ML |
11730 | This switch causes the command-line options used to invoke the |
11731 | compiler that may affect code generation to be appended to the | |
11732 | DW_AT_producer attribute in DWARF debugging information. The options | |
11733 | are concatenated with spaces separating them from each other and from | |
11734 | the compiler version. | |
11735 | It is enabled by default. | |
11736 | See also @option{-frecord-gcc-switches} for another | |
11737 | way of storing compiler options into the object file. | |
11738 | ||
d77de738 | 11739 | @opindex gstrict-dwarf |
ddf6fe37 | 11740 | @item -gstrict-dwarf |
d77de738 ML |
11741 | Disallow using extensions of later DWARF standard version than selected |
11742 | with @option{-gdwarf-@var{version}}. On most targets using non-conflicting | |
11743 | DWARF extensions from later standard versions is allowed. | |
11744 | ||
d77de738 | 11745 | @opindex gno-strict-dwarf |
ddf6fe37 | 11746 | @item -gno-strict-dwarf |
d77de738 ML |
11747 | Allow using extensions of later DWARF standard version than selected with |
11748 | @option{-gdwarf-@var{version}}. | |
11749 | ||
d77de738 | 11750 | @opindex gas-loc-support |
ddf6fe37 | 11751 | @item -gas-loc-support |
d77de738 ML |
11752 | Inform the compiler that the assembler supports @code{.loc} directives. |
11753 | It may then use them for the assembler to generate DWARF2+ line number | |
11754 | tables. | |
11755 | ||
11756 | This is generally desirable, because assembler-generated line-number | |
11757 | tables are a lot more compact than those the compiler can generate | |
11758 | itself. | |
11759 | ||
11760 | This option will be enabled by default if, at GCC configure time, the | |
11761 | assembler was found to support such directives. | |
11762 | ||
d77de738 | 11763 | @opindex gno-as-loc-support |
ddf6fe37 | 11764 | @item -gno-as-loc-support |
d77de738 ML |
11765 | Force GCC to generate DWARF2+ line number tables internally, if DWARF2+ |
11766 | line number tables are to be generated. | |
11767 | ||
d77de738 | 11768 | @opindex gas-locview-support |
ddf6fe37 | 11769 | @item -gas-locview-support |
d77de738 ML |
11770 | Inform the compiler that the assembler supports @code{view} assignment |
11771 | and reset assertion checking in @code{.loc} directives. | |
11772 | ||
11773 | This option will be enabled by default if, at GCC configure time, the | |
11774 | assembler was found to support them. | |
11775 | ||
11776 | @item -gno-as-locview-support | |
11777 | Force GCC to assign view numbers internally, if | |
11778 | @option{-gvariable-location-views} are explicitly requested. | |
11779 | ||
d77de738 ML |
11780 | @opindex gcolumn-info |
11781 | @opindex gno-column-info | |
ddf6fe37 AA |
11782 | @item -gcolumn-info |
11783 | @itemx -gno-column-info | |
d77de738 ML |
11784 | Emit location column information into DWARF debugging information, rather |
11785 | than just file and line. | |
11786 | This option is enabled by default. | |
11787 | ||
d77de738 ML |
11788 | @opindex gstatement-frontiers |
11789 | @opindex gno-statement-frontiers | |
ddf6fe37 AA |
11790 | @item -gstatement-frontiers |
11791 | @itemx -gno-statement-frontiers | |
d77de738 ML |
11792 | This option causes GCC to create markers in the internal representation |
11793 | at the beginning of statements, and to keep them roughly in place | |
11794 | throughout compilation, using them to guide the output of @code{is_stmt} | |
11795 | markers in the line number table. This is enabled by default when | |
11796 | compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2}, | |
11797 | @dots{}), and outputting DWARF 2 debug information at the normal level. | |
11798 | ||
d77de738 ML |
11799 | @opindex gvariable-location-views |
11800 | @opindex gvariable-location-views=incompat5 | |
11801 | @opindex gno-variable-location-views | |
ddf6fe37 AA |
11802 | @item -gvariable-location-views |
11803 | @itemx -gvariable-location-views=incompat5 | |
11804 | @itemx -gno-variable-location-views | |
d77de738 ML |
11805 | Augment variable location lists with progressive view numbers implied |
11806 | from the line number table. This enables debug information consumers to | |
11807 | inspect state at certain points of the program, even if no instructions | |
11808 | associated with the corresponding source locations are present at that | |
11809 | point. If the assembler lacks support for view numbers in line number | |
11810 | tables, this will cause the compiler to emit the line number table, | |
11811 | which generally makes them somewhat less compact. The augmented line | |
11812 | number tables and location lists are fully backward-compatible, so they | |
11813 | can be consumed by debug information consumers that are not aware of | |
11814 | these augmentations, but they won't derive any benefit from them either. | |
11815 | ||
11816 | This is enabled by default when outputting DWARF 2 debug information at | |
11817 | the normal level, as long as there is assembler support, | |
11818 | @option{-fvar-tracking-assignments} is enabled and | |
11819 | @option{-gstrict-dwarf} is not. When assembler support is not | |
11820 | available, this may still be enabled, but it will force GCC to output | |
11821 | internal line number tables, and if | |
11822 | @option{-ginternal-reset-location-views} is not enabled, that will most | |
11823 | certainly lead to silently mismatching location views. | |
11824 | ||
11825 | There is a proposed representation for view numbers that is not backward | |
11826 | compatible with the location list format introduced in DWARF 5, that can | |
11827 | be enabled with @option{-gvariable-location-views=incompat5}. This | |
11828 | option may be removed in the future, is only provided as a reference | |
11829 | implementation of the proposed representation. Debug information | |
11830 | consumers are not expected to support this extended format, and they | |
11831 | would be rendered unable to decode location lists using it. | |
11832 | ||
d77de738 ML |
11833 | @opindex ginternal-reset-location-views |
11834 | @opindex gno-internal-reset-location-views | |
ddf6fe37 AA |
11835 | @item -ginternal-reset-location-views |
11836 | @itemx -gno-internal-reset-location-views | |
d77de738 ML |
11837 | Attempt to determine location views that can be omitted from location |
11838 | view lists. This requires the compiler to have very accurate insn | |
11839 | length estimates, which isn't always the case, and it may cause | |
11840 | incorrect view lists to be generated silently when using an assembler | |
11841 | that does not support location view lists. The GNU assembler will flag | |
11842 | any such error as a @code{view number mismatch}. This is only enabled | |
11843 | on ports that define a reliable estimation function. | |
11844 | ||
d77de738 ML |
11845 | @opindex ginline-points |
11846 | @opindex gno-inline-points | |
ddf6fe37 AA |
11847 | @item -ginline-points |
11848 | @itemx -gno-inline-points | |
d77de738 ML |
11849 | Generate extended debug information for inlined functions. Location |
11850 | view tracking markers are inserted at inlined entry points, so that | |
11851 | address and view numbers can be computed and output in debug | |
11852 | information. This can be enabled independently of location views, in | |
11853 | which case the view numbers won't be output, but it can only be enabled | |
11854 | along with statement frontiers, and it is only enabled by default if | |
11855 | location views are enabled. | |
11856 | ||
d77de738 | 11857 | @opindex gz |
ddf6fe37 | 11858 | @item -gz@r{[}=@var{type}@r{]} |
d77de738 ML |
11859 | Produce compressed debug sections in DWARF format, if that is supported. |
11860 | If @var{type} is not given, the default type depends on the capabilities | |
11861 | of the assembler and linker used. @var{type} may be one of | |
11862 | @samp{none} (don't compress debug sections), or @samp{zlib} (use zlib | |
11863 | compression in ELF gABI format). If the linker doesn't support writing | |
11864 | compressed debug sections, the option is rejected. Otherwise, if the | |
11865 | assembler does not support them, @option{-gz} is silently ignored when | |
11866 | producing object files. | |
11867 | ||
d77de738 | 11868 | @opindex femit-struct-debug-baseonly |
ddf6fe37 | 11869 | @item -femit-struct-debug-baseonly |
d77de738 ML |
11870 | Emit debug information for struct-like types |
11871 | only when the base name of the compilation source file | |
11872 | matches the base name of file in which the struct is defined. | |
11873 | ||
11874 | This option substantially reduces the size of debugging information, | |
11875 | but at significant potential loss in type information to the debugger. | |
11876 | See @option{-femit-struct-debug-reduced} for a less aggressive option. | |
11877 | See @option{-femit-struct-debug-detailed} for more detailed control. | |
11878 | ||
11879 | This option works only with DWARF debug output. | |
11880 | ||
d77de738 | 11881 | @opindex femit-struct-debug-reduced |
ddf6fe37 | 11882 | @item -femit-struct-debug-reduced |
d77de738 ML |
11883 | Emit debug information for struct-like types |
11884 | only when the base name of the compilation source file | |
11885 | matches the base name of file in which the type is defined, | |
11886 | unless the struct is a template or defined in a system header. | |
11887 | ||
11888 | This option significantly reduces the size of debugging information, | |
11889 | with some potential loss in type information to the debugger. | |
11890 | See @option{-femit-struct-debug-baseonly} for a more aggressive option. | |
11891 | See @option{-femit-struct-debug-detailed} for more detailed control. | |
11892 | ||
11893 | This option works only with DWARF debug output. | |
11894 | ||
d77de738 | 11895 | @opindex femit-struct-debug-detailed |
ddf6fe37 | 11896 | @item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]} |
d77de738 ML |
11897 | Specify the struct-like types |
11898 | for which the compiler generates debug information. | |
11899 | The intent is to reduce duplicate struct debug information | |
11900 | between different object files within the same program. | |
11901 | ||
11902 | This option is a detailed version of | |
11903 | @option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly}, | |
11904 | which serves for most needs. | |
11905 | ||
11906 | A specification has the syntax@* | |
11907 | [@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none}) | |
11908 | ||
11909 | The optional first word limits the specification to | |
11910 | structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}). | |
11911 | A struct type is used directly when it is the type of a variable, member. | |
11912 | Indirect uses arise through pointers to structs. | |
11913 | That is, when use of an incomplete struct is valid, the use is indirect. | |
11914 | An example is | |
11915 | @samp{struct one direct; struct two * indirect;}. | |
11916 | ||
11917 | The optional second word limits the specification to | |
11918 | ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}). | |
11919 | Generic structs are a bit complicated to explain. | |
11920 | For C++, these are non-explicit specializations of template classes, | |
11921 | or non-template classes within the above. | |
11922 | Other programming languages have generics, | |
11923 | but @option{-femit-struct-debug-detailed} does not yet implement them. | |
11924 | ||
11925 | The third word specifies the source files for those | |
11926 | structs for which the compiler should emit debug information. | |
11927 | The values @samp{none} and @samp{any} have the normal meaning. | |
11928 | The value @samp{base} means that | |
11929 | the base of name of the file in which the type declaration appears | |
11930 | must match the base of the name of the main compilation file. | |
11931 | In practice, this means that when compiling @file{foo.c}, debug information | |
11932 | is generated for types declared in that file and @file{foo.h}, | |
11933 | but not other header files. | |
11934 | The value @samp{sys} means those types satisfying @samp{base} | |
11935 | or declared in system or compiler headers. | |
11936 | ||
11937 | You may need to experiment to determine the best settings for your application. | |
11938 | ||
11939 | The default is @option{-femit-struct-debug-detailed=all}. | |
11940 | ||
11941 | This option works only with DWARF debug output. | |
11942 | ||
d77de738 ML |
11943 | @opindex fdwarf2-cfi-asm |
11944 | @opindex fno-dwarf2-cfi-asm | |
ddf6fe37 | 11945 | @item -fno-dwarf2-cfi-asm |
d77de738 ML |
11946 | Emit DWARF unwind info as compiler generated @code{.eh_frame} section |
11947 | instead of using GAS @code{.cfi_*} directives. | |
11948 | ||
d77de738 ML |
11949 | @opindex feliminate-unused-debug-types |
11950 | @opindex fno-eliminate-unused-debug-types | |
ddf6fe37 | 11951 | @item -fno-eliminate-unused-debug-types |
d77de738 ML |
11952 | Normally, when producing DWARF output, GCC avoids producing debug symbol |
11953 | output for types that are nowhere used in the source file being compiled. | |
11954 | Sometimes it is useful to have GCC emit debugging | |
11955 | information for all types declared in a compilation | |
11956 | unit, regardless of whether or not they are actually used | |
11957 | in that compilation unit, for example | |
11958 | if, in the debugger, you want to cast a value to a type that is | |
11959 | not actually used in your program (but is declared). More often, | |
11960 | however, this results in a significant amount of wasted space. | |
11961 | @end table | |
11962 | ||
11963 | @node Optimize Options | |
11964 | @section Options That Control Optimization | |
11965 | @cindex optimize options | |
11966 | @cindex options, optimization | |
11967 | ||
11968 | These options control various sorts of optimizations. | |
11969 | ||
11970 | Without any optimization option, the compiler's goal is to reduce the | |
11971 | cost of compilation and to make debugging produce the expected | |
11972 | results. Statements are independent: if you stop the program with a | |
11973 | breakpoint between statements, you can then assign a new value to any | |
11974 | variable or change the program counter to any other statement in the | |
11975 | function and get exactly the results you expect from the source | |
11976 | code. | |
11977 | ||
11978 | Turning on optimization flags makes the compiler attempt to improve | |
11979 | the performance and/or code size at the expense of compilation time | |
11980 | and possibly the ability to debug the program. | |
11981 | ||
11982 | The compiler performs optimization based on the knowledge it has of the | |
11983 | program. Compiling multiple files at once to a single output file mode allows | |
11984 | the compiler to use information gained from all of the files when compiling | |
11985 | each of them. | |
11986 | ||
11987 | Not all optimizations are controlled directly by a flag. Only | |
11988 | optimizations that have a flag are listed in this section. | |
11989 | ||
11990 | Most optimizations are completely disabled at @option{-O0} or if an | |
11991 | @option{-O} level is not set on the command line, even if individual | |
11992 | optimization flags are specified. Similarly, @option{-Og} suppresses | |
11993 | many optimization passes. | |
11994 | ||
11995 | Depending on the target and how GCC was configured, a slightly different | |
11996 | set of optimizations may be enabled at each @option{-O} level than | |
11997 | those listed here. You can invoke GCC with @option{-Q --help=optimizers} | |
11998 | to find out the exact set of optimizations that are enabled at each level. | |
11999 | @xref{Overall Options}, for examples. | |
12000 | ||
12001 | @table @gcctabopt | |
d77de738 ML |
12002 | @opindex O |
12003 | @opindex O1 | |
ddf6fe37 AA |
12004 | @item -O |
12005 | @itemx -O1 | |
d77de738 ML |
12006 | Optimize. Optimizing compilation takes somewhat more time, and a lot |
12007 | more memory for a large function. | |
12008 | ||
12009 | With @option{-O}, the compiler tries to reduce code size and execution | |
12010 | time, without performing any optimizations that take a great deal of | |
12011 | compilation time. | |
12012 | ||
12013 | @c Note that in addition to the default_options_table list in opts.cc, | |
12014 | @c several optimization flags default to true but control optimization | |
12015 | @c passes that are explicitly disabled at -O0. | |
12016 | ||
12017 | @option{-O} turns on the following optimization flags: | |
12018 | ||
12019 | @c Please keep the following list alphabetized. | |
43b72ede AA |
12020 | @gccoptlist{-fauto-inc-dec |
12021 | -fbranch-count-reg | |
12022 | -fcombine-stack-adjustments | |
12023 | -fcompare-elim | |
12024 | -fcprop-registers | |
12025 | -fdce | |
12026 | -fdefer-pop | |
12027 | -fdelayed-branch | |
12028 | -fdse | |
12029 | -fforward-propagate | |
12030 | -fguess-branch-probability | |
12031 | -fif-conversion | |
12032 | -fif-conversion2 | |
12033 | -finline-functions-called-once | |
12034 | -fipa-modref | |
12035 | -fipa-profile | |
12036 | -fipa-pure-const | |
12037 | -fipa-reference | |
12038 | -fipa-reference-addressable | |
12039 | -fmerge-constants | |
12040 | -fmove-loop-invariants | |
12041 | -fmove-loop-stores | |
12042 | -fomit-frame-pointer | |
12043 | -freorder-blocks | |
12044 | -fshrink-wrap | |
12045 | -fshrink-wrap-separate | |
12046 | -fsplit-wide-types | |
12047 | -fssa-backprop | |
12048 | -fssa-phiopt | |
12049 | -ftree-bit-ccp | |
12050 | -ftree-ccp | |
12051 | -ftree-ch | |
12052 | -ftree-coalesce-vars | |
12053 | -ftree-copy-prop | |
12054 | -ftree-dce | |
12055 | -ftree-dominator-opts | |
12056 | -ftree-dse | |
12057 | -ftree-forwprop | |
12058 | -ftree-fre | |
12059 | -ftree-phiprop | |
12060 | -ftree-pta | |
12061 | -ftree-scev-cprop | |
12062 | -ftree-sink | |
12063 | -ftree-slsr | |
12064 | -ftree-sra | |
12065 | -ftree-ter | |
d77de738 ML |
12066 | -funit-at-a-time} |
12067 | ||
d77de738 | 12068 | @opindex O2 |
ddf6fe37 | 12069 | @item -O2 |
d77de738 ML |
12070 | Optimize even more. GCC performs nearly all supported optimizations |
12071 | that do not involve a space-speed tradeoff. | |
12072 | As compared to @option{-O}, this option increases both compilation time | |
12073 | and the performance of the generated code. | |
12074 | ||
12075 | @option{-O2} turns on all optimization flags specified by @option{-O1}. It | |
12076 | also turns on the following optimization flags: | |
12077 | ||
12078 | @c Please keep the following list alphabetized! | |
43b72ede AA |
12079 | @gccoptlist{-falign-functions -falign-jumps |
12080 | -falign-labels -falign-loops | |
12081 | -fcaller-saves | |
12082 | -fcode-hoisting | |
12083 | -fcrossjumping | |
12084 | -fcse-follow-jumps -fcse-skip-blocks | |
12085 | -fdelete-null-pointer-checks | |
12086 | -fdevirtualize -fdevirtualize-speculatively | |
12087 | -fexpensive-optimizations | |
12088 | -ffinite-loops | |
12089 | -fgcse -fgcse-lm | |
12090 | -fhoist-adjacent-loads | |
12091 | -finline-functions | |
12092 | -finline-small-functions | |
12093 | -findirect-inlining | |
12094 | -fipa-bit-cp -fipa-cp -fipa-icf | |
12095 | -fipa-ra -fipa-sra -fipa-vrp | |
12096 | -fisolate-erroneous-paths-dereference | |
12097 | -flra-remat | |
12098 | -foptimize-sibling-calls | |
12099 | -foptimize-strlen | |
12100 | -fpartial-inlining | |
12101 | -fpeephole2 | |
12102 | -freorder-blocks-algorithm=stc | |
12103 | -freorder-blocks-and-partition -freorder-functions | |
12104 | -frerun-cse-after-loop | |
12105 | -fschedule-insns -fschedule-insns2 | |
12106 | -fsched-interblock -fsched-spec | |
12107 | -fstore-merging | |
12108 | -fstrict-aliasing | |
12109 | -fthread-jumps | |
12110 | -ftree-builtin-call-dce | |
12111 | -ftree-loop-vectorize | |
12112 | -ftree-pre | |
12113 | -ftree-slp-vectorize | |
12114 | -ftree-switch-conversion -ftree-tail-merge | |
12115 | -ftree-vrp | |
d77de738 ML |
12116 | -fvect-cost-model=very-cheap} |
12117 | ||
12118 | Please note the warning under @option{-fgcse} about | |
12119 | invoking @option{-O2} on programs that use computed gotos. | |
12120 | ||
d77de738 | 12121 | @opindex O3 |
ddf6fe37 | 12122 | @item -O3 |
d77de738 ML |
12123 | Optimize yet more. @option{-O3} turns on all optimizations specified |
12124 | by @option{-O2} and also turns on the following optimization flags: | |
12125 | ||
12126 | @c Please keep the following list alphabetized! | |
43b72ede | 12127 | @gccoptlist{-fgcse-after-reload |
d77de738 | 12128 | -fipa-cp-clone |
43b72ede AA |
12129 | -floop-interchange |
12130 | -floop-unroll-and-jam | |
12131 | -fpeel-loops | |
12132 | -fpredictive-commoning | |
12133 | -fsplit-loops | |
12134 | -fsplit-paths | |
12135 | -ftree-loop-distribution | |
12136 | -ftree-partial-pre | |
12137 | -funswitch-loops | |
12138 | -fvect-cost-model=dynamic | |
d77de738 ML |
12139 | -fversion-loops-for-strides} |
12140 | ||
d77de738 | 12141 | @opindex O0 |
ddf6fe37 | 12142 | @item -O0 |
d77de738 ML |
12143 | Reduce compilation time and make debugging produce the expected |
12144 | results. This is the default. | |
12145 | ||
d77de738 | 12146 | @opindex Os |
ddf6fe37 | 12147 | @item -Os |
d77de738 ML |
12148 | Optimize for size. @option{-Os} enables all @option{-O2} optimizations |
12149 | except those that often increase code size: | |
12150 | ||
43b72ede AA |
12151 | @gccoptlist{-falign-functions -falign-jumps |
12152 | -falign-labels -falign-loops | |
d77de738 ML |
12153 | -fprefetch-loop-arrays -freorder-blocks-algorithm=stc} |
12154 | ||
12155 | It also enables @option{-finline-functions}, causes the compiler to tune for | |
12156 | code size rather than execution speed, and performs further optimizations | |
12157 | designed to reduce code size. | |
12158 | ||
d77de738 | 12159 | @opindex Ofast |
ddf6fe37 | 12160 | @item -Ofast |
d77de738 ML |
12161 | Disregard strict standards compliance. @option{-Ofast} enables all |
12162 | @option{-O3} optimizations. It also enables optimizations that are not | |
12163 | valid for all standard-compliant programs. | |
12164 | It turns on @option{-ffast-math}, @option{-fallow-store-data-races} | |
12165 | and the Fortran-specific @option{-fstack-arrays}, unless | |
12166 | @option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}. | |
12167 | It turns off @option{-fsemantic-interposition}. | |
12168 | ||
d77de738 | 12169 | @opindex Og |
ddf6fe37 | 12170 | @item -Og |
d77de738 ML |
12171 | Optimize debugging experience. @option{-Og} should be the optimization |
12172 | level of choice for the standard edit-compile-debug cycle, offering | |
12173 | a reasonable level of optimization while maintaining fast compilation | |
12174 | and a good debugging experience. It is a better choice than @option{-O0} | |
12175 | for producing debuggable code because some compiler passes | |
12176 | that collect debug information are disabled at @option{-O0}. | |
12177 | ||
12178 | Like @option{-O0}, @option{-Og} completely disables a number of | |
12179 | optimization passes so that individual options controlling them have | |
12180 | no effect. Otherwise @option{-Og} enables all @option{-O1} | |
12181 | optimization flags except for those that may interfere with debugging: | |
12182 | ||
43b72ede AA |
12183 | @gccoptlist{-fbranch-count-reg -fdelayed-branch |
12184 | -fdse -fif-conversion -fif-conversion2 | |
12185 | -finline-functions-called-once | |
12186 | -fmove-loop-invariants -fmove-loop-stores -fssa-phiopt | |
d77de738 ML |
12187 | -ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra} |
12188 | ||
d77de738 | 12189 | @opindex Oz |
ddf6fe37 | 12190 | @item -Oz |
d77de738 ML |
12191 | Optimize aggressively for size rather than speed. This may increase |
12192 | the number of instructions executed if those instructions require | |
12193 | fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os} | |
12194 | including enabling most @option{-O2} optimizations. | |
12195 | ||
12196 | @end table | |
12197 | ||
12198 | If you use multiple @option{-O} options, with or without level numbers, | |
12199 | the last such option is the one that is effective. | |
12200 | ||
12201 | Options of the form @option{-f@var{flag}} specify machine-independent | |
12202 | flags. Most flags have both positive and negative forms; the negative | |
12203 | form of @option{-ffoo} is @option{-fno-foo}. In the table | |
12204 | below, only one of the forms is listed---the one you typically | |
12205 | use. You can figure out the other form by either removing @samp{no-} | |
12206 | or adding it. | |
12207 | ||
12208 | The following options control specific optimizations. They are either | |
12209 | activated by @option{-O} options or are related to ones that are. You | |
12210 | can use the following flags in the rare cases when ``fine-tuning'' of | |
12211 | optimizations to be performed is desired. | |
12212 | ||
12213 | @table @gcctabopt | |
d77de738 ML |
12214 | @opindex fno-defer-pop |
12215 | @opindex fdefer-pop | |
ddf6fe37 | 12216 | @item -fno-defer-pop |
d77de738 ML |
12217 | For machines that must pop arguments after a function call, always pop |
12218 | the arguments as soon as each function returns. | |
12219 | At levels @option{-O1} and higher, @option{-fdefer-pop} is the default; | |
12220 | this allows the compiler to let arguments accumulate on the stack for several | |
12221 | function calls and pop them all at once. | |
12222 | ||
d77de738 | 12223 | @opindex fforward-propagate |
ddf6fe37 | 12224 | @item -fforward-propagate |
d77de738 ML |
12225 | Perform a forward propagation pass on RTL@. The pass tries to combine two |
12226 | instructions and checks if the result can be simplified. If loop unrolling | |
12227 | is active, two passes are performed and the second is scheduled after | |
12228 | loop unrolling. | |
12229 | ||
12230 | This option is enabled by default at optimization levels @option{-O1}, | |
12231 | @option{-O2}, @option{-O3}, @option{-Os}. | |
12232 | ||
d77de738 | 12233 | @opindex ffp-contract |
ddf6fe37 | 12234 | @item -ffp-contract=@var{style} |
d77de738 ML |
12235 | @option{-ffp-contract=off} disables floating-point expression contraction. |
12236 | @option{-ffp-contract=fast} enables floating-point expression contraction | |
12237 | such as forming of fused multiply-add operations if the target has | |
12238 | native support for them. | |
12239 | @option{-ffp-contract=on} enables floating-point expression contraction | |
1c1dd396 AM |
12240 | if allowed by the language standard. This is implemented for C and C++, |
12241 | where it enables contraction within one expression, but not across | |
12242 | different statements. | |
d77de738 | 12243 | |
1c1dd396 AM |
12244 | The default is @option{-ffp-contract=off} for C in a standards compliant mode |
12245 | (@option{-std=c11} or similar), @option{-ffp-contract=fast} otherwise. | |
d77de738 | 12246 | |
d77de738 | 12247 | @opindex fomit-frame-pointer |
ddf6fe37 | 12248 | @item -fomit-frame-pointer |
d77de738 ML |
12249 | Omit the frame pointer in functions that don't need one. This avoids the |
12250 | instructions to save, set up and restore the frame pointer; on many targets | |
12251 | it also makes an extra register available. | |
12252 | ||
12253 | On some targets this flag has no effect because the standard calling sequence | |
12254 | always uses a frame pointer, so it cannot be omitted. | |
12255 | ||
12256 | Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer | |
12257 | is used in all functions. Several targets always omit the frame pointer in | |
12258 | leaf functions. | |
12259 | ||
12260 | Enabled by default at @option{-O1} and higher. | |
12261 | ||
d77de738 | 12262 | @opindex foptimize-sibling-calls |
ddf6fe37 | 12263 | @item -foptimize-sibling-calls |
d77de738 ML |
12264 | Optimize sibling and tail recursive calls. |
12265 | ||
12266 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12267 | ||
d77de738 | 12268 | @opindex foptimize-strlen |
ddf6fe37 | 12269 | @item -foptimize-strlen |
d77de738 ML |
12270 | Optimize various standard C string functions (e.g.@: @code{strlen}, |
12271 | @code{strchr} or @code{strcpy}) and | |
12272 | their @code{_FORTIFY_SOURCE} counterparts into faster alternatives. | |
12273 | ||
12274 | Enabled at levels @option{-O2}, @option{-O3}. | |
12275 | ||
d77de738 ML |
12276 | @opindex fno-inline |
12277 | @opindex finline | |
ddf6fe37 | 12278 | @item -fno-inline |
d77de738 ML |
12279 | Do not expand any functions inline apart from those marked with |
12280 | the @code{always_inline} attribute. This is the default when not | |
12281 | optimizing. | |
12282 | ||
12283 | Single functions can be exempted from inlining by marking them | |
12284 | with the @code{noinline} attribute. | |
12285 | ||
d77de738 | 12286 | @opindex finline-small-functions |
ddf6fe37 | 12287 | @item -finline-small-functions |
d77de738 ML |
12288 | Integrate functions into their callers when their body is smaller than expected |
12289 | function call code (so overall size of program gets smaller). The compiler | |
12290 | heuristically decides which functions are simple enough to be worth integrating | |
12291 | in this way. This inlining applies to all functions, even those not declared | |
12292 | inline. | |
12293 | ||
12294 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12295 | ||
d77de738 | 12296 | @opindex findirect-inlining |
ddf6fe37 | 12297 | @item -findirect-inlining |
d77de738 ML |
12298 | Inline also indirect calls that are discovered to be known at compile |
12299 | time thanks to previous inlining. This option has any effect only | |
12300 | when inlining itself is turned on by the @option{-finline-functions} | |
12301 | or @option{-finline-small-functions} options. | |
12302 | ||
12303 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12304 | ||
d77de738 | 12305 | @opindex finline-functions |
ddf6fe37 | 12306 | @item -finline-functions |
d77de738 ML |
12307 | Consider all functions for inlining, even if they are not declared inline. |
12308 | The compiler heuristically decides which functions are worth integrating | |
12309 | in this way. | |
12310 | ||
12311 | If all calls to a given function are integrated, and the function is | |
12312 | declared @code{static}, then the function is normally not output as | |
12313 | assembler code in its own right. | |
12314 | ||
12315 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled | |
12316 | by @option{-fprofile-use} and @option{-fauto-profile}. | |
12317 | ||
d77de738 | 12318 | @opindex finline-functions-called-once |
ddf6fe37 | 12319 | @item -finline-functions-called-once |
d77de738 ML |
12320 | Consider all @code{static} functions called once for inlining into their |
12321 | caller even if they are not marked @code{inline}. If a call to a given | |
12322 | function is integrated, then the function is not output as assembler code | |
12323 | in its own right. | |
12324 | ||
12325 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os}, | |
12326 | but not @option{-Og}. | |
12327 | ||
d77de738 | 12328 | @opindex fearly-inlining |
ddf6fe37 | 12329 | @item -fearly-inlining |
d77de738 ML |
12330 | Inline functions marked by @code{always_inline} and functions whose body seems |
12331 | smaller than the function call overhead early before doing | |
12332 | @option{-fprofile-generate} instrumentation and real inlining pass. Doing so | |
12333 | makes profiling significantly cheaper and usually inlining faster on programs | |
12334 | having large chains of nested wrapper functions. | |
12335 | ||
12336 | Enabled by default. | |
12337 | ||
d77de738 | 12338 | @opindex fipa-sra |
ddf6fe37 | 12339 | @item -fipa-sra |
d77de738 ML |
12340 | Perform interprocedural scalar replacement of aggregates, removal of |
12341 | unused parameters and replacement of parameters passed by reference | |
12342 | by parameters passed by value. | |
12343 | ||
12344 | Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}. | |
12345 | ||
d77de738 | 12346 | @opindex finline-limit |
ddf6fe37 | 12347 | @item -finline-limit=@var{n} |
d77de738 ML |
12348 | By default, GCC limits the size of functions that can be inlined. This flag |
12349 | allows coarse control of this limit. @var{n} is the size of functions that | |
12350 | can be inlined in number of pseudo instructions. | |
12351 | ||
12352 | Inlining is actually controlled by a number of parameters, which may be | |
12353 | specified individually by using @option{--param @var{name}=@var{value}}. | |
12354 | The @option{-finline-limit=@var{n}} option sets some of these parameters | |
12355 | as follows: | |
12356 | ||
12357 | @table @gcctabopt | |
12358 | @item max-inline-insns-single | |
12359 | is set to @var{n}/2. | |
12360 | @item max-inline-insns-auto | |
12361 | is set to @var{n}/2. | |
12362 | @end table | |
12363 | ||
12364 | See below for a documentation of the individual | |
12365 | parameters controlling inlining and for the defaults of these parameters. | |
12366 | ||
12367 | @emph{Note:} there may be no value to @option{-finline-limit} that results | |
12368 | in default behavior. | |
12369 | ||
12370 | @emph{Note:} pseudo instruction represents, in this particular context, an | |
12371 | abstract measurement of function's size. In no way does it represent a count | |
12372 | of assembly instructions and as such its exact meaning might change from one | |
12373 | release to an another. | |
12374 | ||
d77de738 ML |
12375 | @opindex fno-keep-inline-dllexport |
12376 | @opindex fkeep-inline-dllexport | |
ddf6fe37 | 12377 | @item -fno-keep-inline-dllexport |
d77de738 ML |
12378 | This is a more fine-grained version of @option{-fkeep-inline-functions}, |
12379 | which applies only to functions that are declared using the @code{dllexport} | |
12380 | attribute or declspec. @xref{Function Attributes,,Declaring Attributes of | |
12381 | Functions}. | |
12382 | ||
d77de738 | 12383 | @opindex fkeep-inline-functions |
ddf6fe37 | 12384 | @item -fkeep-inline-functions |
d77de738 ML |
12385 | In C, emit @code{static} functions that are declared @code{inline} |
12386 | into the object file, even if the function has been inlined into all | |
12387 | of its callers. This switch does not affect functions using the | |
12388 | @code{extern inline} extension in GNU C90@. In C++, emit any and all | |
12389 | inline functions into the object file. | |
12390 | ||
d77de738 | 12391 | @opindex fkeep-static-functions |
ddf6fe37 | 12392 | @item -fkeep-static-functions |
d77de738 ML |
12393 | Emit @code{static} functions into the object file, even if the function |
12394 | is never used. | |
12395 | ||
d77de738 | 12396 | @opindex fkeep-static-consts |
ddf6fe37 | 12397 | @item -fkeep-static-consts |
d77de738 ML |
12398 | Emit variables declared @code{static const} when optimization isn't turned |
12399 | on, even if the variables aren't referenced. | |
12400 | ||
12401 | GCC enables this option by default. If you want to force the compiler to | |
12402 | check if a variable is referenced, regardless of whether or not | |
12403 | optimization is turned on, use the @option{-fno-keep-static-consts} option. | |
12404 | ||
d77de738 | 12405 | @opindex fmerge-constants |
ddf6fe37 | 12406 | @item -fmerge-constants |
d77de738 ML |
12407 | Attempt to merge identical constants (string constants and floating-point |
12408 | constants) across compilation units. | |
12409 | ||
12410 | This option is the default for optimized compilation if the assembler and | |
12411 | linker support it. Use @option{-fno-merge-constants} to inhibit this | |
12412 | behavior. | |
12413 | ||
12414 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
12415 | ||
d77de738 | 12416 | @opindex fmerge-all-constants |
ddf6fe37 | 12417 | @item -fmerge-all-constants |
d77de738 ML |
12418 | Attempt to merge identical constants and identical variables. |
12419 | ||
12420 | This option implies @option{-fmerge-constants}. In addition to | |
12421 | @option{-fmerge-constants} this considers e.g.@: even constant initialized | |
12422 | arrays or initialized constant variables with integral or floating-point | |
12423 | types. Languages like C or C++ require each variable, including multiple | |
12424 | instances of the same variable in recursive calls, to have distinct locations, | |
12425 | so using this option results in non-conforming | |
12426 | behavior. | |
12427 | ||
d77de738 | 12428 | @opindex fmodulo-sched |
ddf6fe37 | 12429 | @item -fmodulo-sched |
d77de738 ML |
12430 | Perform swing modulo scheduling immediately before the first scheduling |
12431 | pass. This pass looks at innermost loops and reorders their | |
12432 | instructions by overlapping different iterations. | |
12433 | ||
d77de738 | 12434 | @opindex fmodulo-sched-allow-regmoves |
ddf6fe37 | 12435 | @item -fmodulo-sched-allow-regmoves |
d77de738 ML |
12436 | Perform more aggressive SMS-based modulo scheduling with register moves |
12437 | allowed. By setting this flag certain anti-dependences edges are | |
12438 | deleted, which triggers the generation of reg-moves based on the | |
12439 | life-range analysis. This option is effective only with | |
12440 | @option{-fmodulo-sched} enabled. | |
12441 | ||
d77de738 ML |
12442 | @opindex fno-branch-count-reg |
12443 | @opindex fbranch-count-reg | |
ddf6fe37 | 12444 | @item -fno-branch-count-reg |
d77de738 ML |
12445 | Disable the optimization pass that scans for opportunities to use |
12446 | ``decrement and branch'' instructions on a count register instead of | |
12447 | instruction sequences that decrement a register, compare it against zero, and | |
12448 | then branch based upon the result. This option is only meaningful on | |
12449 | architectures that support such instructions, which include x86, PowerPC, | |
12450 | IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option | |
12451 | doesn't remove the decrement and branch instructions from the generated | |
12452 | instruction stream introduced by other optimization passes. | |
12453 | ||
12454 | The default is @option{-fbranch-count-reg} at @option{-O1} and higher, | |
12455 | except for @option{-Og}. | |
12456 | ||
d77de738 ML |
12457 | @opindex fno-function-cse |
12458 | @opindex ffunction-cse | |
ddf6fe37 | 12459 | @item -fno-function-cse |
d77de738 ML |
12460 | Do not put function addresses in registers; make each instruction that |
12461 | calls a constant function contain the function's address explicitly. | |
12462 | ||
12463 | This option results in less efficient code, but some strange hacks | |
12464 | that alter the assembler output may be confused by the optimizations | |
12465 | performed when this option is not used. | |
12466 | ||
12467 | The default is @option{-ffunction-cse} | |
12468 | ||
d77de738 ML |
12469 | @opindex fno-zero-initialized-in-bss |
12470 | @opindex fzero-initialized-in-bss | |
ddf6fe37 | 12471 | @item -fno-zero-initialized-in-bss |
d77de738 ML |
12472 | If the target supports a BSS section, GCC by default puts variables that |
12473 | are initialized to zero into BSS@. This can save space in the resulting | |
12474 | code. | |
12475 | ||
12476 | This option turns off this behavior because some programs explicitly | |
12477 | rely on variables going to the data section---e.g., so that the | |
12478 | resulting executable can find the beginning of that section and/or make | |
12479 | assumptions based on that. | |
12480 | ||
12481 | The default is @option{-fzero-initialized-in-bss}. | |
12482 | ||
d77de738 | 12483 | @opindex fthread-jumps |
ddf6fe37 | 12484 | @item -fthread-jumps |
d77de738 ML |
12485 | Perform optimizations that check to see if a jump branches to a |
12486 | location where another comparison subsumed by the first is found. If | |
12487 | so, the first branch is redirected to either the destination of the | |
12488 | second branch or a point immediately following it, depending on whether | |
12489 | the condition is known to be true or false. | |
12490 | ||
12491 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
12492 | ||
d77de738 | 12493 | @opindex fsplit-wide-types |
ddf6fe37 | 12494 | @item -fsplit-wide-types |
d77de738 ML |
12495 | When using a type that occupies multiple registers, such as @code{long |
12496 | long} on a 32-bit system, split the registers apart and allocate them | |
12497 | independently. This normally generates better code for those types, | |
12498 | but may make debugging more difficult. | |
12499 | ||
12500 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, | |
12501 | @option{-Os}. | |
12502 | ||
d77de738 | 12503 | @opindex fsplit-wide-types-early |
ddf6fe37 | 12504 | @item -fsplit-wide-types-early |
d77de738 ML |
12505 | Fully split wide types early, instead of very late. |
12506 | This option has no effect unless @option{-fsplit-wide-types} is turned on. | |
12507 | ||
12508 | This is the default on some targets. | |
12509 | ||
d77de738 | 12510 | @opindex fcse-follow-jumps |
ddf6fe37 | 12511 | @item -fcse-follow-jumps |
d77de738 ML |
12512 | In common subexpression elimination (CSE), scan through jump instructions |
12513 | when the target of the jump is not reached by any other path. For | |
12514 | example, when CSE encounters an @code{if} statement with an | |
12515 | @code{else} clause, CSE follows the jump when the condition | |
12516 | tested is false. | |
12517 | ||
12518 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12519 | ||
d77de738 | 12520 | @opindex fcse-skip-blocks |
ddf6fe37 | 12521 | @item -fcse-skip-blocks |
d77de738 ML |
12522 | This is similar to @option{-fcse-follow-jumps}, but causes CSE to |
12523 | follow jumps that conditionally skip over blocks. When CSE | |
12524 | encounters a simple @code{if} statement with no else clause, | |
12525 | @option{-fcse-skip-blocks} causes CSE to follow the jump around the | |
12526 | body of the @code{if}. | |
12527 | ||
12528 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12529 | ||
d77de738 | 12530 | @opindex frerun-cse-after-loop |
ddf6fe37 | 12531 | @item -frerun-cse-after-loop |
d77de738 ML |
12532 | Re-run common subexpression elimination after loop optimizations are |
12533 | performed. | |
12534 | ||
12535 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12536 | ||
d77de738 | 12537 | @opindex fgcse |
ddf6fe37 | 12538 | @item -fgcse |
d77de738 ML |
12539 | Perform a global common subexpression elimination pass. |
12540 | This pass also performs global constant and copy propagation. | |
12541 | ||
12542 | @emph{Note:} When compiling a program using computed gotos, a GCC | |
12543 | extension, you may get better run-time performance if you disable | |
12544 | the global common subexpression elimination pass by adding | |
12545 | @option{-fno-gcse} to the command line. | |
12546 | ||
12547 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12548 | ||
d77de738 | 12549 | @opindex fgcse-lm |
ddf6fe37 | 12550 | @item -fgcse-lm |
d77de738 ML |
12551 | When @option{-fgcse-lm} is enabled, global common subexpression elimination |
12552 | attempts to move loads that are only killed by stores into themselves. This | |
12553 | allows a loop containing a load/store sequence to be changed to a load outside | |
12554 | the loop, and a copy/store within the loop. | |
12555 | ||
12556 | Enabled by default when @option{-fgcse} is enabled. | |
12557 | ||
d77de738 | 12558 | @opindex fgcse-sm |
ddf6fe37 | 12559 | @item -fgcse-sm |
d77de738 ML |
12560 | When @option{-fgcse-sm} is enabled, a store motion pass is run after |
12561 | global common subexpression elimination. This pass attempts to move | |
12562 | stores out of loops. When used in conjunction with @option{-fgcse-lm}, | |
12563 | loops containing a load/store sequence can be changed to a load before | |
12564 | the loop and a store after the loop. | |
12565 | ||
12566 | Not enabled at any optimization level. | |
12567 | ||
d77de738 | 12568 | @opindex fgcse-las |
ddf6fe37 | 12569 | @item -fgcse-las |
d77de738 ML |
12570 | When @option{-fgcse-las} is enabled, the global common subexpression |
12571 | elimination pass eliminates redundant loads that come after stores to the | |
12572 | same memory location (both partial and full redundancies). | |
12573 | ||
12574 | Not enabled at any optimization level. | |
12575 | ||
d77de738 | 12576 | @opindex fgcse-after-reload |
ddf6fe37 | 12577 | @item -fgcse-after-reload |
d77de738 ML |
12578 | When @option{-fgcse-after-reload} is enabled, a redundant load elimination |
12579 | pass is performed after reload. The purpose of this pass is to clean up | |
12580 | redundant spilling. | |
12581 | ||
12582 | Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}. | |
12583 | ||
d77de738 | 12584 | @opindex faggressive-loop-optimizations |
ddf6fe37 | 12585 | @item -faggressive-loop-optimizations |
d77de738 ML |
12586 | This option tells the loop optimizer to use language constraints to |
12587 | derive bounds for the number of iterations of a loop. This assumes that | |
12588 | loop code does not invoke undefined behavior by for example causing signed | |
12589 | integer overflows or out-of-bound array accesses. The bounds for the | |
12590 | number of iterations of a loop are used to guide loop unrolling and peeling | |
12591 | and loop exit test optimizations. | |
12592 | This option is enabled by default. | |
12593 | ||
d77de738 | 12594 | @opindex funconstrained-commons |
ddf6fe37 | 12595 | @item -funconstrained-commons |
d77de738 ML |
12596 | This option tells the compiler that variables declared in common blocks |
12597 | (e.g.@: Fortran) may later be overridden with longer trailing arrays. This | |
12598 | prevents certain optimizations that depend on knowing the array bounds. | |
12599 | ||
d77de738 | 12600 | @opindex fcrossjumping |
ddf6fe37 | 12601 | @item -fcrossjumping |
d77de738 ML |
12602 | Perform cross-jumping transformation. |
12603 | This transformation unifies equivalent code and saves code size. The | |
12604 | resulting code may or may not perform better than without cross-jumping. | |
12605 | ||
12606 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12607 | ||
d77de738 | 12608 | @opindex fauto-inc-dec |
ddf6fe37 | 12609 | @item -fauto-inc-dec |
d77de738 ML |
12610 | Combine increments or decrements of addresses with memory accesses. |
12611 | This pass is always skipped on architectures that do not have | |
12612 | instructions to support this. Enabled by default at @option{-O1} and | |
12613 | higher on architectures that support this. | |
12614 | ||
d77de738 | 12615 | @opindex fdce |
ddf6fe37 | 12616 | @item -fdce |
d77de738 ML |
12617 | Perform dead code elimination (DCE) on RTL@. |
12618 | Enabled by default at @option{-O1} and higher. | |
12619 | ||
d77de738 | 12620 | @opindex fdse |
ddf6fe37 | 12621 | @item -fdse |
d77de738 ML |
12622 | Perform dead store elimination (DSE) on RTL@. |
12623 | Enabled by default at @option{-O1} and higher. | |
12624 | ||
d77de738 | 12625 | @opindex fif-conversion |
ddf6fe37 | 12626 | @item -fif-conversion |
d77de738 ML |
12627 | Attempt to transform conditional jumps into branch-less equivalents. This |
12628 | includes use of conditional moves, min, max, set flags and abs instructions, and | |
12629 | some tricks doable by standard arithmetics. The use of conditional execution | |
12630 | on chips where it is available is controlled by @option{-fif-conversion2}. | |
12631 | ||
12632 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but | |
12633 | not with @option{-Og}. | |
12634 | ||
d77de738 | 12635 | @opindex fif-conversion2 |
ddf6fe37 | 12636 | @item -fif-conversion2 |
d77de738 ML |
12637 | Use conditional execution (where available) to transform conditional jumps into |
12638 | branch-less equivalents. | |
12639 | ||
12640 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but | |
12641 | not with @option{-Og}. | |
12642 | ||
d77de738 | 12643 | @opindex fdeclone-ctor-dtor |
ddf6fe37 | 12644 | @item -fdeclone-ctor-dtor |
d77de738 ML |
12645 | The C++ ABI requires multiple entry points for constructors and |
12646 | destructors: one for a base subobject, one for a complete object, and | |
12647 | one for a virtual destructor that calls operator delete afterwards. | |
12648 | For a hierarchy with virtual bases, the base and complete variants are | |
12649 | clones, which means two copies of the function. With this option, the | |
12650 | base and complete variants are changed to be thunks that call a common | |
12651 | implementation. | |
12652 | ||
12653 | Enabled by @option{-Os}. | |
12654 | ||
d77de738 | 12655 | @opindex fdelete-null-pointer-checks |
ddf6fe37 | 12656 | @item -fdelete-null-pointer-checks |
d77de738 ML |
12657 | Assume that programs cannot safely dereference null pointers, and that |
12658 | no code or data element resides at address zero. | |
12659 | This option enables simple constant | |
12660 | folding optimizations at all optimization levels. In addition, other | |
12661 | optimization passes in GCC use this flag to control global dataflow | |
12662 | analyses that eliminate useless checks for null pointers; these assume | |
12663 | that a memory access to address zero always results in a trap, so | |
12664 | that if a pointer is checked after it has already been dereferenced, | |
12665 | it cannot be null. | |
12666 | ||
12667 | Note however that in some environments this assumption is not true. | |
12668 | Use @option{-fno-delete-null-pointer-checks} to disable this optimization | |
12669 | for programs that depend on that behavior. | |
12670 | ||
12671 | This option is enabled by default on most targets. On Nios II ELF, it | |
12672 | defaults to off. On AVR and MSP430, this option is completely disabled. | |
12673 | ||
12674 | Passes that use the dataflow information | |
12675 | are enabled independently at different optimization levels. | |
12676 | ||
d77de738 | 12677 | @opindex fdevirtualize |
ddf6fe37 | 12678 | @item -fdevirtualize |
d77de738 ML |
12679 | Attempt to convert calls to virtual functions to direct calls. This |
12680 | is done both within a procedure and interprocedurally as part of | |
12681 | indirect inlining (@option{-findirect-inlining}) and interprocedural constant | |
12682 | propagation (@option{-fipa-cp}). | |
12683 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12684 | ||
d77de738 | 12685 | @opindex fdevirtualize-speculatively |
ddf6fe37 | 12686 | @item -fdevirtualize-speculatively |
d77de738 ML |
12687 | Attempt to convert calls to virtual functions to speculative direct calls. |
12688 | Based on the analysis of the type inheritance graph, determine for a given call | |
12689 | the set of likely targets. If the set is small, preferably of size 1, change | |
12690 | the call into a conditional deciding between direct and indirect calls. The | |
12691 | speculative calls enable more optimizations, such as inlining. When they seem | |
12692 | useless after further optimization, they are converted back into original form. | |
12693 | ||
d77de738 | 12694 | @opindex fdevirtualize-at-ltrans |
ddf6fe37 | 12695 | @item -fdevirtualize-at-ltrans |
d77de738 ML |
12696 | Stream extra information needed for aggressive devirtualization when running |
12697 | the link-time optimizer in local transformation mode. | |
12698 | This option enables more devirtualization but | |
12699 | significantly increases the size of streamed data. For this reason it is | |
12700 | disabled by default. | |
12701 | ||
d77de738 | 12702 | @opindex fexpensive-optimizations |
ddf6fe37 | 12703 | @item -fexpensive-optimizations |
d77de738 ML |
12704 | Perform a number of minor optimizations that are relatively expensive. |
12705 | ||
12706 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12707 | ||
d77de738 | 12708 | @opindex free |
ddf6fe37 | 12709 | @item -free |
d77de738 ML |
12710 | Attempt to remove redundant extension instructions. This is especially |
12711 | helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit | |
12712 | registers after writing to their lower 32-bit half. | |
12713 | ||
88ae53a3 LC |
12714 | Enabled for Alpha, AArch64, LoongArch, PowerPC, RISC-V, SPARC, h83000 and x86 at |
12715 | levels @option{-O2}, @option{-O3}, @option{-Os}. | |
d77de738 | 12716 | |
d77de738 ML |
12717 | @opindex fno-lifetime-dse |
12718 | @opindex flifetime-dse | |
ddf6fe37 | 12719 | @item -fno-lifetime-dse |
d77de738 ML |
12720 | In C++ the value of an object is only affected by changes within its |
12721 | lifetime: when the constructor begins, the object has an indeterminate | |
12722 | value, and any changes during the lifetime of the object are dead when | |
12723 | the object is destroyed. Normally dead store elimination will take | |
12724 | advantage of this; if your code relies on the value of the object | |
12725 | storage persisting beyond the lifetime of the object, you can use this | |
12726 | flag to disable this optimization. To preserve stores before the | |
12727 | constructor starts (e.g.@: because your operator new clears the object | |
12728 | storage) but still treat the object as dead after the destructor, you | |
12729 | can use @option{-flifetime-dse=1}. The default behavior can be | |
12730 | explicitly selected with @option{-flifetime-dse=2}. | |
12731 | @option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}. | |
12732 | ||
d77de738 | 12733 | @opindex flive-range-shrinkage |
ddf6fe37 | 12734 | @item -flive-range-shrinkage |
d77de738 ML |
12735 | Attempt to decrease register pressure through register live range |
12736 | shrinkage. This is helpful for fast processors with small or moderate | |
12737 | size register sets. | |
12738 | ||
d77de738 | 12739 | @opindex fira-algorithm |
ddf6fe37 | 12740 | @item -fira-algorithm=@var{algorithm} |
d77de738 ML |
12741 | Use the specified coloring algorithm for the integrated register |
12742 | allocator. The @var{algorithm} argument can be @samp{priority}, which | |
12743 | specifies Chow's priority coloring, or @samp{CB}, which specifies | |
12744 | Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented | |
12745 | for all architectures, but for those targets that do support it, it is | |
12746 | the default because it generates better code. | |
12747 | ||
d77de738 | 12748 | @opindex fira-region |
ddf6fe37 | 12749 | @item -fira-region=@var{region} |
d77de738 ML |
12750 | Use specified regions for the integrated register allocator. The |
12751 | @var{region} argument should be one of the following: | |
12752 | ||
12753 | @table @samp | |
12754 | ||
12755 | @item all | |
12756 | Use all loops as register allocation regions. | |
12757 | This can give the best results for machines with a small and/or | |
12758 | irregular register set. | |
12759 | ||
12760 | @item mixed | |
12761 | Use all loops except for loops with small register pressure | |
12762 | as the regions. This value usually gives | |
12763 | the best results in most cases and for most architectures, | |
12764 | and is enabled by default when compiling with optimization for speed | |
12765 | (@option{-O}, @option{-O2}, @dots{}). | |
12766 | ||
12767 | @item one | |
12768 | Use all functions as a single region. | |
12769 | This typically results in the smallest code size, and is enabled by default for | |
12770 | @option{-Os} or @option{-O0}. | |
12771 | ||
12772 | @end table | |
12773 | ||
d77de738 | 12774 | @opindex fira-hoist-pressure |
ddf6fe37 | 12775 | @item -fira-hoist-pressure |
d77de738 ML |
12776 | Use IRA to evaluate register pressure in the code hoisting pass for |
12777 | decisions to hoist expressions. This option usually results in smaller | |
12778 | code, but it can slow the compiler down. | |
12779 | ||
12780 | This option is enabled at level @option{-Os} for all targets. | |
12781 | ||
d77de738 | 12782 | @opindex fira-loop-pressure |
ddf6fe37 | 12783 | @item -fira-loop-pressure |
d77de738 ML |
12784 | Use IRA to evaluate register pressure in loops for decisions to move |
12785 | loop invariants. This option usually results in generation | |
12786 | of faster and smaller code on machines with large register files (>= 32 | |
12787 | registers), but it can slow the compiler down. | |
12788 | ||
12789 | This option is enabled at level @option{-O3} for some targets. | |
12790 | ||
d77de738 ML |
12791 | @opindex fno-ira-share-save-slots |
12792 | @opindex fira-share-save-slots | |
ddf6fe37 | 12793 | @item -fno-ira-share-save-slots |
d77de738 ML |
12794 | Disable sharing of stack slots used for saving call-used hard |
12795 | registers living through a call. Each hard register gets a | |
12796 | separate stack slot, and as a result function stack frames are | |
12797 | larger. | |
12798 | ||
d77de738 ML |
12799 | @opindex fno-ira-share-spill-slots |
12800 | @opindex fira-share-spill-slots | |
ddf6fe37 | 12801 | @item -fno-ira-share-spill-slots |
d77de738 ML |
12802 | Disable sharing of stack slots allocated for pseudo-registers. Each |
12803 | pseudo-register that does not get a hard register gets a separate | |
12804 | stack slot, and as a result function stack frames are larger. | |
12805 | ||
d77de738 | 12806 | @opindex flra-remat |
ddf6fe37 | 12807 | @item -flra-remat |
d77de738 ML |
12808 | Enable CFG-sensitive rematerialization in LRA. Instead of loading |
12809 | values of spilled pseudos, LRA tries to rematerialize (recalculate) | |
12810 | values if it is profitable. | |
12811 | ||
12812 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12813 | ||
d77de738 | 12814 | @opindex fdelayed-branch |
ddf6fe37 | 12815 | @item -fdelayed-branch |
d77de738 ML |
12816 | If supported for the target machine, attempt to reorder instructions |
12817 | to exploit instruction slots available after delayed branch | |
12818 | instructions. | |
12819 | ||
12820 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, | |
12821 | but not at @option{-Og}. | |
12822 | ||
d77de738 | 12823 | @opindex fschedule-insns |
ddf6fe37 | 12824 | @item -fschedule-insns |
d77de738 ML |
12825 | If supported for the target machine, attempt to reorder instructions to |
12826 | eliminate execution stalls due to required data being unavailable. This | |
12827 | helps machines that have slow floating point or memory load instructions | |
12828 | by allowing other instructions to be issued until the result of the load | |
12829 | or floating-point instruction is required. | |
12830 | ||
12831 | Enabled at levels @option{-O2}, @option{-O3}. | |
12832 | ||
d77de738 | 12833 | @opindex fschedule-insns2 |
ddf6fe37 | 12834 | @item -fschedule-insns2 |
d77de738 ML |
12835 | Similar to @option{-fschedule-insns}, but requests an additional pass of |
12836 | instruction scheduling after register allocation has been done. This is | |
12837 | especially useful on machines with a relatively small number of | |
12838 | registers and where memory load instructions take more than one cycle. | |
12839 | ||
12840 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12841 | ||
d77de738 ML |
12842 | @opindex fno-sched-interblock |
12843 | @opindex fsched-interblock | |
ddf6fe37 | 12844 | @item -fno-sched-interblock |
d77de738 ML |
12845 | Disable instruction scheduling across basic blocks, which |
12846 | is normally enabled when scheduling before register allocation, i.e.@: | |
12847 | with @option{-fschedule-insns} or at @option{-O2} or higher. | |
12848 | ||
d77de738 ML |
12849 | @opindex fno-sched-spec |
12850 | @opindex fsched-spec | |
ddf6fe37 | 12851 | @item -fno-sched-spec |
d77de738 ML |
12852 | Disable speculative motion of non-load instructions, which |
12853 | is normally enabled when scheduling before register allocation, i.e.@: | |
12854 | with @option{-fschedule-insns} or at @option{-O2} or higher. | |
12855 | ||
d77de738 | 12856 | @opindex fsched-pressure |
ddf6fe37 | 12857 | @item -fsched-pressure |
d77de738 ML |
12858 | Enable register pressure sensitive insn scheduling before register |
12859 | allocation. This only makes sense when scheduling before register | |
12860 | allocation is enabled, i.e.@: with @option{-fschedule-insns} or at | |
12861 | @option{-O2} or higher. Usage of this option can improve the | |
12862 | generated code and decrease its size by preventing register pressure | |
12863 | increase above the number of available hard registers and subsequent | |
12864 | spills in register allocation. | |
12865 | ||
d77de738 | 12866 | @opindex fsched-spec-load |
ddf6fe37 | 12867 | @item -fsched-spec-load |
d77de738 ML |
12868 | Allow speculative motion of some load instructions. This only makes |
12869 | sense when scheduling before register allocation, i.e.@: with | |
12870 | @option{-fschedule-insns} or at @option{-O2} or higher. | |
12871 | ||
d77de738 | 12872 | @opindex fsched-spec-load-dangerous |
ddf6fe37 | 12873 | @item -fsched-spec-load-dangerous |
d77de738 ML |
12874 | Allow speculative motion of more load instructions. This only makes |
12875 | sense when scheduling before register allocation, i.e.@: with | |
12876 | @option{-fschedule-insns} or at @option{-O2} or higher. | |
12877 | ||
ddf6fe37 | 12878 | @opindex fsched-stalled-insns |
d77de738 ML |
12879 | @item -fsched-stalled-insns |
12880 | @itemx -fsched-stalled-insns=@var{n} | |
d77de738 ML |
12881 | Define how many insns (if any) can be moved prematurely from the queue |
12882 | of stalled insns into the ready list during the second scheduling pass. | |
12883 | @option{-fno-sched-stalled-insns} means that no insns are moved | |
12884 | prematurely, @option{-fsched-stalled-insns=0} means there is no limit | |
12885 | on how many queued insns can be moved prematurely. | |
12886 | @option{-fsched-stalled-insns} without a value is equivalent to | |
12887 | @option{-fsched-stalled-insns=1}. | |
12888 | ||
ddf6fe37 | 12889 | @opindex fsched-stalled-insns-dep |
d77de738 ML |
12890 | @item -fsched-stalled-insns-dep |
12891 | @itemx -fsched-stalled-insns-dep=@var{n} | |
d77de738 ML |
12892 | Define how many insn groups (cycles) are examined for a dependency |
12893 | on a stalled insn that is a candidate for premature removal from the queue | |
12894 | of stalled insns. This has an effect only during the second scheduling pass, | |
12895 | and only if @option{-fsched-stalled-insns} is used. | |
12896 | @option{-fno-sched-stalled-insns-dep} is equivalent to | |
12897 | @option{-fsched-stalled-insns-dep=0}. | |
12898 | @option{-fsched-stalled-insns-dep} without a value is equivalent to | |
12899 | @option{-fsched-stalled-insns-dep=1}. | |
12900 | ||
d77de738 | 12901 | @opindex fsched2-use-superblocks |
ddf6fe37 | 12902 | @item -fsched2-use-superblocks |
d77de738 ML |
12903 | When scheduling after register allocation, use superblock scheduling. |
12904 | This allows motion across basic block boundaries, | |
12905 | resulting in faster schedules. This option is experimental, as not all machine | |
12906 | descriptions used by GCC model the CPU closely enough to avoid unreliable | |
12907 | results from the algorithm. | |
12908 | ||
12909 | This only makes sense when scheduling after register allocation, i.e.@: with | |
12910 | @option{-fschedule-insns2} or at @option{-O2} or higher. | |
12911 | ||
d77de738 | 12912 | @opindex fsched-group-heuristic |
ddf6fe37 | 12913 | @item -fsched-group-heuristic |
d77de738 ML |
12914 | Enable the group heuristic in the scheduler. This heuristic favors |
12915 | the instruction that belongs to a schedule group. This is enabled | |
12916 | by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns} | |
12917 | or @option{-fschedule-insns2} or at @option{-O2} or higher. | |
12918 | ||
d77de738 | 12919 | @opindex fsched-critical-path-heuristic |
ddf6fe37 | 12920 | @item -fsched-critical-path-heuristic |
d77de738 ML |
12921 | Enable the critical-path heuristic in the scheduler. This heuristic favors |
12922 | instructions on the critical path. This is enabled by default when | |
12923 | scheduling is enabled, i.e.@: with @option{-fschedule-insns} | |
12924 | or @option{-fschedule-insns2} or at @option{-O2} or higher. | |
12925 | ||
d77de738 | 12926 | @opindex fsched-spec-insn-heuristic |
ddf6fe37 | 12927 | @item -fsched-spec-insn-heuristic |
d77de738 ML |
12928 | Enable the speculative instruction heuristic in the scheduler. This |
12929 | heuristic favors speculative instructions with greater dependency weakness. | |
12930 | This is enabled by default when scheduling is enabled, i.e.@: | |
12931 | with @option{-fschedule-insns} or @option{-fschedule-insns2} | |
12932 | or at @option{-O2} or higher. | |
12933 | ||
d77de738 | 12934 | @opindex fsched-rank-heuristic |
ddf6fe37 | 12935 | @item -fsched-rank-heuristic |
d77de738 ML |
12936 | Enable the rank heuristic in the scheduler. This heuristic favors |
12937 | the instruction belonging to a basic block with greater size or frequency. | |
12938 | This is enabled by default when scheduling is enabled, i.e.@: | |
12939 | with @option{-fschedule-insns} or @option{-fschedule-insns2} or | |
12940 | at @option{-O2} or higher. | |
12941 | ||
d77de738 | 12942 | @opindex fsched-last-insn-heuristic |
ddf6fe37 | 12943 | @item -fsched-last-insn-heuristic |
d77de738 ML |
12944 | Enable the last-instruction heuristic in the scheduler. This heuristic |
12945 | favors the instruction that is less dependent on the last instruction | |
12946 | scheduled. This is enabled by default when scheduling is enabled, | |
12947 | i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or | |
12948 | at @option{-O2} or higher. | |
12949 | ||
d77de738 | 12950 | @opindex fsched-dep-count-heuristic |
ddf6fe37 | 12951 | @item -fsched-dep-count-heuristic |
d77de738 ML |
12952 | Enable the dependent-count heuristic in the scheduler. This heuristic |
12953 | favors the instruction that has more instructions depending on it. | |
12954 | This is enabled by default when scheduling is enabled, i.e.@: | |
12955 | with @option{-fschedule-insns} or @option{-fschedule-insns2} or | |
12956 | at @option{-O2} or higher. | |
12957 | ||
d77de738 | 12958 | @opindex freschedule-modulo-scheduled-loops |
ddf6fe37 | 12959 | @item -freschedule-modulo-scheduled-loops |
d77de738 ML |
12960 | Modulo scheduling is performed before traditional scheduling. If a loop |
12961 | is modulo scheduled, later scheduling passes may change its schedule. | |
12962 | Use this option to control that behavior. | |
12963 | ||
d77de738 | 12964 | @opindex fselective-scheduling |
ddf6fe37 | 12965 | @item -fselective-scheduling |
d77de738 ML |
12966 | Schedule instructions using selective scheduling algorithm. Selective |
12967 | scheduling runs instead of the first scheduler pass. | |
12968 | ||
d77de738 | 12969 | @opindex fselective-scheduling2 |
ddf6fe37 | 12970 | @item -fselective-scheduling2 |
d77de738 ML |
12971 | Schedule instructions using selective scheduling algorithm. Selective |
12972 | scheduling runs instead of the second scheduler pass. | |
12973 | ||
d77de738 | 12974 | @opindex fsel-sched-pipelining |
ddf6fe37 | 12975 | @item -fsel-sched-pipelining |
d77de738 ML |
12976 | Enable software pipelining of innermost loops during selective scheduling. |
12977 | This option has no effect unless one of @option{-fselective-scheduling} or | |
12978 | @option{-fselective-scheduling2} is turned on. | |
12979 | ||
d77de738 | 12980 | @opindex fsel-sched-pipelining-outer-loops |
ddf6fe37 | 12981 | @item -fsel-sched-pipelining-outer-loops |
d77de738 ML |
12982 | When pipelining loops during selective scheduling, also pipeline outer loops. |
12983 | This option has no effect unless @option{-fsel-sched-pipelining} is turned on. | |
12984 | ||
d77de738 | 12985 | @opindex fsemantic-interposition |
ddf6fe37 | 12986 | @item -fsemantic-interposition |
d77de738 ML |
12987 | Some object formats, like ELF, allow interposing of symbols by the |
12988 | dynamic linker. | |
12989 | This means that for symbols exported from the DSO, the compiler cannot perform | |
12990 | interprocedural propagation, inlining and other optimizations in anticipation | |
12991 | that the function or variable in question may change. While this feature is | |
12992 | useful, for example, to rewrite memory allocation functions by a debugging | |
12993 | implementation, it is expensive in the terms of code quality. | |
12994 | With @option{-fno-semantic-interposition} the compiler assumes that | |
12995 | if interposition happens for functions the overwriting function will have | |
12996 | precisely the same semantics (and side effects). | |
12997 | Similarly if interposition happens | |
12998 | for variables, the constructor of the variable will be the same. The flag | |
12999 | has no effect for functions explicitly declared inline | |
13000 | (where it is never allowed for interposition to change semantics) | |
13001 | and for symbols explicitly declared weak. | |
13002 | ||
d77de738 | 13003 | @opindex fshrink-wrap |
ddf6fe37 | 13004 | @item -fshrink-wrap |
d77de738 ML |
13005 | Emit function prologues only before parts of the function that need it, |
13006 | rather than at the top of the function. This flag is enabled by default at | |
13007 | @option{-O} and higher. | |
13008 | ||
d77de738 | 13009 | @opindex fshrink-wrap-separate |
ddf6fe37 | 13010 | @item -fshrink-wrap-separate |
d77de738 ML |
13011 | Shrink-wrap separate parts of the prologue and epilogue separately, so that |
13012 | those parts are only executed when needed. | |
13013 | This option is on by default, but has no effect unless @option{-fshrink-wrap} | |
13014 | is also turned on and the target supports this. | |
13015 | ||
d77de738 | 13016 | @opindex fcaller-saves |
ddf6fe37 | 13017 | @item -fcaller-saves |
d77de738 ML |
13018 | Enable allocation of values to registers that are clobbered by |
13019 | function calls, by emitting extra instructions to save and restore the | |
13020 | registers around such calls. Such allocation is done only when it | |
13021 | seems to result in better code. | |
13022 | ||
13023 | This option is always enabled by default on certain machines, usually | |
13024 | those which have no call-preserved registers to use instead. | |
13025 | ||
13026 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13027 | ||
d77de738 | 13028 | @opindex fcombine-stack-adjustments |
ddf6fe37 | 13029 | @item -fcombine-stack-adjustments |
d77de738 ML |
13030 | Tracks stack adjustments (pushes and pops) and stack memory references |
13031 | and then tries to find ways to combine them. | |
13032 | ||
13033 | Enabled by default at @option{-O1} and higher. | |
13034 | ||
d77de738 | 13035 | @opindex fipa-ra |
ddf6fe37 | 13036 | @item -fipa-ra |
d77de738 ML |
13037 | Use caller save registers for allocation if those registers are not used by |
13038 | any called function. In that case it is not necessary to save and restore | |
13039 | them around calls. This is only possible if called functions are part of | |
13040 | same compilation unit as current function and they are compiled before it. | |
13041 | ||
13042 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option | |
13043 | is disabled if generated code will be instrumented for profiling | |
13044 | (@option{-p}, or @option{-pg}) or if callee's register usage cannot be known | |
13045 | exactly (this happens on targets that do not expose prologues | |
13046 | and epilogues in RTL). | |
13047 | ||
d77de738 | 13048 | @opindex fconserve-stack |
ddf6fe37 | 13049 | @item -fconserve-stack |
d77de738 ML |
13050 | Attempt to minimize stack usage. The compiler attempts to use less |
13051 | stack space, even if that makes the program slower. This option | |
13052 | implies setting the @option{large-stack-frame} parameter to 100 | |
13053 | and the @option{large-stack-frame-growth} parameter to 400. | |
13054 | ||
d77de738 | 13055 | @opindex ftree-reassoc |
ddf6fe37 | 13056 | @item -ftree-reassoc |
d77de738 ML |
13057 | Perform reassociation on trees. This flag is enabled by default |
13058 | at @option{-O1} and higher. | |
13059 | ||
d77de738 | 13060 | @opindex fcode-hoisting |
ddf6fe37 | 13061 | @item -fcode-hoisting |
d77de738 ML |
13062 | Perform code hoisting. Code hoisting tries to move the |
13063 | evaluation of expressions executed on all paths to the function exit | |
13064 | as early as possible. This is especially useful as a code size | |
13065 | optimization, but it often helps for code speed as well. | |
13066 | This flag is enabled by default at @option{-O2} and higher. | |
13067 | ||
d77de738 | 13068 | @opindex ftree-pre |
ddf6fe37 | 13069 | @item -ftree-pre |
d77de738 ML |
13070 | Perform partial redundancy elimination (PRE) on trees. This flag is |
13071 | enabled by default at @option{-O2} and @option{-O3}. | |
13072 | ||
d77de738 | 13073 | @opindex ftree-partial-pre |
ddf6fe37 | 13074 | @item -ftree-partial-pre |
d77de738 ML |
13075 | Make partial redundancy elimination (PRE) more aggressive. This flag is |
13076 | enabled by default at @option{-O3}. | |
13077 | ||
d77de738 | 13078 | @opindex ftree-forwprop |
ddf6fe37 | 13079 | @item -ftree-forwprop |
d77de738 ML |
13080 | Perform forward propagation on trees. This flag is enabled by default |
13081 | at @option{-O1} and higher. | |
13082 | ||
d77de738 | 13083 | @opindex ftree-fre |
ddf6fe37 | 13084 | @item -ftree-fre |
d77de738 ML |
13085 | Perform full redundancy elimination (FRE) on trees. The difference |
13086 | between FRE and PRE is that FRE only considers expressions | |
13087 | that are computed on all paths leading to the redundant computation. | |
13088 | This analysis is faster than PRE, though it exposes fewer redundancies. | |
13089 | This flag is enabled by default at @option{-O1} and higher. | |
13090 | ||
d77de738 | 13091 | @opindex ftree-phiprop |
ddf6fe37 | 13092 | @item -ftree-phiprop |
d77de738 ML |
13093 | Perform hoisting of loads from conditional pointers on trees. This |
13094 | pass is enabled by default at @option{-O1} and higher. | |
13095 | ||
d77de738 | 13096 | @opindex fhoist-adjacent-loads |
ddf6fe37 | 13097 | @item -fhoist-adjacent-loads |
d77de738 ML |
13098 | Speculatively hoist loads from both branches of an if-then-else if the |
13099 | loads are from adjacent locations in the same structure and the target | |
13100 | architecture has a conditional move instruction. This flag is enabled | |
13101 | by default at @option{-O2} and higher. | |
13102 | ||
d77de738 | 13103 | @opindex ftree-copy-prop |
ddf6fe37 | 13104 | @item -ftree-copy-prop |
d77de738 ML |
13105 | Perform copy propagation on trees. This pass eliminates unnecessary |
13106 | copy operations. This flag is enabled by default at @option{-O1} and | |
13107 | higher. | |
13108 | ||
d77de738 | 13109 | @opindex fipa-pure-const |
ddf6fe37 | 13110 | @item -fipa-pure-const |
d77de738 ML |
13111 | Discover which functions are pure or constant. |
13112 | Enabled by default at @option{-O1} and higher. | |
13113 | ||
d77de738 | 13114 | @opindex fipa-reference |
ddf6fe37 | 13115 | @item -fipa-reference |
d77de738 ML |
13116 | Discover which static variables do not escape the |
13117 | compilation unit. | |
13118 | Enabled by default at @option{-O1} and higher. | |
13119 | ||
d77de738 | 13120 | @opindex fipa-reference-addressable |
ddf6fe37 | 13121 | @item -fipa-reference-addressable |
d77de738 ML |
13122 | Discover read-only, write-only and non-addressable static variables. |
13123 | Enabled by default at @option{-O1} and higher. | |
13124 | ||
d77de738 | 13125 | @opindex fipa-stack-alignment |
ddf6fe37 | 13126 | @item -fipa-stack-alignment |
d77de738 ML |
13127 | Reduce stack alignment on call sites if possible. |
13128 | Enabled by default. | |
13129 | ||
d77de738 | 13130 | @opindex fipa-pta |
ddf6fe37 | 13131 | @item -fipa-pta |
d77de738 ML |
13132 | Perform interprocedural pointer analysis and interprocedural modification |
13133 | and reference analysis. This option can cause excessive memory and | |
13134 | compile-time usage on large compilation units. It is not enabled by | |
13135 | default at any optimization level. | |
13136 | ||
d77de738 | 13137 | @opindex fipa-profile |
ddf6fe37 | 13138 | @item -fipa-profile |
d77de738 ML |
13139 | Perform interprocedural profile propagation. The functions called only from |
13140 | cold functions are marked as cold. Also functions executed once (such as | |
13141 | @code{cold}, @code{noreturn}, static constructors or destructors) are | |
13142 | identified. Cold functions and loop less parts of functions executed once are | |
13143 | then optimized for size. | |
13144 | Enabled by default at @option{-O1} and higher. | |
13145 | ||
d77de738 | 13146 | @opindex fipa-modref |
ddf6fe37 | 13147 | @item -fipa-modref |
d77de738 ML |
13148 | Perform interprocedural mod/ref analysis. This optimization analyzes the side |
13149 | effects of functions (memory locations that are modified or referenced) and | |
13150 | enables better optimization across the function call boundary. This flag is | |
13151 | enabled by default at @option{-O1} and higher. | |
13152 | ||
d77de738 | 13153 | @opindex fipa-cp |
ddf6fe37 | 13154 | @item -fipa-cp |
d77de738 ML |
13155 | Perform interprocedural constant propagation. |
13156 | This optimization analyzes the program to determine when values passed | |
13157 | to functions are constants and then optimizes accordingly. | |
13158 | This optimization can substantially increase performance | |
13159 | if the application has constants passed to functions. | |
13160 | This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}. | |
13161 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13162 | ||
d77de738 | 13163 | @opindex fipa-cp-clone |
ddf6fe37 | 13164 | @item -fipa-cp-clone |
d77de738 ML |
13165 | Perform function cloning to make interprocedural constant propagation stronger. |
13166 | When enabled, interprocedural constant propagation performs function cloning | |
13167 | when externally visible function can be called with constant arguments. | |
13168 | Because this optimization can create multiple copies of functions, | |
13169 | it may significantly increase code size | |
13170 | (see @option{--param ipa-cp-unit-growth=@var{value}}). | |
13171 | This flag is enabled by default at @option{-O3}. | |
13172 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13173 | ||
d77de738 | 13174 | @opindex fipa-bit-cp |
ddf6fe37 | 13175 | @item -fipa-bit-cp |
d77de738 ML |
13176 | When enabled, perform interprocedural bitwise constant |
13177 | propagation. This flag is enabled by default at @option{-O2} and | |
13178 | by @option{-fprofile-use} and @option{-fauto-profile}. | |
13179 | It requires that @option{-fipa-cp} is enabled. | |
13180 | ||
d77de738 | 13181 | @opindex fipa-vrp |
ddf6fe37 | 13182 | @item -fipa-vrp |
d77de738 ML |
13183 | When enabled, perform interprocedural propagation of value |
13184 | ranges. This flag is enabled by default at @option{-O2}. It requires | |
13185 | that @option{-fipa-cp} is enabled. | |
13186 | ||
d77de738 | 13187 | @opindex fipa-icf |
ddf6fe37 | 13188 | @item -fipa-icf |
d77de738 ML |
13189 | Perform Identical Code Folding for functions and read-only variables. |
13190 | The optimization reduces code size and may disturb unwind stacks by replacing | |
13191 | a function by equivalent one with a different name. The optimization works | |
13192 | more effectively with link-time optimization enabled. | |
13193 | ||
13194 | Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF | |
13195 | works on different levels and thus the optimizations are not same - there are | |
13196 | equivalences that are found only by GCC and equivalences found only by Gold. | |
13197 | ||
13198 | This flag is enabled by default at @option{-O2} and @option{-Os}. | |
13199 | ||
d77de738 | 13200 | @opindex flive-patching |
ddf6fe37 | 13201 | @item -flive-patching=@var{level} |
d77de738 ML |
13202 | Control GCC's optimizations to produce output suitable for live-patching. |
13203 | ||
13204 | If the compiler's optimization uses a function's body or information extracted | |
13205 | from its body to optimize/change another function, the latter is called an | |
13206 | impacted function of the former. If a function is patched, its impacted | |
13207 | functions should be patched too. | |
13208 | ||
13209 | The impacted functions are determined by the compiler's interprocedural | |
13210 | optimizations. For example, a caller is impacted when inlining a function | |
13211 | into its caller, | |
13212 | cloning a function and changing its caller to call this new clone, | |
13213 | or extracting a function's pureness/constness information to optimize | |
13214 | its direct or indirect callers, etc. | |
13215 | ||
13216 | Usually, the more IPA optimizations enabled, the larger the number of | |
13217 | impacted functions for each function. In order to control the number of | |
13218 | impacted functions and more easily compute the list of impacted function, | |
13219 | IPA optimizations can be partially enabled at two different levels. | |
13220 | ||
13221 | The @var{level} argument should be one of the following: | |
13222 | ||
13223 | @table @samp | |
13224 | ||
13225 | @item inline-clone | |
13226 | ||
13227 | Only enable inlining and cloning optimizations, which includes inlining, | |
13228 | cloning, interprocedural scalar replacement of aggregates and partial inlining. | |
13229 | As a result, when patching a function, all its callers and its clones' | |
13230 | callers are impacted, therefore need to be patched as well. | |
13231 | ||
13232 | @option{-flive-patching=inline-clone} disables the following optimization flags: | |
43b72ede AA |
13233 | @gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra |
13234 | -fipa-icf -fipa-icf-functions -fipa-icf-variables | |
13235 | -fipa-bit-cp -fipa-vrp -fipa-pure-const | |
13236 | -fipa-reference-addressable | |
d77de738 ML |
13237 | -fipa-stack-alignment -fipa-modref} |
13238 | ||
13239 | @item inline-only-static | |
13240 | ||
13241 | Only enable inlining of static functions. | |
13242 | As a result, when patching a static function, all its callers are impacted | |
13243 | and so need to be patched as well. | |
13244 | ||
13245 | In addition to all the flags that @option{-flive-patching=inline-clone} | |
13246 | disables, | |
13247 | @option{-flive-patching=inline-only-static} disables the following additional | |
13248 | optimization flags: | |
13249 | @gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp} | |
13250 | ||
13251 | @end table | |
13252 | ||
13253 | When @option{-flive-patching} is specified without any value, the default value | |
13254 | is @var{inline-clone}. | |
13255 | ||
13256 | This flag is disabled by default. | |
13257 | ||
13258 | Note that @option{-flive-patching} is not supported with link-time optimization | |
13259 | (@option{-flto}). | |
13260 | ||
d77de738 | 13261 | @opindex fisolate-erroneous-paths-dereference |
ddf6fe37 | 13262 | @item -fisolate-erroneous-paths-dereference |
d77de738 ML |
13263 | Detect paths that trigger erroneous or undefined behavior due to |
13264 | dereferencing a null pointer. Isolate those paths from the main control | |
13265 | flow and turn the statement with erroneous or undefined behavior into a trap. | |
13266 | This flag is enabled by default at @option{-O2} and higher and depends on | |
13267 | @option{-fdelete-null-pointer-checks} also being enabled. | |
13268 | ||
d77de738 | 13269 | @opindex fisolate-erroneous-paths-attribute |
ddf6fe37 | 13270 | @item -fisolate-erroneous-paths-attribute |
d77de738 ML |
13271 | Detect paths that trigger erroneous or undefined behavior due to a null value |
13272 | being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull} | |
13273 | attribute. Isolate those paths from the main control flow and turn the | |
13274 | statement with erroneous or undefined behavior into a trap. This is not | |
13275 | currently enabled, but may be enabled by @option{-O2} in the future. | |
13276 | ||
d77de738 | 13277 | @opindex ftree-sink |
ddf6fe37 | 13278 | @item -ftree-sink |
d77de738 ML |
13279 | Perform forward store motion on trees. This flag is |
13280 | enabled by default at @option{-O1} and higher. | |
13281 | ||
d77de738 | 13282 | @opindex ftree-bit-ccp |
ddf6fe37 | 13283 | @item -ftree-bit-ccp |
d77de738 ML |
13284 | Perform sparse conditional bit constant propagation on trees and propagate |
13285 | pointer alignment information. | |
13286 | This pass only operates on local scalar variables and is enabled by default | |
13287 | at @option{-O1} and higher, except for @option{-Og}. | |
13288 | It requires that @option{-ftree-ccp} is enabled. | |
13289 | ||
d77de738 | 13290 | @opindex ftree-ccp |
ddf6fe37 | 13291 | @item -ftree-ccp |
d77de738 ML |
13292 | Perform sparse conditional constant propagation (CCP) on trees. This |
13293 | pass only operates on local scalar variables and is enabled by default | |
13294 | at @option{-O1} and higher. | |
13295 | ||
d77de738 | 13296 | @opindex fssa-backprop |
ddf6fe37 | 13297 | @item -fssa-backprop |
d77de738 ML |
13298 | Propagate information about uses of a value up the definition chain |
13299 | in order to simplify the definitions. For example, this pass strips | |
13300 | sign operations if the sign of a value never matters. The flag is | |
13301 | enabled by default at @option{-O1} and higher. | |
13302 | ||
d77de738 | 13303 | @opindex fssa-phiopt |
ddf6fe37 | 13304 | @item -fssa-phiopt |
d77de738 ML |
13305 | Perform pattern matching on SSA PHI nodes to optimize conditional |
13306 | code. This pass is enabled by default at @option{-O1} and higher, | |
13307 | except for @option{-Og}. | |
13308 | ||
d77de738 | 13309 | @opindex ftree-switch-conversion |
ddf6fe37 | 13310 | @item -ftree-switch-conversion |
d77de738 ML |
13311 | Perform conversion of simple initializations in a switch to |
13312 | initializations from a scalar array. This flag is enabled by default | |
13313 | at @option{-O2} and higher. | |
13314 | ||
d77de738 | 13315 | @opindex ftree-tail-merge |
ddf6fe37 | 13316 | @item -ftree-tail-merge |
d77de738 ML |
13317 | Look for identical code sequences. When found, replace one with a jump to the |
13318 | other. This optimization is known as tail merging or cross jumping. This flag | |
13319 | is enabled by default at @option{-O2} and higher. The compilation time | |
13320 | in this pass can | |
13321 | be limited using @option{max-tail-merge-comparisons} parameter and | |
13322 | @option{max-tail-merge-iterations} parameter. | |
13323 | ||
d77de738 | 13324 | @opindex ftree-dce |
ddf6fe37 | 13325 | @item -ftree-dce |
d77de738 ML |
13326 | Perform dead code elimination (DCE) on trees. This flag is enabled by |
13327 | default at @option{-O1} and higher. | |
13328 | ||
d77de738 | 13329 | @opindex ftree-builtin-call-dce |
ddf6fe37 | 13330 | @item -ftree-builtin-call-dce |
d77de738 ML |
13331 | Perform conditional dead code elimination (DCE) for calls to built-in functions |
13332 | that may set @code{errno} but are otherwise free of side effects. This flag is | |
13333 | enabled by default at @option{-O2} and higher if @option{-Os} is not also | |
13334 | specified. | |
13335 | ||
d77de738 ML |
13336 | @opindex ffinite-loops |
13337 | @opindex fno-finite-loops | |
ddf6fe37 | 13338 | @item -ffinite-loops |
d77de738 ML |
13339 | Assume that a loop with an exit will eventually take the exit and not loop |
13340 | indefinitely. This allows the compiler to remove loops that otherwise have | |
13341 | no side-effects, not considering eventual endless looping as such. | |
13342 | ||
13343 | This option is enabled by default at @option{-O2} for C++ with -std=c++11 | |
13344 | or higher. | |
13345 | ||
d77de738 | 13346 | @opindex ftree-dominator-opts |
ddf6fe37 | 13347 | @item -ftree-dominator-opts |
d77de738 ML |
13348 | Perform a variety of simple scalar cleanups (constant/copy |
13349 | propagation, redundancy elimination, range propagation and expression | |
13350 | simplification) based on a dominator tree traversal. This also | |
13351 | performs jump threading (to reduce jumps to jumps). This flag is | |
13352 | enabled by default at @option{-O1} and higher. | |
13353 | ||
d77de738 | 13354 | @opindex ftree-dse |
ddf6fe37 | 13355 | @item -ftree-dse |
d77de738 ML |
13356 | Perform dead store elimination (DSE) on trees. A dead store is a store into |
13357 | a memory location that is later overwritten by another store without | |
13358 | any intervening loads. In this case the earlier store can be deleted. This | |
13359 | flag is enabled by default at @option{-O1} and higher. | |
13360 | ||
d77de738 | 13361 | @opindex ftree-ch |
ddf6fe37 | 13362 | @item -ftree-ch |
d77de738 ML |
13363 | Perform loop header copying on trees. This is beneficial since it increases |
13364 | effectiveness of code motion optimizations. It also saves one jump. This flag | |
13365 | is enabled by default at @option{-O1} and higher. It is not enabled | |
13366 | for @option{-Os}, since it usually increases code size. | |
13367 | ||
d77de738 | 13368 | @opindex ftree-loop-optimize |
ddf6fe37 | 13369 | @item -ftree-loop-optimize |
d77de738 ML |
13370 | Perform loop optimizations on trees. This flag is enabled by default |
13371 | at @option{-O1} and higher. | |
13372 | ||
d77de738 ML |
13373 | @opindex ftree-loop-linear |
13374 | @opindex floop-strip-mine | |
13375 | @opindex floop-block | |
ddf6fe37 AA |
13376 | @item -ftree-loop-linear |
13377 | @itemx -floop-strip-mine | |
13378 | @itemx -floop-block | |
d77de738 ML |
13379 | Perform loop nest optimizations. Same as |
13380 | @option{-floop-nest-optimize}. To use this code transformation, GCC has | |
13381 | to be configured with @option{--with-isl} to enable the Graphite loop | |
13382 | transformation infrastructure. | |
13383 | ||
d77de738 | 13384 | @opindex fgraphite-identity |
ddf6fe37 | 13385 | @item -fgraphite-identity |
d77de738 ML |
13386 | Enable the identity transformation for graphite. For every SCoP we generate |
13387 | the polyhedral representation and transform it back to gimple. Using | |
13388 | @option{-fgraphite-identity} we can check the costs or benefits of the | |
13389 | GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations | |
13390 | are also performed by the code generator isl, like index splitting and | |
13391 | dead code elimination in loops. | |
13392 | ||
d77de738 | 13393 | @opindex floop-nest-optimize |
ddf6fe37 | 13394 | @item -floop-nest-optimize |
d77de738 ML |
13395 | Enable the isl based loop nest optimizer. This is a generic loop nest |
13396 | optimizer based on the Pluto optimization algorithms. It calculates a loop | |
13397 | structure optimized for data-locality and parallelism. This option | |
13398 | is experimental. | |
13399 | ||
d77de738 | 13400 | @opindex floop-parallelize-all |
ddf6fe37 | 13401 | @item -floop-parallelize-all |
d77de738 ML |
13402 | Use the Graphite data dependence analysis to identify loops that can |
13403 | be parallelized. Parallelize all the loops that can be analyzed to | |
13404 | not contain loop carried dependences without checking that it is | |
13405 | profitable to parallelize the loops. | |
13406 | ||
d77de738 | 13407 | @opindex ftree-coalesce-vars |
ddf6fe37 | 13408 | @item -ftree-coalesce-vars |
d77de738 ML |
13409 | While transforming the program out of the SSA representation, attempt to |
13410 | reduce copying by coalescing versions of different user-defined | |
13411 | variables, instead of just compiler temporaries. This may severely | |
13412 | limit the ability to debug an optimized program compiled with | |
13413 | @option{-fno-var-tracking-assignments}. In the negated form, this flag | |
13414 | prevents SSA coalescing of user variables. This option is enabled by | |
13415 | default if optimization is enabled, and it does very little otherwise. | |
13416 | ||
d77de738 | 13417 | @opindex ftree-loop-if-convert |
ddf6fe37 | 13418 | @item -ftree-loop-if-convert |
d77de738 ML |
13419 | Attempt to transform conditional jumps in the innermost loops to |
13420 | branch-less equivalents. The intent is to remove control-flow from | |
13421 | the innermost loops in order to improve the ability of the | |
13422 | vectorization pass to handle these loops. This is enabled by default | |
13423 | if vectorization is enabled. | |
13424 | ||
d77de738 | 13425 | @opindex ftree-loop-distribution |
ddf6fe37 | 13426 | @item -ftree-loop-distribution |
d77de738 ML |
13427 | Perform loop distribution. This flag can improve cache performance on |
13428 | big loop bodies and allow further loop optimizations, like | |
13429 | parallelization or vectorization, to take place. For example, the loop | |
13430 | @smallexample | |
13431 | DO I = 1, N | |
13432 | A(I) = B(I) + C | |
13433 | D(I) = E(I) * F | |
13434 | ENDDO | |
13435 | @end smallexample | |
13436 | is transformed to | |
13437 | @smallexample | |
13438 | DO I = 1, N | |
13439 | A(I) = B(I) + C | |
13440 | ENDDO | |
13441 | DO I = 1, N | |
13442 | D(I) = E(I) * F | |
13443 | ENDDO | |
13444 | @end smallexample | |
13445 | This flag is enabled by default at @option{-O3}. | |
13446 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13447 | ||
d77de738 | 13448 | @opindex ftree-loop-distribute-patterns |
ddf6fe37 | 13449 | @item -ftree-loop-distribute-patterns |
d77de738 ML |
13450 | Perform loop distribution of patterns that can be code generated with |
13451 | calls to a library. This flag is enabled by default at @option{-O2} and | |
13452 | higher, and by @option{-fprofile-use} and @option{-fauto-profile}. | |
13453 | ||
13454 | This pass distributes the initialization loops and generates a call to | |
13455 | memset zero. For example, the loop | |
13456 | @smallexample | |
13457 | DO I = 1, N | |
13458 | A(I) = 0 | |
13459 | B(I) = A(I) + I | |
13460 | ENDDO | |
13461 | @end smallexample | |
13462 | is transformed to | |
13463 | @smallexample | |
13464 | DO I = 1, N | |
13465 | A(I) = 0 | |
13466 | ENDDO | |
13467 | DO I = 1, N | |
13468 | B(I) = A(I) + I | |
13469 | ENDDO | |
13470 | @end smallexample | |
13471 | and the initialization loop is transformed into a call to memset zero. | |
13472 | This flag is enabled by default at @option{-O3}. | |
13473 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13474 | ||
d77de738 | 13475 | @opindex floop-interchange |
ddf6fe37 | 13476 | @item -floop-interchange |
d77de738 ML |
13477 | Perform loop interchange outside of graphite. This flag can improve cache |
13478 | performance on loop nest and allow further loop optimizations, like | |
13479 | vectorization, to take place. For example, the loop | |
13480 | @smallexample | |
13481 | for (int i = 0; i < N; i++) | |
13482 | for (int j = 0; j < N; j++) | |
13483 | for (int k = 0; k < N; k++) | |
13484 | c[i][j] = c[i][j] + a[i][k]*b[k][j]; | |
13485 | @end smallexample | |
13486 | is transformed to | |
13487 | @smallexample | |
13488 | for (int i = 0; i < N; i++) | |
13489 | for (int k = 0; k < N; k++) | |
13490 | for (int j = 0; j < N; j++) | |
13491 | c[i][j] = c[i][j] + a[i][k]*b[k][j]; | |
13492 | @end smallexample | |
13493 | This flag is enabled by default at @option{-O3}. | |
13494 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13495 | ||
d77de738 | 13496 | @opindex floop-unroll-and-jam |
ddf6fe37 | 13497 | @item -floop-unroll-and-jam |
d77de738 ML |
13498 | Apply unroll and jam transformations on feasible loops. In a loop |
13499 | nest this unrolls the outer loop by some factor and fuses the resulting | |
13500 | multiple inner loops. This flag is enabled by default at @option{-O3}. | |
13501 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13502 | ||
d77de738 | 13503 | @opindex ftree-loop-im |
ddf6fe37 | 13504 | @item -ftree-loop-im |
d77de738 ML |
13505 | Perform loop invariant motion on trees. This pass moves only invariants that |
13506 | are hard to handle at RTL level (function calls, operations that expand to | |
13507 | nontrivial sequences of insns). With @option{-funswitch-loops} it also moves | |
13508 | operands of conditions that are invariant out of the loop, so that we can use | |
13509 | just trivial invariantness analysis in loop unswitching. The pass also includes | |
13510 | store motion. | |
13511 | ||
d77de738 | 13512 | @opindex ftree-loop-ivcanon |
ddf6fe37 | 13513 | @item -ftree-loop-ivcanon |
d77de738 ML |
13514 | Create a canonical counter for number of iterations in loops for which |
13515 | determining number of iterations requires complicated analysis. Later | |
13516 | optimizations then may determine the number easily. Useful especially | |
13517 | in connection with unrolling. | |
13518 | ||
d77de738 | 13519 | @opindex ftree-scev-cprop |
ddf6fe37 | 13520 | @item -ftree-scev-cprop |
d77de738 ML |
13521 | Perform final value replacement. If a variable is modified in a loop |
13522 | in such a way that its value when exiting the loop can be determined using | |
13523 | only its initial value and the number of loop iterations, replace uses of | |
13524 | the final value by such a computation, provided it is sufficiently cheap. | |
13525 | This reduces data dependencies and may allow further simplifications. | |
13526 | Enabled by default at @option{-O1} and higher. | |
13527 | ||
d77de738 | 13528 | @opindex fivopts |
ddf6fe37 | 13529 | @item -fivopts |
d77de738 ML |
13530 | Perform induction variable optimizations (strength reduction, induction |
13531 | variable merging and induction variable elimination) on trees. | |
13532 | ||
d77de738 | 13533 | @opindex ftree-parallelize-loops |
ddf6fe37 | 13534 | @item -ftree-parallelize-loops=n |
d77de738 ML |
13535 | Parallelize loops, i.e., split their iteration space to run in n threads. |
13536 | This is only possible for loops whose iterations are independent | |
13537 | and can be arbitrarily reordered. The optimization is only | |
13538 | profitable on multiprocessor machines, for loops that are CPU-intensive, | |
13539 | rather than constrained e.g.@: by memory bandwidth. This option | |
13540 | implies @option{-pthread}, and thus is only supported on targets | |
13541 | that have support for @option{-pthread}. | |
13542 | ||
d77de738 | 13543 | @opindex ftree-pta |
ddf6fe37 | 13544 | @item -ftree-pta |
d77de738 ML |
13545 | Perform function-local points-to analysis on trees. This flag is |
13546 | enabled by default at @option{-O1} and higher, except for @option{-Og}. | |
13547 | ||
d77de738 | 13548 | @opindex ftree-sra |
ddf6fe37 | 13549 | @item -ftree-sra |
d77de738 ML |
13550 | Perform scalar replacement of aggregates. This pass replaces structure |
13551 | references with scalars to prevent committing structures to memory too | |
13552 | early. This flag is enabled by default at @option{-O1} and higher, | |
13553 | except for @option{-Og}. | |
13554 | ||
d77de738 | 13555 | @opindex fstore-merging |
ddf6fe37 | 13556 | @item -fstore-merging |
d77de738 ML |
13557 | Perform merging of narrow stores to consecutive memory addresses. This pass |
13558 | merges contiguous stores of immediate values narrower than a word into fewer | |
13559 | wider stores to reduce the number of instructions. This is enabled by default | |
13560 | at @option{-O2} and higher as well as @option{-Os}. | |
13561 | ||
d77de738 | 13562 | @opindex ftree-ter |
ddf6fe37 | 13563 | @item -ftree-ter |
d77de738 ML |
13564 | Perform temporary expression replacement during the SSA->normal phase. Single |
13565 | use/single def temporaries are replaced at their use location with their | |
13566 | defining expression. This results in non-GIMPLE code, but gives the expanders | |
13567 | much more complex trees to work on resulting in better RTL generation. This is | |
13568 | enabled by default at @option{-O1} and higher. | |
13569 | ||
d77de738 | 13570 | @opindex ftree-slsr |
ddf6fe37 | 13571 | @item -ftree-slsr |
d77de738 ML |
13572 | Perform straight-line strength reduction on trees. This recognizes related |
13573 | expressions involving multiplications and replaces them by less expensive | |
13574 | calculations when possible. This is enabled by default at @option{-O1} and | |
13575 | higher. | |
13576 | ||
d77de738 | 13577 | @opindex ftree-vectorize |
ddf6fe37 | 13578 | @item -ftree-vectorize |
d77de738 ML |
13579 | Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize} |
13580 | and @option{-ftree-slp-vectorize} if not explicitly specified. | |
13581 | ||
d77de738 | 13582 | @opindex ftree-loop-vectorize |
ddf6fe37 | 13583 | @item -ftree-loop-vectorize |
d77de738 ML |
13584 | Perform loop vectorization on trees. This flag is enabled by default at |
13585 | @option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use}, | |
13586 | and @option{-fauto-profile}. | |
13587 | ||
d77de738 | 13588 | @opindex ftree-slp-vectorize |
ddf6fe37 | 13589 | @item -ftree-slp-vectorize |
d77de738 ML |
13590 | Perform basic block vectorization on trees. This flag is enabled by default at |
13591 | @option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use}, | |
13592 | and @option{-fauto-profile}. | |
13593 | ||
d77de738 | 13594 | @opindex ftrivial-auto-var-init |
ddf6fe37 | 13595 | @item -ftrivial-auto-var-init=@var{choice} |
d77de738 ML |
13596 | Initialize automatic variables with either a pattern or with zeroes to increase |
13597 | the security and predictability of a program by preventing uninitialized memory | |
13598 | disclosure and use. | |
13599 | GCC still considers an automatic variable that doesn't have an explicit | |
13600 | initializer as uninitialized, @option{-Wuninitialized} and | |
13601 | @option{-Wanalyzer-use-of-uninitialized-value} will still report | |
8f4634fb RB |
13602 | warning messages on such automatic variables and the compiler will |
13603 | perform optimization as if the variable were uninitialized. | |
d77de738 ML |
13604 | With this option, GCC will also initialize any padding of automatic variables |
13605 | that have structure or union types to zeroes. | |
13606 | However, the current implementation cannot initialize automatic variables that | |
13607 | are declared between the controlling expression and the first case of a | |
13608 | @code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all | |
13609 | such cases. | |
13610 | ||
13611 | The three values of @var{choice} are: | |
13612 | ||
13613 | @itemize @bullet | |
13614 | @item | |
13615 | @samp{uninitialized} doesn't initialize any automatic variables. | |
13616 | This is C and C++'s default. | |
13617 | ||
13618 | @item | |
13619 | @samp{pattern} Initialize automatic variables with values which will likely | |
13620 | transform logic bugs into crashes down the line, are easily recognized in a | |
13621 | crash dump and without being values that programmers can rely on for useful | |
13622 | program semantics. | |
13623 | The current value is byte-repeatable pattern with byte "0xFE". | |
13624 | The values used for pattern initialization might be changed in the future. | |
13625 | ||
13626 | @item | |
13627 | @samp{zero} Initialize automatic variables with zeroes. | |
13628 | @end itemize | |
13629 | ||
13630 | The default is @samp{uninitialized}. | |
13631 | ||
13632 | You can control this behavior for a specific variable by using the variable | |
13633 | attribute @code{uninitialized} (@pxref{Variable Attributes}). | |
13634 | ||
d77de738 | 13635 | @opindex fvect-cost-model |
ddf6fe37 | 13636 | @item -fvect-cost-model=@var{model} |
d77de738 ML |
13637 | Alter the cost model used for vectorization. The @var{model} argument |
13638 | should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or | |
13639 | @samp{very-cheap}. | |
13640 | With the @samp{unlimited} model the vectorized code-path is assumed | |
13641 | to be profitable while with the @samp{dynamic} model a runtime check | |
13642 | guards the vectorized code-path to enable it only for iteration | |
13643 | counts that will likely execute faster than when executing the original | |
13644 | scalar loop. The @samp{cheap} model disables vectorization of | |
13645 | loops where doing so would be cost prohibitive for example due to | |
13646 | required runtime checks for data dependence or alignment but otherwise | |
13647 | is equal to the @samp{dynamic} model. The @samp{very-cheap} model only | |
13648 | allows vectorization if the vector code would entirely replace the | |
13649 | scalar code that is being vectorized. For example, if each iteration | |
13650 | of a vectorized loop would only be able to handle exactly four iterations | |
13651 | of the scalar loop, the @samp{very-cheap} model would only allow | |
13652 | vectorization if the scalar iteration count is known to be a multiple | |
13653 | of four. | |
13654 | ||
13655 | The default cost model depends on other optimization flags and is | |
13656 | either @samp{dynamic} or @samp{cheap}. | |
13657 | ||
d77de738 | 13658 | @opindex fsimd-cost-model |
ddf6fe37 | 13659 | @item -fsimd-cost-model=@var{model} |
d77de738 ML |
13660 | Alter the cost model used for vectorization of loops marked with the OpenMP |
13661 | simd directive. The @var{model} argument should be one of | |
13662 | @samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model} | |
13663 | have the same meaning as described in @option{-fvect-cost-model} and by | |
13664 | default a cost model defined with @option{-fvect-cost-model} is used. | |
13665 | ||
d77de738 | 13666 | @opindex ftree-vrp |
ddf6fe37 | 13667 | @item -ftree-vrp |
d77de738 ML |
13668 | Perform Value Range Propagation on trees. This is similar to the |
13669 | constant propagation pass, but instead of values, ranges of values are | |
13670 | propagated. This allows the optimizers to remove unnecessary range | |
13671 | checks like array bound checks and null pointer checks. This is | |
13672 | enabled by default at @option{-O2} and higher. Null pointer check | |
13673 | elimination is only done if @option{-fdelete-null-pointer-checks} is | |
13674 | enabled. | |
13675 | ||
d77de738 | 13676 | @opindex fsplit-paths |
ddf6fe37 | 13677 | @item -fsplit-paths |
d77de738 ML |
13678 | Split paths leading to loop backedges. This can improve dead code |
13679 | elimination and common subexpression elimination. This is enabled by | |
13680 | default at @option{-O3} and above. | |
13681 | ||
d77de738 | 13682 | @opindex fsplit-ivs-in-unroller |
ddf6fe37 | 13683 | @item -fsplit-ivs-in-unroller |
d77de738 ML |
13684 | Enables expression of values of induction variables in later iterations |
13685 | of the unrolled loop using the value in the first iteration. This breaks | |
13686 | long dependency chains, thus improving efficiency of the scheduling passes. | |
13687 | ||
13688 | A combination of @option{-fweb} and CSE is often sufficient to obtain the | |
13689 | same effect. However, that is not reliable in cases where the loop body | |
13690 | is more complicated than a single basic block. It also does not work at all | |
13691 | on some architectures due to restrictions in the CSE pass. | |
13692 | ||
13693 | This optimization is enabled by default. | |
13694 | ||
d77de738 | 13695 | @opindex fvariable-expansion-in-unroller |
ddf6fe37 | 13696 | @item -fvariable-expansion-in-unroller |
d77de738 ML |
13697 | With this option, the compiler creates multiple copies of some |
13698 | local variables when unrolling a loop, which can result in superior code. | |
13699 | ||
13700 | This optimization is enabled by default for PowerPC targets, but disabled | |
13701 | by default otherwise. | |
13702 | ||
d77de738 | 13703 | @opindex fpartial-inlining |
ddf6fe37 | 13704 | @item -fpartial-inlining |
d77de738 ML |
13705 | Inline parts of functions. This option has any effect only |
13706 | when inlining itself is turned on by the @option{-finline-functions} | |
13707 | or @option{-finline-small-functions} options. | |
13708 | ||
13709 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13710 | ||
d77de738 | 13711 | @opindex fpredictive-commoning |
ddf6fe37 | 13712 | @item -fpredictive-commoning |
d77de738 ML |
13713 | Perform predictive commoning optimization, i.e., reusing computations |
13714 | (especially memory loads and stores) performed in previous | |
13715 | iterations of loops. | |
13716 | ||
13717 | This option is enabled at level @option{-O3}. | |
13718 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13719 | ||
d77de738 | 13720 | @opindex fprefetch-loop-arrays |
ddf6fe37 | 13721 | @item -fprefetch-loop-arrays |
d77de738 ML |
13722 | If supported by the target machine, generate instructions to prefetch |
13723 | memory to improve the performance of loops that access large arrays. | |
13724 | ||
13725 | This option may generate better or worse code; results are highly | |
13726 | dependent on the structure of loops within the source code. | |
13727 | ||
13728 | Disabled at level @option{-Os}. | |
13729 | ||
d77de738 ML |
13730 | @opindex fno-printf-return-value |
13731 | @opindex fprintf-return-value | |
ddf6fe37 | 13732 | @item -fno-printf-return-value |
d77de738 ML |
13733 | Do not substitute constants for known return value of formatted output |
13734 | functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and | |
13735 | @code{vsnprintf} (but not @code{printf} of @code{fprintf}). This | |
13736 | transformation allows GCC to optimize or even eliminate branches based | |
13737 | on the known return value of these functions called with arguments that | |
13738 | are either constant, or whose values are known to be in a range that | |
13739 | makes determining the exact return value possible. For example, when | |
13740 | @option{-fprintf-return-value} is in effect, both the branch and the | |
13741 | body of the @code{if} statement (but not the call to @code{snprint}) | |
13742 | can be optimized away when @code{i} is a 32-bit or smaller integer | |
13743 | because the return value is guaranteed to be at most 8. | |
13744 | ||
13745 | @smallexample | |
13746 | char buf[9]; | |
13747 | if (snprintf (buf, "%08x", i) >= sizeof buf) | |
13748 | @dots{} | |
13749 | @end smallexample | |
13750 | ||
13751 | The @option{-fprintf-return-value} option relies on other optimizations | |
13752 | and yields best results with @option{-O2} and above. It works in tandem | |
13753 | with the @option{-Wformat-overflow} and @option{-Wformat-truncation} | |
13754 | options. The @option{-fprintf-return-value} option is enabled by default. | |
13755 | ||
d77de738 ML |
13756 | @opindex fno-peephole |
13757 | @opindex fpeephole | |
13758 | @opindex fno-peephole2 | |
13759 | @opindex fpeephole2 | |
ddf6fe37 AA |
13760 | @item -fno-peephole |
13761 | @itemx -fno-peephole2 | |
d77de738 ML |
13762 | Disable any machine-specific peephole optimizations. The difference |
13763 | between @option{-fno-peephole} and @option{-fno-peephole2} is in how they | |
13764 | are implemented in the compiler; some targets use one, some use the | |
13765 | other, a few use both. | |
13766 | ||
13767 | @option{-fpeephole} is enabled by default. | |
13768 | @option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13769 | ||
d77de738 ML |
13770 | @opindex fno-guess-branch-probability |
13771 | @opindex fguess-branch-probability | |
ddf6fe37 | 13772 | @item -fno-guess-branch-probability |
d77de738 ML |
13773 | Do not guess branch probabilities using heuristics. |
13774 | ||
13775 | GCC uses heuristics to guess branch probabilities if they are | |
13776 | not provided by profiling feedback (@option{-fprofile-arcs}). These | |
13777 | heuristics are based on the control flow graph. If some branch probabilities | |
13778 | are specified by @code{__builtin_expect}, then the heuristics are | |
13779 | used to guess branch probabilities for the rest of the control flow graph, | |
13780 | taking the @code{__builtin_expect} info into account. The interactions | |
13781 | between the heuristics and @code{__builtin_expect} can be complex, and in | |
13782 | some cases, it may be useful to disable the heuristics so that the effects | |
13783 | of @code{__builtin_expect} are easier to understand. | |
13784 | ||
13785 | It is also possible to specify expected probability of the expression | |
13786 | with @code{__builtin_expect_with_probability} built-in function. | |
13787 | ||
13788 | The default is @option{-fguess-branch-probability} at levels | |
13789 | @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}. | |
13790 | ||
d77de738 | 13791 | @opindex freorder-blocks |
ddf6fe37 | 13792 | @item -freorder-blocks |
d77de738 ML |
13793 | Reorder basic blocks in the compiled function in order to reduce number of |
13794 | taken branches and improve code locality. | |
13795 | ||
13796 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
13797 | ||
d77de738 | 13798 | @opindex freorder-blocks-algorithm |
ddf6fe37 | 13799 | @item -freorder-blocks-algorithm=@var{algorithm} |
d77de738 ML |
13800 | Use the specified algorithm for basic block reordering. The |
13801 | @var{algorithm} argument can be @samp{simple}, which does not increase | |
13802 | code size (except sometimes due to secondary effects like alignment), | |
13803 | or @samp{stc}, the ``software trace cache'' algorithm, which tries to | |
13804 | put all often executed code together, minimizing the number of branches | |
13805 | executed by making extra copies of code. | |
13806 | ||
13807 | The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and | |
13808 | @samp{stc} at levels @option{-O2}, @option{-O3}. | |
13809 | ||
d77de738 | 13810 | @opindex freorder-blocks-and-partition |
ddf6fe37 | 13811 | @item -freorder-blocks-and-partition |
d77de738 ML |
13812 | In addition to reordering basic blocks in the compiled function, in order |
13813 | to reduce number of taken branches, partitions hot and cold basic blocks | |
13814 | into separate sections of the assembly and @file{.o} files, to improve | |
13815 | paging and cache locality performance. | |
13816 | ||
13817 | This optimization is automatically turned off in the presence of | |
13818 | exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined | |
13819 | section attribute and on any architecture that does not support named | |
13820 | sections. When @option{-fsplit-stack} is used this option is not | |
13821 | enabled by default (to avoid linker errors), but may be enabled | |
13822 | explicitly (if using a working linker). | |
13823 | ||
13824 | Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13825 | ||
d77de738 | 13826 | @opindex freorder-functions |
ddf6fe37 | 13827 | @item -freorder-functions |
d77de738 ML |
13828 | Reorder functions in the object file in order to |
13829 | improve code locality. This is implemented by using special | |
13830 | subsections @code{.text.hot} for most frequently executed functions and | |
13831 | @code{.text.unlikely} for unlikely executed functions. Reordering is done by | |
13832 | the linker so object file format must support named sections and linker must | |
13833 | place them in a reasonable way. | |
13834 | ||
13835 | This option isn't effective unless you either provide profile feedback | |
13836 | (see @option{-fprofile-arcs} for details) or manually annotate functions with | |
13837 | @code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}). | |
13838 | ||
13839 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13840 | ||
d77de738 | 13841 | @opindex fstrict-aliasing |
ddf6fe37 | 13842 | @item -fstrict-aliasing |
d77de738 ML |
13843 | Allow the compiler to assume the strictest aliasing rules applicable to |
13844 | the language being compiled. For C (and C++), this activates | |
13845 | optimizations based on the type of expressions. In particular, an | |
13846 | object of one type is assumed never to reside at the same address as an | |
13847 | object of a different type, unless the types are almost the same. For | |
13848 | example, an @code{unsigned int} can alias an @code{int}, but not a | |
13849 | @code{void*} or a @code{double}. A character type may alias any other | |
13850 | type. | |
13851 | ||
13852 | @anchor{Type-punning}Pay special attention to code like this: | |
13853 | @smallexample | |
13854 | union a_union @{ | |
13855 | int i; | |
13856 | double d; | |
13857 | @}; | |
13858 | ||
13859 | int f() @{ | |
13860 | union a_union t; | |
13861 | t.d = 3.0; | |
13862 | return t.i; | |
13863 | @} | |
13864 | @end smallexample | |
13865 | The practice of reading from a different union member than the one most | |
13866 | recently written to (called ``type-punning'') is common. Even with | |
13867 | @option{-fstrict-aliasing}, type-punning is allowed, provided the memory | |
13868 | is accessed through the union type. So, the code above works as | |
13869 | expected. @xref{Structures unions enumerations and bit-fields | |
13870 | implementation}. However, this code might not: | |
13871 | @smallexample | |
13872 | int f() @{ | |
13873 | union a_union t; | |
13874 | int* ip; | |
13875 | t.d = 3.0; | |
13876 | ip = &t.i; | |
13877 | return *ip; | |
13878 | @} | |
13879 | @end smallexample | |
13880 | ||
13881 | Similarly, access by taking the address, casting the resulting pointer | |
13882 | and dereferencing the result has undefined behavior, even if the cast | |
13883 | uses a union type, e.g.: | |
13884 | @smallexample | |
13885 | int f() @{ | |
13886 | double d = 3.0; | |
13887 | return ((union a_union *) &d)->i; | |
13888 | @} | |
13889 | @end smallexample | |
13890 | ||
13891 | The @option{-fstrict-aliasing} option is enabled at levels | |
13892 | @option{-O2}, @option{-O3}, @option{-Os}. | |
13893 | ||
d77de738 | 13894 | @opindex fipa-strict-aliasing |
ddf6fe37 | 13895 | @item -fipa-strict-aliasing |
d77de738 ML |
13896 | Controls whether rules of @option{-fstrict-aliasing} are applied across |
13897 | function boundaries. Note that if multiple functions gets inlined into a | |
13898 | single function the memory accesses are no longer considered to be crossing a | |
13899 | function boundary. | |
13900 | ||
13901 | The @option{-fipa-strict-aliasing} option is enabled by default and is | |
13902 | effective only in combination with @option{-fstrict-aliasing}. | |
13903 | ||
ddf6fe37 | 13904 | @opindex falign-functions |
d77de738 ML |
13905 | @item -falign-functions |
13906 | @itemx -falign-functions=@var{n} | |
13907 | @itemx -falign-functions=@var{n}:@var{m} | |
13908 | @itemx -falign-functions=@var{n}:@var{m}:@var{n2} | |
13909 | @itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
13910 | Align the start of functions to the next power-of-two greater than or |
13911 | equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at | |
13912 | least the first @var{m} bytes of the function can be fetched by the CPU | |
13913 | without crossing an @var{n}-byte alignment boundary. | |
13914 | ||
13915 | If @var{m} is not specified, it defaults to @var{n}. | |
13916 | ||
13917 | Examples: @option{-falign-functions=32} aligns functions to the next | |
13918 | 32-byte boundary, @option{-falign-functions=24} aligns to the next | |
13919 | 32-byte boundary only if this can be done by skipping 23 bytes or less, | |
13920 | @option{-falign-functions=32:7} aligns to the next | |
13921 | 32-byte boundary only if this can be done by skipping 6 bytes or less. | |
13922 | ||
13923 | The second pair of @var{n2}:@var{m2} values allows you to specify | |
13924 | a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to | |
13925 | the next 64-byte boundary if this can be done by skipping 6 bytes or less, | |
13926 | otherwise aligns to the next 32-byte boundary if this can be done | |
13927 | by skipping 2 bytes or less. | |
13928 | If @var{m2} is not specified, it defaults to @var{n2}. | |
13929 | ||
13930 | Some assemblers only support this flag when @var{n} is a power of two; | |
13931 | in that case, it is rounded up. | |
13932 | ||
13933 | @option{-fno-align-functions} and @option{-falign-functions=1} are | |
13934 | equivalent and mean that functions are not aligned. | |
13935 | ||
13936 | If @var{n} is not specified or is zero, use a machine-dependent default. | |
13937 | The maximum allowed @var{n} option value is 65536. | |
13938 | ||
13939 | Enabled at levels @option{-O2}, @option{-O3}. | |
13940 | ||
13941 | @item -flimit-function-alignment | |
13942 | If this option is enabled, the compiler tries to avoid unnecessarily | |
13943 | overaligning functions. It attempts to instruct the assembler to align | |
13944 | by the amount specified by @option{-falign-functions}, but not to | |
13945 | skip more bytes than the size of the function. | |
13946 | ||
ddf6fe37 | 13947 | @opindex falign-labels |
d77de738 ML |
13948 | @item -falign-labels |
13949 | @itemx -falign-labels=@var{n} | |
13950 | @itemx -falign-labels=@var{n}:@var{m} | |
13951 | @itemx -falign-labels=@var{n}:@var{m}:@var{n2} | |
13952 | @itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
13953 | Align all branch targets to a power-of-two boundary. |
13954 | ||
13955 | Parameters of this option are analogous to the @option{-falign-functions} option. | |
13956 | @option{-fno-align-labels} and @option{-falign-labels=1} are | |
13957 | equivalent and mean that labels are not aligned. | |
13958 | ||
13959 | If @option{-falign-loops} or @option{-falign-jumps} are applicable and | |
13960 | are greater than this value, then their values are used instead. | |
13961 | ||
13962 | If @var{n} is not specified or is zero, use a machine-dependent default | |
13963 | which is very likely to be @samp{1}, meaning no alignment. | |
13964 | The maximum allowed @var{n} option value is 65536. | |
13965 | ||
13966 | Enabled at levels @option{-O2}, @option{-O3}. | |
13967 | ||
ddf6fe37 | 13968 | @opindex falign-loops |
d77de738 ML |
13969 | @item -falign-loops |
13970 | @itemx -falign-loops=@var{n} | |
13971 | @itemx -falign-loops=@var{n}:@var{m} | |
13972 | @itemx -falign-loops=@var{n}:@var{m}:@var{n2} | |
13973 | @itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
13974 | Align loops to a power-of-two boundary. If the loops are executed |
13975 | many times, this makes up for any execution of the dummy padding | |
13976 | instructions. | |
13977 | ||
13978 | If @option{-falign-labels} is greater than this value, then its value | |
13979 | is used instead. | |
13980 | ||
13981 | Parameters of this option are analogous to the @option{-falign-functions} option. | |
13982 | @option{-fno-align-loops} and @option{-falign-loops=1} are | |
13983 | equivalent and mean that loops are not aligned. | |
13984 | The maximum allowed @var{n} option value is 65536. | |
13985 | ||
13986 | If @var{n} is not specified or is zero, use a machine-dependent default. | |
13987 | ||
13988 | Enabled at levels @option{-O2}, @option{-O3}. | |
13989 | ||
ddf6fe37 | 13990 | @opindex falign-jumps |
d77de738 ML |
13991 | @item -falign-jumps |
13992 | @itemx -falign-jumps=@var{n} | |
13993 | @itemx -falign-jumps=@var{n}:@var{m} | |
13994 | @itemx -falign-jumps=@var{n}:@var{m}:@var{n2} | |
13995 | @itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
13996 | Align branch targets to a power-of-two boundary, for branch targets |
13997 | where the targets can only be reached by jumping. In this case, | |
13998 | no dummy operations need be executed. | |
13999 | ||
14000 | If @option{-falign-labels} is greater than this value, then its value | |
14001 | is used instead. | |
14002 | ||
14003 | Parameters of this option are analogous to the @option{-falign-functions} option. | |
14004 | @option{-fno-align-jumps} and @option{-falign-jumps=1} are | |
14005 | equivalent and mean that loops are not aligned. | |
14006 | ||
14007 | If @var{n} is not specified or is zero, use a machine-dependent default. | |
14008 | The maximum allowed @var{n} option value is 65536. | |
14009 | ||
14010 | Enabled at levels @option{-O2}, @option{-O3}. | |
14011 | ||
d77de738 | 14012 | @opindex fno-allocation-dce |
ddf6fe37 | 14013 | @item -fno-allocation-dce |
d77de738 ML |
14014 | Do not remove unused C++ allocations in dead code elimination. |
14015 | ||
d77de738 | 14016 | @opindex fallow-store-data-races |
ddf6fe37 | 14017 | @item -fallow-store-data-races |
d77de738 ML |
14018 | Allow the compiler to perform optimizations that may introduce new data races |
14019 | on stores, without proving that the variable cannot be concurrently accessed | |
14020 | by other threads. Does not affect optimization of local data. It is safe to | |
14021 | use this option if it is known that global data will not be accessed by | |
14022 | multiple threads. | |
14023 | ||
14024 | Examples of optimizations enabled by @option{-fallow-store-data-races} include | |
14025 | hoisting or if-conversions that may cause a value that was already in memory | |
14026 | to be re-written with that same value. Such re-writing is safe in a single | |
14027 | threaded context but may be unsafe in a multi-threaded context. Note that on | |
14028 | some processors, if-conversions may be required in order to enable | |
14029 | vectorization. | |
14030 | ||
14031 | Enabled at level @option{-Ofast}. | |
14032 | ||
d77de738 | 14033 | @opindex funit-at-a-time |
ddf6fe37 | 14034 | @item -funit-at-a-time |
d77de738 ML |
14035 | This option is left for compatibility reasons. @option{-funit-at-a-time} |
14036 | has no effect, while @option{-fno-unit-at-a-time} implies | |
14037 | @option{-fno-toplevel-reorder} and @option{-fno-section-anchors}. | |
14038 | ||
14039 | Enabled by default. | |
14040 | ||
d77de738 ML |
14041 | @opindex fno-toplevel-reorder |
14042 | @opindex ftoplevel-reorder | |
ddf6fe37 | 14043 | @item -fno-toplevel-reorder |
d77de738 ML |
14044 | Do not reorder top-level functions, variables, and @code{asm} |
14045 | statements. Output them in the same order that they appear in the | |
14046 | input file. When this option is used, unreferenced static variables | |
14047 | are not removed. This option is intended to support existing code | |
14048 | that relies on a particular ordering. For new code, it is better to | |
14049 | use attributes when possible. | |
14050 | ||
14051 | @option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and | |
14052 | also at @option{-O0} if @option{-fsection-anchors} is explicitly requested. | |
14053 | Additionally @option{-fno-toplevel-reorder} implies | |
14054 | @option{-fno-section-anchors}. | |
14055 | ||
d77de738 | 14056 | @opindex funreachable-traps |
ddf6fe37 | 14057 | @item -funreachable-traps |
d77de738 ML |
14058 | With this option, the compiler turns calls to |
14059 | @code{__builtin_unreachable} into traps, instead of using them for | |
14060 | optimization. This also affects any such calls implicitly generated | |
14061 | by the compiler. | |
14062 | ||
14063 | This option has the same effect as @option{-fsanitize=unreachable | |
14064 | -fsanitize-trap=unreachable}, but does not affect the values of those | |
14065 | options. If @option{-fsanitize=unreachable} is enabled, that option | |
14066 | takes priority over this one. | |
14067 | ||
14068 | This option is enabled by default at @option{-O0} and @option{-Og}. | |
14069 | ||
d77de738 | 14070 | @opindex fweb |
ddf6fe37 | 14071 | @item -fweb |
d77de738 ML |
14072 | Constructs webs as commonly used for register allocation purposes and assign |
14073 | each web individual pseudo register. This allows the register allocation pass | |
14074 | to operate on pseudos directly, but also strengthens several other optimization | |
14075 | passes, such as CSE, loop optimizer and trivial dead code remover. It can, | |
14076 | however, make debugging impossible, since variables no longer stay in a | |
14077 | ``home register''. | |
14078 | ||
14079 | Enabled by default with @option{-funroll-loops}. | |
14080 | ||
d77de738 | 14081 | @opindex fwhole-program |
ddf6fe37 | 14082 | @item -fwhole-program |
d77de738 ML |
14083 | Assume that the current compilation unit represents the whole program being |
14084 | compiled. All public functions and variables with the exception of @code{main} | |
14085 | and those merged by attribute @code{externally_visible} become static functions | |
14086 | and in effect are optimized more aggressively by interprocedural optimizers. | |
14087 | ||
39ebd3a9 JH |
14088 | With @option{-flto} this option has a limited use. In most cases the |
14089 | precise list of symbols used or exported from the binary is known the | |
14090 | resolution info passed to the link-time optimizer by the linker plugin. It is | |
14091 | still useful if no linker plugin is used or during incremental link step when | |
14092 | final code is produced (with @option{-flto} | |
14093 | @option{-flinker-output=nolto-rel}). | |
d77de738 | 14094 | |
d77de738 | 14095 | @opindex flto |
ddf6fe37 | 14096 | @item -flto[=@var{n}] |
d77de738 ML |
14097 | This option runs the standard link-time optimizer. When invoked |
14098 | with source code, it generates GIMPLE (one of GCC's internal | |
14099 | representations) and writes it to special ELF sections in the object | |
14100 | file. When the object files are linked together, all the function | |
14101 | bodies are read from these ELF sections and instantiated as if they | |
14102 | had been part of the same translation unit. | |
14103 | ||
14104 | To use the link-time optimizer, @option{-flto} and optimization | |
14105 | options should be specified at compile time and during the final link. | |
14106 | It is recommended that you compile all the files participating in the | |
14107 | same link with the same options and also specify those options at | |
14108 | link time. | |
14109 | For example: | |
14110 | ||
14111 | @smallexample | |
14112 | gcc -c -O2 -flto foo.c | |
14113 | gcc -c -O2 -flto bar.c | |
14114 | gcc -o myprog -flto -O2 foo.o bar.o | |
14115 | @end smallexample | |
14116 | ||
14117 | The first two invocations to GCC save a bytecode representation | |
14118 | of GIMPLE into special ELF sections inside @file{foo.o} and | |
14119 | @file{bar.o}. The final invocation reads the GIMPLE bytecode from | |
14120 | @file{foo.o} and @file{bar.o}, merges the two files into a single | |
14121 | internal image, and compiles the result as usual. Since both | |
14122 | @file{foo.o} and @file{bar.o} are merged into a single image, this | |
14123 | causes all the interprocedural analyses and optimizations in GCC to | |
14124 | work across the two files as if they were a single one. This means, | |
14125 | for example, that the inliner is able to inline functions in | |
14126 | @file{bar.o} into functions in @file{foo.o} and vice-versa. | |
14127 | ||
14128 | Another (simpler) way to enable link-time optimization is: | |
14129 | ||
14130 | @smallexample | |
14131 | gcc -o myprog -flto -O2 foo.c bar.c | |
14132 | @end smallexample | |
14133 | ||
14134 | The above generates bytecode for @file{foo.c} and @file{bar.c}, | |
14135 | merges them together into a single GIMPLE representation and optimizes | |
14136 | them as usual to produce @file{myprog}. | |
14137 | ||
14138 | The important thing to keep in mind is that to enable link-time | |
14139 | optimizations you need to use the GCC driver to perform the link step. | |
14140 | GCC automatically performs link-time optimization if any of the | |
14141 | objects involved were compiled with the @option{-flto} command-line option. | |
14142 | You can always override | |
14143 | the automatic decision to do link-time optimization | |
14144 | by passing @option{-fno-lto} to the link command. | |
14145 | ||
14146 | To make whole program optimization effective, it is necessary to make | |
14147 | certain whole program assumptions. The compiler needs to know | |
14148 | what functions and variables can be accessed by libraries and runtime | |
14149 | outside of the link-time optimized unit. When supported by the linker, | |
14150 | the linker plugin (see @option{-fuse-linker-plugin}) passes information | |
14151 | to the compiler about used and externally visible symbols. When | |
14152 | the linker plugin is not available, @option{-fwhole-program} should be | |
14153 | used to allow the compiler to make these assumptions, which leads | |
14154 | to more aggressive optimization decisions. | |
14155 | ||
14156 | When a file is compiled with @option{-flto} without | |
14157 | @option{-fuse-linker-plugin}, the generated object file is larger than | |
14158 | a regular object file because it contains GIMPLE bytecodes and the usual | |
14159 | final code (see @option{-ffat-lto-objects}). This means that | |
14160 | object files with LTO information can be linked as normal object | |
14161 | files; if @option{-fno-lto} is passed to the linker, no | |
14162 | interprocedural optimizations are applied. Note that when | |
14163 | @option{-fno-fat-lto-objects} is enabled the compile stage is faster | |
14164 | but you cannot perform a regular, non-LTO link on them. | |
14165 | ||
14166 | When producing the final binary, GCC only | |
14167 | applies link-time optimizations to those files that contain bytecode. | |
14168 | Therefore, you can mix and match object files and libraries with | |
14169 | GIMPLE bytecodes and final object code. GCC automatically selects | |
14170 | which files to optimize in LTO mode and which files to link without | |
14171 | further processing. | |
14172 | ||
14173 | Generally, options specified at link time override those | |
14174 | specified at compile time, although in some cases GCC attempts to infer | |
14175 | link-time options from the settings used to compile the input files. | |
14176 | ||
14177 | If you do not specify an optimization level option @option{-O} at | |
14178 | link time, then GCC uses the highest optimization level | |
14179 | used when compiling the object files. Note that it is generally | |
14180 | ineffective to specify an optimization level option only at link time and | |
14181 | not at compile time, for two reasons. First, compiling without | |
14182 | optimization suppresses compiler passes that gather information | |
14183 | needed for effective optimization at link time. Second, some early | |
14184 | optimization passes can be performed only at compile time and | |
14185 | not at link time. | |
14186 | ||
14187 | There are some code generation flags preserved by GCC when | |
14188 | generating bytecodes, as they need to be used during the final link. | |
14189 | Currently, the following options and their settings are taken from | |
14190 | the first object file that explicitly specifies them: | |
14191 | @option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions}, | |
14192 | @option{-fgnu-tm} and all the @option{-m} target flags. | |
14193 | ||
14194 | The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and | |
14195 | @option{-fPIE} are combined based on the following scheme: | |
14196 | ||
14197 | @smallexample | |
14198 | @option{-fPIC} + @option{-fpic} = @option{-fpic} | |
14199 | @option{-fPIC} + @option{-fno-pic} = @option{-fno-pic} | |
14200 | @option{-fpic/-fPIC} + (no option) = (no option) | |
14201 | @option{-fPIC} + @option{-fPIE} = @option{-fPIE} | |
14202 | @option{-fpic} + @option{-fPIE} = @option{-fpie} | |
14203 | @option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie} | |
14204 | @end smallexample | |
14205 | ||
14206 | Certain ABI-changing flags are required to match in all compilation units, | |
14207 | and trying to override this at link time with a conflicting value | |
14208 | is ignored. This includes options such as @option{-freg-struct-return} | |
14209 | and @option{-fpcc-struct-return}. | |
14210 | ||
14211 | Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow}, | |
14212 | @option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing} | |
14213 | are passed through to the link stage and merged conservatively for | |
14214 | conflicting translation units. Specifically | |
14215 | @option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take | |
14216 | precedence; and for example @option{-ffp-contract=off} takes precedence | |
14217 | over @option{-ffp-contract=fast}. You can override them at link time. | |
14218 | ||
14219 | Diagnostic options such as @option{-Wstringop-overflow} are passed | |
14220 | through to the link stage and their setting matches that of the | |
14221 | compile-step at function granularity. Note that this matters only | |
14222 | for diagnostics emitted during optimization. Note that code | |
14223 | transforms such as inlining can lead to warnings being enabled | |
14224 | or disabled for regions if code not consistent with the setting | |
14225 | at compile time. | |
14226 | ||
14227 | When you need to pass options to the assembler via @option{-Wa} or | |
14228 | @option{-Xassembler} make sure to either compile such translation | |
14229 | units with @option{-fno-lto} or consistently use the same assembler | |
14230 | options on all translation units. You can alternatively also | |
14231 | specify assembler options at LTO link time. | |
14232 | ||
14233 | To enable debug info generation you need to supply @option{-g} at | |
14234 | compile time. If any of the input files at link time were built | |
14235 | with debug info generation enabled the link will enable debug info | |
14236 | generation as well. Any elaborate debug info settings | |
14237 | like the dwarf level @option{-gdwarf-5} need to be explicitly repeated | |
14238 | at the linker command line and mixing different settings in different | |
14239 | translation units is discouraged. | |
14240 | ||
14241 | If LTO encounters objects with C linkage declared with incompatible | |
14242 | types in separate translation units to be linked together (undefined | |
14243 | behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be | |
14244 | issued. The behavior is still undefined at run time. Similar | |
14245 | diagnostics may be raised for other languages. | |
14246 | ||
14247 | Another feature of LTO is that it is possible to apply interprocedural | |
14248 | optimizations on files written in different languages: | |
14249 | ||
14250 | @smallexample | |
14251 | gcc -c -flto foo.c | |
14252 | g++ -c -flto bar.cc | |
14253 | gfortran -c -flto baz.f90 | |
14254 | g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran | |
14255 | @end smallexample | |
14256 | ||
14257 | Notice that the final link is done with @command{g++} to get the C++ | |
14258 | runtime libraries and @option{-lgfortran} is added to get the Fortran | |
14259 | runtime libraries. In general, when mixing languages in LTO mode, you | |
14260 | should use the same link command options as when mixing languages in a | |
14261 | regular (non-LTO) compilation. | |
14262 | ||
14263 | If object files containing GIMPLE bytecode are stored in a library archive, say | |
14264 | @file{libfoo.a}, it is possible to extract and use them in an LTO link if you | |
14265 | are using a linker with plugin support. To create static libraries suitable | |
14266 | for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar} | |
14267 | and @command{ranlib}; | |
14268 | to show the symbols of object files with GIMPLE bytecode, use | |
14269 | @command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib} | |
14270 | and @command{nm} have been compiled with plugin support. At link time, use the | |
14271 | flag @option{-fuse-linker-plugin} to ensure that the library participates in | |
14272 | the LTO optimization process: | |
14273 | ||
14274 | @smallexample | |
14275 | gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo | |
14276 | @end smallexample | |
14277 | ||
14278 | With the linker plugin enabled, the linker extracts the needed | |
14279 | GIMPLE files from @file{libfoo.a} and passes them on to the running GCC | |
14280 | to make them part of the aggregated GIMPLE image to be optimized. | |
14281 | ||
14282 | If you are not using a linker with plugin support and/or do not | |
14283 | enable the linker plugin, then the objects inside @file{libfoo.a} | |
14284 | are extracted and linked as usual, but they do not participate | |
14285 | in the LTO optimization process. In order to make a static library suitable | |
14286 | for both LTO optimization and usual linkage, compile its object files with | |
14287 | @option{-flto} @option{-ffat-lto-objects}. | |
14288 | ||
14289 | Link-time optimizations do not require the presence of the whole program to | |
14290 | operate. If the program does not require any symbols to be exported, it is | |
14291 | possible to combine @option{-flto} and @option{-fwhole-program} to allow | |
14292 | the interprocedural optimizers to use more aggressive assumptions which may | |
14293 | lead to improved optimization opportunities. | |
14294 | Use of @option{-fwhole-program} is not needed when linker plugin is | |
14295 | active (see @option{-fuse-linker-plugin}). | |
14296 | ||
14297 | The current implementation of LTO makes no | |
14298 | attempt to generate bytecode that is portable between different | |
14299 | types of hosts. The bytecode files are versioned and there is a | |
14300 | strict version check, so bytecode files generated in one version of | |
14301 | GCC do not work with an older or newer version of GCC. | |
14302 | ||
14303 | Link-time optimization does not work well with generation of debugging | |
14304 | information on systems other than those using a combination of ELF and | |
14305 | DWARF. | |
14306 | ||
14307 | If you specify the optional @var{n}, the optimization and code | |
14308 | generation done at link time is executed in parallel using @var{n} | |
14309 | parallel jobs by utilizing an installed @command{make} program. The | |
14310 | environment variable @env{MAKE} may be used to override the program | |
14311 | used. | |
14312 | ||
14313 | You can also specify @option{-flto=jobserver} to use GNU make's | |
14314 | job server mode to determine the number of parallel jobs. This | |
14315 | is useful when the Makefile calling GCC is already executing in parallel. | |
14316 | You must prepend a @samp{+} to the command recipe in the parent Makefile | |
14317 | for this to work. This option likely only works if @env{MAKE} is | |
14318 | GNU make. Even without the option value, GCC tries to automatically | |
14319 | detect a running GNU make's job server. | |
14320 | ||
14321 | Use @option{-flto=auto} to use GNU make's job server, if available, | |
14322 | or otherwise fall back to autodetection of the number of CPU threads | |
14323 | present in your system. | |
14324 | ||
d77de738 | 14325 | @opindex flto-partition |
ddf6fe37 | 14326 | @item -flto-partition=@var{alg} |
d77de738 ML |
14327 | Specify the partitioning algorithm used by the link-time optimizer. |
14328 | The value is either @samp{1to1} to specify a partitioning mirroring | |
14329 | the original source files or @samp{balanced} to specify partitioning | |
14330 | into equally sized chunks (whenever possible) or @samp{max} to create | |
14331 | new partition for every symbol where possible. Specifying @samp{none} | |
14332 | as an algorithm disables partitioning and streaming completely. | |
14333 | The default value is @samp{balanced}. While @samp{1to1} can be used | |
14334 | as an workaround for various code ordering issues, the @samp{max} | |
14335 | partitioning is intended for internal testing only. | |
14336 | The value @samp{one} specifies that exactly one partition should be | |
14337 | used while the value @samp{none} bypasses partitioning and executes | |
14338 | the link-time optimization step directly from the WPA phase. | |
14339 | ||
d77de738 | 14340 | @opindex flto-compression-level |
ddf6fe37 | 14341 | @item -flto-compression-level=@var{n} |
d77de738 ML |
14342 | This option specifies the level of compression used for intermediate |
14343 | language written to LTO object files, and is only meaningful in | |
14344 | conjunction with LTO mode (@option{-flto}). GCC currently supports two | |
14345 | LTO compression algorithms. For zstd, valid values are 0 (no compression) | |
14346 | to 19 (maximum compression), while zlib supports values from 0 to 9. | |
14347 | Values outside this range are clamped to either minimum or maximum | |
14348 | of the supported values. If the option is not given, | |
14349 | a default balanced compression setting is used. | |
14350 | ||
d77de738 | 14351 | @opindex fuse-linker-plugin |
ddf6fe37 | 14352 | @item -fuse-linker-plugin |
d77de738 ML |
14353 | Enables the use of a linker plugin during link-time optimization. This |
14354 | option relies on plugin support in the linker, which is available in gold | |
14355 | or in GNU ld 2.21 or newer. | |
14356 | ||
14357 | This option enables the extraction of object files with GIMPLE bytecode out | |
14358 | of library archives. This improves the quality of optimization by exposing | |
14359 | more code to the link-time optimizer. This information specifies what | |
14360 | symbols can be accessed externally (by non-LTO object or during dynamic | |
14361 | linking). Resulting code quality improvements on binaries (and shared | |
14362 | libraries that use hidden visibility) are similar to @option{-fwhole-program}. | |
14363 | See @option{-flto} for a description of the effect of this flag and how to | |
14364 | use it. | |
14365 | ||
14366 | This option is enabled by default when LTO support in GCC is enabled | |
14367 | and GCC was configured for use with | |
14368 | a linker supporting plugins (GNU ld 2.21 or newer or gold). | |
14369 | ||
d77de738 | 14370 | @opindex ffat-lto-objects |
ddf6fe37 | 14371 | @item -ffat-lto-objects |
d77de738 ML |
14372 | Fat LTO objects are object files that contain both the intermediate language |
14373 | and the object code. This makes them usable for both LTO linking and normal | |
14374 | linking. This option is effective only when compiling with @option{-flto} | |
14375 | and is ignored at link time. | |
14376 | ||
14377 | @option{-fno-fat-lto-objects} improves compilation time over plain LTO, but | |
14378 | requires the complete toolchain to be aware of LTO. It requires a linker with | |
14379 | linker plugin support for basic functionality. Additionally, | |
14380 | @command{nm}, @command{ar} and @command{ranlib} | |
14381 | need to support linker plugins to allow a full-featured build environment | |
14382 | (capable of building static libraries etc). GCC provides the @command{gcc-ar}, | |
14383 | @command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options | |
14384 | to these tools. With non fat LTO makefiles need to be modified to use them. | |
14385 | ||
14386 | Note that modern binutils provide plugin auto-load mechanism. | |
14387 | Installing the linker plugin into @file{$libdir/bfd-plugins} has the same | |
14388 | effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and | |
14389 | @command{gcc-ranlib}). | |
14390 | ||
14391 | The default is @option{-fno-fat-lto-objects} on targets with linker plugin | |
14392 | support. | |
14393 | ||
d77de738 | 14394 | @opindex fcompare-elim |
ddf6fe37 | 14395 | @item -fcompare-elim |
d77de738 ML |
14396 | After register allocation and post-register allocation instruction splitting, |
14397 | identify arithmetic instructions that compute processor flags similar to a | |
14398 | comparison operation based on that arithmetic. If possible, eliminate the | |
14399 | explicit comparison operation. | |
14400 | ||
14401 | This pass only applies to certain targets that cannot explicitly represent | |
14402 | the comparison operation before register allocation is complete. | |
14403 | ||
14404 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
14405 | ||
04c9cf5c MT |
14406 | @opindex ffold-mem-offsets |
14407 | @item -ffold-mem-offsets | |
14408 | @itemx -fno-fold-mem-offsets | |
14409 | Try to eliminate add instructions by folding them in memory loads/stores. | |
14410 | ||
14411 | Enabled at levels @option{-O2}, @option{-O3}. | |
14412 | ||
d77de738 | 14413 | @opindex fcprop-registers |
ddf6fe37 | 14414 | @item -fcprop-registers |
d77de738 ML |
14415 | After register allocation and post-register allocation instruction splitting, |
14416 | perform a copy-propagation pass to try to reduce scheduling dependencies | |
14417 | and occasionally eliminate the copy. | |
14418 | ||
14419 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
14420 | ||
d77de738 | 14421 | @opindex fprofile-correction |
ddf6fe37 | 14422 | @item -fprofile-correction |
d77de738 ML |
14423 | Profiles collected using an instrumented binary for multi-threaded programs may |
14424 | be inconsistent due to missed counter updates. When this option is specified, | |
14425 | GCC uses heuristics to correct or smooth out such inconsistencies. By | |
14426 | default, GCC emits an error message when an inconsistent profile is detected. | |
14427 | ||
14428 | This option is enabled by @option{-fauto-profile}. | |
14429 | ||
d77de738 | 14430 | @opindex fprofile-partial-training |
ddf6fe37 | 14431 | @item -fprofile-partial-training |
d77de738 ML |
14432 | With @code{-fprofile-use} all portions of programs not executed during train |
14433 | run are optimized agressively for size rather than speed. In some cases it is | |
14434 | not practical to train all possible hot paths in the program. (For | |
14435 | example, program may contain functions specific for a given hardware and | |
14436 | trianing may not cover all hardware configurations program is run on.) With | |
14437 | @code{-fprofile-partial-training} profile feedback will be ignored for all | |
14438 | functions not executed during the train run leading them to be optimized as if | |
14439 | they were compiled without profile feedback. This leads to better performance | |
14440 | when train run is not representative but also leads to significantly bigger | |
14441 | code. | |
14442 | ||
ddf6fe37 | 14443 | @opindex fprofile-use |
d77de738 ML |
14444 | @item -fprofile-use |
14445 | @itemx -fprofile-use=@var{path} | |
d77de738 ML |
14446 | Enable profile feedback-directed optimizations, |
14447 | and the following optimizations, many of which | |
14448 | are generally profitable only with profile feedback available: | |
14449 | ||
43b72ede AA |
14450 | @gccoptlist{-fbranch-probabilities -fprofile-values |
14451 | -funroll-loops -fpeel-loops -ftracer -fvpt | |
14452 | -finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp | |
14453 | -fpredictive-commoning -fsplit-loops -funswitch-loops | |
14454 | -fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize | |
14455 | -fvect-cost-model=dynamic -ftree-loop-distribute-patterns | |
d77de738 ML |
14456 | -fprofile-reorder-functions} |
14457 | ||
14458 | Before you can use this option, you must first generate profiling information. | |
14459 | @xref{Instrumentation Options}, for information about the | |
14460 | @option{-fprofile-generate} option. | |
14461 | ||
14462 | By default, GCC emits an error message if the feedback profiles do not | |
14463 | match the source code. This error can be turned into a warning by using | |
14464 | @option{-Wno-error=coverage-mismatch}. Note this may result in poorly | |
14465 | optimized code. Additionally, by default, GCC also emits a warning message if | |
14466 | the feedback profiles do not exist (see @option{-Wmissing-profile}). | |
14467 | ||
14468 | If @var{path} is specified, GCC looks at the @var{path} to find | |
14469 | the profile feedback data files. See @option{-fprofile-dir}. | |
14470 | ||
ddf6fe37 | 14471 | @opindex fauto-profile |
d77de738 ML |
14472 | @item -fauto-profile |
14473 | @itemx -fauto-profile=@var{path} | |
d77de738 ML |
14474 | Enable sampling-based feedback-directed optimizations, |
14475 | and the following optimizations, | |
14476 | many of which are generally profitable only with profile feedback available: | |
14477 | ||
43b72ede AA |
14478 | @gccoptlist{-fbranch-probabilities -fprofile-values |
14479 | -funroll-loops -fpeel-loops -ftracer -fvpt | |
14480 | -finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp | |
14481 | -fpredictive-commoning -fsplit-loops -funswitch-loops | |
14482 | -fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize | |
14483 | -fvect-cost-model=dynamic -ftree-loop-distribute-patterns | |
d77de738 ML |
14484 | -fprofile-correction} |
14485 | ||
14486 | @var{path} is the name of a file containing AutoFDO profile information. | |
14487 | If omitted, it defaults to @file{fbdata.afdo} in the current directory. | |
14488 | ||
14489 | Producing an AutoFDO profile data file requires running your program | |
14490 | with the @command{perf} utility on a supported GNU/Linux target system. | |
14491 | For more information, see @uref{https://perf.wiki.kernel.org/}. | |
14492 | ||
14493 | E.g. | |
14494 | @smallexample | |
14495 | perf record -e br_inst_retired:near_taken -b -o perf.data \ | |
14496 | -- your_program | |
14497 | @end smallexample | |
14498 | ||
14499 | Then use the @command{create_gcov} tool to convert the raw profile data | |
14500 | to a format that can be used by GCC.@ You must also supply the | |
14501 | unstripped binary for your program to this tool. | |
14502 | See @uref{https://github.com/google/autofdo}. | |
14503 | ||
14504 | E.g. | |
14505 | @smallexample | |
14506 | create_gcov --binary=your_program.unstripped --profile=perf.data \ | |
14507 | --gcov=profile.afdo | |
14508 | @end smallexample | |
14509 | @end table | |
14510 | ||
14511 | The following options control compiler behavior regarding floating-point | |
14512 | arithmetic. These options trade off between speed and | |
14513 | correctness. All must be specifically enabled. | |
14514 | ||
14515 | @table @gcctabopt | |
d77de738 | 14516 | @opindex ffloat-store |
ddf6fe37 | 14517 | @item -ffloat-store |
d77de738 ML |
14518 | Do not store floating-point variables in registers, and inhibit other |
14519 | options that might change whether a floating-point value is taken from a | |
14520 | register or memory. | |
14521 | ||
14522 | @cindex floating-point precision | |
14523 | This option prevents undesirable excess precision on machines such as | |
14524 | the 68000 where the floating registers (of the 68881) keep more | |
14525 | precision than a @code{double} is supposed to have. Similarly for the | |
14526 | x86 architecture. For most programs, the excess precision does only | |
14527 | good, but a few programs rely on the precise definition of IEEE floating | |
14528 | point. Use @option{-ffloat-store} for such programs, after modifying | |
14529 | them to store all pertinent intermediate computations into variables. | |
14530 | ||
d77de738 | 14531 | @opindex fexcess-precision |
ddf6fe37 | 14532 | @item -fexcess-precision=@var{style} |
d77de738 ML |
14533 | This option allows further control over excess precision on machines |
14534 | where floating-point operations occur in a format with more precision or | |
14535 | range than the IEEE standard and interchange floating-point types. By | |
14536 | default, @option{-fexcess-precision=fast} is in effect; this means that | |
14537 | operations may be carried out in a wider precision than the types specified | |
14538 | in the source if that would result in faster code, and it is unpredictable | |
14539 | when rounding to the types specified in the source code takes place. | |
14540 | When compiling C or C++, if @option{-fexcess-precision=standard} is specified | |
14541 | then excess precision follows the rules specified in ISO C99 or C++; in particular, | |
14542 | both casts and assignments cause values to be rounded to their | |
14543 | semantic types (whereas @option{-ffloat-store} only affects | |
14544 | assignments). This option is enabled by default for C or C++ if a strict | |
14545 | conformance option such as @option{-std=c99} or @option{-std=c++17} is used. | |
14546 | @option{-ffast-math} enables @option{-fexcess-precision=fast} by default | |
14547 | regardless of whether a strict conformance option is used. | |
14548 | ||
14549 | @opindex mfpmath | |
14550 | @option{-fexcess-precision=standard} is not implemented for languages | |
14551 | other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse} | |
14552 | or @option{-mfpmath=sse+387} is specified; in the former case, IEEE | |
14553 | semantics apply without excess precision, and in the latter, rounding | |
14554 | is unpredictable. | |
14555 | ||
d77de738 | 14556 | @opindex ffast-math |
ddf6fe37 | 14557 | @item -ffast-math |
d77de738 ML |
14558 | Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations}, |
14559 | @option{-ffinite-math-only}, @option{-fno-rounding-math}, | |
14560 | @option{-fno-signaling-nans}, @option{-fcx-limited-range} and | |
14561 | @option{-fexcess-precision=fast}. | |
14562 | ||
14563 | This option causes the preprocessor macro @code{__FAST_MATH__} to be defined. | |
14564 | ||
14565 | This option is not turned on by any @option{-O} option besides | |
14566 | @option{-Ofast} since it can result in incorrect output for programs | |
14567 | that depend on an exact implementation of IEEE or ISO rules/specifications | |
14568 | for math functions. It may, however, yield faster code for programs | |
14569 | that do not require the guarantees of these specifications. | |
14570 | ||
d77de738 ML |
14571 | @opindex fno-math-errno |
14572 | @opindex fmath-errno | |
ddf6fe37 | 14573 | @item -fno-math-errno |
d77de738 ML |
14574 | Do not set @code{errno} after calling math functions that are executed |
14575 | with a single instruction, e.g., @code{sqrt}. A program that relies on | |
14576 | IEEE exceptions for math error handling may want to use this flag | |
14577 | for speed while maintaining IEEE arithmetic compatibility. | |
14578 | ||
14579 | This option is not turned on by any @option{-O} option since | |
14580 | it can result in incorrect output for programs that depend on | |
14581 | an exact implementation of IEEE or ISO rules/specifications for | |
14582 | math functions. It may, however, yield faster code for programs | |
14583 | that do not require the guarantees of these specifications. | |
14584 | ||
14585 | The default is @option{-fmath-errno}. | |
14586 | ||
14587 | On Darwin systems, the math library never sets @code{errno}. There is | |
14588 | therefore no reason for the compiler to consider the possibility that | |
14589 | it might, and @option{-fno-math-errno} is the default. | |
14590 | ||
d77de738 | 14591 | @opindex funsafe-math-optimizations |
ddf6fe37 | 14592 | @item -funsafe-math-optimizations |
d77de738 ML |
14593 | |
14594 | Allow optimizations for floating-point arithmetic that (a) assume | |
14595 | that arguments and results are valid and (b) may violate IEEE or | |
14596 | ANSI standards. When used at link time, it may include libraries | |
14597 | or startup files that change the default FPU control word or other | |
14598 | similar optimizations. | |
14599 | ||
14600 | This option is not turned on by any @option{-O} option since | |
14601 | it can result in incorrect output for programs that depend on | |
14602 | an exact implementation of IEEE or ISO rules/specifications for | |
14603 | math functions. It may, however, yield faster code for programs | |
14604 | that do not require the guarantees of these specifications. | |
14605 | Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math}, | |
14606 | @option{-fassociative-math} and @option{-freciprocal-math}. | |
14607 | ||
14608 | The default is @option{-fno-unsafe-math-optimizations}. | |
14609 | ||
d77de738 | 14610 | @opindex fassociative-math |
ddf6fe37 | 14611 | @item -fassociative-math |
d77de738 ML |
14612 | |
14613 | Allow re-association of operands in series of floating-point operations. | |
14614 | This violates the ISO C and C++ language standard by possibly changing | |
14615 | computation result. NOTE: re-ordering may change the sign of zero as | |
14616 | well as ignore NaNs and inhibit or create underflow or overflow (and | |
14617 | thus cannot be used on code that relies on rounding behavior like | |
14618 | @code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons | |
14619 | and thus may not be used when ordered comparisons are required. | |
14620 | This option requires that both @option{-fno-signed-zeros} and | |
14621 | @option{-fno-trapping-math} be in effect. Moreover, it doesn't make | |
14622 | much sense with @option{-frounding-math}. For Fortran the option | |
14623 | is automatically enabled when both @option{-fno-signed-zeros} and | |
14624 | @option{-fno-trapping-math} are in effect. | |
14625 | ||
14626 | The default is @option{-fno-associative-math}. | |
14627 | ||
d77de738 | 14628 | @opindex freciprocal-math |
ddf6fe37 | 14629 | @item -freciprocal-math |
d77de738 ML |
14630 | |
14631 | Allow the reciprocal of a value to be used instead of dividing by | |
14632 | the value if this enables optimizations. For example @code{x / y} | |
14633 | can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)} | |
14634 | is subject to common subexpression elimination. Note that this loses | |
14635 | precision and increases the number of flops operating on the value. | |
14636 | ||
14637 | The default is @option{-fno-reciprocal-math}. | |
14638 | ||
d77de738 | 14639 | @opindex ffinite-math-only |
ddf6fe37 | 14640 | @item -ffinite-math-only |
d77de738 ML |
14641 | Allow optimizations for floating-point arithmetic that assume |
14642 | that arguments and results are not NaNs or +-Infs. | |
14643 | ||
14644 | This option is not turned on by any @option{-O} option since | |
14645 | it can result in incorrect output for programs that depend on | |
14646 | an exact implementation of IEEE or ISO rules/specifications for | |
14647 | math functions. It may, however, yield faster code for programs | |
14648 | that do not require the guarantees of these specifications. | |
14649 | ||
14650 | The default is @option{-fno-finite-math-only}. | |
14651 | ||
d77de738 ML |
14652 | @opindex fno-signed-zeros |
14653 | @opindex fsigned-zeros | |
ddf6fe37 | 14654 | @item -fno-signed-zeros |
d77de738 ML |
14655 | Allow optimizations for floating-point arithmetic that ignore the |
14656 | signedness of zero. IEEE arithmetic specifies the behavior of | |
14657 | distinct +0.0 and @minus{}0.0 values, which then prohibits simplification | |
14658 | of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}). | |
14659 | This option implies that the sign of a zero result isn't significant. | |
14660 | ||
14661 | The default is @option{-fsigned-zeros}. | |
14662 | ||
d77de738 ML |
14663 | @opindex fno-trapping-math |
14664 | @opindex ftrapping-math | |
ddf6fe37 | 14665 | @item -fno-trapping-math |
d77de738 ML |
14666 | Compile code assuming that floating-point operations cannot generate |
14667 | user-visible traps. These traps include division by zero, overflow, | |
14668 | underflow, inexact result and invalid operation. This option requires | |
14669 | that @option{-fno-signaling-nans} be in effect. Setting this option may | |
14670 | allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example. | |
14671 | ||
14672 | This option should never be turned on by any @option{-O} option since | |
14673 | it can result in incorrect output for programs that depend on | |
14674 | an exact implementation of IEEE or ISO rules/specifications for | |
14675 | math functions. | |
14676 | ||
14677 | The default is @option{-ftrapping-math}. | |
14678 | ||
14679 | Future versions of GCC may provide finer control of this setting | |
14680 | using C99's @code{FENV_ACCESS} pragma. This command-line option | |
14681 | will be used along with @option{-frounding-math} to specify the | |
14682 | default state for @code{FENV_ACCESS}. | |
14683 | ||
d77de738 | 14684 | @opindex frounding-math |
ddf6fe37 | 14685 | @item -frounding-math |
d77de738 ML |
14686 | Disable transformations and optimizations that assume default floating-point |
14687 | rounding behavior. This is round-to-zero for all floating point | |
14688 | to integer conversions, and round-to-nearest for all other arithmetic | |
14689 | truncations. This option should be specified for programs that change | |
14690 | the FP rounding mode dynamically, or that may be executed with a | |
14691 | non-default rounding mode. This option disables constant folding of | |
14692 | floating-point expressions at compile time (which may be affected by | |
14693 | rounding mode) and arithmetic transformations that are unsafe in the | |
14694 | presence of sign-dependent rounding modes. | |
14695 | ||
14696 | The default is @option{-fno-rounding-math}. | |
14697 | ||
14698 | This option is experimental and does not currently guarantee to | |
14699 | disable all GCC optimizations that are affected by rounding mode. | |
14700 | Future versions of GCC may provide finer control of this setting | |
14701 | using C99's @code{FENV_ACCESS} pragma. This command-line option | |
14702 | will be used along with @option{-ftrapping-math} to specify the | |
14703 | default state for @code{FENV_ACCESS}. | |
14704 | ||
d77de738 | 14705 | @opindex fsignaling-nans |
ddf6fe37 | 14706 | @item -fsignaling-nans |
d77de738 ML |
14707 | Compile code assuming that IEEE signaling NaNs may generate user-visible |
14708 | traps during floating-point operations. Setting this option disables | |
14709 | optimizations that may change the number of exceptions visible with | |
14710 | signaling NaNs. This option implies @option{-ftrapping-math}. | |
14711 | ||
14712 | This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to | |
14713 | be defined. | |
14714 | ||
14715 | The default is @option{-fno-signaling-nans}. | |
14716 | ||
14717 | This option is experimental and does not currently guarantee to | |
14718 | disable all GCC optimizations that affect signaling NaN behavior. | |
14719 | ||
d77de738 ML |
14720 | @opindex fno-fp-int-builtin-inexact |
14721 | @opindex ffp-int-builtin-inexact | |
ddf6fe37 | 14722 | @item -fno-fp-int-builtin-inexact |
d77de738 ML |
14723 | Do not allow the built-in functions @code{ceil}, @code{floor}, |
14724 | @code{round} and @code{trunc}, and their @code{float} and @code{long | |
14725 | double} variants, to generate code that raises the ``inexact'' | |
14726 | floating-point exception for noninteger arguments. ISO C99 and C11 | |
14727 | allow these functions to raise the ``inexact'' exception, but ISO/IEC | |
14728 | TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into | |
14729 | ISO C2X, does not allow these functions to do so. | |
14730 | ||
14731 | The default is @option{-ffp-int-builtin-inexact}, allowing the | |
14732 | exception to be raised, unless C2X or a later C standard is selected. | |
14733 | This option does nothing unless @option{-ftrapping-math} is in effect. | |
14734 | ||
14735 | Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions | |
14736 | generate a call to a library function then the ``inexact'' exception | |
14737 | may be raised if the library implementation does not follow TS 18661. | |
14738 | ||
d77de738 | 14739 | @opindex fsingle-precision-constant |
ddf6fe37 | 14740 | @item -fsingle-precision-constant |
d77de738 ML |
14741 | Treat floating-point constants as single precision instead of |
14742 | implicitly converting them to double-precision constants. | |
14743 | ||
d77de738 | 14744 | @opindex fcx-limited-range |
ddf6fe37 | 14745 | @item -fcx-limited-range |
d77de738 ML |
14746 | When enabled, this option states that a range reduction step is not |
14747 | needed when performing complex division. Also, there is no checking | |
14748 | whether the result of a complex multiplication or division is @code{NaN | |
14749 | + I*NaN}, with an attempt to rescue the situation in that case. The | |
14750 | default is @option{-fno-cx-limited-range}, but is enabled by | |
14751 | @option{-ffast-math}. | |
14752 | ||
14753 | This option controls the default setting of the ISO C99 | |
14754 | @code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to | |
14755 | all languages. | |
14756 | ||
d77de738 | 14757 | @opindex fcx-fortran-rules |
ddf6fe37 | 14758 | @item -fcx-fortran-rules |
d77de738 ML |
14759 | Complex multiplication and division follow Fortran rules. Range |
14760 | reduction is done as part of complex division, but there is no checking | |
14761 | whether the result of a complex multiplication or division is @code{NaN | |
14762 | + I*NaN}, with an attempt to rescue the situation in that case. | |
14763 | ||
14764 | The default is @option{-fno-cx-fortran-rules}. | |
14765 | ||
14766 | @end table | |
14767 | ||
14768 | The following options control optimizations that may improve | |
14769 | performance, but are not enabled by any @option{-O} options. This | |
14770 | section includes experimental options that may produce broken code. | |
14771 | ||
14772 | @table @gcctabopt | |
d77de738 | 14773 | @opindex fbranch-probabilities |
ddf6fe37 | 14774 | @item -fbranch-probabilities |
d77de738 ML |
14775 | After running a program compiled with @option{-fprofile-arcs} |
14776 | (@pxref{Instrumentation Options}), | |
14777 | you can compile it a second time using | |
14778 | @option{-fbranch-probabilities}, to improve optimizations based on | |
14779 | the number of times each branch was taken. When a program | |
14780 | compiled with @option{-fprofile-arcs} exits, it saves arc execution | |
14781 | counts to a file called @file{@var{sourcename}.gcda} for each source | |
14782 | file. The information in this data file is very dependent on the | |
14783 | structure of the generated code, so you must use the same source code | |
14784 | and the same optimization options for both compilations. | |
14785 | See details about the file naming in @option{-fprofile-arcs}. | |
14786 | ||
14787 | With @option{-fbranch-probabilities}, GCC puts a | |
14788 | @samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}. | |
14789 | These can be used to improve optimization. Currently, they are only | |
14790 | used in one place: in @file{reorg.cc}, instead of guessing which path a | |
14791 | branch is most likely to take, the @samp{REG_BR_PROB} values are used to | |
14792 | exactly determine which path is taken more often. | |
14793 | ||
14794 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14795 | ||
d77de738 | 14796 | @opindex fprofile-values |
ddf6fe37 | 14797 | @item -fprofile-values |
d77de738 ML |
14798 | If combined with @option{-fprofile-arcs}, it adds code so that some |
14799 | data about values of expressions in the program is gathered. | |
14800 | ||
14801 | With @option{-fbranch-probabilities}, it reads back the data gathered | |
14802 | from profiling values of expressions for usage in optimizations. | |
14803 | ||
14804 | Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and | |
14805 | @option{-fauto-profile}. | |
14806 | ||
d77de738 | 14807 | @opindex fprofile-reorder-functions |
ddf6fe37 | 14808 | @item -fprofile-reorder-functions |
d77de738 ML |
14809 | Function reordering based on profile instrumentation collects |
14810 | first time of execution of a function and orders these functions | |
14811 | in ascending order. | |
14812 | ||
14813 | Enabled with @option{-fprofile-use}. | |
14814 | ||
d77de738 | 14815 | @opindex fvpt |
ddf6fe37 | 14816 | @item -fvpt |
d77de738 ML |
14817 | If combined with @option{-fprofile-arcs}, this option instructs the compiler |
14818 | to add code to gather information about values of expressions. | |
14819 | ||
14820 | With @option{-fbranch-probabilities}, it reads back the data gathered | |
14821 | and actually performs the optimizations based on them. | |
14822 | Currently the optimizations include specialization of division operations | |
14823 | using the knowledge about the value of the denominator. | |
14824 | ||
14825 | Enabled with @option{-fprofile-use} and @option{-fauto-profile}. | |
14826 | ||
d77de738 | 14827 | @opindex frename-registers |
ddf6fe37 | 14828 | @item -frename-registers |
d77de738 ML |
14829 | Attempt to avoid false dependencies in scheduled code by making use |
14830 | of registers left over after register allocation. This optimization | |
14831 | most benefits processors with lots of registers. Depending on the | |
14832 | debug information format adopted by the target, however, it can | |
14833 | make debugging impossible, since variables no longer stay in | |
14834 | a ``home register''. | |
14835 | ||
14836 | Enabled by default with @option{-funroll-loops}. | |
14837 | ||
d77de738 | 14838 | @opindex fschedule-fusion |
ddf6fe37 | 14839 | @item -fschedule-fusion |
d77de738 ML |
14840 | Performs a target dependent pass over the instruction stream to schedule |
14841 | instructions of same type together because target machine can execute them | |
14842 | more efficiently if they are adjacent to each other in the instruction flow. | |
14843 | ||
14844 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
14845 | ||
d77de738 | 14846 | @opindex ftracer |
ddf6fe37 | 14847 | @item -ftracer |
d77de738 ML |
14848 | Perform tail duplication to enlarge superblock size. This transformation |
14849 | simplifies the control flow of the function allowing other optimizations to do | |
14850 | a better job. | |
14851 | ||
14852 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14853 | ||
d77de738 | 14854 | @opindex funroll-loops |
ddf6fe37 | 14855 | @item -funroll-loops |
d77de738 ML |
14856 | Unroll loops whose number of iterations can be determined at compile time or |
14857 | upon entry to the loop. @option{-funroll-loops} implies | |
14858 | @option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}. | |
14859 | It also turns on complete loop peeling (i.e.@: complete removal of loops with | |
14860 | a small constant number of iterations). This option makes code larger, and may | |
14861 | or may not make it run faster. | |
14862 | ||
14863 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14864 | ||
d77de738 | 14865 | @opindex funroll-all-loops |
ddf6fe37 | 14866 | @item -funroll-all-loops |
d77de738 ML |
14867 | Unroll all loops, even if their number of iterations is uncertain when |
14868 | the loop is entered. This usually makes programs run more slowly. | |
14869 | @option{-funroll-all-loops} implies the same options as | |
14870 | @option{-funroll-loops}. | |
14871 | ||
d77de738 | 14872 | @opindex fpeel-loops |
ddf6fe37 | 14873 | @item -fpeel-loops |
d77de738 ML |
14874 | Peels loops for which there is enough information that they do not |
14875 | roll much (from profile feedback or static analysis). It also turns on | |
14876 | complete loop peeling (i.e.@: complete removal of loops with small constant | |
14877 | number of iterations). | |
14878 | ||
14879 | Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}. | |
14880 | ||
d77de738 | 14881 | @opindex fmove-loop-invariants |
ddf6fe37 | 14882 | @item -fmove-loop-invariants |
d77de738 ML |
14883 | Enables the loop invariant motion pass in the RTL loop optimizer. Enabled |
14884 | at level @option{-O1} and higher, except for @option{-Og}. | |
14885 | ||
d77de738 | 14886 | @opindex fmove-loop-stores |
ddf6fe37 | 14887 | @item -fmove-loop-stores |
d77de738 ML |
14888 | Enables the loop store motion pass in the GIMPLE loop optimizer. This |
14889 | moves invariant stores to after the end of the loop in exchange for | |
14890 | carrying the stored value in a register across the iteration. | |
14891 | Note for this option to have an effect @option{-ftree-loop-im} has to | |
14892 | be enabled as well. Enabled at level @option{-O1} and higher, except | |
14893 | for @option{-Og}. | |
14894 | ||
d77de738 | 14895 | @opindex fsplit-loops |
ddf6fe37 | 14896 | @item -fsplit-loops |
d77de738 ML |
14897 | Split a loop into two if it contains a condition that's always true |
14898 | for one side of the iteration space and false for the other. | |
14899 | ||
14900 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14901 | ||
d77de738 | 14902 | @opindex funswitch-loops |
ddf6fe37 | 14903 | @item -funswitch-loops |
d77de738 ML |
14904 | Move branches with loop invariant conditions out of the loop, with duplicates |
14905 | of the loop on both branches (modified according to result of the condition). | |
14906 | ||
14907 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14908 | ||
d77de738 | 14909 | @opindex fversion-loops-for-strides |
ddf6fe37 | 14910 | @item -fversion-loops-for-strides |
d77de738 ML |
14911 | If a loop iterates over an array with a variable stride, create another |
14912 | version of the loop that assumes the stride is always one. For example: | |
14913 | ||
14914 | @smallexample | |
14915 | for (int i = 0; i < n; ++i) | |
14916 | x[i * stride] = @dots{}; | |
14917 | @end smallexample | |
14918 | ||
14919 | becomes: | |
14920 | ||
14921 | @smallexample | |
14922 | if (stride == 1) | |
14923 | for (int i = 0; i < n; ++i) | |
14924 | x[i] = @dots{}; | |
14925 | else | |
14926 | for (int i = 0; i < n; ++i) | |
14927 | x[i * stride] = @dots{}; | |
14928 | @end smallexample | |
14929 | ||
14930 | This is particularly useful for assumed-shape arrays in Fortran where | |
14931 | (for example) it allows better vectorization assuming contiguous accesses. | |
14932 | This flag is enabled by default at @option{-O3}. | |
14933 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14934 | ||
d77de738 ML |
14935 | @opindex ffunction-sections |
14936 | @opindex fdata-sections | |
ddf6fe37 AA |
14937 | @item -ffunction-sections |
14938 | @itemx -fdata-sections | |
d77de738 ML |
14939 | Place each function or data item into its own section in the output |
14940 | file if the target supports arbitrary sections. The name of the | |
14941 | function or the name of the data item determines the section's name | |
14942 | in the output file. | |
14943 | ||
14944 | Use these options on systems where the linker can perform optimizations to | |
14945 | improve locality of reference in the instruction space. Most systems using the | |
14946 | ELF object format have linkers with such optimizations. On AIX, the linker | |
14947 | rearranges sections (CSECTs) based on the call graph. The performance impact | |
14948 | varies. | |
14949 | ||
14950 | Together with a linker garbage collection (linker @option{--gc-sections} | |
14951 | option) these options may lead to smaller statically-linked executables (after | |
14952 | stripping). | |
14953 | ||
14954 | On ELF/DWARF systems these options do not degenerate the quality of the debug | |
14955 | information. There could be issues with other object files/debug info formats. | |
14956 | ||
14957 | Only use these options when there are significant benefits from doing so. When | |
14958 | you specify these options, the assembler and linker create larger object and | |
14959 | executable files and are also slower. These options affect code generation. | |
14960 | They prevent optimizations by the compiler and assembler using relative | |
14961 | locations inside a translation unit since the locations are unknown until | |
14962 | link time. An example of such an optimization is relaxing calls to short call | |
14963 | instructions. | |
14964 | ||
d77de738 | 14965 | @opindex fstdarg-opt |
ddf6fe37 | 14966 | @item -fstdarg-opt |
d77de738 ML |
14967 | Optimize the prologue of variadic argument functions with respect to usage of |
14968 | those arguments. | |
14969 | ||
d77de738 | 14970 | @opindex fsection-anchors |
ddf6fe37 | 14971 | @item -fsection-anchors |
d77de738 ML |
14972 | Try to reduce the number of symbolic address calculations by using |
14973 | shared ``anchor'' symbols to address nearby objects. This transformation | |
14974 | can help to reduce the number of GOT entries and GOT accesses on some | |
14975 | targets. | |
14976 | ||
14977 | For example, the implementation of the following function @code{foo}: | |
14978 | ||
14979 | @smallexample | |
14980 | static int a, b, c; | |
14981 | int foo (void) @{ return a + b + c; @} | |
14982 | @end smallexample | |
14983 | ||
14984 | @noindent | |
14985 | usually calculates the addresses of all three variables, but if you | |
14986 | compile it with @option{-fsection-anchors}, it accesses the variables | |
14987 | from a common anchor point instead. The effect is similar to the | |
14988 | following pseudocode (which isn't valid C): | |
14989 | ||
14990 | @smallexample | |
14991 | int foo (void) | |
14992 | @{ | |
14993 | register int *xr = &x; | |
14994 | return xr[&a - &x] + xr[&b - &x] + xr[&c - &x]; | |
14995 | @} | |
14996 | @end smallexample | |
14997 | ||
14998 | Not all targets support this option. | |
14999 | ||
d77de738 | 15000 | @opindex fzero-call-used-regs |
ddf6fe37 | 15001 | @item -fzero-call-used-regs=@var{choice} |
d77de738 ML |
15002 | Zero call-used registers at function return to increase program |
15003 | security by either mitigating Return-Oriented Programming (ROP) | |
15004 | attacks or preventing information leakage through registers. | |
15005 | ||
15006 | The possible values of @var{choice} are the same as for the | |
15007 | @code{zero_call_used_regs} attribute (@pxref{Function Attributes}). | |
15008 | The default is @samp{skip}. | |
15009 | ||
15010 | You can control this behavior for a specific function by using the function | |
15011 | attribute @code{zero_call_used_regs} (@pxref{Function Attributes}). | |
15012 | ||
d77de738 | 15013 | @opindex param |
ddf6fe37 | 15014 | @item --param @var{name}=@var{value} |
d77de738 ML |
15015 | In some places, GCC uses various constants to control the amount of |
15016 | optimization that is done. For example, GCC does not inline functions | |
15017 | that contain more than a certain number of instructions. You can | |
15018 | control some of these constants on the command line using the | |
15019 | @option{--param} option. | |
15020 | ||
15021 | The names of specific parameters, and the meaning of the values, are | |
15022 | tied to the internals of the compiler, and are subject to change | |
15023 | without notice in future releases. | |
15024 | ||
c381327d GP |
15025 | In order to get the minimal, maximal and default values of a parameter, |
15026 | use the @option{--help=param -Q} options. | |
d77de738 ML |
15027 | |
15028 | In each case, the @var{value} is an integer. The following choices | |
15029 | of @var{name} are recognized for all targets: | |
15030 | ||
15031 | @table @gcctabopt | |
15032 | @item predictable-branch-outcome | |
15033 | When branch is predicted to be taken with probability lower than this threshold | |
15034 | (in percent), then it is considered well predictable. | |
15035 | ||
15036 | @item max-rtl-if-conversion-insns | |
15037 | RTL if-conversion tries to remove conditional branches around a block and | |
15038 | replace them with conditionally executed instructions. This parameter | |
15039 | gives the maximum number of instructions in a block which should be | |
15040 | considered for if-conversion. The compiler will | |
15041 | also use other heuristics to decide whether if-conversion is likely to be | |
15042 | profitable. | |
15043 | ||
15044 | @item max-rtl-if-conversion-predictable-cost | |
15045 | RTL if-conversion will try to remove conditional branches around a block | |
15046 | and replace them with conditionally executed instructions. These parameters | |
15047 | give the maximum permissible cost for the sequence that would be generated | |
15048 | by if-conversion depending on whether the branch is statically determined | |
15049 | to be predictable or not. The units for this parameter are the same as | |
15050 | those for the GCC internal seq_cost metric. The compiler will try to | |
15051 | provide a reasonable default for this parameter using the BRANCH_COST | |
15052 | target macro. | |
15053 | ||
15054 | @item max-crossjump-edges | |
15055 | The maximum number of incoming edges to consider for cross-jumping. | |
15056 | The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in | |
15057 | the number of edges incoming to each block. Increasing values mean | |
15058 | more aggressive optimization, making the compilation time increase with | |
15059 | probably small improvement in executable size. | |
15060 | ||
15061 | @item min-crossjump-insns | |
15062 | The minimum number of instructions that must be matched at the end | |
15063 | of two blocks before cross-jumping is performed on them. This | |
15064 | value is ignored in the case where all instructions in the block being | |
15065 | cross-jumped from are matched. | |
15066 | ||
15067 | @item max-grow-copy-bb-insns | |
15068 | The maximum code size expansion factor when copying basic blocks | |
15069 | instead of jumping. The expansion is relative to a jump instruction. | |
15070 | ||
15071 | @item max-goto-duplication-insns | |
15072 | The maximum number of instructions to duplicate to a block that jumps | |
15073 | to a computed goto. To avoid @math{O(N^2)} behavior in a number of | |
15074 | passes, GCC factors computed gotos early in the compilation process, | |
15075 | and unfactors them as late as possible. Only computed jumps at the | |
15076 | end of a basic blocks with no more than max-goto-duplication-insns are | |
15077 | unfactored. | |
15078 | ||
15079 | @item max-delay-slot-insn-search | |
15080 | The maximum number of instructions to consider when looking for an | |
15081 | instruction to fill a delay slot. If more than this arbitrary number of | |
15082 | instructions are searched, the time savings from filling the delay slot | |
15083 | are minimal, so stop searching. Increasing values mean more | |
15084 | aggressive optimization, making the compilation time increase with probably | |
15085 | small improvement in execution time. | |
15086 | ||
15087 | @item max-delay-slot-live-search | |
15088 | When trying to fill delay slots, the maximum number of instructions to | |
15089 | consider when searching for a block with valid live register | |
15090 | information. Increasing this arbitrarily chosen value means more | |
15091 | aggressive optimization, increasing the compilation time. This parameter | |
15092 | should be removed when the delay slot code is rewritten to maintain the | |
15093 | control-flow graph. | |
15094 | ||
15095 | @item max-gcse-memory | |
15096 | The approximate maximum amount of memory in @code{kB} that can be allocated in | |
15097 | order to perform the global common subexpression elimination | |
15098 | optimization. If more memory than specified is required, the | |
15099 | optimization is not done. | |
15100 | ||
15101 | @item max-gcse-insertion-ratio | |
15102 | If the ratio of expression insertions to deletions is larger than this value | |
15103 | for any expression, then RTL PRE inserts or removes the expression and thus | |
15104 | leaves partially redundant computations in the instruction stream. | |
15105 | ||
15106 | @item max-pending-list-length | |
15107 | The maximum number of pending dependencies scheduling allows | |
15108 | before flushing the current state and starting over. Large functions | |
15109 | with few branches or calls can create excessively large lists which | |
15110 | needlessly consume memory and resources. | |
15111 | ||
15112 | @item max-modulo-backtrack-attempts | |
15113 | The maximum number of backtrack attempts the scheduler should make | |
15114 | when modulo scheduling a loop. Larger values can exponentially increase | |
15115 | compilation time. | |
15116 | ||
15117 | @item max-inline-functions-called-once-loop-depth | |
15118 | Maximal loop depth of a call considered by inline heuristics that tries to | |
15119 | inline all functions called once. | |
15120 | ||
15121 | @item max-inline-functions-called-once-insns | |
15122 | Maximal estimated size of functions produced while inlining functions called | |
15123 | once. | |
15124 | ||
15125 | @item max-inline-insns-single | |
15126 | Several parameters control the tree inliner used in GCC@. This number sets the | |
15127 | maximum number of instructions (counted in GCC's internal representation) in a | |
15128 | single function that the tree inliner considers for inlining. This only | |
15129 | affects functions declared inline and methods implemented in a class | |
15130 | declaration (C++). | |
15131 | ||
15132 | ||
15133 | @item max-inline-insns-auto | |
15134 | When you use @option{-finline-functions} (included in @option{-O3}), | |
15135 | a lot of functions that would otherwise not be considered for inlining | |
15136 | by the compiler are investigated. To those functions, a different | |
15137 | (more restrictive) limit compared to functions declared inline can | |
15138 | be applied (@option{--param max-inline-insns-auto}). | |
15139 | ||
15140 | @item max-inline-insns-small | |
15141 | This is bound applied to calls which are considered relevant with | |
15142 | @option{-finline-small-functions}. | |
15143 | ||
15144 | @item max-inline-insns-size | |
15145 | This is bound applied to calls which are optimized for size. Small growth | |
15146 | may be desirable to anticipate optimization oppurtunities exposed by inlining. | |
15147 | ||
15148 | @item uninlined-function-insns | |
15149 | Number of instructions accounted by inliner for function overhead such as | |
15150 | function prologue and epilogue. | |
15151 | ||
15152 | @item uninlined-function-time | |
15153 | Extra time accounted by inliner for function overhead such as time needed to | |
15154 | execute function prologue and epilogue. | |
15155 | ||
15156 | @item inline-heuristics-hint-percent | |
15157 | The scale (in percents) applied to @option{inline-insns-single}, | |
15158 | @option{inline-insns-single-O2}, @option{inline-insns-auto} | |
15159 | when inline heuristics hints that inlining is | |
15160 | very profitable (will enable later optimizations). | |
15161 | ||
15162 | @item uninlined-thunk-insns | |
15163 | @item uninlined-thunk-time | |
15164 | Same as @option{--param uninlined-function-insns} and | |
15165 | @option{--param uninlined-function-time} but applied to function thunks. | |
15166 | ||
15167 | @item inline-min-speedup | |
15168 | When estimated performance improvement of caller + callee runtime exceeds this | |
15169 | threshold (in percent), the function can be inlined regardless of the limit on | |
15170 | @option{--param max-inline-insns-single} and @option{--param | |
15171 | max-inline-insns-auto}. | |
15172 | ||
15173 | @item large-function-insns | |
15174 | The limit specifying really large functions. For functions larger than this | |
15175 | limit after inlining, inlining is constrained by | |
15176 | @option{--param large-function-growth}. This parameter is useful primarily | |
15177 | to avoid extreme compilation time caused by non-linear algorithms used by the | |
15178 | back end. | |
15179 | ||
15180 | @item large-function-growth | |
15181 | Specifies maximal growth of large function caused by inlining in percents. | |
15182 | For example, parameter value 100 limits large function growth to 2.0 times | |
15183 | the original size. | |
15184 | ||
15185 | @item large-unit-insns | |
15186 | The limit specifying large translation unit. Growth caused by inlining of | |
15187 | units larger than this limit is limited by @option{--param inline-unit-growth}. | |
15188 | For small units this might be too tight. | |
15189 | For example, consider a unit consisting of function A | |
15190 | that is inline and B that just calls A three times. If B is small relative to | |
15191 | A, the growth of unit is 300\% and yet such inlining is very sane. For very | |
15192 | large units consisting of small inlineable functions, however, the overall unit | |
15193 | growth limit is needed to avoid exponential explosion of code size. Thus for | |
15194 | smaller units, the size is increased to @option{--param large-unit-insns} | |
15195 | before applying @option{--param inline-unit-growth}. | |
15196 | ||
15197 | @item lazy-modules | |
15198 | Maximum number of concurrently open C++ module files when lazy loading. | |
15199 | ||
15200 | @item inline-unit-growth | |
15201 | Specifies maximal overall growth of the compilation unit caused by inlining. | |
15202 | For example, parameter value 20 limits unit growth to 1.2 times the original | |
15203 | size. Cold functions (either marked cold via an attribute or by profile | |
15204 | feedback) are not accounted into the unit size. | |
15205 | ||
15206 | @item ipa-cp-unit-growth | |
15207 | Specifies maximal overall growth of the compilation unit caused by | |
15208 | interprocedural constant propagation. For example, parameter value 10 limits | |
15209 | unit growth to 1.1 times the original size. | |
15210 | ||
15211 | @item ipa-cp-large-unit-insns | |
15212 | The size of translation unit that IPA-CP pass considers large. | |
15213 | ||
15214 | @item large-stack-frame | |
15215 | The limit specifying large stack frames. While inlining the algorithm is trying | |
15216 | to not grow past this limit too much. | |
15217 | ||
15218 | @item large-stack-frame-growth | |
15219 | Specifies maximal growth of large stack frames caused by inlining in percents. | |
15220 | For example, parameter value 1000 limits large stack frame growth to 11 times | |
15221 | the original size. | |
15222 | ||
15223 | @item max-inline-insns-recursive | |
15224 | @itemx max-inline-insns-recursive-auto | |
15225 | Specifies the maximum number of instructions an out-of-line copy of a | |
15226 | self-recursive inline | |
15227 | function can grow into by performing recursive inlining. | |
15228 | ||
15229 | @option{--param max-inline-insns-recursive} applies to functions | |
15230 | declared inline. | |
15231 | For functions not declared inline, recursive inlining | |
15232 | happens only when @option{-finline-functions} (included in @option{-O3}) is | |
15233 | enabled; @option{--param max-inline-insns-recursive-auto} applies instead. | |
15234 | ||
15235 | @item max-inline-recursive-depth | |
15236 | @itemx max-inline-recursive-depth-auto | |
15237 | Specifies the maximum recursion depth used for recursive inlining. | |
15238 | ||
15239 | @option{--param max-inline-recursive-depth} applies to functions | |
15240 | declared inline. For functions not declared inline, recursive inlining | |
15241 | happens only when @option{-finline-functions} (included in @option{-O3}) is | |
15242 | enabled; @option{--param max-inline-recursive-depth-auto} applies instead. | |
15243 | ||
15244 | @item min-inline-recursive-probability | |
15245 | Recursive inlining is profitable only for function having deep recursion | |
15246 | in average and can hurt for function having little recursion depth by | |
15247 | increasing the prologue size or complexity of function body to other | |
15248 | optimizers. | |
15249 | ||
15250 | When profile feedback is available (see @option{-fprofile-generate}) the actual | |
15251 | recursion depth can be guessed from the probability that function recurses | |
15252 | via a given call expression. This parameter limits inlining only to call | |
15253 | expressions whose probability exceeds the given threshold (in percents). | |
15254 | ||
15255 | @item early-inlining-insns | |
15256 | Specify growth that the early inliner can make. In effect it increases | |
15257 | the amount of inlining for code having a large abstraction penalty. | |
15258 | ||
15259 | @item max-early-inliner-iterations | |
15260 | Limit of iterations of the early inliner. This basically bounds | |
15261 | the number of nested indirect calls the early inliner can resolve. | |
15262 | Deeper chains are still handled by late inlining. | |
15263 | ||
15264 | @item comdat-sharing-probability | |
15265 | Probability (in percent) that C++ inline function with comdat visibility | |
15266 | are shared across multiple compilation units. | |
15267 | ||
15268 | @item modref-max-bases | |
15269 | @item modref-max-refs | |
15270 | @item modref-max-accesses | |
15271 | Specifies the maximal number of base pointers, references and accesses stored | |
15272 | for a single function by mod/ref analysis. | |
15273 | ||
15274 | @item modref-max-tests | |
15275 | Specifies the maxmal number of tests alias oracle can perform to disambiguate | |
15276 | memory locations using the mod/ref information. This parameter ought to be | |
15277 | bigger than @option{--param modref-max-bases} and @option{--param | |
15278 | modref-max-refs}. | |
15279 | ||
15280 | @item modref-max-depth | |
15281 | Specifies the maximum depth of DFS walk used by modref escape analysis. | |
15282 | Setting to 0 disables the analysis completely. | |
15283 | ||
15284 | @item modref-max-escape-points | |
15285 | Specifies the maximum number of escape points tracked by modref per SSA-name. | |
15286 | ||
15287 | @item modref-max-adjustments | |
15288 | Specifies the maximum number the access range is enlarged during modref dataflow | |
15289 | analysis. | |
15290 | ||
15291 | @item profile-func-internal-id | |
15292 | A parameter to control whether to use function internal id in profile | |
15293 | database lookup. If the value is 0, the compiler uses an id that | |
15294 | is based on function assembler name and filename, which makes old profile | |
15295 | data more tolerant to source changes such as function reordering etc. | |
15296 | ||
15297 | @item min-vect-loop-bound | |
15298 | The minimum number of iterations under which loops are not vectorized | |
15299 | when @option{-ftree-vectorize} is used. The number of iterations after | |
15300 | vectorization needs to be greater than the value specified by this option | |
15301 | to allow vectorization. | |
15302 | ||
15303 | @item gcse-cost-distance-ratio | |
15304 | Scaling factor in calculation of maximum distance an expression | |
15305 | can be moved by GCSE optimizations. This is currently supported only in the | |
15306 | code hoisting pass. The bigger the ratio, the more aggressive code hoisting | |
15307 | is with simple expressions, i.e., the expressions that have cost | |
15308 | less than @option{gcse-unrestricted-cost}. Specifying 0 disables | |
15309 | hoisting of simple expressions. | |
15310 | ||
15311 | @item gcse-unrestricted-cost | |
15312 | Cost, roughly measured as the cost of a single typical machine | |
15313 | instruction, at which GCSE optimizations do not constrain | |
15314 | the distance an expression can travel. This is currently | |
15315 | supported only in the code hoisting pass. The lesser the cost, | |
15316 | the more aggressive code hoisting is. Specifying 0 | |
15317 | allows all expressions to travel unrestricted distances. | |
15318 | ||
15319 | @item max-hoist-depth | |
15320 | The depth of search in the dominator tree for expressions to hoist. | |
15321 | This is used to avoid quadratic behavior in hoisting algorithm. | |
15322 | The value of 0 does not limit on the search, but may slow down compilation | |
15323 | of huge functions. | |
15324 | ||
15325 | @item max-tail-merge-comparisons | |
15326 | The maximum amount of similar bbs to compare a bb with. This is used to | |
15327 | avoid quadratic behavior in tree tail merging. | |
15328 | ||
15329 | @item max-tail-merge-iterations | |
15330 | The maximum amount of iterations of the pass over the function. This is used to | |
15331 | limit compilation time in tree tail merging. | |
15332 | ||
15333 | @item store-merging-allow-unaligned | |
15334 | Allow the store merging pass to introduce unaligned stores if it is legal to | |
15335 | do so. | |
15336 | ||
15337 | @item max-stores-to-merge | |
15338 | The maximum number of stores to attempt to merge into wider stores in the store | |
15339 | merging pass. | |
15340 | ||
15341 | @item max-store-chains-to-track | |
15342 | The maximum number of store chains to track at the same time in the attempt | |
15343 | to merge them into wider stores in the store merging pass. | |
15344 | ||
15345 | @item max-stores-to-track | |
15346 | The maximum number of stores to track at the same time in the attemt to | |
15347 | to merge them into wider stores in the store merging pass. | |
15348 | ||
15349 | @item max-unrolled-insns | |
15350 | The maximum number of instructions that a loop may have to be unrolled. | |
15351 | If a loop is unrolled, this parameter also determines how many times | |
15352 | the loop code is unrolled. | |
15353 | ||
15354 | @item max-average-unrolled-insns | |
15355 | The maximum number of instructions biased by probabilities of their execution | |
15356 | that a loop may have to be unrolled. If a loop is unrolled, | |
15357 | this parameter also determines how many times the loop code is unrolled. | |
15358 | ||
15359 | @item max-unroll-times | |
15360 | The maximum number of unrollings of a single loop. | |
15361 | ||
15362 | @item max-peeled-insns | |
15363 | The maximum number of instructions that a loop may have to be peeled. | |
15364 | If a loop is peeled, this parameter also determines how many times | |
15365 | the loop code is peeled. | |
15366 | ||
15367 | @item max-peel-times | |
15368 | The maximum number of peelings of a single loop. | |
15369 | ||
15370 | @item max-peel-branches | |
15371 | The maximum number of branches on the hot path through the peeled sequence. | |
15372 | ||
15373 | @item max-completely-peeled-insns | |
15374 | The maximum number of insns of a completely peeled loop. | |
15375 | ||
15376 | @item max-completely-peel-times | |
15377 | The maximum number of iterations of a loop to be suitable for complete peeling. | |
15378 | ||
15379 | @item max-completely-peel-loop-nest-depth | |
15380 | The maximum depth of a loop nest suitable for complete peeling. | |
15381 | ||
15382 | @item max-unswitch-insns | |
15383 | The maximum number of insns of an unswitched loop. | |
15384 | ||
5b50850c RB |
15385 | @item max-unswitch-depth |
15386 | The maximum depth of a loop nest to be unswitched. | |
15387 | ||
d77de738 ML |
15388 | @item lim-expensive |
15389 | The minimum cost of an expensive expression in the loop invariant motion. | |
15390 | ||
15391 | @item min-loop-cond-split-prob | |
15392 | When FDO profile information is available, @option{min-loop-cond-split-prob} | |
15393 | specifies minimum threshold for probability of semi-invariant condition | |
15394 | statement to trigger loop split. | |
15395 | ||
15396 | @item iv-consider-all-candidates-bound | |
15397 | Bound on number of candidates for induction variables, below which | |
15398 | all candidates are considered for each use in induction variable | |
15399 | optimizations. If there are more candidates than this, | |
15400 | only the most relevant ones are considered to avoid quadratic time complexity. | |
15401 | ||
15402 | @item iv-max-considered-uses | |
15403 | The induction variable optimizations give up on loops that contain more | |
15404 | induction variable uses. | |
15405 | ||
15406 | @item iv-always-prune-cand-set-bound | |
15407 | If the number of candidates in the set is smaller than this value, | |
15408 | always try to remove unnecessary ivs from the set | |
15409 | when adding a new one. | |
15410 | ||
15411 | @item avg-loop-niter | |
15412 | Average number of iterations of a loop. | |
15413 | ||
15414 | @item dse-max-object-size | |
15415 | Maximum size (in bytes) of objects tracked bytewise by dead store elimination. | |
15416 | Larger values may result in larger compilation times. | |
15417 | ||
15418 | @item dse-max-alias-queries-per-store | |
15419 | Maximum number of queries into the alias oracle per store. | |
15420 | Larger values result in larger compilation times and may result in more | |
15421 | removed dead stores. | |
15422 | ||
15423 | @item scev-max-expr-size | |
15424 | Bound on size of expressions used in the scalar evolutions analyzer. | |
15425 | Large expressions slow the analyzer. | |
15426 | ||
15427 | @item scev-max-expr-complexity | |
15428 | Bound on the complexity of the expressions in the scalar evolutions analyzer. | |
15429 | Complex expressions slow the analyzer. | |
15430 | ||
15431 | @item max-tree-if-conversion-phi-args | |
15432 | Maximum number of arguments in a PHI supported by TREE if conversion | |
15433 | unless the loop is marked with simd pragma. | |
15434 | ||
15435 | @item vect-max-layout-candidates | |
15436 | The maximum number of possible vector layouts (such as permutations) | |
15437 | to consider when optimizing to-be-vectorized code. | |
15438 | ||
15439 | @item vect-max-version-for-alignment-checks | |
15440 | The maximum number of run-time checks that can be performed when | |
15441 | doing loop versioning for alignment in the vectorizer. | |
15442 | ||
15443 | @item vect-max-version-for-alias-checks | |
15444 | The maximum number of run-time checks that can be performed when | |
15445 | doing loop versioning for alias in the vectorizer. | |
15446 | ||
15447 | @item vect-max-peeling-for-alignment | |
15448 | The maximum number of loop peels to enhance access alignment | |
15449 | for vectorizer. Value -1 means no limit. | |
15450 | ||
15451 | @item max-iterations-to-track | |
15452 | The maximum number of iterations of a loop the brute-force algorithm | |
15453 | for analysis of the number of iterations of the loop tries to evaluate. | |
15454 | ||
15455 | @item hot-bb-count-fraction | |
15456 | The denominator n of fraction 1/n of the maximal execution count of a | |
15457 | basic block in the entire program that a basic block needs to at least | |
15458 | have in order to be considered hot. The default is 10000, which means | |
15459 | that a basic block is considered hot if its execution count is greater | |
15460 | than 1/10000 of the maximal execution count. 0 means that it is never | |
15461 | considered hot. Used in non-LTO mode. | |
15462 | ||
15463 | @item hot-bb-count-ws-permille | |
15464 | The number of most executed permilles, ranging from 0 to 1000, of the | |
15465 | profiled execution of the entire program to which the execution count | |
15466 | of a basic block must be part of in order to be considered hot. The | |
15467 | default is 990, which means that a basic block is considered hot if | |
15468 | its execution count contributes to the upper 990 permilles, or 99.0%, | |
15469 | of the profiled execution of the entire program. 0 means that it is | |
15470 | never considered hot. Used in LTO mode. | |
15471 | ||
15472 | @item hot-bb-frequency-fraction | |
15473 | The denominator n of fraction 1/n of the execution frequency of the | |
15474 | entry block of a function that a basic block of this function needs | |
15475 | to at least have in order to be considered hot. The default is 1000, | |
15476 | which means that a basic block is considered hot in a function if it | |
15477 | is executed more frequently than 1/1000 of the frequency of the entry | |
15478 | block of the function. 0 means that it is never considered hot. | |
15479 | ||
15480 | @item unlikely-bb-count-fraction | |
15481 | The denominator n of fraction 1/n of the number of profiled runs of | |
15482 | the entire program below which the execution count of a basic block | |
15483 | must be in order for the basic block to be considered unlikely executed. | |
15484 | The default is 20, which means that a basic block is considered unlikely | |
15485 | executed if it is executed in fewer than 1/20, or 5%, of the runs of | |
15486 | the program. 0 means that it is always considered unlikely executed. | |
15487 | ||
15488 | @item max-predicted-iterations | |
15489 | The maximum number of loop iterations we predict statically. This is useful | |
15490 | in cases where a function contains a single loop with known bound and | |
15491 | another loop with unknown bound. | |
15492 | The known number of iterations is predicted correctly, while | |
15493 | the unknown number of iterations average to roughly 10. This means that the | |
15494 | loop without bounds appears artificially cold relative to the other one. | |
15495 | ||
15496 | @item builtin-expect-probability | |
15497 | Control the probability of the expression having the specified value. This | |
15498 | parameter takes a percentage (i.e.@: 0 ... 100) as input. | |
15499 | ||
15500 | @item builtin-string-cmp-inline-length | |
15501 | The maximum length of a constant string for a builtin string cmp call | |
15502 | eligible for inlining. | |
15503 | ||
15504 | @item align-threshold | |
15505 | ||
15506 | Select fraction of the maximal frequency of executions of a basic block in | |
15507 | a function to align the basic block. | |
15508 | ||
15509 | @item align-loop-iterations | |
15510 | ||
15511 | A loop expected to iterate at least the selected number of iterations is | |
15512 | aligned. | |
15513 | ||
15514 | @item tracer-dynamic-coverage | |
15515 | @itemx tracer-dynamic-coverage-feedback | |
15516 | ||
15517 | This value is used to limit superblock formation once the given percentage of | |
15518 | executed instructions is covered. This limits unnecessary code size | |
15519 | expansion. | |
15520 | ||
15521 | The @option{tracer-dynamic-coverage-feedback} parameter | |
15522 | is used only when profile | |
15523 | feedback is available. The real profiles (as opposed to statically estimated | |
15524 | ones) are much less balanced allowing the threshold to be larger value. | |
15525 | ||
15526 | @item tracer-max-code-growth | |
15527 | Stop tail duplication once code growth has reached given percentage. This is | |
15528 | a rather artificial limit, as most of the duplicates are eliminated later in | |
15529 | cross jumping, so it may be set to much higher values than is the desired code | |
15530 | growth. | |
15531 | ||
15532 | @item tracer-min-branch-ratio | |
15533 | ||
15534 | Stop reverse growth when the reverse probability of best edge is less than this | |
15535 | threshold (in percent). | |
15536 | ||
15537 | @item tracer-min-branch-probability | |
15538 | @itemx tracer-min-branch-probability-feedback | |
15539 | ||
15540 | Stop forward growth if the best edge has probability lower than this | |
15541 | threshold. | |
15542 | ||
15543 | Similarly to @option{tracer-dynamic-coverage} two parameters are | |
15544 | provided. @option{tracer-min-branch-probability-feedback} is used for | |
15545 | compilation with profile feedback and @option{tracer-min-branch-probability} | |
15546 | compilation without. The value for compilation with profile feedback | |
15547 | needs to be more conservative (higher) in order to make tracer | |
15548 | effective. | |
15549 | ||
15550 | @item stack-clash-protection-guard-size | |
15551 | Specify the size of the operating system provided stack guard as | |
15552 | 2 raised to @var{num} bytes. Higher values may reduce the | |
15553 | number of explicit probes, but a value larger than the operating system | |
15554 | provided guard will leave code vulnerable to stack clash style attacks. | |
15555 | ||
15556 | @item stack-clash-protection-probe-interval | |
15557 | Stack clash protection involves probing stack space as it is allocated. This | |
15558 | param controls the maximum distance between probes into the stack as 2 raised | |
15559 | to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value | |
15560 | larger than the operating system provided guard will leave code vulnerable to | |
15561 | stack clash style attacks. | |
15562 | ||
15563 | @item max-cse-path-length | |
15564 | ||
15565 | The maximum number of basic blocks on path that CSE considers. | |
15566 | ||
15567 | @item max-cse-insns | |
15568 | The maximum number of instructions CSE processes before flushing. | |
15569 | ||
15570 | @item ggc-min-expand | |
15571 | ||
15572 | GCC uses a garbage collector to manage its own memory allocation. This | |
15573 | parameter specifies the minimum percentage by which the garbage | |
15574 | collector's heap should be allowed to expand between collections. | |
15575 | Tuning this may improve compilation speed; it has no effect on code | |
15576 | generation. | |
15577 | ||
15578 | The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when | |
15579 | RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is | |
15580 | the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If | |
15581 | GCC is not able to calculate RAM on a particular platform, the lower | |
15582 | bound of 30% is used. Setting this parameter and | |
15583 | @option{ggc-min-heapsize} to zero causes a full collection to occur at | |
15584 | every opportunity. This is extremely slow, but can be useful for | |
15585 | debugging. | |
15586 | ||
15587 | @item ggc-min-heapsize | |
15588 | ||
15589 | Minimum size of the garbage collector's heap before it begins bothering | |
15590 | to collect garbage. The first collection occurs after the heap expands | |
15591 | by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again, | |
15592 | tuning this may improve compilation speed, and has no effect on code | |
15593 | generation. | |
15594 | ||
15595 | The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that | |
15596 | tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but | |
15597 | with a lower bound of 4096 (four megabytes) and an upper bound of | |
15598 | 131072 (128 megabytes). If GCC is not able to calculate RAM on a | |
15599 | particular platform, the lower bound is used. Setting this parameter | |
15600 | very large effectively disables garbage collection. Setting this | |
15601 | parameter and @option{ggc-min-expand} to zero causes a full collection | |
15602 | to occur at every opportunity. | |
15603 | ||
15604 | @item max-reload-search-insns | |
15605 | The maximum number of instruction reload should look backward for equivalent | |
15606 | register. Increasing values mean more aggressive optimization, making the | |
15607 | compilation time increase with probably slightly better performance. | |
15608 | ||
15609 | @item max-cselib-memory-locations | |
15610 | The maximum number of memory locations cselib should take into account. | |
15611 | Increasing values mean more aggressive optimization, making the compilation time | |
15612 | increase with probably slightly better performance. | |
15613 | ||
15614 | @item max-sched-ready-insns | |
15615 | The maximum number of instructions ready to be issued the scheduler should | |
15616 | consider at any given time during the first scheduling pass. Increasing | |
15617 | values mean more thorough searches, making the compilation time increase | |
15618 | with probably little benefit. | |
15619 | ||
15620 | @item max-sched-region-blocks | |
15621 | The maximum number of blocks in a region to be considered for | |
15622 | interblock scheduling. | |
15623 | ||
15624 | @item max-pipeline-region-blocks | |
15625 | The maximum number of blocks in a region to be considered for | |
15626 | pipelining in the selective scheduler. | |
15627 | ||
15628 | @item max-sched-region-insns | |
15629 | The maximum number of insns in a region to be considered for | |
15630 | interblock scheduling. | |
15631 | ||
15632 | @item max-pipeline-region-insns | |
15633 | The maximum number of insns in a region to be considered for | |
15634 | pipelining in the selective scheduler. | |
15635 | ||
15636 | @item min-spec-prob | |
15637 | The minimum probability (in percents) of reaching a source block | |
15638 | for interblock speculative scheduling. | |
15639 | ||
15640 | @item max-sched-extend-regions-iters | |
15641 | The maximum number of iterations through CFG to extend regions. | |
15642 | A value of 0 disables region extensions. | |
15643 | ||
15644 | @item max-sched-insn-conflict-delay | |
15645 | The maximum conflict delay for an insn to be considered for speculative motion. | |
15646 | ||
15647 | @item sched-spec-prob-cutoff | |
15648 | The minimal probability of speculation success (in percents), so that | |
15649 | speculative insns are scheduled. | |
15650 | ||
15651 | @item sched-state-edge-prob-cutoff | |
15652 | The minimum probability an edge must have for the scheduler to save its | |
15653 | state across it. | |
15654 | ||
15655 | @item sched-mem-true-dep-cost | |
15656 | Minimal distance (in CPU cycles) between store and load targeting same | |
15657 | memory locations. | |
15658 | ||
15659 | @item selsched-max-lookahead | |
15660 | The maximum size of the lookahead window of selective scheduling. It is a | |
15661 | depth of search for available instructions. | |
15662 | ||
15663 | @item selsched-max-sched-times | |
15664 | The maximum number of times that an instruction is scheduled during | |
15665 | selective scheduling. This is the limit on the number of iterations | |
15666 | through which the instruction may be pipelined. | |
15667 | ||
15668 | @item selsched-insns-to-rename | |
15669 | The maximum number of best instructions in the ready list that are considered | |
15670 | for renaming in the selective scheduler. | |
15671 | ||
15672 | @item sms-min-sc | |
15673 | The minimum value of stage count that swing modulo scheduler | |
15674 | generates. | |
15675 | ||
15676 | @item max-last-value-rtl | |
15677 | The maximum size measured as number of RTLs that can be recorded in an expression | |
15678 | in combiner for a pseudo register as last known value of that register. | |
15679 | ||
15680 | @item max-combine-insns | |
15681 | The maximum number of instructions the RTL combiner tries to combine. | |
15682 | ||
15683 | @item integer-share-limit | |
15684 | Small integer constants can use a shared data structure, reducing the | |
15685 | compiler's memory usage and increasing its speed. This sets the maximum | |
15686 | value of a shared integer constant. | |
15687 | ||
15688 | @item ssp-buffer-size | |
15689 | The minimum size of buffers (i.e.@: arrays) that receive stack smashing | |
15690 | protection when @option{-fstack-protector} is used. | |
15691 | ||
15692 | @item min-size-for-stack-sharing | |
15693 | The minimum size of variables taking part in stack slot sharing when not | |
15694 | optimizing. | |
15695 | ||
15696 | @item max-jump-thread-duplication-stmts | |
15697 | Maximum number of statements allowed in a block that needs to be | |
15698 | duplicated when threading jumps. | |
15699 | ||
15700 | @item max-jump-thread-paths | |
15701 | The maximum number of paths to consider when searching for jump threading | |
15702 | opportunities. When arriving at a block, incoming edges are only considered | |
15703 | if the number of paths to be searched so far multiplied by the number of | |
15704 | incoming edges does not exhaust the specified maximum number of paths to | |
15705 | consider. | |
15706 | ||
15707 | @item max-fields-for-field-sensitive | |
15708 | Maximum number of fields in a structure treated in | |
15709 | a field sensitive manner during pointer analysis. | |
15710 | ||
15711 | @item prefetch-latency | |
15712 | Estimate on average number of instructions that are executed before | |
15713 | prefetch finishes. The distance prefetched ahead is proportional | |
15714 | to this constant. Increasing this number may also lead to less | |
15715 | streams being prefetched (see @option{simultaneous-prefetches}). | |
15716 | ||
15717 | @item simultaneous-prefetches | |
15718 | Maximum number of prefetches that can run at the same time. | |
15719 | ||
15720 | @item l1-cache-line-size | |
15721 | The size of cache line in L1 data cache, in bytes. | |
15722 | ||
15723 | @item l1-cache-size | |
15724 | The size of L1 data cache, in kilobytes. | |
15725 | ||
15726 | @item l2-cache-size | |
15727 | The size of L2 data cache, in kilobytes. | |
15728 | ||
15729 | @item prefetch-dynamic-strides | |
15730 | Whether the loop array prefetch pass should issue software prefetch hints | |
15731 | for strides that are non-constant. In some cases this may be | |
15732 | beneficial, though the fact the stride is non-constant may make it | |
15733 | hard to predict when there is clear benefit to issuing these hints. | |
15734 | ||
15735 | Set to 1 if the prefetch hints should be issued for non-constant | |
15736 | strides. Set to 0 if prefetch hints should be issued only for strides that | |
15737 | are known to be constant and below @option{prefetch-minimum-stride}. | |
15738 | ||
15739 | @item prefetch-minimum-stride | |
15740 | Minimum constant stride, in bytes, to start using prefetch hints for. If | |
15741 | the stride is less than this threshold, prefetch hints will not be issued. | |
15742 | ||
15743 | This setting is useful for processors that have hardware prefetchers, in | |
15744 | which case there may be conflicts between the hardware prefetchers and | |
15745 | the software prefetchers. If the hardware prefetchers have a maximum | |
15746 | stride they can handle, it should be used here to improve the use of | |
15747 | software prefetchers. | |
15748 | ||
15749 | A value of -1 means we don't have a threshold and therefore | |
15750 | prefetch hints can be issued for any constant stride. | |
15751 | ||
15752 | This setting is only useful for strides that are known and constant. | |
15753 | ||
15754 | @item destructive-interference-size | |
15755 | @item constructive-interference-size | |
15756 | The values for the C++17 variables | |
15757 | @code{std::hardware_destructive_interference_size} and | |
15758 | @code{std::hardware_constructive_interference_size}. The destructive | |
15759 | interference size is the minimum recommended offset between two | |
15760 | independent concurrently-accessed objects; the constructive | |
15761 | interference size is the maximum recommended size of contiguous memory | |
15762 | accessed together. Typically both will be the size of an L1 cache | |
15763 | line for the target, in bytes. For a generic target covering a range of L1 | |
15764 | cache line sizes, typically the constructive interference size will be | |
15765 | the small end of the range and the destructive size will be the large | |
15766 | end. | |
15767 | ||
15768 | The destructive interference size is intended to be used for layout, | |
15769 | and thus has ABI impact. The default value is not expected to be | |
15770 | stable, and on some targets varies with @option{-mtune}, so use of | |
15771 | this variable in a context where ABI stability is important, such as | |
15772 | the public interface of a library, is strongly discouraged; if it is | |
15773 | used in that context, users can stabilize the value using this | |
15774 | option. | |
15775 | ||
15776 | The constructive interference size is less sensitive, as it is | |
15777 | typically only used in a @samp{static_assert} to make sure that a type | |
15778 | fits within a cache line. | |
15779 | ||
15780 | See also @option{-Winterference-size}. | |
15781 | ||
15782 | @item loop-interchange-max-num-stmts | |
15783 | The maximum number of stmts in a loop to be interchanged. | |
15784 | ||
15785 | @item loop-interchange-stride-ratio | |
15786 | The minimum ratio between stride of two loops for interchange to be profitable. | |
15787 | ||
15788 | @item min-insn-to-prefetch-ratio | |
15789 | The minimum ratio between the number of instructions and the | |
15790 | number of prefetches to enable prefetching in a loop. | |
15791 | ||
15792 | @item prefetch-min-insn-to-mem-ratio | |
15793 | The minimum ratio between the number of instructions and the | |
15794 | number of memory references to enable prefetching in a loop. | |
15795 | ||
15796 | @item use-canonical-types | |
15797 | Whether the compiler should use the ``canonical'' type system. | |
15798 | Should always be 1, which uses a more efficient internal | |
15799 | mechanism for comparing types in C++ and Objective-C++. However, if | |
15800 | bugs in the canonical type system are causing compilation failures, | |
15801 | set this value to 0 to disable canonical types. | |
15802 | ||
15803 | @item switch-conversion-max-branch-ratio | |
15804 | Switch initialization conversion refuses to create arrays that are | |
15805 | bigger than @option{switch-conversion-max-branch-ratio} times the number of | |
15806 | branches in the switch. | |
15807 | ||
15808 | @item max-partial-antic-length | |
15809 | Maximum length of the partial antic set computed during the tree | |
15810 | partial redundancy elimination optimization (@option{-ftree-pre}) when | |
15811 | optimizing at @option{-O3} and above. For some sorts of source code | |
15812 | the enhanced partial redundancy elimination optimization can run away, | |
15813 | consuming all of the memory available on the host machine. This | |
15814 | parameter sets a limit on the length of the sets that are computed, | |
15815 | which prevents the runaway behavior. Setting a value of 0 for | |
15816 | this parameter allows an unlimited set length. | |
15817 | ||
15818 | @item rpo-vn-max-loop-depth | |
15819 | Maximum loop depth that is value-numbered optimistically. | |
15820 | When the limit hits the innermost | |
15821 | @var{rpo-vn-max-loop-depth} loops and the outermost loop in the | |
15822 | loop nest are value-numbered optimistically and the remaining ones not. | |
15823 | ||
15824 | @item sccvn-max-alias-queries-per-access | |
15825 | Maximum number of alias-oracle queries we perform when looking for | |
15826 | redundancies for loads and stores. If this limit is hit the search | |
15827 | is aborted and the load or store is not considered redundant. The | |
15828 | number of queries is algorithmically limited to the number of | |
15829 | stores on all paths from the load to the function entry. | |
15830 | ||
15831 | @item ira-max-loops-num | |
15832 | IRA uses regional register allocation by default. If a function | |
15833 | contains more loops than the number given by this parameter, only at most | |
15834 | the given number of the most frequently-executed loops form regions | |
15835 | for regional register allocation. | |
15836 | ||
15837 | @item ira-max-conflict-table-size | |
15838 | Although IRA uses a sophisticated algorithm to compress the conflict | |
15839 | table, the table can still require excessive amounts of memory for | |
15840 | huge functions. If the conflict table for a function could be more | |
15841 | than the size in MB given by this parameter, the register allocator | |
15842 | instead uses a faster, simpler, and lower-quality | |
15843 | algorithm that does not require building a pseudo-register conflict table. | |
15844 | ||
15845 | @item ira-loop-reserved-regs | |
15846 | IRA can be used to evaluate more accurate register pressure in loops | |
15847 | for decisions to move loop invariants (see @option{-O3}). The number | |
15848 | of available registers reserved for some other purposes is given | |
15849 | by this parameter. Default of the parameter | |
15850 | is the best found from numerous experiments. | |
15851 | ||
15852 | @item ira-consider-dup-in-all-alts | |
15853 | Make IRA to consider matching constraint (duplicated operand number) | |
15854 | heavily in all available alternatives for preferred register class. | |
15855 | If it is set as zero, it means IRA only respects the matching | |
15856 | constraint when it's in the only available alternative with an | |
15857 | appropriate register class. Otherwise, it means IRA will check all | |
15858 | available alternatives for preferred register class even if it has | |
15859 | found some choice with an appropriate register class and respect the | |
15860 | found qualified matching constraint. | |
15861 | ||
9847c753 ML |
15862 | @item ira-simple-lra-insn-threshold |
15863 | Approximate function insn number in 1K units triggering simple local RA. | |
15864 | ||
d77de738 ML |
15865 | @item lra-inheritance-ebb-probability-cutoff |
15866 | LRA tries to reuse values reloaded in registers in subsequent insns. | |
15867 | This optimization is called inheritance. EBB is used as a region to | |
15868 | do this optimization. The parameter defines a minimal fall-through | |
15869 | edge probability in percentage used to add BB to inheritance EBB in | |
15870 | LRA. The default value was chosen | |
15871 | from numerous runs of SPEC2000 on x86-64. | |
15872 | ||
15873 | @item loop-invariant-max-bbs-in-loop | |
15874 | Loop invariant motion can be very expensive, both in compilation time and | |
15875 | in amount of needed compile-time memory, with very large loops. Loops | |
15876 | with more basic blocks than this parameter won't have loop invariant | |
15877 | motion optimization performed on them. | |
15878 | ||
15879 | @item loop-max-datarefs-for-datadeps | |
15880 | Building data dependencies is expensive for very large loops. This | |
15881 | parameter limits the number of data references in loops that are | |
15882 | considered for data dependence analysis. These large loops are no | |
15883 | handled by the optimizations using loop data dependencies. | |
15884 | ||
15885 | @item max-vartrack-size | |
15886 | Sets a maximum number of hash table slots to use during variable | |
15887 | tracking dataflow analysis of any function. If this limit is exceeded | |
15888 | with variable tracking at assignments enabled, analysis for that | |
15889 | function is retried without it, after removing all debug insns from | |
15890 | the function. If the limit is exceeded even without debug insns, var | |
15891 | tracking analysis is completely disabled for the function. Setting | |
15892 | the parameter to zero makes it unlimited. | |
15893 | ||
15894 | @item max-vartrack-expr-depth | |
15895 | Sets a maximum number of recursion levels when attempting to map | |
15896 | variable names or debug temporaries to value expressions. This trades | |
15897 | compilation time for more complete debug information. If this is set too | |
15898 | low, value expressions that are available and could be represented in | |
15899 | debug information may end up not being used; setting this higher may | |
15900 | enable the compiler to find more complex debug expressions, but compile | |
15901 | time and memory use may grow. | |
15902 | ||
15903 | @item max-debug-marker-count | |
15904 | Sets a threshold on the number of debug markers (e.g.@: begin stmt | |
15905 | markers) to avoid complexity explosion at inlining or expanding to RTL. | |
15906 | If a function has more such gimple stmts than the set limit, such stmts | |
15907 | will be dropped from the inlined copy of a function, and from its RTL | |
15908 | expansion. | |
15909 | ||
15910 | @item min-nondebug-insn-uid | |
15911 | Use uids starting at this parameter for nondebug insns. The range below | |
15912 | the parameter is reserved exclusively for debug insns created by | |
15913 | @option{-fvar-tracking-assignments}, but debug insns may get | |
15914 | (non-overlapping) uids above it if the reserved range is exhausted. | |
15915 | ||
10478270 MJ |
15916 | @item ipa-sra-deref-prob-threshold |
15917 | IPA-SRA replaces a pointer which is known not be NULL with one or more | |
15918 | new parameters only when the probability (in percent, relative to | |
15919 | function entry) of it being dereferenced is higher than this parameter. | |
15920 | ||
d77de738 ML |
15921 | @item ipa-sra-ptr-growth-factor |
15922 | IPA-SRA replaces a pointer to an aggregate with one or more new | |
15923 | parameters only when their cumulative size is less or equal to | |
15924 | @option{ipa-sra-ptr-growth-factor} times the size of the original | |
15925 | pointer parameter. | |
15926 | ||
69363825 ML |
15927 | @item ipa-sra-ptrwrap-growth-factor |
15928 | Additional maximum allowed growth of total size of new parameters | |
15929 | that ipa-sra replaces a pointer to an aggregate with, | |
049dccd0 MJ |
15930 | if it points to a local variable that the caller only writes to and |
15931 | passes it as an argument to other functions. | |
69363825 | 15932 | |
d77de738 ML |
15933 | @item ipa-sra-max-replacements |
15934 | Maximum pieces of an aggregate that IPA-SRA tracks. As a | |
15935 | consequence, it is also the maximum number of replacements of a formal | |
15936 | parameter. | |
15937 | ||
15938 | @item sra-max-scalarization-size-Ospeed | |
15939 | @itemx sra-max-scalarization-size-Osize | |
15940 | The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to | |
15941 | replace scalar parts of aggregates with uses of independent scalar | |
15942 | variables. These parameters control the maximum size, in storage units, | |
15943 | of aggregate which is considered for replacement when compiling for | |
15944 | speed | |
15945 | (@option{sra-max-scalarization-size-Ospeed}) or size | |
15946 | (@option{sra-max-scalarization-size-Osize}) respectively. | |
15947 | ||
15948 | @item sra-max-propagations | |
15949 | The maximum number of artificial accesses that Scalar Replacement of | |
15950 | Aggregates (SRA) will track, per one local variable, in order to | |
15951 | facilitate copy propagation. | |
15952 | ||
15953 | @item tm-max-aggregate-size | |
15954 | When making copies of thread-local variables in a transaction, this | |
15955 | parameter specifies the size in bytes after which variables are | |
15956 | saved with the logging functions as opposed to save/restore code | |
15957 | sequence pairs. This option only applies when using | |
15958 | @option{-fgnu-tm}. | |
15959 | ||
15960 | @item graphite-max-nb-scop-params | |
15961 | To avoid exponential effects in the Graphite loop transforms, the | |
15962 | number of parameters in a Static Control Part (SCoP) is bounded. | |
15963 | A value of zero can be used to lift | |
15964 | the bound. A variable whose value is unknown at compilation time and | |
15965 | defined outside a SCoP is a parameter of the SCoP. | |
15966 | ||
15967 | @item loop-block-tile-size | |
15968 | Loop blocking or strip mining transforms, enabled with | |
15969 | @option{-floop-block} or @option{-floop-strip-mine}, strip mine each | |
15970 | loop in the loop nest by a given number of iterations. The strip | |
15971 | length can be changed using the @option{loop-block-tile-size} | |
15972 | parameter. | |
15973 | ||
15974 | @item ipa-jump-function-lookups | |
15975 | Specifies number of statements visited during jump function offset discovery. | |
15976 | ||
15977 | @item ipa-cp-value-list-size | |
15978 | IPA-CP attempts to track all possible values and types passed to a function's | |
15979 | parameter in order to propagate them and perform devirtualization. | |
15980 | @option{ipa-cp-value-list-size} is the maximum number of values and types it | |
15981 | stores per one formal parameter of a function. | |
15982 | ||
15983 | @item ipa-cp-eval-threshold | |
15984 | IPA-CP calculates its own score of cloning profitability heuristics | |
15985 | and performs those cloning opportunities with scores that exceed | |
15986 | @option{ipa-cp-eval-threshold}. | |
15987 | ||
15988 | @item ipa-cp-max-recursive-depth | |
15989 | Maximum depth of recursive cloning for self-recursive function. | |
15990 | ||
15991 | @item ipa-cp-min-recursive-probability | |
15992 | Recursive cloning only when the probability of call being executed exceeds | |
15993 | the parameter. | |
15994 | ||
15995 | @item ipa-cp-profile-count-base | |
15996 | When using @option{-fprofile-use} option, IPA-CP will consider the measured | |
15997 | execution count of a call graph edge at this percentage position in their | |
15998 | histogram as the basis for its heuristics calculation. | |
15999 | ||
16000 | @item ipa-cp-recursive-freq-factor | |
16001 | The number of times interprocedural copy propagation expects recursive | |
16002 | functions to call themselves. | |
16003 | ||
16004 | @item ipa-cp-recursion-penalty | |
16005 | Percentage penalty the recursive functions will receive when they | |
16006 | are evaluated for cloning. | |
16007 | ||
16008 | @item ipa-cp-single-call-penalty | |
16009 | Percentage penalty functions containing a single call to another | |
16010 | function will receive when they are evaluated for cloning. | |
16011 | ||
16012 | @item ipa-max-agg-items | |
16013 | IPA-CP is also capable to propagate a number of scalar values passed | |
16014 | in an aggregate. @option{ipa-max-agg-items} controls the maximum | |
16015 | number of such values per one parameter. | |
16016 | ||
16017 | @item ipa-cp-loop-hint-bonus | |
16018 | When IPA-CP determines that a cloning candidate would make the number | |
16019 | of iterations of a loop known, it adds a bonus of | |
16020 | @option{ipa-cp-loop-hint-bonus} to the profitability score of | |
16021 | the candidate. | |
16022 | ||
16023 | @item ipa-max-loop-predicates | |
16024 | The maximum number of different predicates IPA will use to describe when | |
16025 | loops in a function have known properties. | |
16026 | ||
16027 | @item ipa-max-aa-steps | |
16028 | During its analysis of function bodies, IPA-CP employs alias analysis | |
16029 | in order to track values pointed to by function parameters. In order | |
16030 | not spend too much time analyzing huge functions, it gives up and | |
16031 | consider all memory clobbered after examining | |
16032 | @option{ipa-max-aa-steps} statements modifying memory. | |
16033 | ||
16034 | @item ipa-max-switch-predicate-bounds | |
16035 | Maximal number of boundary endpoints of case ranges of switch statement. | |
16036 | For switch exceeding this limit, IPA-CP will not construct cloning cost | |
16037 | predicate, which is used to estimate cloning benefit, for default case | |
16038 | of the switch statement. | |
16039 | ||
16040 | @item ipa-max-param-expr-ops | |
16041 | IPA-CP will analyze conditional statement that references some function | |
16042 | parameter to estimate benefit for cloning upon certain constant value. | |
16043 | But if number of operations in a parameter expression exceeds | |
16044 | @option{ipa-max-param-expr-ops}, the expression is treated as complicated | |
16045 | one, and is not handled by IPA analysis. | |
16046 | ||
16047 | @item lto-partitions | |
16048 | Specify desired number of partitions produced during WHOPR compilation. | |
16049 | The number of partitions should exceed the number of CPUs used for compilation. | |
16050 | ||
16051 | @item lto-min-partition | |
16052 | Size of minimal partition for WHOPR (in estimated instructions). | |
16053 | This prevents expenses of splitting very small programs into too many | |
16054 | partitions. | |
16055 | ||
16056 | @item lto-max-partition | |
16057 | Size of max partition for WHOPR (in estimated instructions). | |
16058 | to provide an upper bound for individual size of partition. | |
16059 | Meant to be used only with balanced partitioning. | |
16060 | ||
16061 | @item lto-max-streaming-parallelism | |
16062 | Maximal number of parallel processes used for LTO streaming. | |
16063 | ||
16064 | @item cxx-max-namespaces-for-diagnostic-help | |
16065 | The maximum number of namespaces to consult for suggestions when C++ | |
16066 | name lookup fails for an identifier. | |
16067 | ||
16068 | @item sink-frequency-threshold | |
16069 | The maximum relative execution frequency (in percents) of the target block | |
16070 | relative to a statement's original block to allow statement sinking of a | |
16071 | statement. Larger numbers result in more aggressive statement sinking. | |
16072 | A small positive adjustment is applied for | |
16073 | statements with memory operands as those are even more profitable so sink. | |
16074 | ||
16075 | @item max-stores-to-sink | |
16076 | The maximum number of conditional store pairs that can be sunk. Set to 0 | |
16077 | if either vectorization (@option{-ftree-vectorize}) or if-conversion | |
16078 | (@option{-ftree-loop-if-convert}) is disabled. | |
16079 | ||
16080 | @item case-values-threshold | |
16081 | The smallest number of different values for which it is best to use a | |
16082 | jump-table instead of a tree of conditional branches. If the value is | |
16083 | 0, use the default for the machine. | |
16084 | ||
16085 | @item jump-table-max-growth-ratio-for-size | |
16086 | The maximum code size growth ratio when expanding | |
16087 | into a jump table (in percent). The parameter is used when | |
16088 | optimizing for size. | |
16089 | ||
16090 | @item jump-table-max-growth-ratio-for-speed | |
16091 | The maximum code size growth ratio when expanding | |
16092 | into a jump table (in percent). The parameter is used when | |
16093 | optimizing for speed. | |
16094 | ||
16095 | @item tree-reassoc-width | |
16096 | Set the maximum number of instructions executed in parallel in | |
16097 | reassociated tree. This parameter overrides target dependent | |
16098 | heuristics used by default if has non zero value. | |
16099 | ||
16100 | @item sched-pressure-algorithm | |
16101 | Choose between the two available implementations of | |
16102 | @option{-fsched-pressure}. Algorithm 1 is the original implementation | |
16103 | and is the more likely to prevent instructions from being reordered. | |
16104 | Algorithm 2 was designed to be a compromise between the relatively | |
16105 | conservative approach taken by algorithm 1 and the rather aggressive | |
16106 | approach taken by the default scheduler. It relies more heavily on | |
16107 | having a regular register file and accurate register pressure classes. | |
16108 | See @file{haifa-sched.cc} in the GCC sources for more details. | |
16109 | ||
16110 | The default choice depends on the target. | |
16111 | ||
16112 | @item max-slsr-cand-scan | |
16113 | Set the maximum number of existing candidates that are considered when | |
16114 | seeking a basis for a new straight-line strength reduction candidate. | |
16115 | ||
16116 | @item asan-globals | |
16117 | Enable buffer overflow detection for global objects. This kind | |
16118 | of protection is enabled by default if you are using | |
16119 | @option{-fsanitize=address} option. | |
16120 | To disable global objects protection use @option{--param asan-globals=0}. | |
16121 | ||
16122 | @item asan-stack | |
16123 | Enable buffer overflow detection for stack objects. This kind of | |
16124 | protection is enabled by default when using @option{-fsanitize=address}. | |
16125 | To disable stack protection use @option{--param asan-stack=0} option. | |
16126 | ||
16127 | @item asan-instrument-reads | |
16128 | Enable buffer overflow detection for memory reads. This kind of | |
16129 | protection is enabled by default when using @option{-fsanitize=address}. | |
16130 | To disable memory reads protection use | |
16131 | @option{--param asan-instrument-reads=0}. | |
16132 | ||
16133 | @item asan-instrument-writes | |
16134 | Enable buffer overflow detection for memory writes. This kind of | |
16135 | protection is enabled by default when using @option{-fsanitize=address}. | |
16136 | To disable memory writes protection use | |
16137 | @option{--param asan-instrument-writes=0} option. | |
16138 | ||
16139 | @item asan-memintrin | |
16140 | Enable detection for built-in functions. This kind of protection | |
16141 | is enabled by default when using @option{-fsanitize=address}. | |
16142 | To disable built-in functions protection use | |
16143 | @option{--param asan-memintrin=0}. | |
16144 | ||
16145 | @item asan-use-after-return | |
16146 | Enable detection of use-after-return. This kind of protection | |
16147 | is enabled by default when using the @option{-fsanitize=address} option. | |
16148 | To disable it use @option{--param asan-use-after-return=0}. | |
16149 | ||
16150 | Note: By default the check is disabled at run time. To enable it, | |
16151 | add @code{detect_stack_use_after_return=1} to the environment variable | |
16152 | @env{ASAN_OPTIONS}. | |
16153 | ||
16154 | @item asan-instrumentation-with-call-threshold | |
16155 | If number of memory accesses in function being instrumented | |
16156 | is greater or equal to this number, use callbacks instead of inline checks. | |
16157 | E.g. to disable inline code use | |
16158 | @option{--param asan-instrumentation-with-call-threshold=0}. | |
16159 | ||
545c9f8b | 16160 | @item asan-kernel-mem-intrinsic-prefix |
f56ed5b3 SL |
16161 | If nonzero, prefix calls to @code{memcpy}, @code{memset} and @code{memmove} |
16162 | with @samp{__asan_} or @samp{__hwasan_} | |
16163 | for @option{-fsanitize=kernel-address} or @samp{-fsanitize=kernel-hwaddress}, | |
16164 | respectively. | |
545c9f8b | 16165 | |
d77de738 ML |
16166 | @item hwasan-instrument-stack |
16167 | Enable hwasan instrumentation of statically sized stack-allocated variables. | |
16168 | This kind of instrumentation is enabled by default when using | |
16169 | @option{-fsanitize=hwaddress} and disabled by default when using | |
16170 | @option{-fsanitize=kernel-hwaddress}. | |
16171 | To disable stack instrumentation use | |
16172 | @option{--param hwasan-instrument-stack=0}, and to enable it use | |
16173 | @option{--param hwasan-instrument-stack=1}. | |
16174 | ||
16175 | @item hwasan-random-frame-tag | |
16176 | When using stack instrumentation, decide tags for stack variables using a | |
16177 | deterministic sequence beginning at a random tag for each frame. With this | |
16178 | parameter unset tags are chosen using the same sequence but beginning from 1. | |
16179 | This is enabled by default for @option{-fsanitize=hwaddress} and unavailable | |
16180 | for @option{-fsanitize=kernel-hwaddress}. | |
16181 | To disable it use @option{--param hwasan-random-frame-tag=0}. | |
16182 | ||
16183 | @item hwasan-instrument-allocas | |
16184 | Enable hwasan instrumentation of dynamically sized stack-allocated variables. | |
16185 | This kind of instrumentation is enabled by default when using | |
16186 | @option{-fsanitize=hwaddress} and disabled by default when using | |
16187 | @option{-fsanitize=kernel-hwaddress}. | |
16188 | To disable instrumentation of such variables use | |
16189 | @option{--param hwasan-instrument-allocas=0}, and to enable it use | |
16190 | @option{--param hwasan-instrument-allocas=1}. | |
16191 | ||
16192 | @item hwasan-instrument-reads | |
16193 | Enable hwasan checks on memory reads. Instrumentation of reads is enabled by | |
16194 | default for both @option{-fsanitize=hwaddress} and | |
16195 | @option{-fsanitize=kernel-hwaddress}. | |
16196 | To disable checking memory reads use | |
16197 | @option{--param hwasan-instrument-reads=0}. | |
16198 | ||
16199 | @item hwasan-instrument-writes | |
16200 | Enable hwasan checks on memory writes. Instrumentation of writes is enabled by | |
16201 | default for both @option{-fsanitize=hwaddress} and | |
16202 | @option{-fsanitize=kernel-hwaddress}. | |
16203 | To disable checking memory writes use | |
16204 | @option{--param hwasan-instrument-writes=0}. | |
16205 | ||
16206 | @item hwasan-instrument-mem-intrinsics | |
16207 | Enable hwasan instrumentation of builtin functions. Instrumentation of these | |
16208 | builtin functions is enabled by default for both @option{-fsanitize=hwaddress} | |
16209 | and @option{-fsanitize=kernel-hwaddress}. | |
16210 | To disable instrumentation of builtin functions use | |
16211 | @option{--param hwasan-instrument-mem-intrinsics=0}. | |
16212 | ||
16213 | @item use-after-scope-direct-emission-threshold | |
16214 | If the size of a local variable in bytes is smaller or equal to this | |
16215 | number, directly poison (or unpoison) shadow memory instead of using | |
16216 | run-time callbacks. | |
16217 | ||
16218 | @item tsan-distinguish-volatile | |
16219 | Emit special instrumentation for accesses to volatiles. | |
16220 | ||
16221 | @item tsan-instrument-func-entry-exit | |
16222 | Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit(). | |
16223 | ||
16224 | @item max-fsm-thread-path-insns | |
16225 | Maximum number of instructions to copy when duplicating blocks on a | |
16226 | finite state automaton jump thread path. | |
16227 | ||
16228 | @item threader-debug | |
16229 | threader-debug=[none|all] Enables verbose dumping of the threader solver. | |
16230 | ||
16231 | @item parloops-chunk-size | |
16232 | Chunk size of omp schedule for loops parallelized by parloops. | |
16233 | ||
16234 | @item parloops-schedule | |
16235 | Schedule type of omp schedule for loops parallelized by parloops (static, | |
16236 | dynamic, guided, auto, runtime). | |
16237 | ||
16238 | @item parloops-min-per-thread | |
16239 | The minimum number of iterations per thread of an innermost parallelized | |
16240 | loop for which the parallelized variant is preferred over the single threaded | |
16241 | one. Note that for a parallelized loop nest the | |
16242 | minimum number of iterations of the outermost loop per thread is two. | |
16243 | ||
16244 | @item max-ssa-name-query-depth | |
16245 | Maximum depth of recursion when querying properties of SSA names in things | |
16246 | like fold routines. One level of recursion corresponds to following a | |
16247 | use-def chain. | |
16248 | ||
16249 | @item max-speculative-devirt-maydefs | |
16250 | The maximum number of may-defs we analyze when looking for a must-def | |
16251 | specifying the dynamic type of an object that invokes a virtual call | |
16252 | we may be able to devirtualize speculatively. | |
16253 | ||
d77de738 ML |
16254 | @item ranger-debug |
16255 | Specifies the type of debug output to be issued for ranges. | |
16256 | ||
d77de738 ML |
16257 | @item unroll-jam-min-percent |
16258 | The minimum percentage of memory references that must be optimized | |
16259 | away for the unroll-and-jam transformation to be considered profitable. | |
16260 | ||
16261 | @item unroll-jam-max-unroll | |
16262 | The maximum number of times the outer loop should be unrolled by | |
16263 | the unroll-and-jam transformation. | |
16264 | ||
16265 | @item max-rtl-if-conversion-unpredictable-cost | |
16266 | Maximum permissible cost for the sequence that would be generated | |
16267 | by the RTL if-conversion pass for a branch that is considered unpredictable. | |
16268 | ||
16269 | @item max-variable-expansions-in-unroller | |
16270 | If @option{-fvariable-expansion-in-unroller} is used, the maximum number | |
16271 | of times that an individual variable will be expanded during loop unrolling. | |
16272 | ||
16273 | @item partial-inlining-entry-probability | |
16274 | Maximum probability of the entry BB of split region | |
16275 | (in percent relative to entry BB of the function) | |
16276 | to make partial inlining happen. | |
16277 | ||
16278 | @item max-tracked-strlens | |
16279 | Maximum number of strings for which strlen optimization pass will | |
16280 | track string lengths. | |
16281 | ||
16282 | @item gcse-after-reload-partial-fraction | |
16283 | The threshold ratio for performing partial redundancy | |
16284 | elimination after reload. | |
16285 | ||
16286 | @item gcse-after-reload-critical-fraction | |
16287 | The threshold ratio of critical edges execution count that | |
16288 | permit performing redundancy elimination after reload. | |
16289 | ||
16290 | @item max-loop-header-insns | |
16291 | The maximum number of insns in loop header duplicated | |
16292 | by the copy loop headers pass. | |
16293 | ||
16294 | @item vect-epilogues-nomask | |
16295 | Enable loop epilogue vectorization using smaller vector size. | |
16296 | ||
16297 | @item vect-partial-vector-usage | |
16298 | Controls when the loop vectorizer considers using partial vector loads | |
16299 | and stores as an alternative to falling back to scalar code. 0 stops | |
16300 | the vectorizer from ever using partial vector loads and stores. 1 allows | |
16301 | partial vector loads and stores if vectorization removes the need for the | |
16302 | code to iterate. 2 allows partial vector loads and stores in all loops. | |
16303 | The parameter only has an effect on targets that support partial | |
16304 | vector loads and stores. | |
16305 | ||
16306 | @item vect-inner-loop-cost-factor | |
16307 | The maximum factor which the loop vectorizer applies to the cost of statements | |
16308 | in an inner loop relative to the loop being vectorized. The factor applied | |
16309 | is the maximum of the estimated number of iterations of the inner loop and | |
16310 | this parameter. The default value of this parameter is 50. | |
16311 | ||
16312 | @item vect-induction-float | |
16313 | Enable loop vectorization of floating point inductions. | |
16314 | ||
cbe32d38 ML |
16315 | @item vrp-sparse-threshold |
16316 | Maximum number of basic blocks before VRP uses a sparse bitmap cache. | |
16317 | ||
16318 | @item vrp-switch-limit | |
16319 | Maximum number of outgoing edges in a switch before VRP will not process it. | |
16320 | ||
16321 | @item vrp-vector-threshold | |
16322 | Maximum number of basic blocks for VRP to use a basic cache vector. | |
16323 | ||
d77de738 ML |
16324 | @item avoid-fma-max-bits |
16325 | Maximum number of bits for which we avoid creating FMAs. | |
16326 | ||
16327 | @item sms-loop-average-count-threshold | |
16328 | A threshold on the average loop count considered by the swing modulo scheduler. | |
16329 | ||
16330 | @item sms-dfa-history | |
16331 | The number of cycles the swing modulo scheduler considers when checking | |
16332 | conflicts using DFA. | |
16333 | ||
16334 | @item graphite-allow-codegen-errors | |
16335 | Whether codegen errors should be ICEs when @option{-fchecking}. | |
16336 | ||
16337 | @item sms-max-ii-factor | |
16338 | A factor for tuning the upper bound that swing modulo scheduler | |
16339 | uses for scheduling a loop. | |
16340 | ||
16341 | @item lra-max-considered-reload-pseudos | |
16342 | The max number of reload pseudos which are considered during | |
16343 | spilling a non-reload pseudo. | |
16344 | ||
16345 | @item max-pow-sqrt-depth | |
16346 | Maximum depth of sqrt chains to use when synthesizing exponentiation | |
16347 | by a real constant. | |
16348 | ||
16349 | @item max-dse-active-local-stores | |
16350 | Maximum number of active local stores in RTL dead store elimination. | |
16351 | ||
16352 | @item asan-instrument-allocas | |
16353 | Enable asan allocas/VLAs protection. | |
16354 | ||
16355 | @item max-iterations-computation-cost | |
16356 | Bound on the cost of an expression to compute the number of iterations. | |
16357 | ||
16358 | @item max-isl-operations | |
16359 | Maximum number of isl operations, 0 means unlimited. | |
16360 | ||
16361 | @item graphite-max-arrays-per-scop | |
16362 | Maximum number of arrays per scop. | |
16363 | ||
16364 | @item max-vartrack-reverse-op-size | |
16365 | Max. size of loc list for which reverse ops should be added. | |
16366 | ||
16367 | @item fsm-scale-path-stmts | |
16368 | Scale factor to apply to the number of statements in a threading path | |
7c9f20fc RB |
16369 | crossing a loop backedge when comparing to |
16370 | @option{--param=max-jump-thread-duplication-stmts}. | |
d77de738 ML |
16371 | |
16372 | @item uninit-control-dep-attempts | |
16373 | Maximum number of nested calls to search for control dependencies | |
16374 | during uninitialized variable analysis. | |
16375 | ||
b8a2a124 RB |
16376 | @item uninit-max-chain-len |
16377 | Maximum number of predicates anded for each predicate ored in the normalized | |
16378 | predicate chain. | |
16379 | ||
16380 | @item uninit-max-num-chains | |
16381 | Maximum number of predicates ored in the normalized predicate chain. | |
16382 | ||
d77de738 ML |
16383 | @item sched-autopref-queue-depth |
16384 | Hardware autoprefetcher scheduler model control flag. | |
16385 | Number of lookahead cycles the model looks into; at ' | |
16386 | ' only enable instruction sorting heuristic. | |
16387 | ||
16388 | @item loop-versioning-max-inner-insns | |
16389 | The maximum number of instructions that an inner loop can have | |
16390 | before the loop versioning pass considers it too big to copy. | |
16391 | ||
16392 | @item loop-versioning-max-outer-insns | |
16393 | The maximum number of instructions that an outer loop can have | |
16394 | before the loop versioning pass considers it too big to copy, | |
16395 | discounting any instructions in inner loops that directly benefit | |
16396 | from versioning. | |
16397 | ||
16398 | @item ssa-name-def-chain-limit | |
16399 | The maximum number of SSA_NAME assignments to follow in determining | |
16400 | a property of a variable such as its value. This limits the number | |
16401 | of iterations or recursive calls GCC performs when optimizing certain | |
16402 | statements or when determining their validity prior to issuing | |
16403 | diagnostics. | |
16404 | ||
16405 | @item store-merging-max-size | |
16406 | Maximum size of a single store merging region in bytes. | |
16407 | ||
16408 | @item hash-table-verification-limit | |
16409 | The number of elements for which hash table verification is done | |
16410 | for each searched element. | |
16411 | ||
16412 | @item max-find-base-term-values | |
16413 | Maximum number of VALUEs handled during a single find_base_term call. | |
16414 | ||
16415 | @item analyzer-max-enodes-per-program-point | |
16416 | The maximum number of exploded nodes per program point within | |
16417 | the analyzer, before terminating analysis of that point. | |
16418 | ||
16419 | @item analyzer-max-constraints | |
16420 | The maximum number of constraints per state. | |
16421 | ||
16422 | @item analyzer-min-snodes-for-call-summary | |
16423 | The minimum number of supernodes within a function for the | |
16424 | analyzer to consider summarizing its effects at call sites. | |
16425 | ||
16426 | @item analyzer-max-enodes-for-full-dump | |
16427 | The maximum depth of exploded nodes that should appear in a dot dump | |
16428 | before switching to a less verbose format. | |
16429 | ||
16430 | @item analyzer-max-recursion-depth | |
16431 | The maximum number of times a callsite can appear in a call stack | |
16432 | within the analyzer, before terminating analysis of a call that would | |
16433 | recurse deeper. | |
16434 | ||
16435 | @item analyzer-max-svalue-depth | |
16436 | The maximum depth of a symbolic value, before approximating | |
16437 | the value as unknown. | |
16438 | ||
16439 | @item analyzer-max-infeasible-edges | |
16440 | The maximum number of infeasible edges to reject before declaring | |
16441 | a diagnostic as infeasible. | |
16442 | ||
16443 | @item gimple-fe-computed-hot-bb-threshold | |
16444 | The number of executions of a basic block which is considered hot. | |
16445 | The parameter is used only in GIMPLE FE. | |
16446 | ||
16447 | @item analyzer-bb-explosion-factor | |
16448 | The maximum number of 'after supernode' exploded nodes within the analyzer | |
16449 | per supernode, before terminating analysis. | |
16450 | ||
c0c5a57b MJ |
16451 | @item analyzer-text-art-string-ellipsis-threshold |
16452 | The number of bytes at which to ellipsize string literals in analyzer text art diagrams. | |
16453 | ||
16454 | @item analyzer-text-art-ideal-canvas-width | |
16455 | The ideal width in characters of text art diagrams generated by the analyzer. | |
16456 | ||
16457 | @item analyzer-text-art-string-ellipsis-head-len | |
16458 | The number of literal bytes to show at the head of a string literal in text art when ellipsizing it. | |
16459 | ||
16460 | @item analyzer-text-art-string-ellipsis-tail-len | |
16461 | The number of literal bytes to show at the tail of a string literal in text art when ellipsizing it. | |
16462 | ||
d77de738 ML |
16463 | @item ranger-logical-depth |
16464 | Maximum depth of logical expression evaluation ranger will look through | |
16465 | when evaluating outgoing edge ranges. | |
16466 | ||
9fd6d83a ML |
16467 | @item ranger-recompute-depth |
16468 | Maximum depth of instruction chains to consider for recomputation | |
16469 | in the outgoing range calculator. | |
16470 | ||
d77de738 ML |
16471 | @item relation-block-limit |
16472 | Maximum number of relations the oracle will register in a basic block. | |
16473 | ||
16474 | @item min-pagesize | |
16475 | Minimum page size for warning purposes. | |
16476 | ||
16477 | @item openacc-kernels | |
16478 | Specify mode of OpenACC `kernels' constructs handling. | |
16479 | With @option{--param=openacc-kernels=decompose}, OpenACC `kernels' | |
16480 | constructs are decomposed into parts, a sequence of compute | |
16481 | constructs, each then handled individually. | |
16482 | This is work in progress. | |
16483 | With @option{--param=openacc-kernels=parloops}, OpenACC `kernels' | |
16484 | constructs are handled by the @samp{parloops} pass, en bloc. | |
16485 | This is the current default. | |
16486 | ||
16487 | @item openacc-privatization | |
4ace81b6 SL |
16488 | Control whether the @option{-fopt-info-omp-note} and applicable |
16489 | @option{-fdump-tree-*-details} options emit OpenACC privatization diagnostics. | |
d77de738 ML |
16490 | With @option{--param=openacc-privatization=quiet}, don't diagnose. |
16491 | This is the current default. | |
16492 | With @option{--param=openacc-privatization=noisy}, do diagnose. | |
16493 | ||
16494 | @end table | |
16495 | ||
16496 | The following choices of @var{name} are available on AArch64 targets: | |
16497 | ||
16498 | @table @gcctabopt | |
16499 | @item aarch64-sve-compare-costs | |
16500 | When vectorizing for SVE, consider using ``unpacked'' vectors for | |
16501 | smaller elements and use the cost model to pick the cheapest approach. | |
16502 | Also use the cost model to choose between SVE and Advanced SIMD vectorization. | |
16503 | ||
16504 | Using unpacked vectors includes storing smaller elements in larger | |
16505 | containers and accessing elements with extending loads and truncating | |
16506 | stores. | |
16507 | ||
16508 | @item aarch64-float-recp-precision | |
16509 | The number of Newton iterations for calculating the reciprocal for float type. | |
16510 | The precision of division is proportional to this param when division | |
16511 | approximation is enabled. The default value is 1. | |
16512 | ||
16513 | @item aarch64-double-recp-precision | |
16514 | The number of Newton iterations for calculating the reciprocal for double type. | |
16515 | The precision of division is propotional to this param when division | |
16516 | approximation is enabled. The default value is 2. | |
16517 | ||
16518 | @item aarch64-autovec-preference | |
16519 | Force an ISA selection strategy for auto-vectorization. Accepts values from | |
16520 | 0 to 4, inclusive. | |
16521 | @table @samp | |
16522 | @item 0 | |
16523 | Use the default heuristics. | |
16524 | @item 1 | |
16525 | Use only Advanced SIMD for auto-vectorization. | |
16526 | @item 2 | |
16527 | Use only SVE for auto-vectorization. | |
16528 | @item 3 | |
16529 | Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are | |
16530 | deemed equal. | |
16531 | @item 4 | |
16532 | Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal. | |
16533 | @end table | |
16534 | The default value is 0. | |
16535 | ||
834fc2bf MA |
16536 | @item aarch64-ldp-policy |
16537 | Fine-grained policy for load pairs. | |
16538 | With @option{--param=aarch64-ldp-policy=default}, use the policy of the | |
16539 | tuning structure. This is the current default. | |
16540 | With @option{--param=aarch64-ldp-policy=always}, emit ldp regardless | |
16541 | of alignment. | |
16542 | With @option{--param=aarch64-ldp-policy=never}, do not emit ldp. | |
16543 | With @option{--param=aarch64-ldp-policy=aligned}, emit ldp only if the | |
16544 | source pointer is aligned to at least double the alignment of the type. | |
16545 | ||
16546 | @item aarch64-stp-policy | |
16547 | Fine-grained policy for store pairs. | |
16548 | With @option{--param=aarch64-stp-policy=default}, use the policy of the | |
16549 | tuning structure. This is the current default. | |
16550 | With @option{--param=aarch64-stp-policy=always}, emit stp regardless | |
16551 | of alignment. | |
16552 | With @option{--param=aarch64-stp-policy=never}, do not emit stp. | |
16553 | With @option{--param=aarch64-stp-policy=aligned}, emit stp only if the | |
16554 | source pointer is aligned to at least double the alignment of the type. | |
16555 | ||
d77de738 ML |
16556 | @item aarch64-loop-vect-issue-rate-niters |
16557 | The tuning for some AArch64 CPUs tries to take both latencies and issue | |
16558 | rates into account when deciding whether a loop should be vectorized | |
16559 | using SVE, vectorized using Advanced SIMD, or not vectorized at all. | |
16560 | If this parameter is set to @var{n}, GCC will not use this heuristic | |
16561 | for loops that are known to execute in fewer than @var{n} Advanced | |
16562 | SIMD iterations. | |
16563 | ||
16564 | @item aarch64-vect-unroll-limit | |
16565 | The vectorizer will use available tuning information to determine whether it | |
16566 | would be beneficial to unroll the main vectorized loop and by how much. This | |
16567 | parameter set's the upper bound of how much the vectorizer will unroll the main | |
16568 | loop. The default value is four. | |
16569 | ||
16570 | @end table | |
16571 | ||
16572 | The following choices of @var{name} are available on i386 and x86_64 targets: | |
16573 | ||
16574 | @table @gcctabopt | |
16575 | @item x86-stlf-window-ninsns | |
16576 | Instructions number above which STFL stall penalty can be compensated. | |
16577 | ||
60101899 RB |
16578 | @item x86-stv-max-visits |
16579 | The maximum number of use and def visits when discovering a STV chain before | |
16580 | the discovery is aborted. | |
16581 | ||
d77de738 ML |
16582 | @end table |
16583 | ||
16584 | @end table | |
16585 | ||
16586 | @node Instrumentation Options | |
16587 | @section Program Instrumentation Options | |
16588 | @cindex instrumentation options | |
16589 | @cindex program instrumentation options | |
16590 | @cindex run-time error checking options | |
16591 | @cindex profiling options | |
16592 | @cindex options, program instrumentation | |
16593 | @cindex options, run-time error checking | |
16594 | @cindex options, profiling | |
16595 | ||
16596 | GCC supports a number of command-line options that control adding | |
16597 | run-time instrumentation to the code it normally generates. | |
16598 | For example, one purpose of instrumentation is collect profiling | |
16599 | statistics for use in finding program hot spots, code coverage | |
16600 | analysis, or profile-guided optimizations. | |
16601 | Another class of program instrumentation is adding run-time checking | |
16602 | to detect programming errors like invalid pointer | |
16603 | dereferences or out-of-bounds array accesses, as well as deliberately | |
16604 | hostile attacks such as stack smashing or C++ vtable hijacking. | |
16605 | There is also a general hook which can be used to implement other | |
16606 | forms of tracing or function-level instrumentation for debug or | |
16607 | program analysis purposes. | |
16608 | ||
16609 | @table @gcctabopt | |
16610 | @cindex @command{prof} | |
16611 | @cindex @command{gprof} | |
d77de738 ML |
16612 | @opindex p |
16613 | @opindex pg | |
ddf6fe37 AA |
16614 | @item -p |
16615 | @itemx -pg | |
d77de738 ML |
16616 | Generate extra code to write profile information suitable for the |
16617 | analysis program @command{prof} (for @option{-p}) or @command{gprof} | |
16618 | (for @option{-pg}). You must use this option when compiling | |
16619 | the source files you want data about, and you must also use it when | |
16620 | linking. | |
16621 | ||
16622 | You can use the function attribute @code{no_instrument_function} to | |
16623 | suppress profiling of individual functions when compiling with these options. | |
16624 | @xref{Common Function Attributes}. | |
16625 | ||
d77de738 | 16626 | @opindex fprofile-arcs |
ddf6fe37 | 16627 | @item -fprofile-arcs |
d77de738 ML |
16628 | Add code so that program flow @dfn{arcs} are instrumented. During |
16629 | execution the program records how many times each branch and call is | |
16630 | executed and how many times it is taken or returns. On targets that support | |
16631 | constructors with priority support, profiling properly handles constructors, | |
16632 | destructors and C++ constructors (and destructors) of classes which are used | |
16633 | as a type of a global variable. | |
16634 | ||
16635 | When the compiled | |
16636 | program exits it saves this data to a file called | |
16637 | @file{@var{auxname}.gcda} for each source file. The data may be used for | |
16638 | profile-directed optimizations (@option{-fbranch-probabilities}), or for | |
16639 | test coverage analysis (@option{-ftest-coverage}). Each object file's | |
16640 | @var{auxname} is generated from the name of the output file, if | |
16641 | explicitly specified and it is not the final executable, otherwise it is | |
16642 | the basename of the source file. In both cases any suffix is removed | |
16643 | (e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or | |
16644 | @file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}). | |
16645 | ||
16646 | Note that if a command line directly links source files, the corresponding | |
16647 | @var{.gcda} files will be prefixed with the unsuffixed name of the output file. | |
16648 | E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and | |
16649 | @file{binary-b.gcda} files. | |
16650 | ||
16651 | @xref{Cross-profiling}. | |
16652 | ||
16653 | @cindex @command{gcov} | |
d77de738 | 16654 | @opindex coverage |
ddf6fe37 | 16655 | @item --coverage |
d77de738 ML |
16656 | |
16657 | This option is used to compile and link code instrumented for coverage | |
16658 | analysis. The option is a synonym for @option{-fprofile-arcs} | |
16659 | @option{-ftest-coverage} (when compiling) and @option{-lgcov} (when | |
16660 | linking). See the documentation for those options for more details. | |
16661 | ||
16662 | @itemize | |
16663 | ||
16664 | @item | |
16665 | Compile the source files with @option{-fprofile-arcs} plus optimization | |
16666 | and code generation options. For test coverage analysis, use the | |
16667 | additional @option{-ftest-coverage} option. You do not need to profile | |
16668 | every source file in a program. | |
16669 | ||
16670 | @item | |
16671 | Compile the source files additionally with @option{-fprofile-abs-path} | |
16672 | to create absolute path names in the @file{.gcno} files. This allows | |
16673 | @command{gcov} to find the correct sources in projects where compilations | |
16674 | occur with different working directories. | |
16675 | ||
16676 | @item | |
16677 | Link your object files with @option{-lgcov} or @option{-fprofile-arcs} | |
16678 | (the latter implies the former). | |
16679 | ||
16680 | @item | |
16681 | Run the program on a representative workload to generate the arc profile | |
16682 | information. This may be repeated any number of times. You can run | |
16683 | concurrent instances of your program, and provided that the file system | |
16684 | supports locking, the data files will be correctly updated. Unless | |
16685 | a strict ISO C dialect option is in effect, @code{fork} calls are | |
16686 | detected and correctly handled without double counting. | |
16687 | ||
16688 | Moreover, an object file can be recompiled multiple times | |
16689 | and the corresponding @file{.gcda} file merges as long as | |
16690 | the source file and the compiler options are unchanged. | |
16691 | ||
16692 | @item | |
16693 | For profile-directed optimizations, compile the source files again with | |
16694 | the same optimization and code generation options plus | |
16695 | @option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that | |
16696 | Control Optimization}). | |
16697 | ||
16698 | @item | |
16699 | For test coverage analysis, use @command{gcov} to produce human readable | |
16700 | information from the @file{.gcno} and @file{.gcda} files. Refer to the | |
16701 | @command{gcov} documentation for further information. | |
16702 | ||
16703 | @end itemize | |
16704 | ||
16705 | With @option{-fprofile-arcs}, for each function of your program GCC | |
16706 | creates a program flow graph, then finds a spanning tree for the graph. | |
16707 | Only arcs that are not on the spanning tree have to be instrumented: the | |
16708 | compiler adds code to count the number of times that these arcs are | |
16709 | executed. When an arc is the only exit or only entrance to a block, the | |
16710 | instrumentation code can be added to the block; otherwise, a new basic | |
16711 | block must be created to hold the instrumentation code. | |
16712 | ||
16713 | @need 2000 | |
d77de738 | 16714 | @opindex ftest-coverage |
ddf6fe37 | 16715 | @item -ftest-coverage |
d77de738 ML |
16716 | Produce a notes file that the @command{gcov} code-coverage utility |
16717 | (@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to | |
16718 | show program coverage. Each source file's note file is called | |
16719 | @file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option | |
16720 | above for a description of @var{auxname} and instructions on how to | |
16721 | generate test coverage data. Coverage data matches the source files | |
16722 | more closely if you do not optimize. | |
16723 | ||
d77de738 | 16724 | @opindex fprofile-abs-path |
ddf6fe37 | 16725 | @item -fprofile-abs-path |
d77de738 ML |
16726 | Automatically convert relative source file names to absolute path names |
16727 | in the @file{.gcno} files. This allows @command{gcov} to find the correct | |
16728 | sources in projects where compilations occur with different working | |
16729 | directories. | |
16730 | ||
d77de738 | 16731 | @opindex fprofile-dir |
ddf6fe37 | 16732 | @item -fprofile-dir=@var{path} |
d77de738 ML |
16733 | |
16734 | Set the directory to search for the profile data files in to @var{path}. | |
16735 | This option affects only the profile data generated by | |
16736 | @option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs} | |
16737 | and used by @option{-fprofile-use} and @option{-fbranch-probabilities} | |
16738 | and its related options. Both absolute and relative paths can be used. | |
16739 | By default, GCC uses the current directory as @var{path}, thus the | |
16740 | profile data file appears in the same directory as the object file. | |
16741 | In order to prevent the file name clashing, if the object file name is | |
16742 | not an absolute path, we mangle the absolute path of the | |
16743 | @file{@var{sourcename}.gcda} file and use it as the file name of a | |
16744 | @file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}. | |
16745 | See similar option @option{-fprofile-note}. | |
16746 | ||
16747 | When an executable is run in a massive parallel environment, it is recommended | |
16748 | to save profile to different folders. That can be done with variables | |
16749 | in @var{path} that are exported during run-time: | |
16750 | ||
16751 | @table @gcctabopt | |
16752 | ||
16753 | @item %p | |
16754 | process ID. | |
16755 | ||
16756 | @item %q@{VAR@} | |
16757 | value of environment variable @var{VAR} | |
16758 | ||
16759 | @end table | |
16760 | ||
ddf6fe37 | 16761 | @opindex fprofile-generate |
d77de738 ML |
16762 | @item -fprofile-generate |
16763 | @itemx -fprofile-generate=@var{path} | |
d77de738 ML |
16764 | |
16765 | Enable options usually used for instrumenting application to produce | |
16766 | profile useful for later recompilation with profile feedback based | |
16767 | optimization. You must use @option{-fprofile-generate} both when | |
16768 | compiling and when linking your program. | |
16769 | ||
16770 | The following options are enabled: | |
16771 | @option{-fprofile-arcs}, @option{-fprofile-values}, | |
16772 | @option{-finline-functions}, and @option{-fipa-bit-cp}. | |
16773 | ||
16774 | If @var{path} is specified, GCC looks at the @var{path} to find | |
16775 | the profile feedback data files. See @option{-fprofile-dir}. | |
16776 | ||
16777 | To optimize the program based on the collected profile information, use | |
16778 | @option{-fprofile-use}. @xref{Optimize Options}, for more information. | |
16779 | ||
ddf6fe37 | 16780 | @opindex fprofile-info-section |
d77de738 ML |
16781 | @item -fprofile-info-section |
16782 | @itemx -fprofile-info-section=@var{name} | |
d77de738 ML |
16783 | |
16784 | Register the profile information in the specified section instead of using a | |
16785 | constructor/destructor. The section name is @var{name} if it is specified, | |
16786 | otherwise the section name defaults to @code{.gcov_info}. A pointer to the | |
16787 | profile information generated by @option{-fprofile-arcs} is placed in the | |
16788 | specified section for each translation unit. This option disables the profile | |
16789 | information registration through a constructor and it disables the profile | |
16790 | information processing through a destructor. This option is not intended to be | |
16791 | used in hosted environments such as GNU/Linux. It targets freestanding | |
16792 | environments (for example embedded systems) with limited resources which do not | |
16793 | support constructors/destructors or the C library file I/O. | |
16794 | ||
16795 | The linker could collect the input sections in a continuous memory block and | |
16796 | define start and end symbols. A GNU linker script example which defines a | |
16797 | linker output section follows: | |
16798 | ||
16799 | @smallexample | |
16800 | .gcov_info : | |
16801 | @{ | |
16802 | PROVIDE (__gcov_info_start = .); | |
16803 | KEEP (*(.gcov_info)) | |
16804 | PROVIDE (__gcov_info_end = .); | |
16805 | @} | |
16806 | @end smallexample | |
16807 | ||
16808 | The program could dump the profiling information registered in this linker set | |
16809 | for example like this: | |
16810 | ||
16811 | @smallexample | |
16812 | #include <gcov.h> | |
16813 | #include <stdio.h> | |
16814 | #include <stdlib.h> | |
16815 | ||
16816 | extern const struct gcov_info *const __gcov_info_start[]; | |
16817 | extern const struct gcov_info *const __gcov_info_end[]; | |
16818 | ||
16819 | static void | |
16820 | dump (const void *d, unsigned n, void *arg) | |
16821 | @{ | |
16822 | const unsigned char *c = d; | |
16823 | ||
16824 | for (unsigned i = 0; i < n; ++i) | |
16825 | printf ("%02x", c[i]); | |
16826 | @} | |
16827 | ||
16828 | static void | |
16829 | filename (const char *f, void *arg) | |
16830 | @{ | |
16831 | __gcov_filename_to_gcfn (f, dump, arg ); | |
16832 | @} | |
16833 | ||
16834 | static void * | |
16835 | allocate (unsigned length, void *arg) | |
16836 | @{ | |
16837 | return malloc (length); | |
16838 | @} | |
16839 | ||
16840 | static void | |
16841 | dump_gcov_info (void) | |
16842 | @{ | |
16843 | const struct gcov_info *const *info = __gcov_info_start; | |
16844 | const struct gcov_info *const *end = __gcov_info_end; | |
16845 | ||
16846 | /* Obfuscate variable to prevent compiler optimizations. */ | |
16847 | __asm__ ("" : "+r" (info)); | |
16848 | ||
16849 | while (info != end) | |
16850 | @{ | |
16851 | void *arg = NULL; | |
16852 | __gcov_info_to_gcda (*info, filename, dump, allocate, arg); | |
16853 | putchar ('\n'); | |
16854 | ++info; | |
16855 | @} | |
16856 | @} | |
16857 | ||
16858 | int | |
16859 | main (void) | |
16860 | @{ | |
16861 | dump_gcov_info (); | |
16862 | return 0; | |
16863 | @} | |
16864 | @end smallexample | |
16865 | ||
16866 | The @command{merge-stream} subcommand of @command{gcov-tool} may be used to | |
16867 | deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and | |
16868 | @code{__gcov_info_to_gcda} functions and merge the profile information into | |
16869 | @file{.gcda} files on the host filesystem. | |
16870 | ||
d77de738 | 16871 | @opindex fprofile-note |
ddf6fe37 | 16872 | @item -fprofile-note=@var{path} |
d77de738 ML |
16873 | |
16874 | If @var{path} is specified, GCC saves @file{.gcno} file into @var{path} | |
16875 | location. If you combine the option with multiple source files, | |
16876 | the @file{.gcno} file will be overwritten. | |
16877 | ||
d77de738 | 16878 | @opindex fprofile-prefix-path |
ddf6fe37 | 16879 | @item -fprofile-prefix-path=@var{path} |
d77de738 ML |
16880 | |
16881 | This option can be used in combination with | |
16882 | @option{profile-generate=}@var{profile_dir} and | |
16883 | @option{profile-use=}@var{profile_dir} to inform GCC where is the base | |
16884 | directory of built source tree. By default @var{profile_dir} will contain | |
16885 | files with mangled absolute paths of all object files in the built project. | |
16886 | This is not desirable when directory used to build the instrumented binary | |
16887 | differs from the directory used to build the binary optimized with profile | |
16888 | feedback because the profile data will not be found during the optimized build. | |
16889 | In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path} | |
16890 | pointing to the base directory of the build can be used to strip the irrelevant | |
16891 | part of the path and keep all file names relative to the main build directory. | |
16892 | ||
d77de738 | 16893 | @opindex fprofile-prefix-map |
ddf6fe37 | 16894 | @item -fprofile-prefix-map=@var{old}=@var{new} |
d77de738 ML |
16895 | When compiling files residing in directory @file{@var{old}}, record |
16896 | profiling information (with @option{--coverage}) | |
16897 | describing them as if the files resided in | |
16898 | directory @file{@var{new}} instead. | |
2eb0191a | 16899 | See also @option{-ffile-prefix-map} and @option{-fcanon-prefix-map}. |
d77de738 | 16900 | |
d77de738 | 16901 | @opindex fprofile-update |
ddf6fe37 | 16902 | @item -fprofile-update=@var{method} |
d77de738 ML |
16903 | |
16904 | Alter the update method for an application instrumented for profile | |
16905 | feedback based optimization. The @var{method} argument should be one of | |
16906 | @samp{single}, @samp{atomic} or @samp{prefer-atomic}. | |
16907 | The first one is useful for single-threaded applications, | |
16908 | while the second one prevents profile corruption by emitting thread-safe code. | |
16909 | ||
16910 | @strong{Warning:} When an application does not properly join all threads | |
16911 | (or creates an detached thread), a profile file can be still corrupted. | |
16912 | ||
16913 | Using @samp{prefer-atomic} would be transformed either to @samp{atomic}, | |
16914 | when supported by a target, or to @samp{single} otherwise. The GCC driver | |
16915 | automatically selects @samp{prefer-atomic} when @option{-pthread} | |
16916 | is present in the command line. | |
16917 | ||
d77de738 | 16918 | @opindex fprofile-filter-files |
ddf6fe37 | 16919 | @item -fprofile-filter-files=@var{regex} |
d77de738 ML |
16920 | |
16921 | Instrument only functions from files whose name matches | |
16922 | any of the regular expressions (separated by semi-colons). | |
16923 | ||
16924 | For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument | |
16925 | only @file{main.c} and all C files starting with 'module'. | |
16926 | ||
d77de738 | 16927 | @opindex fprofile-exclude-files |
ddf6fe37 | 16928 | @item -fprofile-exclude-files=@var{regex} |
d77de738 ML |
16929 | |
16930 | Instrument only functions from files whose name does not match | |
16931 | any of the regular expressions (separated by semi-colons). | |
16932 | ||
16933 | For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation | |
16934 | of all files that are located in the @file{/usr/} folder. | |
16935 | ||
d77de738 | 16936 | @opindex fprofile-reproducible |
ddf6fe37 | 16937 | @item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]} |
d77de738 ML |
16938 | Control level of reproducibility of profile gathered by |
16939 | @code{-fprofile-generate}. This makes it possible to rebuild program | |
16940 | with same outcome which is useful, for example, for distribution | |
16941 | packages. | |
16942 | ||
16943 | With @option{-fprofile-reproducible=serial} the profile gathered by | |
16944 | @option{-fprofile-generate} is reproducible provided the trained program | |
16945 | behaves the same at each invocation of the train run, it is not | |
16946 | multi-threaded and profile data streaming is always done in the same | |
16947 | order. Note that profile streaming happens at the end of program run but | |
16948 | also before @code{fork} function is invoked. | |
16949 | ||
16950 | Note that it is quite common that execution counts of some part of | |
16951 | programs depends, for example, on length of temporary file names or | |
16952 | memory space randomization (that may affect hash-table collision rate). | |
16953 | Such non-reproducible part of programs may be annotated by | |
16954 | @code{no_instrument_function} function attribute. @command{gcov-dump} with | |
16955 | @option{-l} can be used to dump gathered data and verify that they are | |
16956 | indeed reproducible. | |
16957 | ||
16958 | With @option{-fprofile-reproducible=parallel-runs} collected profile | |
16959 | stays reproducible regardless the order of streaming of the data into | |
16960 | gcda files. This setting makes it possible to run multiple instances of | |
16961 | instrumented program in parallel (such as with @code{make -j}). This | |
16962 | reduces quality of gathered data, in particular of indirect call | |
16963 | profiling. | |
16964 | ||
d77de738 | 16965 | @opindex fsanitize=address |
ddf6fe37 | 16966 | @item -fsanitize=address |
d77de738 ML |
16967 | Enable AddressSanitizer, a fast memory error detector. |
16968 | Memory access instructions are instrumented to detect | |
16969 | out-of-bounds and use-after-free bugs. | |
16970 | The option enables @option{-fsanitize-address-use-after-scope}. | |
16971 | See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for | |
16972 | more details. The run-time behavior can be influenced using the | |
16973 | @env{ASAN_OPTIONS} environment variable. When set to @code{help=1}, | |
16974 | the available options are shown at startup of the instrumented program. See | |
16975 | @url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags} | |
16976 | for a list of supported options. | |
16977 | The option cannot be combined with @option{-fsanitize=thread} or | |
16978 | @option{-fsanitize=hwaddress}. Note that the only target | |
16979 | @option{-fsanitize=hwaddress} is currently supported on is AArch64. | |
16980 | ||
6a07798c MP |
16981 | To get more accurate stack traces, it is possible to use options such as |
16982 | @option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent | |
16983 | most function inlining), @option{-fno-optimize-sibling-calls} (which prevents | |
16984 | optimizing sibling and tail recursive calls; this option is implicit for | |
16985 | @option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which | |
16986 | disables Identical Code Folding for functions). Since multiple runs of the | |
16987 | program may yield backtraces with different addresses due to ASLR (Address | |
16988 | Space Layout Randomization), it may be desirable to turn ASLR off. On Linux, | |
16989 | this can be achieved with @samp{setarch `uname -m` -R ./prog}. | |
16990 | ||
d77de738 | 16991 | @opindex fsanitize=kernel-address |
f33d7a88 | 16992 | @item -fsanitize=kernel-address |
d77de738 | 16993 | Enable AddressSanitizer for Linux kernel. |
a0bf71be | 16994 | See @uref{https://github.com/google/kernel-sanitizers} for more details. |
d77de738 | 16995 | |
d77de738 | 16996 | @opindex fsanitize=hwaddress |
f33d7a88 | 16997 | @item -fsanitize=hwaddress |
d77de738 ML |
16998 | Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to |
16999 | ignore the top byte of a pointer to allow the detection of memory errors with | |
17000 | a low memory overhead. | |
17001 | Memory access instructions are instrumented to detect out-of-bounds and | |
17002 | use-after-free bugs. | |
17003 | The option enables @option{-fsanitize-address-use-after-scope}. | |
17004 | See | |
17005 | @uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html} | |
17006 | for more details. The run-time behavior can be influenced using the | |
17007 | @env{HWASAN_OPTIONS} environment variable. When set to @code{help=1}, | |
17008 | the available options are shown at startup of the instrumented program. | |
17009 | The option cannot be combined with @option{-fsanitize=thread} or | |
17010 | @option{-fsanitize=address}, and is currently only available on AArch64. | |
17011 | ||
d77de738 | 17012 | @opindex fsanitize=kernel-hwaddress |
ddf6fe37 | 17013 | @item -fsanitize=kernel-hwaddress |
d77de738 ML |
17014 | Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel. |
17015 | Similar to @option{-fsanitize=kernel-address} but using an alternate | |
17016 | instrumentation method, and similar to @option{-fsanitize=hwaddress} but with | |
17017 | instrumentation differences necessary for compiling the Linux kernel. | |
17018 | These differences are to avoid hwasan library initialization calls and to | |
17019 | account for the stack pointer having a different value in its top byte. | |
17020 | ||
17021 | @emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}. | |
17022 | Instrumenting the stack and alloca calls are not on by default but are still | |
17023 | possible by specifying the command-line options | |
17024 | @option{--param hwasan-instrument-stack=1} and | |
17025 | @option{--param hwasan-instrument-allocas=1} respectively. Using a random frame | |
17026 | tag is not implemented for kernel instrumentation. | |
17027 | ||
d77de738 | 17028 | @opindex fsanitize=pointer-compare |
ddf6fe37 | 17029 | @item -fsanitize=pointer-compare |
d77de738 ML |
17030 | Instrument comparison operation (<, <=, >, >=) with pointer operands. |
17031 | The option must be combined with either @option{-fsanitize=kernel-address} or | |
17032 | @option{-fsanitize=address} | |
17033 | The option cannot be combined with @option{-fsanitize=thread}. | |
17034 | Note: By default the check is disabled at run time. To enable it, | |
17035 | add @code{detect_invalid_pointer_pairs=2} to the environment variable | |
17036 | @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects | |
17037 | invalid operation only when both pointers are non-null. | |
17038 | ||
d77de738 | 17039 | @opindex fsanitize=pointer-subtract |
ddf6fe37 | 17040 | @item -fsanitize=pointer-subtract |
d77de738 ML |
17041 | Instrument subtraction with pointer operands. |
17042 | The option must be combined with either @option{-fsanitize=kernel-address} or | |
17043 | @option{-fsanitize=address} | |
17044 | The option cannot be combined with @option{-fsanitize=thread}. | |
17045 | Note: By default the check is disabled at run time. To enable it, | |
17046 | add @code{detect_invalid_pointer_pairs=2} to the environment variable | |
17047 | @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects | |
17048 | invalid operation only when both pointers are non-null. | |
17049 | ||
d77de738 | 17050 | @opindex fsanitize=shadow-call-stack |
ddf6fe37 | 17051 | @item -fsanitize=shadow-call-stack |
d77de738 ML |
17052 | Enable ShadowCallStack, a security enhancement mechanism used to protect |
17053 | programs against return address overwrites (e.g. stack buffer overflows.) | |
17054 | It works by saving a function's return address to a separately allocated | |
17055 | shadow call stack in the function prologue and restoring the return address | |
17056 | from the shadow call stack in the function epilogue. Instrumentation only | |
17057 | occurs in functions that need to save the return address to the stack. | |
17058 | ||
17059 | Currently it only supports the aarch64 platform. It is specifically | |
17060 | designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option. | |
17061 | For the user space programs, runtime support is not currently provided | |
17062 | in libc and libgcc. Users who want to use this feature in user space need | |
17063 | to provide their own support for the runtime. It should be noted that | |
17064 | this may cause the ABI rules to be broken. | |
17065 | ||
17066 | On aarch64, the instrumentation makes use of the platform register @code{x18}. | |
17067 | This generally means that any code that may run on the same thread as code | |
17068 | compiled with ShadowCallStack must be compiled with the flag | |
17069 | @option{-ffixed-x18}, otherwise functions compiled without | |
17070 | @option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow | |
17071 | stack pointer. | |
17072 | ||
17073 | Also, because there is no userspace runtime support, code compiled with | |
17074 | ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions} | |
17075 | to turn off exceptions. | |
17076 | ||
17077 | See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more | |
17078 | details. | |
17079 | ||
d77de738 | 17080 | @opindex fsanitize=thread |
ddf6fe37 | 17081 | @item -fsanitize=thread |
d77de738 ML |
17082 | Enable ThreadSanitizer, a fast data race detector. |
17083 | Memory access instructions are instrumented to detect | |
17084 | data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more | |
17085 | details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS} | |
17086 | environment variable; see | |
17087 | @url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of | |
17088 | supported options. | |
17089 | The option cannot be combined with @option{-fsanitize=address}, | |
17090 | @option{-fsanitize=leak}. | |
17091 | ||
17092 | Note that sanitized atomic builtins cannot throw exceptions when | |
17093 | operating on invalid memory addresses with non-call exceptions | |
17094 | (@option{-fnon-call-exceptions}). | |
17095 | ||
d77de738 | 17096 | @opindex fsanitize=leak |
ddf6fe37 | 17097 | @item -fsanitize=leak |
d77de738 | 17098 | Enable LeakSanitizer, a memory leak detector. |
c5c4fdac JG |
17099 | This option only matters for linking of executables. |
17100 | The executable is linked against a library that overrides @code{malloc} | |
d77de738 ML |
17101 | and other allocator functions. See |
17102 | @uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more | |
17103 | details. The run-time behavior can be influenced using the | |
17104 | @env{LSAN_OPTIONS} environment variable. | |
17105 | The option cannot be combined with @option{-fsanitize=thread}. | |
17106 | ||
d77de738 | 17107 | @opindex fsanitize=undefined |
ddf6fe37 | 17108 | @item -fsanitize=undefined |
d77de738 ML |
17109 | Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector. |
17110 | Various computations are instrumented to detect undefined behavior | |
17111 | at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the | |
17112 | @env{UBSAN_OPTIONS} environment variable. Current suboptions are: | |
17113 | ||
17114 | @table @gcctabopt | |
17115 | ||
d77de738 | 17116 | @opindex fsanitize=shift |
ddf6fe37 | 17117 | @item -fsanitize=shift |
d77de738 ML |
17118 | This option enables checking that the result of a shift operation is |
17119 | not undefined. Note that what exactly is considered undefined differs | |
17120 | slightly between C and C++, as well as between ISO C90 and C99, etc. | |
17121 | This option has two suboptions, @option{-fsanitize=shift-base} and | |
17122 | @option{-fsanitize=shift-exponent}. | |
17123 | ||
d77de738 | 17124 | @opindex fsanitize=shift-exponent |
ddf6fe37 | 17125 | @item -fsanitize=shift-exponent |
d77de738 ML |
17126 | This option enables checking that the second argument of a shift operation |
17127 | is not negative and is smaller than the precision of the promoted first | |
17128 | argument. | |
17129 | ||
d77de738 | 17130 | @opindex fsanitize=shift-base |
ddf6fe37 | 17131 | @item -fsanitize=shift-base |
d77de738 ML |
17132 | If the second argument of a shift operation is within range, check that the |
17133 | result of a shift operation is not undefined. Note that what exactly is | |
17134 | considered undefined differs slightly between C and C++, as well as between | |
17135 | ISO C90 and C99, etc. | |
17136 | ||
d77de738 | 17137 | @opindex fsanitize=integer-divide-by-zero |
ddf6fe37 | 17138 | @item -fsanitize=integer-divide-by-zero |
d77de738 ML |
17139 | Detect integer division by zero. |
17140 | ||
d77de738 | 17141 | @opindex fsanitize=unreachable |
ddf6fe37 | 17142 | @item -fsanitize=unreachable |
d77de738 ML |
17143 | With this option, the compiler turns the @code{__builtin_unreachable} |
17144 | call into a diagnostics message call instead. When reaching the | |
17145 | @code{__builtin_unreachable} call, the behavior is undefined. | |
17146 | ||
d77de738 | 17147 | @opindex fsanitize=vla-bound |
ddf6fe37 | 17148 | @item -fsanitize=vla-bound |
d77de738 ML |
17149 | This option instructs the compiler to check that the size of a variable |
17150 | length array is positive. | |
17151 | ||
d77de738 | 17152 | @opindex fsanitize=null |
ddf6fe37 | 17153 | @item -fsanitize=null |
d77de738 ML |
17154 | This option enables pointer checking. Particularly, the application |
17155 | built with this option turned on will issue an error message when it | |
17156 | tries to dereference a NULL pointer, or if a reference (possibly an | |
17157 | rvalue reference) is bound to a NULL pointer, or if a method is invoked | |
17158 | on an object pointed by a NULL pointer. | |
17159 | ||
d77de738 | 17160 | @opindex fsanitize=return |
ddf6fe37 | 17161 | @item -fsanitize=return |
d77de738 ML |
17162 | This option enables return statement checking. Programs |
17163 | built with this option turned on will issue an error message | |
17164 | when the end of a non-void function is reached without actually | |
17165 | returning a value. This option works in C++ only. | |
17166 | ||
d77de738 | 17167 | @opindex fsanitize=signed-integer-overflow |
ddf6fe37 | 17168 | @item -fsanitize=signed-integer-overflow |
d77de738 ML |
17169 | This option enables signed integer overflow checking. We check that |
17170 | the result of @code{+}, @code{*}, and both unary and binary @code{-} | |
17171 | does not overflow in the signed arithmetics. This also detects | |
17172 | @code{INT_MIN / -1} signed division. Note, integer promotion | |
17173 | rules must be taken into account. That is, the following is not an | |
17174 | overflow: | |
17175 | @smallexample | |
17176 | signed char a = SCHAR_MAX; | |
17177 | a++; | |
17178 | @end smallexample | |
17179 | ||
d77de738 | 17180 | @opindex fsanitize=bounds |
ddf6fe37 | 17181 | @item -fsanitize=bounds |
d77de738 ML |
17182 | This option enables instrumentation of array bounds. Various out of bounds |
17183 | accesses are detected. Flexible array members, flexible array member-like | |
c7728805 JJ |
17184 | arrays, and initializers of variables with static storage are not |
17185 | instrumented, with the exception of flexible array member-like arrays | |
17186 | for which @code{-fstrict-flex-arrays} or @code{-fstrict-flex-arrays=} | |
17187 | options or @code{strict_flex_array} attributes say they shouldn't be treated | |
17188 | like flexible array member-like arrays. | |
d77de738 | 17189 | |
d77de738 | 17190 | @opindex fsanitize=bounds-strict |
ddf6fe37 | 17191 | @item -fsanitize=bounds-strict |
d77de738 | 17192 | This option enables strict instrumentation of array bounds. Most out of bounds |
c7728805 JJ |
17193 | accesses are detected, including flexible array member-like arrays. |
17194 | Initializers of variables with static storage are not instrumented. | |
d77de738 | 17195 | |
d77de738 | 17196 | @opindex fsanitize=alignment |
ddf6fe37 | 17197 | @item -fsanitize=alignment |
d77de738 ML |
17198 | |
17199 | This option enables checking of alignment of pointers when they are | |
17200 | dereferenced, or when a reference is bound to insufficiently aligned target, | |
17201 | or when a method or constructor is invoked on insufficiently aligned object. | |
17202 | ||
d77de738 | 17203 | @opindex fsanitize=object-size |
ddf6fe37 | 17204 | @item -fsanitize=object-size |
d77de738 | 17205 | This option enables instrumentation of memory references using the |
7283380a SP |
17206 | @code{__builtin_dynamic_object_size} function. Various out of bounds |
17207 | pointer accesses are detected. | |
d77de738 | 17208 | |
d77de738 | 17209 | @opindex fsanitize=float-divide-by-zero |
ddf6fe37 | 17210 | @item -fsanitize=float-divide-by-zero |
d77de738 ML |
17211 | Detect floating-point division by zero. Unlike other similar options, |
17212 | @option{-fsanitize=float-divide-by-zero} is not enabled by | |
17213 | @option{-fsanitize=undefined}, since floating-point division by zero can | |
17214 | be a legitimate way of obtaining infinities and NaNs. | |
17215 | ||
d77de738 | 17216 | @opindex fsanitize=float-cast-overflow |
ddf6fe37 | 17217 | @item -fsanitize=float-cast-overflow |
d77de738 ML |
17218 | This option enables floating-point type to integer conversion checking. |
17219 | We check that the result of the conversion does not overflow. | |
17220 | Unlike other similar options, @option{-fsanitize=float-cast-overflow} is | |
17221 | not enabled by @option{-fsanitize=undefined}. | |
17222 | This option does not work well with @code{FE_INVALID} exceptions enabled. | |
17223 | ||
d77de738 | 17224 | @opindex fsanitize=nonnull-attribute |
ddf6fe37 | 17225 | @item -fsanitize=nonnull-attribute |
d77de738 ML |
17226 | |
17227 | This option enables instrumentation of calls, checking whether null values | |
17228 | are not passed to arguments marked as requiring a non-null value by the | |
17229 | @code{nonnull} function attribute. | |
17230 | ||
d77de738 | 17231 | @opindex fsanitize=returns-nonnull-attribute |
ddf6fe37 | 17232 | @item -fsanitize=returns-nonnull-attribute |
d77de738 ML |
17233 | |
17234 | This option enables instrumentation of return statements in functions | |
17235 | marked with @code{returns_nonnull} function attribute, to detect returning | |
17236 | of null values from such functions. | |
17237 | ||
d77de738 | 17238 | @opindex fsanitize=bool |
ddf6fe37 | 17239 | @item -fsanitize=bool |
d77de738 ML |
17240 | |
17241 | This option enables instrumentation of loads from bool. If a value other | |
17242 | than 0/1 is loaded, a run-time error is issued. | |
17243 | ||
d77de738 | 17244 | @opindex fsanitize=enum |
ddf6fe37 | 17245 | @item -fsanitize=enum |
d77de738 ML |
17246 | |
17247 | This option enables instrumentation of loads from an enum type. If | |
17248 | a value outside the range of values for the enum type is loaded, | |
17249 | a run-time error is issued. | |
17250 | ||
d77de738 | 17251 | @opindex fsanitize=vptr |
ddf6fe37 | 17252 | @item -fsanitize=vptr |
d77de738 ML |
17253 | |
17254 | This option enables instrumentation of C++ member function calls, member | |
17255 | accesses and some conversions between pointers to base and derived classes, | |
17256 | to verify the referenced object has the correct dynamic type. | |
17257 | ||
d77de738 | 17258 | @opindex fsanitize=pointer-overflow |
ddf6fe37 | 17259 | @item -fsanitize=pointer-overflow |
d77de738 ML |
17260 | |
17261 | This option enables instrumentation of pointer arithmetics. If the pointer | |
17262 | arithmetics overflows, a run-time error is issued. | |
17263 | ||
d77de738 | 17264 | @opindex fsanitize=builtin |
ddf6fe37 | 17265 | @item -fsanitize=builtin |
d77de738 ML |
17266 | |
17267 | This option enables instrumentation of arguments to selected builtin | |
17268 | functions. If an invalid value is passed to such arguments, a run-time | |
17269 | error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz} | |
17270 | or @code{__builtin_clz} invokes undefined behavior and is diagnosed | |
17271 | by this option. | |
17272 | ||
17273 | @end table | |
17274 | ||
17275 | Note that sanitizers tend to increase the rate of false positive | |
17276 | warnings, most notably those around @option{-Wmaybe-uninitialized}. | |
17277 | We recommend against combining @option{-Werror} and [the use of] | |
17278 | sanitizers. | |
17279 | ||
17280 | While @option{-ftrapv} causes traps for signed overflows to be emitted, | |
17281 | @option{-fsanitize=undefined} gives a diagnostic message. | |
17282 | This currently works only for the C family of languages. | |
17283 | ||
d77de738 | 17284 | @opindex fno-sanitize=all |
ddf6fe37 | 17285 | @item -fno-sanitize=all |
d77de738 ML |
17286 | |
17287 | This option disables all previously enabled sanitizers. | |
17288 | @option{-fsanitize=all} is not allowed, as some sanitizers cannot be used | |
17289 | together. | |
17290 | ||
d77de738 | 17291 | @opindex fasan-shadow-offset |
ddf6fe37 | 17292 | @item -fasan-shadow-offset=@var{number} |
d77de738 ML |
17293 | This option forces GCC to use custom shadow offset in AddressSanitizer checks. |
17294 | It is useful for experimenting with different shadow memory layouts in | |
17295 | Kernel AddressSanitizer. | |
17296 | ||
d77de738 | 17297 | @opindex fsanitize-sections |
ddf6fe37 | 17298 | @item -fsanitize-sections=@var{s1},@var{s2},... |
d77de738 ML |
17299 | Sanitize global variables in selected user-defined sections. @var{si} may |
17300 | contain wildcards. | |
17301 | ||
d77de738 ML |
17302 | @opindex fsanitize-recover |
17303 | @opindex fno-sanitize-recover | |
ddf6fe37 | 17304 | @item -fsanitize-recover@r{[}=@var{opts}@r{]} |
d77de738 ML |
17305 | @option{-fsanitize-recover=} controls error recovery mode for sanitizers |
17306 | mentioned in comma-separated list of @var{opts}. Enabling this option | |
17307 | for a sanitizer component causes it to attempt to continue | |
17308 | running the program as if no error happened. This means multiple | |
17309 | runtime errors can be reported in a single program run, and the exit | |
17310 | code of the program may indicate success even when errors | |
17311 | have been reported. The @option{-fno-sanitize-recover=} option | |
17312 | can be used to alter | |
17313 | this behavior: only the first detected error is reported | |
17314 | and program then exits with a non-zero exit code. | |
17315 | ||
17316 | Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions | |
17317 | except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}), | |
17318 | @option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero}, | |
17319 | @option{-fsanitize=bounds-strict}, | |
17320 | @option{-fsanitize=kernel-address} and @option{-fsanitize=address}. | |
17321 | For these sanitizers error recovery is turned on by default, | |
17322 | except @option{-fsanitize=address}, for which this feature is experimental. | |
17323 | @option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also | |
17324 | accepted, the former enables recovery for all sanitizers that support it, | |
17325 | the latter disables recovery for all sanitizers that support it. | |
17326 | ||
17327 | Even if a recovery mode is turned on the compiler side, it needs to be also | |
17328 | enabled on the runtime library side, otherwise the failures are still fatal. | |
17329 | The runtime library defaults to @code{halt_on_error=0} for | |
17330 | ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for | |
17331 | AddressSanitizer is @code{halt_on_error=1}. This can be overridden through | |
17332 | setting the @code{halt_on_error} flag in the corresponding environment variable. | |
17333 | ||
17334 | Syntax without an explicit @var{opts} parameter is deprecated. It is | |
17335 | equivalent to specifying an @var{opts} list of: | |
17336 | ||
17337 | @smallexample | |
17338 | undefined,float-cast-overflow,float-divide-by-zero,bounds-strict | |
17339 | @end smallexample | |
17340 | ||
d77de738 | 17341 | @opindex fsanitize-address-use-after-scope |
ddf6fe37 | 17342 | @item -fsanitize-address-use-after-scope |
d77de738 ML |
17343 | Enable sanitization of local variables to detect use-after-scope bugs. |
17344 | The option sets @option{-fstack-reuse} to @samp{none}. | |
17345 | ||
d77de738 ML |
17346 | @opindex fsanitize-trap |
17347 | @opindex fno-sanitize-trap | |
ddf6fe37 | 17348 | @item -fsanitize-trap@r{[}=@var{opts}@r{]} |
d77de738 ML |
17349 | The @option{-fsanitize-trap=} option instructs the compiler to |
17350 | report for sanitizers mentioned in comma-separated list of @var{opts} | |
17351 | undefined behavior using @code{__builtin_trap} rather than a @code{libubsan} | |
17352 | library routine. If this option is enabled for certain sanitizer, | |
17353 | it takes precedence over the @option{-fsanitizer-recover=} for that | |
17354 | sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless | |
17355 | of whether recovery is enabled or disabled using @option{-fsanitize-recover=}. | |
17356 | ||
17357 | The advantage of this is that the @code{libubsan} library is not needed | |
17358 | and is not linked in, so this is usable even in freestanding environments. | |
17359 | ||
17360 | Currently this feature works with @option{-fsanitize=undefined} (and its suboptions | |
17361 | except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow}, | |
17362 | @option{-fsanitize=float-divide-by-zero} and | |
17363 | @option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also | |
17364 | specified, which enables it for @code{undefined} suboptions, | |
17365 | @option{-fsanitize=float-cast-overflow}, | |
17366 | @option{-fsanitize=float-divide-by-zero} and | |
17367 | @option{-fsanitize=bounds-strict}. | |
17368 | If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used | |
17369 | and @code{-fsanitize=vptr} is enabled on the command line, the | |
17370 | instrumentation is silently ignored as the instrumentation always needs | |
17371 | @code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed. | |
17372 | ||
d77de738 | 17373 | @opindex fsanitize-undefined-trap-on-error |
ddf6fe37 | 17374 | @item -fsanitize-undefined-trap-on-error |
d77de738 ML |
17375 | The @option{-fsanitize-undefined-trap-on-error} option is deprecated |
17376 | equivalent of @option{-fsanitize-trap=all}. | |
17377 | ||
d77de738 | 17378 | @opindex fsanitize-coverage=trace-pc |
ddf6fe37 | 17379 | @item -fsanitize-coverage=trace-pc |
d77de738 ML |
17380 | Enable coverage-guided fuzzing code instrumentation. |
17381 | Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block. | |
17382 | ||
d77de738 | 17383 | @opindex fsanitize-coverage=trace-cmp |
ddf6fe37 | 17384 | @item -fsanitize-coverage=trace-cmp |
d77de738 ML |
17385 | Enable dataflow guided fuzzing code instrumentation. |
17386 | Inserts a call to @code{__sanitizer_cov_trace_cmp1}, | |
17387 | @code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or | |
17388 | @code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands | |
17389 | variable or @code{__sanitizer_cov_trace_const_cmp1}, | |
17390 | @code{__sanitizer_cov_trace_const_cmp2}, | |
17391 | @code{__sanitizer_cov_trace_const_cmp4} or | |
17392 | @code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one | |
17393 | operand constant, @code{__sanitizer_cov_trace_cmpf} or | |
17394 | @code{__sanitizer_cov_trace_cmpd} for float or double comparisons and | |
17395 | @code{__sanitizer_cov_trace_switch} for switch statements. | |
17396 | ||
d77de738 | 17397 | @opindex fcf-protection |
ddf6fe37 | 17398 | @item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]} |
d77de738 ML |
17399 | Enable code instrumentation of control-flow transfers to increase |
17400 | program security by checking that target addresses of control-flow | |
17401 | transfer instructions (such as indirect function call, function return, | |
17402 | indirect jump) are valid. This prevents diverting the flow of control | |
17403 | to an unexpected target. This is intended to protect against such | |
17404 | threats as Return-oriented Programming (ROP), and similarly | |
17405 | call/jmp-oriented programming (COP/JOP). | |
17406 | ||
17407 | The value @code{branch} tells the compiler to implement checking of | |
17408 | validity of control-flow transfer at the point of indirect branch | |
17409 | instructions, i.e.@: call/jmp instructions. The value @code{return} | |
17410 | implements checking of validity at the point of returning from a | |
17411 | function. The value @code{full} is an alias for specifying both | |
17412 | @code{branch} and @code{return}. The value @code{none} turns off | |
17413 | instrumentation. | |
17414 | ||
17415 | The value @code{check} is used for the final link with link-time | |
17416 | optimization (LTO). An error is issued if LTO object files are | |
17417 | compiled with different @option{-fcf-protection} values. The | |
17418 | value @code{check} is ignored at the compile time. | |
17419 | ||
17420 | The macro @code{__CET__} is defined when @option{-fcf-protection} is | |
17421 | used. The first bit of @code{__CET__} is set to 1 for the value | |
17422 | @code{branch} and the second bit of @code{__CET__} is set to 1 for | |
17423 | the @code{return}. | |
17424 | ||
17425 | You can also use the @code{nocf_check} attribute to identify | |
17426 | which functions and calls should be skipped from instrumentation | |
17427 | (@pxref{Function Attributes}). | |
17428 | ||
17429 | Currently the x86 GNU/Linux target provides an implementation based | |
17430 | on Intel Control-flow Enforcement Technology (CET) which works for | |
17431 | i686 processor or newer. | |
17432 | ||
d77de738 | 17433 | @opindex fharden-compares |
ddf6fe37 | 17434 | @item -fharden-compares |
d77de738 ML |
17435 | For every logical test that survives gimple optimizations and is |
17436 | @emph{not} the condition in a conditional branch (for example, | |
17437 | conditions tested for conditional moves, or to store in boolean | |
17438 | variables), emit extra code to compute and verify the reversed | |
17439 | condition, and to call @code{__builtin_trap} if the results do not | |
17440 | match. Use with @samp{-fharden-conditional-branches} to cover all | |
17441 | conditionals. | |
17442 | ||
d77de738 | 17443 | @opindex fharden-conditional-branches |
ddf6fe37 | 17444 | @item -fharden-conditional-branches |
d77de738 ML |
17445 | For every non-vectorized conditional branch that survives gimple |
17446 | optimizations, emit extra code to compute and verify the reversed | |
17447 | condition, and to call @code{__builtin_trap} if the result is | |
17448 | unexpected. Use with @samp{-fharden-compares} to cover all | |
17449 | conditionals. | |
17450 | ||
d77de738 | 17451 | @opindex fstack-protector |
ddf6fe37 | 17452 | @item -fstack-protector |
d77de738 ML |
17453 | Emit extra code to check for buffer overflows, such as stack smashing |
17454 | attacks. This is done by adding a guard variable to functions with | |
17455 | vulnerable objects. This includes functions that call @code{alloca}, and | |
17456 | functions with buffers larger than or equal to 8 bytes. The guards are | |
17457 | initialized when a function is entered and then checked when the function | |
17458 | exits. If a guard check fails, an error message is printed and the program | |
17459 | exits. Only variables that are actually allocated on the stack are | |
17460 | considered, optimized away variables or variables allocated in registers | |
17461 | don't count. | |
17462 | ||
d77de738 | 17463 | @opindex fstack-protector-all |
ddf6fe37 | 17464 | @item -fstack-protector-all |
d77de738 ML |
17465 | Like @option{-fstack-protector} except that all functions are protected. |
17466 | ||
d77de738 | 17467 | @opindex fstack-protector-strong |
ddf6fe37 | 17468 | @item -fstack-protector-strong |
d77de738 ML |
17469 | Like @option{-fstack-protector} but includes additional functions to |
17470 | be protected --- those that have local array definitions, or have | |
17471 | references to local frame addresses. Only variables that are actually | |
17472 | allocated on the stack are considered, optimized away variables or variables | |
17473 | allocated in registers don't count. | |
17474 | ||
d77de738 | 17475 | @opindex fstack-protector-explicit |
ddf6fe37 | 17476 | @item -fstack-protector-explicit |
d77de738 ML |
17477 | Like @option{-fstack-protector} but only protects those functions which |
17478 | have the @code{stack_protect} attribute. | |
17479 | ||
d77de738 | 17480 | @opindex fstack-check |
ddf6fe37 | 17481 | @item -fstack-check |
d77de738 ML |
17482 | Generate code to verify that you do not go beyond the boundary of the |
17483 | stack. You should specify this flag if you are running in an | |
17484 | environment with multiple threads, but you only rarely need to specify it in | |
17485 | a single-threaded environment since stack overflow is automatically | |
17486 | detected on nearly all systems if there is only one stack. | |
17487 | ||
17488 | Note that this switch does not actually cause checking to be done; the | |
17489 | operating system or the language runtime must do that. The switch causes | |
17490 | generation of code to ensure that they see the stack being extended. | |
17491 | ||
17492 | You can additionally specify a string parameter: @samp{no} means no | |
17493 | checking, @samp{generic} means force the use of old-style checking, | |
17494 | @samp{specific} means use the best checking method and is equivalent | |
17495 | to bare @option{-fstack-check}. | |
17496 | ||
17497 | Old-style checking is a generic mechanism that requires no specific | |
17498 | target support in the compiler but comes with the following drawbacks: | |
17499 | ||
17500 | @enumerate | |
17501 | @item | |
17502 | Modified allocation strategy for large objects: they are always | |
17503 | allocated dynamically if their size exceeds a fixed threshold. Note this | |
17504 | may change the semantics of some code. | |
17505 | ||
17506 | @item | |
17507 | Fixed limit on the size of the static frame of functions: when it is | |
17508 | topped by a particular function, stack checking is not reliable and | |
17509 | a warning is issued by the compiler. | |
17510 | ||
17511 | @item | |
17512 | Inefficiency: because of both the modified allocation strategy and the | |
17513 | generic implementation, code performance is hampered. | |
17514 | @end enumerate | |
17515 | ||
17516 | Note that old-style stack checking is also the fallback method for | |
17517 | @samp{specific} if no target support has been added in the compiler. | |
17518 | ||
17519 | @samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion | |
17520 | and stack overflows. @samp{specific} is an excellent choice when compiling | |
17521 | Ada code. It is not generally sufficient to protect against stack-clash | |
17522 | attacks. To protect against those you want @samp{-fstack-clash-protection}. | |
17523 | ||
d77de738 | 17524 | @opindex fstack-clash-protection |
ddf6fe37 | 17525 | @item -fstack-clash-protection |
d77de738 ML |
17526 | Generate code to prevent stack clash style attacks. When this option is |
17527 | enabled, the compiler will only allocate one page of stack space at a time | |
17528 | and each page is accessed immediately after allocation. Thus, it prevents | |
17529 | allocations from jumping over any stack guard page provided by the | |
17530 | operating system. | |
17531 | ||
17532 | Most targets do not fully support stack clash protection. However, on | |
17533 | those targets @option{-fstack-clash-protection} will protect dynamic stack | |
17534 | allocations. @option{-fstack-clash-protection} may also provide limited | |
17535 | protection for static stack allocations if the target supports | |
17536 | @option{-fstack-check=specific}. | |
17537 | ||
d77de738 ML |
17538 | @opindex fstack-limit-register |
17539 | @opindex fstack-limit-symbol | |
17540 | @opindex fno-stack-limit | |
ddf6fe37 AA |
17541 | @item -fstack-limit-register=@var{reg} |
17542 | @itemx -fstack-limit-symbol=@var{sym} | |
17543 | @itemx -fno-stack-limit | |
d77de738 ML |
17544 | Generate code to ensure that the stack does not grow beyond a certain value, |
17545 | either the value of a register or the address of a symbol. If a larger | |
17546 | stack is required, a signal is raised at run time. For most targets, | |
17547 | the signal is raised before the stack overruns the boundary, so | |
17548 | it is possible to catch the signal without taking special precautions. | |
17549 | ||
17550 | For instance, if the stack starts at absolute address @samp{0x80000000} | |
17551 | and grows downwards, you can use the flags | |
17552 | @option{-fstack-limit-symbol=__stack_limit} and | |
17553 | @option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit | |
17554 | of 128KB@. Note that this may only work with the GNU linker. | |
17555 | ||
17556 | You can locally override stack limit checking by using the | |
17557 | @code{no_stack_limit} function attribute (@pxref{Function Attributes}). | |
17558 | ||
d77de738 | 17559 | @opindex fsplit-stack |
ddf6fe37 | 17560 | @item -fsplit-stack |
d77de738 ML |
17561 | Generate code to automatically split the stack before it overflows. |
17562 | The resulting program has a discontiguous stack which can only | |
17563 | overflow if the program is unable to allocate any more memory. This | |
17564 | is most useful when running threaded programs, as it is no longer | |
17565 | necessary to calculate a good stack size to use for each thread. This | |
17566 | is currently only implemented for the x86 targets running | |
17567 | GNU/Linux. | |
17568 | ||
17569 | When code compiled with @option{-fsplit-stack} calls code compiled | |
17570 | without @option{-fsplit-stack}, there may not be much stack space | |
17571 | available for the latter code to run. If compiling all code, | |
17572 | including library code, with @option{-fsplit-stack} is not an option, | |
17573 | then the linker can fix up these calls so that the code compiled | |
17574 | without @option{-fsplit-stack} always has a large stack. Support for | |
17575 | this is implemented in the gold linker in GNU binutils release 2.21 | |
17576 | and later. | |
17577 | ||
d77de738 | 17578 | @opindex fvtable-verify |
ddf6fe37 | 17579 | @item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} |
d77de738 ML |
17580 | This option is only available when compiling C++ code. |
17581 | It turns on (or off, if using @option{-fvtable-verify=none}) the security | |
17582 | feature that verifies at run time, for every virtual call, that | |
17583 | the vtable pointer through which the call is made is valid for the type of | |
17584 | the object, and has not been corrupted or overwritten. If an invalid vtable | |
17585 | pointer is detected at run time, an error is reported and execution of the | |
17586 | program is immediately halted. | |
17587 | ||
17588 | This option causes run-time data structures to be built at program startup, | |
17589 | which are used for verifying the vtable pointers. | |
17590 | The options @samp{std} and @samp{preinit} | |
17591 | control the timing of when these data structures are built. In both cases the | |
17592 | data structures are built before execution reaches @code{main}. Using | |
17593 | @option{-fvtable-verify=std} causes the data structures to be built after | |
17594 | shared libraries have been loaded and initialized. | |
17595 | @option{-fvtable-verify=preinit} causes them to be built before shared | |
17596 | libraries have been loaded and initialized. | |
17597 | ||
17598 | If this option appears multiple times in the command line with different | |
17599 | values specified, @samp{none} takes highest priority over both @samp{std} and | |
17600 | @samp{preinit}; @samp{preinit} takes priority over @samp{std}. | |
17601 | ||
d77de738 | 17602 | @opindex fvtv-debug |
ddf6fe37 | 17603 | @item -fvtv-debug |
d77de738 ML |
17604 | When used in conjunction with @option{-fvtable-verify=std} or |
17605 | @option{-fvtable-verify=preinit}, causes debug versions of the | |
17606 | runtime functions for the vtable verification feature to be called. | |
17607 | This flag also causes the compiler to log information about which | |
17608 | vtable pointers it finds for each class. | |
17609 | This information is written to a file named @file{vtv_set_ptr_data.log} | |
17610 | in the directory named by the environment variable @env{VTV_LOGS_DIR} | |
17611 | if that is defined or the current working directory otherwise. | |
17612 | ||
17613 | Note: This feature @emph{appends} data to the log file. If you want a fresh log | |
17614 | file, be sure to delete any existing one. | |
17615 | ||
d77de738 | 17616 | @opindex fvtv-counts |
ddf6fe37 | 17617 | @item -fvtv-counts |
d77de738 ML |
17618 | This is a debugging flag. When used in conjunction with |
17619 | @option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this | |
17620 | causes the compiler to keep track of the total number of virtual calls | |
17621 | it encounters and the number of verifications it inserts. It also | |
17622 | counts the number of calls to certain run-time library functions | |
17623 | that it inserts and logs this information for each compilation unit. | |
17624 | The compiler writes this information to a file named | |
17625 | @file{vtv_count_data.log} in the directory named by the environment | |
17626 | variable @env{VTV_LOGS_DIR} if that is defined or the current working | |
17627 | directory otherwise. It also counts the size of the vtable pointer sets | |
17628 | for each class, and writes this information to @file{vtv_class_set_sizes.log} | |
17629 | in the same directory. | |
17630 | ||
17631 | Note: This feature @emph{appends} data to the log files. To get fresh log | |
17632 | files, be sure to delete any existing ones. | |
17633 | ||
d77de738 | 17634 | @opindex finstrument-functions |
ddf6fe37 | 17635 | @item -finstrument-functions |
d77de738 ML |
17636 | Generate instrumentation calls for entry and exit to functions. Just |
17637 | after function entry and just before function exit, the following | |
17638 | profiling functions are called with the address of the current | |
17639 | function and its call site. (On some platforms, | |
17640 | @code{__builtin_return_address} does not work beyond the current | |
17641 | function, so the call site information may not be available to the | |
17642 | profiling functions otherwise.) | |
17643 | ||
17644 | @smallexample | |
17645 | void __cyg_profile_func_enter (void *this_fn, | |
17646 | void *call_site); | |
17647 | void __cyg_profile_func_exit (void *this_fn, | |
17648 | void *call_site); | |
17649 | @end smallexample | |
17650 | ||
17651 | The first argument is the address of the start of the current function, | |
17652 | which may be looked up exactly in the symbol table. | |
17653 | ||
17654 | This instrumentation is also done for functions expanded inline in other | |
17655 | functions. The profiling calls indicate where, conceptually, the | |
17656 | inline function is entered and exited. This means that addressable | |
17657 | versions of such functions must be available. If all your uses of a | |
17658 | function are expanded inline, this may mean an additional expansion of | |
17659 | code size. If you use @code{extern inline} in your C code, an | |
17660 | addressable version of such functions must be provided. (This is | |
17661 | normally the case anyway, but if you get lucky and the optimizer always | |
17662 | expands the functions inline, you might have gotten away without | |
17663 | providing static copies.) | |
17664 | ||
17665 | A function may be given the attribute @code{no_instrument_function}, in | |
17666 | which case this instrumentation is not done. This can be used, for | |
17667 | example, for the profiling functions listed above, high-priority | |
17668 | interrupt routines, and any functions from which the profiling functions | |
17669 | cannot safely be called (perhaps signal handlers, if the profiling | |
17670 | routines generate output or allocate memory). | |
17671 | @xref{Common Function Attributes}. | |
17672 | ||
9c19597c | 17673 | @opindex finstrument-functions-once |
ddf6fe37 | 17674 | @item -finstrument-functions-once |
d77de738 ML |
17675 | This is similar to @option{-finstrument-functions}, but the profiling |
17676 | functions are called only once per instrumented function, i.e. the first | |
17677 | profiling function is called after the first entry into the instrumented | |
17678 | function and the second profiling function is called before the exit | |
17679 | corresponding to this first entry. | |
17680 | ||
17681 | The definition of @code{once} for the purpose of this option is a little | |
17682 | vague because the implementation is not protected against data races. | |
17683 | As a result, the implementation only guarantees that the profiling | |
17684 | functions are called at @emph{least} once per process and at @emph{most} | |
17685 | once per thread, but the calls are always paired, that is to say, if a | |
17686 | thread calls the first function, then it will call the second function, | |
17687 | unless it never reaches the exit of the instrumented function. | |
17688 | ||
d77de738 | 17689 | @opindex finstrument-functions-exclude-file-list |
ddf6fe37 | 17690 | @item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{} |
d77de738 ML |
17691 | |
17692 | Set the list of functions that are excluded from instrumentation (see | |
17693 | the description of @option{-finstrument-functions}). If the file that | |
17694 | contains a function definition matches with one of @var{file}, then | |
17695 | that function is not instrumented. The match is done on substrings: | |
17696 | if the @var{file} parameter is a substring of the file name, it is | |
17697 | considered to be a match. | |
17698 | ||
17699 | For example: | |
17700 | ||
17701 | @smallexample | |
17702 | -finstrument-functions-exclude-file-list=/bits/stl,include/sys | |
17703 | @end smallexample | |
17704 | ||
17705 | @noindent | |
17706 | excludes any inline function defined in files whose pathnames | |
17707 | contain @file{/bits/stl} or @file{include/sys}. | |
17708 | ||
17709 | If, for some reason, you want to include letter @samp{,} in one of | |
17710 | @var{sym}, write @samp{\,}. For example, | |
17711 | @option{-finstrument-functions-exclude-file-list='\,\,tmp'} | |
17712 | (note the single quote surrounding the option). | |
17713 | ||
d77de738 | 17714 | @opindex finstrument-functions-exclude-function-list |
ddf6fe37 | 17715 | @item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} |
d77de738 ML |
17716 | |
17717 | This is similar to @option{-finstrument-functions-exclude-file-list}, | |
17718 | but this option sets the list of function names to be excluded from | |
17719 | instrumentation. The function name to be matched is its user-visible | |
17720 | name, such as @code{vector<int> blah(const vector<int> &)}, not the | |
17721 | internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The | |
17722 | match is done on substrings: if the @var{sym} parameter is a substring | |
17723 | of the function name, it is considered to be a match. For C99 and C++ | |
17724 | extended identifiers, the function name must be given in UTF-8, not | |
17725 | using universal character names. | |
17726 | ||
d77de738 | 17727 | @opindex fpatchable-function-entry |
ddf6fe37 | 17728 | @item -fpatchable-function-entry=@var{N}[,@var{M}] |
d77de738 ML |
17729 | Generate @var{N} NOPs right at the beginning |
17730 | of each function, with the function entry point before the @var{M}th NOP. | |
17731 | If @var{M} is omitted, it defaults to @code{0} so the | |
17732 | function entry points to the address just at the first NOP. | |
17733 | The NOP instructions reserve extra space which can be used to patch in | |
17734 | any desired instrumentation at run time, provided that the code segment | |
17735 | is writable. The amount of space is controllable indirectly via | |
17736 | the number of NOPs; the NOP instruction used corresponds to the instruction | |
17737 | emitted by the internal GCC back-end interface @code{gen_nop}. This behavior | |
17738 | is target-specific and may also depend on the architecture variant and/or | |
17739 | other compilation options. | |
17740 | ||
17741 | For run-time identification, the starting addresses of these areas, | |
17742 | which correspond to their respective function entries minus @var{M}, | |
17743 | are additionally collected in the @code{__patchable_function_entries} | |
17744 | section of the resulting binary. | |
17745 | ||
17746 | Note that the value of @code{__attribute__ ((patchable_function_entry | |
17747 | (N,M)))} takes precedence over command-line option | |
17748 | @option{-fpatchable-function-entry=N,M}. This can be used to increase | |
17749 | the area size or to remove it completely on a single function. | |
17750 | If @code{N=0}, no pad location is recorded. | |
17751 | ||
17752 | The NOP instructions are inserted at---and maybe before, depending on | |
17753 | @var{M}---the function entry address, even before the prologue. On | |
17754 | PowerPC with the ELFv2 ABI, for a function with dual entry points, | |
17755 | the local entry point is this function entry address. | |
17756 | ||
17757 | The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the | |
17758 | ELFv2 ABI, for a function with dual entry points, the supported values | |
17759 | for @var{M} are 0, 2, 6 and 14. | |
17760 | @end table | |
17761 | ||
17762 | ||
17763 | @node Preprocessor Options | |
17764 | @section Options Controlling the Preprocessor | |
17765 | @cindex preprocessor options | |
17766 | @cindex options, preprocessor | |
17767 | ||
17768 | These options control the C preprocessor, which is run on each C source | |
17769 | file before actual compilation. | |
17770 | ||
17771 | If you use the @option{-E} option, nothing is done except preprocessing. | |
17772 | Some of these options make sense only together with @option{-E} because | |
17773 | they cause the preprocessor output to be unsuitable for actual | |
17774 | compilation. | |
17775 | ||
17776 | In addition to the options listed here, there are a number of options | |
17777 | to control search paths for include files documented in | |
17778 | @ref{Directory Options}. | |
17779 | Options to control preprocessor diagnostics are listed in | |
17780 | @ref{Warning Options}. | |
17781 | ||
17782 | @table @gcctabopt | |
17783 | @include cppopts.texi | |
17784 | ||
d77de738 | 17785 | @opindex Wp |
ddf6fe37 | 17786 | @item -Wp,@var{option} |
d77de738 ML |
17787 | You can use @option{-Wp,@var{option}} to bypass the compiler driver |
17788 | and pass @var{option} directly through to the preprocessor. If | |
17789 | @var{option} contains commas, it is split into multiple options at the | |
17790 | commas. However, many options are modified, translated or interpreted | |
17791 | by the compiler driver before being passed to the preprocessor, and | |
17792 | @option{-Wp} forcibly bypasses this phase. The preprocessor's direct | |
17793 | interface is undocumented and subject to change, so whenever possible | |
17794 | you should avoid using @option{-Wp} and let the driver handle the | |
17795 | options instead. | |
17796 | ||
d77de738 | 17797 | @opindex Xpreprocessor |
ddf6fe37 | 17798 | @item -Xpreprocessor @var{option} |
d77de738 ML |
17799 | Pass @var{option} as an option to the preprocessor. You can use this to |
17800 | supply system-specific preprocessor options that GCC does not | |
17801 | recognize. | |
17802 | ||
17803 | If you want to pass an option that takes an argument, you must use | |
17804 | @option{-Xpreprocessor} twice, once for the option and once for the argument. | |
17805 | ||
d77de738 | 17806 | @opindex no-integrated-cpp |
ddf6fe37 | 17807 | @item -no-integrated-cpp |
d77de738 ML |
17808 | Perform preprocessing as a separate pass before compilation. |
17809 | By default, GCC performs preprocessing as an integrated part of | |
17810 | input tokenization and parsing. | |
17811 | If this option is provided, the appropriate language front end | |
17812 | (@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++, | |
17813 | and Objective-C, respectively) is instead invoked twice, | |
17814 | once for preprocessing only and once for actual compilation | |
17815 | of the preprocessed input. | |
17816 | This option may be useful in conjunction with the @option{-B} or | |
17817 | @option{-wrapper} options to specify an alternate preprocessor or | |
17818 | perform additional processing of the program source between | |
17819 | normal preprocessing and compilation. | |
17820 | ||
d77de738 | 17821 | @opindex flarge-source-files |
ddf6fe37 | 17822 | @item -flarge-source-files |
d77de738 ML |
17823 | Adjust GCC to expect large source files, at the expense of slower |
17824 | compilation and higher memory usage. | |
17825 | ||
17826 | Specifically, GCC normally tracks both column numbers and line numbers | |
17827 | within source files and it normally prints both of these numbers in | |
17828 | diagnostics. However, once it has processed a certain number of source | |
17829 | lines, it stops tracking column numbers and only tracks line numbers. | |
17830 | This means that diagnostics for later lines do not include column numbers. | |
17831 | It also means that options like @option{-Wmisleading-indentation} cease to work | |
17832 | at that point, although the compiler prints a note if this happens. | |
17833 | Passing @option{-flarge-source-files} significantly increases the number | |
17834 | of source lines that GCC can process before it stops tracking columns. | |
17835 | ||
17836 | @end table | |
17837 | ||
17838 | @node Assembler Options | |
17839 | @section Passing Options to the Assembler | |
17840 | ||
17841 | @c prevent bad page break with this line | |
17842 | You can pass options to the assembler. | |
17843 | ||
17844 | @table @gcctabopt | |
d77de738 | 17845 | @opindex Wa |
ddf6fe37 | 17846 | @item -Wa,@var{option} |
d77de738 ML |
17847 | Pass @var{option} as an option to the assembler. If @var{option} |
17848 | contains commas, it is split into multiple options at the commas. | |
17849 | ||
d77de738 | 17850 | @opindex Xassembler |
ddf6fe37 | 17851 | @item -Xassembler @var{option} |
d77de738 ML |
17852 | Pass @var{option} as an option to the assembler. You can use this to |
17853 | supply system-specific assembler options that GCC does not | |
17854 | recognize. | |
17855 | ||
17856 | If you want to pass an option that takes an argument, you must use | |
17857 | @option{-Xassembler} twice, once for the option and once for the argument. | |
17858 | ||
17859 | @end table | |
17860 | ||
17861 | @node Link Options | |
17862 | @section Options for Linking | |
17863 | @cindex link options | |
17864 | @cindex options, linking | |
17865 | ||
17866 | These options come into play when the compiler links object files into | |
17867 | an executable output file. They are meaningless if the compiler is | |
17868 | not doing a link step. | |
17869 | ||
17870 | @table @gcctabopt | |
17871 | @cindex file names | |
17872 | @item @var{object-file-name} | |
17873 | A file name that does not end in a special recognized suffix is | |
17874 | considered to name an object file or library. (Object files are | |
17875 | distinguished from libraries by the linker according to the file | |
17876 | contents.) If linking is done, these object files are used as input | |
17877 | to the linker. | |
17878 | ||
d77de738 ML |
17879 | @opindex c |
17880 | @opindex S | |
17881 | @opindex E | |
ddf6fe37 AA |
17882 | @item -c |
17883 | @itemx -S | |
17884 | @itemx -E | |
d77de738 ML |
17885 | If any of these options is used, then the linker is not run, and |
17886 | object file names should not be used as arguments. @xref{Overall | |
17887 | Options}. | |
17888 | ||
d77de738 | 17889 | @opindex flinker-output |
ddf6fe37 | 17890 | @item -flinker-output=@var{type} |
d77de738 ML |
17891 | This option controls code generation of the link-time optimizer. By |
17892 | default the linker output is automatically determined by the linker | |
17893 | plugin. For debugging the compiler and if incremental linking with a | |
17894 | non-LTO object file is desired, it may be useful to control the type | |
17895 | manually. | |
17896 | ||
17897 | If @var{type} is @samp{exec}, code generation produces a static | |
17898 | binary. In this case @option{-fpic} and @option{-fpie} are both | |
17899 | disabled. | |
17900 | ||
17901 | If @var{type} is @samp{dyn}, code generation produces a shared | |
17902 | library. In this case @option{-fpic} or @option{-fPIC} is preserved, | |
17903 | but not enabled automatically. This allows to build shared libraries | |
17904 | without position-independent code on architectures where this is | |
17905 | possible, i.e.@: on x86. | |
17906 | ||
17907 | If @var{type} is @samp{pie}, code generation produces an @option{-fpie} | |
17908 | executable. This results in similar optimizations as @samp{exec} | |
17909 | except that @option{-fpie} is not disabled if specified at compilation | |
17910 | time. | |
17911 | ||
17912 | If @var{type} is @samp{rel}, the compiler assumes that incremental linking is | |
17913 | done. The sections containing intermediate code for link-time optimization are | |
17914 | merged, pre-optimized, and output to the resulting object file. In addition, if | |
17915 | @option{-ffat-lto-objects} is specified, binary code is produced for future | |
17916 | non-LTO linking. The object file produced by incremental linking is smaller | |
17917 | than a static library produced from the same object files. At link time the | |
17918 | result of incremental linking also loads faster than a static | |
17919 | library assuming that the majority of objects in the library are used. | |
17920 | ||
17921 | Finally @samp{nolto-rel} configures the compiler for incremental linking where | |
17922 | code generation is forced, a final binary is produced, and the intermediate | |
17923 | code for later link-time optimization is stripped. When multiple object files | |
17924 | are linked together the resulting code is better optimized than with | |
17925 | link-time optimizations disabled (for example, cross-module inlining | |
17926 | happens), but most of benefits of whole program optimizations are lost. | |
17927 | ||
17928 | During the incremental link (by @option{-r}) the linker plugin defaults to | |
17929 | @option{rel}. With current interfaces to GNU Binutils it is however not | |
17930 | possible to incrementally link LTO objects and non-LTO objects into a single | |
17931 | mixed object file. If any of object files in incremental link cannot | |
17932 | be used for link-time optimization, the linker plugin issues a warning and | |
17933 | uses @samp{nolto-rel}. To maintain whole program optimization, it is | |
17934 | recommended to link such objects into static library instead. Alternatively it | |
17935 | is possible to use H.J. Lu's binutils with support for mixed objects. | |
17936 | ||
d77de738 | 17937 | @opindex fuse-ld=bfd |
ddf6fe37 | 17938 | @item -fuse-ld=bfd |
d77de738 ML |
17939 | Use the @command{bfd} linker instead of the default linker. |
17940 | ||
d77de738 | 17941 | @opindex fuse-ld=gold |
ddf6fe37 | 17942 | @item -fuse-ld=gold |
d77de738 ML |
17943 | Use the @command{gold} linker instead of the default linker. |
17944 | ||
d77de738 | 17945 | @opindex fuse-ld=lld |
ddf6fe37 | 17946 | @item -fuse-ld=lld |
d77de738 ML |
17947 | Use the LLVM @command{lld} linker instead of the default linker. |
17948 | ||
d77de738 | 17949 | @opindex fuse-ld=mold |
ddf6fe37 | 17950 | @item -fuse-ld=mold |
d77de738 ML |
17951 | Use the Modern Linker (@command{mold}) instead of the default linker. |
17952 | ||
17953 | @cindex Libraries | |
ddf6fe37 | 17954 | @opindex l |
d77de738 ML |
17955 | @item -l@var{library} |
17956 | @itemx -l @var{library} | |
d77de738 ML |
17957 | Search the library named @var{library} when linking. (The second |
17958 | alternative with the library as a separate argument is only for | |
17959 | POSIX compliance and is not recommended.) | |
17960 | ||
17961 | The @option{-l} option is passed directly to the linker by GCC. Refer | |
17962 | to your linker documentation for exact details. The general | |
17963 | description below applies to the GNU linker. | |
17964 | ||
17965 | The linker searches a standard list of directories for the library. | |
17966 | The directories searched include several standard system directories | |
17967 | plus any that you specify with @option{-L}. | |
17968 | ||
17969 | Static libraries are archives of object files, and have file names | |
17970 | like @file{lib@var{library}.a}. Some targets also support shared | |
17971 | libraries, which typically have names like @file{lib@var{library}.so}. | |
17972 | If both static and shared libraries are found, the linker gives | |
17973 | preference to linking with the shared library unless the | |
17974 | @option{-static} option is used. | |
17975 | ||
17976 | It makes a difference where in the command you write this option; the | |
17977 | linker searches and processes libraries and object files in the order they | |
17978 | are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z} | |
17979 | after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers | |
17980 | to functions in @samp{z}, those functions may not be loaded. | |
17981 | ||
d77de738 | 17982 | @opindex lobjc |
ddf6fe37 | 17983 | @item -lobjc |
d77de738 ML |
17984 | You need this special case of the @option{-l} option in order to |
17985 | link an Objective-C or Objective-C++ program. | |
17986 | ||
d77de738 | 17987 | @opindex nostartfiles |
ddf6fe37 | 17988 | @item -nostartfiles |
d77de738 ML |
17989 | Do not use the standard system startup files when linking. |
17990 | The standard system libraries are used normally, unless @option{-nostdlib}, | |
17991 | @option{-nolibc}, or @option{-nodefaultlibs} is used. | |
17992 | ||
d77de738 | 17993 | @opindex nodefaultlibs |
ddf6fe37 | 17994 | @item -nodefaultlibs |
d77de738 ML |
17995 | Do not use the standard system libraries when linking. |
17996 | Only the libraries you specify are passed to the linker, and options | |
17997 | specifying linkage of the system libraries, such as @option{-static-libgcc} | |
17998 | or @option{-shared-libgcc}, are ignored. | |
17999 | The standard startup files are used normally, unless @option{-nostartfiles} | |
18000 | is used. | |
18001 | ||
18002 | The compiler may generate calls to @code{memcmp}, | |
18003 | @code{memset}, @code{memcpy} and @code{memmove}. | |
18004 | These entries are usually resolved by entries in | |
18005 | libc. These entry points should be supplied through some other | |
18006 | mechanism when this option is specified. | |
18007 | ||
d77de738 | 18008 | @opindex nolibc |
ddf6fe37 | 18009 | @item -nolibc |
d77de738 ML |
18010 | Do not use the C library or system libraries tightly coupled with it when |
18011 | linking. Still link with the startup files, @file{libgcc} or toolchain | |
18012 | provided language support libraries such as @file{libgnat}, @file{libgfortran} | |
18013 | or @file{libstdc++} unless options preventing their inclusion are used as | |
18014 | well. This typically removes @option{-lc} from the link command line, as well | |
18015 | as system libraries that normally go with it and become meaningless when | |
18016 | absence of a C library is assumed, for example @option{-lpthread} or | |
18017 | @option{-lm} in some configurations. This is intended for bare-board | |
18018 | targets when there is indeed no C library available. | |
18019 | ||
d77de738 | 18020 | @opindex nostdlib |
ddf6fe37 | 18021 | @item -nostdlib |
d77de738 ML |
18022 | Do not use the standard system startup files or libraries when linking. |
18023 | No startup files and only the libraries you specify are passed to | |
18024 | the linker, and options specifying linkage of the system libraries, such as | |
18025 | @option{-static-libgcc} or @option{-shared-libgcc}, are ignored. | |
18026 | ||
18027 | The compiler may generate calls to @code{memcmp}, @code{memset}, | |
18028 | @code{memcpy} and @code{memmove}. | |
18029 | These entries are usually resolved by entries in | |
18030 | libc. These entry points should be supplied through some other | |
18031 | mechanism when this option is specified. | |
18032 | ||
18033 | @cindex @option{-lgcc}, use with @option{-nostdlib} | |
18034 | @cindex @option{-nostdlib} and unresolved references | |
18035 | @cindex unresolved references and @option{-nostdlib} | |
18036 | @cindex @option{-lgcc}, use with @option{-nodefaultlibs} | |
18037 | @cindex @option{-nodefaultlibs} and unresolved references | |
18038 | @cindex unresolved references and @option{-nodefaultlibs} | |
18039 | One of the standard libraries bypassed by @option{-nostdlib} and | |
18040 | @option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines | |
18041 | which GCC uses to overcome shortcomings of particular machines, or special | |
18042 | needs for some languages. | |
18043 | (@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler | |
18044 | Collection (GCC) Internals}, | |
18045 | for more discussion of @file{libgcc.a}.) | |
18046 | In most cases, you need @file{libgcc.a} even when you want to avoid | |
18047 | other standard libraries. In other words, when you specify @option{-nostdlib} | |
18048 | or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well. | |
18049 | This ensures that you have no unresolved references to internal GCC | |
18050 | library subroutines. | |
18051 | (An example of such an internal subroutine is @code{__main}, used to ensure C++ | |
18052 | constructors are called; @pxref{Collect2,,@code{collect2}, gccint, | |
18053 | GNU Compiler Collection (GCC) Internals}.) | |
18054 | ||
d77de738 | 18055 | @opindex nostdlib++ |
ddf6fe37 | 18056 | @item -nostdlib++ |
d77de738 ML |
18057 | Do not implicitly link with standard C++ libraries. |
18058 | ||
d77de738 ML |
18059 | @opindex e |
18060 | @opindex entry | |
ddf6fe37 AA |
18061 | @item -e @var{entry} |
18062 | @itemx --entry=@var{entry} | |
d77de738 ML |
18063 | |
18064 | Specify that the program entry point is @var{entry}. The argument is | |
18065 | interpreted by the linker; the GNU linker accepts either a symbol name | |
18066 | or an address. | |
18067 | ||
d77de738 | 18068 | @opindex pie |
ddf6fe37 | 18069 | @item -pie |
d77de738 ML |
18070 | Produce a dynamically linked position independent executable on targets |
18071 | that support it. For predictable results, you must also specify the same | |
18072 | set of options used for compilation (@option{-fpie}, @option{-fPIE}, | |
18073 | or model suboptions) when you specify this linker option. | |
18074 | ||
d77de738 | 18075 | @opindex no-pie |
ddf6fe37 | 18076 | @item -no-pie |
d77de738 ML |
18077 | Don't produce a dynamically linked position independent executable. |
18078 | ||
d77de738 | 18079 | @opindex static-pie |
ddf6fe37 | 18080 | @item -static-pie |
d77de738 ML |
18081 | Produce a static position independent executable on targets that support |
18082 | it. A static position independent executable is similar to a static | |
18083 | executable, but can be loaded at any address without a dynamic linker. | |
18084 | For predictable results, you must also specify the same set of options | |
18085 | used for compilation (@option{-fpie}, @option{-fPIE}, or model | |
18086 | suboptions) when you specify this linker option. | |
18087 | ||
d77de738 | 18088 | @opindex pthread |
ddf6fe37 | 18089 | @item -pthread |
d77de738 ML |
18090 | Link with the POSIX threads library. This option is supported on |
18091 | GNU/Linux targets, most other Unix derivatives, and also on | |
18092 | x86 Cygwin and MinGW targets. On some targets this option also sets | |
18093 | flags for the preprocessor, so it should be used consistently for both | |
18094 | compilation and linking. | |
18095 | ||
d77de738 | 18096 | @opindex r |
ddf6fe37 | 18097 | @item -r |
d77de738 ML |
18098 | Produce a relocatable object as output. This is also known as partial |
18099 | linking. | |
18100 | ||
d77de738 | 18101 | @opindex rdynamic |
ddf6fe37 | 18102 | @item -rdynamic |
d77de738 ML |
18103 | Pass the flag @option{-export-dynamic} to the ELF linker, on targets |
18104 | that support it. This instructs the linker to add all symbols, not | |
18105 | only used ones, to the dynamic symbol table. This option is needed | |
18106 | for some uses of @code{dlopen} or to allow obtaining backtraces | |
18107 | from within a program. | |
18108 | ||
d77de738 | 18109 | @opindex s |
ddf6fe37 | 18110 | @item -s |
d77de738 ML |
18111 | Remove all symbol table and relocation information from the executable. |
18112 | ||
d77de738 | 18113 | @opindex static |
ddf6fe37 | 18114 | @item -static |
d77de738 ML |
18115 | On systems that support dynamic linking, this overrides @option{-pie} |
18116 | and prevents linking with the shared libraries. On other systems, this | |
18117 | option has no effect. | |
18118 | ||
d77de738 | 18119 | @opindex shared |
ddf6fe37 | 18120 | @item -shared |
d77de738 ML |
18121 | Produce a shared object which can then be linked with other objects to |
18122 | form an executable. Not all systems support this option. For predictable | |
18123 | results, you must also specify the same set of options used for compilation | |
18124 | (@option{-fpic}, @option{-fPIC}, or model suboptions) when | |
18125 | you specify this linker option.@footnote{On some systems, @samp{gcc -shared} | |
18126 | needs to build supplementary stub code for constructors to work. On | |
18127 | multi-libbed systems, @samp{gcc -shared} must select the correct support | |
18128 | libraries to link against. Failing to supply the correct flags may lead | |
18129 | to subtle defects. Supplying them in cases where they are not necessary | |
b799acef RB |
18130 | is innocuous. @option{-shared} suppresses the addition of startup code |
18131 | to alter the floating-point environment as done with @option{-ffast-math}, | |
18132 | @option{-Ofast} or @option{-funsafe-math-optimizations} on some targets.} | |
d77de738 | 18133 | |
d77de738 ML |
18134 | @opindex shared-libgcc |
18135 | @opindex static-libgcc | |
ddf6fe37 AA |
18136 | @item -shared-libgcc |
18137 | @itemx -static-libgcc | |
d77de738 ML |
18138 | On systems that provide @file{libgcc} as a shared library, these options |
18139 | force the use of either the shared or static version, respectively. | |
18140 | If no shared version of @file{libgcc} was built when the compiler was | |
18141 | configured, these options have no effect. | |
18142 | ||
18143 | There are several situations in which an application should use the | |
18144 | shared @file{libgcc} instead of the static version. The most common | |
18145 | of these is when the application wishes to throw and catch exceptions | |
18146 | across different shared libraries. In that case, each of the libraries | |
18147 | as well as the application itself should use the shared @file{libgcc}. | |
18148 | ||
18149 | Therefore, the G++ driver automatically adds @option{-shared-libgcc} | |
18150 | whenever you build a shared library or a main executable, because C++ | |
18151 | programs typically use exceptions, so this is the right thing to do. | |
18152 | ||
18153 | If, instead, you use the GCC driver to create shared libraries, you may | |
18154 | find that they are not always linked with the shared @file{libgcc}. | |
18155 | If GCC finds, at its configuration time, that you have a non-GNU linker | |
18156 | or a GNU linker that does not support option @option{--eh-frame-hdr}, | |
18157 | it links the shared version of @file{libgcc} into shared libraries | |
18158 | by default. Otherwise, it takes advantage of the linker and optimizes | |
18159 | away the linking with the shared version of @file{libgcc}, linking with | |
18160 | the static version of libgcc by default. This allows exceptions to | |
18161 | propagate through such shared libraries, without incurring relocation | |
18162 | costs at library load time. | |
18163 | ||
18164 | However, if a library or main executable is supposed to throw or catch | |
18165 | exceptions, you must link it using the G++ driver, or using the option | |
18166 | @option{-shared-libgcc}, such that it is linked with the shared | |
18167 | @file{libgcc}. | |
18168 | ||
d77de738 | 18169 | @opindex static-libasan |
ddf6fe37 | 18170 | @item -static-libasan |
d77de738 ML |
18171 | When the @option{-fsanitize=address} option is used to link a program, |
18172 | the GCC driver automatically links against @option{libasan}. If | |
18173 | @file{libasan} is available as a shared library, and the @option{-static} | |
18174 | option is not used, then this links against the shared version of | |
18175 | @file{libasan}. The @option{-static-libasan} option directs the GCC | |
18176 | driver to link @file{libasan} statically, without necessarily linking | |
18177 | other libraries statically. | |
18178 | ||
d77de738 | 18179 | @opindex static-libtsan |
ddf6fe37 | 18180 | @item -static-libtsan |
d77de738 ML |
18181 | When the @option{-fsanitize=thread} option is used to link a program, |
18182 | the GCC driver automatically links against @option{libtsan}. If | |
18183 | @file{libtsan} is available as a shared library, and the @option{-static} | |
18184 | option is not used, then this links against the shared version of | |
18185 | @file{libtsan}. The @option{-static-libtsan} option directs the GCC | |
18186 | driver to link @file{libtsan} statically, without necessarily linking | |
18187 | other libraries statically. | |
18188 | ||
d77de738 | 18189 | @opindex static-liblsan |
ddf6fe37 | 18190 | @item -static-liblsan |
d77de738 ML |
18191 | When the @option{-fsanitize=leak} option is used to link a program, |
18192 | the GCC driver automatically links against @option{liblsan}. If | |
18193 | @file{liblsan} is available as a shared library, and the @option{-static} | |
18194 | option is not used, then this links against the shared version of | |
18195 | @file{liblsan}. The @option{-static-liblsan} option directs the GCC | |
18196 | driver to link @file{liblsan} statically, without necessarily linking | |
18197 | other libraries statically. | |
18198 | ||
d77de738 | 18199 | @opindex static-libubsan |
ddf6fe37 | 18200 | @item -static-libubsan |
d77de738 ML |
18201 | When the @option{-fsanitize=undefined} option is used to link a program, |
18202 | the GCC driver automatically links against @option{libubsan}. If | |
18203 | @file{libubsan} is available as a shared library, and the @option{-static} | |
18204 | option is not used, then this links against the shared version of | |
18205 | @file{libubsan}. The @option{-static-libubsan} option directs the GCC | |
18206 | driver to link @file{libubsan} statically, without necessarily linking | |
18207 | other libraries statically. | |
18208 | ||
d77de738 | 18209 | @opindex static-libstdc++ |
ddf6fe37 | 18210 | @item -static-libstdc++ |
d77de738 ML |
18211 | When the @command{g++} program is used to link a C++ program, it |
18212 | normally automatically links against @option{libstdc++}. If | |
18213 | @file{libstdc++} is available as a shared library, and the | |
18214 | @option{-static} option is not used, then this links against the | |
18215 | shared version of @file{libstdc++}. That is normally fine. However, it | |
18216 | is sometimes useful to freeze the version of @file{libstdc++} used by | |
18217 | the program without going all the way to a fully static link. The | |
18218 | @option{-static-libstdc++} option directs the @command{g++} driver to | |
18219 | link @file{libstdc++} statically, without necessarily linking other | |
18220 | libraries statically. | |
18221 | ||
d77de738 | 18222 | @opindex symbolic |
ddf6fe37 | 18223 | @item -symbolic |
d77de738 ML |
18224 | Bind references to global symbols when building a shared object. Warn |
18225 | about any unresolved references (unless overridden by the link editor | |
18226 | option @option{-Xlinker -z -Xlinker defs}). Only a few systems support | |
18227 | this option. | |
18228 | ||
d77de738 ML |
18229 | @opindex T |
18230 | @cindex linker script | |
f33d7a88 | 18231 | @item -T @var{script} |
d77de738 ML |
18232 | Use @var{script} as the linker script. This option is supported by most |
18233 | systems using the GNU linker. On some targets, such as bare-board | |
18234 | targets without an operating system, the @option{-T} option may be required | |
18235 | when linking to avoid references to undefined symbols. | |
18236 | ||
d77de738 | 18237 | @opindex Xlinker |
ddf6fe37 | 18238 | @item -Xlinker @var{option} |
d77de738 ML |
18239 | Pass @var{option} as an option to the linker. You can use this to |
18240 | supply system-specific linker options that GCC does not recognize. | |
18241 | ||
18242 | If you want to pass an option that takes a separate argument, you must use | |
18243 | @option{-Xlinker} twice, once for the option and once for the argument. | |
18244 | For example, to pass @option{-assert definitions}, you must write | |
18245 | @option{-Xlinker -assert -Xlinker definitions}. It does not work to write | |
18246 | @option{-Xlinker "-assert definitions"}, because this passes the entire | |
18247 | string as a single argument, which is not what the linker expects. | |
18248 | ||
18249 | When using the GNU linker, it is usually more convenient to pass | |
18250 | arguments to linker options using the @option{@var{option}=@var{value}} | |
18251 | syntax than as separate arguments. For example, you can specify | |
18252 | @option{-Xlinker -Map=output.map} rather than | |
18253 | @option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support | |
18254 | this syntax for command-line options. | |
18255 | ||
d77de738 | 18256 | @opindex Wl |
ddf6fe37 | 18257 | @item -Wl,@var{option} |
d77de738 ML |
18258 | Pass @var{option} as an option to the linker. If @var{option} contains |
18259 | commas, it is split into multiple options at the commas. You can use this | |
18260 | syntax to pass an argument to the option. | |
18261 | For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the | |
18262 | linker. When using the GNU linker, you can also get the same effect with | |
18263 | @option{-Wl,-Map=output.map}. | |
18264 | ||
d77de738 | 18265 | @opindex u |
ddf6fe37 | 18266 | @item -u @var{symbol} |
d77de738 ML |
18267 | Pretend the symbol @var{symbol} is undefined, to force linking of |
18268 | library modules to define it. You can use @option{-u} multiple times with | |
18269 | different symbols to force loading of additional library modules. | |
18270 | ||
d77de738 | 18271 | @opindex z |
ddf6fe37 | 18272 | @item -z @var{keyword} |
d77de738 ML |
18273 | @option{-z} is passed directly on to the linker along with the keyword |
18274 | @var{keyword}. See the section in the documentation of your linker for | |
18275 | permitted values and their meanings. | |
18276 | @end table | |
18277 | ||
18278 | @node Directory Options | |
18279 | @section Options for Directory Search | |
18280 | @cindex directory options | |
18281 | @cindex options, directory search | |
18282 | @cindex search path | |
18283 | ||
18284 | These options specify directories to search for header files, for | |
18285 | libraries and for parts of the compiler: | |
18286 | ||
18287 | @table @gcctabopt | |
18288 | @include cppdiropts.texi | |
18289 | ||
d77de738 | 18290 | @opindex iplugindir= |
ddf6fe37 | 18291 | @item -iplugindir=@var{dir} |
d77de738 ML |
18292 | Set the directory to search for plugins that are passed |
18293 | by @option{-fplugin=@var{name}} instead of | |
18294 | @option{-fplugin=@var{path}/@var{name}.so}. This option is not meant | |
18295 | to be used by the user, but only passed by the driver. | |
18296 | ||
d77de738 | 18297 | @opindex L |
ddf6fe37 | 18298 | @item -L@var{dir} |
d77de738 ML |
18299 | Add directory @var{dir} to the list of directories to be searched |
18300 | for @option{-l}. | |
18301 | ||
d77de738 | 18302 | @opindex B |
ddf6fe37 | 18303 | @item -B@var{prefix} |
d77de738 ML |
18304 | This option specifies where to find the executables, libraries, |
18305 | include files, and data files of the compiler itself. | |
18306 | ||
18307 | The compiler driver program runs one or more of the subprograms | |
18308 | @command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries | |
18309 | @var{prefix} as a prefix for each program it tries to run, both with and | |
18310 | without @samp{@var{machine}/@var{version}/} for the corresponding target | |
18311 | machine and compiler version. | |
18312 | ||
18313 | For each subprogram to be run, the compiler driver first tries the | |
18314 | @option{-B} prefix, if any. If that name is not found, or if @option{-B} | |
18315 | is not specified, the driver tries two standard prefixes, | |
18316 | @file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of | |
18317 | those results in a file name that is found, the unmodified program | |
18318 | name is searched for using the directories specified in your | |
18319 | @env{PATH} environment variable. | |
18320 | ||
18321 | The compiler checks to see if the path provided by @option{-B} | |
18322 | refers to a directory, and if necessary it adds a directory | |
18323 | separator character at the end of the path. | |
18324 | ||
18325 | @option{-B} prefixes that effectively specify directory names also apply | |
18326 | to libraries in the linker, because the compiler translates these | |
18327 | options into @option{-L} options for the linker. They also apply to | |
18328 | include files in the preprocessor, because the compiler translates these | |
18329 | options into @option{-isystem} options for the preprocessor. In this case, | |
18330 | the compiler appends @samp{include} to the prefix. | |
18331 | ||
18332 | The runtime support file @file{libgcc.a} can also be searched for using | |
18333 | the @option{-B} prefix, if needed. If it is not found there, the two | |
18334 | standard prefixes above are tried, and that is all. The file is left | |
18335 | out of the link if it is not found by those means. | |
18336 | ||
18337 | Another way to specify a prefix much like the @option{-B} prefix is to use | |
18338 | the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment | |
18339 | Variables}. | |
18340 | ||
18341 | As a special kludge, if the path provided by @option{-B} is | |
18342 | @file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to | |
18343 | 9, then it is replaced by @file{[dir/]include}. This is to help | |
18344 | with boot-strapping the compiler. | |
18345 | ||
d77de738 | 18346 | @opindex no-canonical-prefixes |
ddf6fe37 | 18347 | @item -no-canonical-prefixes |
d77de738 ML |
18348 | Do not expand any symbolic links, resolve references to @samp{/../} |
18349 | or @samp{/./}, or make the path absolute when generating a relative | |
18350 | prefix. | |
18351 | ||
d77de738 | 18352 | @opindex sysroot |
ddf6fe37 | 18353 | @item --sysroot=@var{dir} |
d77de738 ML |
18354 | Use @var{dir} as the logical root directory for headers and libraries. |
18355 | For example, if the compiler normally searches for headers in | |
18356 | @file{/usr/include} and libraries in @file{/usr/lib}, it instead | |
18357 | searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}. | |
18358 | ||
18359 | If you use both this option and the @option{-isysroot} option, then | |
18360 | the @option{--sysroot} option applies to libraries, but the | |
18361 | @option{-isysroot} option applies to header files. | |
18362 | ||
18363 | The GNU linker (beginning with version 2.16) has the necessary support | |
18364 | for this option. If your linker does not support this option, the | |
18365 | header file aspect of @option{--sysroot} still works, but the | |
18366 | library aspect does not. | |
18367 | ||
d77de738 | 18368 | @opindex no-sysroot-suffix |
ddf6fe37 | 18369 | @item --no-sysroot-suffix |
d77de738 ML |
18370 | For some targets, a suffix is added to the root directory specified |
18371 | with @option{--sysroot}, depending on the other options used, so that | |
18372 | headers may for example be found in | |
18373 | @file{@var{dir}/@var{suffix}/usr/include} instead of | |
18374 | @file{@var{dir}/usr/include}. This option disables the addition of | |
18375 | such a suffix. | |
18376 | ||
18377 | @end table | |
18378 | ||
18379 | @node Code Gen Options | |
18380 | @section Options for Code Generation Conventions | |
18381 | @cindex code generation conventions | |
18382 | @cindex options, code generation | |
18383 | @cindex run-time options | |
18384 | ||
18385 | These machine-independent options control the interface conventions | |
18386 | used in code generation. | |
18387 | ||
18388 | Most of them have both positive and negative forms; the negative form | |
18389 | of @option{-ffoo} is @option{-fno-foo}. In the table below, only | |
18390 | one of the forms is listed---the one that is not the default. You | |
18391 | can figure out the other form by either removing @samp{no-} or adding | |
18392 | it. | |
18393 | ||
18394 | @table @gcctabopt | |
d77de738 | 18395 | @opindex fstack_reuse |
ddf6fe37 | 18396 | @item -fstack-reuse=@var{reuse-level} |
d77de738 ML |
18397 | This option controls stack space reuse for user declared local/auto variables |
18398 | and compiler generated temporaries. @var{reuse_level} can be @samp{all}, | |
18399 | @samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all | |
18400 | local variables and temporaries, @samp{named_vars} enables the reuse only for | |
18401 | user defined local variables with names, and @samp{none} disables stack reuse | |
18402 | completely. The default value is @samp{all}. The option is needed when the | |
18403 | program extends the lifetime of a scoped local variable or a compiler generated | |
18404 | temporary beyond the end point defined by the language. When a lifetime of | |
18405 | a variable ends, and if the variable lives in memory, the optimizing compiler | |
18406 | has the freedom to reuse its stack space with other temporaries or scoped | |
18407 | local variables whose live range does not overlap with it. Legacy code extending | |
18408 | local lifetime is likely to break with the stack reuse optimization. | |
18409 | ||
18410 | For example, | |
18411 | ||
18412 | @smallexample | |
18413 | int *p; | |
18414 | @{ | |
18415 | int local1; | |
18416 | ||
18417 | p = &local1; | |
18418 | local1 = 10; | |
18419 | .... | |
18420 | @} | |
18421 | @{ | |
18422 | int local2; | |
18423 | local2 = 20; | |
18424 | ... | |
18425 | @} | |
18426 | ||
18427 | if (*p == 10) // out of scope use of local1 | |
18428 | @{ | |
18429 | ||
18430 | @} | |
18431 | @end smallexample | |
18432 | ||
18433 | Another example: | |
18434 | @smallexample | |
18435 | ||
18436 | struct A | |
18437 | @{ | |
18438 | A(int k) : i(k), j(k) @{ @} | |
18439 | int i; | |
18440 | int j; | |
18441 | @}; | |
18442 | ||
18443 | A *ap; | |
18444 | ||
18445 | void foo(const A& ar) | |
18446 | @{ | |
18447 | ap = &ar; | |
18448 | @} | |
18449 | ||
18450 | void bar() | |
18451 | @{ | |
18452 | foo(A(10)); // temp object's lifetime ends when foo returns | |
18453 | ||
18454 | @{ | |
18455 | A a(20); | |
18456 | .... | |
18457 | @} | |
18458 | ap->i+= 10; // ap references out of scope temp whose space | |
18459 | // is reused with a. What is the value of ap->i? | |
18460 | @} | |
18461 | ||
18462 | @end smallexample | |
18463 | ||
18464 | The lifetime of a compiler generated temporary is well defined by the C++ | |
18465 | standard. When a lifetime of a temporary ends, and if the temporary lives | |
18466 | in memory, the optimizing compiler has the freedom to reuse its stack | |
18467 | space with other temporaries or scoped local variables whose live range | |
18468 | does not overlap with it. However some of the legacy code relies on | |
18469 | the behavior of older compilers in which temporaries' stack space is | |
18470 | not reused, the aggressive stack reuse can lead to runtime errors. This | |
18471 | option is used to control the temporary stack reuse optimization. | |
18472 | ||
d77de738 | 18473 | @opindex ftrapv |
ddf6fe37 | 18474 | @item -ftrapv |
d77de738 ML |
18475 | This option generates traps for signed overflow on addition, subtraction, |
18476 | multiplication operations. | |
18477 | The options @option{-ftrapv} and @option{-fwrapv} override each other, so using | |
18478 | @option{-ftrapv} @option{-fwrapv} on the command-line results in | |
18479 | @option{-fwrapv} being effective. Note that only active options override, so | |
18480 | using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line | |
18481 | results in @option{-ftrapv} being effective. | |
18482 | ||
d77de738 | 18483 | @opindex fwrapv |
ddf6fe37 | 18484 | @item -fwrapv |
d77de738 ML |
18485 | This option instructs the compiler to assume that signed arithmetic |
18486 | overflow of addition, subtraction and multiplication wraps around | |
18487 | using twos-complement representation. This flag enables some optimizations | |
18488 | and disables others. | |
18489 | The options @option{-ftrapv} and @option{-fwrapv} override each other, so using | |
18490 | @option{-ftrapv} @option{-fwrapv} on the command-line results in | |
18491 | @option{-fwrapv} being effective. Note that only active options override, so | |
18492 | using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line | |
18493 | results in @option{-ftrapv} being effective. | |
18494 | ||
d77de738 | 18495 | @opindex fwrapv-pointer |
ddf6fe37 | 18496 | @item -fwrapv-pointer |
d77de738 ML |
18497 | This option instructs the compiler to assume that pointer arithmetic |
18498 | overflow on addition and subtraction wraps around using twos-complement | |
18499 | representation. This flag disables some optimizations which assume | |
18500 | pointer overflow is invalid. | |
18501 | ||
d77de738 | 18502 | @opindex fstrict-overflow |
ddf6fe37 | 18503 | @item -fstrict-overflow |
d77de738 ML |
18504 | This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when |
18505 | negated implies @option{-fwrapv} @option{-fwrapv-pointer}. | |
18506 | ||
d77de738 | 18507 | @opindex fexceptions |
ddf6fe37 | 18508 | @item -fexceptions |
d77de738 ML |
18509 | Enable exception handling. Generates extra code needed to propagate |
18510 | exceptions. For some targets, this implies GCC generates frame | |
18511 | unwind information for all functions, which can produce significant data | |
18512 | size overhead, although it does not affect execution. If you do not | |
18513 | specify this option, GCC enables it by default for languages like | |
18514 | C++ that normally require exception handling, and disables it for | |
18515 | languages like C that do not normally require it. However, you may need | |
18516 | to enable this option when compiling C code that needs to interoperate | |
18517 | properly with exception handlers written in C++. You may also wish to | |
18518 | disable this option if you are compiling older C++ programs that don't | |
18519 | use exception handling. | |
18520 | ||
d77de738 | 18521 | @opindex fnon-call-exceptions |
ddf6fe37 | 18522 | @item -fnon-call-exceptions |
d77de738 ML |
18523 | Generate code that allows trapping instructions to throw exceptions. |
18524 | Note that this requires platform-specific runtime support that does | |
18525 | not exist everywhere. Moreover, it only allows @emph{trapping} | |
18526 | instructions to throw exceptions, i.e.@: memory references or floating-point | |
18527 | instructions. It does not allow exceptions to be thrown from | |
18528 | arbitrary signal handlers such as @code{SIGALRM}. This enables | |
18529 | @option{-fexceptions}. | |
18530 | ||
d77de738 | 18531 | @opindex fdelete-dead-exceptions |
ddf6fe37 | 18532 | @item -fdelete-dead-exceptions |
d77de738 ML |
18533 | Consider that instructions that may throw exceptions but don't otherwise |
18534 | contribute to the execution of the program can be optimized away. | |
18535 | This does not affect calls to functions except those with the | |
18536 | @code{pure} or @code{const} attributes. | |
18537 | This option is enabled by default for the Ada and C++ compilers, as permitted by | |
18538 | the language specifications. | |
18539 | Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels. | |
18540 | ||
d77de738 | 18541 | @opindex funwind-tables |
ddf6fe37 | 18542 | @item -funwind-tables |
d77de738 ML |
18543 | Similar to @option{-fexceptions}, except that it just generates any needed |
18544 | static data, but does not affect the generated code in any other way. | |
18545 | You normally do not need to enable this option; instead, a language processor | |
18546 | that needs this handling enables it on your behalf. | |
18547 | ||
d77de738 | 18548 | @opindex fasynchronous-unwind-tables |
ddf6fe37 | 18549 | @item -fasynchronous-unwind-tables |
d77de738 ML |
18550 | Generate unwind table in DWARF format, if supported by target machine. The |
18551 | table is exact at each instruction boundary, so it can be used for stack | |
18552 | unwinding from asynchronous events (such as debugger or garbage collector). | |
18553 | ||
d77de738 ML |
18554 | @opindex fno-gnu-unique |
18555 | @opindex fgnu-unique | |
ddf6fe37 | 18556 | @item -fno-gnu-unique |
d77de738 ML |
18557 | On systems with recent GNU assembler and C library, the C++ compiler |
18558 | uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions | |
18559 | of template static data members and static local variables in inline | |
18560 | functions are unique even in the presence of @code{RTLD_LOCAL}; this | |
18561 | is necessary to avoid problems with a library used by two different | |
18562 | @code{RTLD_LOCAL} plugins depending on a definition in one of them and | |
18563 | therefore disagreeing with the other one about the binding of the | |
18564 | symbol. But this causes @code{dlclose} to be ignored for affected | |
18565 | DSOs; if your program relies on reinitialization of a DSO via | |
18566 | @code{dlclose} and @code{dlopen}, you can use | |
18567 | @option{-fno-gnu-unique}. | |
18568 | ||
d77de738 | 18569 | @opindex fpcc-struct-return |
ddf6fe37 | 18570 | @item -fpcc-struct-return |
d77de738 ML |
18571 | Return ``short'' @code{struct} and @code{union} values in memory like |
18572 | longer ones, rather than in registers. This convention is less | |
18573 | efficient, but it has the advantage of allowing intercallability between | |
18574 | GCC-compiled files and files compiled with other compilers, particularly | |
18575 | the Portable C Compiler (pcc). | |
18576 | ||
18577 | The precise convention for returning structures in memory depends | |
18578 | on the target configuration macros. | |
18579 | ||
18580 | Short structures and unions are those whose size and alignment match | |
18581 | that of some integer type. | |
18582 | ||
18583 | @strong{Warning:} code compiled with the @option{-fpcc-struct-return} | |
18584 | switch is not binary compatible with code compiled with the | |
18585 | @option{-freg-struct-return} switch. | |
18586 | Use it to conform to a non-default application binary interface. | |
18587 | ||
d77de738 | 18588 | @opindex freg-struct-return |
ddf6fe37 | 18589 | @item -freg-struct-return |
d77de738 ML |
18590 | Return @code{struct} and @code{union} values in registers when possible. |
18591 | This is more efficient for small structures than | |
18592 | @option{-fpcc-struct-return}. | |
18593 | ||
18594 | If you specify neither @option{-fpcc-struct-return} nor | |
18595 | @option{-freg-struct-return}, GCC defaults to whichever convention is | |
18596 | standard for the target. If there is no standard convention, GCC | |
18597 | defaults to @option{-fpcc-struct-return}, except on targets where GCC is | |
18598 | the principal compiler. In those cases, we can choose the standard, and | |
18599 | we chose the more efficient register return alternative. | |
18600 | ||
18601 | @strong{Warning:} code compiled with the @option{-freg-struct-return} | |
18602 | switch is not binary compatible with code compiled with the | |
18603 | @option{-fpcc-struct-return} switch. | |
18604 | Use it to conform to a non-default application binary interface. | |
18605 | ||
d77de738 | 18606 | @opindex fshort-enums |
ddf6fe37 | 18607 | @item -fshort-enums |
d77de738 ML |
18608 | Allocate to an @code{enum} type only as many bytes as it needs for the |
18609 | declared range of possible values. Specifically, the @code{enum} type | |
18610 | is equivalent to the smallest integer type that has enough room. | |
d8a656d5 JW |
18611 | This option has no effect for an enumeration type with a fixed underlying |
18612 | type. | |
d77de738 ML |
18613 | |
18614 | @strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate | |
18615 | code that is not binary compatible with code generated without that switch. | |
18616 | Use it to conform to a non-default application binary interface. | |
18617 | ||
d77de738 | 18618 | @opindex fshort-wchar |
ddf6fe37 | 18619 | @item -fshort-wchar |
d77de738 ML |
18620 | Override the underlying type for @code{wchar_t} to be @code{short |
18621 | unsigned int} instead of the default for the target. This option is | |
18622 | useful for building programs to run under WINE@. | |
18623 | ||
18624 | @strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate | |
18625 | code that is not binary compatible with code generated without that switch. | |
18626 | Use it to conform to a non-default application binary interface. | |
18627 | ||
d77de738 ML |
18628 | @opindex fcommon |
18629 | @opindex fno-common | |
18630 | @cindex tentative definitions | |
f33d7a88 | 18631 | @item -fcommon |
d77de738 ML |
18632 | In C code, this option controls the placement of global variables |
18633 | defined without an initializer, known as @dfn{tentative definitions} | |
18634 | in the C standard. Tentative definitions are distinct from declarations | |
18635 | of a variable with the @code{extern} keyword, which do not allocate storage. | |
18636 | ||
18637 | The default is @option{-fno-common}, which specifies that the compiler places | |
18638 | uninitialized global variables in the BSS section of the object file. | |
18639 | This inhibits the merging of tentative definitions by the linker so you get a | |
18640 | multiple-definition error if the same variable is accidentally defined in more | |
18641 | than one compilation unit. | |
18642 | ||
18643 | The @option{-fcommon} places uninitialized global variables in a common block. | |
18644 | This allows the linker to resolve all tentative definitions of the same variable | |
18645 | in different compilation units to the same object, or to a non-tentative | |
18646 | definition. This behavior is inconsistent with C++, and on many targets implies | |
18647 | a speed and code size penalty on global variable references. It is mainly | |
18648 | useful to enable legacy code to link without errors. | |
18649 | ||
d77de738 ML |
18650 | @opindex fno-ident |
18651 | @opindex fident | |
ddf6fe37 | 18652 | @item -fno-ident |
d77de738 ML |
18653 | Ignore the @code{#ident} directive. |
18654 | ||
d77de738 | 18655 | @opindex finhibit-size-directive |
ddf6fe37 | 18656 | @item -finhibit-size-directive |
d77de738 ML |
18657 | Don't output a @code{.size} assembler directive, or anything else that |
18658 | would cause trouble if the function is split in the middle, and the | |
18659 | two halves are placed at locations far apart in memory. This option is | |
18660 | used when compiling @file{crtstuff.c}; you should not need to use it | |
18661 | for anything else. | |
18662 | ||
d77de738 | 18663 | @opindex fverbose-asm |
ddf6fe37 | 18664 | @item -fverbose-asm |
d77de738 ML |
18665 | Put extra commentary information in the generated assembly code to |
18666 | make it more readable. This option is generally only of use to those | |
18667 | who actually need to read the generated assembly code (perhaps while | |
18668 | debugging the compiler itself). | |
18669 | ||
18670 | @option{-fno-verbose-asm}, the default, causes the | |
18671 | extra information to be omitted and is useful when comparing two assembler | |
18672 | files. | |
18673 | ||
18674 | The added comments include: | |
18675 | ||
18676 | @itemize @bullet | |
18677 | ||
18678 | @item | |
18679 | information on the compiler version and command-line options, | |
18680 | ||
18681 | @item | |
18682 | the source code lines associated with the assembly instructions, | |
18683 | in the form FILENAME:LINENUMBER:CONTENT OF LINE, | |
18684 | ||
18685 | @item | |
18686 | hints on which high-level expressions correspond to | |
18687 | the various assembly instruction operands. | |
18688 | ||
18689 | @end itemize | |
18690 | ||
18691 | For example, given this C source file: | |
18692 | ||
18693 | @smallexample | |
18694 | int test (int n) | |
18695 | @{ | |
18696 | int i; | |
18697 | int total = 0; | |
18698 | ||
18699 | for (i = 0; i < n; i++) | |
18700 | total += i * i; | |
18701 | ||
18702 | return total; | |
18703 | @} | |
18704 | @end smallexample | |
18705 | ||
18706 | compiling to (x86_64) assembly via @option{-S} and emitting the result | |
18707 | direct to stdout via @option{-o} @option{-} | |
18708 | ||
18709 | @smallexample | |
18710 | gcc -S test.c -fverbose-asm -Os -o - | |
18711 | @end smallexample | |
18712 | ||
18713 | gives output similar to this: | |
18714 | ||
18715 | @smallexample | |
18716 | .file "test.c" | |
18717 | # GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu) | |
18718 | [...snip...] | |
18719 | # options passed: | |
18720 | [...snip...] | |
18721 | ||
18722 | .text | |
18723 | .globl test | |
18724 | .type test, @@function | |
18725 | test: | |
18726 | .LFB0: | |
18727 | .cfi_startproc | |
18728 | # test.c:4: int total = 0; | |
18729 | xorl %eax, %eax # <retval> | |
18730 | # test.c:6: for (i = 0; i < n; i++) | |
18731 | xorl %edx, %edx # i | |
18732 | .L2: | |
18733 | # test.c:6: for (i = 0; i < n; i++) | |
18734 | cmpl %edi, %edx # n, i | |
18735 | jge .L5 #, | |
18736 | # test.c:7: total += i * i; | |
18737 | movl %edx, %ecx # i, tmp92 | |
18738 | imull %edx, %ecx # i, tmp92 | |
18739 | # test.c:6: for (i = 0; i < n; i++) | |
18740 | incl %edx # i | |
18741 | # test.c:7: total += i * i; | |
18742 | addl %ecx, %eax # tmp92, <retval> | |
18743 | jmp .L2 # | |
18744 | .L5: | |
18745 | # test.c:10: @} | |
18746 | ret | |
18747 | .cfi_endproc | |
18748 | .LFE0: | |
18749 | .size test, .-test | |
18750 | .ident "GCC: (GNU) 7.0.0 20160809 (experimental)" | |
18751 | .section .note.GNU-stack,"",@@progbits | |
18752 | @end smallexample | |
18753 | ||
18754 | The comments are intended for humans rather than machines and hence the | |
18755 | precise format of the comments is subject to change. | |
18756 | ||
d77de738 | 18757 | @opindex frecord-gcc-switches |
ddf6fe37 | 18758 | @item -frecord-gcc-switches |
d77de738 ML |
18759 | This switch causes the command line used to invoke the |
18760 | compiler to be recorded into the object file that is being created. | |
18761 | This switch is only implemented on some targets and the exact format | |
18762 | of the recording is target and binary file format dependent, but it | |
18763 | usually takes the form of a section containing ASCII text. This | |
18764 | switch is related to the @option{-fverbose-asm} switch, but that | |
18765 | switch only records information in the assembler output file as | |
18766 | comments, so it never reaches the object file. | |
18767 | See also @option{-grecord-gcc-switches} for another | |
18768 | way of storing compiler options into the object file. | |
18769 | ||
d77de738 ML |
18770 | @opindex fpic |
18771 | @cindex global offset table | |
18772 | @cindex PIC | |
f33d7a88 | 18773 | @item -fpic |
d77de738 ML |
18774 | Generate position-independent code (PIC) suitable for use in a shared |
18775 | library, if supported for the target machine. Such code accesses all | |
18776 | constant addresses through a global offset table (GOT)@. The dynamic | |
18777 | loader resolves the GOT entries when the program starts (the dynamic | |
18778 | loader is not part of GCC; it is part of the operating system). If | |
18779 | the GOT size for the linked executable exceeds a machine-specific | |
18780 | maximum size, you get an error message from the linker indicating that | |
18781 | @option{-fpic} does not work; in that case, recompile with @option{-fPIC} | |
18782 | instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k | |
18783 | on the m68k and RS/6000. The x86 has no such limit.) | |
18784 | ||
18785 | Position-independent code requires special support, and therefore works | |
18786 | only on certain machines. For the x86, GCC supports PIC for System V | |
18787 | but not for the Sun 386i. Code generated for the IBM RS/6000 is always | |
18788 | position-independent. | |
18789 | ||
18790 | When this flag is set, the macros @code{__pic__} and @code{__PIC__} | |
18791 | are defined to 1. | |
18792 | ||
d77de738 | 18793 | @opindex fPIC |
ddf6fe37 | 18794 | @item -fPIC |
d77de738 ML |
18795 | If supported for the target machine, emit position-independent code, |
18796 | suitable for dynamic linking and avoiding any limit on the size of the | |
18797 | global offset table. This option makes a difference on AArch64, m68k, | |
18798 | PowerPC and SPARC@. | |
18799 | ||
18800 | Position-independent code requires special support, and therefore works | |
18801 | only on certain machines. | |
18802 | ||
18803 | When this flag is set, the macros @code{__pic__} and @code{__PIC__} | |
18804 | are defined to 2. | |
18805 | ||
d77de738 ML |
18806 | @opindex fpie |
18807 | @opindex fPIE | |
ddf6fe37 AA |
18808 | @item -fpie |
18809 | @itemx -fPIE | |
d77de738 ML |
18810 | These options are similar to @option{-fpic} and @option{-fPIC}, but the |
18811 | generated position-independent code can be only linked into executables. | |
18812 | Usually these options are used to compile code that will be linked using | |
18813 | the @option{-pie} GCC option. | |
18814 | ||
18815 | @option{-fpie} and @option{-fPIE} both define the macros | |
18816 | @code{__pie__} and @code{__PIE__}. The macros have the value 1 | |
18817 | for @option{-fpie} and 2 for @option{-fPIE}. | |
18818 | ||
d77de738 ML |
18819 | @opindex fno-plt |
18820 | @opindex fplt | |
ddf6fe37 | 18821 | @item -fno-plt |
d77de738 ML |
18822 | Do not use the PLT for external function calls in position-independent code. |
18823 | Instead, load the callee address at call sites from the GOT and branch to it. | |
18824 | This leads to more efficient code by eliminating PLT stubs and exposing | |
18825 | GOT loads to optimizations. On architectures such as 32-bit x86 where | |
18826 | PLT stubs expect the GOT pointer in a specific register, this gives more | |
18827 | register allocation freedom to the compiler. | |
18828 | Lazy binding requires use of the PLT; | |
18829 | with @option{-fno-plt} all external symbols are resolved at load time. | |
18830 | ||
18831 | Alternatively, the function attribute @code{noplt} can be used to avoid calls | |
18832 | through the PLT for specific external functions. | |
18833 | ||
18834 | In position-dependent code, a few targets also convert calls to | |
18835 | functions that are marked to not use the PLT to use the GOT instead. | |
18836 | ||
d77de738 ML |
18837 | @opindex fno-jump-tables |
18838 | @opindex fjump-tables | |
ddf6fe37 | 18839 | @item -fno-jump-tables |
d77de738 ML |
18840 | Do not use jump tables for switch statements even where it would be |
18841 | more efficient than other code generation strategies. This option is | |
18842 | of use in conjunction with @option{-fpic} or @option{-fPIC} for | |
18843 | building code that forms part of a dynamic linker and cannot | |
18844 | reference the address of a jump table. On some targets, jump tables | |
18845 | do not require a GOT and this option is not needed. | |
18846 | ||
d77de738 ML |
18847 | @opindex fno-bit-tests |
18848 | @opindex fbit-tests | |
ddf6fe37 | 18849 | @item -fno-bit-tests |
d77de738 ML |
18850 | Do not use bit tests for switch statements even where it would be |
18851 | more efficient than other code generation strategies. | |
18852 | ||
d77de738 | 18853 | @opindex ffixed |
ddf6fe37 | 18854 | @item -ffixed-@var{reg} |
d77de738 ML |
18855 | Treat the register named @var{reg} as a fixed register; generated code |
18856 | should never refer to it (except perhaps as a stack pointer, frame | |
18857 | pointer or in some other fixed role). | |
18858 | ||
18859 | @var{reg} must be the name of a register. The register names accepted | |
18860 | are machine-specific and are defined in the @code{REGISTER_NAMES} | |
18861 | macro in the machine description macro file. | |
18862 | ||
18863 | This flag does not have a negative form, because it specifies a | |
18864 | three-way choice. | |
18865 | ||
d77de738 | 18866 | @opindex fcall-used |
ddf6fe37 | 18867 | @item -fcall-used-@var{reg} |
d77de738 ML |
18868 | Treat the register named @var{reg} as an allocable register that is |
18869 | clobbered by function calls. It may be allocated for temporaries or | |
18870 | variables that do not live across a call. Functions compiled this way | |
18871 | do not save and restore the register @var{reg}. | |
18872 | ||
18873 | It is an error to use this flag with the frame pointer or stack pointer. | |
18874 | Use of this flag for other registers that have fixed pervasive roles in | |
18875 | the machine's execution model produces disastrous results. | |
18876 | ||
18877 | This flag does not have a negative form, because it specifies a | |
18878 | three-way choice. | |
18879 | ||
d77de738 | 18880 | @opindex fcall-saved |
ddf6fe37 | 18881 | @item -fcall-saved-@var{reg} |
d77de738 ML |
18882 | Treat the register named @var{reg} as an allocable register saved by |
18883 | functions. It may be allocated even for temporaries or variables that | |
18884 | live across a call. Functions compiled this way save and restore | |
18885 | the register @var{reg} if they use it. | |
18886 | ||
18887 | It is an error to use this flag with the frame pointer or stack pointer. | |
18888 | Use of this flag for other registers that have fixed pervasive roles in | |
18889 | the machine's execution model produces disastrous results. | |
18890 | ||
18891 | A different sort of disaster results from the use of this flag for | |
18892 | a register in which function values may be returned. | |
18893 | ||
18894 | This flag does not have a negative form, because it specifies a | |
18895 | three-way choice. | |
18896 | ||
d77de738 | 18897 | @opindex fpack-struct |
ddf6fe37 | 18898 | @item -fpack-struct[=@var{n}] |
d77de738 ML |
18899 | Without a value specified, pack all structure members together without |
18900 | holes. When a value is specified (which must be a small power of two), pack | |
18901 | structure members according to this value, representing the maximum | |
18902 | alignment (that is, objects with default alignment requirements larger than | |
18903 | this are output potentially unaligned at the next fitting location. | |
18904 | ||
18905 | @strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate | |
18906 | code that is not binary compatible with code generated without that switch. | |
18907 | Additionally, it makes the code suboptimal. | |
18908 | Use it to conform to a non-default application binary interface. | |
18909 | ||
d77de738 | 18910 | @opindex fleading-underscore |
ddf6fe37 | 18911 | @item -fleading-underscore |
d77de738 ML |
18912 | This option and its counterpart, @option{-fno-leading-underscore}, forcibly |
18913 | change the way C symbols are represented in the object file. One use | |
18914 | is to help link with legacy assembly code. | |
18915 | ||
18916 | @strong{Warning:} the @option{-fleading-underscore} switch causes GCC to | |
18917 | generate code that is not binary compatible with code generated without that | |
18918 | switch. Use it to conform to a non-default application binary interface. | |
18919 | Not all targets provide complete support for this switch. | |
18920 | ||
d77de738 | 18921 | @opindex ftls-model |
ddf6fe37 | 18922 | @item -ftls-model=@var{model} |
d77de738 ML |
18923 | Alter the thread-local storage model to be used (@pxref{Thread-Local}). |
18924 | The @var{model} argument should be one of @samp{global-dynamic}, | |
18925 | @samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}. | |
18926 | Note that the choice is subject to optimization: the compiler may use | |
18927 | a more efficient model for symbols not visible outside of the translation | |
18928 | unit, or if @option{-fpic} is not given on the command line. | |
18929 | ||
18930 | The default without @option{-fpic} is @samp{initial-exec}; with | |
18931 | @option{-fpic} the default is @samp{global-dynamic}. | |
18932 | ||
d77de738 | 18933 | @opindex ftrampolines |
ddf6fe37 | 18934 | @item -ftrampolines |
d77de738 ML |
18935 | For targets that normally need trampolines for nested functions, always |
18936 | generate them instead of using descriptors. Otherwise, for targets that | |
18937 | do not need them, like for example HP-PA or IA-64, do nothing. | |
18938 | ||
18939 | A trampoline is a small piece of code that is created at run time on the | |
18940 | stack when the address of a nested function is taken, and is used to call | |
18941 | the nested function indirectly. Therefore, it requires the stack to be | |
18942 | made executable in order for the program to work properly. | |
18943 | ||
18944 | @option{-fno-trampolines} is enabled by default on a language by language | |
18945 | basis to let the compiler avoid generating them, if it computes that this | |
18946 | is safe, and replace them with descriptors. Descriptors are made up of data | |
18947 | only, but the generated code must be prepared to deal with them. As of this | |
18948 | writing, @option{-fno-trampolines} is enabled by default only for Ada. | |
18949 | ||
18950 | Moreover, code compiled with @option{-ftrampolines} and code compiled with | |
18951 | @option{-fno-trampolines} are not binary compatible if nested functions are | |
18952 | present. This option must therefore be used on a program-wide basis and be | |
18953 | manipulated with extreme care. | |
18954 | ||
18955 | For languages other than Ada, the @code{-ftrampolines} and | |
18956 | @code{-fno-trampolines} options currently have no effect, and | |
18957 | trampolines are always generated on platforms that need them | |
18958 | for nested functions. | |
18959 | ||
d77de738 | 18960 | @opindex fvisibility |
ddf6fe37 | 18961 | @item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} |
d77de738 ML |
18962 | Set the default ELF image symbol visibility to the specified option---all |
18963 | symbols are marked with this unless overridden within the code. | |
18964 | Using this feature can very substantially improve linking and | |
18965 | load times of shared object libraries, produce more optimized | |
18966 | code, provide near-perfect API export and prevent symbol clashes. | |
18967 | It is @strong{strongly} recommended that you use this in any shared objects | |
18968 | you distribute. | |
18969 | ||
18970 | Despite the nomenclature, @samp{default} always means public; i.e., | |
18971 | available to be linked against from outside the shared object. | |
18972 | @samp{protected} and @samp{internal} are pretty useless in real-world | |
18973 | usage so the only other commonly used option is @samp{hidden}. | |
18974 | The default if @option{-fvisibility} isn't specified is | |
18975 | @samp{default}, i.e., make every symbol public. | |
18976 | ||
18977 | A good explanation of the benefits offered by ensuring ELF | |
18978 | symbols have the correct visibility is given by ``How To Write | |
18979 | Shared Libraries'' by Ulrich Drepper (which can be found at | |
18980 | @w{@uref{https://www.akkadia.org/drepper/}})---however a superior | |
18981 | solution made possible by this option to marking things hidden when | |
18982 | the default is public is to make the default hidden and mark things | |
18983 | public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden} | |
18984 | and @code{__attribute__ ((visibility("default")))} instead of | |
18985 | @code{__declspec(dllexport)} you get almost identical semantics with | |
18986 | identical syntax. This is a great boon to those working with | |
18987 | cross-platform projects. | |
18988 | ||
18989 | For those adding visibility support to existing code, you may find | |
18990 | @code{#pragma GCC visibility} of use. This works by you enclosing | |
18991 | the declarations you wish to set visibility for with (for example) | |
18992 | @code{#pragma GCC visibility push(hidden)} and | |
18993 | @code{#pragma GCC visibility pop}. | |
18994 | Bear in mind that symbol visibility should be viewed @strong{as | |
18995 | part of the API interface contract} and thus all new code should | |
18996 | always specify visibility when it is not the default; i.e., declarations | |
18997 | only for use within the local DSO should @strong{always} be marked explicitly | |
18998 | as hidden as so to avoid PLT indirection overheads---making this | |
18999 | abundantly clear also aids readability and self-documentation of the code. | |
19000 | Note that due to ISO C++ specification requirements, @code{operator new} and | |
19001 | @code{operator delete} must always be of default visibility. | |
19002 | ||
19003 | Be aware that headers from outside your project, in particular system | |
19004 | headers and headers from any other library you use, may not be | |
19005 | expecting to be compiled with visibility other than the default. You | |
19006 | may need to explicitly say @code{#pragma GCC visibility push(default)} | |
19007 | before including any such headers. | |
19008 | ||
19009 | @code{extern} declarations are not affected by @option{-fvisibility}, so | |
19010 | a lot of code can be recompiled with @option{-fvisibility=hidden} with | |
19011 | no modifications. However, this means that calls to @code{extern} | |
19012 | functions with no explicit visibility use the PLT, so it is more | |
19013 | effective to use @code{__attribute ((visibility))} and/or | |
19014 | @code{#pragma GCC visibility} to tell the compiler which @code{extern} | |
19015 | declarations should be treated as hidden. | |
19016 | ||
19017 | Note that @option{-fvisibility} does affect C++ vague linkage | |
19018 | entities. This means that, for instance, an exception class that is | |
19019 | be thrown between DSOs must be explicitly marked with default | |
19020 | visibility so that the @samp{type_info} nodes are unified between | |
19021 | the DSOs. | |
19022 | ||
19023 | An overview of these techniques, their benefits and how to use them | |
19024 | is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}. | |
19025 | ||
d77de738 | 19026 | @opindex fstrict-volatile-bitfields |
ddf6fe37 | 19027 | @item -fstrict-volatile-bitfields |
d77de738 ML |
19028 | This option should be used if accesses to volatile bit-fields (or other |
19029 | structure fields, although the compiler usually honors those types | |
19030 | anyway) should use a single access of the width of the | |
19031 | field's type, aligned to a natural alignment if possible. For | |
19032 | example, targets with memory-mapped peripheral registers might require | |
19033 | all such accesses to be 16 bits wide; with this flag you can | |
19034 | declare all peripheral bit-fields as @code{unsigned short} (assuming short | |
19035 | is 16 bits on these targets) to force GCC to use 16-bit accesses | |
19036 | instead of, perhaps, a more efficient 32-bit access. | |
19037 | ||
19038 | If this option is disabled, the compiler uses the most efficient | |
19039 | instruction. In the previous example, that might be a 32-bit load | |
19040 | instruction, even though that accesses bytes that do not contain | |
19041 | any portion of the bit-field, or memory-mapped registers unrelated to | |
19042 | the one being updated. | |
19043 | ||
19044 | In some cases, such as when the @code{packed} attribute is applied to a | |
19045 | structure field, it may not be possible to access the field with a single | |
19046 | read or write that is correctly aligned for the target machine. In this | |
19047 | case GCC falls back to generating multiple accesses rather than code that | |
19048 | will fault or truncate the result at run time. | |
19049 | ||
19050 | Note: Due to restrictions of the C/C++11 memory model, write accesses are | |
19051 | not allowed to touch non bit-field members. It is therefore recommended | |
19052 | to define all bits of the field's type as bit-field members. | |
19053 | ||
19054 | The default value of this option is determined by the application binary | |
19055 | interface for the target processor. | |
19056 | ||
d77de738 | 19057 | @opindex fsync-libcalls |
ddf6fe37 | 19058 | @item -fsync-libcalls |
d77de738 ML |
19059 | This option controls whether any out-of-line instance of the @code{__sync} |
19060 | family of functions may be used to implement the C++11 @code{__atomic} | |
19061 | family of functions. | |
19062 | ||
19063 | The default value of this option is enabled, thus the only useful form | |
19064 | of the option is @option{-fno-sync-libcalls}. This option is used in | |
19065 | the implementation of the @file{libatomic} runtime library. | |
19066 | ||
19067 | @end table | |
19068 | ||
19069 | @node Developer Options | |
19070 | @section GCC Developer Options | |
19071 | @cindex developer options | |
19072 | @cindex debugging GCC | |
19073 | @cindex debug dump options | |
19074 | @cindex dump options | |
19075 | @cindex compilation statistics | |
19076 | ||
19077 | This section describes command-line options that are primarily of | |
19078 | interest to GCC developers, including options to support compiler | |
19079 | testing and investigation of compiler bugs and compile-time | |
19080 | performance problems. This includes options that produce debug dumps | |
19081 | at various points in the compilation; that print statistics such as | |
19082 | memory use and execution time; and that print information about GCC's | |
19083 | configuration, such as where it searches for libraries. You should | |
19084 | rarely need to use any of these options for ordinary compilation and | |
19085 | linking tasks. | |
19086 | ||
19087 | Many developer options that cause GCC to dump output to a file take an | |
19088 | optional @samp{=@var{filename}} suffix. You can specify @samp{stdout} | |
19089 | or @samp{-} to dump to standard output, and @samp{stderr} for standard | |
19090 | error. | |
19091 | ||
19092 | If @samp{=@var{filename}} is omitted, a default dump file name is | |
19093 | constructed by concatenating the base dump file name, a pass number, | |
19094 | phase letter, and pass name. The base dump file name is the name of | |
19095 | output file produced by the compiler if explicitly specified and not | |
19096 | an executable; otherwise it is the source file name. | |
19097 | The pass number is determined by the order passes are registered with | |
19098 | the compiler's pass manager. | |
19099 | This is generally the same as the order of execution, but passes | |
19100 | registered by plugins, target-specific passes, or passes that are | |
19101 | otherwise registered late are numbered higher than the pass named | |
19102 | @samp{final}, even if they are executed earlier. The phase letter is | |
19103 | one of @samp{i} (inter-procedural analysis), @samp{l} | |
19104 | (language-specific), @samp{r} (RTL), or @samp{t} (tree). | |
19105 | The files are created in the directory of the output file. | |
19106 | ||
19107 | @table @gcctabopt | |
19108 | ||
ddf6fe37 | 19109 | @opindex fcallgraph-info |
d77de738 ML |
19110 | @item -fcallgraph-info |
19111 | @itemx -fcallgraph-info=@var{MARKERS} | |
d77de738 ML |
19112 | Makes the compiler output callgraph information for the program, on a |
19113 | per-object-file basis. The information is generated in the common VCG | |
19114 | format. It can be decorated with additional, per-node and/or per-edge | |
19115 | information, if a list of comma-separated markers is additionally | |
19116 | specified. When the @code{su} marker is specified, the callgraph is | |
19117 | decorated with stack usage information; it is equivalent to | |
19118 | @option{-fstack-usage}. When the @code{da} marker is specified, the | |
19119 | callgraph is decorated with information about dynamically allocated | |
19120 | objects. | |
19121 | ||
19122 | When compiling with @option{-flto}, no callgraph information is output | |
19123 | along with the object file. At LTO link time, @option{-fcallgraph-info} | |
19124 | may generate multiple callgraph information files next to intermediate | |
19125 | LTO output files. | |
19126 | ||
ddf6fe37 AA |
19127 | @opindex d |
19128 | @opindex fdump-rtl-@var{pass} | |
d77de738 ML |
19129 | @item -d@var{letters} |
19130 | @itemx -fdump-rtl-@var{pass} | |
19131 | @itemx -fdump-rtl-@var{pass}=@var{filename} | |
d77de738 ML |
19132 | Says to make debugging dumps during compilation at times specified by |
19133 | @var{letters}. This is used for debugging the RTL-based passes of the | |
19134 | compiler. | |
19135 | ||
19136 | Some @option{-d@var{letters}} switches have different meaning when | |
19137 | @option{-E} is used for preprocessing. @xref{Preprocessor Options}, | |
19138 | for information about preprocessor-specific dump options. | |
19139 | ||
19140 | Debug dumps can be enabled with a @option{-fdump-rtl} switch or some | |
19141 | @option{-d} option @var{letters}. Here are the possible | |
19142 | letters for use in @var{pass} and @var{letters}, and their meanings: | |
19143 | ||
19144 | @table @gcctabopt | |
19145 | ||
d77de738 | 19146 | @opindex fdump-rtl-alignments |
ddf6fe37 | 19147 | @item -fdump-rtl-alignments |
d77de738 ML |
19148 | Dump after branch alignments have been computed. |
19149 | ||
d77de738 | 19150 | @opindex fdump-rtl-asmcons |
ddf6fe37 | 19151 | @item -fdump-rtl-asmcons |
d77de738 ML |
19152 | Dump after fixing rtl statements that have unsatisfied in/out constraints. |
19153 | ||
d77de738 | 19154 | @opindex fdump-rtl-auto_inc_dec |
ddf6fe37 | 19155 | @item -fdump-rtl-auto_inc_dec |
d77de738 ML |
19156 | Dump after auto-inc-dec discovery. This pass is only run on |
19157 | architectures that have auto inc or auto dec instructions. | |
19158 | ||
d77de738 | 19159 | @opindex fdump-rtl-barriers |
ddf6fe37 | 19160 | @item -fdump-rtl-barriers |
d77de738 ML |
19161 | Dump after cleaning up the barrier instructions. |
19162 | ||
d77de738 | 19163 | @opindex fdump-rtl-bbpart |
ddf6fe37 | 19164 | @item -fdump-rtl-bbpart |
d77de738 ML |
19165 | Dump after partitioning hot and cold basic blocks. |
19166 | ||
d77de738 | 19167 | @opindex fdump-rtl-bbro |
ddf6fe37 | 19168 | @item -fdump-rtl-bbro |
d77de738 ML |
19169 | Dump after block reordering. |
19170 | ||
d77de738 ML |
19171 | @opindex fdump-rtl-btl2 |
19172 | @opindex fdump-rtl-btl2 | |
ddf6fe37 AA |
19173 | @item -fdump-rtl-btl1 |
19174 | @itemx -fdump-rtl-btl2 | |
d77de738 ML |
19175 | @option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping |
19176 | after the two branch | |
19177 | target load optimization passes. | |
19178 | ||
d77de738 | 19179 | @opindex fdump-rtl-bypass |
ddf6fe37 | 19180 | @item -fdump-rtl-bypass |
d77de738 ML |
19181 | Dump after jump bypassing and control flow optimizations. |
19182 | ||
d77de738 | 19183 | @opindex fdump-rtl-combine |
ddf6fe37 | 19184 | @item -fdump-rtl-combine |
d77de738 ML |
19185 | Dump after the RTL instruction combination pass. |
19186 | ||
d77de738 | 19187 | @opindex fdump-rtl-compgotos |
ddf6fe37 | 19188 | @item -fdump-rtl-compgotos |
d77de738 ML |
19189 | Dump after duplicating the computed gotos. |
19190 | ||
d77de738 ML |
19191 | @opindex fdump-rtl-ce1 |
19192 | @opindex fdump-rtl-ce2 | |
19193 | @opindex fdump-rtl-ce3 | |
ddf6fe37 AA |
19194 | @item -fdump-rtl-ce1 |
19195 | @itemx -fdump-rtl-ce2 | |
19196 | @itemx -fdump-rtl-ce3 | |
d77de738 ML |
19197 | @option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and |
19198 | @option{-fdump-rtl-ce3} enable dumping after the three | |
19199 | if conversion passes. | |
19200 | ||
d77de738 | 19201 | @opindex fdump-rtl-cprop_hardreg |
ddf6fe37 | 19202 | @item -fdump-rtl-cprop_hardreg |
d77de738 ML |
19203 | Dump after hard register copy propagation. |
19204 | ||
d77de738 | 19205 | @opindex fdump-rtl-csa |
ddf6fe37 | 19206 | @item -fdump-rtl-csa |
d77de738 ML |
19207 | Dump after combining stack adjustments. |
19208 | ||
d77de738 ML |
19209 | @opindex fdump-rtl-cse1 |
19210 | @opindex fdump-rtl-cse2 | |
ddf6fe37 AA |
19211 | @item -fdump-rtl-cse1 |
19212 | @itemx -fdump-rtl-cse2 | |
d77de738 ML |
19213 | @option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after |
19214 | the two common subexpression elimination passes. | |
19215 | ||
d77de738 | 19216 | @opindex fdump-rtl-dce |
ddf6fe37 | 19217 | @item -fdump-rtl-dce |
d77de738 ML |
19218 | Dump after the standalone dead code elimination passes. |
19219 | ||
d77de738 | 19220 | @opindex fdump-rtl-dbr |
ddf6fe37 | 19221 | @item -fdump-rtl-dbr |
d77de738 ML |
19222 | Dump after delayed branch scheduling. |
19223 | ||
d77de738 ML |
19224 | @opindex fdump-rtl-dce1 |
19225 | @opindex fdump-rtl-dce2 | |
ddf6fe37 AA |
19226 | @item -fdump-rtl-dce1 |
19227 | @itemx -fdump-rtl-dce2 | |
d77de738 ML |
19228 | @option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after |
19229 | the two dead store elimination passes. | |
19230 | ||
d77de738 | 19231 | @opindex fdump-rtl-eh |
ddf6fe37 | 19232 | @item -fdump-rtl-eh |
d77de738 ML |
19233 | Dump after finalization of EH handling code. |
19234 | ||
d77de738 | 19235 | @opindex fdump-rtl-eh_ranges |
ddf6fe37 | 19236 | @item -fdump-rtl-eh_ranges |
d77de738 ML |
19237 | Dump after conversion of EH handling range regions. |
19238 | ||
d77de738 | 19239 | @opindex fdump-rtl-expand |
ddf6fe37 | 19240 | @item -fdump-rtl-expand |
d77de738 ML |
19241 | Dump after RTL generation. |
19242 | ||
d77de738 ML |
19243 | @opindex fdump-rtl-fwprop1 |
19244 | @opindex fdump-rtl-fwprop2 | |
ddf6fe37 AA |
19245 | @item -fdump-rtl-fwprop1 |
19246 | @itemx -fdump-rtl-fwprop2 | |
d77de738 ML |
19247 | @option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable |
19248 | dumping after the two forward propagation passes. | |
19249 | ||
d77de738 ML |
19250 | @opindex fdump-rtl-gcse1 |
19251 | @opindex fdump-rtl-gcse2 | |
ddf6fe37 AA |
19252 | @item -fdump-rtl-gcse1 |
19253 | @itemx -fdump-rtl-gcse2 | |
d77de738 ML |
19254 | @option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping |
19255 | after global common subexpression elimination. | |
19256 | ||
d77de738 | 19257 | @opindex fdump-rtl-init-regs |
ddf6fe37 | 19258 | @item -fdump-rtl-init-regs |
d77de738 ML |
19259 | Dump after the initialization of the registers. |
19260 | ||
d77de738 | 19261 | @opindex fdump-rtl-initvals |
ddf6fe37 | 19262 | @item -fdump-rtl-initvals |
d77de738 ML |
19263 | Dump after the computation of the initial value sets. |
19264 | ||
d77de738 | 19265 | @opindex fdump-rtl-into_cfglayout |
ddf6fe37 | 19266 | @item -fdump-rtl-into_cfglayout |
d77de738 ML |
19267 | Dump after converting to cfglayout mode. |
19268 | ||
d77de738 | 19269 | @opindex fdump-rtl-ira |
ddf6fe37 | 19270 | @item -fdump-rtl-ira |
d77de738 ML |
19271 | Dump after iterated register allocation. |
19272 | ||
d77de738 | 19273 | @opindex fdump-rtl-jump |
ddf6fe37 | 19274 | @item -fdump-rtl-jump |
d77de738 ML |
19275 | Dump after the second jump optimization. |
19276 | ||
d77de738 | 19277 | @opindex fdump-rtl-loop2 |
ddf6fe37 | 19278 | @item -fdump-rtl-loop2 |
d77de738 ML |
19279 | @option{-fdump-rtl-loop2} enables dumping after the rtl |
19280 | loop optimization passes. | |
19281 | ||
d77de738 | 19282 | @opindex fdump-rtl-mach |
ddf6fe37 | 19283 | @item -fdump-rtl-mach |
d77de738 ML |
19284 | Dump after performing the machine dependent reorganization pass, if that |
19285 | pass exists. | |
19286 | ||
d77de738 | 19287 | @opindex fdump-rtl-mode_sw |
ddf6fe37 | 19288 | @item -fdump-rtl-mode_sw |
d77de738 ML |
19289 | Dump after removing redundant mode switches. |
19290 | ||
d77de738 | 19291 | @opindex fdump-rtl-rnreg |
ddf6fe37 | 19292 | @item -fdump-rtl-rnreg |
d77de738 ML |
19293 | Dump after register renumbering. |
19294 | ||
d77de738 | 19295 | @opindex fdump-rtl-outof_cfglayout |
ddf6fe37 | 19296 | @item -fdump-rtl-outof_cfglayout |
d77de738 ML |
19297 | Dump after converting from cfglayout mode. |
19298 | ||
d77de738 | 19299 | @opindex fdump-rtl-peephole2 |
ddf6fe37 | 19300 | @item -fdump-rtl-peephole2 |
d77de738 ML |
19301 | Dump after the peephole pass. |
19302 | ||
d77de738 | 19303 | @opindex fdump-rtl-postreload |
ddf6fe37 | 19304 | @item -fdump-rtl-postreload |
d77de738 ML |
19305 | Dump after post-reload optimizations. |
19306 | ||
d77de738 | 19307 | @opindex fdump-rtl-pro_and_epilogue |
ddf6fe37 | 19308 | @item -fdump-rtl-pro_and_epilogue |
d77de738 ML |
19309 | Dump after generating the function prologues and epilogues. |
19310 | ||
d77de738 ML |
19311 | @opindex fdump-rtl-sched1 |
19312 | @opindex fdump-rtl-sched2 | |
ddf6fe37 AA |
19313 | @item -fdump-rtl-sched1 |
19314 | @itemx -fdump-rtl-sched2 | |
d77de738 ML |
19315 | @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping |
19316 | after the basic block scheduling passes. | |
19317 | ||
d77de738 | 19318 | @opindex fdump-rtl-ree |
ddf6fe37 | 19319 | @item -fdump-rtl-ree |
d77de738 ML |
19320 | Dump after sign/zero extension elimination. |
19321 | ||
d77de738 | 19322 | @opindex fdump-rtl-seqabstr |
ddf6fe37 | 19323 | @item -fdump-rtl-seqabstr |
d77de738 ML |
19324 | Dump after common sequence discovery. |
19325 | ||
d77de738 | 19326 | @opindex fdump-rtl-shorten |
ddf6fe37 | 19327 | @item -fdump-rtl-shorten |
d77de738 ML |
19328 | Dump after shortening branches. |
19329 | ||
d77de738 | 19330 | @opindex fdump-rtl-sibling |
ddf6fe37 | 19331 | @item -fdump-rtl-sibling |
d77de738 ML |
19332 | Dump after sibling call optimizations. |
19333 | ||
d77de738 ML |
19334 | @opindex fdump-rtl-split1 |
19335 | @opindex fdump-rtl-split2 | |
19336 | @opindex fdump-rtl-split3 | |
19337 | @opindex fdump-rtl-split4 | |
19338 | @opindex fdump-rtl-split5 | |
ddf6fe37 AA |
19339 | @item -fdump-rtl-split1 |
19340 | @itemx -fdump-rtl-split2 | |
19341 | @itemx -fdump-rtl-split3 | |
19342 | @itemx -fdump-rtl-split4 | |
19343 | @itemx -fdump-rtl-split5 | |
d77de738 ML |
19344 | These options enable dumping after five rounds of |
19345 | instruction splitting. | |
19346 | ||
d77de738 | 19347 | @opindex fdump-rtl-sms |
ddf6fe37 | 19348 | @item -fdump-rtl-sms |
d77de738 ML |
19349 | Dump after modulo scheduling. This pass is only run on some |
19350 | architectures. | |
19351 | ||
d77de738 | 19352 | @opindex fdump-rtl-stack |
ddf6fe37 | 19353 | @item -fdump-rtl-stack |
d77de738 ML |
19354 | Dump after conversion from GCC's ``flat register file'' registers to the |
19355 | x87's stack-like registers. This pass is only run on x86 variants. | |
19356 | ||
d77de738 ML |
19357 | @opindex fdump-rtl-subreg1 |
19358 | @opindex fdump-rtl-subreg2 | |
ddf6fe37 AA |
19359 | @item -fdump-rtl-subreg1 |
19360 | @itemx -fdump-rtl-subreg2 | |
d77de738 ML |
19361 | @option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after |
19362 | the two subreg expansion passes. | |
19363 | ||
d77de738 | 19364 | @opindex fdump-rtl-unshare |
ddf6fe37 | 19365 | @item -fdump-rtl-unshare |
d77de738 ML |
19366 | Dump after all rtl has been unshared. |
19367 | ||
d77de738 | 19368 | @opindex fdump-rtl-vartrack |
ddf6fe37 | 19369 | @item -fdump-rtl-vartrack |
d77de738 ML |
19370 | Dump after variable tracking. |
19371 | ||
d77de738 | 19372 | @opindex fdump-rtl-vregs |
ddf6fe37 | 19373 | @item -fdump-rtl-vregs |
d77de738 ML |
19374 | Dump after converting virtual registers to hard registers. |
19375 | ||
d77de738 | 19376 | @opindex fdump-rtl-web |
ddf6fe37 | 19377 | @item -fdump-rtl-web |
d77de738 ML |
19378 | Dump after live range splitting. |
19379 | ||
d77de738 ML |
19380 | @opindex fdump-rtl-regclass |
19381 | @opindex fdump-rtl-subregs_of_mode_init | |
19382 | @opindex fdump-rtl-subregs_of_mode_finish | |
19383 | @opindex fdump-rtl-dfinit | |
19384 | @opindex fdump-rtl-dfinish | |
ddf6fe37 AA |
19385 | @item -fdump-rtl-regclass |
19386 | @itemx -fdump-rtl-subregs_of_mode_init | |
19387 | @itemx -fdump-rtl-subregs_of_mode_finish | |
19388 | @itemx -fdump-rtl-dfinit | |
19389 | @itemx -fdump-rtl-dfinish | |
d77de738 ML |
19390 | These dumps are defined but always produce empty files. |
19391 | ||
d77de738 ML |
19392 | @opindex da |
19393 | @opindex fdump-rtl-all | |
ddf6fe37 AA |
19394 | @item -da |
19395 | @itemx -fdump-rtl-all | |
d77de738 ML |
19396 | Produce all the dumps listed above. |
19397 | ||
d77de738 | 19398 | @opindex dA |
ddf6fe37 | 19399 | @item -dA |
d77de738 ML |
19400 | Annotate the assembler output with miscellaneous debugging information. |
19401 | ||
d77de738 | 19402 | @opindex dD |
ddf6fe37 | 19403 | @item -dD |
d77de738 ML |
19404 | Dump all macro definitions, at the end of preprocessing, in addition to |
19405 | normal output. | |
19406 | ||
d77de738 | 19407 | @opindex dH |
ddf6fe37 | 19408 | @item -dH |
d77de738 ML |
19409 | Produce a core dump whenever an error occurs. |
19410 | ||
d77de738 | 19411 | @opindex dp |
ddf6fe37 | 19412 | @item -dp |
d77de738 ML |
19413 | Annotate the assembler output with a comment indicating which |
19414 | pattern and alternative is used. The length and cost of each instruction are | |
19415 | also printed. | |
19416 | ||
d77de738 | 19417 | @opindex dP |
ddf6fe37 | 19418 | @item -dP |
d77de738 ML |
19419 | Dump the RTL in the assembler output as a comment before each instruction. |
19420 | Also turns on @option{-dp} annotation. | |
19421 | ||
d77de738 | 19422 | @opindex dx |
ddf6fe37 | 19423 | @item -dx |
d77de738 ML |
19424 | Just generate RTL for a function instead of compiling it. Usually used |
19425 | with @option{-fdump-rtl-expand}. | |
19426 | @end table | |
19427 | ||
d77de738 | 19428 | @opindex fdump-debug |
ddf6fe37 | 19429 | @item -fdump-debug |
d77de738 ML |
19430 | Dump debugging information generated during the debug |
19431 | generation phase. | |
19432 | ||
d77de738 | 19433 | @opindex fdump-earlydebug |
ddf6fe37 | 19434 | @item -fdump-earlydebug |
d77de738 ML |
19435 | Dump debugging information generated during the early debug |
19436 | generation phase. | |
19437 | ||
d77de738 | 19438 | @opindex fdump-noaddr |
ddf6fe37 | 19439 | @item -fdump-noaddr |
d77de738 ML |
19440 | When doing debugging dumps, suppress address output. This makes it more |
19441 | feasible to use diff on debugging dumps for compiler invocations with | |
19442 | different compiler binaries and/or different | |
19443 | text / bss / data / heap / stack / dso start locations. | |
19444 | ||
d77de738 | 19445 | @opindex freport-bug |
ddf6fe37 | 19446 | @item -freport-bug |
d77de738 ML |
19447 | Collect and dump debug information into a temporary file if an |
19448 | internal compiler error (ICE) occurs. | |
19449 | ||
d77de738 | 19450 | @opindex fdump-unnumbered |
ddf6fe37 | 19451 | @item -fdump-unnumbered |
d77de738 ML |
19452 | When doing debugging dumps, suppress instruction numbers and address output. |
19453 | This makes it more feasible to use diff on debugging dumps for compiler | |
19454 | invocations with different options, in particular with and without | |
19455 | @option{-g}. | |
19456 | ||
d77de738 | 19457 | @opindex fdump-unnumbered-links |
ddf6fe37 | 19458 | @item -fdump-unnumbered-links |
d77de738 ML |
19459 | When doing debugging dumps (see @option{-d} option above), suppress |
19460 | instruction numbers for the links to the previous and next instructions | |
19461 | in a sequence. | |
19462 | ||
ddf6fe37 | 19463 | @opindex fdump-ipa |
d77de738 ML |
19464 | @item -fdump-ipa-@var{switch} |
19465 | @itemx -fdump-ipa-@var{switch}-@var{options} | |
d77de738 ML |
19466 | Control the dumping at various stages of inter-procedural analysis |
19467 | language tree to a file. The file name is generated by appending a | |
19468 | switch specific suffix to the source file name, and the file is created | |
19469 | in the same directory as the output file. The following dumps are | |
19470 | possible: | |
19471 | ||
19472 | @table @samp | |
19473 | @item all | |
19474 | Enables all inter-procedural analysis dumps. | |
19475 | ||
19476 | @item cgraph | |
19477 | Dumps information about call-graph optimization, unused function removal, | |
19478 | and inlining decisions. | |
19479 | ||
19480 | @item inline | |
19481 | Dump after function inlining. | |
19482 | ||
19483 | @end table | |
19484 | ||
19485 | Additionally, the options @option{-optimized}, @option{-missed}, | |
19486 | @option{-note}, and @option{-all} can be provided, with the same meaning | |
19487 | as for @option{-fopt-info}, defaulting to @option{-optimized}. | |
19488 | ||
19489 | For example, @option{-fdump-ipa-inline-optimized-missed} will emit | |
19490 | information on callsites that were inlined, along with callsites | |
19491 | that were not inlined. | |
19492 | ||
19493 | By default, the dump will contain messages about successful | |
19494 | optimizations (equivalent to @option{-optimized}) together with | |
19495 | low-level details about the analysis. | |
19496 | ||
d77de738 | 19497 | @opindex fdump-lang |
ddf6fe37 | 19498 | @item -fdump-lang |
d77de738 ML |
19499 | Dump language-specific information. The file name is made by appending |
19500 | @file{.lang} to the source file name. | |
19501 | ||
ddf6fe37 AA |
19502 | @opindex fdump-lang-all |
19503 | @opindex fdump-lang | |
d77de738 ML |
19504 | @item -fdump-lang-all |
19505 | @itemx -fdump-lang-@var{switch} | |
19506 | @itemx -fdump-lang-@var{switch}-@var{options} | |
19507 | @itemx -fdump-lang-@var{switch}-@var{options}=@var{filename} | |
d77de738 ML |
19508 | Control the dumping of language-specific information. The @var{options} |
19509 | and @var{filename} portions behave as described in the | |
19510 | @option{-fdump-tree} option. The following @var{switch} values are | |
19511 | accepted: | |
19512 | ||
19513 | @table @samp | |
19514 | @item all | |
19515 | ||
19516 | Enable all language-specific dumps. | |
19517 | ||
19518 | @item class | |
19519 | Dump class hierarchy information. Virtual table information is emitted | |
19520 | unless '@option{slim}' is specified. This option is applicable to C++ only. | |
19521 | ||
19522 | @item module | |
19523 | Dump module information. Options @option{lineno} (locations), | |
19524 | @option{graph} (reachability), @option{blocks} (clusters), | |
19525 | @option{uid} (serialization), @option{alias} (mergeable), | |
19526 | @option{asmname} (Elrond), @option{eh} (mapper) & @option{vops} | |
19527 | (macros) may provide additional information. This option is | |
19528 | applicable to C++ only. | |
19529 | ||
19530 | @item raw | |
19531 | Dump the raw internal tree data. This option is applicable to C++ only. | |
19532 | ||
19533 | @end table | |
19534 | ||
d77de738 | 19535 | @opindex fdump-passes |
ddf6fe37 | 19536 | @item -fdump-passes |
d77de738 ML |
19537 | Print on @file{stderr} the list of optimization passes that are turned |
19538 | on and off by the current command-line options. | |
19539 | ||
d77de738 | 19540 | @opindex fdump-statistics |
ddf6fe37 | 19541 | @item -fdump-statistics-@var{option} |
d77de738 ML |
19542 | Enable and control dumping of pass statistics in a separate file. The |
19543 | file name is generated by appending a suffix ending in | |
19544 | @samp{.statistics} to the source file name, and the file is created in | |
19545 | the same directory as the output file. If the @samp{-@var{option}} | |
19546 | form is used, @samp{-stats} causes counters to be summed over the | |
19547 | whole compilation unit while @samp{-details} dumps every event as | |
19548 | the passes generate them. The default with no option is to sum | |
19549 | counters for each function compiled. | |
19550 | ||
ddf6fe37 AA |
19551 | @opindex fdump-tree-all |
19552 | @opindex fdump-tree | |
d77de738 ML |
19553 | @item -fdump-tree-all |
19554 | @itemx -fdump-tree-@var{switch} | |
19555 | @itemx -fdump-tree-@var{switch}-@var{options} | |
19556 | @itemx -fdump-tree-@var{switch}-@var{options}=@var{filename} | |
d77de738 ML |
19557 | Control the dumping at various stages of processing the intermediate |
19558 | language tree to a file. If the @samp{-@var{options}} | |
19559 | form is used, @var{options} is a list of @samp{-} separated options | |
19560 | which control the details of the dump. Not all options are applicable | |
19561 | to all dumps; those that are not meaningful are ignored. The | |
19562 | following options are available | |
19563 | ||
19564 | @table @samp | |
19565 | @item address | |
19566 | Print the address of each node. Usually this is not meaningful as it | |
19567 | changes according to the environment and source file. Its primary use | |
19568 | is for tying up a dump file with a debug environment. | |
19569 | @item asmname | |
19570 | If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that | |
19571 | in the dump instead of @code{DECL_NAME}. Its primary use is ease of | |
19572 | use working backward from mangled names in the assembly file. | |
19573 | @item slim | |
19574 | When dumping front-end intermediate representations, inhibit dumping | |
19575 | of members of a scope or body of a function merely because that scope | |
19576 | has been reached. Only dump such items when they are directly reachable | |
19577 | by some other path. | |
19578 | ||
19579 | When dumping pretty-printed trees, this option inhibits dumping the | |
19580 | bodies of control structures. | |
19581 | ||
19582 | When dumping RTL, print the RTL in slim (condensed) form instead of | |
19583 | the default LISP-like representation. | |
19584 | @item raw | |
19585 | Print a raw representation of the tree. By default, trees are | |
19586 | pretty-printed into a C-like representation. | |
19587 | @item details | |
19588 | Enable more detailed dumps (not honored by every dump option). Also | |
19589 | include information from the optimization passes. | |
19590 | @item stats | |
19591 | Enable dumping various statistics about the pass (not honored by every dump | |
19592 | option). | |
19593 | @item blocks | |
19594 | Enable showing basic block boundaries (disabled in raw dumps). | |
19595 | @item graph | |
19596 | For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}), | |
19597 | dump a representation of the control flow graph suitable for viewing with | |
19598 | GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in | |
19599 | the file is pretty-printed as a subgraph, so that GraphViz can render them | |
19600 | all in a single plot. | |
19601 | ||
19602 | This option currently only works for RTL dumps, and the RTL is always | |
19603 | dumped in slim form. | |
19604 | @item vops | |
19605 | Enable showing virtual operands for every statement. | |
19606 | @item lineno | |
19607 | Enable showing line numbers for statements. | |
19608 | @item uid | |
19609 | Enable showing the unique ID (@code{DECL_UID}) for each variable. | |
19610 | @item verbose | |
19611 | Enable showing the tree dump for each statement. | |
19612 | @item eh | |
19613 | Enable showing the EH region number holding each statement. | |
19614 | @item scev | |
19615 | Enable showing scalar evolution analysis details. | |
19616 | @item optimized | |
19617 | Enable showing optimization information (only available in certain | |
19618 | passes). | |
19619 | @item missed | |
19620 | Enable showing missed optimization information (only available in certain | |
19621 | passes). | |
19622 | @item note | |
19623 | Enable other detailed optimization information (only available in | |
19624 | certain passes). | |
19625 | @item all | |
19626 | Turn on all options, except @option{raw}, @option{slim}, @option{verbose} | |
19627 | and @option{lineno}. | |
19628 | @item optall | |
19629 | Turn on all optimization options, i.e., @option{optimized}, | |
19630 | @option{missed}, and @option{note}. | |
19631 | @end table | |
19632 | ||
19633 | To determine what tree dumps are available or find the dump for a pass | |
19634 | of interest follow the steps below. | |
19635 | ||
19636 | @enumerate | |
19637 | @item | |
19638 | Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output | |
19639 | look for a code that corresponds to the pass you are interested in. | |
19640 | For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and | |
19641 | @code{tree-vrp2} correspond to the three Value Range Propagation passes. | |
19642 | The number at the end distinguishes distinct invocations of the same pass. | |
19643 | @item | |
19644 | To enable the creation of the dump file, append the pass code to | |
19645 | the @option{-fdump-} option prefix and invoke GCC with it. For example, | |
19646 | to enable the dump from the Early Value Range Propagation pass, invoke | |
19647 | GCC with the @option{-fdump-tree-evrp} option. Optionally, you may | |
19648 | specify the name of the dump file. If you don't specify one, GCC | |
19649 | creates as described below. | |
19650 | @item | |
19651 | Find the pass dump in a file whose name is composed of three components | |
19652 | separated by a period: the name of the source file GCC was invoked to | |
19653 | compile, a numeric suffix indicating the pass number followed by the | |
19654 | letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes), | |
19655 | and finally the pass code. For example, the Early VRP pass dump might | |
19656 | be in a file named @file{myfile.c.038t.evrp} in the current working | |
19657 | directory. Note that the numeric codes are not stable and may change | |
19658 | from one version of GCC to another. | |
19659 | @end enumerate | |
19660 | ||
ddf6fe37 | 19661 | @opindex fopt-info |
d77de738 ML |
19662 | @item -fopt-info |
19663 | @itemx -fopt-info-@var{options} | |
19664 | @itemx -fopt-info-@var{options}=@var{filename} | |
d77de738 ML |
19665 | Controls optimization dumps from various optimization passes. If the |
19666 | @samp{-@var{options}} form is used, @var{options} is a list of | |
19667 | @samp{-} separated option keywords to select the dump details and | |
19668 | optimizations. | |
19669 | ||
19670 | The @var{options} can be divided into three groups: | |
19671 | @enumerate | |
19672 | @item | |
19673 | options describing what kinds of messages should be emitted, | |
19674 | @item | |
19675 | options describing the verbosity of the dump, and | |
19676 | @item | |
19677 | options describing which optimizations should be included. | |
19678 | @end enumerate | |
19679 | The options from each group can be freely mixed as they are | |
19680 | non-overlapping. However, in case of any conflicts, | |
19681 | the later options override the earlier options on the command | |
19682 | line. | |
19683 | ||
19684 | The following options control which kinds of messages should be emitted: | |
19685 | ||
19686 | @table @samp | |
19687 | @item optimized | |
19688 | Print information when an optimization is successfully applied. It is | |
19689 | up to a pass to decide which information is relevant. For example, the | |
19690 | vectorizer passes print the source location of loops which are | |
19691 | successfully vectorized. | |
19692 | @item missed | |
19693 | Print information about missed optimizations. Individual passes | |
19694 | control which information to include in the output. | |
19695 | @item note | |
19696 | Print verbose information about optimizations, such as certain | |
19697 | transformations, more detailed messages about decisions etc. | |
19698 | @item all | |
19699 | Print detailed optimization information. This includes | |
19700 | @samp{optimized}, @samp{missed}, and @samp{note}. | |
19701 | @end table | |
19702 | ||
19703 | The following option controls the dump verbosity: | |
19704 | ||
19705 | @table @samp | |
19706 | @item internals | |
19707 | By default, only ``high-level'' messages are emitted. This option enables | |
19708 | additional, more detailed, messages, which are likely to only be of interest | |
19709 | to GCC developers. | |
19710 | @end table | |
19711 | ||
19712 | One or more of the following option keywords can be used to describe a | |
19713 | group of optimizations: | |
19714 | ||
19715 | @table @samp | |
19716 | @item ipa | |
19717 | Enable dumps from all interprocedural optimizations. | |
19718 | @item loop | |
19719 | Enable dumps from all loop optimizations. | |
19720 | @item inline | |
19721 | Enable dumps from all inlining optimizations. | |
19722 | @item omp | |
19723 | Enable dumps from all OMP (Offloading and Multi Processing) optimizations. | |
19724 | @item vec | |
19725 | Enable dumps from all vectorization optimizations. | |
19726 | @item optall | |
19727 | Enable dumps from all optimizations. This is a superset of | |
19728 | the optimization groups listed above. | |
19729 | @end table | |
19730 | ||
19731 | If @var{options} is | |
19732 | omitted, it defaults to @samp{optimized-optall}, which means to dump messages | |
19733 | about successful optimizations from all the passes, omitting messages | |
19734 | that are treated as ``internals''. | |
19735 | ||
19736 | If the @var{filename} is provided, then the dumps from all the | |
19737 | applicable optimizations are concatenated into the @var{filename}. | |
19738 | Otherwise the dump is output onto @file{stderr}. Though multiple | |
19739 | @option{-fopt-info} options are accepted, only one of them can include | |
19740 | a @var{filename}. If other filenames are provided then all but the | |
19741 | first such option are ignored. | |
19742 | ||
19743 | Note that the output @var{filename} is overwritten | |
19744 | in case of multiple translation units. If a combined output from | |
19745 | multiple translation units is desired, @file{stderr} should be used | |
19746 | instead. | |
19747 | ||
19748 | In the following example, the optimization info is output to | |
19749 | @file{stderr}: | |
19750 | ||
19751 | @smallexample | |
19752 | gcc -O3 -fopt-info | |
19753 | @end smallexample | |
19754 | ||
19755 | This example: | |
19756 | @smallexample | |
19757 | gcc -O3 -fopt-info-missed=missed.all | |
19758 | @end smallexample | |
19759 | ||
19760 | @noindent | |
19761 | outputs missed optimization report from all the passes into | |
19762 | @file{missed.all}, and this one: | |
19763 | ||
19764 | @smallexample | |
19765 | gcc -O2 -ftree-vectorize -fopt-info-vec-missed | |
19766 | @end smallexample | |
19767 | ||
19768 | @noindent | |
19769 | prints information about missed optimization opportunities from | |
19770 | vectorization passes on @file{stderr}. | |
19771 | Note that @option{-fopt-info-vec-missed} is equivalent to | |
19772 | @option{-fopt-info-missed-vec}. The order of the optimization group | |
19773 | names and message types listed after @option{-fopt-info} does not matter. | |
19774 | ||
19775 | As another example, | |
19776 | @smallexample | |
19777 | gcc -O3 -fopt-info-inline-optimized-missed=inline.txt | |
19778 | @end smallexample | |
19779 | ||
19780 | @noindent | |
19781 | outputs information about missed optimizations as well as | |
19782 | optimized locations from all the inlining passes into | |
19783 | @file{inline.txt}. | |
19784 | ||
19785 | Finally, consider: | |
19786 | ||
19787 | @smallexample | |
19788 | gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt | |
19789 | @end smallexample | |
19790 | ||
19791 | @noindent | |
19792 | Here the two output filenames @file{vec.miss} and @file{loop.opt} are | |
19793 | in conflict since only one output file is allowed. In this case, only | |
19794 | the first option takes effect and the subsequent options are | |
19795 | ignored. Thus only @file{vec.miss} is produced which contains | |
19796 | dumps from the vectorizer about missed opportunities. | |
19797 | ||
d77de738 | 19798 | @opindex fsave-optimization-record |
ddf6fe37 | 19799 | @item -fsave-optimization-record |
d77de738 ML |
19800 | Write a SRCFILE.opt-record.json.gz file detailing what optimizations |
19801 | were performed, for those optimizations that support @option{-fopt-info}. | |
19802 | ||
19803 | This option is experimental and the format of the data within the | |
19804 | compressed JSON file is subject to change. | |
19805 | ||
19806 | It is roughly equivalent to a machine-readable version of | |
19807 | @option{-fopt-info-all}, as a collection of messages with source file, | |
19808 | line number and column number, with the following additional data for | |
19809 | each message: | |
19810 | ||
19811 | @itemize @bullet | |
19812 | ||
19813 | @item | |
19814 | the execution count of the code being optimized, along with metadata about | |
19815 | whether this was from actual profile data, or just an estimate, allowing | |
19816 | consumers to prioritize messages by code hotness, | |
19817 | ||
19818 | @item | |
19819 | the function name of the code being optimized, where applicable, | |
19820 | ||
19821 | @item | |
19822 | the ``inlining chain'' for the code being optimized, so that when | |
19823 | a function is inlined into several different places (which might | |
19824 | themselves be inlined), the reader can distinguish between the copies, | |
19825 | ||
19826 | @item | |
19827 | objects identifying those parts of the message that refer to expressions, | |
19828 | statements or symbol-table nodes, which of these categories they are, and, | |
19829 | when available, their source code location, | |
19830 | ||
19831 | @item | |
19832 | the GCC pass that emitted the message, and | |
19833 | ||
19834 | @item | |
19835 | the location in GCC's own code from which the message was emitted | |
19836 | ||
19837 | @end itemize | |
19838 | ||
19839 | Additionally, some messages are logically nested within other | |
19840 | messages, reflecting implementation details of the optimization | |
19841 | passes. | |
19842 | ||
d77de738 | 19843 | @opindex fsched-verbose |
ddf6fe37 | 19844 | @item -fsched-verbose=@var{n} |
d77de738 ML |
19845 | On targets that use instruction scheduling, this option controls the |
19846 | amount of debugging output the scheduler prints to the dump files. | |
19847 | ||
19848 | For @var{n} greater than zero, @option{-fsched-verbose} outputs the | |
19849 | same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}. | |
19850 | For @var{n} greater than one, it also output basic block probabilities, | |
19851 | detailed ready list information and unit/insn info. For @var{n} greater | |
19852 | than two, it includes RTL at abort point, control-flow and regions info. | |
19853 | And for @var{n} over four, @option{-fsched-verbose} also includes | |
19854 | dependence info. | |
19855 | ||
19856 | ||
19857 | ||
d77de738 ML |
19858 | @opindex fdisable- |
19859 | @opindex fenable- | |
ddf6fe37 AA |
19860 | @item -fenable-@var{kind}-@var{pass} |
19861 | @itemx -fdisable-@var{kind}-@var{pass}=@var{range-list} | |
d77de738 ML |
19862 | |
19863 | This is a set of options that are used to explicitly disable/enable | |
19864 | optimization passes. These options are intended for use for debugging GCC. | |
19865 | Compiler users should use regular options for enabling/disabling | |
19866 | passes instead. | |
19867 | ||
19868 | @table @gcctabopt | |
19869 | ||
19870 | @item -fdisable-ipa-@var{pass} | |
19871 | Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is | |
19872 | statically invoked in the compiler multiple times, the pass name should be | |
19873 | appended with a sequential number starting from 1. | |
19874 | ||
19875 | @item -fdisable-rtl-@var{pass} | |
19876 | @itemx -fdisable-rtl-@var{pass}=@var{range-list} | |
19877 | Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is | |
19878 | statically invoked in the compiler multiple times, the pass name should be | |
19879 | appended with a sequential number starting from 1. @var{range-list} is a | |
19880 | comma-separated list of function ranges or assembler names. Each range is a number | |
19881 | pair separated by a colon. The range is inclusive in both ends. If the range | |
19882 | is trivial, the number pair can be simplified as a single number. If the | |
19883 | function's call graph node's @var{uid} falls within one of the specified ranges, | |
19884 | the @var{pass} is disabled for that function. The @var{uid} is shown in the | |
19885 | function header of a dump file, and the pass names can be dumped by using | |
19886 | option @option{-fdump-passes}. | |
19887 | ||
19888 | @item -fdisable-tree-@var{pass} | |
19889 | @itemx -fdisable-tree-@var{pass}=@var{range-list} | |
19890 | Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of | |
19891 | option arguments. | |
19892 | ||
19893 | @item -fenable-ipa-@var{pass} | |
19894 | Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is | |
19895 | statically invoked in the compiler multiple times, the pass name should be | |
19896 | appended with a sequential number starting from 1. | |
19897 | ||
19898 | @item -fenable-rtl-@var{pass} | |
19899 | @itemx -fenable-rtl-@var{pass}=@var{range-list} | |
19900 | Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument | |
19901 | description and examples. | |
19902 | ||
19903 | @item -fenable-tree-@var{pass} | |
19904 | @itemx -fenable-tree-@var{pass}=@var{range-list} | |
19905 | Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description | |
19906 | of option arguments. | |
19907 | ||
19908 | @end table | |
19909 | ||
19910 | Here are some examples showing uses of these options. | |
19911 | ||
19912 | @smallexample | |
19913 | ||
19914 | # disable ccp1 for all functions | |
19915 | -fdisable-tree-ccp1 | |
19916 | # disable complete unroll for function whose cgraph node uid is 1 | |
19917 | -fenable-tree-cunroll=1 | |
19918 | # disable gcse2 for functions at the following ranges [1,1], | |
19919 | # [300,400], and [400,1000] | |
19920 | # disable gcse2 for functions foo and foo2 | |
19921 | -fdisable-rtl-gcse2=foo,foo2 | |
19922 | # disable early inlining | |
19923 | -fdisable-tree-einline | |
19924 | # disable ipa inlining | |
19925 | -fdisable-ipa-inline | |
19926 | # enable tree full unroll | |
19927 | -fenable-tree-unroll | |
19928 | ||
19929 | @end smallexample | |
19930 | ||
d77de738 ML |
19931 | @opindex fchecking |
19932 | @opindex fno-checking | |
ddf6fe37 AA |
19933 | @item -fchecking |
19934 | @itemx -fchecking=@var{n} | |
d77de738 ML |
19935 | Enable internal consistency checking. The default depends on |
19936 | the compiler configuration. @option{-fchecking=2} enables further | |
19937 | internal consistency checking that might affect code generation. | |
19938 | ||
d77de738 | 19939 | @opindex frandom-seed |
ddf6fe37 | 19940 | @item -frandom-seed=@var{string} |
d77de738 ML |
19941 | This option provides a seed that GCC uses in place of |
19942 | random numbers in generating certain symbol names | |
19943 | that have to be different in every compiled file. It is also used to | |
19944 | place unique stamps in coverage data files and the object files that | |
19945 | produce them. You can use the @option{-frandom-seed} option to produce | |
19946 | reproducibly identical object files. | |
19947 | ||
19948 | The @var{string} can either be a number (decimal, octal or hex) or an | |
19949 | arbitrary string (in which case it's converted to a number by | |
19950 | computing CRC32). | |
19951 | ||
19952 | The @var{string} should be different for every file you compile. | |
19953 | ||
d77de738 | 19954 | @opindex save-temps |
ddf6fe37 | 19955 | @item -save-temps |
d77de738 ML |
19956 | Store the usual ``temporary'' intermediate files permanently; name them |
19957 | as auxiliary output files, as specified described under | |
19958 | @option{-dumpbase} and @option{-dumpdir}. | |
19959 | ||
19960 | When used in combination with the @option{-x} command-line option, | |
19961 | @option{-save-temps} is sensible enough to avoid overwriting an | |
19962 | input source file with the same extension as an intermediate file. | |
19963 | The corresponding intermediate file may be obtained by renaming the | |
19964 | source file before using @option{-save-temps}. | |
19965 | ||
d77de738 | 19966 | @opindex save-temps=cwd |
ddf6fe37 | 19967 | @item -save-temps=cwd |
d77de738 ML |
19968 | Equivalent to @option{-save-temps -dumpdir ./}. |
19969 | ||
d77de738 | 19970 | @opindex save-temps=obj |
ddf6fe37 | 19971 | @item -save-temps=obj |
d77de738 ML |
19972 | Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where |
19973 | @file{outdir/} is the directory of the output file specified after the | |
19974 | @option{-o} option, including any directory separators. If the | |
19975 | @option{-o} option is not used, the @option{-save-temps=obj} switch | |
19976 | behaves like @option{-save-temps=cwd}. | |
19977 | ||
d77de738 | 19978 | @opindex time |
ddf6fe37 | 19979 | @item -time@r{[}=@var{file}@r{]} |
d77de738 ML |
19980 | Report the CPU time taken by each subprocess in the compilation |
19981 | sequence. For C source files, this is the compiler proper and assembler | |
19982 | (plus the linker if linking is done). | |
19983 | ||
19984 | Without the specification of an output file, the output looks like this: | |
19985 | ||
19986 | @smallexample | |
19987 | # cc1 0.12 0.01 | |
19988 | # as 0.00 0.01 | |
19989 | @end smallexample | |
19990 | ||
19991 | The first number on each line is the ``user time'', that is time spent | |
19992 | executing the program itself. The second number is ``system time'', | |
19993 | time spent executing operating system routines on behalf of the program. | |
19994 | Both numbers are in seconds. | |
19995 | ||
19996 | With the specification of an output file, the output is appended to the | |
19997 | named file, and it looks like this: | |
19998 | ||
19999 | @smallexample | |
20000 | 0.12 0.01 cc1 @var{options} | |
20001 | 0.00 0.01 as @var{options} | |
20002 | @end smallexample | |
20003 | ||
20004 | The ``user time'' and the ``system time'' are moved before the program | |
20005 | name, and the options passed to the program are displayed, so that one | |
20006 | can later tell what file was being compiled, and with which options. | |
20007 | ||
d77de738 | 20008 | @opindex fdump-final-insns |
ddf6fe37 | 20009 | @item -fdump-final-insns@r{[}=@var{file}@r{]} |
d77de738 ML |
20010 | Dump the final internal representation (RTL) to @var{file}. If the |
20011 | optional argument is omitted (or if @var{file} is @code{.}), the name | |
20012 | of the dump file is determined by appending @code{.gkd} to the | |
20013 | dump base name, see @option{-dumpbase}. | |
20014 | ||
d77de738 ML |
20015 | @opindex fcompare-debug |
20016 | @opindex fno-compare-debug | |
ddf6fe37 | 20017 | @item -fcompare-debug@r{[}=@var{opts}@r{]} |
d77de738 ML |
20018 | If no error occurs during compilation, run the compiler a second time, |
20019 | adding @var{opts} and @option{-fcompare-debug-second} to the arguments | |
20020 | passed to the second compilation. Dump the final internal | |
20021 | representation in both compilations, and print an error if they differ. | |
20022 | ||
20023 | If the equal sign is omitted, the default @option{-gtoggle} is used. | |
20024 | ||
20025 | The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty | |
20026 | and nonzero, implicitly enables @option{-fcompare-debug}. If | |
20027 | @env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash, | |
20028 | then it is used for @var{opts}, otherwise the default @option{-gtoggle} | |
20029 | is used. | |
20030 | ||
20031 | @option{-fcompare-debug=}, with the equal sign but without @var{opts}, | |
20032 | is equivalent to @option{-fno-compare-debug}, which disables the dumping | |
20033 | of the final representation and the second compilation, preventing even | |
20034 | @env{GCC_COMPARE_DEBUG} from taking effect. | |
20035 | ||
20036 | To verify full coverage during @option{-fcompare-debug} testing, set | |
20037 | @env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden}, | |
20038 | which GCC rejects as an invalid option in any actual compilation | |
20039 | (rather than preprocessing, assembly or linking). To get just a | |
20040 | warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug | |
20041 | not overridden} will do. | |
20042 | ||
d77de738 | 20043 | @opindex fcompare-debug-second |
ddf6fe37 | 20044 | @item -fcompare-debug-second |
d77de738 ML |
20045 | This option is implicitly passed to the compiler for the second |
20046 | compilation requested by @option{-fcompare-debug}, along with options to | |
20047 | silence warnings, and omitting other options that would cause the compiler | |
20048 | to produce output to files or to standard output as a side effect. Dump | |
20049 | files and preserved temporary files are renamed so as to contain the | |
20050 | @code{.gk} additional extension during the second compilation, to avoid | |
20051 | overwriting those generated by the first. | |
20052 | ||
20053 | When this option is passed to the compiler driver, it causes the | |
20054 | @emph{first} compilation to be skipped, which makes it useful for little | |
20055 | other than debugging the compiler proper. | |
20056 | ||
d77de738 | 20057 | @opindex gtoggle |
ddf6fe37 | 20058 | @item -gtoggle |
d77de738 ML |
20059 | Turn off generation of debug info, if leaving out this option |
20060 | generates it, or turn it on at level 2 otherwise. The position of this | |
20061 | argument in the command line does not matter; it takes effect after all | |
20062 | other options are processed, and it does so only once, no matter how | |
20063 | many times it is given. This is mainly intended to be used with | |
20064 | @option{-fcompare-debug}. | |
20065 | ||
d77de738 ML |
20066 | @opindex fvar-tracking-assignments-toggle |
20067 | @opindex fno-var-tracking-assignments-toggle | |
ddf6fe37 | 20068 | @item -fvar-tracking-assignments-toggle |
d77de738 ML |
20069 | Toggle @option{-fvar-tracking-assignments}, in the same way that |
20070 | @option{-gtoggle} toggles @option{-g}. | |
20071 | ||
d77de738 | 20072 | @opindex Q |
ddf6fe37 | 20073 | @item -Q |
d77de738 ML |
20074 | Makes the compiler print out each function name as it is compiled, and |
20075 | print some statistics about each pass when it finishes. | |
20076 | ||
d77de738 | 20077 | @opindex ftime-report |
ddf6fe37 | 20078 | @item -ftime-report |
75d62394 DM |
20079 | Makes the compiler print some statistics to stderr about the time consumed |
20080 | by each pass when it finishes. | |
20081 | ||
20082 | If SARIF output of diagnostics was requested via | |
20083 | @option{-fdiagnostics-format=sarif-file} or | |
20084 | @option{-fdiagnostics-format=sarif-stderr} then the @option{-ftime-report} | |
20085 | information is instead emitted in JSON form as part of SARIF output. The | |
20086 | precise format of this JSON data is subject to change, and the values may | |
20087 | not exactly match those emitted to stderr due to being written out at a | |
20088 | slightly different place within the compiler. | |
d77de738 | 20089 | |
d77de738 | 20090 | @opindex ftime-report-details |
ddf6fe37 | 20091 | @item -ftime-report-details |
d77de738 ML |
20092 | Record the time consumed by infrastructure parts separately for each pass. |
20093 | ||
d77de738 | 20094 | @opindex fira-verbose |
ddf6fe37 | 20095 | @item -fira-verbose=@var{n} |
d77de738 ML |
20096 | Control the verbosity of the dump file for the integrated register allocator. |
20097 | The default value is 5. If the value @var{n} is greater or equal to 10, | |
20098 | the dump output is sent to stderr using the same format as @var{n} minus 10. | |
20099 | ||
d77de738 | 20100 | @opindex flto-report |
ddf6fe37 | 20101 | @item -flto-report |
d77de738 ML |
20102 | Prints a report with internal details on the workings of the link-time |
20103 | optimizer. The contents of this report vary from version to version. | |
20104 | It is meant to be useful to GCC developers when processing object | |
20105 | files in LTO mode (via @option{-flto}). | |
20106 | ||
20107 | Disabled by default. | |
20108 | ||
d77de738 | 20109 | @opindex flto-report-wpa |
ddf6fe37 | 20110 | @item -flto-report-wpa |
d77de738 ML |
20111 | Like @option{-flto-report}, but only print for the WPA phase of link-time |
20112 | optimization. | |
20113 | ||
d77de738 | 20114 | @opindex fmem-report |
ddf6fe37 | 20115 | @item -fmem-report |
d77de738 ML |
20116 | Makes the compiler print some statistics about permanent memory |
20117 | allocation when it finishes. | |
20118 | ||
d77de738 | 20119 | @opindex fmem-report-wpa |
ddf6fe37 | 20120 | @item -fmem-report-wpa |
d77de738 ML |
20121 | Makes the compiler print some statistics about permanent memory |
20122 | allocation for the WPA phase only. | |
20123 | ||
d77de738 | 20124 | @opindex fpre-ipa-mem-report |
d77de738 | 20125 | @opindex fpost-ipa-mem-report |
ddf6fe37 AA |
20126 | @item -fpre-ipa-mem-report |
20127 | @item -fpost-ipa-mem-report | |
d77de738 ML |
20128 | Makes the compiler print some statistics about permanent memory |
20129 | allocation before or after interprocedural optimization. | |
20130 | ||
d77de738 | 20131 | @opindex fmultiflags |
ddf6fe37 | 20132 | @item -fmultiflags |
d77de738 ML |
20133 | This option enables multilib-aware @code{TFLAGS} to be used to build |
20134 | target libraries with options different from those the compiler is | |
20135 | configured to use by default, through the use of specs (@xref{Spec | |
20136 | Files}) set up by compiler internals, by the target, or by builders at | |
20137 | configure time. | |
20138 | ||
20139 | Like @code{TFLAGS}, this allows the target libraries to be built for | |
20140 | portable baseline environments, while the compiler defaults to more | |
20141 | demanding ones. That's useful because users can easily override the | |
20142 | defaults the compiler is configured to use to build their own programs, | |
20143 | if the defaults are not ideal for their target environment, whereas | |
20144 | rebuilding the runtime libraries is usually not as easy or desirable. | |
20145 | ||
20146 | Unlike @code{TFLAGS}, the use of specs enables different flags to be | |
20147 | selected for different multilibs. The way to accomplish that is to | |
20148 | build with @samp{make TFLAGS=-fmultiflags}, after configuring | |
20149 | @samp{--with-specs=%@{fmultiflags:...@}}. | |
20150 | ||
20151 | This option is discarded by the driver once it's done processing driver | |
20152 | self spec. | |
20153 | ||
20154 | It is also useful to check that @code{TFLAGS} are being used to build | |
20155 | all target libraries, by configuring a non-bootstrap compiler | |
20156 | @samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building | |
20157 | the compiler and target libraries. | |
20158 | ||
d77de738 | 20159 | @opindex fprofile-report |
ddf6fe37 | 20160 | @item -fprofile-report |
d77de738 ML |
20161 | Makes the compiler print some statistics about consistency of the |
20162 | (estimated) profile and effect of individual passes. | |
20163 | ||
d77de738 | 20164 | @opindex fstack-usage |
ddf6fe37 | 20165 | @item -fstack-usage |
d77de738 ML |
20166 | Makes the compiler output stack usage information for the program, on a |
20167 | per-function basis. The filename for the dump is made by appending | |
20168 | @file{.su} to the @var{auxname}. @var{auxname} is generated from the name of | |
20169 | the output file, if explicitly specified and it is not an executable, | |
20170 | otherwise it is the basename of the source file. An entry is made up | |
20171 | of three fields: | |
20172 | ||
20173 | @itemize | |
20174 | @item | |
20175 | The name of the function. | |
20176 | @item | |
20177 | A number of bytes. | |
20178 | @item | |
20179 | One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}. | |
20180 | @end itemize | |
20181 | ||
20182 | The qualifier @code{static} means that the function manipulates the stack | |
20183 | statically: a fixed number of bytes are allocated for the frame on function | |
20184 | entry and released on function exit; no stack adjustments are otherwise made | |
20185 | in the function. The second field is this fixed number of bytes. | |
20186 | ||
20187 | The qualifier @code{dynamic} means that the function manipulates the stack | |
20188 | dynamically: in addition to the static allocation described above, stack | |
20189 | adjustments are made in the body of the function, for example to push/pop | |
20190 | arguments around function calls. If the qualifier @code{bounded} is also | |
20191 | present, the amount of these adjustments is bounded at compile time and | |
20192 | the second field is an upper bound of the total amount of stack used by | |
20193 | the function. If it is not present, the amount of these adjustments is | |
20194 | not bounded at compile time and the second field only represents the | |
20195 | bounded part. | |
20196 | ||
d77de738 | 20197 | @opindex fstats |
ddf6fe37 | 20198 | @item -fstats |
d77de738 ML |
20199 | Emit statistics about front-end processing at the end of the compilation. |
20200 | This option is supported only by the C++ front end, and | |
20201 | the information is generally only useful to the G++ development team. | |
20202 | ||
d77de738 | 20203 | @opindex fdbg-cnt-list |
ddf6fe37 | 20204 | @item -fdbg-cnt-list |
d77de738 ML |
20205 | Print the name and the counter upper bound for all debug counters. |
20206 | ||
20207 | ||
d77de738 | 20208 | @opindex fdbg-cnt |
ddf6fe37 | 20209 | @item -fdbg-cnt=@var{counter-value-list} |
d77de738 ML |
20210 | Set the internal debug counter lower and upper bound. @var{counter-value-list} |
20211 | is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1} | |
20212 | [:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets | |
20213 | the name of the counter and list of closed intervals. | |
20214 | The @var{lower_bound} is optional and is zero | |
20215 | initialized if not set. | |
20216 | For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10}, | |
20217 | @code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and | |
20218 | eleventh invocation. | |
20219 | For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations. | |
20220 | ||
d77de738 | 20221 | @opindex print-file-name |
ddf6fe37 | 20222 | @item -print-file-name=@var{library} |
d77de738 ML |
20223 | Print the full absolute name of the library file @var{library} that |
20224 | would be used when linking---and don't do anything else. With this | |
20225 | option, GCC does not compile or link anything; it just prints the | |
20226 | file name. | |
20227 | ||
d77de738 | 20228 | @opindex print-multi-directory |
ddf6fe37 | 20229 | @item -print-multi-directory |
d77de738 ML |
20230 | Print the directory name corresponding to the multilib selected by any |
20231 | other switches present in the command line. This directory is supposed | |
20232 | to exist in @env{GCC_EXEC_PREFIX}. | |
20233 | ||
d77de738 | 20234 | @opindex print-multi-lib |
ddf6fe37 | 20235 | @item -print-multi-lib |
d77de738 ML |
20236 | Print the mapping from multilib directory names to compiler switches |
20237 | that enable them. The directory name is separated from the switches by | |
20238 | @samp{;}, and each switch starts with an @samp{@@} instead of the | |
20239 | @samp{-}, without spaces between multiple switches. This is supposed to | |
20240 | ease shell processing. | |
20241 | ||
d77de738 | 20242 | @opindex print-multi-os-directory |
ddf6fe37 | 20243 | @item -print-multi-os-directory |
d77de738 ML |
20244 | Print the path to OS libraries for the selected |
20245 | multilib, relative to some @file{lib} subdirectory. If OS libraries are | |
20246 | present in the @file{lib} subdirectory and no multilibs are used, this is | |
20247 | usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}} | |
20248 | sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or | |
20249 | @file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}} | |
20250 | subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}. | |
20251 | ||
d77de738 | 20252 | @opindex print-multiarch |
ddf6fe37 | 20253 | @item -print-multiarch |
d77de738 ML |
20254 | Print the path to OS libraries for the selected multiarch, |
20255 | relative to some @file{lib} subdirectory. | |
20256 | ||
d77de738 | 20257 | @opindex print-prog-name |
ddf6fe37 | 20258 | @item -print-prog-name=@var{program} |
d77de738 ML |
20259 | Like @option{-print-file-name}, but searches for a program such as @command{cpp}. |
20260 | ||
d77de738 | 20261 | @opindex print-libgcc-file-name |
ddf6fe37 | 20262 | @item -print-libgcc-file-name |
d77de738 ML |
20263 | Same as @option{-print-file-name=libgcc.a}. |
20264 | ||
20265 | This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs} | |
20266 | but you do want to link with @file{libgcc.a}. You can do: | |
20267 | ||
20268 | @smallexample | |
20269 | gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name` | |
20270 | @end smallexample | |
20271 | ||
d77de738 | 20272 | @opindex print-search-dirs |
ddf6fe37 | 20273 | @item -print-search-dirs |
d77de738 ML |
20274 | Print the name of the configured installation directory and a list of |
20275 | program and library directories @command{gcc} searches---and don't do anything else. | |
20276 | ||
20277 | This is useful when @command{gcc} prints the error message | |
20278 | @samp{installation problem, cannot exec cpp0: No such file or directory}. | |
20279 | To resolve this you either need to put @file{cpp0} and the other compiler | |
20280 | components where @command{gcc} expects to find them, or you can set the environment | |
20281 | variable @env{GCC_EXEC_PREFIX} to the directory where you installed them. | |
20282 | Don't forget the trailing @samp{/}. | |
20283 | @xref{Environment Variables}. | |
20284 | ||
d77de738 | 20285 | @opindex print-sysroot |
ddf6fe37 | 20286 | @item -print-sysroot |
d77de738 ML |
20287 | Print the target sysroot directory that is used during |
20288 | compilation. This is the target sysroot specified either at configure | |
20289 | time or using the @option{--sysroot} option, possibly with an extra | |
20290 | suffix that depends on compilation options. If no target sysroot is | |
20291 | specified, the option prints nothing. | |
20292 | ||
d77de738 | 20293 | @opindex print-sysroot-headers-suffix |
ddf6fe37 | 20294 | @item -print-sysroot-headers-suffix |
d77de738 ML |
20295 | Print the suffix added to the target sysroot when searching for |
20296 | headers, or give an error if the compiler is not configured with such | |
20297 | a suffix---and don't do anything else. | |
20298 | ||
d77de738 | 20299 | @opindex dumpmachine |
ddf6fe37 | 20300 | @item -dumpmachine |
d77de738 ML |
20301 | Print the compiler's target machine (for example, |
20302 | @samp{i686-pc-linux-gnu})---and don't do anything else. | |
20303 | ||
d77de738 | 20304 | @opindex dumpversion |
ddf6fe37 | 20305 | @item -dumpversion |
d77de738 ML |
20306 | Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do |
20307 | anything else. This is the compiler version used in filesystem paths and | |
20308 | specs. Depending on how the compiler has been configured it can be just | |
20309 | a single number (major version), two numbers separated by a dot (major and | |
20310 | minor version) or three numbers separated by dots (major, minor and patchlevel | |
20311 | version). | |
20312 | ||
d77de738 | 20313 | @opindex dumpfullversion |
ddf6fe37 | 20314 | @item -dumpfullversion |
d77de738 ML |
20315 | Print the full compiler version---and don't do anything else. The output is |
20316 | always three numbers separated by dots, major, minor and patchlevel version. | |
20317 | ||
d77de738 | 20318 | @opindex dumpspecs |
ddf6fe37 | 20319 | @item -dumpspecs |
d77de738 ML |
20320 | Print the compiler's built-in specs---and don't do anything else. (This |
20321 | is used when GCC itself is being built.) @xref{Spec Files}. | |
20322 | @end table | |
20323 | ||
20324 | @node Submodel Options | |
20325 | @section Machine-Dependent Options | |
20326 | @cindex submodel options | |
20327 | @cindex specifying hardware config | |
20328 | @cindex hardware models and configurations, specifying | |
20329 | @cindex target-dependent options | |
20330 | @cindex machine-dependent options | |
20331 | ||
20332 | Each target machine supported by GCC can have its own options---for | |
20333 | example, to allow you to compile for a particular processor variant or | |
20334 | ABI, or to control optimizations specific to that machine. By | |
20335 | convention, the names of machine-specific options start with | |
20336 | @samp{-m}. | |
20337 | ||
20338 | Some configurations of the compiler also support additional target-specific | |
20339 | options, usually for compatibility with other compilers on the same | |
20340 | platform. | |
20341 | ||
20342 | @c This list is ordered alphanumerically by subsection name. | |
20343 | @c It should be the same order and spelling as these options are listed | |
20344 | @c in Machine Dependent Options | |
20345 | ||
20346 | @menu | |
20347 | * AArch64 Options:: | |
20348 | * Adapteva Epiphany Options:: | |
20349 | * AMD GCN Options:: | |
20350 | * ARC Options:: | |
20351 | * ARM Options:: | |
20352 | * AVR Options:: | |
20353 | * Blackfin Options:: | |
20354 | * C6X Options:: | |
20355 | * CRIS Options:: | |
20356 | * C-SKY Options:: | |
20357 | * Darwin Options:: | |
20358 | * DEC Alpha Options:: | |
20359 | * eBPF Options:: | |
20360 | * FR30 Options:: | |
20361 | * FT32 Options:: | |
20362 | * FRV Options:: | |
20363 | * GNU/Linux Options:: | |
20364 | * H8/300 Options:: | |
20365 | * HPPA Options:: | |
20366 | * IA-64 Options:: | |
20367 | * LM32 Options:: | |
20368 | * LoongArch Options:: | |
20369 | * M32C Options:: | |
20370 | * M32R/D Options:: | |
20371 | * M680x0 Options:: | |
20372 | * MCore Options:: | |
d77de738 ML |
20373 | * MicroBlaze Options:: |
20374 | * MIPS Options:: | |
20375 | * MMIX Options:: | |
20376 | * MN10300 Options:: | |
20377 | * Moxie Options:: | |
20378 | * MSP430 Options:: | |
20379 | * NDS32 Options:: | |
20380 | * Nios II Options:: | |
20381 | * Nvidia PTX Options:: | |
20382 | * OpenRISC Options:: | |
20383 | * PDP-11 Options:: | |
d77de738 ML |
20384 | * PowerPC Options:: |
20385 | * PRU Options:: | |
20386 | * RISC-V Options:: | |
20387 | * RL78 Options:: | |
20388 | * RS/6000 and PowerPC Options:: | |
20389 | * RX Options:: | |
20390 | * S/390 and zSeries Options:: | |
d77de738 ML |
20391 | * SH Options:: |
20392 | * Solaris 2 Options:: | |
20393 | * SPARC Options:: | |
20394 | * System V Options:: | |
20395 | * V850 Options:: | |
20396 | * VAX Options:: | |
20397 | * Visium Options:: | |
20398 | * VMS Options:: | |
20399 | * VxWorks Options:: | |
20400 | * x86 Options:: | |
20401 | * x86 Windows Options:: | |
20402 | * Xstormy16 Options:: | |
20403 | * Xtensa Options:: | |
20404 | * zSeries Options:: | |
20405 | @end menu | |
20406 | ||
20407 | @node AArch64 Options | |
20408 | @subsection AArch64 Options | |
20409 | @cindex AArch64 Options | |
20410 | ||
20411 | These options are defined for AArch64 implementations: | |
20412 | ||
20413 | @table @gcctabopt | |
20414 | ||
d77de738 | 20415 | @opindex mabi |
ddf6fe37 | 20416 | @item -mabi=@var{name} |
d77de738 ML |
20417 | Generate code for the specified data model. Permissible values |
20418 | are @samp{ilp32} for SysV-like data model where int, long int and pointers | |
20419 | are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits, | |
20420 | but long int and pointers are 64 bits. | |
20421 | ||
20422 | The default depends on the specific target configuration. Note that | |
20423 | the LP64 and ILP32 ABIs are not link-compatible; you must compile your | |
20424 | entire program with the same ABI, and link with a compatible set of libraries. | |
20425 | ||
d77de738 | 20426 | @opindex mbig-endian |
ddf6fe37 | 20427 | @item -mbig-endian |
d77de738 ML |
20428 | Generate big-endian code. This is the default when GCC is configured for an |
20429 | @samp{aarch64_be-*-*} target. | |
20430 | ||
d77de738 | 20431 | @opindex mgeneral-regs-only |
ddf6fe37 | 20432 | @item -mgeneral-regs-only |
d77de738 ML |
20433 | Generate code which uses only the general-purpose registers. This will prevent |
20434 | the compiler from using floating-point and Advanced SIMD registers but will not | |
20435 | impose any restrictions on the assembler. | |
20436 | ||
d77de738 | 20437 | @opindex mlittle-endian |
ddf6fe37 | 20438 | @item -mlittle-endian |
d77de738 ML |
20439 | Generate little-endian code. This is the default when GCC is configured for an |
20440 | @samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target. | |
20441 | ||
d77de738 | 20442 | @opindex mcmodel=tiny |
ddf6fe37 | 20443 | @item -mcmodel=tiny |
d77de738 ML |
20444 | Generate code for the tiny code model. The program and its statically defined |
20445 | symbols must be within 1MB of each other. Programs can be statically or | |
20446 | dynamically linked. | |
20447 | ||
d77de738 | 20448 | @opindex mcmodel=small |
ddf6fe37 | 20449 | @item -mcmodel=small |
d77de738 ML |
20450 | Generate code for the small code model. The program and its statically defined |
20451 | symbols must be within 4GB of each other. Programs can be statically or | |
20452 | dynamically linked. This is the default code model. | |
20453 | ||
d77de738 | 20454 | @opindex mcmodel=large |
ddf6fe37 | 20455 | @item -mcmodel=large |
d77de738 ML |
20456 | Generate code for the large code model. This makes no assumptions about |
20457 | addresses and sizes of sections. Programs can be statically linked only. The | |
20458 | @option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32}, | |
20459 | @option{-fpic} and @option{-fPIC}. | |
20460 | ||
573624ec KT |
20461 | @item -mtp=@var{name} |
20462 | @opindex mtp | |
20463 | Specify the system register to use as a thread pointer. The valid values | |
4389a2d2 KT |
20464 | are @samp{tpidr_el0}, @samp{tpidrro_el0}, @samp{tpidr_el1}, @samp{tpidr_el2}, |
20465 | @samp{tpidr_el3}. For backwards compatibility the aliases @samp{el0}, | |
20466 | @samp{el1}, @samp{el2}, @samp{el3} are also accepted. | |
20467 | The default setting is @samp{tpidr_el0}. It is recommended to compile all | |
20468 | code intended to interoperate with the same value of this option to avoid | |
20469 | accessing a different thread pointer from the wrong exception level. | |
573624ec | 20470 | |
d77de738 ML |
20471 | @opindex mstrict-align |
20472 | @opindex mno-strict-align | |
ddf6fe37 AA |
20473 | @item -mstrict-align |
20474 | @itemx -mno-strict-align | |
d77de738 ML |
20475 | Avoid or allow generating memory accesses that may not be aligned on a natural |
20476 | object boundary as described in the architecture specification. | |
20477 | ||
d77de738 ML |
20478 | @opindex momit-leaf-frame-pointer |
20479 | @opindex mno-omit-leaf-frame-pointer | |
ddf6fe37 AA |
20480 | @item -momit-leaf-frame-pointer |
20481 | @itemx -mno-omit-leaf-frame-pointer | |
d77de738 ML |
20482 | Omit or keep the frame pointer in leaf functions. The former behavior is the |
20483 | default. | |
20484 | ||
d77de738 ML |
20485 | @opindex mstack-protector-guard |
20486 | @opindex mstack-protector-guard-reg | |
20487 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
20488 | @item -mstack-protector-guard=@var{guard} |
20489 | @itemx -mstack-protector-guard-reg=@var{reg} | |
20490 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
20491 | Generate stack protection code using canary at @var{guard}. Supported |
20492 | locations are @samp{global} for a global canary or @samp{sysreg} for a | |
20493 | canary in an appropriate system register. | |
20494 | ||
20495 | With the latter choice the options | |
20496 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
20497 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
20498 | which system register to use as base register for reading the canary, | |
20499 | and from what offset from that base register. There is no default | |
20500 | register or offset as this is entirely for use within the Linux | |
20501 | kernel. | |
20502 | ||
d77de738 | 20503 | @opindex mtls-dialect=desc |
ddf6fe37 | 20504 | @item -mtls-dialect=desc |
d77de738 ML |
20505 | Use TLS descriptors as the thread-local storage mechanism for dynamic accesses |
20506 | of TLS variables. This is the default. | |
20507 | ||
d77de738 | 20508 | @opindex mtls-dialect=traditional |
ddf6fe37 | 20509 | @item -mtls-dialect=traditional |
d77de738 ML |
20510 | Use traditional TLS as the thread-local storage mechanism for dynamic accesses |
20511 | of TLS variables. | |
20512 | ||
d77de738 | 20513 | @opindex mtls-size |
ddf6fe37 | 20514 | @item -mtls-size=@var{size} |
d77de738 ML |
20515 | Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48. |
20516 | This option requires binutils 2.26 or newer. | |
20517 | ||
d77de738 ML |
20518 | @opindex mfix-cortex-a53-835769 |
20519 | @opindex mno-fix-cortex-a53-835769 | |
ddf6fe37 AA |
20520 | @item -mfix-cortex-a53-835769 |
20521 | @itemx -mno-fix-cortex-a53-835769 | |
d77de738 ML |
20522 | Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769. |
20523 | This involves inserting a NOP instruction between memory instructions and | |
20524 | 64-bit integer multiply-accumulate instructions. | |
20525 | ||
d77de738 ML |
20526 | @opindex mfix-cortex-a53-843419 |
20527 | @opindex mno-fix-cortex-a53-843419 | |
ddf6fe37 AA |
20528 | @item -mfix-cortex-a53-843419 |
20529 | @itemx -mno-fix-cortex-a53-843419 | |
d77de738 ML |
20530 | Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419. |
20531 | This erratum workaround is made at link time and this will only pass the | |
20532 | corresponding flag to the linker. | |
20533 | ||
d77de738 ML |
20534 | @opindex mlow-precision-recip-sqrt |
20535 | @opindex mno-low-precision-recip-sqrt | |
ddf6fe37 AA |
20536 | @item -mlow-precision-recip-sqrt |
20537 | @itemx -mno-low-precision-recip-sqrt | |
d77de738 ML |
20538 | Enable or disable the reciprocal square root approximation. |
20539 | This option only has an effect if @option{-ffast-math} or | |
20540 | @option{-funsafe-math-optimizations} is used as well. Enabling this reduces | |
20541 | precision of reciprocal square root results to about 16 bits for | |
20542 | single precision and to 32 bits for double precision. | |
20543 | ||
d77de738 ML |
20544 | @opindex mlow-precision-sqrt |
20545 | @opindex mno-low-precision-sqrt | |
ddf6fe37 AA |
20546 | @item -mlow-precision-sqrt |
20547 | @itemx -mno-low-precision-sqrt | |
d77de738 ML |
20548 | Enable or disable the square root approximation. |
20549 | This option only has an effect if @option{-ffast-math} or | |
20550 | @option{-funsafe-math-optimizations} is used as well. Enabling this reduces | |
20551 | precision of square root results to about 16 bits for | |
20552 | single precision and to 32 bits for double precision. | |
20553 | If enabled, it implies @option{-mlow-precision-recip-sqrt}. | |
20554 | ||
d77de738 ML |
20555 | @opindex mlow-precision-div |
20556 | @opindex mno-low-precision-div | |
ddf6fe37 AA |
20557 | @item -mlow-precision-div |
20558 | @itemx -mno-low-precision-div | |
d77de738 ML |
20559 | Enable or disable the division approximation. |
20560 | This option only has an effect if @option{-ffast-math} or | |
20561 | @option{-funsafe-math-optimizations} is used as well. Enabling this reduces | |
20562 | precision of division results to about 16 bits for | |
20563 | single precision and to 32 bits for double precision. | |
20564 | ||
20565 | @item -mtrack-speculation | |
20566 | @itemx -mno-track-speculation | |
20567 | Enable or disable generation of additional code to track speculative | |
20568 | execution through conditional branches. The tracking state can then | |
20569 | be used by the compiler when expanding calls to | |
20570 | @code{__builtin_speculation_safe_copy} to permit a more efficient code | |
20571 | sequence to be generated. | |
20572 | ||
20573 | @item -moutline-atomics | |
20574 | @itemx -mno-outline-atomics | |
20575 | Enable or disable calls to out-of-line helpers to implement atomic operations. | |
20576 | These helpers will, at runtime, determine if the LSE instructions from | |
20577 | ARMv8.1-A can be used; if not, they will use the load/store-exclusive | |
20578 | instructions that are present in the base ARMv8.0 ISA. | |
20579 | ||
20580 | This option is only applicable when compiling for the base ARMv8.0 | |
20581 | instruction set. If using a later revision, e.g. @option{-march=armv8.1-a} | |
20582 | or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be | |
20583 | used directly. The same applies when using @option{-mcpu=} when the | |
20584 | selected cpu supports the @samp{lse} feature. | |
20585 | This option is on by default. | |
20586 | ||
d77de738 | 20587 | @opindex march |
ddf6fe37 | 20588 | @item -march=@var{name} |
d77de738 ML |
20589 | Specify the name of the target architecture and, optionally, one or |
20590 | more feature modifiers. This option has the form | |
20591 | @option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}. | |
20592 | ||
20593 | The table below summarizes the permissible values for @var{arch} | |
20594 | and the features that they enable by default: | |
20595 | ||
20596 | @multitable @columnfractions 0.20 0.20 0.60 | |
20597 | @headitem @var{arch} value @tab Architecture @tab Includes by default | |
20598 | @item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd} | |
20599 | @item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma} | |
20600 | @item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a} | |
20601 | @item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth} | |
20602 | @item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod} | |
20603 | @item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres} | |
20604 | @item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm} | |
20605 | @item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+ls64} | |
20606 | @item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops} | |
20607 | @item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2} | |
20608 | @item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm} | |
20609 | @item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+ls64} | |
20610 | @item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops} | |
20611 | @item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r} | |
20612 | @end multitable | |
20613 | ||
20614 | The value @samp{native} is available on native AArch64 GNU/Linux and | |
20615 | causes the compiler to pick the architecture of the host system. This | |
20616 | option has no effect if the compiler is unable to recognize the | |
20617 | architecture of the host system, | |
20618 | ||
20619 | The permissible values for @var{feature} are listed in the sub-section | |
20620 | on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu} | |
20621 | Feature Modifiers}. Where conflicting feature modifiers are | |
20622 | specified, the right-most feature is used. | |
20623 | ||
20624 | GCC uses @var{name} to determine what kind of instructions it can emit | |
20625 | when generating assembly code. If @option{-march} is specified | |
20626 | without either of @option{-mtune} or @option{-mcpu} also being | |
20627 | specified, the code is tuned to perform well across a range of target | |
20628 | processors implementing the target architecture. | |
20629 | ||
d77de738 | 20630 | @opindex mtune |
ddf6fe37 | 20631 | @item -mtune=@var{name} |
d77de738 ML |
20632 | Specify the name of the target processor for which GCC should tune the |
20633 | performance of the code. Permissible values for this option are: | |
20634 | @samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, | |
20635 | @samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, | |
20636 | @samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77}, | |
20637 | @samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34}, | |
20638 | @samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, | |
20639 | @samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor}, | |
20640 | @samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1}, | |
20641 | @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{qdf24xx}, | |
20642 | @samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan}, | |
20643 | @samp{octeontx}, @samp{octeontx81}, @samp{octeontx83}, | |
20644 | @samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96} | |
20645 | @samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n}, | |
20646 | @samp{octeontx2f95mm}, | |
20647 | @samp{a64fx}, | |
20648 | @samp{thunderx}, @samp{thunderxt88}, | |
20649 | @samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110}, | |
20650 | @samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus}, | |
20651 | @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
20652 | @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53}, | |
20653 | @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}, | |
ce51e843 | 20654 | @samp{cortex-r82}, @samp{cortex-x1}, @samp{cortex-x1c}, @samp{cortex-x2}, |
3bfde22c SJ |
20655 | @samp{cortex-x3}, @samp{cortex-x4}, @samp{cortex-a510}, @samp{cortex-a520}, |
20656 | @samp{cortex-a710}, @samp{cortex-a715}, @samp{cortex-a720}, @samp{ampere1}, | |
20657 | @samp{ampere1a}, and @samp{native}. | |
d77de738 ML |
20658 | |
20659 | The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
20660 | @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53}, | |
20661 | @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55} specify that GCC | |
20662 | should tune for a big.LITTLE system. | |
20663 | ||
20664 | The value @samp{neoverse-512tvb} specifies that GCC should tune | |
20665 | for Neoverse cores that (a) implement SVE and (b) have a total vector | |
20666 | bandwidth of 512 bits per cycle. In other words, the option tells GCC to | |
20667 | tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic | |
20668 | instructions a cycle and that can execute an equivalent number of SVE | |
20669 | arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE). | |
20670 | This is more general than tuning for a specific core like Neoverse V1 | |
20671 | but is more specific than the default tuning described below. | |
20672 | ||
20673 | Additionally on native AArch64 GNU/Linux systems the value | |
20674 | @samp{native} tunes performance to the host system. This option has no effect | |
20675 | if the compiler is unable to recognize the processor of the host system. | |
20676 | ||
20677 | Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=} | |
20678 | are specified, the code is tuned to perform well across a range | |
20679 | of target processors. | |
20680 | ||
20681 | This option cannot be suffixed by feature modifiers. | |
20682 | ||
d77de738 | 20683 | @opindex mcpu |
ddf6fe37 | 20684 | @item -mcpu=@var{name} |
d77de738 ML |
20685 | Specify the name of the target processor, optionally suffixed by one |
20686 | or more feature modifiers. This option has the form | |
20687 | @option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where | |
20688 | the permissible values for @var{cpu} are the same as those available | |
20689 | for @option{-mtune}. The permissible values for @var{feature} are | |
20690 | documented in the sub-section on | |
20691 | @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu} | |
20692 | Feature Modifiers}. Where conflicting feature modifiers are | |
20693 | specified, the right-most feature is used. | |
20694 | ||
20695 | GCC uses @var{name} to determine what kind of instructions it can emit when | |
20696 | generating assembly code (as if by @option{-march}) and to determine | |
20697 | the target processor for which to tune for performance (as if | |
20698 | by @option{-mtune}). Where this option is used in conjunction | |
20699 | with @option{-march} or @option{-mtune}, those options take precedence | |
20700 | over the appropriate part of this option. | |
20701 | ||
20702 | @option{-mcpu=neoverse-512tvb} is special in that it does not refer | |
20703 | to a specific core, but instead refers to all Neoverse cores that | |
20704 | (a) implement SVE and (b) have a total vector bandwidth of 512 bits | |
20705 | a cycle. Unless overridden by @option{-march}, | |
20706 | @option{-mcpu=neoverse-512tvb} generates code that can run on a | |
20707 | Neoverse V1 core, since Neoverse V1 is the first Neoverse core with | |
20708 | these properties. Unless overridden by @option{-mtune}, | |
20709 | @option{-mcpu=neoverse-512tvb} tunes code in the same way as for | |
20710 | @option{-mtune=neoverse-512tvb}. | |
20711 | ||
d77de738 | 20712 | @opindex moverride |
ddf6fe37 | 20713 | @item -moverride=@var{string} |
d77de738 ML |
20714 | Override tuning decisions made by the back-end in response to a |
20715 | @option{-mtune=} switch. The syntax, semantics, and accepted values | |
20716 | for @var{string} in this option are not guaranteed to be consistent | |
20717 | across releases. | |
20718 | ||
20719 | This option is only intended to be useful when developing GCC. | |
20720 | ||
d77de738 | 20721 | @opindex mverbose-cost-dump |
ddf6fe37 | 20722 | @item -mverbose-cost-dump |
d77de738 ML |
20723 | Enable verbose cost model dumping in the debug dump files. This option is |
20724 | provided for use in debugging the compiler. | |
20725 | ||
d77de738 ML |
20726 | @opindex mpc-relative-literal-loads |
20727 | @opindex mno-pc-relative-literal-loads | |
ddf6fe37 AA |
20728 | @item -mpc-relative-literal-loads |
20729 | @itemx -mno-pc-relative-literal-loads | |
d77de738 ML |
20730 | Enable or disable PC-relative literal loads. With this option literal pools are |
20731 | accessed using a single instruction and emitted after each function. This | |
20732 | limits the maximum size of functions to 1MB. This is enabled by default for | |
20733 | @option{-mcmodel=tiny}. | |
20734 | ||
d77de738 | 20735 | @opindex msign-return-address |
ddf6fe37 | 20736 | @item -msign-return-address=@var{scope} |
d77de738 ML |
20737 | Select the function scope on which return address signing will be applied. |
20738 | Permissible values are @samp{none}, which disables return address signing, | |
20739 | @samp{non-leaf}, which enables pointer signing for functions which are not leaf | |
20740 | functions, and @samp{all}, which enables pointer signing for all functions. The | |
20741 | default value is @samp{none}. This option has been deprecated by | |
20742 | -mbranch-protection. | |
20743 | ||
d77de738 | 20744 | @opindex mbranch-protection |
ddf6fe37 | 20745 | @item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti} |
d77de738 ML |
20746 | Select the branch protection features to use. |
20747 | @samp{none} is the default and turns off all types of branch protection. | |
20748 | @samp{standard} turns on all types of branch protection features. If a feature | |
20749 | has additional tuning options, then @samp{standard} sets it to its standard | |
20750 | level. | |
20751 | @samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard | |
20752 | level: signing functions that save the return address to memory (non-leaf | |
20753 | functions will practically always do this) using the a-key. The optional | |
20754 | argument @samp{leaf} can be used to extend the signing to include leaf | |
20755 | functions. The optional argument @samp{b-key} can be used to sign the functions | |
20756 | with the B-key instead of the A-key. | |
20757 | @samp{bti} turns on branch target identification mechanism. | |
20758 | ||
d77de738 | 20759 | @opindex mharden-sls |
ddf6fe37 | 20760 | @item -mharden-sls=@var{opts} |
d77de738 ML |
20761 | Enable compiler hardening against straight line speculation (SLS). |
20762 | @var{opts} is a comma-separated list of the following options: | |
20763 | @table @samp | |
20764 | @item retbr | |
20765 | @item blr | |
20766 | @end table | |
20767 | In addition, @samp{-mharden-sls=all} enables all SLS hardening while | |
20768 | @samp{-mharden-sls=none} disables all SLS hardening. | |
20769 | ||
d77de738 | 20770 | @opindex msve-vector-bits |
ddf6fe37 | 20771 | @item -msve-vector-bits=@var{bits} |
d77de738 ML |
20772 | Specify the number of bits in an SVE vector register. This option only has |
20773 | an effect when SVE is enabled. | |
20774 | ||
20775 | GCC supports two forms of SVE code generation: ``vector-length | |
20776 | agnostic'' output that works with any size of vector register and | |
20777 | ``vector-length specific'' output that allows GCC to make assumptions | |
20778 | about the vector length when it is useful for optimization reasons. | |
20779 | The possible values of @samp{bits} are: @samp{scalable}, @samp{128}, | |
20780 | @samp{256}, @samp{512}, @samp{1024} and @samp{2048}. | |
20781 | Specifying @samp{scalable} selects vector-length agnostic | |
20782 | output. At present @samp{-msve-vector-bits=128} also generates vector-length | |
20783 | agnostic output for big-endian targets. All other values generate | |
20784 | vector-length specific code. The behavior of these values may change | |
20785 | in future releases and no value except @samp{scalable} should be | |
20786 | relied on for producing code that is portable across different | |
20787 | hardware SVE vector lengths. | |
20788 | ||
20789 | The default is @samp{-msve-vector-bits=scalable}, which produces | |
20790 | vector-length agnostic code. | |
20791 | @end table | |
20792 | ||
20793 | @subsubsection @option{-march} and @option{-mcpu} Feature Modifiers | |
20794 | @anchor{aarch64-feature-modifiers} | |
20795 | @cindex @option{-march} feature modifiers | |
20796 | @cindex @option{-mcpu} feature modifiers | |
20797 | Feature modifiers used with @option{-march} and @option{-mcpu} can be any of | |
20798 | the following and their inverses @option{no@var{feature}}: | |
20799 | ||
20800 | @table @samp | |
20801 | @item crc | |
20802 | Enable CRC extension. This is on by default for | |
20803 | @option{-march=armv8.1-a}. | |
20804 | @item crypto | |
20805 | Enable Crypto extension. This also enables Advanced SIMD and floating-point | |
20806 | instructions. | |
20807 | @item fp | |
20808 | Enable floating-point instructions. This is on by default for all possible | |
20809 | values for options @option{-march} and @option{-mcpu}. | |
20810 | @item simd | |
20811 | Enable Advanced SIMD instructions. This also enables floating-point | |
20812 | instructions. This is on by default for all possible values for options | |
20813 | @option{-march} and @option{-mcpu}. | |
20814 | @item sve | |
20815 | Enable Scalable Vector Extension instructions. This also enables Advanced | |
20816 | SIMD and floating-point instructions. | |
20817 | @item lse | |
20818 | Enable Large System Extension instructions. This is on by default for | |
20819 | @option{-march=armv8.1-a}. | |
20820 | @item rdma | |
20821 | Enable Round Double Multiply Accumulate instructions. This is on by default | |
20822 | for @option{-march=armv8.1-a}. | |
20823 | @item fp16 | |
20824 | Enable FP16 extension. This also enables floating-point instructions. | |
20825 | @item fp16fml | |
20826 | Enable FP16 fmla extension. This also enables FP16 extensions and | |
20827 | 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. | |
20828 | ||
20829 | @item rcpc | |
0431e8ae AV |
20830 | Enable the RCpc extension. This enables the use of the LDAPR instructions for |
20831 | load-acquire atomic semantics, and passes it on to the assembler, enabling | |
20832 | inline asm statements to use instructions from the RCpc extension. | |
d77de738 ML |
20833 | @item dotprod |
20834 | Enable the Dot Product extension. This also enables Advanced SIMD instructions. | |
20835 | @item aes | |
20836 | Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced | |
20837 | SIMD instructions. | |
20838 | @item sha2 | |
20839 | Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions. | |
20840 | @item sha3 | |
20841 | Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD | |
20842 | instructions. Use of this option with architectures prior to Armv8.2-A is not supported. | |
20843 | @item sm4 | |
20844 | Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions. | |
20845 | Use of this option with architectures prior to Armv8.2-A is not supported. | |
20846 | @item profile | |
20847 | Enable the Statistical Profiling extension. This option is only to enable the | |
20848 | extension at the assembler level and does not affect code generation. | |
20849 | @item rng | |
20850 | Enable the Armv8.5-a Random Number instructions. This option is only to | |
20851 | enable the extension at the assembler level and does not affect code | |
20852 | generation. | |
20853 | @item memtag | |
20854 | Enable the Armv8.5-a Memory Tagging Extensions. | |
20855 | Use of this option with architectures prior to Armv8.5-A is not supported. | |
20856 | @item sb | |
20857 | Enable the Armv8-a Speculation Barrier instruction. This option is only to | |
20858 | enable the extension at the assembler level and does not affect code | |
20859 | generation. This option is enabled by default for @option{-march=armv8.5-a}. | |
20860 | @item ssbs | |
20861 | Enable the Armv8-a Speculative Store Bypass Safe instruction. This option | |
20862 | is only to enable the extension at the assembler level and does not affect code | |
20863 | generation. This option is enabled by default for @option{-march=armv8.5-a}. | |
20864 | @item predres | |
20865 | Enable the Armv8-a Execution and Data Prediction Restriction instructions. | |
20866 | This option is only to enable the extension at the assembler level and does | |
20867 | not affect code generation. This option is enabled by default for | |
20868 | @option{-march=armv8.5-a}. | |
20869 | @item sve2 | |
20870 | Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE | |
20871 | instructions. | |
20872 | @item sve2-bitperm | |
20873 | Enable SVE2 bitperm instructions. This also enables SVE2 instructions. | |
20874 | @item sve2-sm4 | |
20875 | Enable SVE2 sm4 instructions. This also enables SVE2 instructions. | |
20876 | @item sve2-aes | |
20877 | Enable SVE2 aes instructions. This also enables SVE2 instructions. | |
20878 | @item sve2-sha3 | |
20879 | Enable SVE2 sha3 instructions. This also enables SVE2 instructions. | |
20880 | @item tme | |
20881 | Enable the Transactional Memory Extension. | |
20882 | @item i8mm | |
20883 | Enable 8-bit Integer Matrix Multiply instructions. This also enables | |
20884 | Advanced SIMD and floating-point instructions. This option is enabled by | |
20885 | default for @option{-march=armv8.6-a}. Use of this option with architectures | |
20886 | prior to Armv8.2-A is not supported. | |
20887 | @item f32mm | |
20888 | Enable 32-bit Floating point Matrix Multiply instructions. This also enables | |
20889 | SVE instructions. Use of this option with architectures prior to Armv8.2-A is | |
20890 | not supported. | |
20891 | @item f64mm | |
20892 | Enable 64-bit Floating point Matrix Multiply instructions. This also enables | |
20893 | SVE instructions. Use of this option with architectures prior to Armv8.2-A is | |
20894 | not supported. | |
20895 | @item bf16 | |
20896 | Enable brain half-precision floating-point instructions. This also enables | |
20897 | Advanced SIMD and floating-point instructions. This option is enabled by | |
20898 | default for @option{-march=armv8.6-a}. Use of this option with architectures | |
20899 | prior to Armv8.2-A is not supported. | |
20900 | @item ls64 | |
20901 | Enable the 64-byte atomic load and store instructions for accelerators. | |
20902 | This option is enabled by default for @option{-march=armv8.7-a}. | |
20903 | @item mops | |
20904 | Enable the instructions to accelerate memory operations like @code{memcpy}, | |
20905 | @code{memmove}, @code{memset}. This option is enabled by default for | |
20906 | @option{-march=armv8.8-a} | |
20907 | @item flagm | |
20908 | Enable the Flag Manipulation instructions Extension. | |
20909 | @item pauth | |
20910 | Enable the Pointer Authentication Extension. | |
d758d190 KT |
20911 | @item cssc |
20912 | Enable the Common Short Sequence Compression instructions. | |
d77de738 ML |
20913 | |
20914 | @end table | |
20915 | ||
20916 | Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd}, | |
20917 | which implies @option{fp}. | |
20918 | Conversely, @option{nofp} implies @option{nosimd}, which implies | |
20919 | @option{nocrypto}, @option{noaes} and @option{nosha2}. | |
20920 | ||
20921 | @node Adapteva Epiphany Options | |
20922 | @subsection Adapteva Epiphany Options | |
20923 | ||
20924 | These @samp{-m} options are defined for Adapteva Epiphany: | |
20925 | ||
20926 | @table @gcctabopt | |
d77de738 | 20927 | @opindex mhalf-reg-file |
ddf6fe37 | 20928 | @item -mhalf-reg-file |
d77de738 ML |
20929 | Don't allocate any register in the range @code{r32}@dots{}@code{r63}. |
20930 | That allows code to run on hardware variants that lack these registers. | |
20931 | ||
d77de738 | 20932 | @opindex mprefer-short-insn-regs |
ddf6fe37 | 20933 | @item -mprefer-short-insn-regs |
d77de738 ML |
20934 | Preferentially allocate registers that allow short instruction generation. |
20935 | This can result in increased instruction count, so this may either reduce or | |
20936 | increase overall code size. | |
20937 | ||
d77de738 | 20938 | @opindex mbranch-cost |
ddf6fe37 | 20939 | @item -mbranch-cost=@var{num} |
d77de738 ML |
20940 | Set the cost of branches to roughly @var{num} ``simple'' instructions. |
20941 | This cost is only a heuristic and is not guaranteed to produce | |
20942 | consistent results across releases. | |
20943 | ||
d77de738 | 20944 | @opindex mcmove |
ddf6fe37 | 20945 | @item -mcmove |
d77de738 ML |
20946 | Enable the generation of conditional moves. |
20947 | ||
d77de738 | 20948 | @opindex mnops |
ddf6fe37 | 20949 | @item -mnops=@var{num} |
d77de738 ML |
20950 | Emit @var{num} NOPs before every other generated instruction. |
20951 | ||
d77de738 ML |
20952 | @opindex mno-soft-cmpsf |
20953 | @opindex msoft-cmpsf | |
ddf6fe37 | 20954 | @item -mno-soft-cmpsf |
d77de738 ML |
20955 | For single-precision floating-point comparisons, emit an @code{fsub} instruction |
20956 | and test the flags. This is faster than a software comparison, but can | |
20957 | get incorrect results in the presence of NaNs, or when two different small | |
20958 | numbers are compared such that their difference is calculated as zero. | |
20959 | The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant, | |
20960 | software comparisons. | |
20961 | ||
d77de738 | 20962 | @opindex mstack-offset |
ddf6fe37 | 20963 | @item -mstack-offset=@var{num} |
d77de738 ML |
20964 | Set the offset between the top of the stack and the stack pointer. |
20965 | E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7} | |
20966 | can be used by leaf functions without stack allocation. | |
20967 | Values other than @samp{8} or @samp{16} are untested and unlikely to work. | |
20968 | Note also that this option changes the ABI; compiling a program with a | |
20969 | different stack offset than the libraries have been compiled with | |
20970 | generally does not work. | |
20971 | This option can be useful if you want to evaluate if a different stack | |
20972 | offset would give you better code, but to actually use a different stack | |
20973 | offset to build working programs, it is recommended to configure the | |
20974 | toolchain with the appropriate @option{--with-stack-offset=@var{num}} option. | |
20975 | ||
d77de738 ML |
20976 | @opindex mno-round-nearest |
20977 | @opindex mround-nearest | |
ddf6fe37 | 20978 | @item -mno-round-nearest |
d77de738 ML |
20979 | Make the scheduler assume that the rounding mode has been set to |
20980 | truncating. The default is @option{-mround-nearest}. | |
20981 | ||
d77de738 | 20982 | @opindex mlong-calls |
ddf6fe37 | 20983 | @item -mlong-calls |
d77de738 ML |
20984 | If not otherwise specified by an attribute, assume all calls might be beyond |
20985 | the offset range of the @code{b} / @code{bl} instructions, and therefore load the | |
20986 | function address into a register before performing a (otherwise direct) call. | |
20987 | This is the default. | |
20988 | ||
d77de738 | 20989 | @opindex short-calls |
ddf6fe37 | 20990 | @item -mshort-calls |
d77de738 ML |
20991 | If not otherwise specified by an attribute, assume all direct calls are |
20992 | in the range of the @code{b} / @code{bl} instructions, so use these instructions | |
20993 | for direct calls. The default is @option{-mlong-calls}. | |
20994 | ||
d77de738 | 20995 | @opindex msmall16 |
ddf6fe37 | 20996 | @item -msmall16 |
d77de738 ML |
20997 | Assume addresses can be loaded as 16-bit unsigned values. This does not |
20998 | apply to function addresses for which @option{-mlong-calls} semantics | |
20999 | are in effect. | |
21000 | ||
d77de738 | 21001 | @opindex mfp-mode |
ddf6fe37 | 21002 | @item -mfp-mode=@var{mode} |
d77de738 ML |
21003 | Set the prevailing mode of the floating-point unit. |
21004 | This determines the floating-point mode that is provided and expected | |
21005 | at function call and return time. Making this mode match the mode you | |
21006 | predominantly need at function start can make your programs smaller and | |
21007 | faster by avoiding unnecessary mode switches. | |
21008 | ||
21009 | @var{mode} can be set to one the following values: | |
21010 | ||
21011 | @table @samp | |
21012 | @item caller | |
21013 | Any mode at function entry is valid, and retained or restored when | |
21014 | the function returns, and when it calls other functions. | |
21015 | This mode is useful for compiling libraries or other compilation units | |
21016 | you might want to incorporate into different programs with different | |
21017 | prevailing FPU modes, and the convenience of being able to use a single | |
21018 | object file outweighs the size and speed overhead for any extra | |
21019 | mode switching that might be needed, compared with what would be needed | |
21020 | with a more specific choice of prevailing FPU mode. | |
21021 | ||
21022 | @item truncate | |
21023 | This is the mode used for floating-point calculations with | |
21024 | truncating (i.e.@: round towards zero) rounding mode. That includes | |
21025 | conversion from floating point to integer. | |
21026 | ||
21027 | @item round-nearest | |
21028 | This is the mode used for floating-point calculations with | |
21029 | round-to-nearest-or-even rounding mode. | |
21030 | ||
21031 | @item int | |
21032 | This is the mode used to perform integer calculations in the FPU, e.g.@: | |
21033 | integer multiply, or integer multiply-and-accumulate. | |
21034 | @end table | |
21035 | ||
21036 | The default is @option{-mfp-mode=caller} | |
21037 | ||
d77de738 ML |
21038 | @opindex mno-split-lohi |
21039 | @opindex msplit-lohi | |
21040 | @opindex mno-postinc | |
21041 | @opindex mpostinc | |
21042 | @opindex mno-postmodify | |
21043 | @opindex mpostmodify | |
ddf6fe37 AA |
21044 | @item -mno-split-lohi |
21045 | @itemx -mno-postinc | |
21046 | @itemx -mno-postmodify | |
d77de738 ML |
21047 | Code generation tweaks that disable, respectively, splitting of 32-bit |
21048 | loads, generation of post-increment addresses, and generation of | |
21049 | post-modify addresses. The defaults are @option{msplit-lohi}, | |
21050 | @option{-mpost-inc}, and @option{-mpost-modify}. | |
21051 | ||
d77de738 ML |
21052 | @opindex mno-vect-double |
21053 | @opindex mvect-double | |
ddf6fe37 | 21054 | @item -mnovect-double |
d77de738 ML |
21055 | Change the preferred SIMD mode to SImode. The default is |
21056 | @option{-mvect-double}, which uses DImode as preferred SIMD mode. | |
21057 | ||
d77de738 | 21058 | @opindex max-vect-align |
ddf6fe37 | 21059 | @item -max-vect-align=@var{num} |
d77de738 ML |
21060 | The maximum alignment for SIMD vector mode types. |
21061 | @var{num} may be 4 or 8. The default is 8. | |
21062 | Note that this is an ABI change, even though many library function | |
21063 | interfaces are unaffected if they don't use SIMD vector modes | |
21064 | in places that affect size and/or alignment of relevant types. | |
21065 | ||
d77de738 | 21066 | @opindex msplit-vecmove-early |
ddf6fe37 | 21067 | @item -msplit-vecmove-early |
d77de738 ML |
21068 | Split vector moves into single word moves before reload. In theory this |
21069 | can give better register allocation, but so far the reverse seems to be | |
21070 | generally the case. | |
21071 | ||
d77de738 | 21072 | @opindex m1reg- |
ddf6fe37 | 21073 | @item -m1reg-@var{reg} |
d77de738 ML |
21074 | Specify a register to hold the constant @minus{}1, which makes loading small negative |
21075 | constants and certain bitmasks faster. | |
21076 | Allowable values for @var{reg} are @samp{r43} and @samp{r63}, | |
21077 | which specify use of that register as a fixed register, | |
21078 | and @samp{none}, which means that no register is used for this | |
21079 | purpose. The default is @option{-m1reg-none}. | |
21080 | ||
21081 | @end table | |
21082 | ||
21083 | @node AMD GCN Options | |
21084 | @subsection AMD GCN Options | |
21085 | @cindex AMD GCN Options | |
21086 | ||
21087 | These options are defined specifically for the AMD GCN port. | |
21088 | ||
21089 | @table @gcctabopt | |
21090 | ||
d77de738 | 21091 | @opindex march |
d77de738 | 21092 | @opindex mtune |
ddf6fe37 AA |
21093 | @item -march=@var{gpu} |
21094 | @itemx -mtune=@var{gpu} | |
d77de738 ML |
21095 | Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu} |
21096 | are | |
21097 | ||
21098 | @table @samp | |
21099 | @item fiji | |
21100 | Compile for GCN3 Fiji devices (gfx803). | |
21101 | ||
21102 | @item gfx900 | |
21103 | Compile for GCN5 Vega 10 devices (gfx900). | |
21104 | ||
21105 | @item gfx906 | |
21106 | Compile for GCN5 Vega 20 devices (gfx906). | |
21107 | ||
21108 | @item gfx908 | |
21109 | Compile for CDNA1 Instinct MI100 series devices (gfx908). | |
21110 | ||
21111 | @item gfx90a | |
21112 | Compile for CDNA2 Instinct MI200 series devices (gfx90a). | |
21113 | ||
21114 | @end table | |
21115 | ||
ddf6fe37 | 21116 | @opindex msram-ecc |
d77de738 ML |
21117 | @item -msram-ecc=on |
21118 | @itemx -msram-ecc=off | |
21119 | @itemx -msram-ecc=any | |
d77de738 ML |
21120 | Compile binaries suitable for devices with the SRAM-ECC feature enabled, |
21121 | disabled, or either mode. This feature can be enabled per-process on some | |
21122 | devices. The compiled code must match the device mode. The default is | |
21123 | @samp{any}, for devices that support it. | |
21124 | ||
d77de738 | 21125 | @opindex mstack-size |
ddf6fe37 | 21126 | @item -mstack-size=@var{bytes} |
d77de738 ML |
21127 | Specify how many @var{bytes} of stack space will be requested for each GPU |
21128 | thread (wave-front). Beware that there may be many threads and limited memory | |
21129 | available. The size of the stack allocation may also have an impact on | |
21130 | run-time performance. The default is 32KB when using OpenACC or OpenMP, and | |
21131 | 1MB otherwise. | |
21132 | ||
d77de738 | 21133 | @opindex mxnack |
366e3d30 TB |
21134 | @item -mxnack=on |
21135 | @itemx -mxnack=off | |
21136 | @itemx -mxnack=any | |
21137 | Compile binaries suitable for devices with the XNACK feature enabled, disabled, | |
21138 | or either mode. Some devices always require XNACK and some allow the user to | |
21139 | configure XNACK. The compiled code must match the device mode. | |
21140 | @c The default is @samp{-mxnack=any}. | |
21141 | At present this option is a placeholder for support that is not yet implemented. | |
d77de738 ML |
21142 | |
21143 | @end table | |
21144 | ||
21145 | @node ARC Options | |
21146 | @subsection ARC Options | |
21147 | @cindex ARC options | |
21148 | ||
21149 | The following options control the architecture variant for which code | |
21150 | is being compiled: | |
21151 | ||
21152 | @c architecture variants | |
21153 | @table @gcctabopt | |
21154 | ||
d77de738 | 21155 | @opindex mbarrel-shifter |
ddf6fe37 | 21156 | @item -mbarrel-shifter |
d77de738 ML |
21157 | Generate instructions supported by barrel shifter. This is the default |
21158 | unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect. | |
21159 | ||
d77de738 | 21160 | @opindex mjli-always |
ddf6fe37 | 21161 | @item -mjli-always |
d77de738 ML |
21162 | Force to call a function using jli_s instruction. This option is |
21163 | valid only for ARCv2 architecture. | |
21164 | ||
d77de738 | 21165 | @opindex mcpu |
ddf6fe37 | 21166 | @item -mcpu=@var{cpu} |
d77de738 ML |
21167 | Set architecture type, register usage, and instruction scheduling |
21168 | parameters for @var{cpu}. There are also shortcut alias options | |
21169 | available for backward compatibility and convenience. Supported | |
21170 | values for @var{cpu} are | |
21171 | ||
21172 | @table @samp | |
21173 | @opindex mA6 | |
21174 | @opindex mARC600 | |
21175 | @item arc600 | |
21176 | Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}. | |
21177 | ||
d77de738 | 21178 | @opindex mARC601 |
ddf6fe37 | 21179 | @item arc601 |
d77de738 ML |
21180 | Compile for ARC601. Alias: @option{-mARC601}. |
21181 | ||
d77de738 ML |
21182 | @opindex mA7 |
21183 | @opindex mARC700 | |
ddf6fe37 | 21184 | @item arc700 |
d77de738 ML |
21185 | Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}. |
21186 | This is the default when configured with @option{--with-cpu=arc700}@. | |
21187 | ||
21188 | @item arcem | |
21189 | Compile for ARC EM. | |
21190 | ||
21191 | @item archs | |
21192 | Compile for ARC HS. | |
21193 | ||
21194 | @item em | |
21195 | Compile for ARC EM CPU with no hardware extensions. | |
21196 | ||
21197 | @item em4 | |
21198 | Compile for ARC EM4 CPU. | |
21199 | ||
21200 | @item em4_dmips | |
21201 | Compile for ARC EM4 DMIPS CPU. | |
21202 | ||
21203 | @item em4_fpus | |
21204 | Compile for ARC EM4 DMIPS CPU with the single-precision floating-point | |
21205 | extension. | |
21206 | ||
21207 | @item em4_fpuda | |
21208 | Compile for ARC EM4 DMIPS CPU with single-precision floating-point and | |
21209 | double assist instructions. | |
21210 | ||
21211 | @item hs | |
21212 | Compile for ARC HS CPU with no hardware extensions except the atomic | |
21213 | instructions. | |
21214 | ||
21215 | @item hs34 | |
21216 | Compile for ARC HS34 CPU. | |
21217 | ||
21218 | @item hs38 | |
21219 | Compile for ARC HS38 CPU. | |
21220 | ||
21221 | @item hs38_linux | |
21222 | Compile for ARC HS38 CPU with all hardware extensions on. | |
21223 | ||
21224 | @item hs4x | |
21225 | Compile for ARC HS4x CPU. | |
21226 | ||
21227 | @item hs4xd | |
21228 | Compile for ARC HS4xD CPU. | |
21229 | ||
21230 | @item hs4x_rel31 | |
21231 | Compile for ARC HS4x CPU release 3.10a. | |
21232 | ||
21233 | @item arc600_norm | |
21234 | Compile for ARC 600 CPU with @code{norm} instructions enabled. | |
21235 | ||
21236 | @item arc600_mul32x16 | |
21237 | Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply | |
21238 | instructions enabled. | |
21239 | ||
21240 | @item arc600_mul64 | |
21241 | Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family | |
21242 | instructions enabled. | |
21243 | ||
21244 | @item arc601_norm | |
21245 | Compile for ARC 601 CPU with @code{norm} instructions enabled. | |
21246 | ||
21247 | @item arc601_mul32x16 | |
21248 | Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply | |
21249 | instructions enabled. | |
21250 | ||
21251 | @item arc601_mul64 | |
21252 | Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family | |
21253 | instructions enabled. | |
21254 | ||
21255 | @item nps400 | |
21256 | Compile for ARC 700 on NPS400 chip. | |
21257 | ||
21258 | @item em_mini | |
21259 | Compile for ARC EM minimalist configuration featuring reduced register | |
21260 | set. | |
21261 | ||
21262 | @end table | |
21263 | ||
d77de738 | 21264 | @opindex mdpfp |
d77de738 | 21265 | @opindex mdpfp-compact |
ddf6fe37 AA |
21266 | @item -mdpfp |
21267 | @itemx -mdpfp-compact | |
d77de738 ML |
21268 | Generate double-precision FPX instructions, tuned for the compact |
21269 | implementation. | |
21270 | ||
d77de738 | 21271 | @opindex mdpfp-fast |
ddf6fe37 | 21272 | @item -mdpfp-fast |
d77de738 ML |
21273 | Generate double-precision FPX instructions, tuned for the fast |
21274 | implementation. | |
21275 | ||
d77de738 | 21276 | @opindex mno-dpfp-lrsr |
ddf6fe37 | 21277 | @item -mno-dpfp-lrsr |
d77de738 ML |
21278 | Disable @code{lr} and @code{sr} instructions from using FPX extension |
21279 | aux registers. | |
21280 | ||
d77de738 | 21281 | @opindex mea |
ddf6fe37 | 21282 | @item -mea |
d77de738 ML |
21283 | Generate extended arithmetic instructions. Currently only |
21284 | @code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are | |
21285 | supported. Only valid for @option{-mcpu=ARC700}. | |
21286 | ||
d77de738 ML |
21287 | @opindex mno-mpy |
21288 | @opindex mmpy | |
ddf6fe37 | 21289 | @item -mno-mpy |
d77de738 ML |
21290 | Do not generate @code{mpy}-family instructions for ARC700. This option is |
21291 | deprecated. | |
21292 | ||
d77de738 | 21293 | @opindex mmul32x16 |
ddf6fe37 | 21294 | @item -mmul32x16 |
d77de738 ML |
21295 | Generate 32x16-bit multiply and multiply-accumulate instructions. |
21296 | ||
d77de738 | 21297 | @opindex mmul64 |
ddf6fe37 | 21298 | @item -mmul64 |
d77de738 ML |
21299 | Generate @code{mul64} and @code{mulu64} instructions. |
21300 | Only valid for @option{-mcpu=ARC600}. | |
21301 | ||
d77de738 | 21302 | @opindex mnorm |
ddf6fe37 | 21303 | @item -mnorm |
d77de738 ML |
21304 | Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700} |
21305 | is in effect. | |
21306 | ||
d77de738 | 21307 | @opindex mspfp |
d77de738 | 21308 | @opindex mspfp-compact |
ddf6fe37 AA |
21309 | @item -mspfp |
21310 | @itemx -mspfp-compact | |
d77de738 ML |
21311 | Generate single-precision FPX instructions, tuned for the compact |
21312 | implementation. | |
21313 | ||
d77de738 | 21314 | @opindex mspfp-fast |
ddf6fe37 | 21315 | @item -mspfp-fast |
d77de738 ML |
21316 | Generate single-precision FPX instructions, tuned for the fast |
21317 | implementation. | |
21318 | ||
d77de738 | 21319 | @opindex msimd |
ddf6fe37 | 21320 | @item -msimd |
d77de738 ML |
21321 | Enable generation of ARC SIMD instructions via target-specific |
21322 | builtins. Only valid for @option{-mcpu=ARC700}. | |
21323 | ||
d77de738 | 21324 | @opindex msoft-float |
ddf6fe37 | 21325 | @item -msoft-float |
d77de738 ML |
21326 | This option ignored; it is provided for compatibility purposes only. |
21327 | Software floating-point code is emitted by default, and this default | |
21328 | can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or | |
21329 | @option{-mspfp-fast} for single precision, and @option{-mdpfp}, | |
21330 | @option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision. | |
21331 | ||
d77de738 | 21332 | @opindex mswap |
ddf6fe37 | 21333 | @item -mswap |
d77de738 ML |
21334 | Generate @code{swap} instructions. |
21335 | ||
d77de738 | 21336 | @opindex matomic |
ddf6fe37 | 21337 | @item -matomic |
d77de738 ML |
21338 | This enables use of the locked load/store conditional extension to implement |
21339 | atomic memory built-in functions. Not available for ARC 6xx or ARC | |
21340 | EM cores. | |
21341 | ||
d77de738 | 21342 | @opindex mdiv-rem |
ddf6fe37 | 21343 | @item -mdiv-rem |
d77de738 ML |
21344 | Enable @code{div} and @code{rem} instructions for ARCv2 cores. |
21345 | ||
d77de738 | 21346 | @opindex mcode-density |
ddf6fe37 | 21347 | @item -mcode-density |
d77de738 ML |
21348 | Enable code density instructions for ARC EM. |
21349 | This option is on by default for ARC HS. | |
21350 | ||
d77de738 | 21351 | @opindex mll64 |
ddf6fe37 | 21352 | @item -mll64 |
d77de738 ML |
21353 | Enable double load/store operations for ARC HS cores. |
21354 | ||
d77de738 | 21355 | @opindex mtp-regno |
ddf6fe37 | 21356 | @item -mtp-regno=@var{regno} |
d77de738 ML |
21357 | Specify thread pointer register number. |
21358 | ||
d77de738 | 21359 | @opindex mmpy-option |
ddf6fe37 | 21360 | @item -mmpy-option=@var{multo} |
d77de738 ML |
21361 | Compile ARCv2 code with a multiplier design option. You can specify |
21362 | the option using either a string or numeric value for @var{multo}. | |
21363 | @samp{wlh1} is the default value. The recognized values are: | |
21364 | ||
21365 | @table @samp | |
21366 | @item 0 | |
21367 | @itemx none | |
21368 | No multiplier available. | |
21369 | ||
21370 | @item 1 | |
21371 | @itemx w | |
21372 | 16x16 multiplier, fully pipelined. | |
21373 | The following instructions are enabled: @code{mpyw} and @code{mpyuw}. | |
21374 | ||
21375 | @item 2 | |
21376 | @itemx wlh1 | |
21377 | 32x32 multiplier, fully | |
21378 | pipelined (1 stage). The following instructions are additionally | |
21379 | enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21380 | ||
21381 | @item 3 | |
21382 | @itemx wlh2 | |
21383 | 32x32 multiplier, fully pipelined | |
21384 | (2 stages). The following instructions are additionally enabled: @code{mpy}, | |
21385 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21386 | ||
21387 | @item 4 | |
21388 | @itemx wlh3 | |
21389 | Two 16x16 multipliers, blocking, | |
21390 | sequential. The following instructions are additionally enabled: @code{mpy}, | |
21391 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21392 | ||
21393 | @item 5 | |
21394 | @itemx wlh4 | |
21395 | One 16x16 multiplier, blocking, | |
21396 | sequential. The following instructions are additionally enabled: @code{mpy}, | |
21397 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21398 | ||
21399 | @item 6 | |
21400 | @itemx wlh5 | |
21401 | One 32x4 multiplier, blocking, | |
21402 | sequential. The following instructions are additionally enabled: @code{mpy}, | |
21403 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21404 | ||
21405 | @item 7 | |
21406 | @itemx plus_dmpy | |
21407 | ARC HS SIMD support. | |
21408 | ||
21409 | @item 8 | |
21410 | @itemx plus_macd | |
21411 | ARC HS SIMD support. | |
21412 | ||
21413 | @item 9 | |
21414 | @itemx plus_qmacw | |
21415 | ARC HS SIMD support. | |
21416 | ||
21417 | @end table | |
21418 | ||
21419 | This option is only available for ARCv2 cores@. | |
21420 | ||
d77de738 | 21421 | @opindex mfpu |
ddf6fe37 | 21422 | @item -mfpu=@var{fpu} |
d77de738 ML |
21423 | Enables support for specific floating-point hardware extensions for ARCv2 |
21424 | cores. Supported values for @var{fpu} are: | |
21425 | ||
21426 | @table @samp | |
21427 | ||
21428 | @item fpus | |
21429 | Enables support for single-precision floating-point hardware | |
21430 | extensions@. | |
21431 | ||
21432 | @item fpud | |
21433 | Enables support for double-precision floating-point hardware | |
21434 | extensions. The single-precision floating-point extension is also | |
21435 | enabled. Not available for ARC EM@. | |
21436 | ||
21437 | @item fpuda | |
21438 | Enables support for double-precision floating-point hardware | |
21439 | extensions using double-precision assist instructions. The single-precision | |
21440 | floating-point extension is also enabled. This option is | |
21441 | only available for ARC EM@. | |
21442 | ||
21443 | @item fpuda_div | |
21444 | Enables support for double-precision floating-point hardware | |
21445 | extensions using double-precision assist instructions. | |
21446 | The single-precision floating-point, square-root, and divide | |
21447 | extensions are also enabled. This option is | |
21448 | only available for ARC EM@. | |
21449 | ||
21450 | @item fpuda_fma | |
21451 | Enables support for double-precision floating-point hardware | |
21452 | extensions using double-precision assist instructions. | |
21453 | The single-precision floating-point and fused multiply and add | |
21454 | hardware extensions are also enabled. This option is | |
21455 | only available for ARC EM@. | |
21456 | ||
21457 | @item fpuda_all | |
21458 | Enables support for double-precision floating-point hardware | |
21459 | extensions using double-precision assist instructions. | |
21460 | All single-precision floating-point hardware extensions are also | |
21461 | enabled. This option is only available for ARC EM@. | |
21462 | ||
21463 | @item fpus_div | |
21464 | Enables support for single-precision floating-point, square-root and divide | |
21465 | hardware extensions@. | |
21466 | ||
21467 | @item fpud_div | |
21468 | Enables support for double-precision floating-point, square-root and divide | |
21469 | hardware extensions. This option | |
21470 | includes option @samp{fpus_div}. Not available for ARC EM@. | |
21471 | ||
21472 | @item fpus_fma | |
21473 | Enables support for single-precision floating-point and | |
21474 | fused multiply and add hardware extensions@. | |
21475 | ||
21476 | @item fpud_fma | |
21477 | Enables support for double-precision floating-point and | |
21478 | fused multiply and add hardware extensions. This option | |
21479 | includes option @samp{fpus_fma}. Not available for ARC EM@. | |
21480 | ||
21481 | @item fpus_all | |
21482 | Enables support for all single-precision floating-point hardware | |
21483 | extensions@. | |
21484 | ||
21485 | @item fpud_all | |
21486 | Enables support for all single- and double-precision floating-point | |
21487 | hardware extensions. Not available for ARC EM@. | |
21488 | ||
21489 | @end table | |
21490 | ||
d77de738 | 21491 | @opindex mirq-ctrl-saved |
ddf6fe37 | 21492 | @item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count} |
d77de738 ML |
21493 | Specifies general-purposes registers that the processor automatically |
21494 | saves/restores on interrupt entry and exit. @var{register-range} is | |
21495 | specified as two registers separated by a dash. The register range | |
21496 | always starts with @code{r0}, the upper limit is @code{fp} register. | |
21497 | @var{blink} and @var{lp_count} are optional. This option is only | |
21498 | valid for ARC EM and ARC HS cores. | |
21499 | ||
d77de738 | 21500 | @opindex mrgf-banked-regs |
ddf6fe37 | 21501 | @item -mrgf-banked-regs=@var{number} |
d77de738 ML |
21502 | Specifies the number of registers replicated in second register bank |
21503 | on entry to fast interrupt. Fast interrupts are interrupts with the | |
21504 | highest priority level P0. These interrupts save only PC and STATUS32 | |
21505 | registers to avoid memory transactions during interrupt entry and exit | |
21506 | sequences. Use this option when you are using fast interrupts in an | |
21507 | ARC V2 family processor. Permitted values are 4, 8, 16, and 32. | |
21508 | ||
d77de738 | 21509 | @opindex mlpc-width |
ddf6fe37 | 21510 | @item -mlpc-width=@var{width} |
d77de738 ML |
21511 | Specify the width of the @code{lp_count} register. Valid values for |
21512 | @var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is | |
21513 | fixed to 32 bits. If the width is less than 32, the compiler does not | |
21514 | attempt to transform loops in your program to use the zero-delay loop | |
21515 | mechanism unless it is known that the @code{lp_count} register can | |
21516 | hold the required loop-counter value. Depending on the width | |
21517 | specified, the compiler and run-time library might continue to use the | |
21518 | loop mechanism for various needs. This option defines macro | |
21519 | @code{__ARC_LPC_WIDTH__} with the value of @var{width}. | |
21520 | ||
d77de738 | 21521 | @opindex mrf16 |
ddf6fe37 | 21522 | @item -mrf16 |
d77de738 ML |
21523 | This option instructs the compiler to generate code for a 16-entry |
21524 | register file. This option defines the @code{__ARC_RF16__} | |
21525 | preprocessor macro. | |
21526 | ||
d77de738 | 21527 | @opindex mbranch-index |
ddf6fe37 | 21528 | @item -mbranch-index |
d77de738 ML |
21529 | Enable use of @code{bi} or @code{bih} instructions to implement jump |
21530 | tables. | |
21531 | ||
21532 | @end table | |
21533 | ||
21534 | The following options are passed through to the assembler, and also | |
21535 | define preprocessor macro symbols. | |
21536 | ||
21537 | @c Flags used by the assembler, but for which we define preprocessor | |
21538 | @c macro symbols as well. | |
21539 | @table @gcctabopt | |
d77de738 | 21540 | @opindex mdsp-packa |
ddf6fe37 | 21541 | @item -mdsp-packa |
d77de738 ML |
21542 | Passed down to the assembler to enable the DSP Pack A extensions. |
21543 | Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is | |
21544 | deprecated. | |
21545 | ||
d77de738 | 21546 | @opindex mdvbf |
ddf6fe37 | 21547 | @item -mdvbf |
d77de738 ML |
21548 | Passed down to the assembler to enable the dual Viterbi butterfly |
21549 | extension. Also sets the preprocessor symbol @code{__Xdvbf}. This | |
21550 | option is deprecated. | |
21551 | ||
21552 | @c ARC700 4.10 extension instruction | |
d77de738 | 21553 | @opindex mlock |
ddf6fe37 | 21554 | @item -mlock |
d77de738 ML |
21555 | Passed down to the assembler to enable the locked load/store |
21556 | conditional extension. Also sets the preprocessor symbol | |
21557 | @code{__Xlock}. | |
21558 | ||
d77de738 | 21559 | @opindex mmac-d16 |
ddf6fe37 | 21560 | @item -mmac-d16 |
d77de738 ML |
21561 | Passed down to the assembler. Also sets the preprocessor symbol |
21562 | @code{__Xxmac_d16}. This option is deprecated. | |
21563 | ||
d77de738 | 21564 | @opindex mmac-24 |
ddf6fe37 | 21565 | @item -mmac-24 |
d77de738 ML |
21566 | Passed down to the assembler. Also sets the preprocessor symbol |
21567 | @code{__Xxmac_24}. This option is deprecated. | |
21568 | ||
21569 | @c ARC700 4.10 extension instruction | |
d77de738 | 21570 | @opindex mrtsc |
ddf6fe37 | 21571 | @item -mrtsc |
d77de738 ML |
21572 | Passed down to the assembler to enable the 64-bit time-stamp counter |
21573 | extension instruction. Also sets the preprocessor symbol | |
21574 | @code{__Xrtsc}. This option is deprecated. | |
21575 | ||
21576 | @c ARC700 4.10 extension instruction | |
d77de738 | 21577 | @opindex mswape |
ddf6fe37 | 21578 | @item -mswape |
d77de738 ML |
21579 | Passed down to the assembler to enable the swap byte ordering |
21580 | extension instruction. Also sets the preprocessor symbol | |
21581 | @code{__Xswape}. | |
21582 | ||
d77de738 | 21583 | @opindex mtelephony |
ddf6fe37 | 21584 | @item -mtelephony |
d77de738 ML |
21585 | Passed down to the assembler to enable dual- and single-operand |
21586 | instructions for telephony. Also sets the preprocessor symbol | |
21587 | @code{__Xtelephony}. This option is deprecated. | |
21588 | ||
d77de738 | 21589 | @opindex mxy |
ddf6fe37 | 21590 | @item -mxy |
d77de738 ML |
21591 | Passed down to the assembler to enable the XY memory extension. Also |
21592 | sets the preprocessor symbol @code{__Xxy}. | |
21593 | ||
21594 | @end table | |
21595 | ||
21596 | The following options control how the assembly code is annotated: | |
21597 | ||
21598 | @c Assembly annotation options | |
21599 | @table @gcctabopt | |
d77de738 | 21600 | @opindex misize |
ddf6fe37 | 21601 | @item -misize |
d77de738 ML |
21602 | Annotate assembler instructions with estimated addresses. |
21603 | ||
d77de738 | 21604 | @opindex mannotate-align |
ddf6fe37 | 21605 | @item -mannotate-align |
e4b19406 | 21606 | Does nothing. Preserved for backward compatibility. |
d77de738 ML |
21607 | |
21608 | @end table | |
21609 | ||
21610 | The following options are passed through to the linker: | |
21611 | ||
21612 | @c options passed through to the linker | |
21613 | @table @gcctabopt | |
d77de738 | 21614 | @opindex marclinux |
ddf6fe37 | 21615 | @item -marclinux |
d77de738 ML |
21616 | Passed through to the linker, to specify use of the @code{arclinux} emulation. |
21617 | This option is enabled by default in tool chains built for | |
21618 | @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets | |
21619 | when profiling is not requested. | |
21620 | ||
d77de738 | 21621 | @opindex marclinux_prof |
ddf6fe37 | 21622 | @item -marclinux_prof |
d77de738 ML |
21623 | Passed through to the linker, to specify use of the |
21624 | @code{arclinux_prof} emulation. This option is enabled by default in | |
21625 | tool chains built for @w{@code{arc-linux-uclibc}} and | |
21626 | @w{@code{arceb-linux-uclibc}} targets when profiling is requested. | |
21627 | ||
21628 | @end table | |
21629 | ||
21630 | The following options control the semantics of generated code: | |
21631 | ||
21632 | @c semantically relevant code generation options | |
21633 | @table @gcctabopt | |
d77de738 | 21634 | @opindex mlong-calls |
ddf6fe37 | 21635 | @item -mlong-calls |
d77de738 ML |
21636 | Generate calls as register indirect calls, thus providing access |
21637 | to the full 32-bit address range. | |
21638 | ||
d77de738 | 21639 | @opindex mmedium-calls |
ddf6fe37 | 21640 | @item -mmedium-calls |
d77de738 ML |
21641 | Don't use less than 25-bit addressing range for calls, which is the |
21642 | offset available for an unconditional branch-and-link | |
21643 | instruction. Conditional execution of function calls is suppressed, to | |
21644 | allow use of the 25-bit range, rather than the 21-bit range with | |
21645 | conditional branch-and-link. This is the default for tool chains built | |
21646 | for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets. | |
21647 | ||
d77de738 | 21648 | @opindex G |
ddf6fe37 | 21649 | @item -G @var{num} |
d77de738 ML |
21650 | Put definitions of externally-visible data in a small data section if |
21651 | that data is no bigger than @var{num} bytes. The default value of | |
21652 | @var{num} is 4 for any ARC configuration, or 8 when we have double | |
21653 | load/store operations. | |
21654 | ||
d77de738 ML |
21655 | @opindex mno-sdata |
21656 | @opindex msdata | |
ddf6fe37 | 21657 | @item -mno-sdata |
d77de738 ML |
21658 | Do not generate sdata references. This is the default for tool chains |
21659 | built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} | |
21660 | targets. | |
21661 | ||
d77de738 | 21662 | @opindex mvolatile-cache |
ddf6fe37 | 21663 | @item -mvolatile-cache |
d77de738 ML |
21664 | Use ordinarily cached memory accesses for volatile references. This is the |
21665 | default. | |
21666 | ||
d77de738 ML |
21667 | @opindex mno-volatile-cache |
21668 | @opindex mvolatile-cache | |
ddf6fe37 | 21669 | @item -mno-volatile-cache |
d77de738 ML |
21670 | Enable cache bypass for volatile references. |
21671 | ||
21672 | @end table | |
21673 | ||
21674 | The following options fine tune code generation: | |
21675 | @c code generation tuning options | |
21676 | @table @gcctabopt | |
d77de738 | 21677 | @opindex malign-call |
ddf6fe37 | 21678 | @item -malign-call |
d77de738 ML |
21679 | Does nothing. Preserved for backward compatibility. |
21680 | ||
d77de738 | 21681 | @opindex mauto-modify-reg |
ddf6fe37 | 21682 | @item -mauto-modify-reg |
d77de738 ML |
21683 | Enable the use of pre/post modify with register displacement. |
21684 | ||
d77de738 | 21685 | @opindex mbbit-peephole |
ddf6fe37 | 21686 | @item -mbbit-peephole |
07f7615c | 21687 | Does nothing. Preserved for backward compatibility. |
d77de738 | 21688 | |
d77de738 | 21689 | @opindex mno-brcc |
ddf6fe37 | 21690 | @item -mno-brcc |
d77de738 ML |
21691 | This option disables a target-specific pass in @file{arc_reorg} to |
21692 | generate compare-and-branch (@code{br@var{cc}}) instructions. | |
21693 | It has no effect on | |
21694 | generation of these instructions driven by the combiner pass. | |
21695 | ||
d77de738 | 21696 | @opindex mcase-vector-pcrel |
ddf6fe37 | 21697 | @item -mcase-vector-pcrel |
d77de738 ML |
21698 | Use PC-relative switch case tables to enable case table shortening. |
21699 | This is the default for @option{-Os}. | |
21700 | ||
d77de738 | 21701 | @opindex mcompact-casesi |
ddf6fe37 | 21702 | @item -mcompact-casesi |
d77de738 ML |
21703 | Enable compact @code{casesi} pattern. This is the default for @option{-Os}, |
21704 | and only available for ARCv1 cores. This option is deprecated. | |
21705 | ||
d77de738 | 21706 | @opindex mno-cond-exec |
ddf6fe37 | 21707 | @item -mno-cond-exec |
d77de738 ML |
21708 | Disable the ARCompact-specific pass to generate conditional |
21709 | execution instructions. | |
21710 | ||
21711 | Due to delay slot scheduling and interactions between operand numbers, | |
21712 | literal sizes, instruction lengths, and the support for conditional execution, | |
21713 | the target-independent pass to generate conditional execution is often lacking, | |
21714 | so the ARC port has kept a special pass around that tries to find more | |
21715 | conditional execution generation opportunities after register allocation, | |
21716 | branch shortening, and delay slot scheduling have been done. This pass | |
21717 | generally, but not always, improves performance and code size, at the cost of | |
21718 | extra compilation time, which is why there is an option to switch it off. | |
21719 | If you have a problem with call instructions exceeding their allowable | |
21720 | offset range because they are conditionalized, you should consider using | |
21721 | @option{-mmedium-calls} instead. | |
21722 | ||
d77de738 | 21723 | @opindex mearly-cbranchsi |
ddf6fe37 | 21724 | @item -mearly-cbranchsi |
d77de738 ML |
21725 | Enable pre-reload use of the @code{cbranchsi} pattern. |
21726 | ||
d77de738 | 21727 | @opindex mexpand-adddi |
ddf6fe37 | 21728 | @item -mexpand-adddi |
d77de738 ML |
21729 | Expand @code{adddi3} and @code{subdi3} at RTL generation time into |
21730 | @code{add.f}, @code{adc} etc. This option is deprecated. | |
21731 | ||
d77de738 | 21732 | @opindex mindexed-loads |
ddf6fe37 | 21733 | @item -mindexed-loads |
d77de738 ML |
21734 | Enable the use of indexed loads. This can be problematic because some |
21735 | optimizers then assume that indexed stores exist, which is not | |
21736 | the case. | |
21737 | ||
d77de738 | 21738 | @opindex mlra |
ddf6fe37 | 21739 | @item -mlra |
d77de738 ML |
21740 | Enable Local Register Allocation. This is still experimental for ARC, |
21741 | so by default the compiler uses standard reload | |
21742 | (i.e.@: @option{-mno-lra}). | |
21743 | ||
d77de738 | 21744 | @opindex mlra-priority-none |
ddf6fe37 | 21745 | @item -mlra-priority-none |
d77de738 ML |
21746 | Don't indicate any priority for target registers. |
21747 | ||
d77de738 | 21748 | @opindex mlra-priority-compact |
ddf6fe37 | 21749 | @item -mlra-priority-compact |
d77de738 ML |
21750 | Indicate target register priority for r0..r3 / r12..r15. |
21751 | ||
d77de738 | 21752 | @opindex mlra-priority-noncompact |
ddf6fe37 | 21753 | @item -mlra-priority-noncompact |
d77de738 ML |
21754 | Reduce target register priority for r0..r3 / r12..r15. |
21755 | ||
d77de738 | 21756 | @opindex mmillicode |
ddf6fe37 | 21757 | @item -mmillicode |
d77de738 ML |
21758 | When optimizing for size (using @option{-Os}), prologues and epilogues |
21759 | that have to save or restore a large number of registers are often | |
21760 | shortened by using call to a special function in libgcc; this is | |
21761 | referred to as a @emph{millicode} call. As these calls can pose | |
21762 | performance issues, and/or cause linking issues when linking in a | |
21763 | nonstandard way, this option is provided to turn on or off millicode | |
21764 | call generation. | |
21765 | ||
d77de738 | 21766 | @opindex mcode-density-frame |
ddf6fe37 | 21767 | @item -mcode-density-frame |
d77de738 ML |
21768 | This option enable the compiler to emit @code{enter} and @code{leave} |
21769 | instructions. These instructions are only valid for CPUs with | |
21770 | code-density feature. | |
21771 | ||
d77de738 | 21772 | @opindex mmixed-code |
ddf6fe37 | 21773 | @item -mmixed-code |
d77de738 ML |
21774 | Does nothing. Preserved for backward compatibility. |
21775 | ||
d77de738 | 21776 | @opindex mq-class |
ddf6fe37 | 21777 | @item -mq-class |
d77de738 ML |
21778 | Ths option is deprecated. Enable @samp{q} instruction alternatives. |
21779 | This is the default for @option{-Os}. | |
21780 | ||
d77de738 | 21781 | @opindex mRcq |
ddf6fe37 | 21782 | @item -mRcq |
d77de738 ML |
21783 | Does nothing. Preserved for backward compatibility. |
21784 | ||
d77de738 | 21785 | @opindex mRcw |
ddf6fe37 | 21786 | @item -mRcw |
d77de738 ML |
21787 | Does nothing. Preserved for backward compatibility. |
21788 | ||
d77de738 | 21789 | @opindex msize-level |
ddf6fe37 | 21790 | @item -msize-level=@var{level} |
d77de738 ML |
21791 | Fine-tune size optimization with regards to instruction lengths and alignment. |
21792 | The recognized values for @var{level} are: | |
21793 | @table @samp | |
21794 | @item 0 | |
21795 | No size optimization. This level is deprecated and treated like @samp{1}. | |
21796 | ||
21797 | @item 1 | |
21798 | Short instructions are used opportunistically. | |
21799 | ||
21800 | @item 2 | |
21801 | In addition, alignment of loops and of code after barriers are dropped. | |
21802 | ||
21803 | @item 3 | |
21804 | In addition, optional data alignment is dropped, and the option @option{Os} is enabled. | |
21805 | ||
21806 | @end table | |
21807 | ||
21808 | This defaults to @samp{3} when @option{-Os} is in effect. Otherwise, | |
21809 | the behavior when this is not set is equivalent to level @samp{1}. | |
21810 | ||
d77de738 | 21811 | @opindex mtune |
ddf6fe37 | 21812 | @item -mtune=@var{cpu} |
d77de738 ML |
21813 | Set instruction scheduling parameters for @var{cpu}, overriding any implied |
21814 | by @option{-mcpu=}. | |
21815 | ||
21816 | Supported values for @var{cpu} are | |
21817 | ||
21818 | @table @samp | |
21819 | @item ARC600 | |
21820 | Tune for ARC600 CPU. | |
21821 | ||
21822 | @item ARC601 | |
21823 | Tune for ARC601 CPU. | |
21824 | ||
21825 | @item ARC700 | |
21826 | Tune for ARC700 CPU with standard multiplier block. | |
21827 | ||
21828 | @item ARC700-xmac | |
21829 | Tune for ARC700 CPU with XMAC block. | |
21830 | ||
21831 | @item ARC725D | |
21832 | Tune for ARC725D CPU. | |
21833 | ||
21834 | @item ARC750D | |
21835 | Tune for ARC750D CPU. | |
21836 | ||
21837 | @item core3 | |
21838 | Tune for ARCv2 core3 type CPU. This option enable usage of | |
21839 | @code{dbnz} instruction. | |
21840 | ||
21841 | @item release31a | |
21842 | Tune for ARC4x release 3.10a. | |
21843 | ||
21844 | @end table | |
21845 | ||
d77de738 | 21846 | @opindex mmultcost |
ddf6fe37 | 21847 | @item -mmultcost=@var{num} |
d77de738 ML |
21848 | Cost to assume for a multiply instruction, with @samp{4} being equal to a |
21849 | normal instruction. | |
21850 | ||
d77de738 | 21851 | @opindex munalign-prob-threshold |
ddf6fe37 | 21852 | @item -munalign-prob-threshold=@var{probability} |
d77de738 ML |
21853 | Does nothing. Preserved for backward compatibility. |
21854 | ||
21855 | @end table | |
21856 | ||
21857 | The following options are maintained for backward compatibility, but | |
21858 | are now deprecated and will be removed in a future release: | |
21859 | ||
21860 | @c Deprecated options | |
21861 | @table @gcctabopt | |
21862 | ||
d77de738 | 21863 | @opindex margonaut |
ddf6fe37 | 21864 | @item -margonaut |
d77de738 ML |
21865 | Obsolete FPX. |
21866 | ||
d77de738 | 21867 | @opindex mbig-endian |
d77de738 | 21868 | @opindex EB |
ddf6fe37 AA |
21869 | @item -mbig-endian |
21870 | @itemx -EB | |
d77de738 ML |
21871 | Compile code for big-endian targets. Use of these options is now |
21872 | deprecated. Big-endian code is supported by configuring GCC to build | |
21873 | @w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets, | |
21874 | for which big endian is the default. | |
21875 | ||
d77de738 | 21876 | @opindex mlittle-endian |
d77de738 | 21877 | @opindex EL |
ddf6fe37 AA |
21878 | @item -mlittle-endian |
21879 | @itemx -EL | |
d77de738 ML |
21880 | Compile code for little-endian targets. Use of these options is now |
21881 | deprecated. Little-endian code is supported by configuring GCC to build | |
21882 | @w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets, | |
21883 | for which little endian is the default. | |
21884 | ||
d77de738 | 21885 | @opindex mbarrel_shifter |
ddf6fe37 | 21886 | @item -mbarrel_shifter |
d77de738 ML |
21887 | Replaced by @option{-mbarrel-shifter}. |
21888 | ||
d77de738 | 21889 | @opindex mdpfp_compact |
ddf6fe37 | 21890 | @item -mdpfp_compact |
d77de738 ML |
21891 | Replaced by @option{-mdpfp-compact}. |
21892 | ||
d77de738 | 21893 | @opindex mdpfp_fast |
ddf6fe37 | 21894 | @item -mdpfp_fast |
d77de738 ML |
21895 | Replaced by @option{-mdpfp-fast}. |
21896 | ||
d77de738 | 21897 | @opindex mdsp_packa |
ddf6fe37 | 21898 | @item -mdsp_packa |
d77de738 ML |
21899 | Replaced by @option{-mdsp-packa}. |
21900 | ||
d77de738 | 21901 | @opindex mEA |
ddf6fe37 | 21902 | @item -mEA |
d77de738 ML |
21903 | Replaced by @option{-mea}. |
21904 | ||
d77de738 | 21905 | @opindex mmac_24 |
ddf6fe37 | 21906 | @item -mmac_24 |
d77de738 ML |
21907 | Replaced by @option{-mmac-24}. |
21908 | ||
d77de738 | 21909 | @opindex mmac_d16 |
ddf6fe37 | 21910 | @item -mmac_d16 |
d77de738 ML |
21911 | Replaced by @option{-mmac-d16}. |
21912 | ||
d77de738 | 21913 | @opindex mspfp_compact |
ddf6fe37 | 21914 | @item -mspfp_compact |
d77de738 ML |
21915 | Replaced by @option{-mspfp-compact}. |
21916 | ||
d77de738 | 21917 | @opindex mspfp_fast |
ddf6fe37 | 21918 | @item -mspfp_fast |
d77de738 ML |
21919 | Replaced by @option{-mspfp-fast}. |
21920 | ||
d77de738 | 21921 | @opindex mtune |
ddf6fe37 | 21922 | @item -mtune=@var{cpu} |
d77de738 ML |
21923 | Values @samp{arc600}, @samp{arc601}, @samp{arc700} and |
21924 | @samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600}, | |
21925 | @samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively. | |
21926 | ||
d77de738 | 21927 | @opindex multcost |
ddf6fe37 | 21928 | @item -multcost=@var{num} |
d77de738 ML |
21929 | Replaced by @option{-mmultcost}. |
21930 | ||
21931 | @end table | |
21932 | ||
21933 | @node ARM Options | |
21934 | @subsection ARM Options | |
21935 | @cindex ARM options | |
21936 | ||
21937 | These @samp{-m} options are defined for the ARM port: | |
21938 | ||
21939 | @table @gcctabopt | |
d77de738 | 21940 | @opindex mabi |
ddf6fe37 | 21941 | @item -mabi=@var{name} |
d77de738 ML |
21942 | Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu}, |
21943 | @samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}. | |
21944 | ||
d77de738 | 21945 | @opindex mapcs-frame |
ddf6fe37 | 21946 | @item -mapcs-frame |
d77de738 ML |
21947 | Generate a stack frame that is compliant with the ARM Procedure Call |
21948 | Standard for all functions, even if this is not strictly necessary for | |
21949 | correct execution of the code. Specifying @option{-fomit-frame-pointer} | |
21950 | with this option causes the stack frames not to be generated for | |
21951 | leaf functions. The default is @option{-mno-apcs-frame}. | |
21952 | This option is deprecated. | |
21953 | ||
d77de738 | 21954 | @opindex mapcs |
ddf6fe37 | 21955 | @item -mapcs |
d77de738 ML |
21956 | This is a synonym for @option{-mapcs-frame} and is deprecated. |
21957 | ||
21958 | @ignore | |
21959 | @c not currently implemented | |
d77de738 | 21960 | @opindex mapcs-stack-check |
ddf6fe37 | 21961 | @item -mapcs-stack-check |
d77de738 ML |
21962 | Generate code to check the amount of stack space available upon entry to |
21963 | every function (that actually uses some stack space). If there is | |
21964 | insufficient space available then either the function | |
21965 | @code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is | |
21966 | called, depending upon the amount of stack space required. The runtime | |
21967 | system is required to provide these functions. The default is | |
21968 | @option{-mno-apcs-stack-check}, since this produces smaller code. | |
21969 | ||
21970 | @c not currently implemented | |
d77de738 | 21971 | @opindex mapcs-reentrant |
ddf6fe37 | 21972 | @item -mapcs-reentrant |
d77de738 ML |
21973 | Generate reentrant, position-independent code. The default is |
21974 | @option{-mno-apcs-reentrant}. | |
21975 | @end ignore | |
21976 | ||
d77de738 | 21977 | @opindex mthumb-interwork |
ddf6fe37 | 21978 | @item -mthumb-interwork |
d77de738 ML |
21979 | Generate code that supports calling between the ARM and Thumb |
21980 | instruction sets. Without this option, on pre-v5 architectures, the | |
21981 | two instruction sets cannot be reliably used inside one program. The | |
21982 | default is @option{-mno-thumb-interwork}, since slightly larger code | |
21983 | is generated when @option{-mthumb-interwork} is specified. In AAPCS | |
21984 | configurations this option is meaningless. | |
21985 | ||
d77de738 ML |
21986 | @opindex mno-sched-prolog |
21987 | @opindex msched-prolog | |
ddf6fe37 | 21988 | @item -mno-sched-prolog |
d77de738 ML |
21989 | Prevent the reordering of instructions in the function prologue, or the |
21990 | merging of those instruction with the instructions in the function's | |
21991 | body. This means that all functions start with a recognizable set | |
21992 | of instructions (or in fact one of a choice from a small set of | |
21993 | different function prologues), and this information can be used to | |
21994 | locate the start of functions inside an executable piece of code. The | |
21995 | default is @option{-msched-prolog}. | |
21996 | ||
d77de738 | 21997 | @opindex mfloat-abi |
ddf6fe37 | 21998 | @item -mfloat-abi=@var{name} |
d77de738 ML |
21999 | Specifies which floating-point ABI to use. Permissible values |
22000 | are: @samp{soft}, @samp{softfp} and @samp{hard}. | |
22001 | ||
22002 | Specifying @samp{soft} causes GCC to generate output containing | |
22003 | library calls for floating-point operations. | |
22004 | @samp{softfp} allows the generation of code using hardware floating-point | |
22005 | instructions, but still uses the soft-float calling conventions. | |
22006 | @samp{hard} allows generation of floating-point instructions | |
22007 | and uses FPU-specific calling conventions. | |
22008 | ||
22009 | The default depends on the specific target configuration. Note that | |
22010 | the hard-float and soft-float ABIs are not link-compatible; you must | |
22011 | compile your entire program with the same ABI, and link with a | |
22012 | compatible set of libraries. | |
22013 | ||
d77de738 | 22014 | @opindex mgeneral-regs-only |
ddf6fe37 | 22015 | @item -mgeneral-regs-only |
d77de738 ML |
22016 | Generate code which uses only the general-purpose registers. This will prevent |
22017 | the compiler from using floating-point and Advanced SIMD registers but will not | |
22018 | impose any restrictions on the assembler. | |
22019 | ||
d77de738 | 22020 | @opindex mlittle-endian |
ddf6fe37 | 22021 | @item -mlittle-endian |
d77de738 ML |
22022 | Generate code for a processor running in little-endian mode. This is |
22023 | the default for all standard configurations. | |
22024 | ||
d77de738 | 22025 | @opindex mbig-endian |
ddf6fe37 | 22026 | @item -mbig-endian |
d77de738 ML |
22027 | Generate code for a processor running in big-endian mode; the default is |
22028 | to compile code for a little-endian processor. | |
22029 | ||
ddf6fe37 | 22030 | @opindex mbe8 |
d77de738 ML |
22031 | @item -mbe8 |
22032 | @itemx -mbe32 | |
d77de738 ML |
22033 | When linking a big-endian image select between BE8 and BE32 formats. |
22034 | The option has no effect for little-endian images and is ignored. The | |
22035 | default is dependent on the selected target architecture. For ARMv6 | |
22036 | and later architectures the default is BE8, for older architectures | |
22037 | the default is BE32. BE32 format has been deprecated by ARM. | |
22038 | ||
d77de738 | 22039 | @opindex march |
ddf6fe37 | 22040 | @item -march=@var{name}@r{[}+extension@dots{}@r{]} |
d77de738 ML |
22041 | This specifies the name of the target ARM architecture. GCC uses this |
22042 | name to determine what kind of instructions it can emit when generating | |
22043 | assembly code. This option can be used in conjunction with or instead | |
22044 | of the @option{-mcpu=} option. | |
22045 | ||
22046 | Permissible names are: | |
22047 | @samp{armv4t}, | |
22048 | @samp{armv5t}, @samp{armv5te}, | |
22049 | @samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2}, | |
22050 | @samp{armv6z}, @samp{armv6zk}, | |
22051 | @samp{armv7}, @samp{armv7-a}, @samp{armv7ve}, | |
22052 | @samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a}, | |
22053 | @samp{armv8.4-a}, | |
22054 | @samp{armv8.5-a}, | |
22055 | @samp{armv8.6-a}, | |
22056 | @samp{armv9-a}, | |
22057 | @samp{armv7-r}, | |
22058 | @samp{armv8-r}, | |
22059 | @samp{armv6-m}, @samp{armv6s-m}, | |
22060 | @samp{armv7-m}, @samp{armv7e-m}, | |
22061 | @samp{armv8-m.base}, @samp{armv8-m.main}, | |
22062 | @samp{armv8.1-m.main}, | |
22063 | @samp{armv9-a}, | |
22064 | @samp{iwmmxt} and @samp{iwmmxt2}. | |
22065 | ||
22066 | Additionally, the following architectures, which lack support for the | |
22067 | Thumb execution state, are recognized but support is deprecated: @samp{armv4}. | |
22068 | ||
22069 | Many of the architectures support extensions. These can be added by | |
22070 | appending @samp{+@var{extension}} to the architecture name. Extension | |
22071 | options are processed in order and capabilities accumulate. An extension | |
22072 | will also enable any necessary base extensions | |
22073 | upon which it depends. For example, the @samp{+crypto} extension | |
22074 | will always enable the @samp{+simd} extension. The exception to the | |
22075 | additive construction is for extensions that are prefixed with | |
22076 | @samp{+no@dots{}}: these extensions disable the specified option and | |
22077 | any other extensions that may depend on the presence of that | |
22078 | extension. | |
22079 | ||
22080 | For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to | |
22081 | writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is | |
22082 | entirely disabled by the @samp{+nofp} option that follows it. | |
22083 | ||
22084 | Most extension names are generically named, but have an effect that is | |
22085 | dependent upon the architecture to which it is applied. For example, | |
22086 | the @samp{+simd} option can be applied to both @samp{armv7-a} and | |
22087 | @samp{armv8-a} architectures, but will enable the original ARMv7-A | |
22088 | Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A | |
22089 | variant for @samp{armv8-a}. | |
22090 | ||
22091 | The table below lists the supported extensions for each architecture. | |
22092 | Architectures not mentioned do not support any extensions. | |
22093 | ||
22094 | @table @samp | |
22095 | @item armv5te | |
22096 | @itemx armv6 | |
22097 | @itemx armv6j | |
22098 | @itemx armv6k | |
22099 | @itemx armv6kz | |
22100 | @itemx armv6t2 | |
22101 | @itemx armv6z | |
22102 | @itemx armv6zk | |
22103 | @table @samp | |
22104 | @item +fp | |
22105 | The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be | |
22106 | used as an alias for this extension. | |
22107 | ||
22108 | @item +nofp | |
22109 | Disable the floating-point instructions. | |
22110 | @end table | |
22111 | ||
22112 | @item armv7 | |
22113 | The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures. | |
22114 | @table @samp | |
22115 | @item +fp | |
22116 | The VFPv3 floating-point instructions, with 16 double-precision | |
22117 | registers. The extension @samp{+vfpv3-d16} can be used as an alias | |
22118 | for this extension. Note that floating-point is not supported by the | |
22119 | base ARMv7-M architecture, but is compatible with both the ARMv7-A and | |
22120 | ARMv7-R architectures. | |
22121 | ||
22122 | @item +nofp | |
22123 | Disable the floating-point instructions. | |
22124 | @end table | |
22125 | ||
22126 | @item armv7-a | |
22127 | @table @samp | |
22128 | @item +mp | |
22129 | The multiprocessing extension. | |
22130 | ||
22131 | @item +sec | |
22132 | The security extension. | |
22133 | ||
22134 | @item +fp | |
22135 | The VFPv3 floating-point instructions, with 16 double-precision | |
22136 | registers. The extension @samp{+vfpv3-d16} can be used as an alias | |
22137 | for this extension. | |
22138 | ||
22139 | @item +simd | |
22140 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions. | |
22141 | The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases | |
22142 | for this extension. | |
22143 | ||
22144 | @item +vfpv3 | |
22145 | The VFPv3 floating-point instructions, with 32 double-precision | |
22146 | registers. | |
22147 | ||
22148 | @item +vfpv3-d16-fp16 | |
22149 | The VFPv3 floating-point instructions, with 16 double-precision | |
22150 | registers and the half-precision floating-point conversion operations. | |
22151 | ||
22152 | @item +vfpv3-fp16 | |
22153 | The VFPv3 floating-point instructions, with 32 double-precision | |
22154 | registers and the half-precision floating-point conversion operations. | |
22155 | ||
22156 | @item +vfpv4-d16 | |
22157 | The VFPv4 floating-point instructions, with 16 double-precision | |
22158 | registers. | |
22159 | ||
22160 | @item +vfpv4 | |
22161 | The VFPv4 floating-point instructions, with 32 double-precision | |
22162 | registers. | |
22163 | ||
22164 | @item +neon-fp16 | |
22165 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with | |
22166 | the half-precision floating-point conversion operations. | |
22167 | ||
22168 | @item +neon-vfpv4 | |
22169 | The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. | |
22170 | ||
22171 | @item +nosimd | |
22172 | Disable the Advanced SIMD instructions (does not disable floating point). | |
22173 | ||
22174 | @item +nofp | |
22175 | Disable the floating-point and Advanced SIMD instructions. | |
22176 | @end table | |
22177 | ||
22178 | @item armv7ve | |
22179 | The extended version of the ARMv7-A architecture with support for | |
22180 | virtualization. | |
22181 | @table @samp | |
22182 | @item +fp | |
22183 | The VFPv4 floating-point instructions, with 16 double-precision registers. | |
22184 | The extension @samp{+vfpv4-d16} can be used as an alias for this extension. | |
22185 | ||
22186 | @item +simd | |
22187 | The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The | |
22188 | extension @samp{+neon-vfpv4} can be used as an alias for this extension. | |
22189 | ||
22190 | @item +vfpv3-d16 | |
22191 | The VFPv3 floating-point instructions, with 16 double-precision | |
22192 | registers. | |
22193 | ||
22194 | @item +vfpv3 | |
22195 | The VFPv3 floating-point instructions, with 32 double-precision | |
22196 | registers. | |
22197 | ||
22198 | @item +vfpv3-d16-fp16 | |
22199 | The VFPv3 floating-point instructions, with 16 double-precision | |
22200 | registers and the half-precision floating-point conversion operations. | |
22201 | ||
22202 | @item +vfpv3-fp16 | |
22203 | The VFPv3 floating-point instructions, with 32 double-precision | |
22204 | registers and the half-precision floating-point conversion operations. | |
22205 | ||
22206 | @item +vfpv4-d16 | |
22207 | The VFPv4 floating-point instructions, with 16 double-precision | |
22208 | registers. | |
22209 | ||
22210 | @item +vfpv4 | |
22211 | The VFPv4 floating-point instructions, with 32 double-precision | |
22212 | registers. | |
22213 | ||
22214 | @item +neon | |
22215 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions. | |
22216 | The extension @samp{+neon-vfpv3} can be used as an alias for this extension. | |
22217 | ||
22218 | @item +neon-fp16 | |
22219 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with | |
22220 | the half-precision floating-point conversion operations. | |
22221 | ||
22222 | @item +nosimd | |
22223 | Disable the Advanced SIMD instructions (does not disable floating point). | |
22224 | ||
22225 | @item +nofp | |
22226 | Disable the floating-point and Advanced SIMD instructions. | |
22227 | @end table | |
22228 | ||
22229 | @item armv8-a | |
22230 | @table @samp | |
22231 | @item +crc | |
22232 | The Cyclic Redundancy Check (CRC) instructions. | |
22233 | @item +simd | |
22234 | The ARMv8-A Advanced SIMD and floating-point instructions. | |
22235 | @item +crypto | |
22236 | The cryptographic instructions. | |
22237 | @item +nocrypto | |
22238 | Disable the cryptographic instructions. | |
22239 | @item +nofp | |
22240 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22241 | @item +sb | |
22242 | Speculation Barrier Instruction. | |
22243 | @item +predres | |
22244 | Execution and Data Prediction Restriction Instructions. | |
22245 | @end table | |
22246 | ||
22247 | @item armv8.1-a | |
22248 | @table @samp | |
22249 | @item +simd | |
22250 | The ARMv8.1-A Advanced SIMD and floating-point instructions. | |
22251 | ||
22252 | @item +crypto | |
22253 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22254 | floating-point instructions. | |
22255 | ||
22256 | @item +nocrypto | |
22257 | Disable the cryptographic instructions. | |
22258 | ||
22259 | @item +nofp | |
22260 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22261 | ||
22262 | @item +sb | |
22263 | Speculation Barrier Instruction. | |
22264 | ||
22265 | @item +predres | |
22266 | Execution and Data Prediction Restriction Instructions. | |
22267 | @end table | |
22268 | ||
22269 | @item armv8.2-a | |
22270 | @itemx armv8.3-a | |
22271 | @table @samp | |
22272 | @item +fp16 | |
22273 | The half-precision floating-point data processing instructions. | |
22274 | This also enables the Advanced SIMD and floating-point instructions. | |
22275 | ||
22276 | @item +fp16fml | |
22277 | The half-precision floating-point fmla extension. This also enables | |
22278 | the half-precision floating-point extension and Advanced SIMD and | |
22279 | floating-point instructions. | |
22280 | ||
22281 | @item +simd | |
22282 | The ARMv8.1-A Advanced SIMD and floating-point instructions. | |
22283 | ||
22284 | @item +crypto | |
22285 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22286 | floating-point instructions. | |
22287 | ||
22288 | @item +dotprod | |
22289 | Enable the Dot Product extension. This also enables Advanced SIMD instructions. | |
22290 | ||
22291 | @item +nocrypto | |
22292 | Disable the cryptographic extension. | |
22293 | ||
22294 | @item +nofp | |
22295 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22296 | ||
22297 | @item +sb | |
22298 | Speculation Barrier Instruction. | |
22299 | ||
22300 | @item +predres | |
22301 | Execution and Data Prediction Restriction Instructions. | |
22302 | ||
22303 | @item +i8mm | |
22304 | 8-bit Integer Matrix Multiply instructions. | |
22305 | This also enables Advanced SIMD and floating-point instructions. | |
22306 | ||
22307 | @item +bf16 | |
22308 | Brain half-precision floating-point instructions. | |
22309 | This also enables Advanced SIMD and floating-point instructions. | |
22310 | @end table | |
22311 | ||
22312 | @item armv8.4-a | |
22313 | @table @samp | |
22314 | @item +fp16 | |
22315 | The half-precision floating-point data processing instructions. | |
22316 | This also enables the Advanced SIMD and floating-point instructions as well | |
22317 | as the Dot Product extension and the half-precision floating-point fmla | |
22318 | extension. | |
22319 | ||
22320 | @item +simd | |
22321 | The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the | |
22322 | Dot Product extension. | |
22323 | ||
22324 | @item +crypto | |
22325 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22326 | floating-point instructions as well as the Dot Product extension. | |
22327 | ||
22328 | @item +nocrypto | |
22329 | Disable the cryptographic extension. | |
22330 | ||
22331 | @item +nofp | |
22332 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22333 | ||
22334 | @item +sb | |
22335 | Speculation Barrier Instruction. | |
22336 | ||
22337 | @item +predres | |
22338 | Execution and Data Prediction Restriction Instructions. | |
22339 | ||
22340 | @item +i8mm | |
22341 | 8-bit Integer Matrix Multiply instructions. | |
22342 | This also enables Advanced SIMD and floating-point instructions. | |
22343 | ||
22344 | @item +bf16 | |
22345 | Brain half-precision floating-point instructions. | |
22346 | This also enables Advanced SIMD and floating-point instructions. | |
22347 | @end table | |
22348 | ||
22349 | @item armv8.5-a | |
22350 | @table @samp | |
22351 | @item +fp16 | |
22352 | The half-precision floating-point data processing instructions. | |
22353 | This also enables the Advanced SIMD and floating-point instructions as well | |
22354 | as the Dot Product extension and the half-precision floating-point fmla | |
22355 | extension. | |
22356 | ||
22357 | @item +simd | |
22358 | The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the | |
22359 | Dot Product extension. | |
22360 | ||
22361 | @item +crypto | |
22362 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22363 | floating-point instructions as well as the Dot Product extension. | |
22364 | ||
22365 | @item +nocrypto | |
22366 | Disable the cryptographic extension. | |
22367 | ||
22368 | @item +nofp | |
22369 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22370 | ||
22371 | @item +i8mm | |
22372 | 8-bit Integer Matrix Multiply instructions. | |
22373 | This also enables Advanced SIMD and floating-point instructions. | |
22374 | ||
22375 | @item +bf16 | |
22376 | Brain half-precision floating-point instructions. | |
22377 | This also enables Advanced SIMD and floating-point instructions. | |
22378 | @end table | |
22379 | ||
22380 | @item armv8.6-a | |
22381 | @table @samp | |
22382 | @item +fp16 | |
22383 | The half-precision floating-point data processing instructions. | |
22384 | This also enables the Advanced SIMD and floating-point instructions as well | |
22385 | as the Dot Product extension and the half-precision floating-point fmla | |
22386 | extension. | |
22387 | ||
22388 | @item +simd | |
22389 | The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the | |
22390 | Dot Product extension. | |
22391 | ||
22392 | @item +crypto | |
22393 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22394 | floating-point instructions as well as the Dot Product extension. | |
22395 | ||
22396 | @item +nocrypto | |
22397 | Disable the cryptographic extension. | |
22398 | ||
22399 | @item +nofp | |
22400 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22401 | ||
22402 | @item +i8mm | |
22403 | 8-bit Integer Matrix Multiply instructions. | |
22404 | This also enables Advanced SIMD and floating-point instructions. | |
22405 | ||
22406 | @item +bf16 | |
22407 | Brain half-precision floating-point instructions. | |
22408 | This also enables Advanced SIMD and floating-point instructions. | |
22409 | @end table | |
22410 | ||
22411 | @item armv7-r | |
22412 | @table @samp | |
22413 | @item +fp.sp | |
22414 | The single-precision VFPv3 floating-point instructions. The extension | |
22415 | @samp{+vfpv3xd} can be used as an alias for this extension. | |
22416 | ||
22417 | @item +fp | |
22418 | The VFPv3 floating-point instructions with 16 double-precision registers. | |
22419 | The extension +vfpv3-d16 can be used as an alias for this extension. | |
22420 | ||
22421 | @item +vfpv3xd-d16-fp16 | |
22422 | The single-precision VFPv3 floating-point instructions with 16 double-precision | |
22423 | registers and the half-precision floating-point conversion operations. | |
22424 | ||
22425 | @item +vfpv3-d16-fp16 | |
22426 | The VFPv3 floating-point instructions with 16 double-precision | |
22427 | registers and the half-precision floating-point conversion operations. | |
22428 | ||
22429 | @item +nofp | |
22430 | Disable the floating-point extension. | |
22431 | ||
22432 | @item +idiv | |
22433 | The ARM-state integer division instructions. | |
22434 | ||
22435 | @item +noidiv | |
22436 | Disable the ARM-state integer division extension. | |
22437 | @end table | |
22438 | ||
22439 | @item armv7e-m | |
22440 | @table @samp | |
22441 | @item +fp | |
22442 | The single-precision VFPv4 floating-point instructions. | |
22443 | ||
22444 | @item +fpv5 | |
22445 | The single-precision FPv5 floating-point instructions. | |
22446 | ||
22447 | @item +fp.dp | |
22448 | The single- and double-precision FPv5 floating-point instructions. | |
22449 | ||
22450 | @item +nofp | |
22451 | Disable the floating-point extensions. | |
22452 | @end table | |
22453 | ||
22454 | @item armv8.1-m.main | |
22455 | @table @samp | |
22456 | ||
22457 | @item +dsp | |
22458 | The DSP instructions. | |
22459 | ||
22460 | @item +mve | |
22461 | The M-Profile Vector Extension (MVE) integer instructions. | |
22462 | ||
22463 | @item +mve.fp | |
22464 | The M-Profile Vector Extension (MVE) integer and single precision | |
22465 | floating-point instructions. | |
22466 | ||
22467 | @item +fp | |
22468 | The single-precision floating-point instructions. | |
22469 | ||
22470 | @item +fp.dp | |
22471 | The single- and double-precision floating-point instructions. | |
22472 | ||
22473 | @item +nofp | |
22474 | Disable the floating-point extension. | |
22475 | ||
22476 | @item +cdecp0, +cdecp1, ... , +cdecp7 | |
22477 | Enable the Custom Datapath Extension (CDE) on selected coprocessors according | |
22478 | to the numbers given in the options in the range 0 to 7. | |
c91bb7b9 AC |
22479 | |
22480 | @item +pacbti | |
22481 | Enable the Pointer Authentication and Branch Target Identification Extension. | |
d77de738 ML |
22482 | @end table |
22483 | ||
22484 | @item armv8-m.main | |
22485 | @table @samp | |
22486 | @item +dsp | |
22487 | The DSP instructions. | |
22488 | ||
22489 | @item +nodsp | |
22490 | Disable the DSP extension. | |
22491 | ||
22492 | @item +fp | |
22493 | The single-precision floating-point instructions. | |
22494 | ||
22495 | @item +fp.dp | |
22496 | The single- and double-precision floating-point instructions. | |
22497 | ||
22498 | @item +nofp | |
22499 | Disable the floating-point extension. | |
22500 | ||
22501 | @item +cdecp0, +cdecp1, ... , +cdecp7 | |
22502 | Enable the Custom Datapath Extension (CDE) on selected coprocessors according | |
22503 | to the numbers given in the options in the range 0 to 7. | |
22504 | @end table | |
22505 | ||
22506 | @item armv8-r | |
22507 | @table @samp | |
22508 | @item +crc | |
22509 | The Cyclic Redundancy Check (CRC) instructions. | |
22510 | @item +fp.sp | |
22511 | The single-precision FPv5 floating-point instructions. | |
22512 | @item +simd | |
22513 | The ARMv8-A Advanced SIMD and floating-point instructions. | |
22514 | @item +crypto | |
22515 | The cryptographic instructions. | |
22516 | @item +nocrypto | |
22517 | Disable the cryptographic instructions. | |
22518 | @item +nofp | |
22519 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22520 | @end table | |
22521 | ||
22522 | @end table | |
22523 | ||
22524 | @option{-march=native} causes the compiler to auto-detect the architecture | |
22525 | of the build computer. At present, this feature is only supported on | |
22526 | GNU/Linux, and not all architectures are recognized. If the auto-detect | |
22527 | is unsuccessful the option has no effect. | |
22528 | ||
d77de738 | 22529 | @opindex mtune |
ddf6fe37 | 22530 | @item -mtune=@var{name} |
d77de738 ML |
22531 | This option specifies the name of the target ARM processor for |
22532 | which GCC should tune the performance of the code. | |
22533 | For some ARM implementations better performance can be obtained by using | |
22534 | this option. | |
22535 | Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t}, | |
22536 | @samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110}, | |
22537 | @samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810}, | |
22538 | @samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t}, | |
22539 | @samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s}, | |
22540 | @samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t}, | |
22541 | @samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e}, | |
22542 | @samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp}, | |
22543 | @samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s}, | |
22544 | @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8}, | |
22545 | @samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17}, | |
22546 | @samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, | |
22547 | @samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, | |
22548 | @samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77}, | |
22549 | @samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710}, | |
22550 | @samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5}, | |
22551 | @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus}, | |
22552 | @samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3}, | |
22553 | @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33}, | |
ccfd1e7f SP |
22554 | @samp{cortex-m35p}, @samp{cortex-m55}, @samp{cortex-m85}, @samp{cortex-x1}, |
22555 | @samp{cortex-x1c}, @samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply}, | |
d77de738 ML |
22556 | @samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4}, |
22557 | @samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale}, | |
22558 | @samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626}, | |
22559 | @samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1}, | |
22560 | @samp{xgene1}. | |
22561 | ||
22562 | Additionally, this option can specify that GCC should tune the performance | |
22563 | of the code for a big.LITTLE system. Permissible names are: | |
22564 | @samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7}, | |
22565 | @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
22566 | @samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53}, | |
22567 | @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}. | |
22568 | ||
22569 | @option{-mtune=generic-@var{arch}} specifies that GCC should tune the | |
22570 | performance for a blend of processors within architecture @var{arch}. | |
22571 | The aim is to generate code that run well on the current most popular | |
22572 | processors, balancing between optimizations that benefit some CPUs in the | |
22573 | range, and avoiding performance pitfalls of other CPUs. The effects of | |
22574 | this option may change in future GCC versions as CPU models come and go. | |
22575 | ||
22576 | @option{-mtune} permits the same extension options as @option{-mcpu}, but | |
22577 | the extension options do not affect the tuning of the generated code. | |
22578 | ||
22579 | @option{-mtune=native} causes the compiler to auto-detect the CPU | |
22580 | of the build computer. At present, this feature is only supported on | |
22581 | GNU/Linux, and not all architectures are recognized. If the auto-detect is | |
22582 | unsuccessful the option has no effect. | |
22583 | ||
d77de738 | 22584 | @opindex mcpu |
ddf6fe37 | 22585 | @item -mcpu=@var{name}@r{[}+extension@dots{}@r{]} |
d77de738 ML |
22586 | This specifies the name of the target ARM processor. GCC uses this name |
22587 | to derive the name of the target ARM architecture (as if specified | |
22588 | by @option{-march}) and the ARM processor type for which to tune for | |
22589 | performance (as if specified by @option{-mtune}). Where this option | |
22590 | is used in conjunction with @option{-march} or @option{-mtune}, | |
22591 | those options take precedence over the appropriate part of this option. | |
22592 | ||
22593 | Many of the supported CPUs implement optional architectural | |
22594 | extensions. Where this is so the architectural extensions are | |
22595 | normally enabled by default. If implementations that lack the | |
22596 | extension exist, then the extension syntax can be used to disable | |
22597 | those extensions that have been omitted. For floating-point and | |
22598 | Advanced SIMD (Neon) instructions, the settings of the options | |
22599 | @option{-mfloat-abi} and @option{-mfpu} must also be considered: | |
22600 | floating-point and Advanced SIMD instructions will only be used if | |
22601 | @option{-mfloat-abi} is not set to @samp{soft}; and any setting of | |
22602 | @option{-mfpu} other than @samp{auto} will override the available | |
22603 | floating-point and SIMD extension instructions. | |
22604 | ||
22605 | For example, @samp{cortex-a9} can be found in three major | |
22606 | configurations: integer only, with just a floating-point unit or with | |
22607 | floating-point and Advanced SIMD. The default is to enable all the | |
22608 | instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can | |
22609 | be used to disable just the SIMD or both the SIMD and floating-point | |
22610 | instructions respectively. | |
22611 | ||
22612 | Permissible names for this option are the same as those for | |
22613 | @option{-mtune}. | |
22614 | ||
22615 | The following extension options are common to the listed CPUs: | |
22616 | ||
22617 | @table @samp | |
22618 | @item +nodsp | |
ccfd1e7f SP |
22619 | Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p}, |
22620 | @samp{cortex-m55} and @samp{cortex-m85}. Also disable the M-Profile Vector | |
22621 | Extension (MVE) integer and single precision floating-point instructions on | |
22622 | @samp{cortex-m55} and @samp{cortex-m85}. | |
22623 | ||
22624 | @item +nopacbti | |
22625 | Disable the Pointer Authentication and Branch Target Identification Extension | |
22626 | on @samp{cortex-m85}. | |
d77de738 ML |
22627 | |
22628 | @item +nomve | |
22629 | Disable the M-Profile Vector Extension (MVE) integer and single precision | |
ccfd1e7f | 22630 | floating-point instructions on @samp{cortex-m55} and @samp{cortex-m85}. |
d77de738 ML |
22631 | |
22632 | @item +nomve.fp | |
22633 | Disable the M-Profile Vector Extension (MVE) single precision floating-point | |
ccfd1e7f | 22634 | instructions on @samp{cortex-m55} and @samp{cortex-m85}. |
d77de738 | 22635 | |
798a0d05 SP |
22636 | @item +cdecp0, +cdecp1, ... , +cdecp7 |
22637 | Enable the Custom Datapath Extension (CDE) on selected coprocessors according | |
22638 | to the numbers given in the options in the range 0 to 7 on @samp{cortex-m55}. | |
22639 | ||
d77de738 ML |
22640 | @item +nofp |
22641 | Disables the floating-point instructions on @samp{arm9e}, | |
22642 | @samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e}, | |
22643 | @samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s}, | |
22644 | @samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, | |
22645 | @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p} | |
ccfd1e7f SP |
22646 | @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p}, |
22647 | @samp{cortex-m55} and @samp{cortex-m85}. | |
d77de738 ML |
22648 | Disables the floating-point and SIMD instructions on |
22649 | @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, | |
22650 | @samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12}, | |
22651 | @samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7}, | |
22652 | @samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35}, | |
22653 | @samp{cortex-a53} and @samp{cortex-a55}. | |
22654 | ||
22655 | @item +nofp.dp | |
22656 | Disables the double-precision component of the floating-point instructions | |
22657 | on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, | |
22658 | @samp{cortex-r52plus} and @samp{cortex-m7}. | |
22659 | ||
22660 | @item +nosimd | |
22661 | Disables the SIMD (but not floating-point) instructions on | |
22662 | @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7} | |
22663 | and @samp{cortex-a9}. | |
22664 | ||
22665 | @item +crypto | |
22666 | Enables the cryptographic instructions on @samp{cortex-a32}, | |
22667 | @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57}, | |
22668 | @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1}, | |
22669 | @samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
22670 | @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and | |
22671 | @samp{cortex-a75.cortex-a55}. | |
22672 | @end table | |
22673 | ||
22674 | Additionally the @samp{generic-armv7-a} pseudo target defaults to | |
22675 | VFPv3 with 16 double-precision registers. It supports the following | |
22676 | extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16}, | |
22677 | @samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16}, | |
22678 | @samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3}, | |
22679 | @samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for | |
22680 | the extensions to @option{-march=armv7-a}. | |
22681 | ||
22682 | @option{-mcpu=generic-@var{arch}} is also permissible, and is | |
22683 | equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}. | |
22684 | See @option{-mtune} for more information. | |
22685 | ||
22686 | @option{-mcpu=native} causes the compiler to auto-detect the CPU | |
22687 | of the build computer. At present, this feature is only supported on | |
22688 | GNU/Linux, and not all architectures are recognized. If the auto-detect | |
22689 | is unsuccessful the option has no effect. | |
22690 | ||
d77de738 | 22691 | @opindex mfpu |
ddf6fe37 | 22692 | @item -mfpu=@var{name} |
d77de738 ML |
22693 | This specifies what floating-point hardware (or hardware emulation) is |
22694 | available on the target. Permissible names are: @samp{auto}, @samp{vfpv2}, | |
22695 | @samp{vfpv3}, | |
22696 | @samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd}, | |
22697 | @samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4}, | |
22698 | @samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4}, | |
22699 | @samp{fpv5-d16}, @samp{fpv5-sp-d16}, | |
22700 | @samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}. | |
22701 | Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp} | |
22702 | is an alias for @samp{vfpv2}. | |
22703 | ||
22704 | The setting @samp{auto} is the default and is special. It causes the | |
22705 | compiler to select the floating-point and Advanced SIMD instructions | |
22706 | based on the settings of @option{-mcpu} and @option{-march}. | |
22707 | ||
22708 | If the selected floating-point hardware includes the NEON extension | |
22709 | (e.g.@: @option{-mfpu=neon}), note that floating-point | |
22710 | operations are not generated by GCC's auto-vectorization pass unless | |
22711 | @option{-funsafe-math-optimizations} is also specified. This is | |
22712 | because NEON hardware does not fully implement the IEEE 754 standard for | |
22713 | floating-point arithmetic (in particular denormal values are treated as | |
22714 | zero), so the use of NEON instructions may lead to a loss of precision. | |
22715 | ||
22716 | 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}). | |
22717 | ||
d77de738 | 22718 | @opindex mfp16-format |
ddf6fe37 | 22719 | @item -mfp16-format=@var{name} |
d77de738 ML |
22720 | Specify the format of the @code{__fp16} half-precision floating-point type. |
22721 | Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative}; | |
22722 | the default is @samp{none}, in which case the @code{__fp16} type is not | |
22723 | defined. @xref{Half-Precision}, for more information. | |
22724 | ||
d77de738 | 22725 | @opindex mstructure-size-boundary |
ddf6fe37 | 22726 | @item -mstructure-size-boundary=@var{n} |
d77de738 ML |
22727 | The sizes of all structures and unions are rounded up to a multiple |
22728 | of the number of bits set by this option. Permissible values are 8, 32 | |
22729 | and 64. The default value varies for different toolchains. For the COFF | |
22730 | targeted toolchain the default value is 8. A value of 64 is only allowed | |
22731 | if the underlying ABI supports it. | |
22732 | ||
22733 | Specifying a larger number can produce faster, more efficient code, but | |
22734 | can also increase the size of the program. Different values are potentially | |
22735 | incompatible. Code compiled with one value cannot necessarily expect to | |
22736 | work with code or libraries compiled with another value, if they exchange | |
22737 | information using structures or unions. | |
22738 | ||
22739 | This option is deprecated. | |
22740 | ||
d77de738 | 22741 | @opindex mabort-on-noreturn |
ddf6fe37 | 22742 | @item -mabort-on-noreturn |
d77de738 ML |
22743 | Generate a call to the function @code{abort} at the end of a |
22744 | @code{noreturn} function. It is executed if the function tries to | |
22745 | return. | |
22746 | ||
d77de738 ML |
22747 | @opindex mlong-calls |
22748 | @opindex mno-long-calls | |
ddf6fe37 AA |
22749 | @item -mlong-calls |
22750 | @itemx -mno-long-calls | |
d77de738 ML |
22751 | Tells the compiler to perform function calls by first loading the |
22752 | address of the function into a register and then performing a subroutine | |
22753 | call on this register. This switch is needed if the target function | |
22754 | lies outside of the 64-megabyte addressing range of the offset-based | |
22755 | version of subroutine call instruction. | |
22756 | ||
22757 | Even if this switch is enabled, not all function calls are turned | |
22758 | into long calls. The heuristic is that static functions, functions | |
22759 | that have the @code{short_call} attribute, functions that are inside | |
22760 | the scope of a @code{#pragma no_long_calls} directive, and functions whose | |
22761 | definitions have already been compiled within the current compilation | |
22762 | unit are not turned into long calls. The exceptions to this rule are | |
22763 | that weak function definitions, functions with the @code{long_call} | |
22764 | attribute or the @code{section} attribute, and functions that are within | |
22765 | the scope of a @code{#pragma long_calls} directive are always | |
22766 | turned into long calls. | |
22767 | ||
22768 | This feature is not enabled by default. Specifying | |
22769 | @option{-mno-long-calls} restores the default behavior, as does | |
22770 | placing the function calls within the scope of a @code{#pragma | |
22771 | long_calls_off} directive. Note these switches have no effect on how | |
22772 | the compiler generates code to handle function calls via function | |
22773 | pointers. | |
22774 | ||
d77de738 | 22775 | @opindex msingle-pic-base |
ddf6fe37 | 22776 | @item -msingle-pic-base |
d77de738 ML |
22777 | Treat the register used for PIC addressing as read-only, rather than |
22778 | loading it in the prologue for each function. The runtime system is | |
22779 | responsible for initializing this register with an appropriate value | |
22780 | before execution begins. | |
22781 | ||
d77de738 | 22782 | @opindex mpic-register |
ddf6fe37 | 22783 | @item -mpic-register=@var{reg} |
d77de738 ML |
22784 | Specify the register to be used for PIC addressing. |
22785 | For standard PIC base case, the default is any suitable register | |
22786 | determined by compiler. For single PIC base case, the default is | |
22787 | @samp{R9} if target is EABI based or stack-checking is enabled, | |
22788 | otherwise the default is @samp{R10}. | |
22789 | ||
d77de738 | 22790 | @opindex mpic-data-is-text-relative |
ddf6fe37 | 22791 | @item -mpic-data-is-text-relative |
d77de738 ML |
22792 | Assume that the displacement between the text and data segments is fixed |
22793 | at static link time. This permits using PC-relative addressing | |
22794 | operations to access data known to be in the data segment. For | |
22795 | non-VxWorks RTP targets, this option is enabled by default. When | |
22796 | disabled on such targets, it will enable @option{-msingle-pic-base} by | |
22797 | default. | |
22798 | ||
d77de738 | 22799 | @opindex mpoke-function-name |
ddf6fe37 | 22800 | @item -mpoke-function-name |
d77de738 ML |
22801 | Write the name of each function into the text section, directly |
22802 | preceding the function prologue. The generated code is similar to this: | |
22803 | ||
22804 | @smallexample | |
22805 | t0 | |
22806 | .ascii "arm_poke_function_name", 0 | |
22807 | .align | |
22808 | t1 | |
22809 | .word 0xff000000 + (t1 - t0) | |
22810 | arm_poke_function_name | |
22811 | mov ip, sp | |
22812 | stmfd sp!, @{fp, ip, lr, pc@} | |
22813 | sub fp, ip, #4 | |
22814 | @end smallexample | |
22815 | ||
22816 | When performing a stack backtrace, code can inspect the value of | |
22817 | @code{pc} stored at @code{fp + 0}. If the trace function then looks at | |
22818 | location @code{pc - 12} and the top 8 bits are set, then we know that | |
22819 | there is a function name embedded immediately preceding this location | |
22820 | and has length @code{((pc[-3]) & 0xff000000)}. | |
22821 | ||
d77de738 ML |
22822 | @opindex marm |
22823 | @opindex mthumb | |
ddf6fe37 AA |
22824 | @item -mthumb |
22825 | @itemx -marm | |
d77de738 ML |
22826 | |
22827 | Select between generating code that executes in ARM and Thumb | |
22828 | states. The default for most configurations is to generate code | |
22829 | that executes in ARM state, but the default can be changed by | |
22830 | configuring GCC with the @option{--with-mode=}@var{state} | |
22831 | configure option. | |
22832 | ||
22833 | You can also override the ARM and Thumb mode for each function | |
22834 | by using the @code{target("thumb")} and @code{target("arm")} function attributes | |
22835 | (@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}). | |
22836 | ||
d77de738 | 22837 | @opindex mflip-thumb |
ddf6fe37 | 22838 | @item -mflip-thumb |
d77de738 ML |
22839 | Switch ARM/Thumb modes on alternating functions. |
22840 | This option is provided for regression testing of mixed Thumb/ARM code | |
22841 | generation, and is not intended for ordinary use in compiling code. | |
22842 | ||
d77de738 | 22843 | @opindex mtpcs-frame |
ddf6fe37 | 22844 | @item -mtpcs-frame |
d77de738 ML |
22845 | Generate a stack frame that is compliant with the Thumb Procedure Call |
22846 | Standard for all non-leaf functions. (A leaf function is one that does | |
22847 | not call any other functions.) The default is @option{-mno-tpcs-frame}. | |
22848 | ||
d77de738 | 22849 | @opindex mtpcs-leaf-frame |
ddf6fe37 | 22850 | @item -mtpcs-leaf-frame |
d77de738 ML |
22851 | Generate a stack frame that is compliant with the Thumb Procedure Call |
22852 | Standard for all leaf functions. (A leaf function is one that does | |
22853 | not call any other functions.) The default is @option{-mno-apcs-leaf-frame}. | |
22854 | ||
d77de738 | 22855 | @opindex mcallee-super-interworking |
ddf6fe37 | 22856 | @item -mcallee-super-interworking |
d77de738 ML |
22857 | Gives all externally visible functions in the file being compiled an ARM |
22858 | instruction set header which switches to Thumb mode before executing the | |
22859 | rest of the function. This allows these functions to be called from | |
22860 | non-interworking code. This option is not valid in AAPCS configurations | |
22861 | because interworking is enabled by default. | |
22862 | ||
d77de738 | 22863 | @opindex mcaller-super-interworking |
ddf6fe37 | 22864 | @item -mcaller-super-interworking |
d77de738 ML |
22865 | Allows calls via function pointers (including virtual functions) to |
22866 | execute correctly regardless of whether the target code has been | |
22867 | compiled for interworking or not. There is a small overhead in the cost | |
22868 | of executing a function pointer if this option is enabled. This option | |
22869 | is not valid in AAPCS configurations because interworking is enabled | |
22870 | by default. | |
22871 | ||
d77de738 | 22872 | @opindex mtp |
ddf6fe37 | 22873 | @item -mtp=@var{name} |
cca8d9e5 KT |
22874 | Specify the access model for the thread local storage pointer. The model |
22875 | @samp{soft} generates calls to @code{__aeabi_read_tp}. Other accepted | |
22876 | models are @samp{tpidrurw}, @samp{tpidruro} and @samp{tpidrprw} which fetch | |
22877 | the thread pointer from the corresponding system register directly | |
22878 | (supported from the arm6k architecture and later). These system registers | |
22879 | are accessed through the CP15 co-processor interface and the argument | |
22880 | @samp{cp15} is also accepted as a convenience alias of @samp{tpidruro}. | |
22881 | The argument @samp{auto} uses the best available method for the selected | |
22882 | processor. The default setting is @samp{auto}. | |
d77de738 | 22883 | |
d77de738 | 22884 | @opindex mtls-dialect |
ddf6fe37 | 22885 | @item -mtls-dialect=@var{dialect} |
d77de738 ML |
22886 | Specify the dialect to use for accessing thread local storage. Two |
22887 | @var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The | |
22888 | @samp{gnu} dialect selects the original GNU scheme for supporting | |
22889 | local and global dynamic TLS models. The @samp{gnu2} dialect | |
22890 | selects the GNU descriptor scheme, which provides better performance | |
22891 | for shared libraries. The GNU descriptor scheme is compatible with | |
22892 | the original scheme, but does require new assembler, linker and | |
22893 | library support. Initial and local exec TLS models are unaffected by | |
22894 | this option and always use the original scheme. | |
22895 | ||
d77de738 | 22896 | @opindex mword-relocations |
ddf6fe37 | 22897 | @item -mword-relocations |
d77de738 ML |
22898 | Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32). |
22899 | This is enabled by default on targets (uClinux, SymbianOS) where the runtime | |
22900 | loader imposes this restriction, and when @option{-fpic} or @option{-fPIC} | |
22901 | is specified. This option conflicts with @option{-mslow-flash-data}. | |
22902 | ||
d77de738 | 22903 | @opindex mfix-cortex-m3-ldrd |
ddf6fe37 | 22904 | @item -mfix-cortex-m3-ldrd |
d77de738 ML |
22905 | Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions |
22906 | with overlapping destination and base registers are used. This option avoids | |
22907 | generating these instructions. This option is enabled by default when | |
22908 | @option{-mcpu=cortex-m3} is specified. | |
22909 | ||
22910 | @item -mfix-cortex-a57-aes-1742098 | |
22911 | @itemx -mno-fix-cortex-a57-aes-1742098 | |
22912 | @itemx -mfix-cortex-a72-aes-1655431 | |
22913 | @itemx -mno-fix-cortex-a72-aes-1655431 | |
22914 | Enable (disable) mitigation for an erratum on Cortex-A57 and | |
22915 | Cortex-A72 that affects the AES cryptographic instructions. This | |
22916 | option is enabled by default when either @option{-mcpu=cortex-a57} or | |
22917 | @option{-mcpu=cortex-a72} is specified. | |
22918 | ||
d77de738 ML |
22919 | @opindex munaligned-access |
22920 | @opindex mno-unaligned-access | |
ddf6fe37 AA |
22921 | @item -munaligned-access |
22922 | @itemx -mno-unaligned-access | |
d77de738 ML |
22923 | Enables (or disables) reading and writing of 16- and 32- bit values |
22924 | from addresses that are not 16- or 32- bit aligned. By default | |
22925 | unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for | |
22926 | ARMv8-M Baseline architectures, and enabled for all other | |
22927 | architectures. If unaligned access is not enabled then words in packed | |
22928 | data structures are accessed a byte at a time. | |
22929 | ||
22930 | The ARM attribute @code{Tag_CPU_unaligned_access} is set in the | |
22931 | generated object file to either true or false, depending upon the | |
22932 | setting of this option. If unaligned access is enabled then the | |
22933 | preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also | |
22934 | defined. | |
22935 | ||
d77de738 | 22936 | @opindex mneon-for-64bits |
ddf6fe37 | 22937 | @item -mneon-for-64bits |
d77de738 ML |
22938 | This option is deprecated and has no effect. |
22939 | ||
d77de738 | 22940 | @opindex mslow-flash-data |
ddf6fe37 | 22941 | @item -mslow-flash-data |
d77de738 ML |
22942 | Assume loading data from flash is slower than fetching instruction. |
22943 | Therefore literal load is minimized for better performance. | |
22944 | This option is only supported when compiling for ARMv7 M-profile and | |
22945 | off by default. It conflicts with @option{-mword-relocations}. | |
22946 | ||
d77de738 | 22947 | @opindex masm-syntax-unified |
ddf6fe37 | 22948 | @item -masm-syntax-unified |
d77de738 ML |
22949 | Assume inline assembler is using unified asm syntax. The default is |
22950 | currently off which implies divided syntax. This option has no impact | |
22951 | on Thumb2. However, this may change in future releases of GCC. | |
22952 | Divided syntax should be considered deprecated. | |
22953 | ||
d77de738 | 22954 | @opindex mrestrict-it |
ddf6fe37 | 22955 | @item -mrestrict-it |
d77de738 ML |
22956 | Restricts generation of IT blocks to conform to the rules of ARMv8-A. |
22957 | IT blocks can only contain a single 16-bit instruction from a select | |
22958 | set of instructions. This option is on by default for ARMv8-A Thumb mode. | |
22959 | ||
d77de738 | 22960 | @opindex mprint-tune-info |
ddf6fe37 | 22961 | @item -mprint-tune-info |
d77de738 ML |
22962 | Print CPU tuning information as comment in assembler file. This is |
22963 | an option used only for regression testing of the compiler and not | |
22964 | intended for ordinary use in compiling code. This option is disabled | |
22965 | by default. | |
22966 | ||
d77de738 | 22967 | @opindex mverbose-cost-dump |
ddf6fe37 | 22968 | @item -mverbose-cost-dump |
d77de738 ML |
22969 | Enable verbose cost model dumping in the debug dump files. This option is |
22970 | provided for use in debugging the compiler. | |
22971 | ||
d77de738 | 22972 | @opindex mpure-code |
ddf6fe37 | 22973 | @item -mpure-code |
d77de738 ML |
22974 | Do not allow constant data to be placed in code sections. |
22975 | Additionally, when compiling for ELF object format give all text sections the | |
22976 | ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option | |
22977 | is only available when generating non-pic code for M-profile targets. | |
22978 | ||
d77de738 | 22979 | @opindex mcmse |
ddf6fe37 | 22980 | @item -mcmse |
d77de738 ML |
22981 | Generate secure code as per the "ARMv8-M Security Extensions: Requirements on |
22982 | Development Tools Engineering Specification", which can be found on | |
22983 | @url{https://developer.arm.com/documentation/ecm0359818/latest/}. | |
22984 | ||
d77de738 | 22985 | @opindex mfix-cmse-cve-2021-35465 |
ddf6fe37 | 22986 | @item -mfix-cmse-cve-2021-35465 |
d77de738 ML |
22987 | Mitigate against a potential security issue with the @code{VLLDM} instruction |
22988 | in some M-profile devices when using CMSE (CVE-2021-365465). This option is | |
22989 | enabled by default when the option @option{-mcpu=} is used with | |
ccfd1e7f SP |
22990 | @code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m55}, @code{cortex-m85} |
22991 | or @code{star-mc1}. The option @option{-mno-fix-cmse-cve-2021-35465} can be used | |
22992 | to disable the mitigation. | |
d77de738 | 22993 | |
d77de738 ML |
22994 | @opindex mstack-protector-guard |
22995 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
22996 | @item -mstack-protector-guard=@var{guard} |
22997 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
22998 | Generate stack protection code using canary at @var{guard}. Supported |
22999 | locations are @samp{global} for a global canary or @samp{tls} for a | |
23000 | canary accessible via the TLS register. The option | |
23001 | @option{-mstack-protector-guard-offset=} is for use with | |
23002 | @option{-fstack-protector-guard=tls} and not for use in user-land code. | |
23003 | ||
d77de738 ML |
23004 | @opindex mfdpic |
23005 | @opindex mno-fdpic | |
ddf6fe37 AA |
23006 | @item -mfdpic |
23007 | @itemx -mno-fdpic | |
d77de738 ML |
23008 | Select the FDPIC ABI, which uses 64-bit function descriptors to |
23009 | represent pointers to functions. When the compiler is configured for | |
23010 | @code{arm-*-uclinuxfdpiceabi} targets, this option is on by default | |
23011 | and implies @option{-fPIE} if none of the PIC/PIE-related options is | |
23012 | provided. On other targets, it only enables the FDPIC-specific code | |
23013 | generation features, and the user should explicitly provide the | |
23014 | PIC/PIE-related options as needed. | |
23015 | ||
23016 | Note that static linking is not supported because it would still | |
23017 | involve the dynamic linker when the program self-relocates. If such | |
23018 | behavior is acceptable, use -static and -Wl,-dynamic-linker options. | |
23019 | ||
23020 | The opposite @option{-mno-fdpic} option is useful (and required) to | |
23021 | build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi}) | |
23022 | toolchain as the one used to build the userland programs. | |
23023 | ||
14fab5fb | 23024 | @opindex mbranch-protection |
ddf6fe37 | 23025 | @item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]] |
14fab5fb AC |
23026 | Enable branch protection features (armv8.1-m.main only). |
23027 | @samp{none} generate code without branch protection or return address | |
23028 | signing. | |
23029 | @samp{standard[+@var{leaf}]} generate code with all branch protection | |
23030 | features enabled at their standard level. | |
23031 | @samp{pac-ret[+@var{leaf}]} generate code with return address signing | |
23032 | set to its standard level, which is to sign all functions that save | |
23033 | the return address to memory. | |
23034 | @samp{leaf} When return address signing is enabled, also sign leaf | |
23035 | functions even if they do not write the return address to memory. | |
23036 | +@samp{bti} Add landing-pad instructions at the permitted targets of | |
23037 | indirect branch instructions. | |
23038 | ||
23039 | If the @samp{+pacbti} architecture extension is not enabled, then all | |
23040 | branch protection and return address signing operations are | |
23041 | constrained to use only the instructions defined in the | |
23042 | architectural-NOP space. The generated code will remain | |
23043 | backwards-compatible with earlier versions of the architecture, but | |
23044 | the additional security can be enabled at run time on processors that | |
23045 | support the @samp{PACBTI} extension. | |
23046 | ||
23047 | Branch target enforcement using BTI can only be enabled at runtime if | |
23048 | all code in the application has been compiled with at least | |
23049 | @samp{-mbranch-protection=bti}. | |
23050 | ||
23051 | Any setting other than @samp{none} is supported only on armv8-m.main | |
23052 | or later. | |
23053 | ||
23054 | The default is to generate code without branch protection or return | |
23055 | address signing. | |
23056 | ||
d77de738 ML |
23057 | @end table |
23058 | ||
23059 | @node AVR Options | |
23060 | @subsection AVR Options | |
23061 | @cindex AVR Options | |
23062 | ||
23063 | These options are defined for AVR implementations: | |
23064 | ||
23065 | @table @gcctabopt | |
d77de738 | 23066 | @opindex mmcu |
ddf6fe37 | 23067 | @item -mmcu=@var{mcu} |
d77de738 ML |
23068 | Specify Atmel AVR instruction set architectures (ISA) or MCU type. |
23069 | ||
23070 | The default for this option is@tie{}@samp{avr2}. | |
23071 | ||
23072 | GCC supports the following AVR devices and ISAs: | |
23073 | ||
23074 | @include avr-mmcu.texi | |
23075 | ||
d77de738 | 23076 | @opindex mabsdata |
ddf6fe37 | 23077 | @item -mabsdata |
d77de738 ML |
23078 | |
23079 | Assume that all data in static storage can be accessed by LDS / STS | |
23080 | instructions. This option has only an effect on reduced Tiny devices like | |
23081 | ATtiny40. See also the @code{absdata} | |
23082 | @ref{AVR Variable Attributes,variable attribute}. | |
23083 | ||
d77de738 | 23084 | @opindex maccumulate-args |
ddf6fe37 | 23085 | @item -maccumulate-args |
d77de738 ML |
23086 | Accumulate outgoing function arguments and acquire/release the needed |
23087 | stack space for outgoing function arguments once in function | |
23088 | prologue/epilogue. Without this option, outgoing arguments are pushed | |
23089 | before calling a function and popped afterwards. | |
23090 | ||
23091 | Popping the arguments after the function call can be expensive on | |
23092 | AVR so that accumulating the stack space might lead to smaller | |
23093 | executables because arguments need not be removed from the | |
23094 | stack after such a function call. | |
23095 | ||
23096 | This option can lead to reduced code size for functions that perform | |
23097 | several calls to functions that get their arguments on the stack like | |
23098 | calls to printf-like functions. | |
23099 | ||
d77de738 | 23100 | @opindex mbranch-cost |
ddf6fe37 | 23101 | @item -mbranch-cost=@var{cost} |
d77de738 ML |
23102 | Set the branch costs for conditional branch instructions to |
23103 | @var{cost}. Reasonable values for @var{cost} are small, non-negative | |
23104 | integers. The default branch cost is 0. | |
23105 | ||
d77de738 | 23106 | @opindex mcall-prologues |
ddf6fe37 | 23107 | @item -mcall-prologues |
d77de738 ML |
23108 | Functions prologues/epilogues are expanded as calls to appropriate |
23109 | subroutines. Code size is smaller. | |
23110 | ||
d77de738 ML |
23111 | @opindex mdouble |
23112 | @opindex mlong-double | |
ddf6fe37 AA |
23113 | @item -mdouble=@var{bits} |
23114 | @itemx -mlong-double=@var{bits} | |
d77de738 ML |
23115 | Set the size (in bits) of the @code{double} or @code{long double} type, |
23116 | respectively. Possible values for @var{bits} are 32 and 64. | |
23117 | Whether or not a specific value for @var{bits} is allowed depends on | |
23118 | the @code{--with-double=} and @code{--with-long-double=} | |
23119 | @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}}, | |
23120 | and the same applies for the default values of the options. | |
23121 | ||
d77de738 | 23122 | @opindex mgas-isr-prologues |
ddf6fe37 | 23123 | @item -mgas-isr-prologues |
d77de738 ML |
23124 | Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo |
23125 | instruction supported by GNU Binutils. | |
23126 | If this option is on, the feature can still be disabled for individual | |
23127 | ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}} | |
23128 | function attribute. This feature is activated per default | |
23129 | if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}), | |
23130 | and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}. | |
23131 | ||
d77de738 | 23132 | @opindex mint8 |
ddf6fe37 | 23133 | @item -mint8 |
d77de738 ML |
23134 | Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a |
23135 | @code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes, | |
23136 | and @code{long long} is 4 bytes. Please note that this option does not | |
23137 | conform to the C standards, but it results in smaller code | |
23138 | size. | |
23139 | ||
d77de738 | 23140 | @opindex mmain-is-OS_task |
ddf6fe37 | 23141 | @item -mmain-is-OS_task |
d77de738 ML |
23142 | Do not save registers in @code{main}. The effect is the same like |
23143 | attaching attribute @ref{AVR Function Attributes,,@code{OS_task}} | |
23144 | to @code{main}. It is activated per default if optimization is on. | |
23145 | ||
d77de738 | 23146 | @opindex mn-flash |
ddf6fe37 | 23147 | @item -mn-flash=@var{num} |
d77de738 ML |
23148 | Assume that the flash memory has a size of |
23149 | @var{num} times 64@tie{}KiB. | |
23150 | ||
d77de738 | 23151 | @opindex mno-interrupts |
ddf6fe37 | 23152 | @item -mno-interrupts |
d77de738 ML |
23153 | Generated code is not compatible with hardware interrupts. |
23154 | Code size is smaller. | |
23155 | ||
d77de738 | 23156 | @opindex mrelax |
ddf6fe37 | 23157 | @item -mrelax |
d77de738 ML |
23158 | Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter |
23159 | @code{RCALL} resp.@: @code{RJMP} instruction if applicable. | |
23160 | Setting @option{-mrelax} just adds the @option{--mlink-relax} option to | |
23161 | the assembler's command line and the @option{--relax} option to the | |
23162 | linker's command line. | |
23163 | ||
23164 | Jump relaxing is performed by the linker because jump offsets are not | |
23165 | known before code is located. Therefore, the assembler code generated by the | |
23166 | compiler is the same, but the instructions in the executable may | |
23167 | differ from instructions in the assembler code. | |
23168 | ||
23169 | Relaxing must be turned on if linker stubs are needed, see the | |
23170 | section on @code{EIND} and linker stubs below. | |
23171 | ||
d77de738 | 23172 | @opindex mrmw |
ddf6fe37 | 23173 | @item -mrmw |
d77de738 ML |
23174 | Assume that the device supports the Read-Modify-Write |
23175 | instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}. | |
23176 | ||
d77de738 | 23177 | @opindex mshort-calls |
ddf6fe37 | 23178 | @item -mshort-calls |
d77de738 ML |
23179 | |
23180 | Assume that @code{RJMP} and @code{RCALL} can target the whole | |
23181 | program memory. | |
23182 | ||
23183 | This option is used internally for multilib selection. It is | |
23184 | not an optimization option, and you don't need to set it by hand. | |
23185 | ||
d77de738 | 23186 | @opindex msp8 |
ddf6fe37 | 23187 | @item -msp8 |
d77de738 ML |
23188 | Treat the stack pointer register as an 8-bit register, |
23189 | i.e.@: assume the high byte of the stack pointer is zero. | |
23190 | In general, you don't need to set this option by hand. | |
23191 | ||
23192 | This option is used internally by the compiler to select and | |
23193 | build multilibs for architectures @code{avr2} and @code{avr25}. | |
23194 | These architectures mix devices with and without @code{SPH}. | |
23195 | For any setting other than @option{-mmcu=avr2} or @option{-mmcu=avr25} | |
23196 | the compiler driver adds or removes this option from the compiler | |
23197 | proper's command line, because the compiler then knows if the device | |
23198 | or architecture has an 8-bit stack pointer and thus no @code{SPH} | |
23199 | register or not. | |
23200 | ||
d77de738 | 23201 | @opindex mstrict-X |
ddf6fe37 | 23202 | @item -mstrict-X |
d77de738 ML |
23203 | Use address register @code{X} in a way proposed by the hardware. This means |
23204 | that @code{X} is only used in indirect, post-increment or | |
23205 | pre-decrement addressing. | |
23206 | ||
23207 | Without this option, the @code{X} register may be used in the same way | |
23208 | as @code{Y} or @code{Z} which then is emulated by additional | |
23209 | instructions. | |
23210 | For example, loading a value with @code{X+const} addressing with a | |
23211 | small non-negative @code{const < 64} to a register @var{Rn} is | |
23212 | performed as | |
23213 | ||
23214 | @example | |
23215 | adiw r26, const ; X += const | |
23216 | ld @var{Rn}, X ; @var{Rn} = *X | |
23217 | sbiw r26, const ; X -= const | |
23218 | @end example | |
23219 | ||
d77de738 | 23220 | @opindex mtiny-stack |
ddf6fe37 | 23221 | @item -mtiny-stack |
d77de738 ML |
23222 | Only change the lower 8@tie{}bits of the stack pointer. |
23223 | ||
d77de738 | 23224 | @opindex mfract-convert-truncate |
ddf6fe37 | 23225 | @item -mfract-convert-truncate |
d77de738 ML |
23226 | Allow to use truncation instead of rounding towards zero for fractional fixed-point types. |
23227 | ||
d77de738 | 23228 | @opindex nodevicelib |
ddf6fe37 | 23229 | @item -nodevicelib |
d77de738 ML |
23230 | Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}. |
23231 | ||
d77de738 | 23232 | @opindex nodevicespecs |
ddf6fe37 | 23233 | @item -nodevicespecs |
d77de738 ML |
23234 | Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's |
23235 | command line. The user takes responsibility for supplying the sub-processes | |
23236 | like compiler proper, assembler and linker with appropriate command line | |
23237 | options. This means that the user has to supply her private device specs | |
23238 | file by means of @option{-specs=@var{path-to-specs-file}}. There is no | |
23239 | more need for option @option{-mmcu=@var{mcu}}. | |
23240 | ||
23241 | This option can also serve as a replacement for the older way of | |
23242 | specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory | |
23243 | which contains a folder named @code{device-specs} which contains a specs file named | |
23244 | @code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}. | |
23245 | ||
d77de738 ML |
23246 | @opindex Waddr-space-convert |
23247 | @opindex Wno-addr-space-convert | |
ddf6fe37 | 23248 | @item -Waddr-space-convert |
d77de738 ML |
23249 | Warn about conversions between address spaces in the case where the |
23250 | resulting address space is not contained in the incoming address space. | |
23251 | ||
d77de738 ML |
23252 | @opindex Wmisspelled-isr |
23253 | @opindex Wno-misspelled-isr | |
ddf6fe37 | 23254 | @item -Wmisspelled-isr |
d77de738 ML |
23255 | Warn if the ISR is misspelled, i.e.@: without __vector prefix. |
23256 | Enabled by default. | |
23257 | @end table | |
23258 | ||
23259 | @subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash | |
23260 | @cindex @code{EIND} | |
23261 | Pointers in the implementation are 16@tie{}bits wide. | |
23262 | The address of a function or label is represented as word address so | |
23263 | that indirect jumps and calls can target any code address in the | |
23264 | range of 64@tie{}Ki words. | |
23265 | ||
23266 | In order to facilitate indirect jump on devices with more than 128@tie{}Ki | |
23267 | bytes of program memory space, there is a special function register called | |
23268 | @code{EIND} that serves as most significant part of the target address | |
23269 | when @code{EICALL} or @code{EIJMP} instructions are used. | |
23270 | ||
23271 | Indirect jumps and calls on these devices are handled as follows by | |
23272 | the compiler and are subject to some limitations: | |
23273 | ||
23274 | @itemize @bullet | |
23275 | ||
23276 | @item | |
23277 | The compiler never sets @code{EIND}. | |
23278 | ||
23279 | @item | |
23280 | The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP} | |
23281 | instructions or might read @code{EIND} directly in order to emulate an | |
23282 | indirect call/jump by means of a @code{RET} instruction. | |
23283 | ||
23284 | @item | |
23285 | The compiler assumes that @code{EIND} never changes during the startup | |
23286 | code or during the application. In particular, @code{EIND} is not | |
23287 | saved/restored in function or interrupt service routine | |
23288 | prologue/epilogue. | |
23289 | ||
23290 | @item | |
23291 | For indirect calls to functions and computed goto, the linker | |
23292 | generates @emph{stubs}. Stubs are jump pads sometimes also called | |
23293 | @emph{trampolines}. Thus, the indirect call/jump jumps to such a stub. | |
23294 | The stub contains a direct jump to the desired address. | |
23295 | ||
23296 | @item | |
23297 | Linker relaxation must be turned on so that the linker generates | |
23298 | the stubs correctly in all situations. See the compiler option | |
23299 | @option{-mrelax} and the linker option @option{--relax}. | |
23300 | There are corner cases where the linker is supposed to generate stubs | |
23301 | but aborts without relaxation and without a helpful error message. | |
23302 | ||
23303 | @item | |
23304 | The default linker script is arranged for code with @code{EIND = 0}. | |
23305 | If code is supposed to work for a setup with @code{EIND != 0}, a custom | |
23306 | linker script has to be used in order to place the sections whose | |
23307 | name start with @code{.trampolines} into the segment where @code{EIND} | |
23308 | points to. | |
23309 | ||
23310 | @item | |
23311 | The startup code from libgcc never sets @code{EIND}. | |
23312 | Notice that startup code is a blend of code from libgcc and AVR-LibC. | |
23313 | For the impact of AVR-LibC on @code{EIND}, see the | |
a65da9be | 23314 | @w{@uref{https://www.nongnu.org/avr-libc/user-manual/,AVR-LibC user manual}}. |
d77de738 ML |
23315 | |
23316 | @item | |
23317 | It is legitimate for user-specific startup code to set up @code{EIND} | |
23318 | early, for example by means of initialization code located in | |
23319 | section @code{.init3}. Such code runs prior to general startup code | |
23320 | that initializes RAM and calls constructors, but after the bit | |
23321 | of startup code from AVR-LibC that sets @code{EIND} to the segment | |
23322 | where the vector table is located. | |
23323 | @example | |
23324 | #include <avr/io.h> | |
23325 | ||
23326 | static void | |
23327 | __attribute__((section(".init3"),naked,used,no_instrument_function)) | |
23328 | init3_set_eind (void) | |
23329 | @{ | |
23330 | __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t" | |
23331 | "out %i0,r24" :: "n" (&EIND) : "r24","memory"); | |
23332 | @} | |
23333 | @end example | |
23334 | ||
23335 | @noindent | |
23336 | The @code{__trampolines_start} symbol is defined in the linker script. | |
23337 | ||
23338 | @item | |
23339 | Stubs are generated automatically by the linker if | |
23340 | the following two conditions are met: | |
23341 | @itemize @minus | |
23342 | ||
23343 | @item The address of a label is taken by means of the @code{gs} modifier | |
23344 | (short for @emph{generate stubs}) like so: | |
23345 | @example | |
23346 | LDI r24, lo8(gs(@var{func})) | |
23347 | LDI r25, hi8(gs(@var{func})) | |
23348 | @end example | |
23349 | @item The final location of that label is in a code segment | |
23350 | @emph{outside} the segment where the stubs are located. | |
23351 | @end itemize | |
23352 | ||
23353 | @item | |
23354 | The compiler emits such @code{gs} modifiers for code labels in the | |
23355 | following situations: | |
23356 | @itemize @minus | |
23357 | @item Taking address of a function or code label. | |
23358 | @item Computed goto. | |
23359 | @item If prologue-save function is used, see @option{-mcall-prologues} | |
23360 | command-line option. | |
23361 | @item Switch/case dispatch tables. If you do not want such dispatch | |
23362 | tables you can specify the @option{-fno-jump-tables} command-line option. | |
23363 | @item C and C++ constructors/destructors called during startup/shutdown. | |
23364 | @item If the tools hit a @code{gs()} modifier explained above. | |
23365 | @end itemize | |
23366 | ||
23367 | @item | |
23368 | Jumping to non-symbolic addresses like so is @emph{not} supported: | |
23369 | ||
23370 | @example | |
23371 | int main (void) | |
23372 | @{ | |
23373 | /* Call function at word address 0x2 */ | |
23374 | return ((int(*)(void)) 0x2)(); | |
23375 | @} | |
23376 | @end example | |
23377 | ||
23378 | Instead, a stub has to be set up, i.e.@: the function has to be called | |
23379 | through a symbol (@code{func_4} in the example): | |
23380 | ||
23381 | @example | |
23382 | int main (void) | |
23383 | @{ | |
23384 | extern int func_4 (void); | |
23385 | ||
23386 | /* Call function at byte address 0x4 */ | |
23387 | return func_4(); | |
23388 | @} | |
23389 | @end example | |
23390 | ||
23391 | and the application be linked with @option{-Wl,--defsym,func_4=0x4}. | |
23392 | Alternatively, @code{func_4} can be defined in the linker script. | |
23393 | @end itemize | |
23394 | ||
23395 | @subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers | |
23396 | @cindex @code{RAMPD} | |
23397 | @cindex @code{RAMPX} | |
23398 | @cindex @code{RAMPY} | |
23399 | @cindex @code{RAMPZ} | |
23400 | Some AVR devices support memories larger than the 64@tie{}KiB range | |
23401 | that can be accessed with 16-bit pointers. To access memory locations | |
23402 | outside this 64@tie{}KiB range, the content of a @code{RAMP} | |
23403 | register is used as high part of the address: | |
23404 | The @code{X}, @code{Y}, @code{Z} address register is concatenated | |
23405 | with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function | |
23406 | register, respectively, to get a wide address. Similarly, | |
23407 | @code{RAMPD} is used together with direct addressing. | |
23408 | ||
23409 | @itemize | |
23410 | @item | |
23411 | The startup code initializes the @code{RAMP} special function | |
23412 | registers with zero. | |
23413 | ||
23414 | @item | |
23415 | If a @ref{AVR Named Address Spaces,named address space} other than | |
23416 | generic or @code{__flash} is used, then @code{RAMPZ} is set | |
23417 | as needed before the operation. | |
23418 | ||
23419 | @item | |
23420 | If the device supports RAM larger than 64@tie{}KiB and the compiler | |
23421 | needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ} | |
23422 | is reset to zero after the operation. | |
23423 | ||
23424 | @item | |
23425 | If the device comes with a specific @code{RAMP} register, the ISR | |
23426 | prologue/epilogue saves/restores that SFR and initializes it with | |
23427 | zero in case the ISR code might (implicitly) use it. | |
23428 | ||
23429 | @item | |
23430 | RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets. | |
23431 | If you use inline assembler to read from locations outside the | |
23432 | 16-bit address range and change one of the @code{RAMP} registers, | |
23433 | you must reset it to zero after the access. | |
23434 | ||
23435 | @end itemize | |
23436 | ||
23437 | @subsubsection AVR Built-in Macros | |
23438 | ||
23439 | GCC defines several built-in macros so that the user code can test | |
23440 | for the presence or absence of features. Almost any of the following | |
23441 | built-in macros are deduced from device capabilities and thus | |
23442 | triggered by the @option{-mmcu=} command-line option. | |
23443 | ||
23444 | For even more AVR-specific built-in macros see | |
23445 | @ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}. | |
23446 | ||
23447 | @table @code | |
23448 | ||
23449 | @item __AVR_ARCH__ | |
23450 | Build-in macro that resolves to a decimal number that identifies the | |
23451 | architecture and depends on the @option{-mmcu=@var{mcu}} option. | |
23452 | Possible values are: | |
23453 | ||
23454 | @code{2}, @code{25}, @code{3}, @code{31}, @code{35}, | |
23455 | @code{4}, @code{5}, @code{51}, @code{6} | |
23456 | ||
23457 | for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31}, | |
23458 | @code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6}, | |
23459 | ||
23460 | respectively and | |
23461 | ||
23462 | @code{100}, | |
23463 | @code{102}, @code{103}, @code{104}, | |
23464 | @code{105}, @code{106}, @code{107} | |
23465 | ||
23466 | for @var{mcu}=@code{avrtiny}, | |
23467 | @code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4}, | |
23468 | @code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively. | |
23469 | If @var{mcu} specifies a device, this built-in macro is set | |
23470 | accordingly. For example, with @option{-mmcu=atmega8} the macro is | |
23471 | defined to @code{4}. | |
23472 | ||
23473 | @item __AVR_@var{Device}__ | |
23474 | Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects | |
23475 | the device's name. For example, @option{-mmcu=atmega8} defines the | |
23476 | built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines | |
23477 | @code{__AVR_ATtiny261A__}, etc. | |
23478 | ||
23479 | The built-in macros' names follow | |
23480 | the scheme @code{__AVR_@var{Device}__} where @var{Device} is | |
23481 | the device name as from the AVR user manual. The difference between | |
23482 | @var{Device} in the built-in macro and @var{device} in | |
23483 | @option{-mmcu=@var{device}} is that the latter is always lowercase. | |
23484 | ||
23485 | If @var{device} is not a device but only a core architecture like | |
23486 | @samp{avr51}, this macro is not defined. | |
23487 | ||
23488 | @item __AVR_DEVICE_NAME__ | |
23489 | Setting @option{-mmcu=@var{device}} defines this built-in macro to | |
23490 | the device's name. For example, with @option{-mmcu=atmega8} the macro | |
23491 | is defined to @code{atmega8}. | |
23492 | ||
23493 | If @var{device} is not a device but only a core architecture like | |
23494 | @samp{avr51}, this macro is not defined. | |
23495 | ||
23496 | @item __AVR_XMEGA__ | |
23497 | The device / architecture belongs to the XMEGA family of devices. | |
23498 | ||
23499 | @item __AVR_HAVE_ELPM__ | |
23500 | The device has the @code{ELPM} instruction. | |
23501 | ||
23502 | @item __AVR_HAVE_ELPMX__ | |
23503 | The device has the @code{ELPM R@var{n},Z} and @code{ELPM | |
23504 | R@var{n},Z+} instructions. | |
23505 | ||
23506 | @item __AVR_HAVE_MOVW__ | |
23507 | The device has the @code{MOVW} instruction to perform 16-bit | |
23508 | register-register moves. | |
23509 | ||
23510 | @item __AVR_HAVE_LPMX__ | |
23511 | The device has the @code{LPM R@var{n},Z} and | |
23512 | @code{LPM R@var{n},Z+} instructions. | |
23513 | ||
23514 | @item __AVR_HAVE_MUL__ | |
23515 | The device has a hardware multiplier. | |
23516 | ||
23517 | @item __AVR_HAVE_JMP_CALL__ | |
23518 | The device has the @code{JMP} and @code{CALL} instructions. | |
23519 | This is the case for devices with more than 8@tie{}KiB of program | |
23520 | memory. | |
23521 | ||
23522 | @item __AVR_HAVE_EIJMP_EICALL__ | |
23523 | @itemx __AVR_3_BYTE_PC__ | |
23524 | The device has the @code{EIJMP} and @code{EICALL} instructions. | |
23525 | This is the case for devices with more than 128@tie{}KiB of program memory. | |
23526 | This also means that the program counter | |
23527 | (PC) is 3@tie{}bytes wide. | |
23528 | ||
23529 | @item __AVR_2_BYTE_PC__ | |
23530 | The program counter (PC) is 2@tie{}bytes wide. This is the case for devices | |
23531 | with up to 128@tie{}KiB of program memory. | |
23532 | ||
23533 | @item __AVR_HAVE_8BIT_SP__ | |
23534 | @itemx __AVR_HAVE_16BIT_SP__ | |
23535 | The stack pointer (SP) register is treated as 8-bit respectively | |
23536 | 16-bit register by the compiler. | |
23537 | The definition of these macros is affected by @option{-mtiny-stack}. | |
23538 | ||
23539 | @item __AVR_HAVE_SPH__ | |
23540 | @itemx __AVR_SP8__ | |
23541 | The device has the SPH (high part of stack pointer) special function | |
23542 | register or has an 8-bit stack pointer, respectively. | |
23543 | The definition of these macros is affected by @option{-mmcu=} and | |
23544 | in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also | |
23545 | by @option{-msp8}. | |
23546 | ||
23547 | @item __AVR_HAVE_RAMPD__ | |
23548 | @itemx __AVR_HAVE_RAMPX__ | |
23549 | @itemx __AVR_HAVE_RAMPY__ | |
23550 | @itemx __AVR_HAVE_RAMPZ__ | |
23551 | The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY}, | |
23552 | @code{RAMPZ} special function register, respectively. | |
23553 | ||
23554 | @item __NO_INTERRUPTS__ | |
23555 | This macro reflects the @option{-mno-interrupts} command-line option. | |
23556 | ||
23557 | @item __AVR_ERRATA_SKIP__ | |
23558 | @itemx __AVR_ERRATA_SKIP_JMP_CALL__ | |
23559 | Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit | |
23560 | instructions because of a hardware erratum. Skip instructions are | |
23561 | @code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}. | |
23562 | The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also | |
23563 | set. | |
23564 | ||
23565 | @item __AVR_ISA_RMW__ | |
23566 | The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT). | |
23567 | ||
23568 | @item __AVR_SFR_OFFSET__=@var{offset} | |
23569 | Instructions that can address I/O special function registers directly | |
23570 | like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different | |
23571 | address as if addressed by an instruction to access RAM like @code{LD} | |
23572 | or @code{STS}. This offset depends on the device architecture and has | |
23573 | to be subtracted from the RAM address in order to get the | |
23574 | respective I/O@tie{}address. | |
23575 | ||
23576 | @item __AVR_SHORT_CALLS__ | |
23577 | The @option{-mshort-calls} command line option is set. | |
23578 | ||
23579 | @item __AVR_PM_BASE_ADDRESS__=@var{addr} | |
23580 | Some devices support reading from flash memory by means of @code{LD*} | |
23581 | instructions. The flash memory is seen in the data address space | |
23582 | at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro | |
23583 | is not defined, this feature is not available. If defined, | |
23584 | the address space is linear and there is no need to put | |
23585 | @code{.rodata} into RAM. This is handled by the default linker | |
23586 | description file, and is currently available for | |
23587 | @code{avrtiny} and @code{avrxmega3}. Even more convenient, | |
23588 | there is no need to use address spaces like @code{__flash} or | |
23589 | features like attribute @code{progmem} and @code{pgm_read_*}. | |
23590 | ||
23591 | @item __WITH_AVRLIBC__ | |
23592 | The compiler is configured to be used together with AVR-Libc. | |
23593 | See the @option{--with-avrlibc} configure option. | |
23594 | ||
23595 | @item __HAVE_DOUBLE_MULTILIB__ | |
23596 | Defined if @option{-mdouble=} acts as a multilib option. | |
23597 | ||
23598 | @item __HAVE_DOUBLE32__ | |
23599 | @itemx __HAVE_DOUBLE64__ | |
23600 | Defined if the compiler supports 32-bit double resp. 64-bit double. | |
23601 | The actual layout is specified by option @option{-mdouble=}. | |
23602 | ||
23603 | @item __DEFAULT_DOUBLE__ | |
23604 | The size in bits of @code{double} if @option{-mdouble=} is not set. | |
23605 | To test the layout of @code{double} in a program, use the built-in | |
23606 | macro @code{__SIZEOF_DOUBLE__}. | |
23607 | ||
23608 | @item __HAVE_LONG_DOUBLE32__ | |
23609 | @itemx __HAVE_LONG_DOUBLE64__ | |
23610 | @itemx __HAVE_LONG_DOUBLE_MULTILIB__ | |
23611 | @itemx __DEFAULT_LONG_DOUBLE__ | |
23612 | Same as above, but for @code{long double} instead of @code{double}. | |
23613 | ||
23614 | @item __WITH_DOUBLE_COMPARISON__ | |
23615 | Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}} | |
23616 | @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}} | |
23617 | and is defined to @code{2} or @code{3}. | |
23618 | ||
23619 | @item __WITH_LIBF7_LIBGCC__ | |
23620 | @itemx __WITH_LIBF7_MATH__ | |
23621 | @itemx __WITH_LIBF7_MATH_SYMBOLS__ | |
23622 | Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}} | |
23623 | @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}. | |
23624 | ||
23625 | @end table | |
23626 | ||
23627 | @node Blackfin Options | |
23628 | @subsection Blackfin Options | |
23629 | @cindex Blackfin Options | |
23630 | ||
23631 | @table @gcctabopt | |
d77de738 | 23632 | @opindex mcpu= |
ddf6fe37 | 23633 | @item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} |
d77de738 ML |
23634 | Specifies the name of the target Blackfin processor. Currently, @var{cpu} |
23635 | can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518}, | |
23636 | @samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526}, | |
23637 | @samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533}, | |
23638 | @samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539}, | |
23639 | @samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549}, | |
23640 | @samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m}, | |
23641 | @samp{bf561}, @samp{bf592}. | |
23642 | ||
23643 | The optional @var{sirevision} specifies the silicon revision of the target | |
23644 | Blackfin processor. Any workarounds available for the targeted silicon revision | |
23645 | are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled. | |
23646 | If @var{sirevision} is @samp{any}, all workarounds for the targeted processor | |
23647 | are enabled. The @code{__SILICON_REVISION__} macro is defined to two | |
23648 | hexadecimal digits representing the major and minor numbers in the silicon | |
23649 | revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__} | |
23650 | is not defined. If @var{sirevision} is @samp{any}, the | |
23651 | @code{__SILICON_REVISION__} is defined to be @code{0xffff}. | |
23652 | If this optional @var{sirevision} is not used, GCC assumes the latest known | |
23653 | silicon revision of the targeted Blackfin processor. | |
23654 | ||
23655 | GCC defines a preprocessor macro for the specified @var{cpu}. | |
23656 | For the @samp{bfin-elf} toolchain, this option causes the hardware BSP | |
23657 | provided by libgloss to be linked in if @option{-msim} is not given. | |
23658 | ||
23659 | Without this option, @samp{bf532} is used as the processor by default. | |
23660 | ||
23661 | Note that support for @samp{bf561} is incomplete. For @samp{bf561}, | |
23662 | only the preprocessor macro is defined. | |
23663 | ||
d77de738 | 23664 | @opindex msim |
ddf6fe37 | 23665 | @item -msim |
d77de738 ML |
23666 | Specifies that the program will be run on the simulator. This causes |
23667 | the simulator BSP provided by libgloss to be linked in. This option | |
23668 | has effect only for @samp{bfin-elf} toolchain. | |
23669 | Certain other options, such as @option{-mid-shared-library} and | |
23670 | @option{-mfdpic}, imply @option{-msim}. | |
23671 | ||
d77de738 | 23672 | @opindex momit-leaf-frame-pointer |
ddf6fe37 | 23673 | @item -momit-leaf-frame-pointer |
d77de738 ML |
23674 | Don't keep the frame pointer in a register for leaf functions. This |
23675 | avoids the instructions to save, set up and restore frame pointers and | |
23676 | makes an extra register available in leaf functions. | |
23677 | ||
d77de738 | 23678 | @opindex mspecld-anomaly |
ddf6fe37 | 23679 | @item -mspecld-anomaly |
d77de738 ML |
23680 | When enabled, the compiler ensures that the generated code does not |
23681 | contain speculative loads after jump instructions. If this option is used, | |
23682 | @code{__WORKAROUND_SPECULATIVE_LOADS} is defined. | |
23683 | ||
d77de738 ML |
23684 | @opindex mno-specld-anomaly |
23685 | @opindex mspecld-anomaly | |
ddf6fe37 | 23686 | @item -mno-specld-anomaly |
d77de738 ML |
23687 | Don't generate extra code to prevent speculative loads from occurring. |
23688 | ||
d77de738 | 23689 | @opindex mcsync-anomaly |
ddf6fe37 | 23690 | @item -mcsync-anomaly |
d77de738 ML |
23691 | When enabled, the compiler ensures that the generated code does not |
23692 | contain CSYNC or SSYNC instructions too soon after conditional branches. | |
23693 | If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined. | |
23694 | ||
d77de738 ML |
23695 | @opindex mno-csync-anomaly |
23696 | @opindex mcsync-anomaly | |
ddf6fe37 | 23697 | @item -mno-csync-anomaly |
d77de738 ML |
23698 | Don't generate extra code to prevent CSYNC or SSYNC instructions from |
23699 | occurring too soon after a conditional branch. | |
23700 | ||
d77de738 | 23701 | @opindex mlow64k |
ddf6fe37 | 23702 | @item -mlow64k |
d77de738 ML |
23703 | When enabled, the compiler is free to take advantage of the knowledge that |
23704 | the entire program fits into the low 64k of memory. | |
23705 | ||
d77de738 | 23706 | @opindex mno-low64k |
ddf6fe37 | 23707 | @item -mno-low64k |
d77de738 ML |
23708 | Assume that the program is arbitrarily large. This is the default. |
23709 | ||
d77de738 | 23710 | @opindex mstack-check-l1 |
ddf6fe37 | 23711 | @item -mstack-check-l1 |
d77de738 ML |
23712 | Do stack checking using information placed into L1 scratchpad memory by the |
23713 | uClinux kernel. | |
23714 | ||
d77de738 | 23715 | @opindex mid-shared-library |
ddf6fe37 | 23716 | @item -mid-shared-library |
d77de738 ML |
23717 | Generate code that supports shared libraries via the library ID method. |
23718 | This allows for execute in place and shared libraries in an environment | |
23719 | without virtual memory management. This option implies @option{-fPIC}. | |
23720 | With a @samp{bfin-elf} target, this option implies @option{-msim}. | |
23721 | ||
d77de738 ML |
23722 | @opindex mno-id-shared-library |
23723 | @opindex mid-shared-library | |
ddf6fe37 | 23724 | @item -mno-id-shared-library |
d77de738 ML |
23725 | Generate code that doesn't assume ID-based shared libraries are being used. |
23726 | This is the default. | |
23727 | ||
d77de738 | 23728 | @opindex mleaf-id-shared-library |
ddf6fe37 | 23729 | @item -mleaf-id-shared-library |
d77de738 ML |
23730 | Generate code that supports shared libraries via the library ID method, |
23731 | but assumes that this library or executable won't link against any other | |
23732 | ID shared libraries. That allows the compiler to use faster code for jumps | |
23733 | and calls. | |
23734 | ||
d77de738 ML |
23735 | @opindex mno-leaf-id-shared-library |
23736 | @opindex mleaf-id-shared-library | |
ddf6fe37 | 23737 | @item -mno-leaf-id-shared-library |
d77de738 ML |
23738 | Do not assume that the code being compiled won't link against any ID shared |
23739 | libraries. Slower code is generated for jump and call insns. | |
23740 | ||
d77de738 | 23741 | @opindex mshared-library-id |
ddf6fe37 | 23742 | @item -mshared-library-id=n |
d77de738 ML |
23743 | Specifies the identification number of the ID-based shared library being |
23744 | compiled. Specifying a value of 0 generates more compact code; specifying | |
23745 | other values forces the allocation of that number to the current | |
23746 | library but is no more space- or time-efficient than omitting this option. | |
23747 | ||
d77de738 | 23748 | @opindex msep-data |
ddf6fe37 | 23749 | @item -msep-data |
d77de738 ML |
23750 | Generate code that allows the data segment to be located in a different |
23751 | area of memory from the text segment. This allows for execute in place in | |
23752 | an environment without virtual memory management by eliminating relocations | |
23753 | against the text section. | |
23754 | ||
d77de738 ML |
23755 | @opindex mno-sep-data |
23756 | @opindex msep-data | |
ddf6fe37 | 23757 | @item -mno-sep-data |
d77de738 ML |
23758 | Generate code that assumes that the data segment follows the text segment. |
23759 | This is the default. | |
23760 | ||
d77de738 ML |
23761 | @opindex mlong-calls |
23762 | @opindex mno-long-calls | |
ddf6fe37 AA |
23763 | @item -mlong-calls |
23764 | @itemx -mno-long-calls | |
d77de738 ML |
23765 | Tells the compiler to perform function calls by first loading the |
23766 | address of the function into a register and then performing a subroutine | |
23767 | call on this register. This switch is needed if the target function | |
23768 | lies outside of the 24-bit addressing range of the offset-based | |
23769 | version of subroutine call instruction. | |
23770 | ||
23771 | This feature is not enabled by default. Specifying | |
23772 | @option{-mno-long-calls} restores the default behavior. Note these | |
23773 | switches have no effect on how the compiler generates code to handle | |
23774 | function calls via function pointers. | |
23775 | ||
d77de738 | 23776 | @opindex mfast-fp |
ddf6fe37 | 23777 | @item -mfast-fp |
d77de738 ML |
23778 | Link with the fast floating-point library. This library relaxes some of |
23779 | the IEEE floating-point standard's rules for checking inputs against | |
23780 | Not-a-Number (NAN), in the interest of performance. | |
23781 | ||
d77de738 | 23782 | @opindex minline-plt |
ddf6fe37 | 23783 | @item -minline-plt |
d77de738 ML |
23784 | Enable inlining of PLT entries in function calls to functions that are |
23785 | not known to bind locally. It has no effect without @option{-mfdpic}. | |
23786 | ||
d77de738 | 23787 | @opindex mmulticore |
ddf6fe37 | 23788 | @item -mmulticore |
d77de738 ML |
23789 | Build a standalone application for multicore Blackfin processors. |
23790 | This option causes proper start files and link scripts supporting | |
23791 | multicore to be used, and defines the macro @code{__BFIN_MULTICORE}. | |
23792 | It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}. | |
23793 | ||
23794 | This option can be used with @option{-mcorea} or @option{-mcoreb}, which | |
23795 | selects the one-application-per-core programming model. Without | |
23796 | @option{-mcorea} or @option{-mcoreb}, the single-application/dual-core | |
23797 | programming model is used. In this model, the main function of Core B | |
23798 | should be named as @code{coreb_main}. | |
23799 | ||
23800 | If this option is not used, the single-core application programming | |
23801 | model is used. | |
23802 | ||
d77de738 | 23803 | @opindex mcorea |
ddf6fe37 | 23804 | @item -mcorea |
d77de738 ML |
23805 | Build a standalone application for Core A of BF561 when using |
23806 | the one-application-per-core programming model. Proper start files | |
23807 | and link scripts are used to support Core A, and the macro | |
23808 | @code{__BFIN_COREA} is defined. | |
23809 | This option can only be used in conjunction with @option{-mmulticore}. | |
23810 | ||
d77de738 | 23811 | @opindex mcoreb |
ddf6fe37 | 23812 | @item -mcoreb |
d77de738 ML |
23813 | Build a standalone application for Core B of BF561 when using |
23814 | the one-application-per-core programming model. Proper start files | |
23815 | and link scripts are used to support Core B, and the macro | |
23816 | @code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main} | |
23817 | should be used instead of @code{main}. | |
23818 | This option can only be used in conjunction with @option{-mmulticore}. | |
23819 | ||
d77de738 | 23820 | @opindex msdram |
ddf6fe37 | 23821 | @item -msdram |
d77de738 ML |
23822 | Build a standalone application for SDRAM. Proper start files and |
23823 | link scripts are used to put the application into SDRAM, and the macro | |
23824 | @code{__BFIN_SDRAM} is defined. | |
23825 | The loader should initialize SDRAM before loading the application. | |
23826 | ||
d77de738 | 23827 | @opindex micplb |
ddf6fe37 | 23828 | @item -micplb |
d77de738 ML |
23829 | Assume that ICPLBs are enabled at run time. This has an effect on certain |
23830 | anomaly workarounds. For Linux targets, the default is to assume ICPLBs | |
23831 | are enabled; for standalone applications the default is off. | |
23832 | @end table | |
23833 | ||
23834 | @node C6X Options | |
23835 | @subsection C6X Options | |
23836 | @cindex C6X Options | |
23837 | ||
23838 | @table @gcctabopt | |
d77de738 | 23839 | @opindex march |
ddf6fe37 | 23840 | @item -march=@var{name} |
d77de738 ML |
23841 | This specifies the name of the target architecture. GCC uses this |
23842 | name to determine what kind of instructions it can emit when generating | |
23843 | assembly code. Permissible names are: @samp{c62x}, | |
23844 | @samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}. | |
23845 | ||
d77de738 | 23846 | @opindex mbig-endian |
ddf6fe37 | 23847 | @item -mbig-endian |
d77de738 ML |
23848 | Generate code for a big-endian target. |
23849 | ||
d77de738 | 23850 | @opindex mlittle-endian |
ddf6fe37 | 23851 | @item -mlittle-endian |
d77de738 ML |
23852 | Generate code for a little-endian target. This is the default. |
23853 | ||
d77de738 | 23854 | @opindex msim |
ddf6fe37 | 23855 | @item -msim |
d77de738 ML |
23856 | Choose startup files and linker script suitable for the simulator. |
23857 | ||
d77de738 | 23858 | @opindex msdata=default |
ddf6fe37 | 23859 | @item -msdata=default |
d77de738 ML |
23860 | Put small global and static data in the @code{.neardata} section, |
23861 | which is pointed to by register @code{B14}. Put small uninitialized | |
23862 | global and static data in the @code{.bss} section, which is adjacent | |
23863 | to the @code{.neardata} section. Put small read-only data into the | |
23864 | @code{.rodata} section. The corresponding sections used for large | |
23865 | pieces of data are @code{.fardata}, @code{.far} and @code{.const}. | |
23866 | ||
d77de738 | 23867 | @opindex msdata=all |
ddf6fe37 | 23868 | @item -msdata=all |
d77de738 ML |
23869 | Put all data, not just small objects, into the sections reserved for |
23870 | small data, and use addressing relative to the @code{B14} register to | |
23871 | access them. | |
23872 | ||
d77de738 | 23873 | @opindex msdata=none |
ddf6fe37 | 23874 | @item -msdata=none |
d77de738 ML |
23875 | Make no use of the sections reserved for small data, and use absolute |
23876 | addresses to access all data. Put all initialized global and static | |
23877 | data in the @code{.fardata} section, and all uninitialized data in the | |
23878 | @code{.far} section. Put all constant data into the @code{.const} | |
23879 | section. | |
23880 | @end table | |
23881 | ||
23882 | @node CRIS Options | |
23883 | @subsection CRIS Options | |
23884 | @cindex CRIS Options | |
23885 | ||
23886 | These options are defined specifically for the CRIS ports. | |
23887 | ||
23888 | @table @gcctabopt | |
d77de738 ML |
23889 | @opindex march |
23890 | @opindex mcpu | |
ddf6fe37 AA |
23891 | @item -march=@var{architecture-type} |
23892 | @itemx -mcpu=@var{architecture-type} | |
d77de738 ML |
23893 | Generate code for the specified architecture. The choices for |
23894 | @var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for | |
23895 | respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@. | |
23896 | Default is @samp{v0}. | |
23897 | ||
d77de738 | 23898 | @opindex mtune |
ddf6fe37 | 23899 | @item -mtune=@var{architecture-type} |
d77de738 ML |
23900 | Tune to @var{architecture-type} everything applicable about the generated |
23901 | code, except for the ABI and the set of available instructions. The | |
23902 | choices for @var{architecture-type} are the same as for | |
23903 | @option{-march=@var{architecture-type}}. | |
23904 | ||
d77de738 | 23905 | @opindex mmax-stack-frame |
ddf6fe37 | 23906 | @item -mmax-stack-frame=@var{n} |
d77de738 ML |
23907 | Warn when the stack frame of a function exceeds @var{n} bytes. |
23908 | ||
d77de738 ML |
23909 | @opindex metrax4 |
23910 | @opindex metrax100 | |
ddf6fe37 AA |
23911 | @item -metrax4 |
23912 | @itemx -metrax100 | |
d77de738 ML |
23913 | The options @option{-metrax4} and @option{-metrax100} are synonyms for |
23914 | @option{-march=v3} and @option{-march=v8} respectively. | |
23915 | ||
d77de738 ML |
23916 | @opindex mmul-bug-workaround |
23917 | @opindex mno-mul-bug-workaround | |
ddf6fe37 AA |
23918 | @item -mmul-bug-workaround |
23919 | @itemx -mno-mul-bug-workaround | |
d77de738 ML |
23920 | Work around a bug in the @code{muls} and @code{mulu} instructions for CPU |
23921 | models where it applies. This option is disabled by default. | |
23922 | ||
d77de738 | 23923 | @opindex mpdebug |
ddf6fe37 | 23924 | @item -mpdebug |
d77de738 ML |
23925 | Enable CRIS-specific verbose debug-related information in the assembly |
23926 | code. This option also has the effect of turning off the @samp{#NO_APP} | |
23927 | formatted-code indicator to the assembler at the beginning of the | |
23928 | assembly file. | |
23929 | ||
d77de738 | 23930 | @opindex mcc-init |
ddf6fe37 | 23931 | @item -mcc-init |
d77de738 ML |
23932 | Do not use condition-code results from previous instruction; always emit |
23933 | compare and test instructions before use of condition codes. | |
23934 | ||
d77de738 ML |
23935 | @opindex mno-side-effects |
23936 | @opindex mside-effects | |
ddf6fe37 | 23937 | @item -mno-side-effects |
d77de738 ML |
23938 | Do not emit instructions with side effects in addressing modes other than |
23939 | post-increment. | |
23940 | ||
d77de738 ML |
23941 | @opindex mstack-align |
23942 | @opindex mno-stack-align | |
23943 | @opindex mdata-align | |
23944 | @opindex mno-data-align | |
23945 | @opindex mconst-align | |
23946 | @opindex mno-const-align | |
ddf6fe37 AA |
23947 | @item -mstack-align |
23948 | @itemx -mno-stack-align | |
23949 | @itemx -mdata-align | |
23950 | @itemx -mno-data-align | |
23951 | @itemx -mconst-align | |
23952 | @itemx -mno-const-align | |
d77de738 ML |
23953 | These options (@samp{no-} options) arrange (eliminate arrangements) for the |
23954 | stack frame, individual data and constants to be aligned for the maximum | |
23955 | single data access size for the chosen CPU model. The default is to | |
23956 | arrange for 32-bit alignment. ABI details such as structure layout are | |
23957 | not affected by these options. | |
23958 | ||
d77de738 ML |
23959 | @opindex m32-bit |
23960 | @opindex m16-bit | |
23961 | @opindex m8-bit | |
ddf6fe37 AA |
23962 | @item -m32-bit |
23963 | @itemx -m16-bit | |
23964 | @itemx -m8-bit | |
d77de738 ML |
23965 | Similar to the stack- data- and const-align options above, these options |
23966 | arrange for stack frame, writable data and constants to all be 32-bit, | |
23967 | 16-bit or 8-bit aligned. The default is 32-bit alignment. | |
23968 | ||
d77de738 ML |
23969 | @opindex mno-prologue-epilogue |
23970 | @opindex mprologue-epilogue | |
ddf6fe37 AA |
23971 | @item -mno-prologue-epilogue |
23972 | @itemx -mprologue-epilogue | |
d77de738 ML |
23973 | With @option{-mno-prologue-epilogue}, the normal function prologue and |
23974 | epilogue which set up the stack frame are omitted and no return | |
23975 | instructions or return sequences are generated in the code. Use this | |
23976 | option only together with visual inspection of the compiled code: no | |
23977 | warnings or errors are generated when call-saved registers must be saved, | |
23978 | or storage for local variables needs to be allocated. | |
23979 | ||
d77de738 | 23980 | @opindex melf |
ddf6fe37 | 23981 | @item -melf |
d77de738 ML |
23982 | Legacy no-op option. |
23983 | ||
d77de738 | 23984 | @opindex sim |
ddf6fe37 | 23985 | @item -sim |
d77de738 ML |
23986 | This option arranges |
23987 | to link with input-output functions from a simulator library. Code, | |
23988 | initialized data and zero-initialized data are allocated consecutively. | |
23989 | ||
d77de738 | 23990 | @opindex sim2 |
ddf6fe37 | 23991 | @item -sim2 |
d77de738 ML |
23992 | Like @option{-sim}, but pass linker options to locate initialized data at |
23993 | 0x40000000 and zero-initialized data at 0x80000000. | |
23994 | @end table | |
23995 | ||
23996 | @node C-SKY Options | |
23997 | @subsection C-SKY Options | |
23998 | @cindex C-SKY Options | |
23999 | ||
24000 | GCC supports these options when compiling for C-SKY V2 processors. | |
24001 | ||
24002 | @table @gcctabopt | |
24003 | ||
d77de738 | 24004 | @opindex march= |
ddf6fe37 | 24005 | @item -march=@var{arch} |
d77de738 ML |
24006 | Specify the C-SKY target architecture. Valid values for @var{arch} are: |
24007 | @samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}. | |
24008 | The default is @samp{ck810}. | |
24009 | ||
d77de738 | 24010 | @opindex mcpu= |
ddf6fe37 | 24011 | @item -mcpu=@var{cpu} |
d77de738 ML |
24012 | Specify the C-SKY target processor. Valid values for @var{cpu} are: |
24013 | @samp{ck801}, @samp{ck801t}, | |
24014 | @samp{ck802}, @samp{ck802t}, @samp{ck802j}, | |
24015 | @samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht}, | |
24016 | @samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh}, | |
24017 | @samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh}, | |
24018 | @samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1}, | |
24019 | @samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1}, | |
24020 | @samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1}, | |
24021 | @samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1}, | |
24022 | @samp{ck803eftr1}, @samp{ck803efhtr1}, | |
24023 | @samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf}, | |
24024 | @samp{ck803sef}, @samp{ck803seft}, | |
24025 | @samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f}, | |
24026 | @samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft}, | |
24027 | @samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv}, | |
24028 | @samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}. | |
24029 | ||
d77de738 | 24030 | @opindex mbig-endian |
d77de738 | 24031 | @opindex EB |
d77de738 | 24032 | @opindex mlittle-endian |
d77de738 | 24033 | @opindex EL |
ddf6fe37 AA |
24034 | @item -mbig-endian |
24035 | @itemx -EB | |
24036 | @itemx -mlittle-endian | |
24037 | @itemx -EL | |
d77de738 ML |
24038 | |
24039 | Select big- or little-endian code. The default is little-endian. | |
24040 | ||
d77de738 | 24041 | @opindex mfloat-abi |
ddf6fe37 | 24042 | @item -mfloat-abi=@var{name} |
d77de738 ML |
24043 | Specifies which floating-point ABI to use. Permissible values |
24044 | are: @samp{soft}, @samp{softfp} and @samp{hard}. | |
24045 | ||
24046 | Specifying @samp{soft} causes GCC to generate output containing | |
24047 | library calls for floating-point operations. | |
24048 | @samp{softfp} allows the generation of code using hardware floating-point | |
24049 | instructions, but still uses the soft-float calling conventions. | |
24050 | @samp{hard} allows generation of floating-point instructions | |
24051 | and uses FPU-specific calling conventions. | |
24052 | ||
24053 | The default depends on the specific target configuration. Note that | |
24054 | the hard-float and soft-float ABIs are not link-compatible; you must | |
24055 | compile your entire program with the same ABI, and link with a | |
24056 | compatible set of libraries. | |
24057 | ||
d77de738 | 24058 | @opindex mhard-float |
d77de738 | 24059 | @opindex msoft-float |
ddf6fe37 AA |
24060 | @item -mhard-float |
24061 | @itemx -msoft-float | |
d77de738 ML |
24062 | |
24063 | Select hardware or software floating-point implementations. | |
24064 | The default is soft float. | |
24065 | ||
ddf6fe37 | 24066 | @opindex mdouble-float |
d77de738 ML |
24067 | @item -mdouble-float |
24068 | @itemx -mno-double-float | |
d77de738 ML |
24069 | When @option{-mhard-float} is in effect, enable generation of |
24070 | double-precision float instructions. This is the default except | |
24071 | when compiling for CK803. | |
24072 | ||
ddf6fe37 | 24073 | @opindex mfdivdu |
d77de738 ML |
24074 | @item -mfdivdu |
24075 | @itemx -mno-fdivdu | |
d77de738 ML |
24076 | When @option{-mhard-float} is in effect, enable generation of |
24077 | @code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions. | |
24078 | This is the default except when compiling for CK803. | |
24079 | ||
d77de738 | 24080 | @opindex mfpu= |
ddf6fe37 | 24081 | @item -mfpu=@var{fpu} |
d77de738 ML |
24082 | Select the floating-point processor. This option can only be used with |
24083 | @option{-mhard-float}. | |
24084 | Values for @var{fpu} are | |
24085 | @samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}), | |
24086 | @samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and | |
24087 | @samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}). | |
24088 | ||
ddf6fe37 | 24089 | @opindex melrw |
d77de738 ML |
24090 | @item -melrw |
24091 | @itemx -mno-elrw | |
d77de738 ML |
24092 | Enable the extended @code{lrw} instruction. This option defaults to on |
24093 | for CK801 and off otherwise. | |
24094 | ||
ddf6fe37 | 24095 | @opindex mistack |
d77de738 ML |
24096 | @item -mistack |
24097 | @itemx -mno-istack | |
d77de738 ML |
24098 | Enable interrupt stack instructions; the default is off. |
24099 | ||
24100 | The @option{-mistack} option is required to handle the | |
24101 | @code{interrupt} and @code{isr} function attributes | |
24102 | (@pxref{C-SKY Function Attributes}). | |
24103 | ||
d77de738 | 24104 | @opindex mmp |
ddf6fe37 | 24105 | @item -mmp |
d77de738 ML |
24106 | Enable multiprocessor instructions; the default is off. |
24107 | ||
d77de738 | 24108 | @opindex mcp |
ddf6fe37 | 24109 | @item -mcp |
d77de738 ML |
24110 | Enable coprocessor instructions; the default is off. |
24111 | ||
d77de738 | 24112 | @opindex mcache |
ddf6fe37 | 24113 | @item -mcache |
d77de738 ML |
24114 | Enable coprocessor instructions; the default is off. |
24115 | ||
d77de738 | 24116 | @opindex msecurity |
ddf6fe37 | 24117 | @item -msecurity |
d77de738 ML |
24118 | Enable C-SKY security instructions; the default is off. |
24119 | ||
d77de738 | 24120 | @opindex mtrust |
ddf6fe37 | 24121 | @item -mtrust |
d77de738 ML |
24122 | Enable C-SKY trust instructions; the default is off. |
24123 | ||
d77de738 | 24124 | @opindex mdsp |
d77de738 | 24125 | @opindex medsp |
d77de738 | 24126 | @opindex mvdsp |
ddf6fe37 AA |
24127 | @item -mdsp |
24128 | @itemx -medsp | |
24129 | @itemx -mvdsp | |
d77de738 ML |
24130 | Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively. |
24131 | All of these options default to off. | |
24132 | ||
ddf6fe37 | 24133 | @opindex mdiv |
d77de738 ML |
24134 | @item -mdiv |
24135 | @itemx -mno-div | |
d77de738 ML |
24136 | Generate divide instructions. Default is off. |
24137 | ||
ddf6fe37 | 24138 | @opindex msmart |
d77de738 ML |
24139 | @item -msmart |
24140 | @itemx -mno-smart | |
d77de738 ML |
24141 | Generate code for Smart Mode, using only registers numbered 0-7 to allow |
24142 | use of 16-bit instructions. This option is ignored for CK801 where this | |
24143 | is the required behavior, and it defaults to on for CK802. | |
24144 | For other targets, the default is off. | |
24145 | ||
ddf6fe37 | 24146 | @opindex mhigh-registers |
d77de738 ML |
24147 | @item -mhigh-registers |
24148 | @itemx -mno-high-registers | |
d77de738 ML |
24149 | Generate code using the high registers numbered 16-31. This option |
24150 | is not supported on CK801, CK802, or CK803, and is enabled by default | |
24151 | for other processors. | |
24152 | ||
ddf6fe37 | 24153 | @opindex manchor |
d77de738 ML |
24154 | @item -manchor |
24155 | @itemx -mno-anchor | |
d77de738 ML |
24156 | Generate code using global anchor symbol addresses. |
24157 | ||
ddf6fe37 | 24158 | @opindex mpushpop |
d77de738 ML |
24159 | @item -mpushpop |
24160 | @itemx -mno-pushpop | |
d77de738 ML |
24161 | Generate code using @code{push} and @code{pop} instructions. This option |
24162 | defaults to on. | |
24163 | ||
ddf6fe37 | 24164 | @opindex mmultiple-stld |
d77de738 ML |
24165 | @item -mmultiple-stld |
24166 | @itemx -mstm | |
24167 | @itemx -mno-multiple-stld | |
24168 | @itemx -mno-stm | |
d77de738 ML |
24169 | Generate code using @code{stm} and @code{ldm} instructions. This option |
24170 | isn't supported on CK801 but is enabled by default on other processors. | |
24171 | ||
ddf6fe37 | 24172 | @opindex mconstpool |
d77de738 ML |
24173 | @item -mconstpool |
24174 | @itemx -mno-constpool | |
d77de738 ML |
24175 | Create constant pools in the compiler instead of deferring it to the |
24176 | assembler. This option is the default and required for correct code | |
24177 | generation on CK801 and CK802, and is optional on other processors. | |
24178 | ||
ddf6fe37 | 24179 | @opindex mstack-size |
d77de738 ML |
24180 | @item -mstack-size |
24181 | @item -mno-stack-size | |
d77de738 ML |
24182 | Emit @code{.stack_size} directives for each function in the assembly |
24183 | output. This option defaults to off. | |
24184 | ||
ddf6fe37 | 24185 | @opindex mccrt |
d77de738 ML |
24186 | @item -mccrt |
24187 | @itemx -mno-ccrt | |
d77de738 ML |
24188 | Generate code for the C-SKY compiler runtime instead of libgcc. This |
24189 | option defaults to off. | |
24190 | ||
d77de738 | 24191 | @opindex mbranch-cost= |
ddf6fe37 | 24192 | @item -mbranch-cost=@var{n} |
d77de738 ML |
24193 | Set the branch costs to roughly @code{n} instructions. The default is 1. |
24194 | ||
ddf6fe37 | 24195 | @opindex msched-prolog |
d77de738 ML |
24196 | @item -msched-prolog |
24197 | @itemx -mno-sched-prolog | |
d77de738 ML |
24198 | Permit scheduling of function prologue and epilogue sequences. Using |
24199 | this option can result in code that is not compliant with the C-SKY V2 ABI | |
24200 | prologue requirements and that cannot be debugged or backtraced. | |
24201 | It is disabled by default. | |
24202 | ||
d77de738 | 24203 | @opindex msim |
ddf6fe37 | 24204 | @item -msim |
d77de738 ML |
24205 | Links the library libsemi.a which is in compatible with simulator. Applicable |
24206 | to ELF compiler only. | |
24207 | ||
24208 | @end table | |
24209 | ||
24210 | @node Darwin Options | |
24211 | @subsection Darwin Options | |
24212 | @cindex Darwin options | |
24213 | ||
24214 | These options are defined for all architectures running the Darwin operating | |
24215 | system. | |
24216 | ||
24217 | FSF GCC on Darwin does not create ``fat'' object files; it creates | |
24218 | an object file for the single architecture that GCC was built to | |
24219 | target. Apple's GCC on Darwin does create ``fat'' files if multiple | |
24220 | @option{-arch} options are used; it does so by running the compiler or | |
24221 | linker multiple times and joining the results together with | |
24222 | @file{lipo}. | |
24223 | ||
24224 | The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or | |
24225 | @samp{i686}) is determined by the flags that specify the ISA | |
24226 | that GCC is targeting, like @option{-mcpu} or @option{-march}. The | |
24227 | @option{-force_cpusubtype_ALL} option can be used to override this. | |
24228 | ||
24229 | The Darwin tools vary in their behavior when presented with an ISA | |
24230 | mismatch. The assembler, @file{as}, only permits instructions to | |
24231 | be used that are valid for the subtype of the file it is generating, | |
24232 | so you cannot put 64-bit instructions in a @samp{ppc750} object file. | |
24233 | The linker for shared libraries, @file{/usr/bin/libtool}, fails | |
24234 | and prints an error if asked to create a shared library with a less | |
24235 | restrictive subtype than its input files (for instance, trying to put | |
24236 | a @samp{ppc970} object file in a @samp{ppc7400} library). The linker | |
24237 | for executables, @command{ld}, quietly gives the executable the most | |
24238 | restrictive subtype of any of its input files. | |
24239 | ||
24240 | @table @gcctabopt | |
d77de738 | 24241 | @opindex F |
ddf6fe37 | 24242 | @item -F@var{dir} |
d77de738 ML |
24243 | Add the framework directory @var{dir} to the head of the list of |
24244 | directories to be searched for header files. These directories are | |
24245 | interleaved with those specified by @option{-I} options and are | |
24246 | scanned in a left-to-right order. | |
24247 | ||
24248 | A framework directory is a directory with frameworks in it. A | |
24249 | framework is a directory with a @file{Headers} and/or | |
24250 | @file{PrivateHeaders} directory contained directly in it that ends | |
24251 | in @file{.framework}. The name of a framework is the name of this | |
24252 | directory excluding the @file{.framework}. Headers associated with | |
24253 | the framework are found in one of those two directories, with | |
24254 | @file{Headers} being searched first. A subframework is a framework | |
24255 | directory that is in a framework's @file{Frameworks} directory. | |
24256 | Includes of subframework headers can only appear in a header of a | |
24257 | framework that contains the subframework, or in a sibling subframework | |
24258 | header. Two subframeworks are siblings if they occur in the same | |
24259 | framework. A subframework should not have the same name as a | |
24260 | framework; a warning is issued if this is violated. Currently a | |
24261 | subframework cannot have subframeworks; in the future, the mechanism | |
24262 | may be extended to support this. The standard frameworks can be found | |
24263 | in @file{/System/Library/Frameworks} and | |
24264 | @file{/Library/Frameworks}. An example include looks like | |
24265 | @code{#include <Framework/header.h>}, where @file{Framework} denotes | |
24266 | the name of the framework and @file{header.h} is found in the | |
24267 | @file{PrivateHeaders} or @file{Headers} directory. | |
24268 | ||
d77de738 | 24269 | @opindex iframework |
ddf6fe37 | 24270 | @item -iframework@var{dir} |
d77de738 ML |
24271 | Like @option{-F} except the directory is a treated as a system |
24272 | directory. The main difference between this @option{-iframework} and | |
24273 | @option{-F} is that with @option{-iframework} the compiler does not | |
24274 | warn about constructs contained within header files found via | |
24275 | @var{dir}. This option is valid only for the C family of languages. | |
24276 | ||
d77de738 | 24277 | @opindex gused |
ddf6fe37 | 24278 | @item -gused |
d77de738 ML |
24279 | Emit debugging information for symbols that are used. For stabs |
24280 | debugging format, this enables @option{-feliminate-unused-debug-symbols}. | |
24281 | This is by default ON@. | |
24282 | ||
d77de738 | 24283 | @opindex gfull |
ddf6fe37 | 24284 | @item -gfull |
d77de738 ML |
24285 | Emit debugging information for all symbols and types. |
24286 | ||
cdd4b3c0 IS |
24287 | @opindex fconstant-cfstrings |
24288 | @item -fconstant-cfstrings | |
24289 | The @option{-fconstant-cfstrings} is an alias for @option{-mconstant-cfstrings}. | |
24290 | ||
24291 | @opindex mconstant-cfstrings | |
24292 | @item -mconstant-cfstrings | |
24293 | When the NeXT runtime is being used (the default on these systems), override | |
24294 | any @option{-fconstant-string-class} setting and cause @code{@@"@dots{}"} | |
24295 | literals to be laid out as constant CoreFoundation strings. | |
24296 | ||
24297 | @opindex mmacosx-version-min | |
d77de738 | 24298 | @item -mmacosx-version-min=@var{version} |
cdd4b3c0 IS |
24299 | The earliest version of MacOS X that this executable will run on is |
24300 | @var{version}. Typical values supported for @var{version} include @code{12}, | |
24301 | @code{10.12}, and @code{10.5.8}. | |
d77de738 ML |
24302 | |
24303 | If the compiler was built to use the system's headers by default, | |
24304 | then the default for this option is the system version on which the | |
24305 | compiler is running, otherwise the default is to make choices that | |
24306 | are compatible with as many systems and code bases as possible. | |
24307 | ||
d77de738 | 24308 | @opindex mkernel |
ddf6fe37 | 24309 | @item -mkernel |
d77de738 ML |
24310 | Enable kernel development mode. The @option{-mkernel} option sets |
24311 | @option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit}, | |
24312 | @option{-fno-exceptions}, @option{-fno-non-call-exceptions}, | |
24313 | @option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where | |
24314 | applicable. This mode also sets @option{-mno-altivec}, | |
24315 | @option{-msoft-float}, @option{-fno-builtin} and | |
24316 | @option{-mlong-branch} for PowerPC targets. | |
24317 | ||
d77de738 | 24318 | @opindex mone-byte-bool |
ddf6fe37 | 24319 | @item -mone-byte-bool |
d77de738 ML |
24320 | Override the defaults for @code{bool} so that @code{sizeof(bool)==1}. |
24321 | By default @code{sizeof(bool)} is @code{4} when compiling for | |
24322 | Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this | |
24323 | option has no effect on x86. | |
24324 | ||
24325 | @strong{Warning:} The @option{-mone-byte-bool} switch causes GCC | |
24326 | to generate code that is not binary compatible with code generated | |
24327 | without that switch. Using this switch may require recompiling all | |
24328 | other modules in a program, including system libraries. Use this | |
24329 | switch to conform to a non-default data model. | |
24330 | ||
d77de738 ML |
24331 | @opindex mfix-and-continue |
24332 | @opindex ffix-and-continue | |
24333 | @opindex findirect-data | |
ddf6fe37 AA |
24334 | @item -mfix-and-continue |
24335 | @itemx -ffix-and-continue | |
24336 | @itemx -findirect-data | |
d77de738 ML |
24337 | Generate code suitable for fast turnaround development, such as to |
24338 | allow GDB to dynamically load @file{.o} files into already-running | |
24339 | programs. @option{-findirect-data} and @option{-ffix-and-continue} | |
24340 | are provided for backwards compatibility. | |
24341 | ||
d77de738 | 24342 | @opindex all_load |
ddf6fe37 | 24343 | @item -all_load |
d77de738 ML |
24344 | Loads all members of static archive libraries. |
24345 | See man ld(1) for more information. | |
24346 | ||
d77de738 | 24347 | @opindex arch_errors_fatal |
ddf6fe37 | 24348 | @item -arch_errors_fatal |
d77de738 ML |
24349 | Cause the errors having to do with files that have the wrong architecture |
24350 | to be fatal. | |
24351 | ||
d77de738 | 24352 | @opindex bind_at_load |
ddf6fe37 | 24353 | @item -bind_at_load |
d77de738 ML |
24354 | Causes the output file to be marked such that the dynamic linker will |
24355 | bind all undefined references when the file is loaded or launched. | |
24356 | ||
d77de738 | 24357 | @opindex bundle |
ddf6fe37 | 24358 | @item -bundle |
d77de738 ML |
24359 | Produce a Mach-o bundle format file. |
24360 | See man ld(1) for more information. | |
24361 | ||
d77de738 | 24362 | @opindex bundle_loader |
ddf6fe37 | 24363 | @item -bundle_loader @var{executable} |
d77de738 ML |
24364 | This option specifies the @var{executable} that will load the build |
24365 | output file being linked. See man ld(1) for more information. | |
24366 | ||
d77de738 | 24367 | @opindex dynamiclib |
ddf6fe37 | 24368 | @item -dynamiclib |
d77de738 ML |
24369 | When passed this option, GCC produces a dynamic library instead of |
24370 | an executable when linking, using the Darwin @file{libtool} command. | |
24371 | ||
d77de738 | 24372 | @opindex force_cpusubtype_ALL |
ddf6fe37 | 24373 | @item -force_cpusubtype_ALL |
d77de738 ML |
24374 | This causes GCC's output file to have the @samp{ALL} subtype, instead of |
24375 | one controlled by the @option{-mcpu} or @option{-march} option. | |
24376 | ||
24377 | @item -allowable_client @var{client_name} | |
24378 | @itemx -client_name | |
24379 | @itemx -compatibility_version | |
24380 | @itemx -current_version | |
24381 | @itemx -dead_strip | |
24382 | @itemx -dependency-file | |
24383 | @itemx -dylib_file | |
24384 | @itemx -dylinker_install_name | |
24385 | @itemx -dynamic | |
24386 | @itemx -exported_symbols_list | |
24387 | @itemx -filelist | |
24388 | @need 800 | |
24389 | @itemx -flat_namespace | |
24390 | @itemx -force_flat_namespace | |
24391 | @itemx -headerpad_max_install_names | |
24392 | @itemx -image_base | |
24393 | @itemx -init | |
24394 | @itemx -install_name | |
24395 | @itemx -keep_private_externs | |
24396 | @itemx -multi_module | |
24397 | @itemx -multiply_defined | |
24398 | @itemx -multiply_defined_unused | |
24399 | @need 800 | |
24400 | @itemx -noall_load | |
24401 | @itemx -no_dead_strip_inits_and_terms | |
24402 | @itemx -nofixprebinding | |
24403 | @itemx -nomultidefs | |
24404 | @itemx -noprebind | |
24405 | @itemx -noseglinkedit | |
24406 | @itemx -pagezero_size | |
24407 | @itemx -prebind | |
24408 | @itemx -prebind_all_twolevel_modules | |
24409 | @itemx -private_bundle | |
24410 | @need 800 | |
24411 | @itemx -read_only_relocs | |
24412 | @itemx -sectalign | |
24413 | @itemx -sectobjectsymbols | |
24414 | @itemx -whyload | |
24415 | @itemx -seg1addr | |
24416 | @itemx -sectcreate | |
24417 | @itemx -sectobjectsymbols | |
24418 | @itemx -sectorder | |
24419 | @itemx -segaddr | |
24420 | @itemx -segs_read_only_addr | |
24421 | @need 800 | |
24422 | @itemx -segs_read_write_addr | |
24423 | @itemx -seg_addr_table | |
24424 | @itemx -seg_addr_table_filename | |
24425 | @itemx -seglinkedit | |
24426 | @itemx -segprot | |
24427 | @itemx -segs_read_only_addr | |
24428 | @itemx -segs_read_write_addr | |
24429 | @itemx -single_module | |
24430 | @itemx -static | |
24431 | @itemx -sub_library | |
24432 | @need 800 | |
d77de738 ML |
24433 | @opindex allowable_client |
24434 | @opindex client_name | |
24435 | @opindex compatibility_version | |
24436 | @opindex current_version | |
24437 | @opindex dead_strip | |
24438 | @opindex dependency-file | |
24439 | @opindex dylib_file | |
24440 | @opindex dylinker_install_name | |
24441 | @opindex dynamic | |
24442 | @opindex exported_symbols_list | |
24443 | @opindex filelist | |
24444 | @opindex flat_namespace | |
24445 | @opindex force_flat_namespace | |
24446 | @opindex headerpad_max_install_names | |
24447 | @opindex image_base | |
24448 | @opindex init | |
24449 | @opindex install_name | |
24450 | @opindex keep_private_externs | |
24451 | @opindex multi_module | |
24452 | @opindex multiply_defined | |
24453 | @opindex multiply_defined_unused | |
24454 | @opindex noall_load | |
24455 | @opindex no_dead_strip_inits_and_terms | |
24456 | @opindex nofixprebinding | |
24457 | @opindex nomultidefs | |
24458 | @opindex noprebind | |
24459 | @opindex noseglinkedit | |
24460 | @opindex pagezero_size | |
24461 | @opindex prebind | |
24462 | @opindex prebind_all_twolevel_modules | |
24463 | @opindex private_bundle | |
24464 | @opindex read_only_relocs | |
24465 | @opindex sectalign | |
24466 | @opindex sectobjectsymbols | |
24467 | @opindex whyload | |
24468 | @opindex seg1addr | |
24469 | @opindex sectcreate | |
24470 | @opindex sectobjectsymbols | |
24471 | @opindex sectorder | |
24472 | @opindex segaddr | |
24473 | @opindex segs_read_only_addr | |
24474 | @opindex segs_read_write_addr | |
24475 | @opindex seg_addr_table | |
24476 | @opindex seg_addr_table_filename | |
24477 | @opindex seglinkedit | |
24478 | @opindex segprot | |
24479 | @opindex segs_read_only_addr | |
24480 | @opindex segs_read_write_addr | |
24481 | @opindex single_module | |
24482 | @opindex static | |
24483 | @opindex sub_library | |
24484 | @opindex sub_umbrella | |
24485 | @opindex twolevel_namespace | |
24486 | @opindex umbrella | |
24487 | @opindex undefined | |
24488 | @opindex unexported_symbols_list | |
24489 | @opindex weak_reference_mismatches | |
24490 | @opindex whatsloaded | |
ddf6fe37 AA |
24491 | @itemx -sub_umbrella |
24492 | @itemx -twolevel_namespace | |
24493 | @itemx -umbrella | |
24494 | @itemx -undefined | |
24495 | @itemx -unexported_symbols_list | |
24496 | @itemx -weak_reference_mismatches | |
24497 | @itemx -whatsloaded | |
d77de738 ML |
24498 | These options are passed to the Darwin linker. The Darwin linker man page |
24499 | describes them in detail. | |
24500 | @end table | |
24501 | ||
24502 | @node DEC Alpha Options | |
24503 | @subsection DEC Alpha Options | |
24504 | ||
24505 | These @samp{-m} options are defined for the DEC Alpha implementations: | |
24506 | ||
24507 | @table @gcctabopt | |
d77de738 ML |
24508 | @opindex mno-soft-float |
24509 | @opindex msoft-float | |
ddf6fe37 AA |
24510 | @item -mno-soft-float |
24511 | @itemx -msoft-float | |
d77de738 ML |
24512 | Use (do not use) the hardware floating-point instructions for |
24513 | floating-point operations. When @option{-msoft-float} is specified, | |
24514 | functions in @file{libgcc.a} are used to perform floating-point | |
24515 | operations. Unless they are replaced by routines that emulate the | |
24516 | floating-point operations, or compiled in such a way as to call such | |
24517 | emulations routines, these routines issue floating-point | |
24518 | operations. If you are compiling for an Alpha without floating-point | |
24519 | operations, you must ensure that the library is built so as not to call | |
24520 | them. | |
24521 | ||
24522 | Note that Alpha implementations without floating-point operations are | |
24523 | required to have floating-point registers. | |
24524 | ||
d77de738 ML |
24525 | @opindex mfp-reg |
24526 | @opindex mno-fp-regs | |
ddf6fe37 AA |
24527 | @item -mfp-reg |
24528 | @itemx -mno-fp-regs | |
d77de738 ML |
24529 | Generate code that uses (does not use) the floating-point register set. |
24530 | @option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point | |
24531 | register set is not used, floating-point operands are passed in integer | |
24532 | registers as if they were integers and floating-point results are passed | |
24533 | in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence, | |
24534 | so any function with a floating-point argument or return value called by code | |
24535 | compiled with @option{-mno-fp-regs} must also be compiled with that | |
24536 | option. | |
24537 | ||
24538 | A typical use of this option is building a kernel that does not use, | |
24539 | and hence need not save and restore, any floating-point registers. | |
24540 | ||
d77de738 | 24541 | @opindex mieee |
ddf6fe37 | 24542 | @item -mieee |
d77de738 ML |
24543 | The Alpha architecture implements floating-point hardware optimized for |
24544 | maximum performance. It is mostly compliant with the IEEE floating-point | |
24545 | standard. However, for full compliance, software assistance is | |
24546 | required. This option generates code fully IEEE-compliant code | |
24547 | @emph{except} that the @var{inexact-flag} is not maintained (see below). | |
24548 | If this option is turned on, the preprocessor macro @code{_IEEE_FP} is | |
24549 | defined during compilation. The resulting code is less efficient but is | |
24550 | able to correctly support denormalized numbers and exceptional IEEE | |
24551 | values such as not-a-number and plus/minus infinity. Other Alpha | |
24552 | compilers call this option @option{-ieee_with_no_inexact}. | |
24553 | ||
d77de738 | 24554 | @opindex mieee-with-inexact |
ddf6fe37 | 24555 | @item -mieee-with-inexact |
d77de738 ML |
24556 | This is like @option{-mieee} except the generated code also maintains |
24557 | the IEEE @var{inexact-flag}. Turning on this option causes the | |
24558 | generated code to implement fully-compliant IEEE math. In addition to | |
24559 | @code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor | |
24560 | macro. On some Alpha implementations the resulting code may execute | |
24561 | significantly slower than the code generated by default. Since there is | |
24562 | very little code that depends on the @var{inexact-flag}, you should | |
24563 | normally not specify this option. Other Alpha compilers call this | |
24564 | option @option{-ieee_with_inexact}. | |
24565 | ||
d77de738 | 24566 | @opindex mfp-trap-mode |
ddf6fe37 | 24567 | @item -mfp-trap-mode=@var{trap-mode} |
d77de738 ML |
24568 | This option controls what floating-point related traps are enabled. |
24569 | Other Alpha compilers call this option @option{-fptm @var{trap-mode}}. | |
24570 | The trap mode can be set to one of four values: | |
24571 | ||
24572 | @table @samp | |
24573 | @item n | |
24574 | This is the default (normal) setting. The only traps that are enabled | |
24575 | are the ones that cannot be disabled in software (e.g., division by zero | |
24576 | trap). | |
24577 | ||
24578 | @item u | |
24579 | In addition to the traps enabled by @samp{n}, underflow traps are enabled | |
24580 | as well. | |
24581 | ||
24582 | @item su | |
24583 | Like @samp{u}, but the instructions are marked to be safe for software | |
24584 | completion (see Alpha architecture manual for details). | |
24585 | ||
24586 | @item sui | |
24587 | Like @samp{su}, but inexact traps are enabled as well. | |
24588 | @end table | |
24589 | ||
d77de738 | 24590 | @opindex mfp-rounding-mode |
ddf6fe37 | 24591 | @item -mfp-rounding-mode=@var{rounding-mode} |
d77de738 ML |
24592 | Selects the IEEE rounding mode. Other Alpha compilers call this option |
24593 | @option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one | |
24594 | of: | |
24595 | ||
24596 | @table @samp | |
24597 | @item n | |
24598 | Normal IEEE rounding mode. Floating-point numbers are rounded towards | |
24599 | the nearest machine number or towards the even machine number in case | |
24600 | of a tie. | |
24601 | ||
24602 | @item m | |
24603 | Round towards minus infinity. | |
24604 | ||
24605 | @item c | |
24606 | Chopped rounding mode. Floating-point numbers are rounded towards zero. | |
24607 | ||
24608 | @item d | |
24609 | Dynamic rounding mode. A field in the floating-point control register | |
24610 | (@var{fpcr}, see Alpha architecture reference manual) controls the | |
24611 | rounding mode in effect. The C library initializes this register for | |
24612 | rounding towards plus infinity. Thus, unless your program modifies the | |
24613 | @var{fpcr}, @samp{d} corresponds to round towards plus infinity. | |
24614 | @end table | |
24615 | ||
d77de738 | 24616 | @opindex mtrap-precision |
ddf6fe37 | 24617 | @item -mtrap-precision=@var{trap-precision} |
d77de738 ML |
24618 | In the Alpha architecture, floating-point traps are imprecise. This |
24619 | means without software assistance it is impossible to recover from a | |
24620 | floating trap and program execution normally needs to be terminated. | |
24621 | GCC can generate code that can assist operating system trap handlers | |
24622 | in determining the exact location that caused a floating-point trap. | |
24623 | Depending on the requirements of an application, different levels of | |
24624 | precisions can be selected: | |
24625 | ||
24626 | @table @samp | |
24627 | @item p | |
24628 | Program precision. This option is the default and means a trap handler | |
24629 | can only identify which program caused a floating-point exception. | |
24630 | ||
24631 | @item f | |
24632 | Function precision. The trap handler can determine the function that | |
24633 | caused a floating-point exception. | |
24634 | ||
24635 | @item i | |
24636 | Instruction precision. The trap handler can determine the exact | |
24637 | instruction that caused a floating-point exception. | |
24638 | @end table | |
24639 | ||
24640 | Other Alpha compilers provide the equivalent options called | |
24641 | @option{-scope_safe} and @option{-resumption_safe}. | |
24642 | ||
d77de738 | 24643 | @opindex mieee-conformant |
ddf6fe37 | 24644 | @item -mieee-conformant |
d77de738 ML |
24645 | This option marks the generated code as IEEE conformant. You must not |
24646 | use this option unless you also specify @option{-mtrap-precision=i} and either | |
24647 | @option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect | |
24648 | is to emit the line @samp{.eflag 48} in the function prologue of the | |
24649 | generated assembly file. | |
24650 | ||
d77de738 | 24651 | @opindex mbuild-constants |
ddf6fe37 | 24652 | @item -mbuild-constants |
d77de738 ML |
24653 | Normally GCC examines a 32- or 64-bit integer constant to |
24654 | see if it can construct it from smaller constants in two or three | |
24655 | instructions. If it cannot, it outputs the constant as a literal and | |
24656 | generates code to load it from the data segment at run time. | |
24657 | ||
24658 | Use this option to require GCC to construct @emph{all} integer constants | |
24659 | using code, even if it takes more instructions (the maximum is six). | |
24660 | ||
24661 | You typically use this option to build a shared library dynamic | |
24662 | loader. Itself a shared library, it must relocate itself in memory | |
24663 | before it can find the variables and constants in its own data segment. | |
24664 | ||
d77de738 ML |
24665 | @opindex mbwx |
24666 | @opindex mno-bwx | |
24667 | @opindex mcix | |
24668 | @opindex mno-cix | |
24669 | @opindex mfix | |
24670 | @opindex mno-fix | |
24671 | @opindex mmax | |
24672 | @opindex mno-max | |
ddf6fe37 AA |
24673 | @item -mbwx |
24674 | @itemx -mno-bwx | |
24675 | @itemx -mcix | |
24676 | @itemx -mno-cix | |
24677 | @itemx -mfix | |
24678 | @itemx -mno-fix | |
24679 | @itemx -mmax | |
24680 | @itemx -mno-max | |
d77de738 ML |
24681 | Indicate whether GCC should generate code to use the optional BWX, |
24682 | CIX, FIX and MAX instruction sets. The default is to use the instruction | |
24683 | sets supported by the CPU type specified via @option{-mcpu=} option or that | |
24684 | of the CPU on which GCC was built if none is specified. | |
24685 | ||
d77de738 ML |
24686 | @opindex mfloat-vax |
24687 | @opindex mfloat-ieee | |
ddf6fe37 AA |
24688 | @item -mfloat-vax |
24689 | @itemx -mfloat-ieee | |
d77de738 ML |
24690 | Generate code that uses (does not use) VAX F and G floating-point |
24691 | arithmetic instead of IEEE single and double precision. | |
24692 | ||
d77de738 ML |
24693 | @opindex mexplicit-relocs |
24694 | @opindex mno-explicit-relocs | |
ddf6fe37 AA |
24695 | @item -mexplicit-relocs |
24696 | @itemx -mno-explicit-relocs | |
d77de738 ML |
24697 | Older Alpha assemblers provided no way to generate symbol relocations |
24698 | except via assembler macros. Use of these macros does not allow | |
24699 | optimal instruction scheduling. GNU binutils as of version 2.12 | |
24700 | supports a new syntax that allows the compiler to explicitly mark | |
24701 | which relocations should apply to which instructions. This option | |
24702 | is mostly useful for debugging, as GCC detects the capabilities of | |
24703 | the assembler when it is built and sets the default accordingly. | |
24704 | ||
d77de738 ML |
24705 | @opindex msmall-data |
24706 | @opindex mlarge-data | |
ddf6fe37 AA |
24707 | @item -msmall-data |
24708 | @itemx -mlarge-data | |
d77de738 ML |
24709 | When @option{-mexplicit-relocs} is in effect, static data is |
24710 | accessed via @dfn{gp-relative} relocations. When @option{-msmall-data} | |
24711 | is used, objects 8 bytes long or smaller are placed in a @dfn{small data area} | |
24712 | (the @code{.sdata} and @code{.sbss} sections) and are accessed via | |
24713 | 16-bit relocations off of the @code{$gp} register. This limits the | |
24714 | size of the small data area to 64KB, but allows the variables to be | |
24715 | directly accessed via a single instruction. | |
24716 | ||
24717 | The default is @option{-mlarge-data}. With this option the data area | |
24718 | is limited to just below 2GB@. Programs that require more than 2GB of | |
24719 | data must use @code{malloc} or @code{mmap} to allocate the data in the | |
24720 | heap instead of in the program's data segment. | |
24721 | ||
24722 | When generating code for shared libraries, @option{-fpic} implies | |
24723 | @option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}. | |
24724 | ||
d77de738 ML |
24725 | @opindex msmall-text |
24726 | @opindex mlarge-text | |
ddf6fe37 AA |
24727 | @item -msmall-text |
24728 | @itemx -mlarge-text | |
d77de738 ML |
24729 | When @option{-msmall-text} is used, the compiler assumes that the |
24730 | code of the entire program (or shared library) fits in 4MB, and is | |
24731 | thus reachable with a branch instruction. When @option{-msmall-data} | |
24732 | is used, the compiler can assume that all local symbols share the | |
24733 | same @code{$gp} value, and thus reduce the number of instructions | |
24734 | required for a function call from 4 to 1. | |
24735 | ||
24736 | The default is @option{-mlarge-text}. | |
24737 | ||
d77de738 | 24738 | @opindex mcpu |
ddf6fe37 | 24739 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
24740 | Set the instruction set and instruction scheduling parameters for |
24741 | machine type @var{cpu_type}. You can specify either the @samp{EV} | |
24742 | style name or the corresponding chip number. GCC supports scheduling | |
24743 | parameters for the EV4, EV5 and EV6 family of processors and | |
24744 | chooses the default values for the instruction set from the processor | |
24745 | you specify. If you do not specify a processor type, GCC defaults | |
24746 | to the processor on which the compiler was built. | |
24747 | ||
24748 | Supported values for @var{cpu_type} are | |
24749 | ||
24750 | @table @samp | |
24751 | @item ev4 | |
24752 | @itemx ev45 | |
24753 | @itemx 21064 | |
24754 | Schedules as an EV4 and has no instruction set extensions. | |
24755 | ||
24756 | @item ev5 | |
24757 | @itemx 21164 | |
24758 | Schedules as an EV5 and has no instruction set extensions. | |
24759 | ||
24760 | @item ev56 | |
24761 | @itemx 21164a | |
24762 | Schedules as an EV5 and supports the BWX extension. | |
24763 | ||
24764 | @item pca56 | |
24765 | @itemx 21164pc | |
24766 | @itemx 21164PC | |
24767 | Schedules as an EV5 and supports the BWX and MAX extensions. | |
24768 | ||
24769 | @item ev6 | |
24770 | @itemx 21264 | |
24771 | Schedules as an EV6 and supports the BWX, FIX, and MAX extensions. | |
24772 | ||
24773 | @item ev67 | |
24774 | @itemx 21264a | |
24775 | Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions. | |
24776 | @end table | |
24777 | ||
24778 | Native toolchains also support the value @samp{native}, | |
24779 | which selects the best architecture option for the host processor. | |
24780 | @option{-mcpu=native} has no effect if GCC does not recognize | |
24781 | the processor. | |
24782 | ||
d77de738 | 24783 | @opindex mtune |
ddf6fe37 | 24784 | @item -mtune=@var{cpu_type} |
d77de738 ML |
24785 | Set only the instruction scheduling parameters for machine type |
24786 | @var{cpu_type}. The instruction set is not changed. | |
24787 | ||
24788 | Native toolchains also support the value @samp{native}, | |
24789 | which selects the best architecture option for the host processor. | |
24790 | @option{-mtune=native} has no effect if GCC does not recognize | |
24791 | the processor. | |
24792 | ||
d77de738 | 24793 | @opindex mmemory-latency |
ddf6fe37 | 24794 | @item -mmemory-latency=@var{time} |
d77de738 ML |
24795 | Sets the latency the scheduler should assume for typical memory |
24796 | references as seen by the application. This number is highly | |
24797 | dependent on the memory access patterns used by the application | |
24798 | and the size of the external cache on the machine. | |
24799 | ||
24800 | Valid options for @var{time} are | |
24801 | ||
24802 | @table @samp | |
24803 | @item @var{number} | |
24804 | A decimal number representing clock cycles. | |
24805 | ||
24806 | @item L1 | |
24807 | @itemx L2 | |
24808 | @itemx L3 | |
24809 | @itemx main | |
24810 | The compiler contains estimates of the number of clock cycles for | |
24811 | ``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches | |
24812 | (also called Dcache, Scache, and Bcache), as well as to main memory. | |
24813 | Note that L3 is only valid for EV5. | |
24814 | ||
24815 | @end table | |
24816 | @end table | |
24817 | ||
24818 | @node eBPF Options | |
24819 | @subsection eBPF Options | |
24820 | @cindex eBPF Options | |
24821 | ||
24822 | @table @gcctabopt | |
24823 | @item -mframe-limit=@var{bytes} | |
24824 | This specifies the hard limit for frame sizes, in bytes. Currently, | |
24825 | the value that can be specified should be less than or equal to | |
24826 | @samp{32767}. Defaults to whatever limit is imposed by the version of | |
24827 | the Linux kernel targeted. | |
24828 | ||
d77de738 | 24829 | @opindex mbig-endian |
ddf6fe37 | 24830 | @item -mbig-endian |
d77de738 ML |
24831 | Generate code for a big-endian target. |
24832 | ||
d77de738 | 24833 | @opindex mlittle-endian |
ddf6fe37 | 24834 | @item -mlittle-endian |
d77de738 ML |
24835 | Generate code for a little-endian target. This is the default. |
24836 | ||
d77de738 | 24837 | @opindex mjmpext |
ddf6fe37 | 24838 | @item -mjmpext |
9cbf4286 DF |
24839 | @itemx -mno-jmpext |
24840 | Enable or disable generation of extra conditional-branch instructions. | |
d77de738 ML |
24841 | Enabled for CPU v2 and above. |
24842 | ||
d77de738 | 24843 | @opindex mjmp32 |
ddf6fe37 | 24844 | @item -mjmp32 |
9cbf4286 DF |
24845 | @itemx -mno-jmp32 |
24846 | Enable or disable generation of 32-bit jump instructions. | |
24847 | Enabled for CPU v3 and above. | |
d77de738 | 24848 | |
d77de738 | 24849 | @opindex malu32 |
ddf6fe37 | 24850 | @item -malu32 |
9cbf4286 DF |
24851 | @itemx -mno-alu32 |
24852 | Enable or disable generation of 32-bit ALU instructions. | |
24853 | Enabled for CPU v3 and above. | |
24854 | ||
24855 | @opindex mv3-atomics | |
24856 | @item -mv3-atomics | |
24857 | @itemx -mno-v3-atomics | |
24858 | Enable or disable instructions for general atomic operations introduced | |
24859 | in CPU v3. Enabled for CPU v3 and above. | |
d77de738 | 24860 | |
f1e34551 JM |
24861 | @opindex mbswap |
24862 | @item -mbswap | |
9cbf4286 DF |
24863 | @itemx -mno-bswap |
24864 | Enable or disable byte swap instructions. Enabled for CPU v4 and above. | |
f1e34551 | 24865 | |
4be3919f JM |
24866 | @opindex msdiv |
24867 | @item -msdiv | |
9cbf4286 DF |
24868 | @itemx -mno-sdiv |
24869 | Enable or disable signed division and modulus instructions. Enabled for | |
24870 | CPU v4 and above. | |
db189d02 | 24871 | |
14dab1a1 DF |
24872 | @opindex msmov |
24873 | @item -msmov | |
24874 | @itemx -mno-smov | |
24875 | Enable or disable sign-extending move and memory load instructions. | |
24876 | Enabled for CPU v4 and above. | |
24877 | ||
d77de738 | 24878 | @opindex mcpu |
ddf6fe37 | 24879 | @item -mcpu=@var{version} |
d77de738 | 24880 | This specifies which version of the eBPF ISA to target. Newer versions |
f1e34551 | 24881 | may not be supported by all kernels. The default is @samp{v4}. |
d77de738 ML |
24882 | |
24883 | Supported values for @var{version} are: | |
24884 | ||
24885 | @table @samp | |
24886 | @item v1 | |
24887 | The first stable eBPF ISA with no special features or extensions. | |
24888 | ||
24889 | @item v2 | |
24890 | Supports the jump extensions, as in @option{-mjmpext}. | |
24891 | ||
24892 | @item v3 | |
24893 | All features of v2, plus: | |
24894 | @itemize @minus | |
24895 | @item 32-bit jump operations, as in @option{-mjmp32} | |
24896 | @item 32-bit ALU operations, as in @option{-malu32} | |
db189d02 | 24897 | @item general atomic operations, as in @option{-mv3-atomics} |
d77de738 ML |
24898 | @end itemize |
24899 | ||
f1e34551 JM |
24900 | @item v4 |
24901 | All features of v3, plus: | |
24902 | @itemize @minus | |
24903 | @item Byte swap instructions, as in @option{-mbswap} | |
9cbf4286 | 24904 | @item Signed division and modulus instructions, as in @option{-msdiv} |
14dab1a1 | 24905 | @item Sign-extending move and memory load instructions, as in @option{-msmov} |
f1e34551 | 24906 | @end itemize |
d77de738 ML |
24907 | @end table |
24908 | ||
d77de738 | 24909 | @opindex mco-re |
ddf6fe37 | 24910 | @item -mco-re |
d77de738 ML |
24911 | Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and |
24912 | is implied by @option{-gbtf}. | |
24913 | ||
d77de738 | 24914 | @opindex mno-co-re |
ddf6fe37 | 24915 | @item -mno-co-re |
d77de738 ML |
24916 | Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE |
24917 | support is enabled by default when generating BTF debug information for | |
24918 | the BPF target. | |
24919 | ||
24920 | @item -mxbpf | |
24921 | Generate code for an expanded version of BPF, which relaxes some of | |
24922 | the restrictions imposed by the BPF architecture: | |
24923 | @itemize @minus | |
24924 | @item Save and restore callee-saved registers at function entry and | |
24925 | exit, respectively. | |
24926 | @end itemize | |
77d0f9ec CM |
24927 | |
24928 | @opindex masm=@var{dialect} | |
24929 | @item -masm=@var{dialect} | |
24930 | Outputs assembly instructions using eBPF selected @var{dialect}. The default | |
24931 | is @samp{normal}. | |
24932 | ||
24933 | Supported values for @var{dialect} are: | |
24934 | ||
24935 | @table @samp | |
24936 | @item normal | |
24937 | Outputs normal assembly dialect. | |
24938 | ||
24939 | @item pseudoc | |
24940 | Outputs pseudo-c assembly dialect. | |
24941 | ||
24942 | @end table | |
24943 | ||
d77de738 ML |
24944 | @end table |
24945 | ||
24946 | @node FR30 Options | |
24947 | @subsection FR30 Options | |
24948 | @cindex FR30 Options | |
24949 | ||
24950 | These options are defined specifically for the FR30 port. | |
24951 | ||
24952 | @table @gcctabopt | |
24953 | ||
d77de738 | 24954 | @opindex msmall-model |
ddf6fe37 | 24955 | @item -msmall-model |
d77de738 ML |
24956 | Use the small address space model. This can produce smaller code, but |
24957 | it does assume that all symbolic values and addresses fit into a | |
24958 | 20-bit range. | |
24959 | ||
d77de738 | 24960 | @opindex mno-lsim |
ddf6fe37 | 24961 | @item -mno-lsim |
d77de738 ML |
24962 | Assume that runtime support has been provided and so there is no need |
24963 | to include the simulator library (@file{libsim.a}) on the linker | |
24964 | command line. | |
24965 | ||
24966 | @end table | |
24967 | ||
24968 | @node FT32 Options | |
24969 | @subsection FT32 Options | |
24970 | @cindex FT32 Options | |
24971 | ||
24972 | These options are defined specifically for the FT32 port. | |
24973 | ||
24974 | @table @gcctabopt | |
24975 | ||
d77de738 | 24976 | @opindex msim |
ddf6fe37 | 24977 | @item -msim |
d77de738 ML |
24978 | Specifies that the program will be run on the simulator. This causes |
24979 | an alternate runtime startup and library to be linked. | |
24980 | You must not use this option when generating programs that will run on | |
24981 | real hardware; you must provide your own runtime library for whatever | |
24982 | I/O functions are needed. | |
24983 | ||
d77de738 | 24984 | @opindex mlra |
ddf6fe37 | 24985 | @item -mlra |
d77de738 ML |
24986 | Enable Local Register Allocation. This is still experimental for FT32, |
24987 | so by default the compiler uses standard reload. | |
24988 | ||
d77de738 | 24989 | @opindex mnodiv |
ddf6fe37 | 24990 | @item -mnodiv |
d77de738 ML |
24991 | Do not use div and mod instructions. |
24992 | ||
d77de738 | 24993 | @opindex mft32b |
ddf6fe37 | 24994 | @item -mft32b |
d77de738 ML |
24995 | Enable use of the extended instructions of the FT32B processor. |
24996 | ||
d77de738 | 24997 | @opindex mcompress |
ddf6fe37 | 24998 | @item -mcompress |
d77de738 ML |
24999 | Compress all code using the Ft32B code compression scheme. |
25000 | ||
d77de738 | 25001 | @opindex mnopm |
ddf6fe37 | 25002 | @item -mnopm |
d77de738 ML |
25003 | Do not generate code that reads program memory. |
25004 | ||
25005 | @end table | |
25006 | ||
25007 | @node FRV Options | |
25008 | @subsection FRV Options | |
25009 | @cindex FRV Options | |
25010 | ||
25011 | @table @gcctabopt | |
d77de738 | 25012 | @opindex mgpr-32 |
ddf6fe37 | 25013 | @item -mgpr-32 |
d77de738 ML |
25014 | |
25015 | Only use the first 32 general-purpose registers. | |
25016 | ||
d77de738 | 25017 | @opindex mgpr-64 |
ddf6fe37 | 25018 | @item -mgpr-64 |
d77de738 ML |
25019 | |
25020 | Use all 64 general-purpose registers. | |
25021 | ||
d77de738 | 25022 | @opindex mfpr-32 |
ddf6fe37 | 25023 | @item -mfpr-32 |
d77de738 ML |
25024 | |
25025 | Use only the first 32 floating-point registers. | |
25026 | ||
d77de738 | 25027 | @opindex mfpr-64 |
ddf6fe37 | 25028 | @item -mfpr-64 |
d77de738 ML |
25029 | |
25030 | Use all 64 floating-point registers. | |
25031 | ||
d77de738 | 25032 | @opindex mhard-float |
ddf6fe37 | 25033 | @item -mhard-float |
d77de738 ML |
25034 | |
25035 | Use hardware instructions for floating-point operations. | |
25036 | ||
d77de738 | 25037 | @opindex msoft-float |
ddf6fe37 | 25038 | @item -msoft-float |
d77de738 ML |
25039 | |
25040 | Use library routines for floating-point operations. | |
25041 | ||
d77de738 | 25042 | @opindex malloc-cc |
ddf6fe37 | 25043 | @item -malloc-cc |
d77de738 ML |
25044 | |
25045 | Dynamically allocate condition code registers. | |
25046 | ||
d77de738 | 25047 | @opindex mfixed-cc |
ddf6fe37 | 25048 | @item -mfixed-cc |
d77de738 ML |
25049 | |
25050 | Do not try to dynamically allocate condition code registers, only | |
25051 | use @code{icc0} and @code{fcc0}. | |
25052 | ||
d77de738 | 25053 | @opindex mdword |
ddf6fe37 | 25054 | @item -mdword |
d77de738 ML |
25055 | |
25056 | Change ABI to use double word insns. | |
25057 | ||
d77de738 ML |
25058 | @opindex mno-dword |
25059 | @opindex mdword | |
ddf6fe37 | 25060 | @item -mno-dword |
d77de738 ML |
25061 | |
25062 | Do not use double word instructions. | |
25063 | ||
d77de738 | 25064 | @opindex mdouble |
ddf6fe37 | 25065 | @item -mdouble |
d77de738 ML |
25066 | |
25067 | Use floating-point double instructions. | |
25068 | ||
d77de738 | 25069 | @opindex mno-double |
ddf6fe37 | 25070 | @item -mno-double |
d77de738 ML |
25071 | |
25072 | Do not use floating-point double instructions. | |
25073 | ||
d77de738 | 25074 | @opindex mmedia |
ddf6fe37 | 25075 | @item -mmedia |
d77de738 ML |
25076 | |
25077 | Use media instructions. | |
25078 | ||
d77de738 | 25079 | @opindex mno-media |
ddf6fe37 | 25080 | @item -mno-media |
d77de738 ML |
25081 | |
25082 | Do not use media instructions. | |
25083 | ||
d77de738 | 25084 | @opindex mmuladd |
ddf6fe37 | 25085 | @item -mmuladd |
d77de738 ML |
25086 | |
25087 | Use multiply and add/subtract instructions. | |
25088 | ||
d77de738 | 25089 | @opindex mno-muladd |
ddf6fe37 | 25090 | @item -mno-muladd |
d77de738 ML |
25091 | |
25092 | Do not use multiply and add/subtract instructions. | |
25093 | ||
d77de738 | 25094 | @opindex mfdpic |
ddf6fe37 | 25095 | @item -mfdpic |
d77de738 ML |
25096 | |
25097 | Select the FDPIC ABI, which uses function descriptors to represent | |
25098 | pointers to functions. Without any PIC/PIE-related options, it | |
25099 | implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it | |
25100 | assumes GOT entries and small data are within a 12-bit range from the | |
25101 | GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets | |
25102 | are computed with 32 bits. | |
25103 | With a @samp{bfin-elf} target, this option implies @option{-msim}. | |
25104 | ||
d77de738 | 25105 | @opindex minline-plt |
ddf6fe37 | 25106 | @item -minline-plt |
d77de738 ML |
25107 | |
25108 | Enable inlining of PLT entries in function calls to functions that are | |
25109 | not known to bind locally. It has no effect without @option{-mfdpic}. | |
25110 | It's enabled by default if optimizing for speed and compiling for | |
25111 | shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an | |
25112 | optimization option such as @option{-O3} or above is present in the | |
25113 | command line. | |
25114 | ||
d77de738 | 25115 | @opindex mTLS |
ddf6fe37 | 25116 | @item -mTLS |
d77de738 ML |
25117 | |
25118 | Assume a large TLS segment when generating thread-local code. | |
25119 | ||
d77de738 | 25120 | @opindex mtls |
ddf6fe37 | 25121 | @item -mtls |
d77de738 ML |
25122 | |
25123 | Do not assume a large TLS segment when generating thread-local code. | |
25124 | ||
d77de738 | 25125 | @opindex mgprel-ro |
ddf6fe37 | 25126 | @item -mgprel-ro |
d77de738 ML |
25127 | |
25128 | Enable the use of @code{GPREL} relocations in the FDPIC ABI for data | |
25129 | that is known to be in read-only sections. It's enabled by default, | |
25130 | except for @option{-fpic} or @option{-fpie}: even though it may help | |
25131 | make the global offset table smaller, it trades 1 instruction for 4. | |
25132 | With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4, | |
25133 | one of which may be shared by multiple symbols, and it avoids the need | |
25134 | for a GOT entry for the referenced symbol, so it's more likely to be a | |
25135 | win. If it is not, @option{-mno-gprel-ro} can be used to disable it. | |
25136 | ||
d77de738 | 25137 | @opindex multilib-library-pic |
ddf6fe37 | 25138 | @item -multilib-library-pic |
d77de738 ML |
25139 | |
25140 | Link with the (library, not FD) pic libraries. It's implied by | |
25141 | @option{-mlibrary-pic}, as well as by @option{-fPIC} and | |
25142 | @option{-fpic} without @option{-mfdpic}. You should never have to use | |
25143 | it explicitly. | |
25144 | ||
d77de738 | 25145 | @opindex mlinked-fp |
ddf6fe37 | 25146 | @item -mlinked-fp |
d77de738 ML |
25147 | |
25148 | Follow the EABI requirement of always creating a frame pointer whenever | |
25149 | a stack frame is allocated. This option is enabled by default and can | |
25150 | be disabled with @option{-mno-linked-fp}. | |
25151 | ||
d77de738 | 25152 | @opindex mlong-calls |
ddf6fe37 | 25153 | @item -mlong-calls |
d77de738 ML |
25154 | |
25155 | Use indirect addressing to call functions outside the current | |
25156 | compilation unit. This allows the functions to be placed anywhere | |
25157 | within the 32-bit address space. | |
25158 | ||
d77de738 | 25159 | @opindex malign-labels |
ddf6fe37 | 25160 | @item -malign-labels |
d77de738 ML |
25161 | |
25162 | Try to align labels to an 8-byte boundary by inserting NOPs into the | |
25163 | previous packet. This option only has an effect when VLIW packing | |
25164 | is enabled. It doesn't create new packets; it merely adds NOPs to | |
25165 | existing ones. | |
25166 | ||
d77de738 | 25167 | @opindex mlibrary-pic |
ddf6fe37 | 25168 | @item -mlibrary-pic |
d77de738 ML |
25169 | |
25170 | Generate position-independent EABI code. | |
25171 | ||
d77de738 | 25172 | @opindex macc-4 |
ddf6fe37 | 25173 | @item -macc-4 |
d77de738 ML |
25174 | |
25175 | Use only the first four media accumulator registers. | |
25176 | ||
d77de738 | 25177 | @opindex macc-8 |
ddf6fe37 | 25178 | @item -macc-8 |
d77de738 ML |
25179 | |
25180 | Use all eight media accumulator registers. | |
25181 | ||
d77de738 | 25182 | @opindex mpack |
ddf6fe37 | 25183 | @item -mpack |
d77de738 ML |
25184 | |
25185 | Pack VLIW instructions. | |
25186 | ||
d77de738 | 25187 | @opindex mno-pack |
ddf6fe37 | 25188 | @item -mno-pack |
d77de738 ML |
25189 | |
25190 | Do not pack VLIW instructions. | |
25191 | ||
d77de738 | 25192 | @opindex mno-eflags |
ddf6fe37 | 25193 | @item -mno-eflags |
d77de738 ML |
25194 | |
25195 | Do not mark ABI switches in e_flags. | |
25196 | ||
d77de738 | 25197 | @opindex mcond-move |
ddf6fe37 | 25198 | @item -mcond-move |
d77de738 ML |
25199 | |
25200 | Enable the use of conditional-move instructions (default). | |
25201 | ||
25202 | This switch is mainly for debugging the compiler and will likely be removed | |
25203 | in a future version. | |
25204 | ||
d77de738 | 25205 | @opindex mno-cond-move |
ddf6fe37 | 25206 | @item -mno-cond-move |
d77de738 ML |
25207 | |
25208 | Disable the use of conditional-move instructions. | |
25209 | ||
25210 | This switch is mainly for debugging the compiler and will likely be removed | |
25211 | in a future version. | |
25212 | ||
d77de738 | 25213 | @opindex mscc |
ddf6fe37 | 25214 | @item -mscc |
d77de738 ML |
25215 | |
25216 | Enable the use of conditional set instructions (default). | |
25217 | ||
25218 | This switch is mainly for debugging the compiler and will likely be removed | |
25219 | in a future version. | |
25220 | ||
d77de738 | 25221 | @opindex mno-scc |
ddf6fe37 | 25222 | @item -mno-scc |
d77de738 ML |
25223 | |
25224 | Disable the use of conditional set instructions. | |
25225 | ||
25226 | This switch is mainly for debugging the compiler and will likely be removed | |
25227 | in a future version. | |
25228 | ||
d77de738 | 25229 | @opindex mcond-exec |
ddf6fe37 | 25230 | @item -mcond-exec |
d77de738 ML |
25231 | |
25232 | Enable the use of conditional execution (default). | |
25233 | ||
25234 | This switch is mainly for debugging the compiler and will likely be removed | |
25235 | in a future version. | |
25236 | ||
d77de738 | 25237 | @opindex mno-cond-exec |
ddf6fe37 | 25238 | @item -mno-cond-exec |
d77de738 ML |
25239 | |
25240 | Disable the use of conditional execution. | |
25241 | ||
25242 | This switch is mainly for debugging the compiler and will likely be removed | |
25243 | in a future version. | |
25244 | ||
d77de738 | 25245 | @opindex mvliw-branch |
ddf6fe37 | 25246 | @item -mvliw-branch |
d77de738 ML |
25247 | |
25248 | Run a pass to pack branches into VLIW instructions (default). | |
25249 | ||
25250 | This switch is mainly for debugging the compiler and will likely be removed | |
25251 | in a future version. | |
25252 | ||
d77de738 | 25253 | @opindex mno-vliw-branch |
ddf6fe37 | 25254 | @item -mno-vliw-branch |
d77de738 ML |
25255 | |
25256 | Do not run a pass to pack branches into VLIW instructions. | |
25257 | ||
25258 | This switch is mainly for debugging the compiler and will likely be removed | |
25259 | in a future version. | |
25260 | ||
d77de738 | 25261 | @opindex mmulti-cond-exec |
ddf6fe37 | 25262 | @item -mmulti-cond-exec |
d77de738 ML |
25263 | |
25264 | Enable optimization of @code{&&} and @code{||} in conditional execution | |
25265 | (default). | |
25266 | ||
25267 | This switch is mainly for debugging the compiler and will likely be removed | |
25268 | in a future version. | |
25269 | ||
d77de738 | 25270 | @opindex mno-multi-cond-exec |
ddf6fe37 | 25271 | @item -mno-multi-cond-exec |
d77de738 ML |
25272 | |
25273 | Disable optimization of @code{&&} and @code{||} in conditional execution. | |
25274 | ||
25275 | This switch is mainly for debugging the compiler and will likely be removed | |
25276 | in a future version. | |
25277 | ||
d77de738 | 25278 | @opindex mnested-cond-exec |
ddf6fe37 | 25279 | @item -mnested-cond-exec |
d77de738 ML |
25280 | |
25281 | Enable nested conditional execution optimizations (default). | |
25282 | ||
25283 | This switch is mainly for debugging the compiler and will likely be removed | |
25284 | in a future version. | |
25285 | ||
d77de738 | 25286 | @opindex mno-nested-cond-exec |
ddf6fe37 | 25287 | @item -mno-nested-cond-exec |
d77de738 ML |
25288 | |
25289 | Disable nested conditional execution optimizations. | |
25290 | ||
25291 | This switch is mainly for debugging the compiler and will likely be removed | |
25292 | in a future version. | |
25293 | ||
d77de738 | 25294 | @opindex moptimize-membar |
ddf6fe37 | 25295 | @item -moptimize-membar |
d77de738 ML |
25296 | |
25297 | This switch removes redundant @code{membar} instructions from the | |
25298 | compiler-generated code. It is enabled by default. | |
25299 | ||
d77de738 ML |
25300 | @opindex mno-optimize-membar |
25301 | @opindex moptimize-membar | |
ddf6fe37 | 25302 | @item -mno-optimize-membar |
d77de738 ML |
25303 | |
25304 | This switch disables the automatic removal of redundant @code{membar} | |
25305 | instructions from the generated code. | |
25306 | ||
d77de738 | 25307 | @opindex mtomcat-stats |
ddf6fe37 | 25308 | @item -mtomcat-stats |
d77de738 ML |
25309 | |
25310 | Cause gas to print out tomcat statistics. | |
25311 | ||
d77de738 | 25312 | @opindex mcpu |
ddf6fe37 | 25313 | @item -mcpu=@var{cpu} |
d77de738 ML |
25314 | |
25315 | Select the processor type for which to generate code. Possible values are | |
25316 | @samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450}, | |
25317 | @samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}. | |
25318 | ||
25319 | @end table | |
25320 | ||
25321 | @node GNU/Linux Options | |
25322 | @subsection GNU/Linux Options | |
25323 | ||
25324 | These @samp{-m} options are defined for GNU/Linux targets: | |
25325 | ||
25326 | @table @gcctabopt | |
d77de738 | 25327 | @opindex mglibc |
ddf6fe37 | 25328 | @item -mglibc |
d77de738 ML |
25329 | Use the GNU C library. This is the default except |
25330 | on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and | |
25331 | @samp{*-*-linux-*android*} targets. | |
25332 | ||
d77de738 | 25333 | @opindex muclibc |
ddf6fe37 | 25334 | @item -muclibc |
d77de738 ML |
25335 | Use uClibc C library. This is the default on |
25336 | @samp{*-*-linux-*uclibc*} targets. | |
25337 | ||
d77de738 | 25338 | @opindex mmusl |
ddf6fe37 | 25339 | @item -mmusl |
d77de738 ML |
25340 | Use the musl C library. This is the default on |
25341 | @samp{*-*-linux-*musl*} targets. | |
25342 | ||
d77de738 | 25343 | @opindex mbionic |
ddf6fe37 | 25344 | @item -mbionic |
d77de738 ML |
25345 | Use Bionic C library. This is the default on |
25346 | @samp{*-*-linux-*android*} targets. | |
25347 | ||
d77de738 | 25348 | @opindex mandroid |
ddf6fe37 | 25349 | @item -mandroid |
d77de738 ML |
25350 | Compile code compatible with Android platform. This is the default on |
25351 | @samp{*-*-linux-*android*} targets. | |
25352 | ||
25353 | When compiling, this option enables @option{-mbionic}, @option{-fPIC}, | |
25354 | @option{-fno-exceptions} and @option{-fno-rtti} by default. When linking, | |
25355 | this option makes the GCC driver pass Android-specific options to the linker. | |
25356 | Finally, this option causes the preprocessor macro @code{__ANDROID__} | |
25357 | to be defined. | |
25358 | ||
d77de738 | 25359 | @opindex tno-android-cc |
ddf6fe37 | 25360 | @item -tno-android-cc |
d77de738 ML |
25361 | Disable compilation effects of @option{-mandroid}, i.e., do not enable |
25362 | @option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and | |
25363 | @option{-fno-rtti} by default. | |
25364 | ||
d77de738 | 25365 | @opindex tno-android-ld |
ddf6fe37 | 25366 | @item -tno-android-ld |
d77de738 ML |
25367 | Disable linking effects of @option{-mandroid}, i.e., pass standard Linux |
25368 | linking options to the linker. | |
25369 | ||
25370 | @end table | |
25371 | ||
25372 | @node H8/300 Options | |
25373 | @subsection H8/300 Options | |
25374 | ||
25375 | These @samp{-m} options are defined for the H8/300 implementations: | |
25376 | ||
25377 | @table @gcctabopt | |
d77de738 | 25378 | @opindex mrelax |
ddf6fe37 | 25379 | @item -mrelax |
d77de738 ML |
25380 | Shorten some address references at link time, when possible; uses the |
25381 | linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300, | |
25382 | ld, Using ld}, for a fuller description. | |
25383 | ||
d77de738 | 25384 | @opindex mh |
ddf6fe37 | 25385 | @item -mh |
d77de738 ML |
25386 | Generate code for the H8/300H@. |
25387 | ||
d77de738 | 25388 | @opindex ms |
ddf6fe37 | 25389 | @item -ms |
d77de738 ML |
25390 | Generate code for the H8S@. |
25391 | ||
d77de738 | 25392 | @opindex mn |
ddf6fe37 | 25393 | @item -mn |
d77de738 ML |
25394 | Generate code for the H8S and H8/300H in the normal mode. This switch |
25395 | must be used either with @option{-mh} or @option{-ms}. | |
25396 | ||
d77de738 | 25397 | @opindex ms2600 |
ddf6fe37 | 25398 | @item -ms2600 |
d77de738 ML |
25399 | Generate code for the H8S/2600. This switch must be used with @option{-ms}. |
25400 | ||
d77de738 | 25401 | @opindex mexr |
ddf6fe37 | 25402 | @item -mexr |
d77de738 ML |
25403 | Extended registers are stored on stack before execution of function |
25404 | with monitor attribute. Default option is @option{-mexr}. | |
25405 | This option is valid only for H8S targets. | |
25406 | ||
d77de738 ML |
25407 | @opindex mno-exr |
25408 | @opindex mexr | |
ddf6fe37 | 25409 | @item -mno-exr |
d77de738 ML |
25410 | Extended registers are not stored on stack before execution of function |
25411 | with monitor attribute. Default option is @option{-mno-exr}. | |
25412 | This option is valid only for H8S targets. | |
25413 | ||
d77de738 | 25414 | @opindex mint32 |
ddf6fe37 | 25415 | @item -mint32 |
d77de738 ML |
25416 | Make @code{int} data 32 bits by default. |
25417 | ||
d77de738 | 25418 | @opindex malign-300 |
ddf6fe37 | 25419 | @item -malign-300 |
d77de738 ML |
25420 | On the H8/300H and H8S, use the same alignment rules as for the H8/300. |
25421 | The default for the H8/300H and H8S is to align longs and floats on | |
25422 | 4-byte boundaries. | |
25423 | @option{-malign-300} causes them to be aligned on 2-byte boundaries. | |
25424 | This option has no effect on the H8/300. | |
25425 | @end table | |
25426 | ||
25427 | @node HPPA Options | |
25428 | @subsection HPPA Options | |
25429 | @cindex HPPA Options | |
25430 | ||
25431 | These @samp{-m} options are defined for the HPPA family of computers: | |
25432 | ||
25433 | @table @gcctabopt | |
d77de738 | 25434 | @opindex march |
ddf6fe37 | 25435 | @item -march=@var{architecture-type} |
d77de738 ML |
25436 | Generate code for the specified architecture. The choices for |
25437 | @var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA | |
25438 | 1.1, and @samp{2.0} for PA 2.0 processors. Refer to | |
25439 | @file{/usr/lib/sched.models} on an HP-UX system to determine the proper | |
25440 | architecture option for your machine. Code compiled for lower numbered | |
25441 | architectures runs on higher numbered architectures, but not the | |
25442 | other way around. | |
25443 | ||
d77de738 ML |
25444 | @opindex mpa-risc-1-0 |
25445 | @opindex mpa-risc-1-1 | |
25446 | @opindex mpa-risc-2-0 | |
ddf6fe37 AA |
25447 | @item -mpa-risc-1-0 |
25448 | @itemx -mpa-risc-1-1 | |
25449 | @itemx -mpa-risc-2-0 | |
d77de738 ML |
25450 | Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively. |
25451 | ||
cf467fb9 JDA |
25452 | @opindex matomic-libcalls |
25453 | @opindex mno-atomic-libcalls | |
ddf6fe37 | 25454 | @item -matomic-libcalls |
cf467fb9 JDA |
25455 | Generate libcalls for atomic loads and stores when sync libcalls are disabled. |
25456 | This option is enabled by default. It only affects the generation of | |
25457 | atomic libcalls by the HPPA backend. | |
25458 | ||
25459 | Both the sync and @file{libatomic} libcall implementations use locking. | |
25460 | As a result, processor stores are not atomic with respect to other | |
25461 | atomic operations. Processor loads up to DImode are atomic with | |
25462 | respect to other atomic operations provided they are implemented as | |
25463 | a single access. | |
25464 | ||
25465 | The PA-RISC architecture does not support any atomic operations in | |
25466 | hardware except for the @code{ldcw} instruction. Thus, all atomic | |
25467 | support is implemented using sync and atomic libcalls. Sync libcall | |
25468 | support is in @file{libgcc.a}. Atomic libcall support is in | |
25469 | @file{libatomic}. | |
25470 | ||
25471 | This option generates @code{__atomic_exchange} calls for atomic stores. | |
25472 | It also provides special handling for atomic DImode accesses on 32-bit | |
25473 | targets. | |
25474 | ||
cf467fb9 | 25475 | @opindex mbig-switch |
ddf6fe37 | 25476 | @item -mbig-switch |
cf467fb9 JDA |
25477 | Does nothing. Preserved for backward compatibility. |
25478 | ||
d77de738 | 25479 | @opindex mcaller-copies |
ddf6fe37 | 25480 | @item -mcaller-copies |
d77de738 ML |
25481 | The caller copies function arguments passed by hidden reference. This |
25482 | option should be used with care as it is not compatible with the default | |
25483 | 32-bit runtime. However, only aggregates larger than eight bytes are | |
25484 | passed by hidden reference and the option provides better compatibility | |
25485 | with OpenMP. | |
25486 | ||
cf467fb9 | 25487 | @opindex mcoherent-ldcw |
ddf6fe37 | 25488 | @item -mcoherent-ldcw |
cf467fb9 | 25489 | Use ldcw/ldcd coherent cache-control hint. |
d77de738 | 25490 | |
d77de738 | 25491 | @opindex mdisable-fpregs |
ddf6fe37 | 25492 | @item -mdisable-fpregs |
cf467fb9 | 25493 | Disable floating-point registers. Equivalent to @code{-msoft-float}. |
d77de738 | 25494 | |
d77de738 | 25495 | @opindex mdisable-indexing |
ddf6fe37 | 25496 | @item -mdisable-indexing |
d77de738 ML |
25497 | Prevent the compiler from using indexing address modes. This avoids some |
25498 | rather obscure problems when compiling MIG generated code under MACH@. | |
25499 | ||
d77de738 | 25500 | @opindex mfast-indirect-calls |
ddf6fe37 | 25501 | @item -mfast-indirect-calls |
d77de738 ML |
25502 | Generate code that assumes calls never cross space boundaries. This |
25503 | allows GCC to emit code that performs faster indirect calls. | |
25504 | ||
25505 | This option does not work in the presence of shared libraries or nested | |
25506 | functions. | |
25507 | ||
d77de738 | 25508 | @opindex mfixed-range |
ddf6fe37 | 25509 | @item -mfixed-range=@var{register-range} |
d77de738 ML |
25510 | Generate code treating the given register range as fixed registers. |
25511 | A fixed register is one that the register allocator cannot use. This is | |
25512 | useful when compiling kernel code. A register range is specified as | |
25513 | two registers separated by a dash. Multiple register ranges can be | |
25514 | specified separated by a comma. | |
25515 | ||
d77de738 | 25516 | @opindex mgas |
ddf6fe37 | 25517 | @item -mgas |
d77de738 ML |
25518 | Enable the use of assembler directives only GAS understands. |
25519 | ||
d77de738 | 25520 | @opindex mgnu-ld |
ddf6fe37 | 25521 | @item -mgnu-ld |
d77de738 ML |
25522 | Use options specific to GNU @command{ld}. |
25523 | This passes @option{-shared} to @command{ld} when | |
25524 | building a shared library. It is the default when GCC is configured, | |
25525 | explicitly or implicitly, with the GNU linker. This option does not | |
25526 | affect which @command{ld} is called; it only changes what parameters | |
25527 | are passed to that @command{ld}. | |
25528 | The @command{ld} that is called is determined by the | |
25529 | @option{--with-ld} configure option, GCC's program search path, and | |
25530 | finally by the user's @env{PATH}. The linker used by GCC can be printed | |
25531 | using @samp{which `gcc -print-prog-name=ld`}. This option is only available | |
25532 | on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}. | |
25533 | ||
d77de738 | 25534 | @opindex mhp-ld |
ddf6fe37 | 25535 | @item -mhp-ld |
d77de738 ML |
25536 | Use options specific to HP @command{ld}. |
25537 | This passes @option{-b} to @command{ld} when building | |
25538 | a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all | |
25539 | links. It is the default when GCC is configured, explicitly or | |
25540 | implicitly, with the HP linker. This option does not affect | |
25541 | which @command{ld} is called; it only changes what parameters are passed to that | |
25542 | @command{ld}. | |
25543 | The @command{ld} that is called is determined by the @option{--with-ld} | |
25544 | configure option, GCC's program search path, and finally by the user's | |
25545 | @env{PATH}. The linker used by GCC can be printed using @samp{which | |
25546 | `gcc -print-prog-name=ld`}. This option is only available on the 64-bit | |
25547 | HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}. | |
25548 | ||
cf467fb9 | 25549 | @opindex mlinker-opt |
ddf6fe37 | 25550 | @item -mlinker-opt |
cf467fb9 JDA |
25551 | Enable the optimization pass in the HP-UX linker. Note this makes symbolic |
25552 | debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9 | |
25553 | linkers in which they give bogus error messages when linking some programs. | |
25554 | ||
d77de738 ML |
25555 | @opindex mno-long-calls |
25556 | @opindex mlong-calls | |
ddf6fe37 | 25557 | @item -mlong-calls |
d77de738 ML |
25558 | Generate code that uses long call sequences. This ensures that a call |
25559 | is always able to reach linker generated stubs. The default is to generate | |
25560 | long calls only when the distance from the call site to the beginning | |
25561 | of the function or translation unit, as the case may be, exceeds a | |
25562 | predefined limit set by the branch type being used. The limits for | |
25563 | normal calls are 7,600,000 and 240,000 bytes, respectively for the | |
25564 | PA 2.0 and PA 1.X architectures. Sibcalls are always limited at | |
25565 | 240,000 bytes. | |
25566 | ||
25567 | Distances are measured from the beginning of functions when using the | |
25568 | @option{-ffunction-sections} option, or when using the @option{-mgas} | |
25569 | and @option{-mno-portable-runtime} options together under HP-UX with | |
25570 | the SOM linker. | |
25571 | ||
25572 | It is normally not desirable to use this option as it degrades | |
25573 | performance. However, it may be useful in large applications, | |
25574 | particularly when partial linking is used to build the application. | |
25575 | ||
25576 | The types of long calls used depends on the capabilities of the | |
25577 | assembler and linker, and the type of code being generated. The | |
25578 | impact on systems that support long absolute calls, and long pic | |
25579 | symbol-difference or pc-relative calls should be relatively small. | |
25580 | However, an indirect call is used on 32-bit ELF systems in pic code | |
25581 | and it is quite long. | |
25582 | ||
cf467fb9 | 25583 | @opindex mlong-load-store |
ddf6fe37 | 25584 | @item -mlong-load-store |
cf467fb9 JDA |
25585 | Generate 3-instruction load and store sequences as sometimes required by |
25586 | the HP-UX 10 linker. This is equivalent to the @samp{+k} option to | |
25587 | the HP compilers. | |
25588 | ||
cf467fb9 | 25589 | @opindex mjump-in-delay |
ddf6fe37 | 25590 | @item -mjump-in-delay |
cf467fb9 JDA |
25591 | This option is ignored and provided for compatibility purposes only. |
25592 | ||
cf467fb9 JDA |
25593 | @opindex mno-space-regs |
25594 | @opindex mspace-regs | |
ddf6fe37 | 25595 | @item -mno-space-regs |
cf467fb9 JDA |
25596 | Generate code that assumes the target has no space registers. This allows |
25597 | GCC to generate faster indirect calls and use unscaled index address modes. | |
25598 | ||
25599 | Such code is suitable for level 0 PA systems and kernels. | |
25600 | ||
cf467fb9 | 25601 | @opindex mordered |
ddf6fe37 | 25602 | @item -mordered |
cf467fb9 JDA |
25603 | Assume memory references are ordered and barriers are not needed. |
25604 | ||
cf467fb9 | 25605 | @opindex mportable-runtime |
ddf6fe37 | 25606 | @item -mportable-runtime |
cf467fb9 JDA |
25607 | Use the portable calling conventions proposed by HP for ELF systems. |
25608 | ||
cf467fb9 | 25609 | @opindex mschedule |
ddf6fe37 | 25610 | @item -mschedule=@var{cpu-type} |
cf467fb9 JDA |
25611 | Schedule code according to the constraints for the machine type |
25612 | @var{cpu-type}. The choices for @var{cpu-type} are @samp{700} | |
25613 | @samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer | |
25614 | to @file{/usr/lib/sched.models} on an HP-UX system to determine the | |
25615 | proper scheduling option for your machine. The default scheduling is | |
25616 | @samp{8000}. | |
25617 | ||
cf467fb9 | 25618 | @opindex msio |
ddf6fe37 | 25619 | @item -msio |
cf467fb9 JDA |
25620 | Generate the predefine, @code{_SIO}, for server IO@. The default is |
25621 | @option{-mwsio}. This generates the predefines, @code{__hp9000s700}, | |
25622 | @code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These | |
25623 | options are available under HP-UX and HI-UX@. | |
25624 | ||
cf467fb9 | 25625 | @opindex msoft-float |
ddf6fe37 | 25626 | @item -msoft-float |
cf467fb9 JDA |
25627 | Generate output containing library calls for floating point. |
25628 | @strong{Warning:} the requisite libraries are not available for all HPPA | |
25629 | targets. Normally the facilities of the machine's usual C compiler are | |
25630 | used, but this cannot be done directly in cross-compilation. You must make | |
25631 | your own arrangements to provide suitable library functions for | |
25632 | cross-compilation. | |
25633 | ||
25634 | @option{-msoft-float} changes the calling convention in the output file; | |
25635 | therefore, it is only useful if you compile @emph{all} of a program with | |
25636 | this option. In particular, you need to compile @file{libgcc.a}, the | |
25637 | library that comes with GCC, with @option{-msoft-float} in order for | |
25638 | this to work. | |
25639 | ||
cf467fb9 | 25640 | @opindex msoft-mult |
ddf6fe37 | 25641 | @item -msoft-mult |
cf467fb9 JDA |
25642 | Use software integer multiplication. |
25643 | ||
25644 | This disables the use of the @code{xmpyu} instruction. | |
25645 | ||
d77de738 | 25646 | @opindex march |
ddf6fe37 | 25647 | @item -munix=@var{unix-std} |
d77de738 ML |
25648 | Generate compiler predefines and select a startfile for the specified |
25649 | UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95} | |
25650 | and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95} | |
25651 | is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX | |
25652 | 11.11 and later. The default values are @samp{93} for HP-UX 10.00, | |
25653 | @samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11 | |
25654 | and later. | |
25655 | ||
25656 | @option{-munix=93} provides the same predefines as GCC 3.3 and 3.4. | |
25657 | @option{-munix=95} provides additional predefines for @code{XOPEN_UNIX} | |
25658 | and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}. | |
25659 | @option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX}, | |
25660 | @code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and | |
25661 | @code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}. | |
25662 | ||
25663 | It is @emph{important} to note that this option changes the interfaces | |
25664 | for various library routines. It also affects the operational behavior | |
25665 | of the C library. Thus, @emph{extreme} care is needed in using this | |
25666 | option. | |
25667 | ||
25668 | Library code that is intended to operate with more than one UNIX | |
25669 | standard must test, set and restore the variable @code{__xpg4_extended_mask} | |
25670 | as appropriate. Most GNU software doesn't provide this capability. | |
25671 | ||
d77de738 | 25672 | @opindex nolibdld |
ddf6fe37 | 25673 | @item -nolibdld |
d77de738 ML |
25674 | Suppress the generation of link options to search libdld.sl when the |
25675 | @option{-static} option is specified on HP-UX 10 and later. | |
25676 | ||
d77de738 | 25677 | @opindex static |
ddf6fe37 | 25678 | @item -static |
d77de738 ML |
25679 | The HP-UX implementation of setlocale in libc has a dependency on |
25680 | libdld.sl. There isn't an archive version of libdld.sl. Thus, | |
25681 | when the @option{-static} option is specified, special link options | |
25682 | are needed to resolve this dependency. | |
25683 | ||
25684 | On HP-UX 10 and later, the GCC driver adds the necessary options to | |
25685 | link with libdld.sl when the @option{-static} option is specified. | |
25686 | This causes the resulting binary to be dynamic. On the 64-bit port, | |
25687 | the linkers generate dynamic binaries by default in any case. The | |
25688 | @option{-nolibdld} option can be used to prevent the GCC driver from | |
25689 | adding these link options. | |
25690 | ||
d77de738 | 25691 | @opindex threads |
ddf6fe37 | 25692 | @item -threads |
d77de738 ML |
25693 | Add support for multithreading with the @dfn{dce thread} library |
25694 | under HP-UX@. This option sets flags for both the preprocessor and | |
25695 | linker. | |
25696 | @end table | |
25697 | ||
25698 | @node IA-64 Options | |
25699 | @subsection IA-64 Options | |
25700 | @cindex IA-64 Options | |
25701 | ||
25702 | These are the @samp{-m} options defined for the Intel IA-64 architecture. | |
25703 | ||
25704 | @table @gcctabopt | |
d77de738 | 25705 | @opindex mbig-endian |
ddf6fe37 | 25706 | @item -mbig-endian |
d77de738 ML |
25707 | Generate code for a big-endian target. This is the default for HP-UX@. |
25708 | ||
d77de738 | 25709 | @opindex mlittle-endian |
ddf6fe37 | 25710 | @item -mlittle-endian |
d77de738 ML |
25711 | Generate code for a little-endian target. This is the default for AIX5 |
25712 | and GNU/Linux. | |
25713 | ||
d77de738 ML |
25714 | @opindex mgnu-as |
25715 | @opindex mno-gnu-as | |
ddf6fe37 AA |
25716 | @item -mgnu-as |
25717 | @itemx -mno-gnu-as | |
d77de738 ML |
25718 | Generate (or don't) code for the GNU assembler. This is the default. |
25719 | @c Also, this is the default if the configure option @option{--with-gnu-as} | |
25720 | @c is used. | |
25721 | ||
d77de738 ML |
25722 | @opindex mgnu-ld |
25723 | @opindex mno-gnu-ld | |
ddf6fe37 AA |
25724 | @item -mgnu-ld |
25725 | @itemx -mno-gnu-ld | |
d77de738 ML |
25726 | Generate (or don't) code for the GNU linker. This is the default. |
25727 | @c Also, this is the default if the configure option @option{--with-gnu-ld} | |
25728 | @c is used. | |
25729 | ||
d77de738 | 25730 | @opindex mno-pic |
ddf6fe37 | 25731 | @item -mno-pic |
d77de738 ML |
25732 | Generate code that does not use a global pointer register. The result |
25733 | is not position independent code, and violates the IA-64 ABI@. | |
25734 | ||
d77de738 ML |
25735 | @opindex mvolatile-asm-stop |
25736 | @opindex mno-volatile-asm-stop | |
ddf6fe37 AA |
25737 | @item -mvolatile-asm-stop |
25738 | @itemx -mno-volatile-asm-stop | |
d77de738 ML |
25739 | Generate (or don't) a stop bit immediately before and after volatile asm |
25740 | statements. | |
25741 | ||
d77de738 ML |
25742 | @opindex mregister-names |
25743 | @opindex mno-register-names | |
ddf6fe37 AA |
25744 | @item -mregister-names |
25745 | @itemx -mno-register-names | |
d77de738 ML |
25746 | Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for |
25747 | the stacked registers. This may make assembler output more readable. | |
25748 | ||
d77de738 ML |
25749 | @opindex mno-sdata |
25750 | @opindex msdata | |
ddf6fe37 AA |
25751 | @item -mno-sdata |
25752 | @itemx -msdata | |
d77de738 ML |
25753 | Disable (or enable) optimizations that use the small data section. This may |
25754 | be useful for working around optimizer bugs. | |
25755 | ||
d77de738 | 25756 | @opindex mconstant-gp |
ddf6fe37 | 25757 | @item -mconstant-gp |
d77de738 ML |
25758 | Generate code that uses a single constant global pointer value. This is |
25759 | useful when compiling kernel code. | |
25760 | ||
d77de738 | 25761 | @opindex mauto-pic |
ddf6fe37 | 25762 | @item -mauto-pic |
d77de738 ML |
25763 | Generate code that is self-relocatable. This implies @option{-mconstant-gp}. |
25764 | This is useful when compiling firmware code. | |
25765 | ||
d77de738 | 25766 | @opindex minline-float-divide-min-latency |
ddf6fe37 | 25767 | @item -minline-float-divide-min-latency |
d77de738 ML |
25768 | Generate code for inline divides of floating-point values |
25769 | using the minimum latency algorithm. | |
25770 | ||
d77de738 | 25771 | @opindex minline-float-divide-max-throughput |
ddf6fe37 | 25772 | @item -minline-float-divide-max-throughput |
d77de738 ML |
25773 | Generate code for inline divides of floating-point values |
25774 | using the maximum throughput algorithm. | |
25775 | ||
d77de738 | 25776 | @opindex mno-inline-float-divide |
ddf6fe37 | 25777 | @item -mno-inline-float-divide |
d77de738 ML |
25778 | Do not generate inline code for divides of floating-point values. |
25779 | ||
d77de738 | 25780 | @opindex minline-int-divide-min-latency |
ddf6fe37 | 25781 | @item -minline-int-divide-min-latency |
d77de738 ML |
25782 | Generate code for inline divides of integer values |
25783 | using the minimum latency algorithm. | |
25784 | ||
d77de738 | 25785 | @opindex minline-int-divide-max-throughput |
ddf6fe37 | 25786 | @item -minline-int-divide-max-throughput |
d77de738 ML |
25787 | Generate code for inline divides of integer values |
25788 | using the maximum throughput algorithm. | |
25789 | ||
d77de738 ML |
25790 | @opindex mno-inline-int-divide |
25791 | @opindex minline-int-divide | |
ddf6fe37 | 25792 | @item -mno-inline-int-divide |
d77de738 ML |
25793 | Do not generate inline code for divides of integer values. |
25794 | ||
d77de738 | 25795 | @opindex minline-sqrt-min-latency |
ddf6fe37 | 25796 | @item -minline-sqrt-min-latency |
d77de738 ML |
25797 | Generate code for inline square roots |
25798 | using the minimum latency algorithm. | |
25799 | ||
d77de738 | 25800 | @opindex minline-sqrt-max-throughput |
ddf6fe37 | 25801 | @item -minline-sqrt-max-throughput |
d77de738 ML |
25802 | Generate code for inline square roots |
25803 | using the maximum throughput algorithm. | |
25804 | ||
d77de738 | 25805 | @opindex mno-inline-sqrt |
ddf6fe37 | 25806 | @item -mno-inline-sqrt |
d77de738 ML |
25807 | Do not generate inline code for @code{sqrt}. |
25808 | ||
d77de738 ML |
25809 | @opindex mfused-madd |
25810 | @opindex mno-fused-madd | |
ddf6fe37 AA |
25811 | @item -mfused-madd |
25812 | @itemx -mno-fused-madd | |
d77de738 ML |
25813 | Do (don't) generate code that uses the fused multiply/add or multiply/subtract |
25814 | instructions. The default is to use these instructions. | |
25815 | ||
d77de738 ML |
25816 | @opindex mno-dwarf2-asm |
25817 | @opindex mdwarf2-asm | |
ddf6fe37 AA |
25818 | @item -mno-dwarf2-asm |
25819 | @itemx -mdwarf2-asm | |
d77de738 ML |
25820 | Don't (or do) generate assembler code for the DWARF line number debugging |
25821 | info. This may be useful when not using the GNU assembler. | |
25822 | ||
d77de738 ML |
25823 | @opindex mearly-stop-bits |
25824 | @opindex mno-early-stop-bits | |
ddf6fe37 AA |
25825 | @item -mearly-stop-bits |
25826 | @itemx -mno-early-stop-bits | |
d77de738 ML |
25827 | Allow stop bits to be placed earlier than immediately preceding the |
25828 | instruction that triggered the stop bit. This can improve instruction | |
25829 | scheduling, but does not always do so. | |
25830 | ||
d77de738 | 25831 | @opindex mfixed-range |
ddf6fe37 | 25832 | @item -mfixed-range=@var{register-range} |
d77de738 ML |
25833 | Generate code treating the given register range as fixed registers. |
25834 | A fixed register is one that the register allocator cannot use. This is | |
25835 | useful when compiling kernel code. A register range is specified as | |
25836 | two registers separated by a dash. Multiple register ranges can be | |
25837 | specified separated by a comma. | |
25838 | ||
d77de738 | 25839 | @opindex mtls-size |
ddf6fe37 | 25840 | @item -mtls-size=@var{tls-size} |
d77de738 ML |
25841 | Specify bit size of immediate TLS offsets. Valid values are 14, 22, and |
25842 | 64. | |
25843 | ||
d77de738 | 25844 | @opindex mtune |
ddf6fe37 | 25845 | @item -mtune=@var{cpu-type} |
d77de738 ML |
25846 | Tune the instruction scheduling for a particular CPU, Valid values are |
25847 | @samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2}, | |
25848 | and @samp{mckinley}. | |
25849 | ||
d77de738 ML |
25850 | @opindex milp32 |
25851 | @opindex mlp64 | |
ddf6fe37 AA |
25852 | @item -milp32 |
25853 | @itemx -mlp64 | |
d77de738 ML |
25854 | Generate code for a 32-bit or 64-bit environment. |
25855 | The 32-bit environment sets int, long and pointer to 32 bits. | |
25856 | The 64-bit environment sets int to 32 bits and long and pointer | |
25857 | to 64 bits. These are HP-UX specific flags. | |
25858 | ||
d77de738 ML |
25859 | @opindex mno-sched-br-data-spec |
25860 | @opindex msched-br-data-spec | |
ddf6fe37 AA |
25861 | @item -mno-sched-br-data-spec |
25862 | @itemx -msched-br-data-spec | |
d77de738 ML |
25863 | (Dis/En)able data speculative scheduling before reload. |
25864 | This results in generation of @code{ld.a} instructions and | |
25865 | the corresponding check instructions (@code{ld.c} / @code{chk.a}). | |
25866 | The default setting is disabled. | |
25867 | ||
d77de738 ML |
25868 | @opindex msched-ar-data-spec |
25869 | @opindex mno-sched-ar-data-spec | |
ddf6fe37 AA |
25870 | @item -msched-ar-data-spec |
25871 | @itemx -mno-sched-ar-data-spec | |
d77de738 ML |
25872 | (En/Dis)able data speculative scheduling after reload. |
25873 | This results in generation of @code{ld.a} instructions and | |
25874 | the corresponding check instructions (@code{ld.c} / @code{chk.a}). | |
25875 | The default setting is enabled. | |
25876 | ||
d77de738 ML |
25877 | @opindex mno-sched-control-spec |
25878 | @opindex msched-control-spec | |
ddf6fe37 AA |
25879 | @item -mno-sched-control-spec |
25880 | @itemx -msched-control-spec | |
d77de738 ML |
25881 | (Dis/En)able control speculative scheduling. This feature is |
25882 | available only during region scheduling (i.e.@: before reload). | |
25883 | This results in generation of the @code{ld.s} instructions and | |
25884 | the corresponding check instructions @code{chk.s}. | |
25885 | The default setting is disabled. | |
25886 | ||
d77de738 ML |
25887 | @opindex msched-br-in-data-spec |
25888 | @opindex mno-sched-br-in-data-spec | |
ddf6fe37 AA |
25889 | @item -msched-br-in-data-spec |
25890 | @itemx -mno-sched-br-in-data-spec | |
d77de738 ML |
25891 | (En/Dis)able speculative scheduling of the instructions that |
25892 | are dependent on the data speculative loads before reload. | |
25893 | This is effective only with @option{-msched-br-data-spec} enabled. | |
25894 | The default setting is enabled. | |
25895 | ||
d77de738 ML |
25896 | @opindex msched-ar-in-data-spec |
25897 | @opindex mno-sched-ar-in-data-spec | |
ddf6fe37 AA |
25898 | @item -msched-ar-in-data-spec |
25899 | @itemx -mno-sched-ar-in-data-spec | |
d77de738 ML |
25900 | (En/Dis)able speculative scheduling of the instructions that |
25901 | are dependent on the data speculative loads after reload. | |
25902 | This is effective only with @option{-msched-ar-data-spec} enabled. | |
25903 | The default setting is enabled. | |
25904 | ||
d77de738 ML |
25905 | @opindex msched-in-control-spec |
25906 | @opindex mno-sched-in-control-spec | |
ddf6fe37 AA |
25907 | @item -msched-in-control-spec |
25908 | @itemx -mno-sched-in-control-spec | |
d77de738 ML |
25909 | (En/Dis)able speculative scheduling of the instructions that |
25910 | are dependent on the control speculative loads. | |
25911 | This is effective only with @option{-msched-control-spec} enabled. | |
25912 | The default setting is enabled. | |
25913 | ||
d77de738 ML |
25914 | @opindex mno-sched-prefer-non-data-spec-insns |
25915 | @opindex msched-prefer-non-data-spec-insns | |
ddf6fe37 AA |
25916 | @item -mno-sched-prefer-non-data-spec-insns |
25917 | @itemx -msched-prefer-non-data-spec-insns | |
d77de738 ML |
25918 | If enabled, data-speculative instructions are chosen for schedule |
25919 | only if there are no other choices at the moment. This makes | |
25920 | the use of the data speculation much more conservative. | |
25921 | The default setting is disabled. | |
25922 | ||
d77de738 ML |
25923 | @opindex mno-sched-prefer-non-control-spec-insns |
25924 | @opindex msched-prefer-non-control-spec-insns | |
ddf6fe37 AA |
25925 | @item -mno-sched-prefer-non-control-spec-insns |
25926 | @itemx -msched-prefer-non-control-spec-insns | |
d77de738 ML |
25927 | If enabled, control-speculative instructions are chosen for schedule |
25928 | only if there are no other choices at the moment. This makes | |
25929 | the use of the control speculation much more conservative. | |
25930 | The default setting is disabled. | |
25931 | ||
d77de738 ML |
25932 | @opindex mno-sched-count-spec-in-critical-path |
25933 | @opindex msched-count-spec-in-critical-path | |
ddf6fe37 AA |
25934 | @item -mno-sched-count-spec-in-critical-path |
25935 | @itemx -msched-count-spec-in-critical-path | |
d77de738 ML |
25936 | If enabled, speculative dependencies are considered during |
25937 | computation of the instructions priorities. This makes the use of the | |
25938 | speculation a bit more conservative. | |
25939 | The default setting is disabled. | |
25940 | ||
d77de738 | 25941 | @opindex msched-spec-ldc |
ddf6fe37 | 25942 | @item -msched-spec-ldc |
d77de738 ML |
25943 | Use a simple data speculation check. This option is on by default. |
25944 | ||
d77de738 | 25945 | @opindex msched-spec-ldc |
ddf6fe37 | 25946 | @item -msched-control-spec-ldc |
d77de738 ML |
25947 | Use a simple check for control speculation. This option is on by default. |
25948 | ||
d77de738 | 25949 | @opindex msched-stop-bits-after-every-cycle |
ddf6fe37 | 25950 | @item -msched-stop-bits-after-every-cycle |
d77de738 ML |
25951 | Place a stop bit after every cycle when scheduling. This option is on |
25952 | by default. | |
25953 | ||
d77de738 | 25954 | @opindex msched-fp-mem-deps-zero-cost |
ddf6fe37 | 25955 | @item -msched-fp-mem-deps-zero-cost |
d77de738 ML |
25956 | Assume that floating-point stores and loads are not likely to cause a conflict |
25957 | when placed into the same instruction group. This option is disabled by | |
25958 | default. | |
25959 | ||
d77de738 | 25960 | @opindex msel-sched-dont-check-control-spec |
ddf6fe37 | 25961 | @item -msel-sched-dont-check-control-spec |
d77de738 ML |
25962 | Generate checks for control speculation in selective scheduling. |
25963 | This flag is disabled by default. | |
25964 | ||
d77de738 | 25965 | @opindex msched-max-memory-insns |
ddf6fe37 | 25966 | @item -msched-max-memory-insns=@var{max-insns} |
d77de738 ML |
25967 | Limit on the number of memory insns per instruction group, giving lower |
25968 | priority to subsequent memory insns attempting to schedule in the same | |
25969 | instruction group. Frequently useful to prevent cache bank conflicts. | |
25970 | The default value is 1. | |
25971 | ||
d77de738 | 25972 | @opindex msched-max-memory-insns-hard-limit |
ddf6fe37 | 25973 | @item -msched-max-memory-insns-hard-limit |
d77de738 ML |
25974 | Makes the limit specified by @option{msched-max-memory-insns} a hard limit, |
25975 | disallowing more than that number in an instruction group. | |
25976 | Otherwise, the limit is ``soft'', meaning that non-memory operations | |
25977 | are preferred when the limit is reached, but memory operations may still | |
25978 | be scheduled. | |
25979 | ||
25980 | @end table | |
25981 | ||
25982 | @node LM32 Options | |
25983 | @subsection LM32 Options | |
25984 | @cindex LM32 options | |
25985 | ||
25986 | These @option{-m} options are defined for the LatticeMico32 architecture: | |
25987 | ||
25988 | @table @gcctabopt | |
d77de738 | 25989 | @opindex mbarrel-shift-enabled |
ddf6fe37 | 25990 | @item -mbarrel-shift-enabled |
d77de738 ML |
25991 | Enable barrel-shift instructions. |
25992 | ||
d77de738 | 25993 | @opindex mdivide-enabled |
ddf6fe37 | 25994 | @item -mdivide-enabled |
d77de738 ML |
25995 | Enable divide and modulus instructions. |
25996 | ||
d77de738 | 25997 | @opindex multiply-enabled |
ddf6fe37 | 25998 | @item -mmultiply-enabled |
d77de738 ML |
25999 | Enable multiply instructions. |
26000 | ||
d77de738 | 26001 | @opindex msign-extend-enabled |
ddf6fe37 | 26002 | @item -msign-extend-enabled |
d77de738 ML |
26003 | Enable sign extend instructions. |
26004 | ||
d77de738 | 26005 | @opindex muser-enabled |
ddf6fe37 | 26006 | @item -muser-enabled |
d77de738 ML |
26007 | Enable user-defined instructions. |
26008 | ||
26009 | @end table | |
26010 | ||
26011 | @node LoongArch Options | |
26012 | @subsection LoongArch Options | |
26013 | @cindex LoongArch Options | |
26014 | ||
26015 | These command-line options are defined for LoongArch targets: | |
26016 | ||
26017 | @table @gcctabopt | |
9c19597c | 26018 | @opindex march |
ddf6fe37 | 26019 | @item -march=@var{cpu-type} |
d77de738 ML |
26020 | Generate instructions for the machine type @var{cpu-type}. In contrast to |
26021 | @option{-mtune=@var{cpu-type}}, which merely tunes the generated code | |
26022 | for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC | |
26023 | to generate code that may not run at all on processors other than the one | |
26024 | indicated. Specifying @option{-march=@var{cpu-type}} implies | |
26025 | @option{-mtune=@var{cpu-type}}, except where noted otherwise. | |
26026 | ||
26027 | The choices for @var{cpu-type} are: | |
26028 | ||
26029 | @table @samp | |
26030 | @item native | |
26031 | This selects the CPU to generate code for at compilation time by determining | |
26032 | the processor type of the compiling machine. Using @option{-march=native} | |
26033 | enables all instruction subsets supported by the local machine (hence | |
26034 | the result might not run on different machines). Using @option{-mtune=native} | |
26035 | produces code optimized for the local machine under the constraints | |
26036 | of the selected instruction set. | |
26037 | @item loongarch64 | |
26038 | A generic CPU with 64-bit extensions. | |
26039 | @item la464 | |
26040 | LoongArch LA464 CPU with LBT, LSX, LASX, LVZ. | |
26041 | @end table | |
26042 | ||
d77de738 | 26043 | @opindex mtune |
ddf6fe37 | 26044 | @item -mtune=@var{cpu-type} |
d77de738 ML |
26045 | Optimize the output for the given processor, specified by microarchitecture |
26046 | name. | |
26047 | ||
d77de738 | 26048 | @opindex mabi |
ddf6fe37 | 26049 | @item -mabi=@var{base-abi-type} |
d77de738 ML |
26050 | Generate code for the specified calling convention. |
26051 | @var{base-abi-type} can be one of: | |
26052 | @table @samp | |
26053 | @item lp64d | |
26054 | Uses 64-bit general purpose registers and 32/64-bit floating-point | |
26055 | registers for parameter passing. Data model is LP64, where @samp{int} | |
26056 | is 32 bits, while @samp{long int} and pointers are 64 bits. | |
26057 | @item lp64f | |
26058 | Uses 64-bit general purpose registers and 32-bit floating-point | |
26059 | registers for parameter passing. Data model is LP64, where @samp{int} | |
26060 | is 32 bits, while @samp{long int} and pointers are 64 bits. | |
26061 | @item lp64s | |
26062 | Uses 64-bit general purpose registers and no floating-point | |
26063 | registers for parameter passing. Data model is LP64, where @samp{int} | |
26064 | is 32 bits, while @samp{long int} and pointers are 64 bits. | |
26065 | @end table | |
26066 | ||
d77de738 | 26067 | @opindex mfpu |
ddf6fe37 | 26068 | @item -mfpu=@var{fpu-type} |
d77de738 ML |
26069 | Generate code for the specified FPU type, which can be one of: |
26070 | @table @samp | |
26071 | @item 64 | |
26072 | Allow the use of hardware floating-point instructions for 32-bit | |
26073 | and 64-bit operations. | |
26074 | @item 32 | |
26075 | Allow the use of hardware floating-point instructions for 32-bit | |
26076 | operations. | |
26077 | @item none | |
26078 | @item 0 | |
26079 | Prevent the use of hardware floating-point instructions. | |
26080 | @end table | |
26081 | ||
bb4a8198 YY |
26082 | @opindex msimd |
26083 | @item -msimd=@var{simd-type} | |
26084 | Enable generation of LoongArch SIMD instructions for vectorization | |
26085 | and via builtin functions. The value can be one of: | |
26086 | @table @samp | |
26087 | @item lasx | |
26088 | Enable generating instructions from the 256-bit LoongArch Advanced | |
26089 | SIMD Extension (LASX) and the 128-bit LoongArch SIMD Extension (LSX). | |
26090 | @item lsx | |
26091 | Enable generating instructions from the 128-bit LoongArch SIMD | |
26092 | Extension (LSX). | |
26093 | @item none | |
26094 | No LoongArch SIMD instruction may be generated. | |
26095 | @end table | |
26096 | ||
d77de738 | 26097 | @opindex msoft-float |
ddf6fe37 | 26098 | @item -msoft-float |
d77de738 ML |
26099 | Force @option{-mfpu=none} and prevents the use of floating-point |
26100 | registers for parameter passing. This option may change the target | |
26101 | ABI. | |
26102 | ||
9c19597c | 26103 | @opindex msingle-float |
ddf6fe37 | 26104 | @item -msingle-float |
d77de738 ML |
26105 | Force @option{-mfpu=32} and allow the use of 32-bit floating-point |
26106 | registers for parameter passing. This option may change the target | |
26107 | ABI. | |
26108 | ||
9c19597c | 26109 | @opindex mdouble-float |
ddf6fe37 | 26110 | @item -mdouble-float |
d77de738 ML |
26111 | Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point |
26112 | registers for parameter passing. This option may change the target | |
26113 | ABI. | |
26114 | ||
bb4a8198 YY |
26115 | @opindex ml[a]sx |
26116 | @item -mlasx | |
26117 | @itemx -mno-lasx | |
26118 | @item -mlsx | |
26119 | @itemx -mno-lsx | |
26120 | Incrementally adjust the scope of the SIMD extensions (none / LSX / LASX) | |
26121 | that can be used by the compiler for code generation. Enabling LASX with | |
26122 | @option{mlasx} automatically enables LSX, and diabling LSX with @option{mno-lsx} | |
26123 | automatically disables LASX. These driver-only options act upon the final | |
26124 | @option{msimd} configuration state and make incremental chagnes in the order | |
26125 | they appear on the GCC driver's command line, deriving the final / canonicalized | |
26126 | @option{msimd} option that is passed to the compiler proper. | |
26127 | ||
9c19597c | 26128 | @opindex mbranch-cost |
ddf6fe37 | 26129 | @item -mbranch-cost=@var{n} |
d77de738 ML |
26130 | Set the cost of branches to roughly @var{n} instructions. |
26131 | ||
ddf6fe37 | 26132 | @opindex mcheck-zero-division |
d77de738 ML |
26133 | @item -mcheck-zero-division |
26134 | @itemx -mno-check-zero-divison | |
d77de738 ML |
26135 | Trap (do not trap) on integer division by zero. The default is |
26136 | @option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and | |
26137 | @option{-mno-check-zero-division} for other optimization levels. | |
26138 | ||
ddf6fe37 | 26139 | @opindex mcond-move-int |
d77de738 ML |
26140 | @item -mcond-move-int |
26141 | @itemx -mno-cond-move-int | |
d77de738 ML |
26142 | Conditional moves for integral data in general-purpose registers |
26143 | are enabled (disabled). The default is @option{-mcond-move-int}. | |
26144 | ||
ddf6fe37 | 26145 | @opindex mcond-move-float |
d77de738 ML |
26146 | @item -mcond-move-float |
26147 | @itemx -mno-cond-move-float | |
d77de738 ML |
26148 | Conditional moves for floating-point registers are enabled (disabled). |
26149 | The default is @option{-mcond-move-float}. | |
26150 | ||
ddf6fe37 | 26151 | @opindex mmemcpy |
d77de738 ML |
26152 | @item -mmemcpy |
26153 | @itemx -mno-memcpy | |
d77de738 ML |
26154 | Force (do not force) the use of @code{memcpy} for non-trivial block moves. |
26155 | The default is @option{-mno-memcpy}, which allows GCC to inline most | |
26156 | constant-sized copies. Setting optimization level to @option{-Os} also | |
26157 | forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this | |
26158 | behavior if explicitly specified, regardless of the order these options on | |
26159 | the command line. | |
26160 | ||
ddf6fe37 | 26161 | @opindex mstrict-align |
d77de738 ML |
26162 | @item -mstrict-align |
26163 | @itemx -mno-strict-align | |
d77de738 ML |
26164 | Avoid or allow generating memory accesses that may not be aligned on a natural |
26165 | object boundary as described in the architecture specification. The default is | |
26166 | @option{-mno-strict-align}. | |
26167 | ||
9c19597c | 26168 | @opindex msmall-data-limit |
ddf6fe37 | 26169 | @item -msmall-data-limit=@var{number} |
d77de738 ML |
26170 | Put global and static data smaller than @var{number} bytes into a special |
26171 | section (on some targets). The default value is 0. | |
26172 | ||
9c19597c | 26173 | @opindex mmax-inline-memcpy-size |
ddf6fe37 | 26174 | @item -mmax-inline-memcpy-size=@var{n} |
d77de738 ML |
26175 | Inline all block moves (such as calls to @code{memcpy} or structure copies) |
26176 | less than or equal to @var{n} bytes. The default value of @var{n} is 1024. | |
26177 | ||
26178 | @item -mcmodel=@var{code-model} | |
26179 | Set the code model to one of: | |
26180 | @table @samp | |
26181 | @item tiny-static (Not implemented yet) | |
26182 | @item tiny (Not implemented yet) | |
26183 | ||
26184 | @item normal | |
26185 | The text segment must be within 128MB addressing space. The data segment must | |
26186 | be within 2GB addressing space. | |
26187 | ||
26188 | @item medium | |
26189 | The text segment and data segment must be within 2GB addressing space. | |
26190 | ||
26191 | @item large (Not implemented yet) | |
26192 | ||
26193 | @item extreme | |
26194 | This mode does not limit the size of the code segment and data segment. | |
26195 | The @option{-mcmodel=extreme} option is incompatible with @option{-fplt} and | |
26196 | @option{-mno-explicit-relocs}. | |
26197 | @end table | |
26198 | The default code model is @code{normal}. | |
26199 | ||
d77de738 ML |
26200 | @opindex mexplicit-relocs |
26201 | @opindex mno-explicit-relocs | |
ddf6fe37 AA |
26202 | @item -mexplicit-relocs |
26203 | @itemx -mno-explicit-relocs | |
d77de738 ML |
26204 | Use or do not use assembler relocation operators when dealing with symbolic |
26205 | addresses. The alternative is to use assembler macros instead, which may | |
c25d6f15 XR |
26206 | limit instruction scheduling but allow linker relaxation. The default |
26207 | value for the option is determined during GCC build-time by detecting | |
26208 | corresponding assembler support: | |
26209 | @code{-mno-explicit-relocs} if the assembler supports relaxation or it | |
26210 | does not support relocation operators at all, | |
26211 | @code{-mexplicit-relocs} otherwise. This option is mostly useful for | |
d77de738 ML |
26212 | debugging, or interoperation with assemblers different from the build-time |
26213 | one. | |
26214 | ||
ddf6fe37 | 26215 | @opindex mdirect-extern-access |
d77de738 ML |
26216 | @item -mdirect-extern-access |
26217 | @itemx -mno-direct-extern-access | |
d77de738 ML |
26218 | Do not use or use GOT to access external symbols. The default is |
26219 | @option{-mno-direct-extern-access}: GOT is used for external symbols with | |
26220 | default visibility, but not used for other external symbols. | |
26221 | ||
26222 | With @option{-mdirect-extern-access}, GOT is not used and all external | |
26223 | symbols are PC-relatively addressed. It is @strong{only} suitable for | |
26224 | environments where no dynamic link is performed, like firmwares, OS | |
26225 | kernels, executables linked with @option{-static} or @option{-static-pie}. | |
26226 | @option{-mdirect-extern-access} is not compatible with @option{-fPIC} or | |
26227 | @option{-fpic}. | |
26228 | @end table | |
26229 | ||
bb4a8198 | 26230 | |
d77de738 ML |
26231 | @node M32C Options |
26232 | @subsection M32C Options | |
26233 | @cindex M32C options | |
26234 | ||
26235 | @table @gcctabopt | |
d77de738 | 26236 | @opindex mcpu= |
ddf6fe37 | 26237 | @item -mcpu=@var{name} |
d77de738 ML |
26238 | Select the CPU for which code is generated. @var{name} may be one of |
26239 | @samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to | |
26240 | /60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for | |
26241 | the M32C/80 series. | |
26242 | ||
d77de738 | 26243 | @opindex msim |
ddf6fe37 | 26244 | @item -msim |
d77de738 ML |
26245 | Specifies that the program will be run on the simulator. This causes |
26246 | an alternate runtime library to be linked in which supports, for | |
26247 | example, file I/O@. You must not use this option when generating | |
26248 | programs that will run on real hardware; you must provide your own | |
26249 | runtime library for whatever I/O functions are needed. | |
26250 | ||
d77de738 | 26251 | @opindex memregs= |
ddf6fe37 | 26252 | @item -memregs=@var{number} |
d77de738 ML |
26253 | Specifies the number of memory-based pseudo-registers GCC uses |
26254 | during code generation. These pseudo-registers are used like real | |
26255 | registers, so there is a tradeoff between GCC's ability to fit the | |
26256 | code into available registers, and the performance penalty of using | |
26257 | memory instead of registers. Note that all modules in a program must | |
26258 | be compiled with the same value for this option. Because of that, you | |
26259 | must not use this option with GCC's default runtime libraries. | |
26260 | ||
26261 | @end table | |
26262 | ||
26263 | @node M32R/D Options | |
26264 | @subsection M32R/D Options | |
26265 | @cindex M32R/D options | |
26266 | ||
26267 | These @option{-m} options are defined for Renesas M32R/D architectures: | |
26268 | ||
26269 | @table @gcctabopt | |
d77de738 | 26270 | @opindex m32r2 |
ddf6fe37 | 26271 | @item -m32r2 |
d77de738 ML |
26272 | Generate code for the M32R/2@. |
26273 | ||
d77de738 | 26274 | @opindex m32rx |
ddf6fe37 | 26275 | @item -m32rx |
d77de738 ML |
26276 | Generate code for the M32R/X@. |
26277 | ||
d77de738 | 26278 | @opindex m32r |
ddf6fe37 | 26279 | @item -m32r |
d77de738 ML |
26280 | Generate code for the M32R@. This is the default. |
26281 | ||
d77de738 | 26282 | @opindex mmodel=small |
ddf6fe37 | 26283 | @item -mmodel=small |
d77de738 ML |
26284 | Assume all objects live in the lower 16MB of memory (so that their addresses |
26285 | can be loaded with the @code{ld24} instruction), and assume all subroutines | |
26286 | are reachable with the @code{bl} instruction. | |
26287 | This is the default. | |
26288 | ||
26289 | The addressability of a particular object can be set with the | |
26290 | @code{model} attribute. | |
26291 | ||
d77de738 | 26292 | @opindex mmodel=medium |
ddf6fe37 | 26293 | @item -mmodel=medium |
d77de738 ML |
26294 | Assume objects may be anywhere in the 32-bit address space (the compiler |
26295 | generates @code{seth/add3} instructions to load their addresses), and | |
26296 | assume all subroutines are reachable with the @code{bl} instruction. | |
26297 | ||
d77de738 | 26298 | @opindex mmodel=large |
ddf6fe37 | 26299 | @item -mmodel=large |
d77de738 ML |
26300 | Assume objects may be anywhere in the 32-bit address space (the compiler |
26301 | generates @code{seth/add3} instructions to load their addresses), and | |
26302 | assume subroutines may not be reachable with the @code{bl} instruction | |
26303 | (the compiler generates the much slower @code{seth/add3/jl} | |
26304 | instruction sequence). | |
26305 | ||
d77de738 | 26306 | @opindex msdata=none |
ddf6fe37 | 26307 | @item -msdata=none |
d77de738 ML |
26308 | Disable use of the small data area. Variables are put into |
26309 | one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the | |
26310 | @code{section} attribute has been specified). | |
26311 | This is the default. | |
26312 | ||
26313 | The small data area consists of sections @code{.sdata} and @code{.sbss}. | |
26314 | Objects may be explicitly put in the small data area with the | |
26315 | @code{section} attribute using one of these sections. | |
26316 | ||
d77de738 | 26317 | @opindex msdata=sdata |
ddf6fe37 | 26318 | @item -msdata=sdata |
d77de738 ML |
26319 | Put small global and static data in the small data area, but do not |
26320 | generate special code to reference them. | |
26321 | ||
d77de738 | 26322 | @opindex msdata=use |
ddf6fe37 | 26323 | @item -msdata=use |
d77de738 ML |
26324 | Put small global and static data in the small data area, and generate |
26325 | special instructions to reference them. | |
26326 | ||
d77de738 ML |
26327 | @opindex G |
26328 | @cindex smaller data references | |
f33d7a88 | 26329 | @item -G @var{num} |
d77de738 ML |
26330 | Put global and static objects less than or equal to @var{num} bytes |
26331 | into the small data or BSS sections instead of the normal data or BSS | |
26332 | sections. The default value of @var{num} is 8. | |
26333 | The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use} | |
26334 | for this option to have any effect. | |
26335 | ||
26336 | All modules should be compiled with the same @option{-G @var{num}} value. | |
26337 | Compiling with different values of @var{num} may or may not work; if it | |
26338 | doesn't the linker gives an error message---incorrect code is not | |
26339 | generated. | |
26340 | ||
d77de738 | 26341 | @opindex mdebug |
ddf6fe37 | 26342 | @item -mdebug |
d77de738 ML |
26343 | Makes the M32R-specific code in the compiler display some statistics |
26344 | that might help in debugging programs. | |
26345 | ||
d77de738 | 26346 | @opindex malign-loops |
ddf6fe37 | 26347 | @item -malign-loops |
d77de738 ML |
26348 | Align all loops to a 32-byte boundary. |
26349 | ||
d77de738 | 26350 | @opindex mno-align-loops |
ddf6fe37 | 26351 | @item -mno-align-loops |
d77de738 ML |
26352 | Do not enforce a 32-byte alignment for loops. This is the default. |
26353 | ||
d77de738 | 26354 | @opindex missue-rate=@var{number} |
ddf6fe37 | 26355 | @item -missue-rate=@var{number} |
d77de738 ML |
26356 | Issue @var{number} instructions per cycle. @var{number} can only be 1 |
26357 | or 2. | |
26358 | ||
d77de738 | 26359 | @opindex mbranch-cost=@var{number} |
ddf6fe37 | 26360 | @item -mbranch-cost=@var{number} |
d77de738 ML |
26361 | @var{number} can only be 1 or 2. If it is 1 then branches are |
26362 | preferred over conditional code, if it is 2, then the opposite applies. | |
26363 | ||
d77de738 | 26364 | @opindex mflush-trap=@var{number} |
ddf6fe37 | 26365 | @item -mflush-trap=@var{number} |
d77de738 ML |
26366 | Specifies the trap number to use to flush the cache. The default is |
26367 | 12. Valid numbers are between 0 and 15 inclusive. | |
26368 | ||
d77de738 | 26369 | @opindex mno-flush-trap |
ddf6fe37 | 26370 | @item -mno-flush-trap |
d77de738 ML |
26371 | Specifies that the cache cannot be flushed by using a trap. |
26372 | ||
d77de738 | 26373 | @opindex mflush-func=@var{name} |
ddf6fe37 | 26374 | @item -mflush-func=@var{name} |
d77de738 ML |
26375 | Specifies the name of the operating system function to call to flush |
26376 | the cache. The default is @samp{_flush_cache}, but a function call | |
26377 | is only used if a trap is not available. | |
26378 | ||
d77de738 | 26379 | @opindex mno-flush-func |
ddf6fe37 | 26380 | @item -mno-flush-func |
d77de738 ML |
26381 | Indicates that there is no OS function for flushing the cache. |
26382 | ||
26383 | @end table | |
26384 | ||
26385 | @node M680x0 Options | |
26386 | @subsection M680x0 Options | |
26387 | @cindex M680x0 options | |
26388 | ||
26389 | These are the @samp{-m} options defined for M680x0 and ColdFire processors. | |
26390 | The default settings depend on which architecture was selected when | |
26391 | the compiler was configured; the defaults for the most common choices | |
26392 | are given below. | |
26393 | ||
26394 | @table @gcctabopt | |
d77de738 | 26395 | @opindex march |
ddf6fe37 | 26396 | @item -march=@var{arch} |
d77de738 ML |
26397 | Generate code for a specific M680x0 or ColdFire instruction set |
26398 | architecture. Permissible values of @var{arch} for M680x0 | |
26399 | architectures are: @samp{68000}, @samp{68010}, @samp{68020}, | |
26400 | @samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire | |
26401 | architectures are selected according to Freescale's ISA classification | |
26402 | and the permissible values are: @samp{isaa}, @samp{isaaplus}, | |
26403 | @samp{isab} and @samp{isac}. | |
26404 | ||
26405 | GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating | |
26406 | code for a ColdFire target. The @var{arch} in this macro is one of the | |
26407 | @option{-march} arguments given above. | |
26408 | ||
26409 | When used together, @option{-march} and @option{-mtune} select code | |
26410 | that runs on a family of similar processors but that is optimized | |
26411 | for a particular microarchitecture. | |
26412 | ||
d77de738 | 26413 | @opindex mcpu |
ddf6fe37 | 26414 | @item -mcpu=@var{cpu} |
d77de738 ML |
26415 | Generate code for a specific M680x0 or ColdFire processor. |
26416 | The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020}, | |
26417 | @samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332} | |
26418 | and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table | |
26419 | below, which also classifies the CPUs into families: | |
26420 | ||
26421 | @multitable @columnfractions 0.20 0.80 | |
26422 | @headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments} | |
26423 | @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} | |
26424 | @item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206} | |
26425 | @item @samp{5206e} @tab @samp{5206e} | |
26426 | @item @samp{5208} @tab @samp{5207} @samp{5208} | |
26427 | @item @samp{5211a} @tab @samp{5210a} @samp{5211a} | |
26428 | @item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213} | |
26429 | @item @samp{5216} @tab @samp{5214} @samp{5216} | |
26430 | @item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235} | |
26431 | @item @samp{5225} @tab @samp{5224} @samp{5225} | |
26432 | @item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259} | |
26433 | @item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x} | |
26434 | @item @samp{5249} @tab @samp{5249} | |
26435 | @item @samp{5250} @tab @samp{5250} | |
26436 | @item @samp{5271} @tab @samp{5270} @samp{5271} | |
26437 | @item @samp{5272} @tab @samp{5272} | |
26438 | @item @samp{5275} @tab @samp{5274} @samp{5275} | |
26439 | @item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x} | |
26440 | @item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017} | |
26441 | @item @samp{5307} @tab @samp{5307} | |
26442 | @item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x} | |
26443 | @item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x} | |
26444 | @item @samp{5407} @tab @samp{5407} | |
26445 | @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} | |
26446 | @end multitable | |
26447 | ||
26448 | @option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if | |
26449 | @var{arch} is compatible with @var{cpu}. Other combinations of | |
26450 | @option{-mcpu} and @option{-march} are rejected. | |
26451 | ||
26452 | GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target | |
26453 | @var{cpu} is selected. It also defines @code{__mcf_family_@var{family}}, | |
26454 | where the value of @var{family} is given by the table above. | |
26455 | ||
d77de738 | 26456 | @opindex mtune |
ddf6fe37 | 26457 | @item -mtune=@var{tune} |
d77de738 ML |
26458 | Tune the code for a particular microarchitecture within the |
26459 | constraints set by @option{-march} and @option{-mcpu}. | |
26460 | The M680x0 microarchitectures are: @samp{68000}, @samp{68010}, | |
26461 | @samp{68020}, @samp{68030}, @samp{68040}, @samp{68060} | |
26462 | and @samp{cpu32}. The ColdFire microarchitectures | |
26463 | are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}. | |
26464 | ||
26465 | You can also use @option{-mtune=68020-40} for code that needs | |
26466 | to run relatively well on 68020, 68030 and 68040 targets. | |
26467 | @option{-mtune=68020-60} is similar but includes 68060 targets | |
26468 | as well. These two options select the same tuning decisions as | |
26469 | @option{-m68020-40} and @option{-m68020-60} respectively. | |
26470 | ||
26471 | GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__} | |
26472 | when tuning for 680x0 architecture @var{arch}. It also defines | |
26473 | @code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std} | |
26474 | option is used. If GCC is tuning for a range of architectures, | |
26475 | as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60}, | |
26476 | it defines the macros for every architecture in the range. | |
26477 | ||
26478 | GCC also defines the macro @code{__m@var{uarch}__} when tuning for | |
26479 | ColdFire microarchitecture @var{uarch}, where @var{uarch} is one | |
26480 | of the arguments given above. | |
26481 | ||
d77de738 ML |
26482 | @opindex m68000 |
26483 | @opindex mc68000 | |
ddf6fe37 AA |
26484 | @item -m68000 |
26485 | @itemx -mc68000 | |
d77de738 ML |
26486 | Generate output for a 68000. This is the default |
26487 | when the compiler is configured for 68000-based systems. | |
26488 | It is equivalent to @option{-march=68000}. | |
26489 | ||
26490 | Use this option for microcontrollers with a 68000 or EC000 core, | |
26491 | including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356. | |
26492 | ||
d77de738 | 26493 | @opindex m68010 |
ddf6fe37 | 26494 | @item -m68010 |
d77de738 ML |
26495 | Generate output for a 68010. This is the default |
26496 | when the compiler is configured for 68010-based systems. | |
26497 | It is equivalent to @option{-march=68010}. | |
26498 | ||
d77de738 ML |
26499 | @opindex m68020 |
26500 | @opindex mc68020 | |
ddf6fe37 AA |
26501 | @item -m68020 |
26502 | @itemx -mc68020 | |
d77de738 ML |
26503 | Generate output for a 68020. This is the default |
26504 | when the compiler is configured for 68020-based systems. | |
26505 | It is equivalent to @option{-march=68020}. | |
26506 | ||
d77de738 | 26507 | @opindex m68030 |
ddf6fe37 | 26508 | @item -m68030 |
d77de738 ML |
26509 | Generate output for a 68030. This is the default when the compiler is |
26510 | configured for 68030-based systems. It is equivalent to | |
26511 | @option{-march=68030}. | |
26512 | ||
d77de738 | 26513 | @opindex m68040 |
ddf6fe37 | 26514 | @item -m68040 |
d77de738 ML |
26515 | Generate output for a 68040. This is the default when the compiler is |
26516 | configured for 68040-based systems. It is equivalent to | |
26517 | @option{-march=68040}. | |
26518 | ||
26519 | This option inhibits the use of 68881/68882 instructions that have to be | |
26520 | emulated by software on the 68040. Use this option if your 68040 does not | |
26521 | have code to emulate those instructions. | |
26522 | ||
d77de738 | 26523 | @opindex m68060 |
ddf6fe37 | 26524 | @item -m68060 |
d77de738 ML |
26525 | Generate output for a 68060. This is the default when the compiler is |
26526 | configured for 68060-based systems. It is equivalent to | |
26527 | @option{-march=68060}. | |
26528 | ||
26529 | This option inhibits the use of 68020 and 68881/68882 instructions that | |
26530 | have to be emulated by software on the 68060. Use this option if your 68060 | |
26531 | does not have code to emulate those instructions. | |
26532 | ||
d77de738 | 26533 | @opindex mcpu32 |
ddf6fe37 | 26534 | @item -mcpu32 |
d77de738 ML |
26535 | Generate output for a CPU32. This is the default |
26536 | when the compiler is configured for CPU32-based systems. | |
26537 | It is equivalent to @option{-march=cpu32}. | |
26538 | ||
26539 | Use this option for microcontrollers with a | |
26540 | CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334, | |
26541 | 68336, 68340, 68341, 68349 and 68360. | |
26542 | ||
d77de738 | 26543 | @opindex m5200 |
ddf6fe37 | 26544 | @item -m5200 |
d77de738 ML |
26545 | Generate output for a 520X ColdFire CPU@. This is the default |
26546 | when the compiler is configured for 520X-based systems. | |
26547 | It is equivalent to @option{-mcpu=5206}, and is now deprecated | |
26548 | in favor of that option. | |
26549 | ||
26550 | Use this option for microcontroller with a 5200 core, including | |
26551 | the MCF5202, MCF5203, MCF5204 and MCF5206. | |
26552 | ||
d77de738 | 26553 | @opindex m5206e |
ddf6fe37 | 26554 | @item -m5206e |
d77de738 ML |
26555 | Generate output for a 5206e ColdFire CPU@. The option is now |
26556 | deprecated in favor of the equivalent @option{-mcpu=5206e}. | |
26557 | ||
d77de738 | 26558 | @opindex m528x |
ddf6fe37 | 26559 | @item -m528x |
d77de738 ML |
26560 | Generate output for a member of the ColdFire 528X family. |
26561 | The option is now deprecated in favor of the equivalent | |
26562 | @option{-mcpu=528x}. | |
26563 | ||
d77de738 | 26564 | @opindex m5307 |
ddf6fe37 | 26565 | @item -m5307 |
d77de738 ML |
26566 | Generate output for a ColdFire 5307 CPU@. The option is now deprecated |
26567 | in favor of the equivalent @option{-mcpu=5307}. | |
26568 | ||
d77de738 | 26569 | @opindex m5407 |
ddf6fe37 | 26570 | @item -m5407 |
d77de738 ML |
26571 | Generate output for a ColdFire 5407 CPU@. The option is now deprecated |
26572 | in favor of the equivalent @option{-mcpu=5407}. | |
26573 | ||
d77de738 | 26574 | @opindex mcfv4e |
ddf6fe37 | 26575 | @item -mcfv4e |
d77de738 ML |
26576 | Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x). |
26577 | This includes use of hardware floating-point instructions. | |
26578 | The option is equivalent to @option{-mcpu=547x}, and is now | |
26579 | deprecated in favor of that option. | |
26580 | ||
d77de738 | 26581 | @opindex m68020-40 |
ddf6fe37 | 26582 | @item -m68020-40 |
d77de738 ML |
26583 | Generate output for a 68040, without using any of the new instructions. |
26584 | This results in code that can run relatively efficiently on either a | |
26585 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
26586 | 68881 instructions that are emulated on the 68040. | |
26587 | ||
26588 | The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}. | |
26589 | ||
d77de738 | 26590 | @opindex m68020-60 |
ddf6fe37 | 26591 | @item -m68020-60 |
d77de738 ML |
26592 | Generate output for a 68060, without using any of the new instructions. |
26593 | This results in code that can run relatively efficiently on either a | |
26594 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
26595 | 68881 instructions that are emulated on the 68060. | |
26596 | ||
26597 | The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}. | |
26598 | ||
d77de738 ML |
26599 | @opindex mhard-float |
26600 | @opindex m68881 | |
ddf6fe37 AA |
26601 | @item -mhard-float |
26602 | @itemx -m68881 | |
d77de738 ML |
26603 | Generate floating-point instructions. This is the default for 68020 |
26604 | and above, and for ColdFire devices that have an FPU@. It defines the | |
26605 | macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__} | |
26606 | on ColdFire targets. | |
26607 | ||
d77de738 | 26608 | @opindex msoft-float |
ddf6fe37 | 26609 | @item -msoft-float |
d77de738 ML |
26610 | Do not generate floating-point instructions; use library calls instead. |
26611 | This is the default for 68000, 68010, and 68832 targets. It is also | |
26612 | the default for ColdFire devices that have no FPU. | |
26613 | ||
d77de738 ML |
26614 | @opindex mdiv |
26615 | @opindex mno-div | |
ddf6fe37 AA |
26616 | @item -mdiv |
26617 | @itemx -mno-div | |
d77de738 ML |
26618 | Generate (do not generate) ColdFire hardware divide and remainder |
26619 | instructions. If @option{-march} is used without @option{-mcpu}, | |
26620 | the default is ``on'' for ColdFire architectures and ``off'' for M680x0 | |
26621 | architectures. Otherwise, the default is taken from the target CPU | |
26622 | (either the default CPU, or the one specified by @option{-mcpu}). For | |
26623 | example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for | |
26624 | @option{-mcpu=5206e}. | |
26625 | ||
26626 | GCC defines the macro @code{__mcfhwdiv__} when this option is enabled. | |
26627 | ||
d77de738 | 26628 | @opindex mshort |
ddf6fe37 | 26629 | @item -mshort |
d77de738 ML |
26630 | Consider type @code{int} to be 16 bits wide, like @code{short int}. |
26631 | Additionally, parameters passed on the stack are also aligned to a | |
26632 | 16-bit boundary even on targets whose API mandates promotion to 32-bit. | |
26633 | ||
d77de738 | 26634 | @opindex mno-short |
ddf6fe37 | 26635 | @item -mno-short |
d77de738 ML |
26636 | Do not consider type @code{int} to be 16 bits wide. This is the default. |
26637 | ||
d77de738 ML |
26638 | @opindex mnobitfield |
26639 | @opindex mno-bitfield | |
ddf6fe37 AA |
26640 | @item -mnobitfield |
26641 | @itemx -mno-bitfield | |
d77de738 ML |
26642 | Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32} |
26643 | and @option{-m5200} options imply @w{@option{-mnobitfield}}. | |
26644 | ||
d77de738 | 26645 | @opindex mbitfield |
ddf6fe37 | 26646 | @item -mbitfield |
d77de738 ML |
26647 | Do use the bit-field instructions. The @option{-m68020} option implies |
26648 | @option{-mbitfield}. This is the default if you use a configuration | |
26649 | designed for a 68020. | |
26650 | ||
d77de738 | 26651 | @opindex mrtd |
ddf6fe37 | 26652 | @item -mrtd |
d77de738 ML |
26653 | Use a different function-calling convention, in which functions |
26654 | that take a fixed number of arguments return with the @code{rtd} | |
26655 | instruction, which pops their arguments while returning. This | |
26656 | saves one instruction in the caller since there is no need to pop | |
26657 | the arguments there. | |
26658 | ||
26659 | This calling convention is incompatible with the one normally | |
26660 | used on Unix, so you cannot use it if you need to call libraries | |
26661 | compiled with the Unix compiler. | |
26662 | ||
26663 | Also, you must provide function prototypes for all functions that | |
26664 | take variable numbers of arguments (including @code{printf}); | |
26665 | otherwise incorrect code is generated for calls to those | |
26666 | functions. | |
26667 | ||
26668 | In addition, seriously incorrect code results if you call a | |
26669 | function with too many arguments. (Normally, extra arguments are | |
26670 | harmlessly ignored.) | |
26671 | ||
26672 | The @code{rtd} instruction is supported by the 68010, 68020, 68030, | |
26673 | 68040, 68060 and CPU32 processors, but not by the 68000 or 5200. | |
26674 | ||
26675 | The default is @option{-mno-rtd}. | |
26676 | ||
d77de738 ML |
26677 | @opindex malign-int |
26678 | @opindex mno-align-int | |
ddf6fe37 AA |
26679 | @item -malign-int |
26680 | @itemx -mno-align-int | |
d77de738 ML |
26681 | Control whether GCC aligns @code{int}, @code{long}, @code{long long}, |
26682 | @code{float}, @code{double}, and @code{long double} variables on a 32-bit | |
26683 | boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}). | |
26684 | Aligning variables on 32-bit boundaries produces code that runs somewhat | |
26685 | faster on processors with 32-bit busses at the expense of more memory. | |
26686 | ||
26687 | @strong{Warning:} if you use the @option{-malign-int} switch, GCC | |
26688 | aligns structures containing the above types differently than | |
26689 | most published application binary interface specifications for the m68k. | |
26690 | ||
26691 | @opindex mpcrel | |
26692 | Use the pc-relative addressing mode of the 68000 directly, instead of | |
26693 | using a global offset table. At present, this option implies @option{-fpic}, | |
26694 | allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is | |
26695 | not presently supported with @option{-mpcrel}, though this could be supported for | |
26696 | 68020 and higher processors. | |
26697 | ||
d77de738 ML |
26698 | @opindex mno-strict-align |
26699 | @opindex mstrict-align | |
ddf6fe37 AA |
26700 | @item -mno-strict-align |
26701 | @itemx -mstrict-align | |
d77de738 ML |
26702 | Do not (do) assume that unaligned memory references are handled by |
26703 | the system. | |
26704 | ||
26705 | @item -msep-data | |
26706 | Generate code that allows the data segment to be located in a different | |
26707 | area of memory from the text segment. This allows for execute-in-place in | |
26708 | an environment without virtual memory management. This option implies | |
26709 | @option{-fPIC}. | |
26710 | ||
26711 | @item -mno-sep-data | |
26712 | Generate code that assumes that the data segment follows the text segment. | |
26713 | This is the default. | |
26714 | ||
26715 | @item -mid-shared-library | |
26716 | Generate code that supports shared libraries via the library ID method. | |
26717 | This allows for execute-in-place and shared libraries in an environment | |
26718 | without virtual memory management. This option implies @option{-fPIC}. | |
26719 | ||
26720 | @item -mno-id-shared-library | |
26721 | Generate code that doesn't assume ID-based shared libraries are being used. | |
26722 | This is the default. | |
26723 | ||
26724 | @item -mshared-library-id=n | |
26725 | Specifies the identification number of the ID-based shared library being | |
26726 | compiled. Specifying a value of 0 generates more compact code; specifying | |
26727 | other values forces the allocation of that number to the current | |
26728 | library, but is no more space- or time-efficient than omitting this option. | |
26729 | ||
d77de738 ML |
26730 | @opindex mxgot |
26731 | @opindex mno-xgot | |
ddf6fe37 AA |
26732 | @item -mxgot |
26733 | @itemx -mno-xgot | |
d77de738 ML |
26734 | When generating position-independent code for ColdFire, generate code |
26735 | that works if the GOT has more than 8192 entries. This code is | |
26736 | larger and slower than code generated without this option. On M680x0 | |
26737 | processors, this option is not needed; @option{-fPIC} suffices. | |
26738 | ||
26739 | GCC normally uses a single instruction to load values from the GOT@. | |
26740 | While this is relatively efficient, it only works if the GOT | |
26741 | is smaller than about 64k. Anything larger causes the linker | |
26742 | to report an error such as: | |
26743 | ||
26744 | @cindex relocation truncated to fit (ColdFire) | |
26745 | @smallexample | |
26746 | relocation truncated to fit: R_68K_GOT16O foobar | |
26747 | @end smallexample | |
26748 | ||
26749 | If this happens, you should recompile your code with @option{-mxgot}. | |
26750 | It should then work with very large GOTs. However, code generated with | |
26751 | @option{-mxgot} is less efficient, since it takes 4 instructions to fetch | |
26752 | the value of a global symbol. | |
26753 | ||
26754 | Note that some linkers, including newer versions of the GNU linker, | |
26755 | can create multiple GOTs and sort GOT entries. If you have such a linker, | |
26756 | you should only need to use @option{-mxgot} when compiling a single | |
26757 | object file that accesses more than 8192 GOT entries. Very few do. | |
26758 | ||
26759 | These options have no effect unless GCC is generating | |
26760 | position-independent code. | |
26761 | ||
d77de738 | 26762 | @opindex mlong-jump-table-offsets |
ddf6fe37 | 26763 | @item -mlong-jump-table-offsets |
d77de738 ML |
26764 | Use 32-bit offsets in @code{switch} tables. The default is to use |
26765 | 16-bit offsets. | |
26766 | ||
26767 | @end table | |
26768 | ||
26769 | @node MCore Options | |
26770 | @subsection MCore Options | |
26771 | @cindex MCore options | |
26772 | ||
26773 | These are the @samp{-m} options defined for the Motorola M*Core | |
26774 | processors. | |
26775 | ||
26776 | @table @gcctabopt | |
26777 | ||
d77de738 ML |
26778 | @opindex mhardlit |
26779 | @opindex mno-hardlit | |
ddf6fe37 AA |
26780 | @item -mhardlit |
26781 | @itemx -mno-hardlit | |
d77de738 ML |
26782 | Inline constants into the code stream if it can be done in two |
26783 | instructions or less. | |
26784 | ||
d77de738 ML |
26785 | @opindex mdiv |
26786 | @opindex mno-div | |
ddf6fe37 AA |
26787 | @item -mdiv |
26788 | @itemx -mno-div | |
d77de738 ML |
26789 | Use the divide instruction. (Enabled by default). |
26790 | ||
d77de738 ML |
26791 | @opindex mrelax-immediate |
26792 | @opindex mno-relax-immediate | |
ddf6fe37 AA |
26793 | @item -mrelax-immediate |
26794 | @itemx -mno-relax-immediate | |
d77de738 ML |
26795 | Allow arbitrary-sized immediates in bit operations. |
26796 | ||
d77de738 ML |
26797 | @opindex mwide-bitfields |
26798 | @opindex mno-wide-bitfields | |
ddf6fe37 AA |
26799 | @item -mwide-bitfields |
26800 | @itemx -mno-wide-bitfields | |
d77de738 ML |
26801 | Always treat bit-fields as @code{int}-sized. |
26802 | ||
d77de738 ML |
26803 | @opindex m4byte-functions |
26804 | @opindex mno-4byte-functions | |
ddf6fe37 AA |
26805 | @item -m4byte-functions |
26806 | @itemx -mno-4byte-functions | |
d77de738 ML |
26807 | Force all functions to be aligned to a 4-byte boundary. |
26808 | ||
d77de738 ML |
26809 | @opindex mcallgraph-data |
26810 | @opindex mno-callgraph-data | |
ddf6fe37 AA |
26811 | @item -mcallgraph-data |
26812 | @itemx -mno-callgraph-data | |
d77de738 ML |
26813 | Emit callgraph information. |
26814 | ||
d77de738 ML |
26815 | @opindex mslow-bytes |
26816 | @opindex mno-slow-bytes | |
ddf6fe37 AA |
26817 | @item -mslow-bytes |
26818 | @itemx -mno-slow-bytes | |
d77de738 ML |
26819 | Prefer word access when reading byte quantities. |
26820 | ||
d77de738 ML |
26821 | @opindex mlittle-endian |
26822 | @opindex mbig-endian | |
ddf6fe37 AA |
26823 | @item -mlittle-endian |
26824 | @itemx -mbig-endian | |
d77de738 ML |
26825 | Generate code for a little-endian target. |
26826 | ||
d77de738 ML |
26827 | @opindex m210 |
26828 | @opindex m340 | |
ddf6fe37 AA |
26829 | @item -m210 |
26830 | @itemx -m340 | |
d77de738 ML |
26831 | Generate code for the 210 processor. |
26832 | ||
d77de738 | 26833 | @opindex mno-lsim |
ddf6fe37 | 26834 | @item -mno-lsim |
d77de738 ML |
26835 | Assume that runtime support has been provided and so omit the |
26836 | simulator library (@file{libsim.a)} from the linker command line. | |
26837 | ||
d77de738 | 26838 | @opindex mstack-increment |
ddf6fe37 | 26839 | @item -mstack-increment=@var{size} |
d77de738 ML |
26840 | Set the maximum amount for a single stack increment operation. Large |
26841 | values can increase the speed of programs that contain functions | |
26842 | that need a large amount of stack space, but they can also trigger a | |
26843 | segmentation fault if the stack is extended too much. The default | |
26844 | value is 0x1000. | |
26845 | ||
26846 | @end table | |
26847 | ||
d77de738 ML |
26848 | @node MicroBlaze Options |
26849 | @subsection MicroBlaze Options | |
26850 | @cindex MicroBlaze Options | |
26851 | ||
26852 | @table @gcctabopt | |
26853 | ||
d77de738 | 26854 | @opindex msoft-float |
ddf6fe37 | 26855 | @item -msoft-float |
d77de738 ML |
26856 | Use software emulation for floating point (default). |
26857 | ||
d77de738 | 26858 | @opindex mhard-float |
ddf6fe37 | 26859 | @item -mhard-float |
d77de738 ML |
26860 | Use hardware floating-point instructions. |
26861 | ||
d77de738 | 26862 | @opindex mmemcpy |
ddf6fe37 | 26863 | @item -mmemcpy |
d77de738 ML |
26864 | Do not optimize block moves, use @code{memcpy}. |
26865 | ||
d77de738 | 26866 | @opindex mno-clearbss |
ddf6fe37 | 26867 | @item -mno-clearbss |
d77de738 ML |
26868 | This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead. |
26869 | ||
d77de738 | 26870 | @opindex mcpu= |
ddf6fe37 | 26871 | @item -mcpu=@var{cpu-type} |
d77de738 ML |
26872 | Use features of, and schedule code for, the given CPU. |
26873 | Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}}, | |
26874 | where @var{X} is a major version, @var{YY} is the minor version, and | |
26875 | @var{Z} is compatibility code. Example values are @samp{v3.00.a}, | |
26876 | @samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}. | |
26877 | ||
d77de738 | 26878 | @opindex mxl-soft-mul |
ddf6fe37 | 26879 | @item -mxl-soft-mul |
d77de738 ML |
26880 | Use software multiply emulation (default). |
26881 | ||
d77de738 | 26882 | @opindex mxl-soft-div |
ddf6fe37 | 26883 | @item -mxl-soft-div |
d77de738 ML |
26884 | Use software emulation for divides (default). |
26885 | ||
d77de738 | 26886 | @opindex mxl-barrel-shift |
ddf6fe37 | 26887 | @item -mxl-barrel-shift |
d77de738 ML |
26888 | Use the hardware barrel shifter. |
26889 | ||
d77de738 | 26890 | @opindex mxl-pattern-compare |
ddf6fe37 | 26891 | @item -mxl-pattern-compare |
d77de738 ML |
26892 | Use pattern compare instructions. |
26893 | ||
d77de738 | 26894 | @opindex msmall-divides |
ddf6fe37 | 26895 | @item -msmall-divides |
d77de738 ML |
26896 | Use table lookup optimization for small signed integer divisions. |
26897 | ||
d77de738 | 26898 | @opindex mxl-stack-check |
ddf6fe37 | 26899 | @item -mxl-stack-check |
d77de738 ML |
26900 | This option is deprecated. Use @option{-fstack-check} instead. |
26901 | ||
d77de738 | 26902 | @opindex mxl-gp-opt |
ddf6fe37 | 26903 | @item -mxl-gp-opt |
d77de738 ML |
26904 | Use GP-relative @code{.sdata}/@code{.sbss} sections. |
26905 | ||
d77de738 | 26906 | @opindex mxl-multiply-high |
ddf6fe37 | 26907 | @item -mxl-multiply-high |
d77de738 ML |
26908 | Use multiply high instructions for high part of 32x32 multiply. |
26909 | ||
d77de738 | 26910 | @opindex mxl-float-convert |
ddf6fe37 | 26911 | @item -mxl-float-convert |
d77de738 ML |
26912 | Use hardware floating-point conversion instructions. |
26913 | ||
d77de738 | 26914 | @opindex mxl-float-sqrt |
ddf6fe37 | 26915 | @item -mxl-float-sqrt |
d77de738 ML |
26916 | Use hardware floating-point square root instruction. |
26917 | ||
d77de738 | 26918 | @opindex mbig-endian |
ddf6fe37 | 26919 | @item -mbig-endian |
d77de738 ML |
26920 | Generate code for a big-endian target. |
26921 | ||
d77de738 | 26922 | @opindex mlittle-endian |
ddf6fe37 | 26923 | @item -mlittle-endian |
d77de738 ML |
26924 | Generate code for a little-endian target. |
26925 | ||
d77de738 | 26926 | @opindex mxl-reorder |
ddf6fe37 | 26927 | @item -mxl-reorder |
d77de738 ML |
26928 | Use reorder instructions (swap and byte reversed load/store). |
26929 | ||
26930 | @item -mxl-mode-@var{app-model} | |
26931 | Select application model @var{app-model}. Valid models are | |
26932 | @table @samp | |
26933 | @item executable | |
26934 | normal executable (default), uses startup code @file{crt0.o}. | |
26935 | ||
26936 | @item xmdstub | |
26937 | for use with Xilinx Microprocessor Debugger (XMD) based | |
26938 | software intrusive debug agent called xmdstub. This uses startup file | |
26939 | @file{crt1.o} and sets the start address of the program to 0x800. | |
26940 | ||
26941 | @item bootstrap | |
26942 | for applications that are loaded using a bootloader. | |
26943 | This model uses startup file @file{crt2.o} which does not contain a processor | |
26944 | reset vector handler. This is suitable for transferring control on a | |
26945 | processor reset to the bootloader rather than the application. | |
26946 | ||
26947 | @item novectors | |
26948 | for applications that do not require any of the | |
26949 | MicroBlaze vectors. This option may be useful for applications running | |
26950 | within a monitoring application. This model uses @file{crt3.o} as a startup file. | |
26951 | @end table | |
26952 | ||
26953 | Option @option{-xl-mode-@var{app-model}} is a deprecated alias for | |
26954 | @option{-mxl-mode-@var{app-model}}. | |
26955 | ||
d77de738 | 26956 | @opindex mpic-data-is-text-relative |
ddf6fe37 | 26957 | @item -mpic-data-is-text-relative |
d77de738 ML |
26958 | Assume that the displacement between the text and data segments is fixed |
26959 | at static link time. This allows data to be referenced by offset from start of | |
26960 | text address instead of GOT since PC-relative addressing is not supported. | |
26961 | ||
26962 | @end table | |
26963 | ||
26964 | @node MIPS Options | |
26965 | @subsection MIPS Options | |
26966 | @cindex MIPS options | |
26967 | ||
26968 | @table @gcctabopt | |
26969 | ||
d77de738 | 26970 | @opindex EB |
ddf6fe37 | 26971 | @item -EB |
d77de738 ML |
26972 | Generate big-endian code. |
26973 | ||
d77de738 | 26974 | @opindex EL |
ddf6fe37 | 26975 | @item -EL |
d77de738 ML |
26976 | Generate little-endian code. This is the default for @samp{mips*el-*-*} |
26977 | configurations. | |
26978 | ||
d77de738 | 26979 | @opindex march |
ddf6fe37 | 26980 | @item -march=@var{arch} |
d77de738 ML |
26981 | Generate code that runs on @var{arch}, which can be the name of a |
26982 | generic MIPS ISA, or the name of a particular processor. | |
26983 | The ISA names are: | |
26984 | @samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4}, | |
26985 | @samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5}, | |
26986 | @samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3}, | |
26987 | @samp{mips64r5} and @samp{mips64r6}. | |
26988 | The processor names are: | |
26989 | @samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc}, | |
26990 | @samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd}, | |
26991 | @samp{5kc}, @samp{5kf}, | |
26992 | @samp{20kc}, | |
26993 | @samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1}, | |
26994 | @samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1}, | |
26995 | @samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn}, | |
26996 | @samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2}, | |
26997 | @samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1}, | |
26998 | @samp{i6400}, @samp{i6500}, | |
26999 | @samp{interaptiv}, | |
27000 | @samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464}, | |
27001 | @samp{gs464e}, @samp{gs264e}, | |
27002 | @samp{m4k}, | |
27003 | @samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec}, | |
27004 | @samp{m5100}, @samp{m5101}, | |
27005 | @samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3}, | |
27006 | @samp{orion}, | |
27007 | @samp{p5600}, @samp{p6600}, | |
27008 | @samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400}, | |
27009 | @samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900}, | |
27010 | @samp{r6000}, @samp{r8000}, | |
27011 | @samp{rm7000}, @samp{rm9000}, | |
27012 | @samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000}, | |
27013 | @samp{sb1}, | |
27014 | @samp{sr71000}, | |
27015 | @samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300}, | |
27016 | @samp{vr5000}, @samp{vr5400}, @samp{vr5500}, | |
27017 | @samp{xlr} and @samp{xlp}. | |
27018 | The special value @samp{from-abi} selects the | |
27019 | most compatible architecture for the selected ABI (that is, | |
27020 | @samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@. | |
27021 | ||
27022 | The native Linux/GNU toolchain also supports the value @samp{native}, | |
27023 | which selects the best architecture option for the host processor. | |
27024 | @option{-march=native} has no effect if GCC does not recognize | |
27025 | the processor. | |
27026 | ||
27027 | In processor names, a final @samp{000} can be abbreviated as @samp{k} | |
27028 | (for example, @option{-march=r2k}). Prefixes are optional, and | |
27029 | @samp{vr} may be written @samp{r}. | |
27030 | ||
27031 | Names of the form @samp{@var{n}f2_1} refer to processors with | |
27032 | FPUs clocked at half the rate of the core, names of the form | |
27033 | @samp{@var{n}f1_1} refer to processors with FPUs clocked at the same | |
27034 | rate as the core, and names of the form @samp{@var{n}f3_2} refer to | |
27035 | processors with FPUs clocked a ratio of 3:2 with respect to the core. | |
27036 | For compatibility reasons, @samp{@var{n}f} is accepted as a synonym | |
27037 | for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are | |
27038 | accepted as synonyms for @samp{@var{n}f1_1}. | |
27039 | ||
27040 | GCC defines two macros based on the value of this option. The first | |
27041 | is @code{_MIPS_ARCH}, which gives the name of target architecture, as | |
27042 | a string. The second has the form @code{_MIPS_ARCH_@var{foo}}, | |
27043 | where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@. | |
27044 | For example, @option{-march=r2000} sets @code{_MIPS_ARCH} | |
27045 | to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}. | |
27046 | ||
27047 | Note that the @code{_MIPS_ARCH} macro uses the processor names given | |
27048 | above. In other words, it has the full prefix and does not | |
27049 | abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi}, | |
27050 | the macro names the resolved architecture (either @code{"mips1"} or | |
27051 | @code{"mips3"}). It names the default architecture when no | |
27052 | @option{-march} option is given. | |
27053 | ||
d77de738 | 27054 | @opindex mtune |
ddf6fe37 | 27055 | @item -mtune=@var{arch} |
d77de738 ML |
27056 | Optimize for @var{arch}. Among other things, this option controls |
27057 | the way instructions are scheduled, and the perceived cost of arithmetic | |
27058 | operations. The list of @var{arch} values is the same as for | |
27059 | @option{-march}. | |
27060 | ||
27061 | When this option is not used, GCC optimizes for the processor | |
27062 | specified by @option{-march}. By using @option{-march} and | |
27063 | @option{-mtune} together, it is possible to generate code that | |
27064 | runs on a family of processors, but optimize the code for one | |
27065 | particular member of that family. | |
27066 | ||
27067 | @option{-mtune} defines the macros @code{_MIPS_TUNE} and | |
27068 | @code{_MIPS_TUNE_@var{foo}}, which work in the same way as the | |
27069 | @option{-march} ones described above. | |
27070 | ||
d77de738 | 27071 | @opindex mips1 |
ddf6fe37 | 27072 | @item -mips1 |
d77de738 ML |
27073 | Equivalent to @option{-march=mips1}. |
27074 | ||
d77de738 | 27075 | @opindex mips2 |
ddf6fe37 | 27076 | @item -mips2 |
d77de738 ML |
27077 | Equivalent to @option{-march=mips2}. |
27078 | ||
d77de738 | 27079 | @opindex mips3 |
ddf6fe37 | 27080 | @item -mips3 |
d77de738 ML |
27081 | Equivalent to @option{-march=mips3}. |
27082 | ||
d77de738 | 27083 | @opindex mips4 |
ddf6fe37 | 27084 | @item -mips4 |
d77de738 ML |
27085 | Equivalent to @option{-march=mips4}. |
27086 | ||
d77de738 | 27087 | @opindex mips32 |
ddf6fe37 | 27088 | @item -mips32 |
d77de738 ML |
27089 | Equivalent to @option{-march=mips32}. |
27090 | ||
d77de738 | 27091 | @opindex mips32r3 |
ddf6fe37 | 27092 | @item -mips32r3 |
d77de738 ML |
27093 | Equivalent to @option{-march=mips32r3}. |
27094 | ||
d77de738 | 27095 | @opindex mips32r5 |
ddf6fe37 | 27096 | @item -mips32r5 |
d77de738 ML |
27097 | Equivalent to @option{-march=mips32r5}. |
27098 | ||
d77de738 | 27099 | @opindex mips32r6 |
ddf6fe37 | 27100 | @item -mips32r6 |
d77de738 ML |
27101 | Equivalent to @option{-march=mips32r6}. |
27102 | ||
d77de738 | 27103 | @opindex mips64 |
ddf6fe37 | 27104 | @item -mips64 |
d77de738 ML |
27105 | Equivalent to @option{-march=mips64}. |
27106 | ||
d77de738 | 27107 | @opindex mips64r2 |
ddf6fe37 | 27108 | @item -mips64r2 |
d77de738 ML |
27109 | Equivalent to @option{-march=mips64r2}. |
27110 | ||
d77de738 | 27111 | @opindex mips64r3 |
ddf6fe37 | 27112 | @item -mips64r3 |
d77de738 ML |
27113 | Equivalent to @option{-march=mips64r3}. |
27114 | ||
d77de738 | 27115 | @opindex mips64r5 |
ddf6fe37 | 27116 | @item -mips64r5 |
d77de738 ML |
27117 | Equivalent to @option{-march=mips64r5}. |
27118 | ||
d77de738 | 27119 | @opindex mips64r6 |
ddf6fe37 | 27120 | @item -mips64r6 |
d77de738 ML |
27121 | Equivalent to @option{-march=mips64r6}. |
27122 | ||
d77de738 ML |
27123 | @opindex mips16 |
27124 | @opindex mno-mips16 | |
ddf6fe37 AA |
27125 | @item -mips16 |
27126 | @itemx -mno-mips16 | |
d77de738 ML |
27127 | Generate (do not generate) MIPS16 code. If GCC is targeting a |
27128 | MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@. | |
27129 | ||
27130 | MIPS16 code generation can also be controlled on a per-function basis | |
27131 | by means of @code{mips16} and @code{nomips16} attributes. | |
27132 | @xref{Function Attributes}, for more information. | |
27133 | ||
926f2d09 JM |
27134 | @opindex mmips16e2 |
27135 | @opindex mno-mips16e2 | |
27136 | @item -mmips16e2 | |
27137 | @itemx -mno-mips16e2 | |
27138 | Use (do not use) the MIPS16e2 ASE. This option modifies the behavior | |
27139 | of the @option{-mips16} option such that it targets the MIPS16e2 ASE@. | |
27140 | ||
d77de738 | 27141 | @opindex mflip-mips16 |
ddf6fe37 | 27142 | @item -mflip-mips16 |
d77de738 ML |
27143 | Generate MIPS16 code on alternating functions. This option is provided |
27144 | for regression testing of mixed MIPS16/non-MIPS16 code generation, and is | |
27145 | not intended for ordinary use in compiling user code. | |
27146 | ||
d77de738 ML |
27147 | @opindex minterlink-compressed |
27148 | @opindex mno-interlink-compressed | |
ddf6fe37 AA |
27149 | @item -minterlink-compressed |
27150 | @itemx -mno-interlink-compressed | |
d77de738 ML |
27151 | Require (do not require) that code using the standard (uncompressed) MIPS ISA |
27152 | be link-compatible with MIPS16 and microMIPS code, and vice versa. | |
27153 | ||
27154 | For example, code using the standard ISA encoding cannot jump directly | |
27155 | to MIPS16 or microMIPS code; it must either use a call or an indirect jump. | |
27156 | @option{-minterlink-compressed} therefore disables direct jumps unless GCC | |
27157 | knows that the target of the jump is not compressed. | |
27158 | ||
d77de738 ML |
27159 | @opindex minterlink-mips16 |
27160 | @opindex mno-interlink-mips16 | |
ddf6fe37 AA |
27161 | @item -minterlink-mips16 |
27162 | @itemx -mno-interlink-mips16 | |
d77de738 ML |
27163 | Aliases of @option{-minterlink-compressed} and |
27164 | @option{-mno-interlink-compressed}. These options predate the microMIPS ASE | |
27165 | and are retained for backwards compatibility. | |
27166 | ||
d77de738 ML |
27167 | @opindex mabi=32 |
27168 | @opindex mabi=o64 | |
27169 | @opindex mabi=n32 | |
27170 | @opindex mabi=64 | |
27171 | @opindex mabi=eabi | |
ddf6fe37 AA |
27172 | @item -mabi=32 |
27173 | @itemx -mabi=o64 | |
27174 | @itemx -mabi=n32 | |
27175 | @itemx -mabi=64 | |
27176 | @itemx -mabi=eabi | |
d77de738 ML |
27177 | Generate code for the given ABI@. |
27178 | ||
27179 | Note that the EABI has a 32-bit and a 64-bit variant. GCC normally | |
27180 | generates 64-bit code when you select a 64-bit architecture, but you | |
27181 | can use @option{-mgp32} to get 32-bit code instead. | |
27182 | ||
27183 | For information about the O64 ABI, see | |
27184 | @uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}. | |
27185 | ||
27186 | GCC supports a variant of the o32 ABI in which floating-point registers | |
27187 | are 64 rather than 32 bits wide. You can select this combination with | |
27188 | @option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1} | |
27189 | and @code{mfhc1} instructions and is therefore only supported for | |
27190 | MIPS32R2, MIPS32R3 and MIPS32R5 processors. | |
27191 | ||
27192 | The register assignments for arguments and return values remain the | |
27193 | same, but each scalar value is passed in a single 64-bit register | |
27194 | rather than a pair of 32-bit registers. For example, scalar | |
27195 | floating-point values are returned in @samp{$f0} only, not a | |
27196 | @samp{$f0}/@samp{$f1} pair. The set of call-saved registers also | |
27197 | remains the same in that the even-numbered double-precision registers | |
27198 | are saved. | |
27199 | ||
27200 | Two additional variants of the o32 ABI are supported to enable | |
27201 | a transition from 32-bit to 64-bit registers. These are FPXX | |
27202 | (@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}). | |
27203 | The FPXX extension mandates that all code must execute correctly | |
27204 | when run using 32-bit or 64-bit registers. The code can be interlinked | |
27205 | with either FP32 or FP64, but not both. | |
27206 | The FP64A extension is similar to the FP64 extension but forbids the | |
27207 | use of odd-numbered single-precision registers. This can be used | |
27208 | in conjunction with the @code{FRE} mode of FPUs in MIPS32R5 | |
27209 | processors and allows both FP32 and FP64A code to interlink and | |
27210 | run in the same process without changing FPU modes. | |
27211 | ||
d77de738 ML |
27212 | @opindex mabicalls |
27213 | @opindex mno-abicalls | |
ddf6fe37 AA |
27214 | @item -mabicalls |
27215 | @itemx -mno-abicalls | |
d77de738 ML |
27216 | Generate (do not generate) code that is suitable for SVR4-style |
27217 | dynamic objects. @option{-mabicalls} is the default for SVR4-based | |
27218 | systems. | |
27219 | ||
27220 | @item -mshared | |
27221 | @itemx -mno-shared | |
27222 | Generate (do not generate) code that is fully position-independent, | |
27223 | and that can therefore be linked into shared libraries. This option | |
27224 | only affects @option{-mabicalls}. | |
27225 | ||
27226 | All @option{-mabicalls} code has traditionally been position-independent, | |
27227 | regardless of options like @option{-fPIC} and @option{-fpic}. However, | |
27228 | as an extension, the GNU toolchain allows executables to use absolute | |
27229 | accesses for locally-binding symbols. It can also use shorter GP | |
27230 | initialization sequences and generate direct calls to locally-defined | |
27231 | functions. This mode is selected by @option{-mno-shared}. | |
27232 | ||
27233 | @option{-mno-shared} depends on binutils 2.16 or higher and generates | |
27234 | objects that can only be linked by the GNU linker. However, the option | |
27235 | does not affect the ABI of the final executable; it only affects the ABI | |
27236 | of relocatable objects. Using @option{-mno-shared} generally makes | |
27237 | executables both smaller and quicker. | |
27238 | ||
27239 | @option{-mshared} is the default. | |
27240 | ||
d77de738 ML |
27241 | @opindex mplt |
27242 | @opindex mno-plt | |
ddf6fe37 AA |
27243 | @item -mplt |
27244 | @itemx -mno-plt | |
d77de738 ML |
27245 | Assume (do not assume) that the static and dynamic linkers |
27246 | support PLTs and copy relocations. This option only affects | |
27247 | @option{-mno-shared -mabicalls}. For the n64 ABI, this option | |
27248 | has no effect without @option{-msym32}. | |
27249 | ||
27250 | You can make @option{-mplt} the default by configuring | |
27251 | GCC with @option{--with-mips-plt}. The default is | |
27252 | @option{-mno-plt} otherwise. | |
27253 | ||
d77de738 ML |
27254 | @opindex mxgot |
27255 | @opindex mno-xgot | |
ddf6fe37 AA |
27256 | @item -mxgot |
27257 | @itemx -mno-xgot | |
d77de738 ML |
27258 | Lift (do not lift) the usual restrictions on the size of the global |
27259 | offset table. | |
27260 | ||
27261 | GCC normally uses a single instruction to load values from the GOT@. | |
27262 | While this is relatively efficient, it only works if the GOT | |
27263 | is smaller than about 64k. Anything larger causes the linker | |
27264 | to report an error such as: | |
27265 | ||
27266 | @cindex relocation truncated to fit (MIPS) | |
27267 | @smallexample | |
27268 | relocation truncated to fit: R_MIPS_GOT16 foobar | |
27269 | @end smallexample | |
27270 | ||
27271 | If this happens, you should recompile your code with @option{-mxgot}. | |
27272 | This works with very large GOTs, although the code is also | |
27273 | less efficient, since it takes three instructions to fetch the | |
27274 | value of a global symbol. | |
27275 | ||
27276 | Note that some linkers can create multiple GOTs. If you have such a | |
27277 | linker, you should only need to use @option{-mxgot} when a single object | |
27278 | file accesses more than 64k's worth of GOT entries. Very few do. | |
27279 | ||
27280 | These options have no effect unless GCC is generating position | |
27281 | independent code. | |
27282 | ||
d77de738 | 27283 | @opindex mgp32 |
ddf6fe37 | 27284 | @item -mgp32 |
d77de738 ML |
27285 | Assume that general-purpose registers are 32 bits wide. |
27286 | ||
d77de738 | 27287 | @opindex mgp64 |
ddf6fe37 | 27288 | @item -mgp64 |
d77de738 ML |
27289 | Assume that general-purpose registers are 64 bits wide. |
27290 | ||
d77de738 | 27291 | @opindex mfp32 |
ddf6fe37 | 27292 | @item -mfp32 |
d77de738 ML |
27293 | Assume that floating-point registers are 32 bits wide. |
27294 | ||
d77de738 | 27295 | @opindex mfp64 |
ddf6fe37 | 27296 | @item -mfp64 |
d77de738 ML |
27297 | Assume that floating-point registers are 64 bits wide. |
27298 | ||
d77de738 | 27299 | @opindex mfpxx |
ddf6fe37 | 27300 | @item -mfpxx |
d77de738 ML |
27301 | Do not assume the width of floating-point registers. |
27302 | ||
d77de738 | 27303 | @opindex mhard-float |
ddf6fe37 | 27304 | @item -mhard-float |
d77de738 ML |
27305 | Use floating-point coprocessor instructions. |
27306 | ||
d77de738 | 27307 | @opindex msoft-float |
ddf6fe37 | 27308 | @item -msoft-float |
d77de738 ML |
27309 | Do not use floating-point coprocessor instructions. Implement |
27310 | floating-point calculations using library calls instead. | |
27311 | ||
d77de738 | 27312 | @opindex mno-float |
ddf6fe37 | 27313 | @item -mno-float |
d77de738 ML |
27314 | Equivalent to @option{-msoft-float}, but additionally asserts that the |
27315 | program being compiled does not perform any floating-point operations. | |
27316 | This option is presently supported only by some bare-metal MIPS | |
27317 | configurations, where it may select a special set of libraries | |
27318 | that lack all floating-point support (including, for example, the | |
27319 | floating-point @code{printf} formats). | |
27320 | If code compiled with @option{-mno-float} accidentally contains | |
27321 | floating-point operations, it is likely to suffer a link-time | |
27322 | or run-time failure. | |
27323 | ||
d77de738 | 27324 | @opindex msingle-float |
ddf6fe37 | 27325 | @item -msingle-float |
d77de738 ML |
27326 | Assume that the floating-point coprocessor only supports single-precision |
27327 | operations. | |
27328 | ||
d77de738 | 27329 | @opindex mdouble-float |
ddf6fe37 | 27330 | @item -mdouble-float |
d77de738 ML |
27331 | Assume that the floating-point coprocessor supports double-precision |
27332 | operations. This is the default. | |
27333 | ||
d77de738 ML |
27334 | @opindex modd-spreg |
27335 | @opindex mno-odd-spreg | |
ddf6fe37 AA |
27336 | @item -modd-spreg |
27337 | @itemx -mno-odd-spreg | |
d77de738 ML |
27338 | Enable the use of odd-numbered single-precision floating-point registers |
27339 | for the o32 ABI. This is the default for processors that are known to | |
27340 | support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg} | |
27341 | is set by default. | |
27342 | ||
d77de738 ML |
27343 | @opindex mabs=2008 |
27344 | @opindex mabs=legacy | |
ddf6fe37 AA |
27345 | @item -mabs=2008 |
27346 | @itemx -mabs=legacy | |
d77de738 ML |
27347 | These options control the treatment of the special not-a-number (NaN) |
27348 | IEEE 754 floating-point data with the @code{abs.@i{fmt}} and | |
27349 | @code{neg.@i{fmt}} machine instructions. | |
27350 | ||
27351 | By default or when @option{-mabs=legacy} is used the legacy | |
27352 | treatment is selected. In this case these instructions are considered | |
27353 | arithmetic and avoided where correct operation is required and the | |
27354 | input operand might be a NaN. A longer sequence of instructions that | |
27355 | manipulate the sign bit of floating-point datum manually is used | |
27356 | instead unless the @option{-ffinite-math-only} option has also been | |
27357 | specified. | |
27358 | ||
27359 | The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In | |
27360 | this case these instructions are considered non-arithmetic and therefore | |
27361 | operating correctly in all cases, including in particular where the | |
27362 | input operand is a NaN. These instructions are therefore always used | |
27363 | for the respective operations. | |
27364 | ||
d77de738 ML |
27365 | @opindex mnan=2008 |
27366 | @opindex mnan=legacy | |
ddf6fe37 AA |
27367 | @item -mnan=2008 |
27368 | @itemx -mnan=legacy | |
d77de738 ML |
27369 | These options control the encoding of the special not-a-number (NaN) |
27370 | IEEE 754 floating-point data. | |
27371 | ||
27372 | The @option{-mnan=legacy} option selects the legacy encoding. In this | |
27373 | case quiet NaNs (qNaNs) are denoted by the first bit of their trailing | |
27374 | significand field being 0, whereas signaling NaNs (sNaNs) are denoted | |
27375 | by the first bit of their trailing significand field being 1. | |
27376 | ||
27377 | The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In | |
27378 | this case qNaNs are denoted by the first bit of their trailing | |
27379 | significand field being 1, whereas sNaNs are denoted by the first bit of | |
27380 | their trailing significand field being 0. | |
27381 | ||
27382 | The default is @option{-mnan=legacy} unless GCC has been configured with | |
27383 | @option{--with-nan=2008}. | |
27384 | ||
d77de738 ML |
27385 | @opindex mllsc |
27386 | @opindex mno-llsc | |
ddf6fe37 AA |
27387 | @item -mllsc |
27388 | @itemx -mno-llsc | |
d77de738 ML |
27389 | Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to |
27390 | implement atomic memory built-in functions. When neither option is | |
27391 | specified, GCC uses the instructions if the target architecture | |
27392 | supports them. | |
27393 | ||
27394 | @option{-mllsc} is useful if the runtime environment can emulate the | |
27395 | instructions and @option{-mno-llsc} can be useful when compiling for | |
27396 | nonstandard ISAs. You can make either option the default by | |
27397 | configuring GCC with @option{--with-llsc} and @option{--without-llsc} | |
27398 | respectively. @option{--with-llsc} is the default for some | |
27399 | configurations; see the installation documentation for details. | |
27400 | ||
d77de738 ML |
27401 | @opindex mdsp |
27402 | @opindex mno-dsp | |
ddf6fe37 AA |
27403 | @item -mdsp |
27404 | @itemx -mno-dsp | |
d77de738 ML |
27405 | Use (do not use) revision 1 of the MIPS DSP ASE@. |
27406 | @xref{MIPS DSP Built-in Functions}. This option defines the | |
27407 | preprocessor macro @code{__mips_dsp}. It also defines | |
27408 | @code{__mips_dsp_rev} to 1. | |
27409 | ||
d77de738 ML |
27410 | @opindex mdspr2 |
27411 | @opindex mno-dspr2 | |
ddf6fe37 AA |
27412 | @item -mdspr2 |
27413 | @itemx -mno-dspr2 | |
d77de738 ML |
27414 | Use (do not use) revision 2 of the MIPS DSP ASE@. |
27415 | @xref{MIPS DSP Built-in Functions}. This option defines the | |
27416 | preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}. | |
27417 | It also defines @code{__mips_dsp_rev} to 2. | |
27418 | ||
d77de738 ML |
27419 | @opindex msmartmips |
27420 | @opindex mno-smartmips | |
ddf6fe37 AA |
27421 | @item -msmartmips |
27422 | @itemx -mno-smartmips | |
d77de738 ML |
27423 | Use (do not use) the MIPS SmartMIPS ASE. |
27424 | ||
d77de738 ML |
27425 | @opindex mpaired-single |
27426 | @opindex mno-paired-single | |
ddf6fe37 AA |
27427 | @item -mpaired-single |
27428 | @itemx -mno-paired-single | |
d77de738 ML |
27429 | Use (do not use) paired-single floating-point instructions. |
27430 | @xref{MIPS Paired-Single Support}. This option requires | |
27431 | hardware floating-point support to be enabled. | |
27432 | ||
d77de738 ML |
27433 | @opindex mdmx |
27434 | @opindex mno-mdmx | |
ddf6fe37 AA |
27435 | @item -mdmx |
27436 | @itemx -mno-mdmx | |
d77de738 ML |
27437 | Use (do not use) MIPS Digital Media Extension instructions. |
27438 | This option can only be used when generating 64-bit code and requires | |
27439 | hardware floating-point support to be enabled. | |
27440 | ||
d77de738 ML |
27441 | @opindex mips3d |
27442 | @opindex mno-mips3d | |
ddf6fe37 AA |
27443 | @item -mips3d |
27444 | @itemx -mno-mips3d | |
d77de738 ML |
27445 | Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}. |
27446 | The option @option{-mips3d} implies @option{-mpaired-single}. | |
27447 | ||
d77de738 ML |
27448 | @opindex mmicromips |
27449 | @opindex mno-mmicromips | |
ddf6fe37 AA |
27450 | @item -mmicromips |
27451 | @itemx -mno-micromips | |
d77de738 ML |
27452 | Generate (do not generate) microMIPS code. |
27453 | ||
27454 | MicroMIPS code generation can also be controlled on a per-function basis | |
27455 | by means of @code{micromips} and @code{nomicromips} attributes. | |
27456 | @xref{Function Attributes}, for more information. | |
27457 | ||
d77de738 ML |
27458 | @opindex mmt |
27459 | @opindex mno-mt | |
ddf6fe37 AA |
27460 | @item -mmt |
27461 | @itemx -mno-mt | |
d77de738 ML |
27462 | Use (do not use) MT Multithreading instructions. |
27463 | ||
d77de738 ML |
27464 | @opindex mmcu |
27465 | @opindex mno-mcu | |
ddf6fe37 AA |
27466 | @item -mmcu |
27467 | @itemx -mno-mcu | |
d77de738 ML |
27468 | Use (do not use) the MIPS MCU ASE instructions. |
27469 | ||
d77de738 ML |
27470 | @opindex meva |
27471 | @opindex mno-eva | |
ddf6fe37 AA |
27472 | @item -meva |
27473 | @itemx -mno-eva | |
d77de738 ML |
27474 | Use (do not use) the MIPS Enhanced Virtual Addressing instructions. |
27475 | ||
d77de738 ML |
27476 | @opindex mvirt |
27477 | @opindex mno-virt | |
ddf6fe37 AA |
27478 | @item -mvirt |
27479 | @itemx -mno-virt | |
d77de738 ML |
27480 | Use (do not use) the MIPS Virtualization (VZ) instructions. |
27481 | ||
d77de738 ML |
27482 | @opindex mxpa |
27483 | @opindex mno-xpa | |
ddf6fe37 AA |
27484 | @item -mxpa |
27485 | @itemx -mno-xpa | |
d77de738 ML |
27486 | Use (do not use) the MIPS eXtended Physical Address (XPA) instructions. |
27487 | ||
d77de738 ML |
27488 | @opindex mcrc |
27489 | @opindex mno-crc | |
ddf6fe37 AA |
27490 | @item -mcrc |
27491 | @itemx -mno-crc | |
d77de738 ML |
27492 | Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions. |
27493 | ||
d77de738 ML |
27494 | @opindex mginv |
27495 | @opindex mno-ginv | |
ddf6fe37 AA |
27496 | @item -mginv |
27497 | @itemx -mno-ginv | |
d77de738 ML |
27498 | Use (do not use) the MIPS Global INValidate (GINV) instructions. |
27499 | ||
d77de738 ML |
27500 | @opindex mloongson-mmi |
27501 | @opindex mno-loongson-mmi | |
ddf6fe37 AA |
27502 | @item -mloongson-mmi |
27503 | @itemx -mno-loongson-mmi | |
d77de738 ML |
27504 | Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI). |
27505 | ||
d77de738 ML |
27506 | @opindex mloongson-ext |
27507 | @opindex mno-loongson-ext | |
ddf6fe37 AA |
27508 | @item -mloongson-ext |
27509 | @itemx -mno-loongson-ext | |
d77de738 ML |
27510 | Use (do not use) the MIPS Loongson EXTensions (EXT) instructions. |
27511 | ||
d77de738 ML |
27512 | @opindex mloongson-ext2 |
27513 | @opindex mno-loongson-ext2 | |
ddf6fe37 AA |
27514 | @item -mloongson-ext2 |
27515 | @itemx -mno-loongson-ext2 | |
d77de738 ML |
27516 | Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions. |
27517 | ||
d77de738 | 27518 | @opindex mlong64 |
ddf6fe37 | 27519 | @item -mlong64 |
d77de738 ML |
27520 | Force @code{long} types to be 64 bits wide. See @option{-mlong32} for |
27521 | an explanation of the default and the way that the pointer size is | |
27522 | determined. | |
27523 | ||
d77de738 | 27524 | @opindex mlong32 |
ddf6fe37 | 27525 | @item -mlong32 |
d77de738 ML |
27526 | Force @code{long}, @code{int}, and pointer types to be 32 bits wide. |
27527 | ||
27528 | The default size of @code{int}s, @code{long}s and pointers depends on | |
27529 | the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI | |
27530 | uses 64-bit @code{long}s, as does the 64-bit EABI; the others use | |
27531 | 32-bit @code{long}s. Pointers are the same size as @code{long}s, | |
27532 | or the same size as integer registers, whichever is smaller. | |
27533 | ||
d77de738 ML |
27534 | @opindex msym32 |
27535 | @opindex mno-sym32 | |
ddf6fe37 AA |
27536 | @item -msym32 |
27537 | @itemx -mno-sym32 | |
d77de738 ML |
27538 | Assume (do not assume) that all symbols have 32-bit values, regardless |
27539 | of the selected ABI@. This option is useful in combination with | |
27540 | @option{-mabi=64} and @option{-mno-abicalls} because it allows GCC | |
27541 | to generate shorter and faster references to symbolic addresses. | |
27542 | ||
d77de738 | 27543 | @opindex G |
ddf6fe37 | 27544 | @item -G @var{num} |
d77de738 ML |
27545 | Put definitions of externally-visible data in a small data section |
27546 | if that data is no bigger than @var{num} bytes. GCC can then generate | |
27547 | more efficient accesses to the data; see @option{-mgpopt} for details. | |
27548 | ||
27549 | The default @option{-G} option depends on the configuration. | |
27550 | ||
d77de738 ML |
27551 | @opindex mlocal-sdata |
27552 | @opindex mno-local-sdata | |
ddf6fe37 AA |
27553 | @item -mlocal-sdata |
27554 | @itemx -mno-local-sdata | |
d77de738 ML |
27555 | Extend (do not extend) the @option{-G} behavior to local data too, |
27556 | such as to static variables in C@. @option{-mlocal-sdata} is the | |
27557 | default for all configurations. | |
27558 | ||
27559 | If the linker complains that an application is using too much small data, | |
27560 | you might want to try rebuilding the less performance-critical parts with | |
27561 | @option{-mno-local-sdata}. You might also want to build large | |
27562 | libraries with @option{-mno-local-sdata}, so that the libraries leave | |
27563 | more room for the main program. | |
27564 | ||
d77de738 ML |
27565 | @opindex mextern-sdata |
27566 | @opindex mno-extern-sdata | |
ddf6fe37 AA |
27567 | @item -mextern-sdata |
27568 | @itemx -mno-extern-sdata | |
d77de738 ML |
27569 | Assume (do not assume) that externally-defined data is in |
27570 | a small data section if the size of that data is within the @option{-G} limit. | |
27571 | @option{-mextern-sdata} is the default for all configurations. | |
27572 | ||
27573 | If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G | |
27574 | @var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var} | |
27575 | that is no bigger than @var{num} bytes, you must make sure that @var{Var} | |
27576 | is placed in a small data section. If @var{Var} is defined by another | |
27577 | module, you must either compile that module with a high-enough | |
27578 | @option{-G} setting or attach a @code{section} attribute to @var{Var}'s | |
27579 | definition. If @var{Var} is common, you must link the application | |
27580 | with a high-enough @option{-G} setting. | |
27581 | ||
27582 | The easiest way of satisfying these restrictions is to compile | |
27583 | and link every module with the same @option{-G} option. However, | |
27584 | you may wish to build a library that supports several different | |
27585 | small data limits. You can do this by compiling the library with | |
27586 | the highest supported @option{-G} setting and additionally using | |
27587 | @option{-mno-extern-sdata} to stop the library from making assumptions | |
27588 | about externally-defined data. | |
27589 | ||
d77de738 ML |
27590 | @opindex mgpopt |
27591 | @opindex mno-gpopt | |
ddf6fe37 AA |
27592 | @item -mgpopt |
27593 | @itemx -mno-gpopt | |
d77de738 ML |
27594 | Use (do not use) GP-relative accesses for symbols that are known to be |
27595 | in a small data section; see @option{-G}, @option{-mlocal-sdata} and | |
27596 | @option{-mextern-sdata}. @option{-mgpopt} is the default for all | |
27597 | configurations. | |
27598 | ||
27599 | @option{-mno-gpopt} is useful for cases where the @code{$gp} register | |
27600 | might not hold the value of @code{_gp}. For example, if the code is | |
27601 | part of a library that might be used in a boot monitor, programs that | |
27602 | call boot monitor routines pass an unknown value in @code{$gp}. | |
27603 | (In such situations, the boot monitor itself is usually compiled | |
27604 | with @option{-G0}.) | |
27605 | ||
27606 | @option{-mno-gpopt} implies @option{-mno-local-sdata} and | |
27607 | @option{-mno-extern-sdata}. | |
27608 | ||
d77de738 ML |
27609 | @opindex membedded-data |
27610 | @opindex mno-embedded-data | |
ddf6fe37 AA |
27611 | @item -membedded-data |
27612 | @itemx -mno-embedded-data | |
d77de738 ML |
27613 | Allocate variables to the read-only data section first if possible, then |
27614 | next in the small data section if possible, otherwise in data. This gives | |
27615 | slightly slower code than the default, but reduces the amount of RAM required | |
27616 | when executing, and thus may be preferred for some embedded systems. | |
27617 | ||
d77de738 ML |
27618 | @opindex muninit-const-in-rodata |
27619 | @opindex mno-uninit-const-in-rodata | |
ddf6fe37 AA |
27620 | @item -muninit-const-in-rodata |
27621 | @itemx -mno-uninit-const-in-rodata | |
d77de738 ML |
27622 | Put uninitialized @code{const} variables in the read-only data section. |
27623 | This option is only meaningful in conjunction with @option{-membedded-data}. | |
27624 | ||
d77de738 | 27625 | @opindex mcode-readable |
ddf6fe37 | 27626 | @item -mcode-readable=@var{setting} |
d77de738 ML |
27627 | Specify whether GCC may generate code that reads from executable sections. |
27628 | There are three possible settings: | |
27629 | ||
27630 | @table @gcctabopt | |
27631 | @item -mcode-readable=yes | |
27632 | Instructions may freely access executable sections. This is the | |
27633 | default setting. | |
27634 | ||
27635 | @item -mcode-readable=pcrel | |
27636 | MIPS16 PC-relative load instructions can access executable sections, | |
27637 | but other instructions must not do so. This option is useful on 4KSc | |
27638 | and 4KSd processors when the code TLBs have the Read Inhibit bit set. | |
27639 | It is also useful on processors that can be configured to have a dual | |
27640 | instruction/data SRAM interface and that, like the M4K, automatically | |
27641 | redirect PC-relative loads to the instruction RAM. | |
27642 | ||
27643 | @item -mcode-readable=no | |
27644 | Instructions must not access executable sections. This option can be | |
27645 | useful on targets that are configured to have a dual instruction/data | |
27646 | SRAM interface but that (unlike the M4K) do not automatically redirect | |
27647 | PC-relative loads to the instruction RAM. | |
27648 | @end table | |
27649 | ||
d77de738 ML |
27650 | @opindex msplit-addresses |
27651 | @opindex mno-split-addresses | |
ddf6fe37 AA |
27652 | @item -msplit-addresses |
27653 | @itemx -mno-split-addresses | |
d77de738 ML |
27654 | Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler |
27655 | relocation operators. This option has been superseded by | |
27656 | @option{-mexplicit-relocs} but is retained for backwards compatibility. | |
27657 | ||
d77de738 ML |
27658 | @opindex mexplicit-relocs |
27659 | @opindex mno-explicit-relocs | |
ddf6fe37 AA |
27660 | @item -mexplicit-relocs |
27661 | @itemx -mno-explicit-relocs | |
d77de738 ML |
27662 | Use (do not use) assembler relocation operators when dealing with symbolic |
27663 | addresses. The alternative, selected by @option{-mno-explicit-relocs}, | |
27664 | is to use assembler macros instead. | |
27665 | ||
27666 | @option{-mexplicit-relocs} is the default if GCC was configured | |
27667 | to use an assembler that supports relocation operators. | |
27668 | ||
d77de738 ML |
27669 | @opindex mcheck-zero-division |
27670 | @opindex mno-check-zero-division | |
ddf6fe37 AA |
27671 | @item -mcheck-zero-division |
27672 | @itemx -mno-check-zero-division | |
d77de738 ML |
27673 | Trap (do not trap) on integer division by zero. |
27674 | ||
27675 | The default is @option{-mcheck-zero-division}. | |
27676 | ||
d77de738 ML |
27677 | @opindex mdivide-traps |
27678 | @opindex mdivide-breaks | |
ddf6fe37 AA |
27679 | @item -mdivide-traps |
27680 | @itemx -mdivide-breaks | |
d77de738 ML |
27681 | MIPS systems check for division by zero by generating either a |
27682 | conditional trap or a break instruction. Using traps results in | |
27683 | smaller code, but is only supported on MIPS II and later. Also, some | |
27684 | versions of the Linux kernel have a bug that prevents trap from | |
27685 | generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to | |
27686 | allow conditional traps on architectures that support them and | |
27687 | @option{-mdivide-breaks} to force the use of breaks. | |
27688 | ||
27689 | The default is usually @option{-mdivide-traps}, but this can be | |
27690 | overridden at configure time using @option{--with-divide=breaks}. | |
27691 | Divide-by-zero checks can be completely disabled using | |
27692 | @option{-mno-check-zero-division}. | |
27693 | ||
d77de738 ML |
27694 | @opindex mload-store-pairs |
27695 | @opindex mno-load-store-pairs | |
ddf6fe37 AA |
27696 | @item -mload-store-pairs |
27697 | @itemx -mno-load-store-pairs | |
d77de738 ML |
27698 | Enable (disable) an optimization that pairs consecutive load or store |
27699 | instructions to enable load/store bonding. This option is enabled by | |
27700 | default but only takes effect when the selected architecture is known | |
27701 | to support bonding. | |
27702 | ||
d77de738 ML |
27703 | @opindex munaligned-access |
27704 | @opindex mno-unaligned-access | |
ddf6fe37 AA |
27705 | @item -munaligned-access |
27706 | @itemx -mno-unaligned-access | |
d77de738 ML |
27707 | Enable (disable) direct unaligned access for MIPS Release 6. |
27708 | MIPSr6 requires load/store unaligned-access support, | |
27709 | by hardware or trap&emulate. | |
27710 | So @option{-mno-unaligned-access} may be needed by kernel. | |
27711 | ||
d77de738 ML |
27712 | @opindex mmemcpy |
27713 | @opindex mno-memcpy | |
ddf6fe37 AA |
27714 | @item -mmemcpy |
27715 | @itemx -mno-memcpy | |
d77de738 ML |
27716 | Force (do not force) the use of @code{memcpy} for non-trivial block |
27717 | moves. The default is @option{-mno-memcpy}, which allows GCC to inline | |
27718 | most constant-sized copies. | |
27719 | ||
d77de738 ML |
27720 | @opindex mlong-calls |
27721 | @opindex mno-long-calls | |
ddf6fe37 AA |
27722 | @item -mlong-calls |
27723 | @itemx -mno-long-calls | |
d77de738 ML |
27724 | Disable (do not disable) use of the @code{jal} instruction. Calling |
27725 | functions using @code{jal} is more efficient but requires the caller | |
27726 | and callee to be in the same 256 megabyte segment. | |
27727 | ||
27728 | This option has no effect on abicalls code. The default is | |
27729 | @option{-mno-long-calls}. | |
27730 | ||
d77de738 ML |
27731 | @opindex mmad |
27732 | @opindex mno-mad | |
ddf6fe37 AA |
27733 | @item -mmad |
27734 | @itemx -mno-mad | |
d77de738 ML |
27735 | Enable (disable) use of the @code{mad}, @code{madu} and @code{mul} |
27736 | instructions, as provided by the R4650 ISA@. | |
27737 | ||
d77de738 ML |
27738 | @opindex mimadd |
27739 | @opindex mno-imadd | |
ddf6fe37 AA |
27740 | @item -mimadd |
27741 | @itemx -mno-imadd | |
d77de738 ML |
27742 | Enable (disable) use of the @code{madd} and @code{msub} integer |
27743 | instructions. The default is @option{-mimadd} on architectures | |
27744 | that support @code{madd} and @code{msub} except for the 74k | |
27745 | architecture where it was found to generate slower code. | |
27746 | ||
d77de738 ML |
27747 | @opindex mfused-madd |
27748 | @opindex mno-fused-madd | |
ddf6fe37 AA |
27749 | @item -mfused-madd |
27750 | @itemx -mno-fused-madd | |
d77de738 ML |
27751 | Enable (disable) use of the floating-point multiply-accumulate |
27752 | instructions, when they are available. The default is | |
27753 | @option{-mfused-madd}. | |
27754 | ||
27755 | On the R8000 CPU when multiply-accumulate instructions are used, | |
27756 | the intermediate product is calculated to infinite precision | |
27757 | and is not subject to the FCSR Flush to Zero bit. This may be | |
27758 | undesirable in some circumstances. On other processors the result | |
27759 | is numerically identical to the equivalent computation using | |
27760 | separate multiply, add, subtract and negate instructions. | |
27761 | ||
d77de738 | 27762 | @opindex nocpp |
ddf6fe37 | 27763 | @item -nocpp |
d77de738 ML |
27764 | Tell the MIPS assembler to not run its preprocessor over user |
27765 | assembler files (with a @samp{.s} suffix) when assembling them. | |
27766 | ||
d77de738 ML |
27767 | @opindex mfix-24k |
27768 | @opindex mno-fix-24k | |
ddf6fe37 AA |
27769 | @item -mfix-24k |
27770 | @itemx -mno-fix-24k | |
d77de738 ML |
27771 | Work around the 24K E48 (lost data on stores during refill) errata. |
27772 | The workarounds are implemented by the assembler rather than by GCC@. | |
27773 | ||
d77de738 ML |
27774 | @opindex mfix-r4000 |
27775 | @opindex mno-fix-r4000 | |
ddf6fe37 AA |
27776 | @item -mfix-r4000 |
27777 | @itemx -mno-fix-r4000 | |
d77de738 ML |
27778 | Work around certain R4000 CPU errata: |
27779 | @itemize @minus | |
27780 | @item | |
27781 | A double-word or a variable shift may give an incorrect result if executed | |
27782 | immediately after starting an integer division. | |
27783 | @item | |
27784 | A double-word or a variable shift may give an incorrect result if executed | |
27785 | while an integer multiplication is in progress. | |
27786 | @item | |
27787 | An integer division may give an incorrect result if started in a delay slot | |
27788 | of a taken branch or a jump. | |
27789 | @end itemize | |
27790 | ||
d77de738 ML |
27791 | @opindex mfix-r4400 |
27792 | @opindex mno-fix-r4400 | |
ddf6fe37 AA |
27793 | @item -mfix-r4400 |
27794 | @itemx -mno-fix-r4400 | |
d77de738 ML |
27795 | Work around certain R4400 CPU errata: |
27796 | @itemize @minus | |
27797 | @item | |
27798 | A double-word or a variable shift may give an incorrect result if executed | |
27799 | immediately after starting an integer division. | |
27800 | @end itemize | |
27801 | ||
d77de738 ML |
27802 | @opindex mfix-r10000 |
27803 | @opindex mno-fix-r10000 | |
ddf6fe37 AA |
27804 | @item -mfix-r10000 |
27805 | @itemx -mno-fix-r10000 | |
d77de738 ML |
27806 | Work around certain R10000 errata: |
27807 | @itemize @minus | |
27808 | @item | |
27809 | @code{ll}/@code{sc} sequences may not behave atomically on revisions | |
27810 | prior to 3.0. They may deadlock on revisions 2.6 and earlier. | |
27811 | @end itemize | |
27812 | ||
27813 | This option can only be used if the target architecture supports | |
27814 | branch-likely instructions. @option{-mfix-r10000} is the default when | |
27815 | @option{-march=r10000} is used; @option{-mno-fix-r10000} is the default | |
27816 | otherwise. | |
27817 | ||
ddf6fe37 | 27818 | @opindex mfix-r5900 |
d77de738 ML |
27819 | @item -mfix-r5900 |
27820 | @itemx -mno-fix-r5900 | |
d77de738 ML |
27821 | Do not attempt to schedule the preceding instruction into the delay slot |
27822 | of a branch instruction placed at the end of a short loop of six | |
27823 | instructions or fewer and always schedule a @code{nop} instruction there | |
27824 | instead. The short loop bug under certain conditions causes loops to | |
27825 | execute only once or twice, due to a hardware bug in the R5900 chip. The | |
27826 | workaround is implemented by the assembler rather than by GCC@. | |
27827 | ||
ddf6fe37 | 27828 | @opindex mfix-rm7000 |
d77de738 ML |
27829 | @item -mfix-rm7000 |
27830 | @itemx -mno-fix-rm7000 | |
d77de738 ML |
27831 | Work around the RM7000 @code{dmult}/@code{dmultu} errata. The |
27832 | workarounds are implemented by the assembler rather than by GCC@. | |
27833 | ||
ddf6fe37 | 27834 | @opindex mfix-vr4120 |
d77de738 ML |
27835 | @item -mfix-vr4120 |
27836 | @itemx -mno-fix-vr4120 | |
d77de738 ML |
27837 | Work around certain VR4120 errata: |
27838 | @itemize @minus | |
27839 | @item | |
27840 | @code{dmultu} does not always produce the correct result. | |
27841 | @item | |
27842 | @code{div} and @code{ddiv} do not always produce the correct result if one | |
27843 | of the operands is negative. | |
27844 | @end itemize | |
27845 | The workarounds for the division errata rely on special functions in | |
27846 | @file{libgcc.a}. At present, these functions are only provided by | |
27847 | the @code{mips64vr*-elf} configurations. | |
27848 | ||
27849 | Other VR4120 errata require a NOP to be inserted between certain pairs of | |
27850 | instructions. These errata are handled by the assembler, not by GCC itself. | |
27851 | ||
d77de738 | 27852 | @opindex mfix-vr4130 |
ddf6fe37 | 27853 | @item -mfix-vr4130 |
d77de738 ML |
27854 | Work around the VR4130 @code{mflo}/@code{mfhi} errata. The |
27855 | workarounds are implemented by the assembler rather than by GCC, | |
27856 | although GCC avoids using @code{mflo} and @code{mfhi} if the | |
27857 | VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi} | |
27858 | instructions are available instead. | |
27859 | ||
ddf6fe37 | 27860 | @opindex mfix-sb1 |
d77de738 ML |
27861 | @item -mfix-sb1 |
27862 | @itemx -mno-fix-sb1 | |
d77de738 ML |
27863 | Work around certain SB-1 CPU core errata. |
27864 | (This flag currently works around the SB-1 revision 2 | |
27865 | ``F1'' and ``F2'' floating-point errata.) | |
27866 | ||
d77de738 | 27867 | @opindex mr10k-cache-barrier |
ddf6fe37 | 27868 | @item -mr10k-cache-barrier=@var{setting} |
d77de738 ML |
27869 | Specify whether GCC should insert cache barriers to avoid the |
27870 | side effects of speculation on R10K processors. | |
27871 | ||
27872 | In common with many processors, the R10K tries to predict the outcome | |
27873 | of a conditional branch and speculatively executes instructions from | |
27874 | the ``taken'' branch. It later aborts these instructions if the | |
27875 | predicted outcome is wrong. However, on the R10K, even aborted | |
27876 | instructions can have side effects. | |
27877 | ||
27878 | This problem only affects kernel stores and, depending on the system, | |
27879 | kernel loads. As an example, a speculatively-executed store may load | |
27880 | the target memory into cache and mark the cache line as dirty, even if | |
27881 | the store itself is later aborted. If a DMA operation writes to the | |
27882 | same area of memory before the ``dirty'' line is flushed, the cached | |
27883 | data overwrites the DMA-ed data. See the R10K processor manual | |
27884 | for a full description, including other potential problems. | |
27885 | ||
27886 | One workaround is to insert cache barrier instructions before every memory | |
27887 | access that might be speculatively executed and that might have side | |
27888 | effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}} | |
27889 | controls GCC's implementation of this workaround. It assumes that | |
27890 | aborted accesses to any byte in the following regions does not have | |
27891 | side effects: | |
27892 | ||
27893 | @enumerate | |
27894 | @item | |
27895 | the memory occupied by the current function's stack frame; | |
27896 | ||
27897 | @item | |
27898 | the memory occupied by an incoming stack argument; | |
27899 | ||
27900 | @item | |
27901 | the memory occupied by an object with a link-time-constant address. | |
27902 | @end enumerate | |
27903 | ||
27904 | It is the kernel's responsibility to ensure that speculative | |
27905 | accesses to these regions are indeed safe. | |
27906 | ||
27907 | If the input program contains a function declaration such as: | |
27908 | ||
27909 | @smallexample | |
27910 | void foo (void); | |
27911 | @end smallexample | |
27912 | ||
27913 | then the implementation of @code{foo} must allow @code{j foo} and | |
27914 | @code{jal foo} to be executed speculatively. GCC honors this | |
27915 | restriction for functions it compiles itself. It expects non-GCC | |
27916 | functions (such as hand-written assembly code) to do the same. | |
27917 | ||
27918 | The option has three forms: | |
27919 | ||
27920 | @table @gcctabopt | |
27921 | @item -mr10k-cache-barrier=load-store | |
27922 | Insert a cache barrier before a load or store that might be | |
27923 | speculatively executed and that might have side effects even | |
27924 | if aborted. | |
27925 | ||
27926 | @item -mr10k-cache-barrier=store | |
27927 | Insert a cache barrier before a store that might be speculatively | |
27928 | executed and that might have side effects even if aborted. | |
27929 | ||
27930 | @item -mr10k-cache-barrier=none | |
27931 | Disable the insertion of cache barriers. This is the default setting. | |
27932 | @end table | |
27933 | ||
ddf6fe37 | 27934 | @opindex mflush-func |
d77de738 ML |
27935 | @item -mflush-func=@var{func} |
27936 | @itemx -mno-flush-func | |
d77de738 ML |
27937 | Specifies the function to call to flush the I and D caches, or to not |
27938 | call any such function. If called, the function must take the same | |
27939 | arguments as the common @code{_flush_func}, that is, the address of the | |
27940 | memory range for which the cache is being flushed, the size of the | |
27941 | memory range, and the number 3 (to flush both caches). The default | |
27942 | depends on the target GCC was configured for, but commonly is either | |
27943 | @code{_flush_func} or @code{__cpu_flush}. | |
27944 | ||
d77de738 | 27945 | @opindex mbranch-cost |
ddf6fe37 | 27946 | @item mbranch-cost=@var{num} |
d77de738 ML |
27947 | Set the cost of branches to roughly @var{num} ``simple'' instructions. |
27948 | This cost is only a heuristic and is not guaranteed to produce | |
27949 | consistent results across releases. A zero cost redundantly selects | |
27950 | the default, which is based on the @option{-mtune} setting. | |
27951 | ||
d77de738 ML |
27952 | @opindex mbranch-likely |
27953 | @opindex mno-branch-likely | |
ddf6fe37 AA |
27954 | @item -mbranch-likely |
27955 | @itemx -mno-branch-likely | |
d77de738 ML |
27956 | Enable or disable use of Branch Likely instructions, regardless of the |
27957 | default for the selected architecture. By default, Branch Likely | |
27958 | instructions may be generated if they are supported by the selected | |
27959 | architecture. An exception is for the MIPS32 and MIPS64 architectures | |
27960 | and processors that implement those architectures; for those, Branch | |
27961 | Likely instructions are not be generated by default because the MIPS32 | |
27962 | and MIPS64 architectures specifically deprecate their use. | |
27963 | ||
d77de738 ML |
27964 | @opindex mcompact-branches=never |
27965 | @opindex mcompact-branches=optimal | |
27966 | @opindex mcompact-branches=always | |
ddf6fe37 AA |
27967 | @item -mcompact-branches=never |
27968 | @itemx -mcompact-branches=optimal | |
27969 | @itemx -mcompact-branches=always | |
d77de738 ML |
27970 | These options control which form of branches will be generated. The |
27971 | default is @option{-mcompact-branches=optimal}. | |
27972 | ||
27973 | The @option{-mcompact-branches=never} option ensures that compact branch | |
27974 | instructions will never be generated. | |
27975 | ||
27976 | The @option{-mcompact-branches=always} option ensures that a compact | |
27977 | branch instruction will be generated if available for MIPS Release 6 onwards. | |
27978 | If a compact branch instruction is not available (or pre-R6), | |
27979 | a delay slot form of the branch will be used instead. | |
27980 | ||
27981 | If it is used for MIPS16/microMIPS targets, it will be just ignored now. | |
27982 | The behaviour for MIPS16/microMIPS may change in future, | |
27983 | since they do have some compact branch instructions. | |
27984 | ||
27985 | The @option{-mcompact-branches=optimal} option will cause a delay slot | |
27986 | branch to be used if one is available in the current ISA and the delay | |
27987 | slot is successfully filled. If the delay slot is not filled, a compact | |
27988 | branch will be chosen if one is available. | |
27989 | ||
ddf6fe37 | 27990 | @opindex mfp-exceptions |
d77de738 ML |
27991 | @item -mfp-exceptions |
27992 | @itemx -mno-fp-exceptions | |
d77de738 ML |
27993 | Specifies whether FP exceptions are enabled. This affects how |
27994 | FP instructions are scheduled for some processors. | |
27995 | The default is that FP exceptions are | |
27996 | enabled. | |
27997 | ||
27998 | For instance, on the SB-1, if FP exceptions are disabled, and we are emitting | |
27999 | 64-bit code, then we can use both FP pipes. Otherwise, we can only use one | |
28000 | FP pipe. | |
28001 | ||
ddf6fe37 | 28002 | @opindex mvr4130-align |
d77de738 ML |
28003 | @item -mvr4130-align |
28004 | @itemx -mno-vr4130-align | |
d77de738 ML |
28005 | The VR4130 pipeline is two-way superscalar, but can only issue two |
28006 | instructions together if the first one is 8-byte aligned. When this | |
28007 | option is enabled, GCC aligns pairs of instructions that it | |
28008 | thinks should execute in parallel. | |
28009 | ||
28010 | This option only has an effect when optimizing for the VR4130. | |
28011 | It normally makes code faster, but at the expense of making it bigger. | |
28012 | It is enabled by default at optimization level @option{-O3}. | |
28013 | ||
ddf6fe37 | 28014 | @opindex msynci |
d77de738 ML |
28015 | @item -msynci |
28016 | @itemx -mno-synci | |
d77de738 ML |
28017 | Enable (disable) generation of @code{synci} instructions on |
28018 | architectures that support it. The @code{synci} instructions (if | |
28019 | enabled) are generated when @code{__builtin___clear_cache} is | |
28020 | compiled. | |
28021 | ||
28022 | This option defaults to @option{-mno-synci}, but the default can be | |
28023 | overridden by configuring GCC with @option{--with-synci}. | |
28024 | ||
28025 | When compiling code for single processor systems, it is generally safe | |
28026 | to use @code{synci}. However, on many multi-core (SMP) systems, it | |
28027 | does not invalidate the instruction caches on all cores and may lead | |
28028 | to undefined behavior. | |
28029 | ||
ddf6fe37 | 28030 | @opindex mrelax-pic-calls |
d77de738 ML |
28031 | @item -mrelax-pic-calls |
28032 | @itemx -mno-relax-pic-calls | |
d77de738 ML |
28033 | Try to turn PIC calls that are normally dispatched via register |
28034 | @code{$25} into direct calls. This is only possible if the linker can | |
28035 | resolve the destination at link time and if the destination is within | |
28036 | range for a direct call. | |
28037 | ||
28038 | @option{-mrelax-pic-calls} is the default if GCC was configured to use | |
28039 | an assembler and a linker that support the @code{.reloc} assembly | |
28040 | directive and @option{-mexplicit-relocs} is in effect. With | |
28041 | @option{-mno-explicit-relocs}, this optimization can be performed by the | |
28042 | assembler and the linker alone without help from the compiler. | |
28043 | ||
d77de738 ML |
28044 | @opindex mmcount-ra-address |
28045 | @opindex mno-mcount-ra-address | |
ddf6fe37 AA |
28046 | @item -mmcount-ra-address |
28047 | @itemx -mno-mcount-ra-address | |
d77de738 ML |
28048 | Emit (do not emit) code that allows @code{_mcount} to modify the |
28049 | calling function's return address. When enabled, this option extends | |
28050 | the usual @code{_mcount} interface with a new @var{ra-address} | |
28051 | parameter, which has type @code{intptr_t *} and is passed in register | |
28052 | @code{$12}. @code{_mcount} can then modify the return address by | |
28053 | doing both of the following: | |
28054 | @itemize | |
28055 | @item | |
28056 | Returning the new address in register @code{$31}. | |
28057 | @item | |
28058 | Storing the new address in @code{*@var{ra-address}}, | |
28059 | if @var{ra-address} is nonnull. | |
28060 | @end itemize | |
28061 | ||
28062 | The default is @option{-mno-mcount-ra-address}. | |
28063 | ||
ddf6fe37 | 28064 | @opindex mframe-header-opt |
d77de738 ML |
28065 | @item -mframe-header-opt |
28066 | @itemx -mno-frame-header-opt | |
d77de738 ML |
28067 | Enable (disable) frame header optimization in the o32 ABI. When using the |
28068 | o32 ABI, calling functions will allocate 16 bytes on the stack for the called | |
28069 | function to write out register arguments. When enabled, this optimization | |
28070 | will suppress the allocation of the frame header if it can be determined that | |
28071 | it is unused. | |
28072 | ||
28073 | This optimization is off by default at all optimization levels. | |
28074 | ||
ddf6fe37 | 28075 | @opindex mlxc1-sxc1 |
d77de738 ML |
28076 | @item -mlxc1-sxc1 |
28077 | @itemx -mno-lxc1-sxc1 | |
d77de738 ML |
28078 | When applicable, enable (disable) the generation of @code{lwxc1}, |
28079 | @code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default. | |
28080 | ||
ddf6fe37 | 28081 | @opindex mmadd4 |
d77de738 ML |
28082 | @item -mmadd4 |
28083 | @itemx -mno-madd4 | |
d77de738 ML |
28084 | When applicable, enable (disable) the generation of 4-operand @code{madd.s}, |
28085 | @code{madd.d} and related instructions. Enabled by default. | |
28086 | ||
28087 | @end table | |
28088 | ||
28089 | @node MMIX Options | |
28090 | @subsection MMIX Options | |
28091 | @cindex MMIX Options | |
28092 | ||
28093 | These options are defined for the MMIX: | |
28094 | ||
28095 | @table @gcctabopt | |
d77de738 ML |
28096 | @opindex mlibfuncs |
28097 | @opindex mno-libfuncs | |
ddf6fe37 AA |
28098 | @item -mlibfuncs |
28099 | @itemx -mno-libfuncs | |
d77de738 ML |
28100 | Specify that intrinsic library functions are being compiled, passing all |
28101 | values in registers, no matter the size. | |
28102 | ||
d77de738 ML |
28103 | @opindex mepsilon |
28104 | @opindex mno-epsilon | |
ddf6fe37 AA |
28105 | @item -mepsilon |
28106 | @itemx -mno-epsilon | |
d77de738 ML |
28107 | Generate floating-point comparison instructions that compare with respect |
28108 | to the @code{rE} epsilon register. | |
28109 | ||
d77de738 ML |
28110 | @opindex mabi=mmixware |
28111 | @opindex mabi=gnu | |
ddf6fe37 AA |
28112 | @item -mabi=mmixware |
28113 | @itemx -mabi=gnu | |
d77de738 ML |
28114 | Generate code that passes function parameters and return values that (in |
28115 | the called function) are seen as registers @code{$0} and up, as opposed to | |
28116 | the GNU ABI which uses global registers @code{$231} and up. | |
28117 | ||
d77de738 ML |
28118 | @opindex mzero-extend |
28119 | @opindex mno-zero-extend | |
ddf6fe37 AA |
28120 | @item -mzero-extend |
28121 | @itemx -mno-zero-extend | |
d77de738 ML |
28122 | When reading data from memory in sizes shorter than 64 bits, use (do not |
28123 | use) zero-extending load instructions by default, rather than | |
28124 | sign-extending ones. | |
28125 | ||
d77de738 ML |
28126 | @opindex mknuthdiv |
28127 | @opindex mno-knuthdiv | |
ddf6fe37 AA |
28128 | @item -mknuthdiv |
28129 | @itemx -mno-knuthdiv | |
d77de738 ML |
28130 | Make the result of a division yielding a remainder have the same sign as |
28131 | the divisor. With the default, @option{-mno-knuthdiv}, the sign of the | |
28132 | remainder follows the sign of the dividend. Both methods are | |
28133 | arithmetically valid, the latter being almost exclusively used. | |
28134 | ||
d77de738 ML |
28135 | @opindex mtoplevel-symbols |
28136 | @opindex mno-toplevel-symbols | |
ddf6fe37 AA |
28137 | @item -mtoplevel-symbols |
28138 | @itemx -mno-toplevel-symbols | |
d77de738 ML |
28139 | Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly |
28140 | code can be used with the @code{PREFIX} assembly directive. | |
28141 | ||
d77de738 | 28142 | @opindex melf |
ddf6fe37 | 28143 | @item -melf |
d77de738 ML |
28144 | Generate an executable in the ELF format, rather than the default |
28145 | @samp{mmo} format used by the @command{mmix} simulator. | |
28146 | ||
d77de738 ML |
28147 | @opindex mbranch-predict |
28148 | @opindex mno-branch-predict | |
ddf6fe37 AA |
28149 | @item -mbranch-predict |
28150 | @itemx -mno-branch-predict | |
d77de738 ML |
28151 | Use (do not use) the probable-branch instructions, when static branch |
28152 | prediction indicates a probable branch. | |
28153 | ||
d77de738 ML |
28154 | @opindex mbase-addresses |
28155 | @opindex mno-base-addresses | |
ddf6fe37 AA |
28156 | @item -mbase-addresses |
28157 | @itemx -mno-base-addresses | |
d77de738 ML |
28158 | Generate (do not generate) code that uses @emph{base addresses}. Using a |
28159 | base address automatically generates a request (handled by the assembler | |
28160 | and the linker) for a constant to be set up in a global register. The | |
28161 | register is used for one or more base address requests within the range 0 | |
28162 | to 255 from the value held in the register. The generally leads to short | |
28163 | and fast code, but the number of different data items that can be | |
28164 | addressed is limited. This means that a program that uses lots of static | |
28165 | data may require @option{-mno-base-addresses}. | |
28166 | ||
d77de738 ML |
28167 | @opindex msingle-exit |
28168 | @opindex mno-single-exit | |
ddf6fe37 AA |
28169 | @item -msingle-exit |
28170 | @itemx -mno-single-exit | |
d77de738 ML |
28171 | Force (do not force) generated code to have a single exit point in each |
28172 | function. | |
28173 | @end table | |
28174 | ||
28175 | @node MN10300 Options | |
28176 | @subsection MN10300 Options | |
28177 | @cindex MN10300 options | |
28178 | ||
28179 | These @option{-m} options are defined for Matsushita MN10300 architectures: | |
28180 | ||
28181 | @table @gcctabopt | |
d77de738 | 28182 | @opindex mmult-bug |
ddf6fe37 | 28183 | @item -mmult-bug |
d77de738 ML |
28184 | Generate code to avoid bugs in the multiply instructions for the MN10300 |
28185 | processors. This is the default. | |
28186 | ||
d77de738 | 28187 | @opindex mno-mult-bug |
ddf6fe37 | 28188 | @item -mno-mult-bug |
d77de738 ML |
28189 | Do not generate code to avoid bugs in the multiply instructions for the |
28190 | MN10300 processors. | |
28191 | ||
d77de738 | 28192 | @opindex mam33 |
ddf6fe37 | 28193 | @item -mam33 |
d77de738 ML |
28194 | Generate code using features specific to the AM33 processor. |
28195 | ||
d77de738 | 28196 | @opindex mno-am33 |
ddf6fe37 | 28197 | @item -mno-am33 |
d77de738 ML |
28198 | Do not generate code using features specific to the AM33 processor. This |
28199 | is the default. | |
28200 | ||
d77de738 | 28201 | @opindex mam33-2 |
ddf6fe37 | 28202 | @item -mam33-2 |
d77de738 ML |
28203 | Generate code using features specific to the AM33/2.0 processor. |
28204 | ||
d77de738 | 28205 | @opindex mam34 |
ddf6fe37 | 28206 | @item -mam34 |
d77de738 ML |
28207 | Generate code using features specific to the AM34 processor. |
28208 | ||
d77de738 | 28209 | @opindex mtune |
ddf6fe37 | 28210 | @item -mtune=@var{cpu-type} |
d77de738 ML |
28211 | Use the timing characteristics of the indicated CPU type when |
28212 | scheduling instructions. This does not change the targeted processor | |
28213 | type. The CPU type must be one of @samp{mn10300}, @samp{am33}, | |
28214 | @samp{am33-2} or @samp{am34}. | |
28215 | ||
d77de738 | 28216 | @opindex mreturn-pointer-on-d0 |
ddf6fe37 | 28217 | @item -mreturn-pointer-on-d0 |
d77de738 ML |
28218 | When generating a function that returns a pointer, return the pointer |
28219 | in both @code{a0} and @code{d0}. Otherwise, the pointer is returned | |
28220 | only in @code{a0}, and attempts to call such functions without a prototype | |
28221 | result in errors. Note that this option is on by default; use | |
28222 | @option{-mno-return-pointer-on-d0} to disable it. | |
28223 | ||
d77de738 | 28224 | @opindex mno-crt0 |
ddf6fe37 | 28225 | @item -mno-crt0 |
d77de738 ML |
28226 | Do not link in the C run-time initialization object file. |
28227 | ||
d77de738 | 28228 | @opindex mrelax |
ddf6fe37 | 28229 | @item -mrelax |
d77de738 ML |
28230 | Indicate to the linker that it should perform a relaxation optimization pass |
28231 | to shorten branches, calls and absolute memory addresses. This option only | |
28232 | has an effect when used on the command line for the final link step. | |
28233 | ||
28234 | This option makes symbolic debugging impossible. | |
28235 | ||
d77de738 | 28236 | @opindex mliw |
ddf6fe37 | 28237 | @item -mliw |
d77de738 ML |
28238 | Allow the compiler to generate @emph{Long Instruction Word} |
28239 | instructions if the target is the @samp{AM33} or later. This is the | |
28240 | default. This option defines the preprocessor macro @code{__LIW__}. | |
28241 | ||
d77de738 | 28242 | @opindex mno-liw |
ddf6fe37 | 28243 | @item -mno-liw |
d77de738 ML |
28244 | Do not allow the compiler to generate @emph{Long Instruction Word} |
28245 | instructions. This option defines the preprocessor macro | |
28246 | @code{__NO_LIW__}. | |
28247 | ||
d77de738 | 28248 | @opindex msetlb |
ddf6fe37 | 28249 | @item -msetlb |
d77de738 ML |
28250 | Allow the compiler to generate the @emph{SETLB} and @emph{Lcc} |
28251 | instructions if the target is the @samp{AM33} or later. This is the | |
28252 | default. This option defines the preprocessor macro @code{__SETLB__}. | |
28253 | ||
d77de738 | 28254 | @opindex mno-setlb |
ddf6fe37 | 28255 | @item -mno-setlb |
d77de738 ML |
28256 | Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc} |
28257 | instructions. This option defines the preprocessor macro | |
28258 | @code{__NO_SETLB__}. | |
28259 | ||
28260 | @end table | |
28261 | ||
28262 | @node Moxie Options | |
28263 | @subsection Moxie Options | |
28264 | @cindex Moxie Options | |
28265 | ||
28266 | @table @gcctabopt | |
28267 | ||
d77de738 | 28268 | @opindex meb |
ddf6fe37 | 28269 | @item -meb |
d77de738 ML |
28270 | Generate big-endian code. This is the default for @samp{moxie-*-*} |
28271 | configurations. | |
28272 | ||
d77de738 | 28273 | @opindex mel |
ddf6fe37 | 28274 | @item -mel |
d77de738 ML |
28275 | Generate little-endian code. |
28276 | ||
d77de738 | 28277 | @opindex mmul.x |
ddf6fe37 | 28278 | @item -mmul.x |
d77de738 ML |
28279 | Generate mul.x and umul.x instructions. This is the default for |
28280 | @samp{moxiebox-*-*} configurations. | |
28281 | ||
d77de738 | 28282 | @opindex mno-crt0 |
ddf6fe37 | 28283 | @item -mno-crt0 |
d77de738 ML |
28284 | Do not link in the C run-time initialization object file. |
28285 | ||
28286 | @end table | |
28287 | ||
28288 | @node MSP430 Options | |
28289 | @subsection MSP430 Options | |
28290 | @cindex MSP430 Options | |
28291 | ||
28292 | These options are defined for the MSP430: | |
28293 | ||
28294 | @table @gcctabopt | |
28295 | ||
d77de738 | 28296 | @opindex masm-hex |
ddf6fe37 | 28297 | @item -masm-hex |
d77de738 ML |
28298 | Force assembly output to always use hex constants. Normally such |
28299 | constants are signed decimals, but this option is available for | |
28300 | testsuite and/or aesthetic purposes. | |
28301 | ||
d77de738 | 28302 | @opindex mmcu= |
ddf6fe37 | 28303 | @item -mmcu= |
d77de738 ML |
28304 | Select the MCU to target. This is used to create a C preprocessor |
28305 | symbol based upon the MCU name, converted to upper case and pre- and | |
28306 | post-fixed with @samp{__}. This in turn is used by the | |
28307 | @file{msp430.h} header file to select an MCU-specific supplementary | |
28308 | header file. | |
28309 | ||
28310 | The option also sets the ISA to use. If the MCU name is one that is | |
28311 | known to only support the 430 ISA then that is selected, otherwise the | |
28312 | 430X ISA is selected. A generic MCU name of @samp{msp430} can also be | |
28313 | used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU | |
28314 | name selects the 430X ISA. | |
28315 | ||
28316 | In addition an MCU-specific linker script is added to the linker | |
28317 | command line. The script's name is the name of the MCU with | |
28318 | @file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc} | |
28319 | command line defines the C preprocessor symbol @code{__XXX__} and | |
28320 | cause the linker to search for a script called @file{xxx.ld}. | |
28321 | ||
28322 | The ISA and hardware multiply supported for the different MCUs is hard-coded | |
28323 | into GCC. However, an external @samp{devices.csv} file can be used to | |
28324 | extend device support beyond those that have been hard-coded. | |
28325 | ||
28326 | GCC searches for the @samp{devices.csv} file using the following methods in the | |
28327 | given precedence order, where the first method takes precendence over the | |
28328 | second which takes precedence over the third. | |
28329 | ||
28330 | @table @asis | |
28331 | @item Include path specified with @code{-I} and @code{-L} | |
28332 | @samp{devices.csv} will be searched for in each of the directories specified by | |
28333 | include paths and linker library search paths. | |
28334 | @item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR} | |
28335 | Define the value of the global environment variable | |
28336 | @samp{MSP430_GCC_INCLUDE_DIR} | |
28337 | to the full path to the directory containing devices.csv, and GCC will search | |
28338 | this directory for devices.csv. If devices.csv is found, this directory will | |
28339 | also be registered as an include path, and linker library path. Header files | |
28340 | and linker scripts in this directory can therefore be used without manually | |
28341 | specifying @code{-I} and @code{-L} on the command line. | |
28342 | @item The @samp{msp430-elf@{,bare@}/include/devices} directory | |
28343 | Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the | |
28344 | toolchain root directory. This directory does not exist in a default | |
28345 | installation, but if the user has created it and copied @samp{devices.csv} | |
28346 | there, then the MCU data will be read. As above, this directory will | |
28347 | also be registered as an include path, and linker library path. | |
28348 | ||
28349 | @end table | |
28350 | If none of the above search methods find @samp{devices.csv}, then the | |
28351 | hard-coded MCU data is used. | |
28352 | ||
28353 | ||
d77de738 ML |
28354 | @opindex mwarn-mcu |
28355 | @opindex mno-warn-mcu | |
ddf6fe37 AA |
28356 | @item -mwarn-mcu |
28357 | @itemx -mno-warn-mcu | |
d77de738 ML |
28358 | This option enables or disables warnings about conflicts between the |
28359 | MCU name specified by the @option{-mmcu} option and the ISA set by the | |
28360 | @option{-mcpu} option and/or the hardware multiply support set by the | |
28361 | @option{-mhwmult} option. It also toggles warnings about unrecognized | |
28362 | MCU names. This option is on by default. | |
28363 | ||
d77de738 | 28364 | @opindex mcpu= |
ddf6fe37 | 28365 | @item -mcpu= |
d77de738 ML |
28366 | Specifies the ISA to use. Accepted values are @samp{msp430}, |
28367 | @samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The | |
28368 | @option{-mmcu=} option should be used to select the ISA. | |
28369 | ||
d77de738 | 28370 | @opindex msim |
ddf6fe37 | 28371 | @item -msim |
d77de738 ML |
28372 | Link to the simulator runtime libraries and linker script. Overrides |
28373 | any scripts that would be selected by the @option{-mmcu=} option. | |
28374 | ||
d77de738 | 28375 | @opindex mlarge |
ddf6fe37 | 28376 | @item -mlarge |
d77de738 ML |
28377 | Use large-model addressing (20-bit pointers, 20-bit @code{size_t}). |
28378 | ||
d77de738 | 28379 | @opindex msmall |
ddf6fe37 | 28380 | @item -msmall |
d77de738 ML |
28381 | Use small-model addressing (16-bit pointers, 16-bit @code{size_t}). |
28382 | ||
d77de738 | 28383 | @opindex mrelax |
ddf6fe37 | 28384 | @item -mrelax |
d77de738 ML |
28385 | This option is passed to the assembler and linker, and allows the |
28386 | linker to perform certain optimizations that cannot be done until | |
28387 | the final link. | |
28388 | ||
d77de738 | 28389 | @opindex mhwmult= |
ddf6fe37 | 28390 | @item mhwmult= |
d77de738 ML |
28391 | Describes the type of hardware multiply supported by the target. |
28392 | Accepted values are @samp{none} for no hardware multiply, @samp{16bit} | |
28393 | for the original 16-bit-only multiply supported by early MCUs. | |
28394 | @samp{32bit} for the 16/32-bit multiply supported by later MCUs and | |
28395 | @samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs. | |
28396 | A value of @samp{auto} can also be given. This tells GCC to deduce | |
28397 | the hardware multiply support based upon the MCU name provided by the | |
28398 | @option{-mmcu} option. If no @option{-mmcu} option is specified or if | |
28399 | the MCU name is not recognized then no hardware multiply support is | |
28400 | assumed. @code{auto} is the default setting. | |
28401 | ||
28402 | Hardware multiplies are normally performed by calling a library | |
28403 | routine. This saves space in the generated code. When compiling at | |
28404 | @option{-O3} or higher however the hardware multiplier is invoked | |
28405 | inline. This makes for bigger, but faster code. | |
28406 | ||
28407 | The hardware multiply routines disable interrupts whilst running and | |
28408 | restore the previous interrupt state when they finish. This makes | |
28409 | them safe to use inside interrupt handlers as well as in normal code. | |
28410 | ||
d77de738 | 28411 | @opindex minrt |
ddf6fe37 | 28412 | @item -minrt |
d77de738 ML |
28413 | Enable the use of a minimum runtime environment - no static |
28414 | initializers or constructors. This is intended for memory-constrained | |
28415 | devices. The compiler includes special symbols in some objects | |
28416 | that tell the linker and runtime which code fragments are required. | |
28417 | ||
d77de738 | 28418 | @opindex mtiny-printf |
ddf6fe37 | 28419 | @item -mtiny-printf |
d77de738 ML |
28420 | Enable reduced code size @code{printf} and @code{puts} library functions. |
28421 | The @samp{tiny} implementations of these functions are not reentrant, so | |
28422 | must be used with caution in multi-threaded applications. | |
28423 | ||
28424 | Support for streams has been removed and the string to be printed will | |
28425 | always be sent to stdout via the @code{write} syscall. The string is not | |
28426 | buffered before it is sent to write. | |
28427 | ||
28428 | This option requires Newlib Nano IO, so GCC must be configured with | |
28429 | @samp{--enable-newlib-nano-formatted-io}. | |
28430 | ||
d77de738 | 28431 | @opindex mmax-inline-shift= |
ddf6fe37 | 28432 | @item -mmax-inline-shift= |
d77de738 ML |
28433 | This option takes an integer between 0 and 64 inclusive, and sets |
28434 | the maximum number of inline shift instructions which should be emitted to | |
28435 | perform a shift operation by a constant amount. When this value needs to be | |
28436 | exceeded, an mspabi helper function is used instead. The default value is 4. | |
28437 | ||
28438 | This only affects cases where a shift by multiple positions cannot be | |
28439 | completed with a single instruction (e.g. all shifts >1 on the 430 ISA). | |
28440 | ||
28441 | Shifts of a 32-bit value are at least twice as costly, so the value passed for | |
28442 | this option is divided by 2 and the resulting value used instead. | |
28443 | ||
d77de738 ML |
28444 | @opindex mcode-region |
28445 | @opindex mdata-region | |
ddf6fe37 AA |
28446 | @item -mcode-region= |
28447 | @itemx -mdata-region= | |
d77de738 ML |
28448 | These options tell the compiler where to place functions and data that |
28449 | do not have one of the @code{lower}, @code{upper}, @code{either} or | |
28450 | @code{section} attributes. Possible values are @code{lower}, | |
28451 | @code{upper}, @code{either} or @code{any}. The first three behave | |
28452 | like the corresponding attribute. The fourth possible value - | |
28453 | @code{any} - is the default. It leaves placement entirely up to the | |
28454 | linker script and how it assigns the standard sections | |
28455 | (@code{.text}, @code{.data}, etc) to the memory regions. | |
28456 | ||
d77de738 | 28457 | @opindex msilicon-errata |
ddf6fe37 | 28458 | @item -msilicon-errata= |
d77de738 ML |
28459 | This option passes on a request to assembler to enable the fixes for |
28460 | the named silicon errata. | |
28461 | ||
d77de738 | 28462 | @opindex msilicon-errata-warn |
ddf6fe37 | 28463 | @item -msilicon-errata-warn= |
d77de738 ML |
28464 | This option passes on a request to the assembler to enable warning |
28465 | messages when a silicon errata might need to be applied. | |
28466 | ||
d77de738 ML |
28467 | @opindex mwarn-devices-csv |
28468 | @opindex mno-warn-devices-csv | |
ddf6fe37 AA |
28469 | @item -mwarn-devices-csv |
28470 | @itemx -mno-warn-devices-csv | |
d77de738 ML |
28471 | Warn if @samp{devices.csv} is not found or there are problem parsing it |
28472 | (default: on). | |
28473 | ||
28474 | @end table | |
28475 | ||
28476 | @node NDS32 Options | |
28477 | @subsection NDS32 Options | |
28478 | @cindex NDS32 Options | |
28479 | ||
28480 | These options are defined for NDS32 implementations: | |
28481 | ||
28482 | @table @gcctabopt | |
28483 | ||
d77de738 | 28484 | @opindex mbig-endian |
ddf6fe37 | 28485 | @item -mbig-endian |
d77de738 ML |
28486 | Generate code in big-endian mode. |
28487 | ||
d77de738 | 28488 | @opindex mlittle-endian |
ddf6fe37 | 28489 | @item -mlittle-endian |
d77de738 ML |
28490 | Generate code in little-endian mode. |
28491 | ||
d77de738 | 28492 | @opindex mreduced-regs |
ddf6fe37 | 28493 | @item -mreduced-regs |
d77de738 ML |
28494 | Use reduced-set registers for register allocation. |
28495 | ||
d77de738 | 28496 | @opindex mfull-regs |
ddf6fe37 | 28497 | @item -mfull-regs |
d77de738 ML |
28498 | Use full-set registers for register allocation. |
28499 | ||
d77de738 | 28500 | @opindex mcmov |
ddf6fe37 | 28501 | @item -mcmov |
d77de738 ML |
28502 | Generate conditional move instructions. |
28503 | ||
d77de738 | 28504 | @opindex mno-cmov |
ddf6fe37 | 28505 | @item -mno-cmov |
d77de738 ML |
28506 | Do not generate conditional move instructions. |
28507 | ||
d77de738 | 28508 | @opindex mext-perf |
ddf6fe37 | 28509 | @item -mext-perf |
d77de738 ML |
28510 | Generate performance extension instructions. |
28511 | ||
d77de738 | 28512 | @opindex mno-ext-perf |
ddf6fe37 | 28513 | @item -mno-ext-perf |
d77de738 ML |
28514 | Do not generate performance extension instructions. |
28515 | ||
d77de738 | 28516 | @opindex mext-perf2 |
ddf6fe37 | 28517 | @item -mext-perf2 |
d77de738 ML |
28518 | Generate performance extension 2 instructions. |
28519 | ||
d77de738 | 28520 | @opindex mno-ext-perf2 |
ddf6fe37 | 28521 | @item -mno-ext-perf2 |
d77de738 ML |
28522 | Do not generate performance extension 2 instructions. |
28523 | ||
d77de738 | 28524 | @opindex mext-string |
ddf6fe37 | 28525 | @item -mext-string |
d77de738 ML |
28526 | Generate string extension instructions. |
28527 | ||
d77de738 | 28528 | @opindex mno-ext-string |
ddf6fe37 | 28529 | @item -mno-ext-string |
d77de738 ML |
28530 | Do not generate string extension instructions. |
28531 | ||
d77de738 | 28532 | @opindex mv3push |
ddf6fe37 | 28533 | @item -mv3push |
d77de738 ML |
28534 | Generate v3 push25/pop25 instructions. |
28535 | ||
d77de738 | 28536 | @opindex mno-v3push |
ddf6fe37 | 28537 | @item -mno-v3push |
d77de738 ML |
28538 | Do not generate v3 push25/pop25 instructions. |
28539 | ||
d77de738 | 28540 | @opindex m16-bit |
ddf6fe37 | 28541 | @item -m16-bit |
d77de738 ML |
28542 | Generate 16-bit instructions. |
28543 | ||
d77de738 | 28544 | @opindex mno-16-bit |
ddf6fe37 | 28545 | @item -mno-16-bit |
d77de738 ML |
28546 | Do not generate 16-bit instructions. |
28547 | ||
d77de738 | 28548 | @opindex misr-vector-size |
ddf6fe37 | 28549 | @item -misr-vector-size=@var{num} |
d77de738 ML |
28550 | Specify the size of each interrupt vector, which must be 4 or 16. |
28551 | ||
d77de738 | 28552 | @opindex mcache-block-size |
ddf6fe37 | 28553 | @item -mcache-block-size=@var{num} |
d77de738 ML |
28554 | Specify the size of each cache block, |
28555 | which must be a power of 2 between 4 and 512. | |
28556 | ||
d77de738 | 28557 | @opindex march |
ddf6fe37 | 28558 | @item -march=@var{arch} |
d77de738 ML |
28559 | Specify the name of the target architecture. |
28560 | ||
d77de738 | 28561 | @opindex mcmodel |
ddf6fe37 | 28562 | @item -mcmodel=@var{code-model} |
d77de738 ML |
28563 | Set the code model to one of |
28564 | @table @asis | |
28565 | @item @samp{small} | |
28566 | All the data and read-only data segments must be within 512KB addressing space. | |
28567 | The text segment must be within 16MB addressing space. | |
28568 | @item @samp{medium} | |
28569 | The data segment must be within 512KB while the read-only data segment can be | |
28570 | within 4GB addressing space. The text segment should be still within 16MB | |
28571 | addressing space. | |
28572 | @item @samp{large} | |
28573 | All the text and data segments can be within 4GB addressing space. | |
28574 | @end table | |
28575 | ||
d77de738 | 28576 | @opindex mctor-dtor |
ddf6fe37 | 28577 | @item -mctor-dtor |
d77de738 ML |
28578 | Enable constructor/destructor feature. |
28579 | ||
d77de738 | 28580 | @opindex mrelax |
ddf6fe37 | 28581 | @item -mrelax |
d77de738 ML |
28582 | Guide linker to relax instructions. |
28583 | ||
28584 | @end table | |
28585 | ||
28586 | @node Nios II Options | |
28587 | @subsection Nios II Options | |
28588 | @cindex Nios II options | |
28589 | @cindex Altera Nios II options | |
28590 | ||
28591 | These are the options defined for the Altera Nios II processor. | |
28592 | ||
28593 | @table @gcctabopt | |
28594 | ||
d77de738 ML |
28595 | @opindex G |
28596 | @cindex smaller data references | |
f33d7a88 | 28597 | @item -G @var{num} |
d77de738 ML |
28598 | Put global and static objects less than or equal to @var{num} bytes |
28599 | into the small data or BSS sections instead of the normal data or BSS | |
28600 | sections. The default value of @var{num} is 8. | |
28601 | ||
ddf6fe37 AA |
28602 | @opindex mgpopt |
28603 | @opindex mno-gpopt | |
d77de738 ML |
28604 | @item -mgpopt=@var{option} |
28605 | @itemx -mgpopt | |
28606 | @itemx -mno-gpopt | |
d77de738 ML |
28607 | Generate (do not generate) GP-relative accesses. The following |
28608 | @var{option} names are recognized: | |
28609 | ||
28610 | @table @samp | |
28611 | ||
28612 | @item none | |
28613 | Do not generate GP-relative accesses. | |
28614 | ||
28615 | @item local | |
28616 | Generate GP-relative accesses for small data objects that are not | |
28617 | external, weak, or uninitialized common symbols. | |
28618 | Also use GP-relative addressing for objects that | |
28619 | have been explicitly placed in a small data section via a @code{section} | |
28620 | attribute. | |
28621 | ||
28622 | @item global | |
28623 | As for @samp{local}, but also generate GP-relative accesses for | |
28624 | small data objects that are external, weak, or common. If you use this option, | |
28625 | you must ensure that all parts of your program (including libraries) are | |
28626 | compiled with the same @option{-G} setting. | |
28627 | ||
28628 | @item data | |
28629 | Generate GP-relative accesses for all data objects in the program. If you | |
28630 | use this option, the entire data and BSS segments | |
28631 | of your program must fit in 64K of memory and you must use an appropriate | |
28632 | linker script to allocate them within the addressable range of the | |
28633 | global pointer. | |
28634 | ||
28635 | @item all | |
28636 | Generate GP-relative addresses for function pointers as well as data | |
28637 | pointers. If you use this option, the entire text, data, and BSS segments | |
28638 | of your program must fit in 64K of memory and you must use an appropriate | |
28639 | linker script to allocate them within the addressable range of the | |
28640 | global pointer. | |
28641 | ||
28642 | @end table | |
28643 | ||
28644 | @option{-mgpopt} is equivalent to @option{-mgpopt=local}, and | |
28645 | @option{-mno-gpopt} is equivalent to @option{-mgpopt=none}. | |
28646 | ||
28647 | The default is @option{-mgpopt} except when @option{-fpic} or | |
28648 | @option{-fPIC} is specified to generate position-independent code. | |
28649 | Note that the Nios II ABI does not permit GP-relative accesses from | |
28650 | shared libraries. | |
28651 | ||
28652 | You may need to specify @option{-mno-gpopt} explicitly when building | |
28653 | programs that include large amounts of small data, including large | |
28654 | GOT data sections. In this case, the 16-bit offset for GP-relative | |
28655 | addressing may not be large enough to allow access to the entire | |
28656 | small data section. | |
28657 | ||
d77de738 | 28658 | @opindex mgprel-sec |
ddf6fe37 | 28659 | @item -mgprel-sec=@var{regexp} |
d77de738 ML |
28660 | This option specifies additional section names that can be accessed via |
28661 | GP-relative addressing. It is most useful in conjunction with | |
28662 | @code{section} attributes on variable declarations | |
28663 | (@pxref{Common Variable Attributes}) and a custom linker script. | |
28664 | The @var{regexp} is a POSIX Extended Regular Expression. | |
28665 | ||
28666 | This option does not affect the behavior of the @option{-G} option, and | |
28667 | the specified sections are in addition to the standard @code{.sdata} | |
28668 | and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}. | |
28669 | ||
d77de738 | 28670 | @opindex mr0rel-sec |
ddf6fe37 | 28671 | @item -mr0rel-sec=@var{regexp} |
d77de738 ML |
28672 | This option specifies names of sections that can be accessed via a |
28673 | 16-bit offset from @code{r0}; that is, in the low 32K or high 32K | |
28674 | of the 32-bit address space. It is most useful in conjunction with | |
28675 | @code{section} attributes on variable declarations | |
28676 | (@pxref{Common Variable Attributes}) and a custom linker script. | |
28677 | The @var{regexp} is a POSIX Extended Regular Expression. | |
28678 | ||
28679 | In contrast to the use of GP-relative addressing for small data, | |
28680 | zero-based addressing is never generated by default and there are no | |
28681 | conventional section names used in standard linker scripts for sections | |
28682 | in the low or high areas of memory. | |
28683 | ||
d77de738 ML |
28684 | @opindex mel |
28685 | @opindex meb | |
ddf6fe37 AA |
28686 | @item -mel |
28687 | @itemx -meb | |
d77de738 ML |
28688 | Generate little-endian (default) or big-endian (experimental) code, |
28689 | respectively. | |
28690 | ||
d77de738 | 28691 | @opindex march |
ddf6fe37 | 28692 | @item -march=@var{arch} |
d77de738 ML |
28693 | This specifies the name of the target Nios II architecture. GCC uses this |
28694 | name to determine what kind of instructions it can emit when generating | |
28695 | assembly code. Permissible names are: @samp{r1}, @samp{r2}. | |
28696 | ||
28697 | The preprocessor macro @code{__nios2_arch__} is available to programs, | |
28698 | with value 1 or 2, indicating the targeted ISA level. | |
28699 | ||
d77de738 ML |
28700 | @opindex mno-bypass-cache |
28701 | @opindex mbypass-cache | |
ddf6fe37 AA |
28702 | @item -mbypass-cache |
28703 | @itemx -mno-bypass-cache | |
d77de738 ML |
28704 | Force all load and store instructions to always bypass cache by |
28705 | using I/O variants of the instructions. The default is not to | |
28706 | bypass the cache. | |
28707 | ||
d77de738 ML |
28708 | @opindex mcache-volatile |
28709 | @opindex mno-cache-volatile | |
ddf6fe37 AA |
28710 | @item -mno-cache-volatile |
28711 | @itemx -mcache-volatile | |
d77de738 ML |
28712 | Volatile memory access bypass the cache using the I/O variants of |
28713 | the load and store instructions. The default is not to bypass the cache. | |
28714 | ||
d77de738 ML |
28715 | @opindex mno-fast-sw-div |
28716 | @opindex mfast-sw-div | |
ddf6fe37 AA |
28717 | @item -mno-fast-sw-div |
28718 | @itemx -mfast-sw-div | |
d77de738 ML |
28719 | Do not use table-based fast divide for small numbers. The default |
28720 | is to use the fast divide at @option{-O3} and above. | |
28721 | ||
d77de738 ML |
28722 | @opindex mno-hw-mul |
28723 | @opindex mhw-mul | |
28724 | @opindex mno-hw-mulx | |
28725 | @opindex mhw-mulx | |
28726 | @opindex mno-hw-div | |
28727 | @opindex mhw-div | |
ddf6fe37 AA |
28728 | @item -mno-hw-mul |
28729 | @itemx -mhw-mul | |
28730 | @itemx -mno-hw-mulx | |
28731 | @itemx -mhw-mulx | |
28732 | @itemx -mno-hw-div | |
28733 | @itemx -mhw-div | |
d77de738 ML |
28734 | Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of |
28735 | instructions by the compiler. The default is to emit @code{mul} | |
28736 | and not emit @code{div} and @code{mulx}. | |
28737 | ||
28738 | @item -mbmx | |
28739 | @itemx -mno-bmx | |
28740 | @itemx -mcdx | |
28741 | @itemx -mno-cdx | |
28742 | Enable or disable generation of Nios II R2 BMX (bit manipulation) and | |
28743 | CDX (code density) instructions. Enabling these instructions also | |
28744 | requires @option{-march=r2}. Since these instructions are optional | |
28745 | extensions to the R2 architecture, the default is not to emit them. | |
28746 | ||
d77de738 ML |
28747 | @opindex mcustom-@var{insn} |
28748 | @opindex mno-custom-@var{insn} | |
ddf6fe37 AA |
28749 | @item -mcustom-@var{insn}=@var{N} |
28750 | @itemx -mno-custom-@var{insn} | |
d77de738 ML |
28751 | Each @option{-mcustom-@var{insn}=@var{N}} option enables use of a |
28752 | custom instruction with encoding @var{N} when generating code that uses | |
28753 | @var{insn}. For example, @option{-mcustom-fadds=253} generates custom | |
28754 | instruction 253 for single-precision floating-point add operations instead | |
28755 | of the default behavior of using a library call. | |
28756 | ||
28757 | The following values of @var{insn} are supported. Except as otherwise | |
28758 | noted, floating-point operations are expected to be implemented with | |
28759 | normal IEEE 754 semantics and correspond directly to the C operators or the | |
28760 | equivalent GCC built-in functions (@pxref{Other Builtins}). | |
28761 | ||
28762 | Single-precision floating point: | |
28763 | @table @asis | |
28764 | ||
28765 | @item @samp{fadds}, @samp{fsubs}, @samp{fdivs}, @samp{fmuls} | |
28766 | Binary arithmetic operations. | |
28767 | ||
28768 | @item @samp{fnegs} | |
28769 | Unary negation. | |
28770 | ||
28771 | @item @samp{fabss} | |
28772 | Unary absolute value. | |
28773 | ||
28774 | @item @samp{fcmpeqs}, @samp{fcmpges}, @samp{fcmpgts}, @samp{fcmples}, @samp{fcmplts}, @samp{fcmpnes} | |
28775 | Comparison operations. | |
28776 | ||
28777 | @item @samp{fmins}, @samp{fmaxs} | |
28778 | Floating-point minimum and maximum. These instructions are only | |
28779 | generated if @option{-ffinite-math-only} is specified. | |
28780 | ||
28781 | @item @samp{fsqrts} | |
28782 | Unary square root operation. | |
28783 | ||
28784 | @item @samp{fcoss}, @samp{fsins}, @samp{ftans}, @samp{fatans}, @samp{fexps}, @samp{flogs} | |
28785 | Floating-point trigonometric and exponential functions. These instructions | |
28786 | are only generated if @option{-funsafe-math-optimizations} is also specified. | |
28787 | ||
28788 | @end table | |
28789 | ||
28790 | Double-precision floating point: | |
28791 | @table @asis | |
28792 | ||
28793 | @item @samp{faddd}, @samp{fsubd}, @samp{fdivd}, @samp{fmuld} | |
28794 | Binary arithmetic operations. | |
28795 | ||
28796 | @item @samp{fnegd} | |
28797 | Unary negation. | |
28798 | ||
28799 | @item @samp{fabsd} | |
28800 | Unary absolute value. | |
28801 | ||
28802 | @item @samp{fcmpeqd}, @samp{fcmpged}, @samp{fcmpgtd}, @samp{fcmpled}, @samp{fcmpltd}, @samp{fcmpned} | |
28803 | Comparison operations. | |
28804 | ||
28805 | @item @samp{fmind}, @samp{fmaxd} | |
28806 | Double-precision minimum and maximum. These instructions are only | |
28807 | generated if @option{-ffinite-math-only} is specified. | |
28808 | ||
28809 | @item @samp{fsqrtd} | |
28810 | Unary square root operation. | |
28811 | ||
28812 | @item @samp{fcosd}, @samp{fsind}, @samp{ftand}, @samp{fatand}, @samp{fexpd}, @samp{flogd} | |
28813 | Double-precision trigonometric and exponential functions. These instructions | |
28814 | are only generated if @option{-funsafe-math-optimizations} is also specified. | |
28815 | ||
28816 | @end table | |
28817 | ||
28818 | Conversions: | |
28819 | @table @asis | |
28820 | @item @samp{fextsd} | |
28821 | Conversion from single precision to double precision. | |
28822 | ||
28823 | @item @samp{ftruncds} | |
28824 | Conversion from double precision to single precision. | |
28825 | ||
28826 | @item @samp{fixsi}, @samp{fixsu}, @samp{fixdi}, @samp{fixdu} | |
28827 | Conversion from floating point to signed or unsigned integer types, with | |
28828 | truncation towards zero. | |
28829 | ||
28830 | @item @samp{round} | |
28831 | Conversion from single-precision floating point to signed integer, | |
28832 | rounding to the nearest integer and ties away from zero. | |
28833 | This corresponds to the @code{__builtin_lroundf} function when | |
28834 | @option{-fno-math-errno} is used. | |
28835 | ||
28836 | @item @samp{floatis}, @samp{floatus}, @samp{floatid}, @samp{floatud} | |
28837 | Conversion from signed or unsigned integer types to floating-point types. | |
28838 | ||
28839 | @end table | |
28840 | ||
28841 | In addition, all of the following transfer instructions for internal | |
28842 | registers X and Y must be provided to use any of the double-precision | |
28843 | floating-point instructions. Custom instructions taking two | |
28844 | double-precision source operands expect the first operand in the | |
28845 | 64-bit register X. The other operand (or only operand of a unary | |
28846 | operation) is given to the custom arithmetic instruction with the | |
28847 | least significant half in source register @var{src1} and the most | |
28848 | significant half in @var{src2}. A custom instruction that returns a | |
28849 | double-precision result returns the most significant 32 bits in the | |
28850 | destination register and the other half in 32-bit register Y. | |
28851 | GCC automatically generates the necessary code sequences to write | |
28852 | register X and/or read register Y when double-precision floating-point | |
28853 | instructions are used. | |
28854 | ||
28855 | @table @asis | |
28856 | ||
28857 | @item @samp{fwrx} | |
28858 | Write @var{src1} into the least significant half of X and @var{src2} into | |
28859 | the most significant half of X. | |
28860 | ||
28861 | @item @samp{fwry} | |
28862 | Write @var{src1} into Y. | |
28863 | ||
28864 | @item @samp{frdxhi}, @samp{frdxlo} | |
28865 | Read the most or least (respectively) significant half of X and store it in | |
28866 | @var{dest}. | |
28867 | ||
28868 | @item @samp{frdy} | |
28869 | Read the value of Y and store it into @var{dest}. | |
28870 | @end table | |
28871 | ||
28872 | Note that you can gain more local control over generation of Nios II custom | |
28873 | instructions by using the @code{target("custom-@var{insn}=@var{N}")} | |
28874 | and @code{target("no-custom-@var{insn}")} function attributes | |
28875 | (@pxref{Function Attributes}) | |
28876 | or pragmas (@pxref{Function Specific Option Pragmas}). | |
28877 | ||
d77de738 | 28878 | @opindex mcustom-fpu-cfg |
ddf6fe37 | 28879 | @item -mcustom-fpu-cfg=@var{name} |
d77de738 ML |
28880 | |
28881 | This option enables a predefined, named set of custom instruction encodings | |
28882 | (see @option{-mcustom-@var{insn}} above). | |
28883 | Currently, the following sets are defined: | |
28884 | ||
28885 | @option{-mcustom-fpu-cfg=60-1} is equivalent to: | |
43b72ede AA |
28886 | @gccoptlist{-mcustom-fmuls=252 |
28887 | -mcustom-fadds=253 | |
28888 | -mcustom-fsubs=254 | |
d77de738 ML |
28889 | -fsingle-precision-constant} |
28890 | ||
28891 | @option{-mcustom-fpu-cfg=60-2} is equivalent to: | |
43b72ede AA |
28892 | @gccoptlist{-mcustom-fmuls=252 |
28893 | -mcustom-fadds=253 | |
28894 | -mcustom-fsubs=254 | |
28895 | -mcustom-fdivs=255 | |
d77de738 ML |
28896 | -fsingle-precision-constant} |
28897 | ||
28898 | @option{-mcustom-fpu-cfg=72-3} is equivalent to: | |
43b72ede AA |
28899 | @gccoptlist{-mcustom-floatus=243 |
28900 | -mcustom-fixsi=244 | |
28901 | -mcustom-floatis=245 | |
28902 | -mcustom-fcmpgts=246 | |
28903 | -mcustom-fcmples=249 | |
28904 | -mcustom-fcmpeqs=250 | |
28905 | -mcustom-fcmpnes=251 | |
28906 | -mcustom-fmuls=252 | |
28907 | -mcustom-fadds=253 | |
28908 | -mcustom-fsubs=254 | |
28909 | -mcustom-fdivs=255 | |
d77de738 ML |
28910 | -fsingle-precision-constant} |
28911 | ||
28912 | @option{-mcustom-fpu-cfg=fph2} is equivalent to: | |
43b72ede AA |
28913 | @gccoptlist{-mcustom-fabss=224 |
28914 | -mcustom-fnegs=225 | |
28915 | -mcustom-fcmpnes=226 | |
28916 | -mcustom-fcmpeqs=227 | |
28917 | -mcustom-fcmpges=228 | |
28918 | -mcustom-fcmpgts=229 | |
28919 | -mcustom-fcmples=230 | |
28920 | -mcustom-fcmplts=231 | |
28921 | -mcustom-fmaxs=232 | |
28922 | -mcustom-fmins=233 | |
28923 | -mcustom-round=248 | |
28924 | -mcustom-fixsi=249 | |
28925 | -mcustom-floatis=250 | |
28926 | -mcustom-fsqrts=251 | |
28927 | -mcustom-fmuls=252 | |
28928 | -mcustom-fadds=253 | |
28929 | -mcustom-fsubs=254 | |
28930 | -mcustom-fdivs=255} | |
d77de738 ML |
28931 | |
28932 | Custom instruction assignments given by individual | |
28933 | @option{-mcustom-@var{insn}=} options override those given by | |
28934 | @option{-mcustom-fpu-cfg=}, regardless of the | |
28935 | order of the options on the command line. | |
28936 | ||
28937 | Note that you can gain more local control over selection of a FPU | |
28938 | configuration by using the @code{target("custom-fpu-cfg=@var{name}")} | |
28939 | function attribute (@pxref{Function Attributes}) | |
28940 | or pragma (@pxref{Function Specific Option Pragmas}). | |
28941 | ||
28942 | The name @var{fph2} is an abbreviation for @emph{Nios II Floating Point | |
28943 | Hardware 2 Component}. Please note that the custom instructions enabled by | |
28944 | @option{-mcustom-fmins=233} and @option{-mcustom-fmaxs=234} are only generated | |
28945 | if @option{-ffinite-math-only} is specified. The custom instruction enabled by | |
28946 | @option{-mcustom-round=248} is only generated if @option{-fno-math-errno} is | |
28947 | specified. In contrast to the other configurations, | |
28948 | @option{-fsingle-precision-constant} is not set. | |
28949 | ||
28950 | @end table | |
28951 | ||
28952 | These additional @samp{-m} options are available for the Altera Nios II | |
28953 | ELF (bare-metal) target: | |
28954 | ||
28955 | @table @gcctabopt | |
28956 | ||
d77de738 | 28957 | @opindex mhal |
ddf6fe37 | 28958 | @item -mhal |
d77de738 ML |
28959 | Link with HAL BSP. This suppresses linking with the GCC-provided C runtime |
28960 | startup and termination code, and is typically used in conjunction with | |
28961 | @option{-msys-crt0=} to specify the location of the alternate startup code | |
28962 | provided by the HAL BSP. | |
28963 | ||
d77de738 | 28964 | @opindex msmallc |
ddf6fe37 | 28965 | @item -msmallc |
d77de738 ML |
28966 | Link with a limited version of the C library, @option{-lsmallc}, rather than |
28967 | Newlib. | |
28968 | ||
d77de738 | 28969 | @opindex msys-crt0 |
ddf6fe37 | 28970 | @item -msys-crt0=@var{startfile} |
d77de738 ML |
28971 | @var{startfile} is the file name of the startfile (crt0) to use |
28972 | when linking. This option is only useful in conjunction with @option{-mhal}. | |
28973 | ||
d77de738 | 28974 | @opindex msys-lib |
ddf6fe37 | 28975 | @item -msys-lib=@var{systemlib} |
d77de738 ML |
28976 | @var{systemlib} is the library name of the library that provides |
28977 | low-level system calls required by the C library, | |
28978 | e.g.@: @code{read} and @code{write}. | |
28979 | This option is typically used to link with a library provided by a HAL BSP. | |
28980 | ||
28981 | @end table | |
28982 | ||
28983 | @node Nvidia PTX Options | |
28984 | @subsection Nvidia PTX Options | |
28985 | @cindex Nvidia PTX options | |
28986 | @cindex nvptx options | |
28987 | ||
28988 | These options are defined for Nvidia PTX: | |
28989 | ||
28990 | @table @gcctabopt | |
28991 | ||
d77de738 | 28992 | @opindex m64 |
ddf6fe37 | 28993 | @item -m64 |
d77de738 ML |
28994 | Ignored, but preserved for backward compatibility. Only 64-bit ABI is |
28995 | supported. | |
28996 | ||
d77de738 | 28997 | @opindex march |
ddf6fe37 | 28998 | @item -march=@var{architecture-string} |
d77de738 ML |
28999 | Generate code for the specified PTX ISA target architecture |
29000 | (e.g.@: @samp{sm_35}). Valid architecture strings are @samp{sm_30}, | |
29001 | @samp{sm_35}, @samp{sm_53}, @samp{sm_70}, @samp{sm_75} and | |
29002 | @samp{sm_80}. | |
29003 | The default depends on how the compiler has been configured, see | |
29004 | @option{--with-arch}. | |
29005 | ||
29006 | This option sets the value of the preprocessor macro | |
29007 | @code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value | |
29008 | @samp{350}. | |
29009 | ||
d77de738 | 29010 | @opindex misa |
ddf6fe37 | 29011 | @item -misa=@var{architecture-string} |
d77de738 ML |
29012 | Alias of @option{-march=}. |
29013 | ||
d77de738 | 29014 | @opindex march |
ddf6fe37 | 29015 | @item -march-map=@var{architecture-string} |
d77de738 ML |
29016 | Select the closest available @option{-march=} value that is not more |
29017 | capable. For instance, for @option{-march-map=sm_50} select | |
29018 | @option{-march=sm_35}, and for @option{-march-map=sm_53} select | |
29019 | @option{-march=sm_53}. | |
29020 | ||
d77de738 | 29021 | @opindex mptx |
ddf6fe37 | 29022 | @item -mptx=@var{version-string} |
d77de738 ML |
29023 | Generate code for the specified PTX ISA version (e.g.@: @samp{7.0}). |
29024 | Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and | |
29025 | @samp{7.0}. The default PTX ISA version is 6.0, unless a higher | |
29026 | version is required for specified PTX ISA target architecture via | |
29027 | option @option{-march=}. | |
29028 | ||
29029 | This option sets the values of the preprocessor macros | |
29030 | @code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__}; | |
29031 | for instance, for @samp{3.1} the macros have the values @samp{3} and | |
29032 | @samp{1}, respectively. | |
29033 | ||
d77de738 | 29034 | @opindex mmainkernel |
ddf6fe37 | 29035 | @item -mmainkernel |
d77de738 ML |
29036 | Link in code for a __main kernel. This is for stand-alone instead of |
29037 | offloading execution. | |
29038 | ||
d77de738 | 29039 | @opindex moptimize |
ddf6fe37 | 29040 | @item -moptimize |
d77de738 ML |
29041 | Apply partitioned execution optimizations. This is the default when any |
29042 | level of optimization is selected. | |
29043 | ||
d77de738 | 29044 | @opindex msoft-stack |
ddf6fe37 | 29045 | @item -msoft-stack |
d77de738 ML |
29046 | Generate code that does not use @code{.local} memory |
29047 | directly for stack storage. Instead, a per-warp stack pointer is | |
29048 | maintained explicitly. This enables variable-length stack allocation (with | |
29049 | variable-length arrays or @code{alloca}), and when global memory is used for | |
29050 | underlying storage, makes it possible to access automatic variables from other | |
29051 | threads, or with atomic instructions. This code generation variant is used | |
29052 | for OpenMP offloading, but the option is exposed on its own for the purpose | |
29053 | of testing the compiler; to generate code suitable for linking into programs | |
29054 | using OpenMP offloading, use option @option{-mgomp}. | |
29055 | ||
d77de738 | 29056 | @opindex muniform-simt |
ddf6fe37 | 29057 | @item -muniform-simt |
d77de738 ML |
29058 | Switch to code generation variant that allows to execute all threads in each |
29059 | warp, while maintaining memory state and side effects as if only one thread | |
29060 | in each warp was active outside of OpenMP SIMD regions. All atomic operations | |
29061 | and calls to runtime (malloc, free, vprintf) are conditionally executed (iff | |
29062 | current lane index equals the master lane index), and the register being | |
29063 | assigned is copied via a shuffle instruction from the master lane. Outside of | |
29064 | SIMD regions lane 0 is the master; inside, each thread sees itself as the | |
29065 | master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or | |
29066 | all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD | |
29067 | regions). Each thread can bitwise-and the bitmask at position @code{tid.y} | |
29068 | with current lane index to compute the master lane index. | |
29069 | ||
d77de738 | 29070 | @opindex mgomp |
ddf6fe37 | 29071 | @item -mgomp |
d77de738 ML |
29072 | Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and |
29073 | @option{-muniform-simt} options, and selects corresponding multilib variant. | |
29074 | ||
29075 | @end table | |
29076 | ||
29077 | @node OpenRISC Options | |
29078 | @subsection OpenRISC Options | |
29079 | @cindex OpenRISC Options | |
29080 | ||
29081 | These options are defined for OpenRISC: | |
29082 | ||
29083 | @table @gcctabopt | |
29084 | ||
d77de738 | 29085 | @opindex mboard |
ddf6fe37 | 29086 | @item -mboard=@var{name} |
d77de738 ML |
29087 | Configure a board specific runtime. This will be passed to the linker for |
29088 | newlib board library linking. The default is @code{or1ksim}. | |
29089 | ||
d77de738 | 29090 | @opindex mnewlib |
ddf6fe37 | 29091 | @item -mnewlib |
d77de738 ML |
29092 | This option is ignored; it is for compatibility purposes only. This used to |
29093 | select linker and preprocessor options for use with newlib. | |
29094 | ||
d77de738 ML |
29095 | @opindex msoft-div |
29096 | @opindex mhard-div | |
ddf6fe37 AA |
29097 | @item -msoft-div |
29098 | @itemx -mhard-div | |
d77de738 ML |
29099 | Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions. |
29100 | This default is hardware divide. | |
29101 | ||
d77de738 ML |
29102 | @opindex msoft-mul |
29103 | @opindex mhard-mul | |
ddf6fe37 AA |
29104 | @item -msoft-mul |
29105 | @itemx -mhard-mul | |
d77de738 ML |
29106 | Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions. |
29107 | This default is hardware multiply. | |
29108 | ||
d77de738 ML |
29109 | @opindex msoft-float |
29110 | @opindex mhard-float | |
ddf6fe37 AA |
29111 | @item -msoft-float |
29112 | @itemx -mhard-float | |
d77de738 ML |
29113 | Select software or hardware for floating point operations. |
29114 | The default is software. | |
29115 | ||
d77de738 | 29116 | @opindex mdouble-float |
ddf6fe37 | 29117 | @item -mdouble-float |
d77de738 ML |
29118 | When @option{-mhard-float} is selected, enables generation of double-precision |
29119 | floating point instructions. By default functions from @file{libgcc} are used | |
29120 | to perform double-precision floating point operations. | |
29121 | ||
d77de738 | 29122 | @opindex munordered-float |
ddf6fe37 | 29123 | @item -munordered-float |
d77de738 ML |
29124 | When @option{-mhard-float} is selected, enables generation of unordered |
29125 | floating point compare and set flag (@code{lf.sfun*}) instructions. By default | |
29126 | functions from @file{libgcc} are used to perform unordered floating point | |
29127 | compare and set flag operations. | |
29128 | ||
d77de738 | 29129 | @opindex mcmov |
ddf6fe37 | 29130 | @item -mcmov |
d77de738 ML |
29131 | Enable generation of conditional move (@code{l.cmov}) instructions. By |
29132 | default the equivalent will be generated using set and branch. | |
29133 | ||
d77de738 | 29134 | @opindex mror |
ddf6fe37 | 29135 | @item -mror |
d77de738 ML |
29136 | Enable generation of rotate right (@code{l.ror}) instructions. By default |
29137 | functions from @file{libgcc} are used to perform rotate right operations. | |
29138 | ||
d77de738 | 29139 | @opindex mrori |
ddf6fe37 | 29140 | @item -mrori |
d77de738 ML |
29141 | Enable generation of rotate right with immediate (@code{l.rori}) instructions. |
29142 | By default functions from @file{libgcc} are used to perform rotate right with | |
29143 | immediate operations. | |
29144 | ||
d77de738 | 29145 | @opindex msext |
ddf6fe37 | 29146 | @item -msext |
d77de738 ML |
29147 | Enable generation of sign extension (@code{l.ext*}) instructions. By default |
29148 | memory loads are used to perform sign extension. | |
29149 | ||
d77de738 | 29150 | @opindex msfimm |
ddf6fe37 | 29151 | @item -msfimm |
d77de738 ML |
29152 | Enable generation of compare and set flag with immediate (@code{l.sf*i}) |
29153 | instructions. By default extra instructions will be generated to store the | |
29154 | immediate to a register first. | |
29155 | ||
d77de738 | 29156 | @opindex mshftimm |
ddf6fe37 | 29157 | @item -mshftimm |
d77de738 ML |
29158 | Enable generation of shift with immediate (@code{l.srai}, @code{l.srli}, |
29159 | @code{l.slli}) instructions. By default extra instructions will be generated | |
29160 | to store the immediate to a register first. | |
29161 | ||
d77de738 | 29162 | @opindex mcmodel=small |
ddf6fe37 | 29163 | @item -mcmodel=small |
d77de738 ML |
29164 | Generate OpenRISC code for the small model: The GOT is limited to 64k. This is |
29165 | the default model. | |
29166 | ||
d77de738 | 29167 | @opindex mcmodel=large |
ddf6fe37 | 29168 | @item -mcmodel=large |
d77de738 ML |
29169 | Generate OpenRISC code for the large model: The GOT may grow up to 4G in size. |
29170 | ||
29171 | ||
29172 | @end table | |
29173 | ||
29174 | @node PDP-11 Options | |
29175 | @subsection PDP-11 Options | |
29176 | @cindex PDP-11 Options | |
29177 | ||
29178 | These options are defined for the PDP-11: | |
29179 | ||
29180 | @table @gcctabopt | |
d77de738 | 29181 | @opindex mfpu |
ddf6fe37 | 29182 | @item -mfpu |
d77de738 ML |
29183 | Use hardware FPP floating point. This is the default. (FIS floating |
29184 | point on the PDP-11/40 is not supported.) Implies -m45. | |
29185 | ||
d77de738 | 29186 | @opindex msoft-float |
ddf6fe37 | 29187 | @item -msoft-float |
d77de738 ML |
29188 | Do not use hardware floating point. |
29189 | ||
d77de738 | 29190 | @opindex mac0 |
ddf6fe37 | 29191 | @item -mac0 |
d77de738 ML |
29192 | Return floating-point results in ac0 (fr0 in Unix assembler syntax). |
29193 | ||
d77de738 | 29194 | @opindex mno-ac0 |
ddf6fe37 | 29195 | @item -mno-ac0 |
d77de738 ML |
29196 | Return floating-point results in memory. This is the default. |
29197 | ||
d77de738 | 29198 | @opindex m40 |
ddf6fe37 | 29199 | @item -m40 |
d77de738 ML |
29200 | Generate code for a PDP-11/40. Implies -msoft-float -mno-split. |
29201 | ||
d77de738 | 29202 | @opindex m45 |
ddf6fe37 | 29203 | @item -m45 |
d77de738 ML |
29204 | Generate code for a PDP-11/45. This is the default. |
29205 | ||
d77de738 | 29206 | @opindex m10 |
ddf6fe37 | 29207 | @item -m10 |
d77de738 ML |
29208 | Generate code for a PDP-11/10. Implies -msoft-float -mno-split. |
29209 | ||
d77de738 ML |
29210 | @opindex mint16 |
29211 | @opindex mno-int32 | |
ddf6fe37 AA |
29212 | @item -mint16 |
29213 | @itemx -mno-int32 | |
d77de738 ML |
29214 | Use 16-bit @code{int}. This is the default. |
29215 | ||
d77de738 ML |
29216 | @opindex mint32 |
29217 | @opindex mno-int16 | |
ddf6fe37 AA |
29218 | @item -mint32 |
29219 | @itemx -mno-int16 | |
d77de738 ML |
29220 | Use 32-bit @code{int}. |
29221 | ||
d77de738 | 29222 | @opindex msplit |
ddf6fe37 | 29223 | @item -msplit |
d77de738 ML |
29224 | Target has split instruction and data space. Implies -m45. |
29225 | ||
d77de738 | 29226 | @opindex munix-asm |
ddf6fe37 | 29227 | @item -munix-asm |
d77de738 ML |
29228 | Use Unix assembler syntax. |
29229 | ||
d77de738 | 29230 | @opindex mdec-asm |
ddf6fe37 | 29231 | @item -mdec-asm |
d77de738 ML |
29232 | Use DEC assembler syntax. |
29233 | ||
d77de738 | 29234 | @opindex mgnu-asm |
ddf6fe37 | 29235 | @item -mgnu-asm |
d77de738 ML |
29236 | Use GNU assembler syntax. This is the default. |
29237 | ||
d77de738 | 29238 | @opindex mlra |
ddf6fe37 | 29239 | @item -mlra |
d77de738 ML |
29240 | Use the new LRA register allocator. By default, the old ``reload'' |
29241 | allocator is used. | |
29242 | @end table | |
29243 | ||
d77de738 ML |
29244 | @node PowerPC Options |
29245 | @subsection PowerPC Options | |
29246 | @cindex PowerPC options | |
29247 | ||
29248 | These are listed under @xref{RS/6000 and PowerPC Options}. | |
29249 | ||
29250 | @node PRU Options | |
29251 | @subsection PRU Options | |
29252 | @cindex PRU Options | |
29253 | ||
29254 | These command-line options are defined for PRU target: | |
29255 | ||
29256 | @table @gcctabopt | |
d77de738 | 29257 | @opindex minrt |
ddf6fe37 | 29258 | @item -minrt |
d77de738 ML |
29259 | Link with a minimum runtime environment, with no support for static |
29260 | initializers and constructors. Using this option can significantly reduce | |
29261 | the size of the final ELF binary. Beware that the compiler could still | |
29262 | generate code with static initializers and constructors. It is up to the | |
29263 | programmer to ensure that the source program will not use those features. | |
29264 | ||
d77de738 | 29265 | @opindex mmcu |
ddf6fe37 | 29266 | @item -mmcu=@var{mcu} |
d77de738 ML |
29267 | Specify the PRU MCU variant to use. Check Newlib for the exact list of |
29268 | supported MCUs. | |
29269 | ||
d77de738 | 29270 | @opindex mno-relax |
ddf6fe37 | 29271 | @item -mno-relax |
d77de738 ML |
29272 | Make GCC pass the @option{--no-relax} command-line option to the linker |
29273 | instead of the @option{--relax} option. | |
29274 | ||
d77de738 | 29275 | @opindex mloop |
ddf6fe37 | 29276 | @item -mloop |
d77de738 ML |
29277 | Allow (or do not allow) GCC to use the LOOP instruction. |
29278 | ||
d77de738 | 29279 | @opindex mabi |
ddf6fe37 | 29280 | @item -mabi=@var{variant} |
d77de738 ML |
29281 | Specify the ABI variant to output code for. @option{-mabi=ti} selects the |
29282 | unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes | |
29283 | more naturally with certain GCC assumptions. These are the differences: | |
29284 | ||
29285 | @table @samp | |
29286 | @item Function Pointer Size | |
29287 | TI ABI specifies that function (code) pointers are 16-bit, whereas GNU | |
29288 | supports only 32-bit data and code pointers. | |
29289 | ||
29290 | @item Optional Return Value Pointer | |
29291 | Function return values larger than 64 bits are passed by using a hidden | |
29292 | pointer as the first argument of the function. TI ABI, though, mandates that | |
29293 | the pointer can be NULL in case the caller is not using the returned value. | |
29294 | GNU always passes and expects a valid return value pointer. | |
29295 | ||
29296 | @end table | |
29297 | ||
29298 | The current @option{-mabi=ti} implementation simply raises a compile error | |
29299 | when any of the above code constructs is detected. As a consequence | |
29300 | the standard C library cannot be built and it is omitted when linking with | |
29301 | @option{-mabi=ti}. | |
29302 | ||
29303 | Relaxation is a GNU feature and for safety reasons is disabled when using | |
29304 | @option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx | |
29305 | instructions, so the GNU linker cannot adjust them when shortening adjacent | |
29306 | LDI32 pseudo instructions. | |
29307 | ||
29308 | @end table | |
29309 | ||
29310 | @node RISC-V Options | |
29311 | @subsection RISC-V Options | |
29312 | @cindex RISC-V Options | |
29313 | ||
29314 | These command-line options are defined for RISC-V targets: | |
29315 | ||
29316 | @table @gcctabopt | |
d77de738 | 29317 | @opindex mbranch-cost |
ddf6fe37 | 29318 | @item -mbranch-cost=@var{n} |
d77de738 ML |
29319 | Set the cost of branches to roughly @var{n} instructions. |
29320 | ||
ddf6fe37 | 29321 | @opindex plt |
d77de738 ML |
29322 | @item -mplt |
29323 | @itemx -mno-plt | |
d77de738 ML |
29324 | When generating PIC code, do or don't allow the use of PLTs. Ignored for |
29325 | non-PIC. The default is @option{-mplt}. | |
29326 | ||
d77de738 | 29327 | @opindex mabi |
ddf6fe37 | 29328 | @item -mabi=@var{ABI-string} |
d77de738 ML |
29329 | Specify integer and floating-point calling convention. @var{ABI-string} |
29330 | contains two parts: the size of integer types and the registers used for | |
29331 | floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that | |
29332 | @samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be | |
29333 | 32-bit), and that floating-point values up to 64 bits wide are passed in F | |
29334 | registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still | |
29335 | allows the compiler to generate code that uses the F and D extensions but only | |
29336 | allows floating-point values up to 32 bits long to be passed in registers; or | |
29337 | @samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be | |
29338 | passed in registers. | |
29339 | ||
29340 | The default for this argument is system dependent, users who want a specific | |
29341 | calling convention should specify one explicitly. The valid calling | |
29342 | conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64}, | |
29343 | @samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to | |
29344 | implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is | |
29345 | invalid because the ABI requires 64-bit values be passed in F registers, but F | |
29346 | registers are only 32 bits wide. There is also the @samp{ilp32e} ABI that can | |
29347 | only be used with the @samp{rv32e} architecture. This ABI is not well | |
29348 | specified at present, and is subject to change. | |
29349 | ||
ddf6fe37 | 29350 | @opindex mfdiv |
d77de738 ML |
29351 | @item -mfdiv |
29352 | @itemx -mno-fdiv | |
d77de738 ML |
29353 | Do or don't use hardware floating-point divide and square root instructions. |
29354 | This requires the F or D extensions for floating-point registers. The default | |
29355 | is to use them if the specified architecture has these instructions. | |
29356 | ||
ddf6fe37 | 29357 | @opindex mdiv |
d77de738 ML |
29358 | @item -mdiv |
29359 | @itemx -mno-div | |
d77de738 ML |
29360 | Do or don't use hardware instructions for integer division. This requires the |
29361 | M extension. The default is to use them if the specified architecture has | |
29362 | these instructions. | |
29363 | ||
d77de738 | 29364 | @opindex misa-spec |
ddf6fe37 | 29365 | @item -misa-spec=@var{ISA-spec-string} |
d77de738 ML |
29366 | Specify the version of the RISC-V Unprivileged (formerly User-Level) |
29367 | ISA specification to produce code conforming to. The possibilities | |
29368 | for @var{ISA-spec-string} are: | |
29369 | @table @code | |
29370 | @item 2.2 | |
29371 | Produce code conforming to version 2.2. | |
29372 | @item 20190608 | |
29373 | Produce code conforming to version 20190608. | |
29374 | @item 20191213 | |
29375 | Produce code conforming to version 20191213. | |
29376 | @end table | |
29377 | The default is @option{-misa-spec=20191213} unless GCC has been configured | |
29378 | with @option{--with-isa-spec=} specifying a different default version. | |
29379 | ||
d77de738 | 29380 | @opindex march |
ddf6fe37 | 29381 | @item -march=@var{ISA-string} |
d77de738 ML |
29382 | Generate code for given RISC-V ISA (e.g.@: @samp{rv64im}). ISA strings must be |
29383 | lower-case. Examples include @samp{rv64i}, @samp{rv32g}, @samp{rv32e}, and | |
29384 | @samp{rv32imaf}. | |
29385 | ||
29386 | When @option{-march=} is not specified, use the setting from @option{-mcpu}. | |
29387 | ||
29388 | If both @option{-march} and @option{-mcpu=} are not specified, the default for | |
29389 | this argument is system dependent, users who want a specific architecture | |
29390 | extensions should specify one explicitly. | |
29391 | ||
d77de738 | 29392 | @opindex mcpu |
ddf6fe37 | 29393 | @item -mcpu=@var{processor-string} |
d77de738 ML |
29394 | Use architecture of and optimize the output for the given processor, specified |
29395 | by particular CPU name. | |
29396 | Permissible values for this option are: @samp{sifive-e20}, @samp{sifive-e21}, | |
29397 | @samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34}, @samp{sifive-e76}, | |
29398 | @samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54}, @samp{sifive-s76}, | |
aa37a91c | 29399 | @samp{sifive-u54}, and @samp{sifive-u74}. |
d77de738 | 29400 | |
d77de738 | 29401 | @opindex mtune |
ddf6fe37 | 29402 | @item -mtune=@var{processor-string} |
d77de738 ML |
29403 | Optimize the output for the given processor, specified by microarchitecture or |
29404 | particular CPU name. Permissible values for this option are: @samp{rocket}, | |
29405 | @samp{sifive-3-series}, @samp{sifive-5-series}, @samp{sifive-7-series}, | |
aa37a91c | 29406 | @samp{thead-c906}, @samp{size}, and all valid options for @option{-mcpu=}. |
d77de738 ML |
29407 | |
29408 | When @option{-mtune=} is not specified, use the setting from @option{-mcpu}, | |
29409 | the default is @samp{rocket} if both are not specified. | |
29410 | ||
29411 | The @samp{size} choice is not intended for use by end-users. This is used | |
29412 | when @option{-Os} is specified. It overrides the instruction cost info | |
29413 | provided by @option{-mtune=}, but does not override the pipeline info. This | |
29414 | helps reduce code size while still giving good performance. | |
29415 | ||
d77de738 | 29416 | @opindex mpreferred-stack-boundary |
ddf6fe37 | 29417 | @item -mpreferred-stack-boundary=@var{num} |
d77de738 ML |
29418 | Attempt to keep the stack boundary aligned to a 2 raised to @var{num} |
29419 | byte boundary. If @option{-mpreferred-stack-boundary} is not specified, | |
29420 | the default is 4 (16 bytes or 128-bits). | |
29421 | ||
29422 | @strong{Warning:} If you use this switch, then you must build all modules with | |
29423 | the same value, including any libraries. This includes the system libraries | |
29424 | and startup modules. | |
29425 | ||
d77de738 | 29426 | @opindex msmall-data-limit |
ddf6fe37 | 29427 | @item -msmall-data-limit=@var{n} |
d77de738 ML |
29428 | Put global and static data smaller than @var{n} bytes into a special section |
29429 | (on some targets). | |
29430 | ||
ddf6fe37 | 29431 | @opindex msave-restore |
d77de738 ML |
29432 | @item -msave-restore |
29433 | @itemx -mno-save-restore | |
d77de738 ML |
29434 | Do or don't use smaller but slower prologue and epilogue code that uses |
29435 | library function calls. The default is to use fast inline prologues and | |
29436 | epilogues. | |
29437 | ||
f797260a PN |
29438 | @opindex minline-atomics |
29439 | @item -minline-atomics | |
29440 | @itemx -mno-inline-atomics | |
29441 | Do or don't use smaller but slower subword atomic emulation code that uses | |
29442 | libatomic function calls. The default is to use fast inline subword atomics | |
29443 | that do not require libatomic. | |
29444 | ||
df48285b CM |
29445 | @opindex minline-strlen |
29446 | @item -minline-strlen | |
29447 | @itemx -mno-inline-strlen | |
29448 | Do or do not attempt to inline strlen calls if possible. | |
29449 | Inlining will only be done if the string is properly aligned | |
29450 | and instructions for accelerated processing are available. | |
29451 | The default is to not inline strlen calls. | |
29452 | ||
949f1ccf CM |
29453 | @opindex minline-strcmp |
29454 | @item -minline-strcmp | |
29455 | @itemx -mno-inline-strcmp | |
29456 | Do or do not attempt to inline strcmp calls if possible. | |
29457 | Inlining will only be done if the strings are properly aligned | |
29458 | and instructions for accelerated processing are available. | |
29459 | The default is to not inline strcmp calls. | |
29460 | ||
29461 | @opindex minline-strncmp | |
29462 | @item -minline-strncmp | |
29463 | @itemx -mno-inline-strncmp | |
29464 | Do or do not attempt to inline strncmp calls if possible. | |
29465 | Inlining will only be done if the strings are properly aligned | |
29466 | and instructions for accelerated processing are available. | |
29467 | The default is to not inline strncmp calls. | |
29468 | ||
ddf6fe37 | 29469 | @opindex mshorten-memrefs |
d77de738 ML |
29470 | @item -mshorten-memrefs |
29471 | @itemx -mno-shorten-memrefs | |
d77de738 ML |
29472 | Do or do not attempt to make more use of compressed load/store instructions by |
29473 | replacing a load/store of 'base register + large offset' with a new load/store | |
29474 | of 'new base + small offset'. If the new base gets stored in a compressed | |
29475 | register, then the new load/store can be compressed. Currently targets 32-bit | |
29476 | integer load/stores only. | |
29477 | ||
ddf6fe37 | 29478 | @opindex mstrict-align |
d77de738 ML |
29479 | @item -mstrict-align |
29480 | @itemx -mno-strict-align | |
d77de738 ML |
29481 | Do not or do generate unaligned memory accesses. The default is set depending |
29482 | on whether the processor we are optimizing for supports fast unaligned access | |
29483 | or not. | |
29484 | ||
d77de738 | 29485 | @opindex mcmodel=medlow |
ddf6fe37 | 29486 | @item -mcmodel=medlow |
d77de738 ML |
29487 | Generate code for the medium-low code model. The program and its statically |
29488 | defined symbols must lie within a single 2 GiB address range and must lie | |
29489 | between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be | |
29490 | statically or dynamically linked. This is the default code model. | |
29491 | ||
d77de738 | 29492 | @opindex mcmodel=medany |
ddf6fe37 | 29493 | @item -mcmodel=medany |
d77de738 ML |
29494 | Generate code for the medium-any code model. The program and its statically |
29495 | defined symbols must be within any single 2 GiB address range. Programs can be | |
29496 | statically or dynamically linked. | |
29497 | ||
29498 | The code generated by the medium-any code model is position-independent, but is | |
29499 | not guaranteed to function correctly when linked into position-independent | |
29500 | executables or libraries. | |
29501 | ||
29502 | @item -mexplicit-relocs | |
29503 | @itemx -mno-exlicit-relocs | |
29504 | Use or do not use assembler relocation operators when dealing with symbolic | |
29505 | addresses. The alternative is to use assembler macros instead, which may | |
29506 | limit optimization. | |
29507 | ||
ddf6fe37 | 29508 | @opindex mrelax |
d77de738 ML |
29509 | @item -mrelax |
29510 | @itemx -mno-relax | |
d77de738 ML |
29511 | Take advantage of linker relaxations to reduce the number of instructions |
29512 | required to materialize symbol addresses. The default is to take advantage of | |
29513 | linker relaxations. | |
29514 | ||
ddf6fe37 | 29515 | @opindex mriscv-attribute |
d77de738 ML |
29516 | @item -mriscv-attribute |
29517 | @itemx -mno-riscv-attribute | |
d77de738 ML |
29518 | Emit (do not emit) RISC-V attribute to record extra information into ELF |
29519 | objects. This feature requires at least binutils 2.32. | |
29520 | ||
ddf6fe37 | 29521 | @opindex mcsr-check |
d77de738 ML |
29522 | @item -mcsr-check |
29523 | @itemx -mno-csr-check | |
d77de738 ML |
29524 | Enables or disables the CSR checking. |
29525 | ||
d77de738 | 29526 | @opindex malign-data |
ddf6fe37 | 29527 | @item -malign-data=@var{type} |
d77de738 ML |
29528 | Control how GCC aligns variables and constants of array, structure, or union |
29529 | types. Supported values for @var{type} are @samp{xlen} which uses x register | |
29530 | width as the alignment value, and @samp{natural} which uses natural alignment. | |
29531 | @samp{xlen} is the default. | |
29532 | ||
d77de738 | 29533 | @opindex mbig-endian |
ddf6fe37 | 29534 | @item -mbig-endian |
d77de738 ML |
29535 | Generate big-endian code. This is the default when GCC is configured for a |
29536 | @samp{riscv64be-*-*} or @samp{riscv32be-*-*} target. | |
29537 | ||
d77de738 | 29538 | @opindex mlittle-endian |
ddf6fe37 | 29539 | @item -mlittle-endian |
d77de738 ML |
29540 | Generate little-endian code. This is the default when GCC is configured for a |
29541 | @samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or | |
29542 | @samp{riscv32be-*-*} target. | |
29543 | ||
d77de738 ML |
29544 | @opindex mstack-protector-guard |
29545 | @opindex mstack-protector-guard-reg | |
29546 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
29547 | @item -mstack-protector-guard=@var{guard} |
29548 | @itemx -mstack-protector-guard-reg=@var{reg} | |
29549 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
29550 | Generate stack protection code using canary at @var{guard}. Supported |
29551 | locations are @samp{global} for a global canary or @samp{tls} for per-thread | |
29552 | canary in the TLS block. | |
29553 | ||
29554 | With the latter choice the options | |
29555 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
29556 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
29557 | which register to use as base register for reading the canary, | |
29558 | and from what offset from that base register. There is no default | |
29559 | register or offset as this is entirely for use within the Linux | |
29560 | kernel. | |
29561 | @end table | |
29562 | ||
29563 | @node RL78 Options | |
29564 | @subsection RL78 Options | |
29565 | @cindex RL78 Options | |
29566 | ||
29567 | @table @gcctabopt | |
29568 | ||
d77de738 | 29569 | @opindex msim |
ddf6fe37 | 29570 | @item -msim |
d77de738 ML |
29571 | Links in additional target libraries to support operation within a |
29572 | simulator. | |
29573 | ||
ddf6fe37 | 29574 | @opindex mmul |
d77de738 ML |
29575 | @item -mmul=none |
29576 | @itemx -mmul=g10 | |
29577 | @itemx -mmul=g13 | |
29578 | @itemx -mmul=g14 | |
29579 | @itemx -mmul=rl78 | |
d77de738 ML |
29580 | Specifies the type of hardware multiplication and division support to |
29581 | be used. The simplest is @code{none}, which uses software for both | |
29582 | multiplication and division. This is the default. The @code{g13} | |
29583 | value is for the hardware multiply/divide peripheral found on the | |
29584 | RL78/G13 (S2 core) targets. The @code{g14} value selects the use of | |
29585 | the multiplication and division instructions supported by the RL78/G14 | |
29586 | (S3 core) parts. The value @code{rl78} is an alias for @code{g14} and | |
29587 | the value @code{mg10} is an alias for @code{none}. | |
29588 | ||
29589 | In addition a C preprocessor macro is defined, based upon the setting | |
29590 | of this option. Possible values are: @code{__RL78_MUL_NONE__}, | |
29591 | @code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}. | |
29592 | ||
ddf6fe37 | 29593 | @opindex mcpu |
d77de738 ML |
29594 | @item -mcpu=g10 |
29595 | @itemx -mcpu=g13 | |
29596 | @itemx -mcpu=g14 | |
29597 | @itemx -mcpu=rl78 | |
d77de738 ML |
29598 | Specifies the RL78 core to target. The default is the G14 core, also |
29599 | known as an S3 core or just RL78. The G13 or S2 core does not have | |
29600 | multiply or divide instructions, instead it uses a hardware peripheral | |
29601 | for these operations. The G10 or S1 core does not have register | |
29602 | banks, so it uses a different calling convention. | |
29603 | ||
29604 | If this option is set it also selects the type of hardware multiply | |
29605 | support to use, unless this is overridden by an explicit | |
29606 | @option{-mmul=none} option on the command line. Thus specifying | |
29607 | @option{-mcpu=g13} enables the use of the G13 hardware multiply | |
29608 | peripheral and specifying @option{-mcpu=g10} disables the use of | |
29609 | hardware multiplications altogether. | |
29610 | ||
29611 | Note, although the RL78/G14 core is the default target, specifying | |
29612 | @option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does | |
29613 | change the behavior of the toolchain since it also enables G14 | |
29614 | hardware multiply support. If these options are not specified on the | |
29615 | command line then software multiplication routines will be used even | |
29616 | though the code targets the RL78 core. This is for backwards | |
29617 | compatibility with older toolchains which did not have hardware | |
29618 | multiply and divide support. | |
29619 | ||
29620 | In addition a C preprocessor macro is defined, based upon the setting | |
29621 | of this option. Possible values are: @code{__RL78_G10__}, | |
29622 | @code{__RL78_G13__} or @code{__RL78_G14__}. | |
29623 | ||
d77de738 ML |
29624 | @opindex mg10 |
29625 | @opindex mg13 | |
29626 | @opindex mg14 | |
29627 | @opindex mrl78 | |
ddf6fe37 AA |
29628 | @item -mg10 |
29629 | @itemx -mg13 | |
29630 | @itemx -mg14 | |
29631 | @itemx -mrl78 | |
d77de738 ML |
29632 | These are aliases for the corresponding @option{-mcpu=} option. They |
29633 | are provided for backwards compatibility. | |
29634 | ||
d77de738 | 29635 | @opindex mallregs |
ddf6fe37 | 29636 | @item -mallregs |
d77de738 ML |
29637 | Allow the compiler to use all of the available registers. By default |
29638 | registers @code{r24..r31} are reserved for use in interrupt handlers. | |
29639 | With this option enabled these registers can be used in ordinary | |
29640 | functions as well. | |
29641 | ||
d77de738 ML |
29642 | @opindex m64bit-doubles |
29643 | @opindex m32bit-doubles | |
ddf6fe37 AA |
29644 | @item -m64bit-doubles |
29645 | @itemx -m32bit-doubles | |
d77de738 ML |
29646 | Make the @code{double} data type be 64 bits (@option{-m64bit-doubles}) |
29647 | or 32 bits (@option{-m32bit-doubles}) in size. The default is | |
29648 | @option{-m32bit-doubles}. | |
29649 | ||
d77de738 ML |
29650 | @opindex msave-mduc-in-interrupts |
29651 | @opindex mno-save-mduc-in-interrupts | |
ddf6fe37 AA |
29652 | @item -msave-mduc-in-interrupts |
29653 | @itemx -mno-save-mduc-in-interrupts | |
d77de738 ML |
29654 | Specifies that interrupt handler functions should preserve the |
29655 | MDUC registers. This is only necessary if normal code might use | |
29656 | the MDUC registers, for example because it performs multiplication | |
29657 | and division operations. The default is to ignore the MDUC registers | |
29658 | as this makes the interrupt handlers faster. The target option -mg13 | |
29659 | needs to be passed for this to work as this feature is only available | |
29660 | on the G13 target (S2 core). The MDUC registers will only be saved | |
29661 | if the interrupt handler performs a multiplication or division | |
29662 | operation or it calls another function. | |
29663 | ||
29664 | @end table | |
29665 | ||
29666 | @node RS/6000 and PowerPC Options | |
29667 | @subsection IBM RS/6000 and PowerPC Options | |
29668 | @cindex RS/6000 and PowerPC Options | |
29669 | @cindex IBM RS/6000 and PowerPC Options | |
29670 | ||
29671 | These @samp{-m} options are defined for the IBM RS/6000 and PowerPC: | |
29672 | @table @gcctabopt | |
29673 | @item -mpowerpc-gpopt | |
29674 | @itemx -mno-powerpc-gpopt | |
29675 | @itemx -mpowerpc-gfxopt | |
29676 | @itemx -mno-powerpc-gfxopt | |
29677 | @need 800 | |
29678 | @itemx -mpowerpc64 | |
29679 | @itemx -mno-powerpc64 | |
29680 | @itemx -mmfcrf | |
29681 | @itemx -mno-mfcrf | |
29682 | @itemx -mpopcntb | |
29683 | @itemx -mno-popcntb | |
29684 | @itemx -mpopcntd | |
29685 | @itemx -mno-popcntd | |
29686 | @itemx -mfprnd | |
29687 | @itemx -mno-fprnd | |
29688 | @need 800 | |
d77de738 ML |
29689 | @opindex mpowerpc-gpopt |
29690 | @opindex mno-powerpc-gpopt | |
29691 | @opindex mpowerpc-gfxopt | |
29692 | @opindex mno-powerpc-gfxopt | |
29693 | @opindex mpowerpc64 | |
29694 | @opindex mno-powerpc64 | |
29695 | @opindex mmfcrf | |
29696 | @opindex mno-mfcrf | |
29697 | @opindex mpopcntb | |
29698 | @opindex mno-popcntb | |
29699 | @opindex mpopcntd | |
29700 | @opindex mno-popcntd | |
29701 | @opindex mfprnd | |
29702 | @opindex mno-fprnd | |
29703 | @opindex mcmpb | |
29704 | @opindex mno-cmpb | |
29705 | @opindex mhard-dfp | |
29706 | @opindex mno-hard-dfp | |
ddf6fe37 AA |
29707 | @itemx -mcmpb |
29708 | @itemx -mno-cmpb | |
29709 | @itemx -mhard-dfp | |
29710 | @itemx -mno-hard-dfp | |
d77de738 ML |
29711 | You use these options to specify which instructions are available on the |
29712 | processor you are using. The default value of these options is | |
29713 | determined when configuring GCC@. Specifying the | |
29714 | @option{-mcpu=@var{cpu_type}} overrides the specification of these | |
29715 | options. We recommend you use the @option{-mcpu=@var{cpu_type}} option | |
29716 | rather than the options listed above. | |
29717 | ||
29718 | Specifying @option{-mpowerpc-gpopt} allows | |
29719 | GCC to use the optional PowerPC architecture instructions in the | |
29720 | General Purpose group, including floating-point square root. Specifying | |
29721 | @option{-mpowerpc-gfxopt} allows GCC to | |
29722 | use the optional PowerPC architecture instructions in the Graphics | |
29723 | group, including floating-point select. | |
29724 | ||
29725 | The @option{-mmfcrf} option allows GCC to generate the move from | |
29726 | condition register field instruction implemented on the POWER4 | |
29727 | processor and other processors that support the PowerPC V2.01 | |
29728 | architecture. | |
29729 | The @option{-mpopcntb} option allows GCC to generate the popcount and | |
29730 | double-precision FP reciprocal estimate instruction implemented on the | |
29731 | POWER5 processor and other processors that support the PowerPC V2.02 | |
29732 | architecture. | |
29733 | The @option{-mpopcntd} option allows GCC to generate the popcount | |
29734 | instruction implemented on the POWER7 processor and other processors | |
29735 | that support the PowerPC V2.06 architecture. | |
29736 | The @option{-mfprnd} option allows GCC to generate the FP round to | |
29737 | integer instructions implemented on the POWER5+ processor and other | |
29738 | processors that support the PowerPC V2.03 architecture. | |
29739 | The @option{-mcmpb} option allows GCC to generate the compare bytes | |
29740 | instruction implemented on the POWER6 processor and other processors | |
29741 | that support the PowerPC V2.05 architecture. | |
29742 | The @option{-mhard-dfp} option allows GCC to generate the decimal | |
29743 | floating-point instructions implemented on some POWER processors. | |
29744 | ||
29745 | The @option{-mpowerpc64} option allows GCC to generate the additional | |
29746 | 64-bit instructions that are found in the full PowerPC64 architecture | |
29747 | and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to | |
29748 | @option{-mno-powerpc64}. | |
29749 | ||
d77de738 | 29750 | @opindex mcpu |
ddf6fe37 | 29751 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
29752 | Set architecture type, register usage, and |
29753 | instruction scheduling parameters for machine type @var{cpu_type}. | |
29754 | Supported values for @var{cpu_type} are @samp{401}, @samp{403}, | |
29755 | @samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp}, | |
29756 | @samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603}, | |
29757 | @samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740}, | |
29758 | @samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823}, | |
29759 | @samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2}, | |
29760 | @samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500}, | |
29761 | @samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5}, | |
29762 | @samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+}, | |
29763 | @samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8}, | |
29764 | @samp{power9}, @samp{power10}, @samp{powerpc}, @samp{powerpc64}, | |
29765 | @samp{powerpc64le}, @samp{rs64}, and @samp{native}. | |
29766 | ||
29767 | @option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and | |
29768 | @option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either | |
29769 | endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC | |
29770 | architecture machine types, with an appropriate, generic processor | |
29771 | model assumed for scheduling purposes. | |
29772 | ||
29773 | Specifying @samp{native} as cpu type detects and selects the | |
29774 | architecture option that corresponds to the host processor of the | |
29775 | system performing the compilation. | |
29776 | @option{-mcpu=native} has no effect if GCC does not recognize the | |
29777 | processor. | |
29778 | ||
29779 | The other options specify a specific processor. Code generated under | |
29780 | those options runs best on that processor, and may not run at all on | |
29781 | others. | |
29782 | ||
29783 | The @option{-mcpu} options automatically enable or disable the | |
29784 | following options: | |
29785 | ||
43b72ede AA |
29786 | @gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple |
29787 | -mpopcntb -mpopcntd -mpowerpc64 | |
29788 | -mpowerpc-gpopt -mpowerpc-gfxopt | |
29789 | -mmulhw -mdlmzb -mmfpgpr -mvsx | |
29790 | -mcrypto -mhtm -mpower8-fusion -mpower8-vector | |
29791 | -mquad-memory -mquad-memory-atomic -mfloat128 | |
29792 | -mfloat128-hardware -mprefixed -mpcrel -mmma | |
d77de738 ML |
29793 | -mrop-protect} |
29794 | ||
29795 | The particular options set for any particular CPU varies between | |
29796 | compiler versions, depending on what setting seems to produce optimal | |
29797 | code for that CPU; it doesn't necessarily reflect the actual hardware's | |
29798 | capabilities. If you wish to set an individual option to a particular | |
29799 | value, you may specify it after the @option{-mcpu} option, like | |
29800 | @option{-mcpu=970 -mno-altivec}. | |
29801 | ||
29802 | On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are | |
29803 | not enabled or disabled by the @option{-mcpu} option at present because | |
29804 | AIX does not have full support for these options. You may still | |
29805 | enable or disable them individually if you're sure it'll work in your | |
29806 | environment. | |
29807 | ||
d77de738 | 29808 | @opindex mtune |
ddf6fe37 | 29809 | @item -mtune=@var{cpu_type} |
d77de738 ML |
29810 | Set the instruction scheduling parameters for machine type |
29811 | @var{cpu_type}, but do not set the architecture type or register usage, | |
29812 | as @option{-mcpu=@var{cpu_type}} does. The same | |
29813 | values for @var{cpu_type} are used for @option{-mtune} as for | |
29814 | @option{-mcpu}. If both are specified, the code generated uses the | |
29815 | architecture and registers set by @option{-mcpu}, but the | |
29816 | scheduling parameters set by @option{-mtune}. | |
29817 | ||
d77de738 | 29818 | @opindex mcmodel=small |
ddf6fe37 | 29819 | @item -mcmodel=small |
d77de738 ML |
29820 | Generate PowerPC64 code for the small model: The TOC is limited to |
29821 | 64k. | |
29822 | ||
d77de738 | 29823 | @opindex mcmodel=medium |
ddf6fe37 | 29824 | @item -mcmodel=medium |
d77de738 ML |
29825 | Generate PowerPC64 code for the medium model: The TOC and other static |
29826 | data may be up to a total of 4G in size. This is the default for 64-bit | |
29827 | Linux. | |
29828 | ||
d77de738 | 29829 | @opindex mcmodel=large |
ddf6fe37 | 29830 | @item -mcmodel=large |
d77de738 ML |
29831 | Generate PowerPC64 code for the large model: The TOC may be up to 4G |
29832 | in size. Other data and code is only limited by the 64-bit address | |
29833 | space. | |
29834 | ||
d77de738 ML |
29835 | @opindex maltivec |
29836 | @opindex mno-altivec | |
ddf6fe37 AA |
29837 | @item -maltivec |
29838 | @itemx -mno-altivec | |
d77de738 ML |
29839 | Generate code that uses (does not use) AltiVec instructions, and also |
29840 | enable the use of built-in functions that allow more direct access to | |
29841 | the AltiVec instruction set. You may also need to set | |
29842 | @option{-mabi=altivec} to adjust the current ABI with AltiVec ABI | |
29843 | enhancements. | |
29844 | ||
29845 | When @option{-maltivec} is used, the element order for AltiVec intrinsics | |
29846 | such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert} | |
29847 | match array element order corresponding to the endianness of the | |
29848 | target. That is, element zero identifies the leftmost element in a | |
29849 | vector register when targeting a big-endian platform, and identifies | |
29850 | the rightmost element in a vector register when targeting a | |
29851 | little-endian platform. | |
29852 | ||
d77de738 ML |
29853 | @opindex mvrsave |
29854 | @opindex mno-vrsave | |
ddf6fe37 AA |
29855 | @item -mvrsave |
29856 | @itemx -mno-vrsave | |
d77de738 ML |
29857 | Generate VRSAVE instructions when generating AltiVec code. |
29858 | ||
d77de738 | 29859 | @opindex msecure-plt |
ddf6fe37 | 29860 | @item -msecure-plt |
d77de738 ML |
29861 | Generate code that allows @command{ld} and @command{ld.so} |
29862 | to build executables and shared | |
29863 | libraries with non-executable @code{.plt} and @code{.got} sections. | |
29864 | This is a PowerPC | |
29865 | 32-bit SYSV ABI option. | |
29866 | ||
d77de738 | 29867 | @opindex mbss-plt |
ddf6fe37 | 29868 | @item -mbss-plt |
d77de738 ML |
29869 | Generate code that uses a BSS @code{.plt} section that @command{ld.so} |
29870 | fills in, and | |
29871 | requires @code{.plt} and @code{.got} | |
29872 | sections that are both writable and executable. | |
29873 | This is a PowerPC 32-bit SYSV ABI option. | |
29874 | ||
d77de738 ML |
29875 | @opindex misel |
29876 | @opindex mno-isel | |
ddf6fe37 AA |
29877 | @item -misel |
29878 | @itemx -mno-isel | |
d77de738 ML |
29879 | This switch enables or disables the generation of ISEL instructions. |
29880 | ||
d77de738 ML |
29881 | @opindex mvsx |
29882 | @opindex mno-vsx | |
ddf6fe37 AA |
29883 | @item -mvsx |
29884 | @itemx -mno-vsx | |
d77de738 ML |
29885 | Generate code that uses (does not use) vector/scalar (VSX) |
29886 | instructions, and also enable the use of built-in functions that allow | |
29887 | more direct access to the VSX instruction set. | |
29888 | ||
d77de738 ML |
29889 | @opindex mcrypto |
29890 | @opindex mno-crypto | |
ddf6fe37 AA |
29891 | @item -mcrypto |
29892 | @itemx -mno-crypto | |
d77de738 ML |
29893 | Enable the use (disable) of the built-in functions that allow direct |
29894 | access to the cryptographic instructions that were added in version | |
29895 | 2.07 of the PowerPC ISA. | |
29896 | ||
d77de738 ML |
29897 | @opindex mhtm |
29898 | @opindex mno-htm | |
ddf6fe37 AA |
29899 | @item -mhtm |
29900 | @itemx -mno-htm | |
d77de738 ML |
29901 | Enable (disable) the use of the built-in functions that allow direct |
29902 | access to the Hardware Transactional Memory (HTM) instructions that | |
29903 | were added in version 2.07 of the PowerPC ISA. | |
29904 | ||
d77de738 ML |
29905 | @opindex mpower8-fusion |
29906 | @opindex mno-power8-fusion | |
ddf6fe37 AA |
29907 | @item -mpower8-fusion |
29908 | @itemx -mno-power8-fusion | |
d77de738 ML |
29909 | Generate code that keeps (does not keeps) some integer operations |
29910 | adjacent so that the instructions can be fused together on power8 and | |
29911 | later processors. | |
29912 | ||
d77de738 ML |
29913 | @opindex mpower8-vector |
29914 | @opindex mno-power8-vector | |
ddf6fe37 AA |
29915 | @item -mpower8-vector |
29916 | @itemx -mno-power8-vector | |
d77de738 ML |
29917 | Generate code that uses (does not use) the vector and scalar |
29918 | instructions that were added in version 2.07 of the PowerPC ISA. Also | |
29919 | enable the use of built-in functions that allow more direct access to | |
29920 | the vector instructions. | |
29921 | ||
d77de738 ML |
29922 | @opindex mquad-memory |
29923 | @opindex mno-quad-memory | |
ddf6fe37 AA |
29924 | @item -mquad-memory |
29925 | @itemx -mno-quad-memory | |
d77de738 ML |
29926 | Generate code that uses (does not use) the non-atomic quad word memory |
29927 | instructions. The @option{-mquad-memory} option requires use of | |
29928 | 64-bit mode. | |
29929 | ||
d77de738 ML |
29930 | @opindex mquad-memory-atomic |
29931 | @opindex mno-quad-memory-atomic | |
ddf6fe37 AA |
29932 | @item -mquad-memory-atomic |
29933 | @itemx -mno-quad-memory-atomic | |
d77de738 ML |
29934 | Generate code that uses (does not use) the atomic quad word memory |
29935 | instructions. The @option{-mquad-memory-atomic} option requires use of | |
29936 | 64-bit mode. | |
29937 | ||
d77de738 ML |
29938 | @opindex mfloat128 |
29939 | @opindex mno-float128 | |
ddf6fe37 AA |
29940 | @item -mfloat128 |
29941 | @itemx -mno-float128 | |
d77de738 ML |
29942 | Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point |
29943 | and use either software emulation for IEEE 128-bit floating point or | |
29944 | hardware instructions. | |
29945 | ||
29946 | The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE | |
29947 | 128-bit floating point support. The IEEE 128-bit floating point is only | |
29948 | supported on Linux. | |
29949 | ||
29950 | The default for @option{-mfloat128} is enabled on PowerPC Linux | |
29951 | systems using the VSX instruction set, and disabled on other systems. | |
29952 | ||
29953 | If you use the ISA 3.0 instruction set (@option{-mpower9-vector} or | |
29954 | @option{-mcpu=power9}) on a 64-bit system, the IEEE 128-bit floating | |
29955 | point support will also enable the generation of ISA 3.0 IEEE 128-bit | |
29956 | floating point instructions. Otherwise, if you do not specify to | |
29957 | generate ISA 3.0 instructions or you are targeting a 32-bit big endian | |
29958 | system, IEEE 128-bit floating point will be done with software | |
29959 | emulation. | |
29960 | ||
d77de738 ML |
29961 | @opindex mfloat128-hardware |
29962 | @opindex mno-float128-hardware | |
ddf6fe37 AA |
29963 | @item -mfloat128-hardware |
29964 | @itemx -mno-float128-hardware | |
d77de738 ML |
29965 | Enable/disable using ISA 3.0 hardware instructions to support the |
29966 | @var{__float128} data type. | |
29967 | ||
29968 | The default for @option{-mfloat128-hardware} is enabled on PowerPC | |
29969 | Linux systems using the ISA 3.0 instruction set, and disabled on other | |
29970 | systems. | |
29971 | ||
d77de738 ML |
29972 | @opindex m32 |
29973 | @opindex m64 | |
ddf6fe37 AA |
29974 | @item -m32 |
29975 | @itemx -m64 | |
d77de738 ML |
29976 | Generate code for 32-bit or 64-bit environments of Darwin and SVR4 |
29977 | targets (including GNU/Linux). The 32-bit environment sets int, long | |
29978 | and pointer to 32 bits and generates code that runs on any PowerPC | |
29979 | variant. The 64-bit environment sets int to 32 bits and long and | |
29980 | pointer to 64 bits, and generates code for PowerPC64, as for | |
29981 | @option{-mpowerpc64}. | |
29982 | ||
d77de738 ML |
29983 | @opindex mfull-toc |
29984 | @opindex mno-fp-in-toc | |
29985 | @opindex mno-sum-in-toc | |
29986 | @opindex mminimal-toc | |
ddf6fe37 AA |
29987 | @item -mfull-toc |
29988 | @itemx -mno-fp-in-toc | |
29989 | @itemx -mno-sum-in-toc | |
29990 | @itemx -mminimal-toc | |
d77de738 ML |
29991 | Modify generation of the TOC (Table Of Contents), which is created for |
29992 | every executable file. The @option{-mfull-toc} option is selected by | |
29993 | default. In that case, GCC allocates at least one TOC entry for | |
29994 | each unique non-automatic variable reference in your program. GCC | |
29995 | also places floating-point constants in the TOC@. However, only | |
29996 | 16,384 entries are available in the TOC@. | |
29997 | ||
29998 | If you receive a linker error message that saying you have overflowed | |
29999 | the available TOC space, you can reduce the amount of TOC space used | |
30000 | with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options. | |
30001 | @option{-mno-fp-in-toc} prevents GCC from putting floating-point | |
30002 | constants in the TOC and @option{-mno-sum-in-toc} forces GCC to | |
30003 | generate code to calculate the sum of an address and a constant at | |
30004 | run time instead of putting that sum into the TOC@. You may specify one | |
30005 | or both of these options. Each causes GCC to produce very slightly | |
30006 | slower and larger code at the expense of conserving TOC space. | |
30007 | ||
30008 | If you still run out of space in the TOC even when you specify both of | |
30009 | these options, specify @option{-mminimal-toc} instead. This option causes | |
30010 | GCC to make only one TOC entry for every file. When you specify this | |
30011 | option, GCC produces code that is slower and larger but which | |
30012 | uses extremely little TOC space. You may wish to use this option | |
30013 | only on files that contain less frequently-executed code. | |
30014 | ||
d77de738 ML |
30015 | @opindex maix64 |
30016 | @opindex maix32 | |
ddf6fe37 AA |
30017 | @item -maix64 |
30018 | @itemx -maix32 | |
d77de738 ML |
30019 | Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit |
30020 | @code{long} type, and the infrastructure needed to support them. | |
30021 | Specifying @option{-maix64} implies @option{-mpowerpc64}, | |
30022 | while @option{-maix32} disables the 64-bit ABI and | |
30023 | implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}. | |
30024 | ||
d77de738 ML |
30025 | @opindex mxl-compat |
30026 | @opindex mno-xl-compat | |
ddf6fe37 AA |
30027 | @item -mxl-compat |
30028 | @itemx -mno-xl-compat | |
d77de738 ML |
30029 | Produce code that conforms more closely to IBM XL compiler semantics |
30030 | when using AIX-compatible ABI@. Pass floating-point arguments to | |
30031 | prototyped functions beyond the register save area (RSA) on the stack | |
30032 | in addition to argument FPRs. Do not assume that most significant | |
30033 | double in 128-bit long double value is properly rounded when comparing | |
30034 | values and converting to double. Use XL symbol names for long double | |
30035 | support routines. | |
30036 | ||
30037 | The AIX calling convention was extended but not initially documented to | |
30038 | handle an obscure K&R C case of calling a function that takes the | |
30039 | address of its arguments with fewer arguments than declared. IBM XL | |
30040 | compilers access floating-point arguments that do not fit in the | |
30041 | RSA from the stack when a subroutine is compiled without | |
30042 | optimization. Because always storing floating-point arguments on the | |
30043 | stack is inefficient and rarely needed, this option is not enabled by | |
30044 | default and only is necessary when calling subroutines compiled by IBM | |
30045 | XL compilers without optimization. | |
30046 | ||
d77de738 | 30047 | @opindex mpe |
ddf6fe37 | 30048 | @item -mpe |
d77de738 ML |
30049 | Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an |
30050 | application written to use message passing with special startup code to | |
30051 | enable the application to run. The system must have PE installed in the | |
30052 | standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file | |
30053 | must be overridden with the @option{-specs=} option to specify the | |
30054 | appropriate directory location. The Parallel Environment does not | |
30055 | support threads, so the @option{-mpe} option and the @option{-pthread} | |
30056 | option are incompatible. | |
30057 | ||
d77de738 ML |
30058 | @opindex malign-natural |
30059 | @opindex malign-power | |
ddf6fe37 AA |
30060 | @item -malign-natural |
30061 | @itemx -malign-power | |
d77de738 ML |
30062 | On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option |
30063 | @option{-malign-natural} overrides the ABI-defined alignment of larger | |
30064 | types, such as floating-point doubles, on their natural size-based boundary. | |
30065 | The option @option{-malign-power} instructs GCC to follow the ABI-specified | |
30066 | alignment rules. GCC defaults to the standard alignment defined in the ABI@. | |
30067 | ||
30068 | On 64-bit Darwin, natural alignment is the default, and @option{-malign-power} | |
30069 | is not supported. | |
30070 | ||
d77de738 ML |
30071 | @opindex msoft-float |
30072 | @opindex mhard-float | |
ddf6fe37 AA |
30073 | @item -msoft-float |
30074 | @itemx -mhard-float | |
d77de738 ML |
30075 | Generate code that does not use (uses) the floating-point register set. |
30076 | Software floating-point emulation is provided if you use the | |
30077 | @option{-msoft-float} option, and pass the option to GCC when linking. | |
30078 | ||
d77de738 ML |
30079 | @opindex mmultiple |
30080 | @opindex mno-multiple | |
ddf6fe37 AA |
30081 | @item -mmultiple |
30082 | @itemx -mno-multiple | |
d77de738 ML |
30083 | Generate code that uses (does not use) the load multiple word |
30084 | instructions and the store multiple word instructions. These | |
30085 | instructions are generated by default on POWER systems, and not | |
30086 | generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian | |
30087 | PowerPC systems, since those instructions do not work when the | |
30088 | processor is in little-endian mode. The exceptions are PPC740 and | |
30089 | PPC750 which permit these instructions in little-endian mode. | |
30090 | ||
d77de738 ML |
30091 | @opindex mupdate |
30092 | @opindex mno-update | |
ddf6fe37 AA |
30093 | @item -mupdate |
30094 | @itemx -mno-update | |
d77de738 ML |
30095 | Generate code that uses (does not use) the load or store instructions |
30096 | that update the base register to the address of the calculated memory | |
30097 | location. These instructions are generated by default. If you use | |
30098 | @option{-mno-update}, there is a small window between the time that the | |
30099 | stack pointer is updated and the address of the previous frame is | |
30100 | stored, which means code that walks the stack frame across interrupts or | |
30101 | signals may get corrupted data. | |
30102 | ||
d77de738 ML |
30103 | @opindex mavoid-indexed-addresses |
30104 | @opindex mno-avoid-indexed-addresses | |
ddf6fe37 AA |
30105 | @item -mavoid-indexed-addresses |
30106 | @itemx -mno-avoid-indexed-addresses | |
d77de738 ML |
30107 | Generate code that tries to avoid (not avoid) the use of indexed load |
30108 | or store instructions. These instructions can incur a performance | |
30109 | penalty on Power6 processors in certain situations, such as when | |
30110 | stepping through large arrays that cross a 16M boundary. This option | |
30111 | is enabled by default when targeting Power6 and disabled otherwise. | |
30112 | ||
d77de738 ML |
30113 | @opindex mfused-madd |
30114 | @opindex mno-fused-madd | |
ddf6fe37 AA |
30115 | @item -mfused-madd |
30116 | @itemx -mno-fused-madd | |
d77de738 ML |
30117 | Generate code that uses (does not use) the floating-point multiply and |
30118 | accumulate instructions. These instructions are generated by default | |
30119 | if hardware floating point is used. The machine-dependent | |
30120 | @option{-mfused-madd} option is now mapped to the machine-independent | |
30121 | @option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is | |
30122 | mapped to @option{-ffp-contract=off}. | |
30123 | ||
d77de738 ML |
30124 | @opindex mmulhw |
30125 | @opindex mno-mulhw | |
ddf6fe37 AA |
30126 | @item -mmulhw |
30127 | @itemx -mno-mulhw | |
d77de738 ML |
30128 | Generate code that uses (does not use) the half-word multiply and |
30129 | multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors. | |
30130 | These instructions are generated by default when targeting those | |
30131 | processors. | |
30132 | ||
d77de738 ML |
30133 | @opindex mdlmzb |
30134 | @opindex mno-dlmzb | |
ddf6fe37 AA |
30135 | @item -mdlmzb |
30136 | @itemx -mno-dlmzb | |
d77de738 ML |
30137 | Generate code that uses (does not use) the string-search @samp{dlmzb} |
30138 | instruction on the IBM 405, 440, 464 and 476 processors. This instruction is | |
30139 | generated by default when targeting those processors. | |
30140 | ||
d77de738 ML |
30141 | @opindex mno-bit-align |
30142 | @opindex mbit-align | |
ddf6fe37 AA |
30143 | @item -mno-bit-align |
30144 | @itemx -mbit-align | |
d77de738 ML |
30145 | On System V.4 and embedded PowerPC systems do not (do) force structures |
30146 | and unions that contain bit-fields to be aligned to the base type of the | |
30147 | bit-field. | |
30148 | ||
30149 | For example, by default a structure containing nothing but 8 | |
30150 | @code{unsigned} bit-fields of length 1 is aligned to a 4-byte | |
30151 | boundary and has a size of 4 bytes. By using @option{-mno-bit-align}, | |
30152 | the structure is aligned to a 1-byte boundary and is 1 byte in | |
30153 | size. | |
30154 | ||
d77de738 ML |
30155 | @opindex mno-strict-align |
30156 | @opindex mstrict-align | |
ddf6fe37 AA |
30157 | @item -mno-strict-align |
30158 | @itemx -mstrict-align | |
d77de738 ML |
30159 | On System V.4 and embedded PowerPC systems do not (do) assume that |
30160 | unaligned memory references are handled by the system. | |
30161 | ||
d77de738 ML |
30162 | @opindex mrelocatable |
30163 | @opindex mno-relocatable | |
ddf6fe37 AA |
30164 | @item -mrelocatable |
30165 | @itemx -mno-relocatable | |
d77de738 ML |
30166 | Generate code that allows (does not allow) a static executable to be |
30167 | relocated to a different address at run time. A simple embedded | |
30168 | PowerPC system loader should relocate the entire contents of | |
30169 | @code{.got2} and 4-byte locations listed in the @code{.fixup} section, | |
30170 | a table of 32-bit addresses generated by this option. For this to | |
30171 | work, all objects linked together must be compiled with | |
30172 | @option{-mrelocatable} or @option{-mrelocatable-lib}. | |
30173 | @option{-mrelocatable} code aligns the stack to an 8-byte boundary. | |
30174 | ||
d77de738 ML |
30175 | @opindex mrelocatable-lib |
30176 | @opindex mno-relocatable-lib | |
ddf6fe37 AA |
30177 | @item -mrelocatable-lib |
30178 | @itemx -mno-relocatable-lib | |
d77de738 ML |
30179 | Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a |
30180 | @code{.fixup} section to allow static executables to be relocated at | |
30181 | run time, but @option{-mrelocatable-lib} does not use the smaller stack | |
30182 | alignment of @option{-mrelocatable}. Objects compiled with | |
30183 | @option{-mrelocatable-lib} may be linked with objects compiled with | |
30184 | any combination of the @option{-mrelocatable} options. | |
30185 | ||
d77de738 ML |
30186 | @opindex mno-toc |
30187 | @opindex mtoc | |
ddf6fe37 AA |
30188 | @item -mno-toc |
30189 | @itemx -mtoc | |
d77de738 ML |
30190 | On System V.4 and embedded PowerPC systems do not (do) assume that |
30191 | register 2 contains a pointer to a global area pointing to the addresses | |
30192 | used in the program. | |
30193 | ||
d77de738 ML |
30194 | @opindex mlittle |
30195 | @opindex mlittle-endian | |
ddf6fe37 AA |
30196 | @item -mlittle |
30197 | @itemx -mlittle-endian | |
d77de738 ML |
30198 | On System V.4 and embedded PowerPC systems compile code for the |
30199 | processor in little-endian mode. The @option{-mlittle-endian} option is | |
30200 | the same as @option{-mlittle}. | |
30201 | ||
d77de738 ML |
30202 | @opindex mbig |
30203 | @opindex mbig-endian | |
ddf6fe37 AA |
30204 | @item -mbig |
30205 | @itemx -mbig-endian | |
d77de738 ML |
30206 | On System V.4 and embedded PowerPC systems compile code for the |
30207 | processor in big-endian mode. The @option{-mbig-endian} option is | |
30208 | the same as @option{-mbig}. | |
30209 | ||
d77de738 | 30210 | @opindex mdynamic-no-pic |
ddf6fe37 | 30211 | @item -mdynamic-no-pic |
a335cf24 | 30212 | On Darwin / macOS systems, compile code so that it is not |
d77de738 ML |
30213 | relocatable, but that its external references are relocatable. The |
30214 | resulting code is suitable for applications, but not shared | |
30215 | libraries. | |
30216 | ||
d77de738 | 30217 | @opindex msingle-pic-base |
ddf6fe37 | 30218 | @item -msingle-pic-base |
d77de738 ML |
30219 | Treat the register used for PIC addressing as read-only, rather than |
30220 | loading it in the prologue for each function. The runtime system is | |
30221 | responsible for initializing this register with an appropriate value | |
30222 | before execution begins. | |
30223 | ||
d77de738 | 30224 | @opindex mprioritize-restricted-insns |
ddf6fe37 | 30225 | @item -mprioritize-restricted-insns=@var{priority} |
d77de738 ML |
30226 | This option controls the priority that is assigned to |
30227 | dispatch-slot restricted instructions during the second scheduling | |
30228 | pass. The argument @var{priority} takes the value @samp{0}, @samp{1}, | |
30229 | or @samp{2} to assign no, highest, or second-highest (respectively) | |
30230 | priority to dispatch-slot restricted | |
30231 | instructions. | |
30232 | ||
d77de738 | 30233 | @opindex msched-costly-dep |
ddf6fe37 | 30234 | @item -msched-costly-dep=@var{dependence_type} |
d77de738 ML |
30235 | This option controls which dependences are considered costly |
30236 | by the target during instruction scheduling. The argument | |
30237 | @var{dependence_type} takes one of the following values: | |
30238 | ||
30239 | @table @asis | |
30240 | @item @samp{no} | |
30241 | No dependence is costly. | |
30242 | ||
30243 | @item @samp{all} | |
30244 | All dependences are costly. | |
30245 | ||
30246 | @item @samp{true_store_to_load} | |
30247 | A true dependence from store to load is costly. | |
30248 | ||
30249 | @item @samp{store_to_load} | |
30250 | Any dependence from store to load is costly. | |
30251 | ||
30252 | @item @var{number} | |
30253 | Any dependence for which the latency is greater than or equal to | |
30254 | @var{number} is costly. | |
30255 | @end table | |
30256 | ||
d77de738 | 30257 | @opindex minsert-sched-nops |
ddf6fe37 | 30258 | @item -minsert-sched-nops=@var{scheme} |
d77de738 ML |
30259 | This option controls which NOP insertion scheme is used during |
30260 | the second scheduling pass. The argument @var{scheme} takes one of the | |
30261 | following values: | |
30262 | ||
30263 | @table @asis | |
30264 | @item @samp{no} | |
30265 | Don't insert NOPs. | |
30266 | ||
30267 | @item @samp{pad} | |
30268 | Pad with NOPs any dispatch group that has vacant issue slots, | |
30269 | according to the scheduler's grouping. | |
30270 | ||
30271 | @item @samp{regroup_exact} | |
30272 | Insert NOPs to force costly dependent insns into | |
30273 | separate groups. Insert exactly as many NOPs as needed to force an insn | |
30274 | to a new group, according to the estimated processor grouping. | |
30275 | ||
30276 | @item @var{number} | |
30277 | Insert NOPs to force costly dependent insns into | |
30278 | separate groups. Insert @var{number} NOPs to force an insn to a new group. | |
30279 | @end table | |
30280 | ||
d77de738 | 30281 | @opindex mcall-sysv |
ddf6fe37 | 30282 | @item -mcall-sysv |
d77de738 ML |
30283 | On System V.4 and embedded PowerPC systems compile code using calling |
30284 | conventions that adhere to the March 1995 draft of the System V | |
30285 | Application Binary Interface, PowerPC processor supplement. This is the | |
30286 | default unless you configured GCC using @samp{powerpc-*-eabiaix}. | |
30287 | ||
d77de738 ML |
30288 | @opindex mcall-sysv-eabi |
30289 | @opindex mcall-eabi | |
ddf6fe37 AA |
30290 | @item -mcall-sysv-eabi |
30291 | @itemx -mcall-eabi | |
d77de738 ML |
30292 | Specify both @option{-mcall-sysv} and @option{-meabi} options. |
30293 | ||
d77de738 | 30294 | @opindex mcall-sysv-noeabi |
ddf6fe37 | 30295 | @item -mcall-sysv-noeabi |
d77de738 ML |
30296 | Specify both @option{-mcall-sysv} and @option{-mno-eabi} options. |
30297 | ||
d7971cf7 | 30298 | @opindex mcall-aixdesc |
ddf6fe37 | 30299 | @item -mcall-aixdesc |
d77de738 ML |
30300 | On System V.4 and embedded PowerPC systems compile code for the AIX |
30301 | operating system. | |
30302 | ||
d77de738 | 30303 | @opindex mcall-linux |
ddf6fe37 | 30304 | @item -mcall-linux |
d77de738 ML |
30305 | On System V.4 and embedded PowerPC systems compile code for the |
30306 | Linux-based GNU system. | |
30307 | ||
d77de738 | 30308 | @opindex mcall-freebsd |
ddf6fe37 | 30309 | @item -mcall-freebsd |
d77de738 ML |
30310 | On System V.4 and embedded PowerPC systems compile code for the |
30311 | FreeBSD operating system. | |
30312 | ||
d77de738 | 30313 | @opindex mcall-netbsd |
ddf6fe37 | 30314 | @item -mcall-netbsd |
d77de738 ML |
30315 | On System V.4 and embedded PowerPC systems compile code for the |
30316 | NetBSD operating system. | |
30317 | ||
d7971cf7 | 30318 | @opindex mcall-openbsd |
ddf6fe37 | 30319 | @item -mcall-openbsd |
d77de738 ML |
30320 | On System V.4 and embedded PowerPC systems compile code for the |
30321 | OpenBSD operating system. | |
30322 | ||
d77de738 | 30323 | @opindex mtraceback |
ddf6fe37 | 30324 | @item -mtraceback=@var{traceback_type} |
d77de738 ML |
30325 | Select the type of traceback table. Valid values for @var{traceback_type} |
30326 | are @samp{full}, @samp{part}, and @samp{no}. | |
30327 | ||
d77de738 | 30328 | @opindex maix-struct-return |
ddf6fe37 | 30329 | @item -maix-struct-return |
d77de738 ML |
30330 | Return all structures in memory (as specified by the AIX ABI)@. |
30331 | ||
d77de738 | 30332 | @opindex msvr4-struct-return |
ddf6fe37 | 30333 | @item -msvr4-struct-return |
d77de738 ML |
30334 | Return structures smaller than 8 bytes in registers (as specified by the |
30335 | SVR4 ABI)@. | |
30336 | ||
d77de738 | 30337 | @opindex mabi |
ddf6fe37 | 30338 | @item -mabi=@var{abi-type} |
d77de738 ML |
30339 | Extend the current ABI with a particular extension, or remove such extension. |
30340 | Valid values are: @samp{altivec}, @samp{no-altivec}, | |
30341 | @samp{ibmlongdouble}, @samp{ieeelongdouble}, | |
30342 | @samp{elfv1}, @samp{elfv2}, | |
30343 | and for AIX: @samp{vec-extabi}, @samp{vec-default}@. | |
30344 | ||
d77de738 | 30345 | @opindex mabi=ibmlongdouble |
ddf6fe37 | 30346 | @item -mabi=ibmlongdouble |
d77de738 ML |
30347 | Change the current ABI to use IBM extended-precision long double. |
30348 | This is not likely to work if your system defaults to using IEEE | |
30349 | extended-precision long double. If you change the long double type | |
30350 | from IEEE extended-precision, the compiler will issue a warning unless | |
30351 | you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128} | |
30352 | to be enabled. | |
30353 | ||
d77de738 | 30354 | @opindex mabi=ieeelongdouble |
ddf6fe37 | 30355 | @item -mabi=ieeelongdouble |
d77de738 ML |
30356 | Change the current ABI to use IEEE extended-precision long double. |
30357 | This is not likely to work if your system defaults to using IBM | |
30358 | extended-precision long double. If you change the long double type | |
30359 | from IBM extended-precision, the compiler will issue a warning unless | |
30360 | you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128} | |
30361 | to be enabled. | |
30362 | ||
d77de738 | 30363 | @opindex mabi=elfv1 |
ddf6fe37 | 30364 | @item -mabi=elfv1 |
d77de738 ML |
30365 | Change the current ABI to use the ELFv1 ABI. |
30366 | This is the default ABI for big-endian PowerPC 64-bit Linux. | |
30367 | Overriding the default ABI requires special system support and is | |
30368 | likely to fail in spectacular ways. | |
30369 | ||
d77de738 | 30370 | @opindex mabi=elfv2 |
ddf6fe37 | 30371 | @item -mabi=elfv2 |
d77de738 ML |
30372 | Change the current ABI to use the ELFv2 ABI. |
30373 | This is the default ABI for little-endian PowerPC 64-bit Linux. | |
30374 | Overriding the default ABI requires special system support and is | |
30375 | likely to fail in spectacular ways. | |
30376 | ||
d77de738 ML |
30377 | @opindex mgnu-attribute |
30378 | @opindex mno-gnu-attribute | |
ddf6fe37 AA |
30379 | @item -mgnu-attribute |
30380 | @itemx -mno-gnu-attribute | |
d77de738 ML |
30381 | Emit .gnu_attribute assembly directives to set tag/value pairs in a |
30382 | .gnu.attributes section that specify ABI variations in function | |
30383 | parameters or return values. | |
30384 | ||
d77de738 ML |
30385 | @opindex mprototype |
30386 | @opindex mno-prototype | |
ddf6fe37 AA |
30387 | @item -mprototype |
30388 | @itemx -mno-prototype | |
d77de738 ML |
30389 | On System V.4 and embedded PowerPC systems assume that all calls to |
30390 | variable argument functions are properly prototyped. Otherwise, the | |
30391 | compiler must insert an instruction before every non-prototyped call to | |
30392 | set or clear bit 6 of the condition code register (@code{CR}) to | |
30393 | indicate whether floating-point values are passed in the floating-point | |
30394 | registers in case the function takes variable arguments. With | |
30395 | @option{-mprototype}, only calls to prototyped variable argument functions | |
30396 | set or clear the bit. | |
30397 | ||
d77de738 | 30398 | @opindex msim |
ddf6fe37 | 30399 | @item -msim |
d77de738 ML |
30400 | On embedded PowerPC systems, assume that the startup module is called |
30401 | @file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and | |
30402 | @file{libc.a}. This is the default for @samp{powerpc-*-eabisim} | |
30403 | configurations. | |
30404 | ||
d77de738 | 30405 | @opindex mmvme |
ddf6fe37 | 30406 | @item -mmvme |
d77de738 ML |
30407 | On embedded PowerPC systems, assume that the startup module is called |
30408 | @file{crt0.o} and the standard C libraries are @file{libmvme.a} and | |
30409 | @file{libc.a}. | |
30410 | ||
d77de738 | 30411 | @opindex mads |
ddf6fe37 | 30412 | @item -mads |
d77de738 ML |
30413 | On embedded PowerPC systems, assume that the startup module is called |
30414 | @file{crt0.o} and the standard C libraries are @file{libads.a} and | |
30415 | @file{libc.a}. | |
30416 | ||
d77de738 | 30417 | @opindex myellowknife |
ddf6fe37 | 30418 | @item -myellowknife |
d77de738 ML |
30419 | On embedded PowerPC systems, assume that the startup module is called |
30420 | @file{crt0.o} and the standard C libraries are @file{libyk.a} and | |
30421 | @file{libc.a}. | |
30422 | ||
d77de738 | 30423 | @opindex mvxworks |
ddf6fe37 | 30424 | @item -mvxworks |
d77de738 ML |
30425 | On System V.4 and embedded PowerPC systems, specify that you are |
30426 | compiling for a VxWorks system. | |
30427 | ||
d77de738 | 30428 | @opindex memb |
ddf6fe37 | 30429 | @item -memb |
d77de738 ML |
30430 | On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags |
30431 | header to indicate that @samp{eabi} extended relocations are used. | |
30432 | ||
d77de738 ML |
30433 | @opindex meabi |
30434 | @opindex mno-eabi | |
ddf6fe37 AA |
30435 | @item -meabi |
30436 | @itemx -mno-eabi | |
d77de738 ML |
30437 | On System V.4 and embedded PowerPC systems do (do not) adhere to the |
30438 | Embedded Applications Binary Interface (EABI), which is a set of | |
30439 | modifications to the System V.4 specifications. Selecting @option{-meabi} | |
30440 | means that the stack is aligned to an 8-byte boundary, a function | |
30441 | @code{__eabi} is called from @code{main} to set up the EABI | |
30442 | environment, and the @option{-msdata} option can use both @code{r2} and | |
30443 | @code{r13} to point to two separate small data areas. Selecting | |
30444 | @option{-mno-eabi} means that the stack is aligned to a 16-byte boundary, | |
30445 | no EABI initialization function is called from @code{main}, and the | |
30446 | @option{-msdata} option only uses @code{r13} to point to a single | |
30447 | small data area. The @option{-meabi} option is on by default if you | |
30448 | configured GCC using one of the @samp{powerpc*-*-eabi*} options. | |
30449 | ||
d77de738 | 30450 | @opindex msdata=eabi |
ddf6fe37 | 30451 | @item -msdata=eabi |
d77de738 ML |
30452 | On System V.4 and embedded PowerPC systems, put small initialized |
30453 | @code{const} global and static data in the @code{.sdata2} section, which | |
30454 | is pointed to by register @code{r2}. Put small initialized | |
30455 | non-@code{const} global and static data in the @code{.sdata} section, | |
30456 | which is pointed to by register @code{r13}. Put small uninitialized | |
30457 | global and static data in the @code{.sbss} section, which is adjacent to | |
30458 | the @code{.sdata} section. The @option{-msdata=eabi} option is | |
30459 | incompatible with the @option{-mrelocatable} option. The | |
30460 | @option{-msdata=eabi} option also sets the @option{-memb} option. | |
30461 | ||
d77de738 | 30462 | @opindex msdata=sysv |
ddf6fe37 | 30463 | @item -msdata=sysv |
d77de738 ML |
30464 | On System V.4 and embedded PowerPC systems, put small global and static |
30465 | data in the @code{.sdata} section, which is pointed to by register | |
30466 | @code{r13}. Put small uninitialized global and static data in the | |
30467 | @code{.sbss} section, which is adjacent to the @code{.sdata} section. | |
30468 | The @option{-msdata=sysv} option is incompatible with the | |
30469 | @option{-mrelocatable} option. | |
30470 | ||
d77de738 ML |
30471 | @opindex msdata=default |
30472 | @opindex msdata | |
ddf6fe37 AA |
30473 | @item -msdata=default |
30474 | @itemx -msdata | |
d77de738 ML |
30475 | On System V.4 and embedded PowerPC systems, if @option{-meabi} is used, |
30476 | compile code the same as @option{-msdata=eabi}, otherwise compile code the | |
30477 | same as @option{-msdata=sysv}. | |
30478 | ||
d77de738 | 30479 | @opindex msdata=data |
ddf6fe37 | 30480 | @item -msdata=data |
d77de738 ML |
30481 | On System V.4 and embedded PowerPC systems, put small global |
30482 | data in the @code{.sdata} section. Put small uninitialized global | |
30483 | data in the @code{.sbss} section. Do not use register @code{r13} | |
30484 | to address small data however. This is the default behavior unless | |
30485 | other @option{-msdata} options are used. | |
30486 | ||
d77de738 ML |
30487 | @opindex msdata=none |
30488 | @opindex mno-sdata | |
ddf6fe37 AA |
30489 | @item -msdata=none |
30490 | @itemx -mno-sdata | |
d77de738 ML |
30491 | On embedded PowerPC systems, put all initialized global and static data |
30492 | in the @code{.data} section, and all uninitialized data in the | |
30493 | @code{.bss} section. | |
30494 | ||
d77de738 ML |
30495 | @opindex mreadonly-in-sdata |
30496 | @opindex mno-readonly-in-sdata | |
ddf6fe37 | 30497 | @item -mreadonly-in-sdata |
d77de738 ML |
30498 | Put read-only objects in the @code{.sdata} section as well. This is the |
30499 | default. | |
30500 | ||
d77de738 | 30501 | @opindex mblock-move-inline-limit |
ddf6fe37 | 30502 | @item -mblock-move-inline-limit=@var{num} |
d77de738 ML |
30503 | Inline all block moves (such as calls to @code{memcpy} or structure |
30504 | copies) less than or equal to @var{num} bytes. The minimum value for | |
30505 | @var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit | |
30506 | targets. The default value is target-specific. | |
30507 | ||
d77de738 | 30508 | @opindex mblock-compare-inline-limit |
ddf6fe37 | 30509 | @item -mblock-compare-inline-limit=@var{num} |
d77de738 ML |
30510 | Generate non-looping inline code for all block compares (such as calls |
30511 | to @code{memcmp} or structure compares) less than or equal to @var{num} | |
30512 | bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of | |
30513 | block compare is disabled. The default value is target-specific. | |
30514 | ||
d77de738 | 30515 | @opindex mblock-compare-inline-loop-limit |
ddf6fe37 | 30516 | @item -mblock-compare-inline-loop-limit=@var{num} |
d77de738 ML |
30517 | Generate an inline expansion using loop code for all block compares that |
30518 | are less than or equal to @var{num} bytes, but greater than the limit | |
30519 | for non-loop inline block compare expansion. If the block length is not | |
30520 | constant, at most @var{num} bytes will be compared before @code{memcmp} | |
30521 | is called to compare the remainder of the block. The default value is | |
30522 | target-specific. | |
30523 | ||
d77de738 | 30524 | @opindex mstring-compare-inline-limit |
ddf6fe37 | 30525 | @item -mstring-compare-inline-limit=@var{num} |
d77de738 ML |
30526 | Compare at most @var{num} string bytes with inline code. |
30527 | If the difference or end of string is not found at the | |
30528 | end of the inline compare a call to @code{strcmp} or @code{strncmp} will | |
30529 | take care of the rest of the comparison. The default is 64 bytes. | |
30530 | ||
d77de738 ML |
30531 | @opindex G |
30532 | @cindex smaller data references (PowerPC) | |
30533 | @cindex .sdata/.sdata2 references (PowerPC) | |
f33d7a88 | 30534 | @item -G @var{num} |
d77de738 ML |
30535 | On embedded PowerPC systems, put global and static items less than or |
30536 | equal to @var{num} bytes into the small data or BSS sections instead of | |
30537 | the normal data or BSS section. By default, @var{num} is 8. The | |
30538 | @option{-G @var{num}} switch is also passed to the linker. | |
30539 | All modules should be compiled with the same @option{-G @var{num}} value. | |
30540 | ||
d77de738 ML |
30541 | @opindex mregnames |
30542 | @opindex mno-regnames | |
ddf6fe37 AA |
30543 | @item -mregnames |
30544 | @itemx -mno-regnames | |
d77de738 ML |
30545 | On System V.4 and embedded PowerPC systems do (do not) emit register |
30546 | names in the assembly language output using symbolic forms. | |
30547 | ||
d77de738 ML |
30548 | @opindex mlongcall |
30549 | @opindex mno-longcall | |
ddf6fe37 AA |
30550 | @item -mlongcall |
30551 | @itemx -mno-longcall | |
d77de738 ML |
30552 | By default assume that all calls are far away so that a longer and more |
30553 | expensive calling sequence is required. This is required for calls | |
30554 | farther than 32 megabytes (33,554,432 bytes) from the current location. | |
30555 | A short call is generated if the compiler knows | |
30556 | the call cannot be that far away. This setting can be overridden by | |
30557 | the @code{shortcall} function attribute, or by @code{#pragma | |
30558 | longcall(0)}. | |
30559 | ||
30560 | Some linkers are capable of detecting out-of-range calls and generating | |
30561 | glue code on the fly. On these systems, long calls are unnecessary and | |
30562 | generate slower code. As of this writing, the AIX linker can do this, | |
30563 | as can the GNU linker for PowerPC/64. It is planned to add this feature | |
30564 | to the GNU linker for 32-bit PowerPC systems as well. | |
30565 | ||
30566 | On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers, | |
30567 | GCC can generate long calls using an inline PLT call sequence (see | |
30568 | @option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64 | |
30569 | ELFv1 (big-endian) do not support inline PLT calls. | |
30570 | ||
30571 | On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr | |
30572 | callee, L42}, plus a @dfn{branch island} (glue code). The two target | |
30573 | addresses represent the callee and the branch island. The | |
30574 | Darwin/PPC linker prefers the first address and generates a @code{bl | |
30575 | callee} if the PPC @code{bl} instruction reaches the callee directly; | |
30576 | otherwise, the linker generates @code{bl L42} to call the branch | |
30577 | island. The branch island is appended to the body of the | |
30578 | calling function; it computes the full 32-bit address of the callee | |
30579 | and jumps to it. | |
30580 | ||
30581 | On Mach-O (Darwin) systems, this option directs the compiler emit to | |
30582 | the glue for every direct call, and the Darwin linker decides whether | |
30583 | to use or discard it. | |
30584 | ||
30585 | In the future, GCC may ignore all longcall specifications | |
30586 | when the linker is known to generate glue. | |
30587 | ||
d77de738 ML |
30588 | @opindex mpltseq |
30589 | @opindex mno-pltseq | |
ddf6fe37 AA |
30590 | @item -mpltseq |
30591 | @itemx -mno-pltseq | |
d77de738 ML |
30592 | Implement (do not implement) -fno-plt and long calls using an inline |
30593 | PLT call sequence that supports lazy linking and long calls to | |
30594 | functions in dlopen'd shared libraries. Inline PLT calls are only | |
30595 | supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU | |
30596 | linkers, and are enabled by default if the support is detected when | |
30597 | configuring GCC, and, in the case of 32-bit PowerPC, if GCC is | |
30598 | configured with @option{--enable-secureplt}. @option{-mpltseq} code | |
30599 | and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be | |
30600 | linked together. | |
30601 | ||
d77de738 ML |
30602 | @opindex mtls-markers |
30603 | @opindex mno-tls-markers | |
ddf6fe37 AA |
30604 | @item -mtls-markers |
30605 | @itemx -mno-tls-markers | |
d77de738 ML |
30606 | Mark (do not mark) calls to @code{__tls_get_addr} with a relocation |
30607 | specifying the function argument. The relocation allows the linker to | |
30608 | reliably associate function call with argument setup instructions for | |
30609 | TLS optimization, which in turn allows GCC to better schedule the | |
30610 | sequence. | |
30611 | ||
ddf6fe37 | 30612 | @opindex mrecip |
d77de738 ML |
30613 | @item -mrecip |
30614 | @itemx -mno-recip | |
d77de738 ML |
30615 | This option enables use of the reciprocal estimate and |
30616 | reciprocal square root estimate instructions with additional | |
30617 | Newton-Raphson steps to increase precision instead of doing a divide or | |
30618 | square root and divide for floating-point arguments. You should use | |
30619 | the @option{-ffast-math} option when using @option{-mrecip} (or at | |
30620 | least @option{-funsafe-math-optimizations}, | |
30621 | @option{-ffinite-math-only}, @option{-freciprocal-math} and | |
30622 | @option{-fno-trapping-math}). Note that while the throughput of the | |
30623 | sequence is generally higher than the throughput of the non-reciprocal | |
30624 | instruction, the precision of the sequence can be decreased by up to 2 | |
30625 | ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square | |
30626 | roots. | |
30627 | ||
d77de738 | 30628 | @opindex mrecip=opt |
ddf6fe37 | 30629 | @item -mrecip=@var{opt} |
d77de738 ML |
30630 | This option controls which reciprocal estimate instructions |
30631 | may be used. @var{opt} is a comma-separated list of options, which may | |
30632 | be preceded by a @code{!} to invert the option: | |
30633 | ||
30634 | @table @samp | |
30635 | ||
30636 | @item all | |
30637 | Enable all estimate instructions. | |
30638 | ||
30639 | @item default | |
30640 | Enable the default instructions, equivalent to @option{-mrecip}. | |
30641 | ||
30642 | @item none | |
30643 | Disable all estimate instructions, equivalent to @option{-mno-recip}. | |
30644 | ||
30645 | @item div | |
30646 | Enable the reciprocal approximation instructions for both | |
30647 | single and double precision. | |
30648 | ||
30649 | @item divf | |
30650 | Enable the single-precision reciprocal approximation instructions. | |
30651 | ||
30652 | @item divd | |
30653 | Enable the double-precision reciprocal approximation instructions. | |
30654 | ||
30655 | @item rsqrt | |
30656 | Enable the reciprocal square root approximation instructions for both | |
30657 | single and double precision. | |
30658 | ||
30659 | @item rsqrtf | |
30660 | Enable the single-precision reciprocal square root approximation instructions. | |
30661 | ||
30662 | @item rsqrtd | |
30663 | Enable the double-precision reciprocal square root approximation instructions. | |
30664 | ||
30665 | @end table | |
30666 | ||
30667 | So, for example, @option{-mrecip=all,!rsqrtd} enables | |
30668 | all of the reciprocal estimate instructions, except for the | |
30669 | @code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions | |
30670 | which handle the double-precision reciprocal square root calculations. | |
30671 | ||
ddf6fe37 | 30672 | @opindex mrecip-precision |
d77de738 ML |
30673 | @item -mrecip-precision |
30674 | @itemx -mno-recip-precision | |
d77de738 ML |
30675 | Assume (do not assume) that the reciprocal estimate instructions |
30676 | provide higher-precision estimates than is mandated by the PowerPC | |
30677 | ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or | |
30678 | @option{-mcpu=power8} automatically selects @option{-mrecip-precision}. | |
30679 | The double-precision square root estimate instructions are not generated by | |
30680 | default on low-precision machines, since they do not provide an | |
30681 | estimate that converges after three steps. | |
30682 | ||
d77de738 | 30683 | @opindex mveclibabi |
ddf6fe37 | 30684 | @item -mveclibabi=@var{type} |
d77de738 ML |
30685 | Specifies the ABI type to use for vectorizing intrinsics using an |
30686 | external library. The only type supported at present is @samp{mass}, | |
30687 | which specifies to use IBM's Mathematical Acceleration Subsystem | |
30688 | (MASS) libraries for vectorizing intrinsics using external libraries. | |
30689 | GCC currently emits calls to @code{acosd2}, @code{acosf4}, | |
30690 | @code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4}, | |
30691 | @code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4}, | |
30692 | @code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4}, | |
30693 | @code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4}, | |
30694 | @code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4}, | |
30695 | @code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4}, | |
30696 | @code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4}, | |
30697 | @code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4}, | |
30698 | @code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4}, | |
30699 | @code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4}, | |
30700 | @code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2}, | |
30701 | @code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2}, | |
30702 | @code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code | |
30703 | for power7. Both @option{-ftree-vectorize} and | |
30704 | @option{-funsafe-math-optimizations} must also be enabled. The MASS | |
30705 | libraries must be specified at link time. | |
30706 | ||
ddf6fe37 | 30707 | @opindex mfriz |
d77de738 ML |
30708 | @item -mfriz |
30709 | @itemx -mno-friz | |
d77de738 ML |
30710 | Generate (do not generate) the @code{friz} instruction when the |
30711 | @option{-funsafe-math-optimizations} option is used to optimize | |
30712 | rounding of floating-point values to 64-bit integer and back to floating | |
30713 | point. The @code{friz} instruction does not return the same value if | |
30714 | the floating-point number is too large to fit in an integer. | |
30715 | ||
ddf6fe37 | 30716 | @opindex mpointers-to-nested-functions |
d77de738 ML |
30717 | @item -mpointers-to-nested-functions |
30718 | @itemx -mno-pointers-to-nested-functions | |
d77de738 ML |
30719 | Generate (do not generate) code to load up the static chain register |
30720 | (@code{r11}) when calling through a pointer on AIX and 64-bit Linux | |
30721 | systems where a function pointer points to a 3-word descriptor giving | |
30722 | the function address, TOC value to be loaded in register @code{r2}, and | |
30723 | static chain value to be loaded in register @code{r11}. The | |
30724 | @option{-mpointers-to-nested-functions} is on by default. You cannot | |
30725 | call through pointers to nested functions or pointers | |
30726 | to functions compiled in other languages that use the static chain if | |
30727 | you use @option{-mno-pointers-to-nested-functions}. | |
30728 | ||
ddf6fe37 | 30729 | @opindex msave-toc-indirect |
d77de738 ML |
30730 | @item -msave-toc-indirect |
30731 | @itemx -mno-save-toc-indirect | |
d77de738 ML |
30732 | Generate (do not generate) code to save the TOC value in the reserved |
30733 | stack location in the function prologue if the function calls through | |
30734 | a pointer on AIX and 64-bit Linux systems. If the TOC value is not | |
30735 | saved in the prologue, it is saved just before the call through the | |
30736 | pointer. The @option{-mno-save-toc-indirect} option is the default. | |
30737 | ||
ddf6fe37 | 30738 | @opindex mcompat-align-parm |
d77de738 ML |
30739 | @item -mcompat-align-parm |
30740 | @itemx -mno-compat-align-parm | |
d77de738 ML |
30741 | Generate (do not generate) code to pass structure parameters with a |
30742 | maximum alignment of 64 bits, for compatibility with older versions | |
30743 | of GCC. | |
30744 | ||
30745 | Older versions of GCC (prior to 4.9.0) incorrectly did not align a | |
30746 | structure parameter on a 128-bit boundary when that structure contained | |
30747 | a member requiring 128-bit alignment. This is corrected in more | |
30748 | recent versions of GCC. This option may be used to generate code | |
30749 | that is compatible with functions compiled with older versions of | |
30750 | GCC. | |
30751 | ||
30752 | The @option{-mno-compat-align-parm} option is the default. | |
30753 | ||
d77de738 ML |
30754 | @opindex mstack-protector-guard |
30755 | @opindex mstack-protector-guard-reg | |
30756 | @opindex mstack-protector-guard-offset | |
30757 | @opindex mstack-protector-guard-symbol | |
ddf6fe37 AA |
30758 | @item -mstack-protector-guard=@var{guard} |
30759 | @itemx -mstack-protector-guard-reg=@var{reg} | |
30760 | @itemx -mstack-protector-guard-offset=@var{offset} | |
30761 | @itemx -mstack-protector-guard-symbol=@var{symbol} | |
d77de738 ML |
30762 | Generate stack protection code using canary at @var{guard}. Supported |
30763 | locations are @samp{global} for global canary or @samp{tls} for per-thread | |
30764 | canary in the TLS block (the default with GNU libc version 2.4 or later). | |
30765 | ||
30766 | With the latter choice the options | |
30767 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
30768 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
30769 | which register to use as base register for reading the canary, and from what | |
30770 | offset from that base register. The default for those is as specified in the | |
30771 | relevant ABI. @option{-mstack-protector-guard-symbol=@var{symbol}} overrides | |
30772 | the offset with a symbol reference to a canary in the TLS block. | |
30773 | ||
d77de738 ML |
30774 | @opindex mpcrel |
30775 | @opindex mno-pcrel | |
ddf6fe37 AA |
30776 | @item -mpcrel |
30777 | @itemx -mno-pcrel | |
d77de738 ML |
30778 | Generate (do not generate) pc-relative addressing. The @option{-mpcrel} |
30779 | option requires that the medium code model (@option{-mcmodel=medium}) | |
30780 | and prefixed addressing (@option{-mprefixed}) options are enabled. | |
30781 | ||
d77de738 ML |
30782 | @opindex mprefixed |
30783 | @opindex mno-prefixed | |
ddf6fe37 AA |
30784 | @item -mprefixed |
30785 | @itemx -mno-prefixed | |
d77de738 ML |
30786 | Generate (do not generate) addressing modes using prefixed load and |
30787 | store instructions. The @option{-mprefixed} option requires that | |
30788 | the option @option{-mcpu=power10} (or later) is enabled. | |
30789 | ||
d77de738 ML |
30790 | @opindex mmma |
30791 | @opindex mno-mma | |
ddf6fe37 AA |
30792 | @item -mmma |
30793 | @itemx -mno-mma | |
d77de738 ML |
30794 | Generate (do not generate) the MMA instructions. The @option{-mma} |
30795 | option requires that the option @option{-mcpu=power10} (or later) | |
30796 | is enabled. | |
30797 | ||
d77de738 ML |
30798 | @opindex mrop-protect |
30799 | @opindex mno-rop-protect | |
ddf6fe37 AA |
30800 | @item -mrop-protect |
30801 | @itemx -mno-rop-protect | |
d77de738 ML |
30802 | Generate (do not generate) ROP protection instructions when the target |
30803 | processor supports them. Currently this option disables the shrink-wrap | |
30804 | optimization (@option{-fshrink-wrap}). | |
30805 | ||
d77de738 ML |
30806 | @opindex mprivileged |
30807 | @opindex mno-privileged | |
ddf6fe37 AA |
30808 | @item -mprivileged |
30809 | @itemx -mno-privileged | |
d77de738 ML |
30810 | Generate (do not generate) code that will run in privileged state. |
30811 | ||
d77de738 ML |
30812 | @opindex block-ops-unaligned-vsx |
30813 | @opindex no-block-ops-unaligned-vsx | |
ddf6fe37 AA |
30814 | @item -mblock-ops-unaligned-vsx |
30815 | @itemx -mno-block-ops-unaligned-vsx | |
d77de738 ML |
30816 | Generate (do not generate) unaligned vsx loads and stores for |
30817 | inline expansion of @code{memcpy} and @code{memmove}. | |
30818 | ||
30819 | @item --param rs6000-vect-unroll-limit= | |
30820 | The vectorizer will check with target information to determine whether it | |
30821 | would be beneficial to unroll the main vectorized loop and by how much. This | |
30822 | parameter sets the upper bound of how much the vectorizer will unroll the main | |
30823 | loop. The default value is four. | |
30824 | ||
30825 | @end table | |
30826 | ||
30827 | @node RX Options | |
30828 | @subsection RX Options | |
30829 | @cindex RX Options | |
30830 | ||
30831 | These command-line options are defined for RX targets: | |
30832 | ||
30833 | @table @gcctabopt | |
d77de738 ML |
30834 | @opindex m64bit-doubles |
30835 | @opindex m32bit-doubles | |
ddf6fe37 AA |
30836 | @item -m64bit-doubles |
30837 | @itemx -m32bit-doubles | |
d77de738 ML |
30838 | Make the @code{double} data type be 64 bits (@option{-m64bit-doubles}) |
30839 | or 32 bits (@option{-m32bit-doubles}) in size. The default is | |
30840 | @option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only | |
30841 | works on 32-bit values, which is why the default is | |
30842 | @option{-m32bit-doubles}. | |
30843 | ||
d77de738 ML |
30844 | @opindex fpu |
30845 | @opindex nofpu | |
ddf6fe37 AA |
30846 | @item -fpu |
30847 | @itemx -nofpu | |
d77de738 ML |
30848 | Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX |
30849 | floating-point hardware. The default is enabled for the RX600 | |
30850 | series and disabled for the RX200 series. | |
30851 | ||
30852 | Floating-point instructions are only generated for 32-bit floating-point | |
30853 | values, however, so the FPU hardware is not used for doubles if the | |
30854 | @option{-m64bit-doubles} option is used. | |
30855 | ||
30856 | @emph{Note} If the @option{-fpu} option is enabled then | |
30857 | @option{-funsafe-math-optimizations} is also enabled automatically. | |
30858 | This is because the RX FPU instructions are themselves unsafe. | |
30859 | ||
d77de738 | 30860 | @opindex mcpu |
ddf6fe37 | 30861 | @item -mcpu=@var{name} |
d77de738 ML |
30862 | Selects the type of RX CPU to be targeted. Currently three types are |
30863 | supported, the generic @samp{RX600} and @samp{RX200} series hardware and | |
30864 | the specific @samp{RX610} CPU. The default is @samp{RX600}. | |
30865 | ||
30866 | The only difference between @samp{RX600} and @samp{RX610} is that the | |
30867 | @samp{RX610} does not support the @code{MVTIPL} instruction. | |
30868 | ||
30869 | The @samp{RX200} series does not have a hardware floating-point unit | |
30870 | and so @option{-nofpu} is enabled by default when this type is | |
30871 | selected. | |
30872 | ||
d77de738 ML |
30873 | @opindex mbig-endian-data |
30874 | @opindex mlittle-endian-data | |
ddf6fe37 AA |
30875 | @item -mbig-endian-data |
30876 | @itemx -mlittle-endian-data | |
d77de738 ML |
30877 | Store data (but not code) in the big-endian format. The default is |
30878 | @option{-mlittle-endian-data}, i.e.@: to store data in the little-endian | |
30879 | format. | |
30880 | ||
d77de738 | 30881 | @opindex msmall-data-limit |
ddf6fe37 | 30882 | @item -msmall-data-limit=@var{N} |
d77de738 ML |
30883 | Specifies the maximum size in bytes of global and static variables |
30884 | which can be placed into the small data area. Using the small data | |
30885 | area can lead to smaller and faster code, but the size of area is | |
30886 | limited and it is up to the programmer to ensure that the area does | |
30887 | not overflow. Also when the small data area is used one of the RX's | |
30888 | registers (usually @code{r13}) is reserved for use pointing to this | |
30889 | area, so it is no longer available for use by the compiler. This | |
30890 | could result in slower and/or larger code if variables are pushed onto | |
30891 | the stack instead of being held in this register. | |
30892 | ||
30893 | Note, common variables (variables that have not been initialized) and | |
30894 | constants are not placed into the small data area as they are assigned | |
30895 | to other sections in the output executable. | |
30896 | ||
30897 | The default value is zero, which disables this feature. Note, this | |
30898 | feature is not enabled by default with higher optimization levels | |
30899 | (@option{-O2} etc) because of the potentially detrimental effects of | |
30900 | reserving a register. It is up to the programmer to experiment and | |
30901 | discover whether this feature is of benefit to their program. See the | |
30902 | description of the @option{-mpid} option for a description of how the | |
30903 | actual register to hold the small data area pointer is chosen. | |
30904 | ||
d77de738 ML |
30905 | @opindex msim |
30906 | @opindex mno-sim | |
ddf6fe37 AA |
30907 | @item -msim |
30908 | @itemx -mno-sim | |
d77de738 ML |
30909 | Use the simulator runtime. The default is to use the libgloss |
30910 | board-specific runtime. | |
30911 | ||
d77de738 ML |
30912 | @opindex mas100-syntax |
30913 | @opindex mno-as100-syntax | |
ddf6fe37 AA |
30914 | @item -mas100-syntax |
30915 | @itemx -mno-as100-syntax | |
d77de738 ML |
30916 | When generating assembler output use a syntax that is compatible with |
30917 | Renesas's AS100 assembler. This syntax can also be handled by the GAS | |
30918 | assembler, but it has some restrictions so it is not generated by default. | |
30919 | ||
d77de738 | 30920 | @opindex mmax-constant-size |
ddf6fe37 | 30921 | @item -mmax-constant-size=@var{N} |
d77de738 ML |
30922 | Specifies the maximum size, in bytes, of a constant that can be used as |
30923 | an operand in a RX instruction. Although the RX instruction set does | |
30924 | allow constants of up to 4 bytes in length to be used in instructions, | |
30925 | a longer value equates to a longer instruction. Thus in some | |
30926 | circumstances it can be beneficial to restrict the size of constants | |
30927 | that are used in instructions. Constants that are too big are instead | |
30928 | placed into a constant pool and referenced via register indirection. | |
30929 | ||
30930 | The value @var{N} can be between 0 and 4. A value of 0 (the default) | |
30931 | or 4 means that constants of any size are allowed. | |
30932 | ||
d77de738 | 30933 | @opindex mrelax |
ddf6fe37 | 30934 | @item -mrelax |
d77de738 ML |
30935 | Enable linker relaxation. Linker relaxation is a process whereby the |
30936 | linker attempts to reduce the size of a program by finding shorter | |
30937 | versions of various instructions. Disabled by default. | |
30938 | ||
d77de738 | 30939 | @opindex mint-register |
ddf6fe37 | 30940 | @item -mint-register=@var{N} |
d77de738 ML |
30941 | Specify the number of registers to reserve for fast interrupt handler |
30942 | functions. The value @var{N} can be between 0 and 4. A value of 1 | |
30943 | means that register @code{r13} is reserved for the exclusive use | |
30944 | of fast interrupt handlers. A value of 2 reserves @code{r13} and | |
30945 | @code{r12}. A value of 3 reserves @code{r13}, @code{r12} and | |
30946 | @code{r11}, and a value of 4 reserves @code{r13} through @code{r10}. | |
30947 | A value of 0, the default, does not reserve any registers. | |
30948 | ||
d77de738 | 30949 | @opindex msave-acc-in-interrupts |
ddf6fe37 | 30950 | @item -msave-acc-in-interrupts |
d77de738 ML |
30951 | Specifies that interrupt handler functions should preserve the |
30952 | accumulator register. This is only necessary if normal code might use | |
30953 | the accumulator register, for example because it performs 64-bit | |
30954 | multiplications. The default is to ignore the accumulator as this | |
30955 | makes the interrupt handlers faster. | |
30956 | ||
d77de738 ML |
30957 | @opindex mpid |
30958 | @opindex mno-pid | |
ddf6fe37 AA |
30959 | @item -mpid |
30960 | @itemx -mno-pid | |
d77de738 ML |
30961 | Enables the generation of position independent data. When enabled any |
30962 | access to constant data is done via an offset from a base address | |
30963 | held in a register. This allows the location of constant data to be | |
30964 | determined at run time without requiring the executable to be | |
30965 | relocated, which is a benefit to embedded applications with tight | |
30966 | memory constraints. Data that can be modified is not affected by this | |
30967 | option. | |
30968 | ||
30969 | Note, using this feature reserves a register, usually @code{r13}, for | |
30970 | the constant data base address. This can result in slower and/or | |
30971 | larger code, especially in complicated functions. | |
30972 | ||
30973 | The actual register chosen to hold the constant data base address | |
30974 | depends upon whether the @option{-msmall-data-limit} and/or the | |
30975 | @option{-mint-register} command-line options are enabled. Starting | |
30976 | with register @code{r13} and proceeding downwards, registers are | |
30977 | allocated first to satisfy the requirements of @option{-mint-register}, | |
30978 | then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it | |
30979 | is possible for the small data area register to be @code{r8} if both | |
30980 | @option{-mint-register=4} and @option{-mpid} are specified on the | |
30981 | command line. | |
30982 | ||
30983 | By default this feature is not enabled. The default can be restored | |
30984 | via the @option{-mno-pid} command-line option. | |
30985 | ||
d77de738 ML |
30986 | @opindex mno-warn-multiple-fast-interrupts |
30987 | @opindex mwarn-multiple-fast-interrupts | |
ddf6fe37 AA |
30988 | @item -mno-warn-multiple-fast-interrupts |
30989 | @itemx -mwarn-multiple-fast-interrupts | |
d77de738 ML |
30990 | Prevents GCC from issuing a warning message if it finds more than one |
30991 | fast interrupt handler when it is compiling a file. The default is to | |
30992 | issue a warning for each extra fast interrupt handler found, as the RX | |
30993 | only supports one such interrupt. | |
30994 | ||
d77de738 ML |
30995 | @opindex mallow-string-insns |
30996 | @opindex mno-allow-string-insns | |
ddf6fe37 AA |
30997 | @item -mallow-string-insns |
30998 | @itemx -mno-allow-string-insns | |
d77de738 ML |
30999 | Enables or disables the use of the string manipulation instructions |
31000 | @code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL} | |
31001 | @code{SWHILE} and also the @code{RMPA} instruction. These | |
31002 | instructions may prefetch data, which is not safe to do if accessing | |
31003 | an I/O register. (See section 12.2.7 of the RX62N Group User's Manual | |
31004 | for more information). | |
31005 | ||
31006 | The default is to allow these instructions, but it is not possible for | |
31007 | GCC to reliably detect all circumstances where a string instruction | |
31008 | might be used to access an I/O register, so their use cannot be | |
31009 | disabled automatically. Instead it is reliant upon the programmer to | |
31010 | use the @option{-mno-allow-string-insns} option if their program | |
31011 | accesses I/O space. | |
31012 | ||
31013 | When the instructions are enabled GCC defines the C preprocessor | |
31014 | symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the | |
31015 | symbol @code{__RX_DISALLOW_STRING_INSNS__}. | |
31016 | ||
d77de738 ML |
31017 | @opindex mjsr |
31018 | @opindex mno-jsr | |
ddf6fe37 AA |
31019 | @item -mjsr |
31020 | @itemx -mno-jsr | |
d77de738 ML |
31021 | Use only (or not only) @code{JSR} instructions to access functions. |
31022 | This option can be used when code size exceeds the range of @code{BSR} | |
31023 | instructions. Note that @option{-mno-jsr} does not mean to not use | |
31024 | @code{JSR} but instead means that any type of branch may be used. | |
31025 | @end table | |
31026 | ||
31027 | @emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}} | |
31028 | has special significance to the RX port when used with the | |
31029 | @code{interrupt} function attribute. This attribute indicates a | |
31030 | function intended to process fast interrupts. GCC ensures | |
31031 | that it only uses the registers @code{r10}, @code{r11}, @code{r12} | |
31032 | and/or @code{r13} and only provided that the normal use of the | |
31033 | corresponding registers have been restricted via the | |
31034 | @option{-ffixed-@var{reg}} or @option{-mint-register} command-line | |
31035 | options. | |
31036 | ||
31037 | @node S/390 and zSeries Options | |
31038 | @subsection S/390 and zSeries Options | |
31039 | @cindex S/390 and zSeries Options | |
31040 | ||
31041 | These are the @samp{-m} options defined for the S/390 and zSeries architecture. | |
31042 | ||
31043 | @table @gcctabopt | |
d77de738 ML |
31044 | @opindex mhard-float |
31045 | @opindex msoft-float | |
ddf6fe37 AA |
31046 | @item -mhard-float |
31047 | @itemx -msoft-float | |
d77de738 ML |
31048 | Use (do not use) the hardware floating-point instructions and registers |
31049 | for floating-point operations. When @option{-msoft-float} is specified, | |
31050 | functions in @file{libgcc.a} are used to perform floating-point | |
31051 | operations. When @option{-mhard-float} is specified, the compiler | |
31052 | generates IEEE floating-point instructions. This is the default. | |
31053 | ||
d77de738 ML |
31054 | @opindex mhard-dfp |
31055 | @opindex mno-hard-dfp | |
ddf6fe37 AA |
31056 | @item -mhard-dfp |
31057 | @itemx -mno-hard-dfp | |
d77de738 ML |
31058 | Use (do not use) the hardware decimal-floating-point instructions for |
31059 | decimal-floating-point operations. When @option{-mno-hard-dfp} is | |
31060 | specified, functions in @file{libgcc.a} are used to perform | |
31061 | decimal-floating-point operations. When @option{-mhard-dfp} is | |
31062 | specified, the compiler generates decimal-floating-point hardware | |
31063 | instructions. This is the default for @option{-march=z9-ec} or higher. | |
31064 | ||
d77de738 ML |
31065 | @opindex mlong-double-64 |
31066 | @opindex mlong-double-128 | |
ddf6fe37 AA |
31067 | @item -mlong-double-64 |
31068 | @itemx -mlong-double-128 | |
d77de738 ML |
31069 | These switches control the size of @code{long double} type. A size |
31070 | of 64 bits makes the @code{long double} type equivalent to the @code{double} | |
31071 | type. This is the default. | |
31072 | ||
d77de738 ML |
31073 | @opindex mbackchain |
31074 | @opindex mno-backchain | |
ddf6fe37 AA |
31075 | @item -mbackchain |
31076 | @itemx -mno-backchain | |
d77de738 ML |
31077 | Store (do not store) the address of the caller's frame as backchain pointer |
31078 | into the callee's stack frame. | |
31079 | A backchain may be needed to allow debugging using tools that do not understand | |
31080 | DWARF call frame information. | |
31081 | When @option{-mno-packed-stack} is in effect, the backchain pointer is stored | |
31082 | at the bottom of the stack frame; when @option{-mpacked-stack} is in effect, | |
31083 | the backchain is placed into the topmost word of the 96/160 byte register | |
31084 | save area. | |
31085 | ||
31086 | In general, code compiled with @option{-mbackchain} is call-compatible with | |
31087 | code compiled with @option{-mno-backchain}; however, use of the backchain | |
31088 | for debugging purposes usually requires that the whole binary is built with | |
31089 | @option{-mbackchain}. Note that the combination of @option{-mbackchain}, | |
31090 | @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order | |
31091 | to build a linux kernel use @option{-msoft-float}. | |
31092 | ||
31093 | The default is to not maintain the backchain. | |
31094 | ||
d77de738 ML |
31095 | @opindex mpacked-stack |
31096 | @opindex mno-packed-stack | |
ddf6fe37 AA |
31097 | @item -mpacked-stack |
31098 | @itemx -mno-packed-stack | |
d77de738 ML |
31099 | Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is |
31100 | specified, the compiler uses the all fields of the 96/160 byte register save | |
31101 | area only for their default purpose; unused fields still take up stack space. | |
31102 | When @option{-mpacked-stack} is specified, register save slots are densely | |
31103 | packed at the top of the register save area; unused space is reused for other | |
31104 | purposes, allowing for more efficient use of the available stack space. | |
31105 | However, when @option{-mbackchain} is also in effect, the topmost word of | |
31106 | the save area is always used to store the backchain, and the return address | |
31107 | register is always saved two words below the backchain. | |
31108 | ||
31109 | As long as the stack frame backchain is not used, code generated with | |
31110 | @option{-mpacked-stack} is call-compatible with code generated with | |
31111 | @option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for | |
31112 | S/390 or zSeries generated code that uses the stack frame backchain at run | |
31113 | time, not just for debugging purposes. Such code is not call-compatible | |
31114 | with code compiled with @option{-mpacked-stack}. Also, note that the | |
31115 | combination of @option{-mbackchain}, | |
31116 | @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order | |
31117 | to build a linux kernel use @option{-msoft-float}. | |
31118 | ||
31119 | The default is to not use the packed stack layout. | |
31120 | ||
d77de738 ML |
31121 | @opindex msmall-exec |
31122 | @opindex mno-small-exec | |
ddf6fe37 AA |
31123 | @item -msmall-exec |
31124 | @itemx -mno-small-exec | |
d77de738 ML |
31125 | Generate (or do not generate) code using the @code{bras} instruction |
31126 | to do subroutine calls. | |
31127 | This only works reliably if the total executable size does not | |
31128 | exceed 64k. The default is to use the @code{basr} instruction instead, | |
31129 | which does not have this limitation. | |
31130 | ||
d77de738 ML |
31131 | @opindex m64 |
31132 | @opindex m31 | |
ddf6fe37 AA |
31133 | @item -m64 |
31134 | @itemx -m31 | |
d77de738 ML |
31135 | When @option{-m31} is specified, generate code compliant to the |
31136 | GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate | |
31137 | code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in | |
31138 | particular to generate 64-bit instructions. For the @samp{s390} | |
31139 | targets, the default is @option{-m31}, while the @samp{s390x} | |
31140 | targets default to @option{-m64}. | |
31141 | ||
d77de738 ML |
31142 | @opindex mzarch |
31143 | @opindex mesa | |
ddf6fe37 AA |
31144 | @item -mzarch |
31145 | @itemx -mesa | |
d77de738 ML |
31146 | When @option{-mzarch} is specified, generate code using the |
31147 | instructions available on z/Architecture. | |
31148 | When @option{-mesa} is specified, generate code using the | |
31149 | instructions available on ESA/390. Note that @option{-mesa} is | |
31150 | not possible with @option{-m64}. | |
31151 | When generating code compliant to the GNU/Linux for S/390 ABI, | |
31152 | the default is @option{-mesa}. When generating code compliant | |
31153 | to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}. | |
31154 | ||
d77de738 ML |
31155 | @opindex mhtm |
31156 | @opindex mno-htm | |
ddf6fe37 AA |
31157 | @item -mhtm |
31158 | @itemx -mno-htm | |
d77de738 ML |
31159 | The @option{-mhtm} option enables a set of builtins making use of |
31160 | instructions available with the transactional execution facility | |
31161 | introduced with the IBM zEnterprise EC12 machine generation | |
31162 | @ref{S/390 System z Built-in Functions}. | |
31163 | @option{-mhtm} is enabled by default when using @option{-march=zEC12}. | |
31164 | ||
d77de738 ML |
31165 | @opindex mvx |
31166 | @opindex mno-vx | |
ddf6fe37 AA |
31167 | @item -mvx |
31168 | @itemx -mno-vx | |
d77de738 ML |
31169 | When @option{-mvx} is specified, generate code using the instructions |
31170 | available with the vector extension facility introduced with the IBM | |
31171 | z13 machine generation. | |
31172 | This option changes the ABI for some vector type values with regard to | |
31173 | alignment and calling conventions. In case vector type values are | |
31174 | being used in an ABI-relevant context a GAS @samp{.gnu_attribute} | |
31175 | command will be added to mark the resulting binary with the ABI used. | |
31176 | @option{-mvx} is enabled by default when using @option{-march=z13}. | |
31177 | ||
d77de738 ML |
31178 | @opindex mzvector |
31179 | @opindex mno-zvector | |
ddf6fe37 AA |
31180 | @item -mzvector |
31181 | @itemx -mno-zvector | |
d77de738 ML |
31182 | The @option{-mzvector} option enables vector language extensions and |
31183 | builtins using instructions available with the vector extension | |
31184 | facility introduced with the IBM z13 machine generation. | |
31185 | This option adds support for @samp{vector} to be used as a keyword to | |
31186 | define vector type variables and arguments. @samp{vector} is only | |
31187 | available when GNU extensions are enabled. It will not be expanded | |
31188 | when requesting strict standard compliance e.g.@: with @option{-std=c99}. | |
31189 | In addition to the GCC low-level builtins @option{-mzvector} enables | |
31190 | a set of builtins added for compatibility with AltiVec-style | |
31191 | implementations like Power and Cell. In order to make use of these | |
31192 | builtins the header file @file{vecintrin.h} needs to be included. | |
31193 | @option{-mzvector} is disabled by default. | |
31194 | ||
d77de738 ML |
31195 | @opindex mmvcle |
31196 | @opindex mno-mvcle | |
ddf6fe37 AA |
31197 | @item -mmvcle |
31198 | @itemx -mno-mvcle | |
d77de738 ML |
31199 | Generate (or do not generate) code using the @code{mvcle} instruction |
31200 | to perform block moves. When @option{-mno-mvcle} is specified, | |
31201 | use a @code{mvc} loop instead. This is the default unless optimizing for | |
31202 | size. | |
31203 | ||
d77de738 ML |
31204 | @opindex mdebug |
31205 | @opindex mno-debug | |
ddf6fe37 AA |
31206 | @item -mdebug |
31207 | @itemx -mno-debug | |
d77de738 ML |
31208 | Print (or do not print) additional debug information when compiling. |
31209 | The default is to not print debug information. | |
31210 | ||
d77de738 | 31211 | @opindex march |
ddf6fe37 | 31212 | @item -march=@var{cpu-type} |
d77de738 ML |
31213 | Generate code that runs on @var{cpu-type}, which is the name of a |
31214 | system representing a certain processor type. Possible values for | |
31215 | @var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6}, | |
31216 | @samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8}, | |
31217 | @samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11}, | |
31218 | @samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13}, | |
31219 | @samp{z16}/@samp{arch14}, and @samp{native}. | |
31220 | ||
31221 | The default is @option{-march=z900}. | |
31222 | ||
31223 | Specifying @samp{native} as cpu type can be used to select the best | |
31224 | architecture option for the host processor. | |
31225 | @option{-march=native} has no effect if GCC does not recognize the | |
31226 | processor. | |
31227 | ||
d77de738 | 31228 | @opindex mtune |
ddf6fe37 | 31229 | @item -mtune=@var{cpu-type} |
d77de738 ML |
31230 | Tune to @var{cpu-type} everything applicable about the generated code, |
31231 | except for the ABI and the set of available instructions. | |
31232 | The list of @var{cpu-type} values is the same as for @option{-march}. | |
31233 | The default is the value used for @option{-march}. | |
31234 | ||
d77de738 ML |
31235 | @opindex mtpf-trace |
31236 | @opindex mno-tpf-trace | |
ddf6fe37 AA |
31237 | @item -mtpf-trace |
31238 | @itemx -mno-tpf-trace | |
d77de738 ML |
31239 | Generate code that adds (does not add) in TPF OS specific branches to trace |
31240 | routines in the operating system. This option is off by default, even | |
31241 | when compiling for the TPF OS@. | |
31242 | ||
d77de738 ML |
31243 | @opindex mtpf-trace-skip |
31244 | @opindex mno-tpf-trace-skip | |
ddf6fe37 AA |
31245 | @item -mtpf-trace-skip |
31246 | @itemx -mno-tpf-trace-skip | |
d77de738 ML |
31247 | Generate code that changes (does not change) the default branch |
31248 | targets enabled by @option{-mtpf-trace} to point to specialized trace | |
31249 | routines providing the ability of selectively skipping function trace | |
31250 | entries for the TPF OS. This option is off by default, even when | |
31251 | compiling for the TPF OS and specifying @option{-mtpf-trace}. | |
31252 | ||
d77de738 ML |
31253 | @opindex mfused-madd |
31254 | @opindex mno-fused-madd | |
ddf6fe37 AA |
31255 | @item -mfused-madd |
31256 | @itemx -mno-fused-madd | |
d77de738 ML |
31257 | Generate code that uses (does not use) the floating-point multiply and |
31258 | accumulate instructions. These instructions are generated by default if | |
31259 | hardware floating point is used. | |
31260 | ||
d77de738 | 31261 | @opindex mwarn-framesize |
ddf6fe37 | 31262 | @item -mwarn-framesize=@var{framesize} |
d77de738 ML |
31263 | Emit a warning if the current function exceeds the given frame size. Because |
31264 | this is a compile-time check it doesn't need to be a real problem when the program | |
31265 | runs. It is intended to identify functions that most probably cause | |
31266 | a stack overflow. It is useful to be used in an environment with limited stack | |
31267 | size e.g.@: the linux kernel. | |
31268 | ||
d77de738 | 31269 | @opindex mwarn-dynamicstack |
ddf6fe37 | 31270 | @item -mwarn-dynamicstack |
d77de738 ML |
31271 | Emit a warning if the function calls @code{alloca} or uses dynamically-sized |
31272 | arrays. This is generally a bad idea with a limited stack size. | |
31273 | ||
d77de738 ML |
31274 | @opindex mstack-guard |
31275 | @opindex mstack-size | |
ddf6fe37 AA |
31276 | @item -mstack-guard=@var{stack-guard} |
31277 | @itemx -mstack-size=@var{stack-size} | |
d77de738 ML |
31278 | If these options are provided the S/390 back end emits additional instructions in |
31279 | the function prologue that trigger a trap if the stack size is @var{stack-guard} | |
31280 | bytes above the @var{stack-size} (remember that the stack on S/390 grows downward). | |
31281 | If the @var{stack-guard} option is omitted the smallest power of 2 larger than | |
31282 | the frame size of the compiled function is chosen. | |
31283 | These options are intended to be used to help debugging stack overflow problems. | |
31284 | The additionally emitted code causes only little overhead and hence can also be | |
31285 | used in production-like systems without greater performance degradation. The given | |
31286 | values have to be exact powers of 2 and @var{stack-size} has to be greater than | |
31287 | @var{stack-guard} without exceeding 64k. | |
31288 | In order to be efficient the extra code makes the assumption that the stack starts | |
31289 | at an address aligned to the value given by @var{stack-size}. | |
31290 | The @var{stack-guard} option can only be used in conjunction with @var{stack-size}. | |
31291 | ||
d77de738 | 31292 | @opindex mhotpatch |
ddf6fe37 | 31293 | @item -mhotpatch=@var{pre-halfwords},@var{post-halfwords} |
d77de738 ML |
31294 | If the hotpatch option is enabled, a ``hot-patching'' function |
31295 | prologue is generated for all functions in the compilation unit. | |
31296 | The funtion label is prepended with the given number of two-byte | |
31297 | NOP instructions (@var{pre-halfwords}, maximum 1000000). After | |
31298 | the label, 2 * @var{post-halfwords} bytes are appended, using the | |
31299 | largest NOP like instructions the architecture allows (maximum | |
31300 | 1000000). | |
31301 | ||
31302 | If both arguments are zero, hotpatching is disabled. | |
31303 | ||
31304 | This option can be overridden for individual functions with the | |
31305 | @code{hotpatch} attribute. | |
31306 | @end table | |
31307 | ||
d77de738 ML |
31308 | @node SH Options |
31309 | @subsection SH Options | |
31310 | ||
31311 | These @samp{-m} options are defined for the SH implementations: | |
31312 | ||
31313 | @table @gcctabopt | |
d77de738 | 31314 | @opindex m1 |
ddf6fe37 | 31315 | @item -m1 |
d77de738 ML |
31316 | Generate code for the SH1. |
31317 | ||
d77de738 | 31318 | @opindex m2 |
ddf6fe37 | 31319 | @item -m2 |
d77de738 ML |
31320 | Generate code for the SH2. |
31321 | ||
31322 | @item -m2e | |
31323 | Generate code for the SH2e. | |
31324 | ||
d77de738 | 31325 | @opindex m2a-nofpu |
ddf6fe37 | 31326 | @item -m2a-nofpu |
d77de738 ML |
31327 | Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way |
31328 | that the floating-point unit is not used. | |
31329 | ||
d77de738 | 31330 | @opindex m2a-single-only |
ddf6fe37 | 31331 | @item -m2a-single-only |
d77de738 ML |
31332 | Generate code for the SH2a-FPU, in such a way that no double-precision |
31333 | floating-point operations are used. | |
31334 | ||
d77de738 | 31335 | @opindex m2a-single |
ddf6fe37 | 31336 | @item -m2a-single |
d77de738 ML |
31337 | Generate code for the SH2a-FPU assuming the floating-point unit is in |
31338 | single-precision mode by default. | |
31339 | ||
d77de738 | 31340 | @opindex m2a |
ddf6fe37 | 31341 | @item -m2a |
d77de738 ML |
31342 | Generate code for the SH2a-FPU assuming the floating-point unit is in |
31343 | double-precision mode by default. | |
31344 | ||
d77de738 | 31345 | @opindex m3 |
ddf6fe37 | 31346 | @item -m3 |
d77de738 ML |
31347 | Generate code for the SH3. |
31348 | ||
d77de738 | 31349 | @opindex m3e |
ddf6fe37 | 31350 | @item -m3e |
d77de738 ML |
31351 | Generate code for the SH3e. |
31352 | ||
d77de738 | 31353 | @opindex m4-nofpu |
ddf6fe37 | 31354 | @item -m4-nofpu |
d77de738 ML |
31355 | Generate code for the SH4 without a floating-point unit. |
31356 | ||
d77de738 | 31357 | @opindex m4-single-only |
ddf6fe37 | 31358 | @item -m4-single-only |
d77de738 ML |
31359 | Generate code for the SH4 with a floating-point unit that only |
31360 | supports single-precision arithmetic. | |
31361 | ||
d77de738 | 31362 | @opindex m4-single |
ddf6fe37 | 31363 | @item -m4-single |
d77de738 ML |
31364 | Generate code for the SH4 assuming the floating-point unit is in |
31365 | single-precision mode by default. | |
31366 | ||
d77de738 | 31367 | @opindex m4 |
ddf6fe37 | 31368 | @item -m4 |
d77de738 ML |
31369 | Generate code for the SH4. |
31370 | ||
d77de738 | 31371 | @opindex m4-100 |
ddf6fe37 | 31372 | @item -m4-100 |
d77de738 ML |
31373 | Generate code for SH4-100. |
31374 | ||
d77de738 | 31375 | @opindex m4-100-nofpu |
ddf6fe37 | 31376 | @item -m4-100-nofpu |
d77de738 ML |
31377 | Generate code for SH4-100 in such a way that the |
31378 | floating-point unit is not used. | |
31379 | ||
d77de738 | 31380 | @opindex m4-100-single |
ddf6fe37 | 31381 | @item -m4-100-single |
d77de738 ML |
31382 | Generate code for SH4-100 assuming the floating-point unit is in |
31383 | single-precision mode by default. | |
31384 | ||
d77de738 | 31385 | @opindex m4-100-single-only |
ddf6fe37 | 31386 | @item -m4-100-single-only |
d77de738 ML |
31387 | Generate code for SH4-100 in such a way that no double-precision |
31388 | floating-point operations are used. | |
31389 | ||
d77de738 | 31390 | @opindex m4-200 |
ddf6fe37 | 31391 | @item -m4-200 |
d77de738 ML |
31392 | Generate code for SH4-200. |
31393 | ||
d77de738 | 31394 | @opindex m4-200-nofpu |
ddf6fe37 | 31395 | @item -m4-200-nofpu |
d77de738 ML |
31396 | Generate code for SH4-200 without in such a way that the |
31397 | floating-point unit is not used. | |
31398 | ||
d77de738 | 31399 | @opindex m4-200-single |
ddf6fe37 | 31400 | @item -m4-200-single |
d77de738 ML |
31401 | Generate code for SH4-200 assuming the floating-point unit is in |
31402 | single-precision mode by default. | |
31403 | ||
d77de738 | 31404 | @opindex m4-200-single-only |
ddf6fe37 | 31405 | @item -m4-200-single-only |
d77de738 ML |
31406 | Generate code for SH4-200 in such a way that no double-precision |
31407 | floating-point operations are used. | |
31408 | ||
d77de738 | 31409 | @opindex m4-300 |
ddf6fe37 | 31410 | @item -m4-300 |
d77de738 ML |
31411 | Generate code for SH4-300. |
31412 | ||
d77de738 | 31413 | @opindex m4-300-nofpu |
ddf6fe37 | 31414 | @item -m4-300-nofpu |
d77de738 ML |
31415 | Generate code for SH4-300 without in such a way that the |
31416 | floating-point unit is not used. | |
31417 | ||
d77de738 | 31418 | @opindex m4-300-single |
ddf6fe37 | 31419 | @item -m4-300-single |
d77de738 ML |
31420 | Generate code for SH4-300 in such a way that no double-precision |
31421 | floating-point operations are used. | |
31422 | ||
d77de738 | 31423 | @opindex m4-300-single-only |
ddf6fe37 | 31424 | @item -m4-300-single-only |
d77de738 ML |
31425 | Generate code for SH4-300 in such a way that no double-precision |
31426 | floating-point operations are used. | |
31427 | ||
d77de738 | 31428 | @opindex m4-340 |
ddf6fe37 | 31429 | @item -m4-340 |
d77de738 ML |
31430 | Generate code for SH4-340 (no MMU, no FPU). |
31431 | ||
d77de738 | 31432 | @opindex m4-500 |
ddf6fe37 | 31433 | @item -m4-500 |
d77de738 ML |
31434 | Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the |
31435 | assembler. | |
31436 | ||
d77de738 | 31437 | @opindex m4a-nofpu |
ddf6fe37 | 31438 | @item -m4a-nofpu |
d77de738 ML |
31439 | Generate code for the SH4al-dsp, or for a SH4a in such a way that the |
31440 | floating-point unit is not used. | |
31441 | ||
d77de738 | 31442 | @opindex m4a-single-only |
ddf6fe37 | 31443 | @item -m4a-single-only |
d77de738 ML |
31444 | Generate code for the SH4a, in such a way that no double-precision |
31445 | floating-point operations are used. | |
31446 | ||
d77de738 | 31447 | @opindex m4a-single |
ddf6fe37 | 31448 | @item -m4a-single |
d77de738 ML |
31449 | Generate code for the SH4a assuming the floating-point unit is in |
31450 | single-precision mode by default. | |
31451 | ||
d77de738 | 31452 | @opindex m4a |
ddf6fe37 | 31453 | @item -m4a |
d77de738 ML |
31454 | Generate code for the SH4a. |
31455 | ||
d77de738 | 31456 | @opindex m4al |
ddf6fe37 | 31457 | @item -m4al |
d77de738 ML |
31458 | Same as @option{-m4a-nofpu}, except that it implicitly passes |
31459 | @option{-dsp} to the assembler. GCC doesn't generate any DSP | |
31460 | instructions at the moment. | |
31461 | ||
d77de738 | 31462 | @opindex mb |
ddf6fe37 | 31463 | @item -mb |
d77de738 ML |
31464 | Compile code for the processor in big-endian mode. |
31465 | ||
d77de738 | 31466 | @opindex ml |
ddf6fe37 | 31467 | @item -ml |
d77de738 ML |
31468 | Compile code for the processor in little-endian mode. |
31469 | ||
d77de738 | 31470 | @opindex mdalign |
ddf6fe37 | 31471 | @item -mdalign |
d77de738 ML |
31472 | Align doubles at 64-bit boundaries. Note that this changes the calling |
31473 | conventions, and thus some functions from the standard C library do | |
31474 | not work unless you recompile it first with @option{-mdalign}. | |
31475 | ||
d77de738 | 31476 | @opindex mrelax |
ddf6fe37 | 31477 | @item -mrelax |
d77de738 ML |
31478 | Shorten some address references at link time, when possible; uses the |
31479 | linker option @option{-relax}. | |
31480 | ||
d77de738 | 31481 | @opindex mbigtable |
ddf6fe37 | 31482 | @item -mbigtable |
d77de738 ML |
31483 | Use 32-bit offsets in @code{switch} tables. The default is to use |
31484 | 16-bit offsets. | |
31485 | ||
d77de738 | 31486 | @opindex mbitops |
ddf6fe37 | 31487 | @item -mbitops |
d77de738 ML |
31488 | Enable the use of bit manipulation instructions on SH2A. |
31489 | ||
d77de738 | 31490 | @opindex mfmovd |
ddf6fe37 | 31491 | @item -mfmovd |
d77de738 ML |
31492 | Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for |
31493 | alignment constraints. | |
31494 | ||
d77de738 | 31495 | @opindex mrenesas |
ddf6fe37 | 31496 | @item -mrenesas |
d77de738 ML |
31497 | Comply with the calling conventions defined by Renesas. |
31498 | ||
d77de738 | 31499 | @opindex mno-renesas |
ddf6fe37 | 31500 | @item -mno-renesas |
d77de738 ML |
31501 | Comply with the calling conventions defined for GCC before the Renesas |
31502 | conventions were available. This option is the default for all | |
31503 | targets of the SH toolchain. | |
31504 | ||
d77de738 | 31505 | @opindex mnomacsave |
ddf6fe37 | 31506 | @item -mnomacsave |
d77de738 ML |
31507 | Mark the @code{MAC} register as call-clobbered, even if |
31508 | @option{-mrenesas} is given. | |
31509 | ||
d77de738 ML |
31510 | @opindex mieee |
31511 | @opindex mno-ieee | |
ddf6fe37 AA |
31512 | @item -mieee |
31513 | @itemx -mno-ieee | |
d77de738 ML |
31514 | Control the IEEE compliance of floating-point comparisons, which affects the |
31515 | handling of cases where the result of a comparison is unordered. By default | |
31516 | @option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is | |
31517 | enabled @option{-mno-ieee} is implicitly set, which results in faster | |
31518 | floating-point greater-equal and less-equal comparisons. The implicit settings | |
31519 | can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}. | |
31520 | ||
d77de738 | 31521 | @opindex minline-ic_invalidate |
ddf6fe37 | 31522 | @item -minline-ic_invalidate |
d77de738 ML |
31523 | Inline code to invalidate instruction cache entries after setting up |
31524 | nested function trampolines. | |
31525 | This option has no effect if @option{-musermode} is in effect and the selected | |
31526 | code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi} | |
31527 | instruction. | |
31528 | If the selected code generation option does not allow the use of the @code{icbi} | |
31529 | instruction, and @option{-musermode} is not in effect, the inlined code | |
31530 | manipulates the instruction cache address array directly with an associative | |
31531 | write. This not only requires privileged mode at run time, but it also | |
31532 | fails if the cache line had been mapped via the TLB and has become unmapped. | |
31533 | ||
d77de738 | 31534 | @opindex misize |
ddf6fe37 | 31535 | @item -misize |
d77de738 ML |
31536 | Dump instruction size and location in the assembly code. |
31537 | ||
d77de738 | 31538 | @opindex mpadstruct |
ddf6fe37 | 31539 | @item -mpadstruct |
d77de738 ML |
31540 | This option is deprecated. It pads structures to multiple of 4 bytes, |
31541 | which is incompatible with the SH ABI@. | |
31542 | ||
d77de738 | 31543 | @opindex matomic-model=@var{model} |
ddf6fe37 | 31544 | @item -matomic-model=@var{model} |
d77de738 ML |
31545 | Sets the model of atomic operations and additional parameters as a comma |
31546 | separated list. For details on the atomic built-in functions see | |
31547 | @ref{__atomic Builtins}. The following models and parameters are supported: | |
31548 | ||
31549 | @table @samp | |
31550 | ||
31551 | @item none | |
31552 | Disable compiler generated atomic sequences and emit library calls for atomic | |
31553 | operations. This is the default if the target is not @code{sh*-*-linux*}. | |
31554 | ||
31555 | @item soft-gusa | |
31556 | Generate GNU/Linux compatible gUSA software atomic sequences for the atomic | |
31557 | built-in functions. The generated atomic sequences require additional support | |
31558 | from the interrupt/exception handling code of the system and are only suitable | |
31559 | for SH3* and SH4* single-core systems. This option is enabled by default when | |
31560 | the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A, | |
31561 | this option also partially utilizes the hardware atomic instructions | |
31562 | @code{movli.l} and @code{movco.l} to create more efficient code, unless | |
31563 | @samp{strict} is specified. | |
31564 | ||
31565 | @item soft-tcb | |
31566 | Generate software atomic sequences that use a variable in the thread control | |
31567 | block. This is a variation of the gUSA sequences which can also be used on | |
31568 | SH1* and SH2* targets. The generated atomic sequences require additional | |
31569 | support from the interrupt/exception handling code of the system and are only | |
31570 | suitable for single-core systems. When using this model, the @samp{gbr-offset=} | |
31571 | parameter has to be specified as well. | |
31572 | ||
31573 | @item soft-imask | |
31574 | Generate software atomic sequences that temporarily disable interrupts by | |
31575 | setting @code{SR.IMASK = 1111}. This model works only when the program runs | |
31576 | in privileged mode and is only suitable for single-core systems. Additional | |
31577 | support from the interrupt/exception handling code of the system is not | |
31578 | required. This model is enabled by default when the target is | |
31579 | @code{sh*-*-linux*} and SH1* or SH2*. | |
31580 | ||
31581 | @item hard-llcs | |
31582 | Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l} | |
31583 | instructions only. This is only available on SH4A and is suitable for | |
31584 | multi-core systems. Since the hardware instructions support only 32 bit atomic | |
31585 | variables access to 8 or 16 bit variables is emulated with 32 bit accesses. | |
31586 | Code compiled with this option is also compatible with other software | |
31587 | atomic model interrupt/exception handling systems if executed on an SH4A | |
31588 | system. Additional support from the interrupt/exception handling code of the | |
31589 | system is not required for this model. | |
31590 | ||
31591 | @item gbr-offset= | |
31592 | This parameter specifies the offset in bytes of the variable in the thread | |
31593 | control block structure that should be used by the generated atomic sequences | |
31594 | when the @samp{soft-tcb} model has been selected. For other models this | |
31595 | parameter is ignored. The specified value must be an integer multiple of four | |
31596 | and in the range 0-1020. | |
31597 | ||
31598 | @item strict | |
31599 | This parameter prevents mixed usage of multiple atomic models, even if they | |
31600 | are compatible, and makes the compiler generate atomic sequences of the | |
31601 | specified model only. | |
31602 | ||
31603 | @end table | |
31604 | ||
d77de738 | 31605 | @opindex mtas |
ddf6fe37 | 31606 | @item -mtas |
d77de738 ML |
31607 | Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}. |
31608 | Notice that depending on the particular hardware and software configuration | |
31609 | this can degrade overall performance due to the operand cache line flushes | |
31610 | that are implied by the @code{tas.b} instruction. On multi-core SH4A | |
31611 | processors the @code{tas.b} instruction must be used with caution since it | |
31612 | can result in data corruption for certain cache configurations. | |
31613 | ||
d77de738 | 31614 | @opindex mprefergot |
ddf6fe37 | 31615 | @item -mprefergot |
d77de738 ML |
31616 | When generating position-independent code, emit function calls using |
31617 | the Global Offset Table instead of the Procedure Linkage Table. | |
31618 | ||
d77de738 ML |
31619 | @opindex musermode |
31620 | @opindex mno-usermode | |
ddf6fe37 AA |
31621 | @item -musermode |
31622 | @itemx -mno-usermode | |
d77de738 ML |
31623 | Don't allow (allow) the compiler generating privileged mode code. Specifying |
31624 | @option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the | |
31625 | inlined code would not work in user mode. @option{-musermode} is the default | |
31626 | when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2* | |
31627 | @option{-musermode} has no effect, since there is no user mode. | |
31628 | ||
d77de738 | 31629 | @opindex multcost=@var{number} |
ddf6fe37 | 31630 | @item -multcost=@var{number} |
d77de738 ML |
31631 | Set the cost to assume for a multiply insn. |
31632 | ||
d77de738 | 31633 | @opindex mdiv=@var{strategy} |
ddf6fe37 | 31634 | @item -mdiv=@var{strategy} |
d77de738 ML |
31635 | Set the division strategy to be used for integer division operations. |
31636 | @var{strategy} can be one of: | |
31637 | ||
31638 | @table @samp | |
31639 | ||
31640 | @item call-div1 | |
31641 | Calls a library function that uses the single-step division instruction | |
31642 | @code{div1} to perform the operation. Division by zero calculates an | |
31643 | unspecified result and does not trap. This is the default except for SH4, | |
31644 | SH2A and SHcompact. | |
31645 | ||
31646 | @item call-fp | |
31647 | Calls a library function that performs the operation in double precision | |
31648 | floating point. Division by zero causes a floating-point exception. This is | |
31649 | the default for SHcompact with FPU. Specifying this for targets that do not | |
31650 | have a double precision FPU defaults to @code{call-div1}. | |
31651 | ||
31652 | @item call-table | |
31653 | Calls a library function that uses a lookup table for small divisors and | |
31654 | the @code{div1} instruction with case distinction for larger divisors. Division | |
31655 | by zero calculates an unspecified result and does not trap. This is the default | |
31656 | for SH4. Specifying this for targets that do not have dynamic shift | |
31657 | instructions defaults to @code{call-div1}. | |
31658 | ||
31659 | @end table | |
31660 | ||
31661 | When a division strategy has not been specified the default strategy is | |
31662 | selected based on the current target. For SH2A the default strategy is to | |
31663 | use the @code{divs} and @code{divu} instructions instead of library function | |
31664 | calls. | |
31665 | ||
d77de738 | 31666 | @opindex maccumulate-outgoing-args |
ddf6fe37 | 31667 | @item -maccumulate-outgoing-args |
d77de738 ML |
31668 | Reserve space once for outgoing arguments in the function prologue rather |
31669 | than around each call. Generally beneficial for performance and size. Also | |
31670 | needed for unwinding to avoid changing the stack frame around conditional code. | |
31671 | ||
d77de738 | 31672 | @opindex mdivsi3_libfunc=@var{name} |
ddf6fe37 | 31673 | @item -mdivsi3_libfunc=@var{name} |
d77de738 ML |
31674 | Set the name of the library function used for 32-bit signed division to |
31675 | @var{name}. | |
31676 | This only affects the name used in the @samp{call} division strategies, and | |
31677 | the compiler still expects the same sets of input/output/clobbered registers as | |
31678 | if this option were not present. | |
31679 | ||
d77de738 | 31680 | @opindex mfixed-range |
ddf6fe37 | 31681 | @item -mfixed-range=@var{register-range} |
d77de738 ML |
31682 | Generate code treating the given register range as fixed registers. |
31683 | A fixed register is one that the register allocator cannot use. This is | |
31684 | useful when compiling kernel code. A register range is specified as | |
31685 | two registers separated by a dash. Multiple register ranges can be | |
31686 | specified separated by a comma. | |
31687 | ||
d77de738 | 31688 | @opindex mbranch-cost=@var{num} |
ddf6fe37 | 31689 | @item -mbranch-cost=@var{num} |
d77de738 ML |
31690 | Assume @var{num} to be the cost for a branch instruction. Higher numbers |
31691 | make the compiler try to generate more branch-free code if possible. | |
31692 | If not specified the value is selected depending on the processor type that | |
31693 | is being compiled for. | |
31694 | ||
d77de738 ML |
31695 | @opindex mzdcbranch |
31696 | @opindex mno-zdcbranch | |
ddf6fe37 AA |
31697 | @item -mzdcbranch |
31698 | @itemx -mno-zdcbranch | |
d77de738 ML |
31699 | Assume (do not assume) that zero displacement conditional branch instructions |
31700 | @code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the | |
31701 | compiler prefers zero displacement branch code sequences. This is | |
31702 | enabled by default when generating code for SH4 and SH4A. It can be explicitly | |
31703 | disabled by specifying @option{-mno-zdcbranch}. | |
31704 | ||
d77de738 | 31705 | @opindex mcbranch-force-delay-slot |
ddf6fe37 | 31706 | @item -mcbranch-force-delay-slot |
d77de738 ML |
31707 | Force the usage of delay slots for conditional branches, which stuffs the delay |
31708 | slot with a @code{nop} if a suitable instruction cannot be found. By default | |
31709 | this option is disabled. It can be enabled to work around hardware bugs as | |
31710 | found in the original SH7055. | |
31711 | ||
d77de738 ML |
31712 | @opindex mfused-madd |
31713 | @opindex mno-fused-madd | |
ddf6fe37 AA |
31714 | @item -mfused-madd |
31715 | @itemx -mno-fused-madd | |
d77de738 ML |
31716 | Generate code that uses (does not use) the floating-point multiply and |
31717 | accumulate instructions. These instructions are generated by default | |
31718 | if hardware floating point is used. The machine-dependent | |
31719 | @option{-mfused-madd} option is now mapped to the machine-independent | |
31720 | @option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is | |
31721 | mapped to @option{-ffp-contract=off}. | |
31722 | ||
d77de738 ML |
31723 | @opindex mfsca |
31724 | @opindex mno-fsca | |
ddf6fe37 AA |
31725 | @item -mfsca |
31726 | @itemx -mno-fsca | |
d77de738 ML |
31727 | Allow or disallow the compiler to emit the @code{fsca} instruction for sine |
31728 | and cosine approximations. The option @option{-mfsca} must be used in | |
31729 | combination with @option{-funsafe-math-optimizations}. It is enabled by default | |
31730 | when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine | |
31731 | approximations even if @option{-funsafe-math-optimizations} is in effect. | |
31732 | ||
d77de738 ML |
31733 | @opindex mfsrra |
31734 | @opindex mno-fsrra | |
ddf6fe37 AA |
31735 | @item -mfsrra |
31736 | @itemx -mno-fsrra | |
d77de738 ML |
31737 | Allow or disallow the compiler to emit the @code{fsrra} instruction for |
31738 | reciprocal square root approximations. The option @option{-mfsrra} must be used | |
31739 | in combination with @option{-funsafe-math-optimizations} and | |
31740 | @option{-ffinite-math-only}. It is enabled by default when generating code for | |
31741 | SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations | |
31742 | even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are | |
31743 | in effect. | |
31744 | ||
d77de738 | 31745 | @opindex mpretend-cmove |
ddf6fe37 | 31746 | @item -mpretend-cmove |
d77de738 ML |
31747 | Prefer zero-displacement conditional branches for conditional move instruction |
31748 | patterns. This can result in faster code on the SH4 processor. | |
31749 | ||
d77de738 | 31750 | @opindex fdpic |
ddf6fe37 | 31751 | @item -mfdpic |
d77de738 ML |
31752 | Generate code using the FDPIC ABI. |
31753 | ||
31754 | @end table | |
31755 | ||
31756 | @node Solaris 2 Options | |
31757 | @subsection Solaris 2 Options | |
31758 | @cindex Solaris 2 options | |
31759 | ||
31760 | These @samp{-m} options are supported on Solaris 2: | |
31761 | ||
31762 | @table @gcctabopt | |
d77de738 | 31763 | @opindex mclear-hwcap |
ddf6fe37 | 31764 | @item -mclear-hwcap |
d77de738 ML |
31765 | @option{-mclear-hwcap} tells the compiler to remove the hardware |
31766 | capabilities generated by the Solaris assembler. This is only necessary | |
31767 | when object files use ISA extensions not supported by the current | |
31768 | machine, but check at runtime whether or not to use them. | |
31769 | ||
d77de738 | 31770 | @opindex mimpure-text |
ddf6fe37 | 31771 | @item -mimpure-text |
d77de738 ML |
31772 | @option{-mimpure-text}, used in addition to @option{-shared}, tells |
31773 | the compiler to not pass @option{-z text} to the linker when linking a | |
31774 | shared object. Using this option, you can link position-dependent | |
31775 | code into a shared object. | |
31776 | ||
31777 | @option{-mimpure-text} suppresses the ``relocations remain against | |
31778 | allocatable but non-writable sections'' linker error message. | |
31779 | However, the necessary relocations trigger copy-on-write, and the | |
31780 | shared object is not actually shared across processes. Instead of | |
31781 | using @option{-mimpure-text}, you should compile all source code with | |
31782 | @option{-fpic} or @option{-fPIC}. | |
31783 | ||
31784 | @end table | |
31785 | ||
31786 | These switches are supported in addition to the above on Solaris 2: | |
31787 | ||
31788 | @table @gcctabopt | |
d77de738 | 31789 | @opindex pthreads |
ddf6fe37 | 31790 | @item -pthreads |
d77de738 ML |
31791 | This is a synonym for @option{-pthread}. |
31792 | @end table | |
31793 | ||
31794 | @node SPARC Options | |
31795 | @subsection SPARC Options | |
31796 | @cindex SPARC options | |
31797 | ||
31798 | These @samp{-m} options are supported on the SPARC: | |
31799 | ||
31800 | @table @gcctabopt | |
d77de738 ML |
31801 | @opindex mno-app-regs |
31802 | @opindex mapp-regs | |
ddf6fe37 AA |
31803 | @item -mno-app-regs |
31804 | @itemx -mapp-regs | |
d77de738 ML |
31805 | Specify @option{-mapp-regs} to generate output using the global registers |
31806 | 2 through 4, which the SPARC SVR4 ABI reserves for applications. Like the | |
31807 | global register 1, each global register 2 through 4 is then treated as an | |
31808 | allocable register that is clobbered by function calls. This is the default. | |
31809 | ||
31810 | To be fully SVR4 ABI-compliant at the cost of some performance loss, | |
31811 | specify @option{-mno-app-regs}. You should compile libraries and system | |
31812 | software with this option. | |
31813 | ||
d77de738 ML |
31814 | @opindex mflat |
31815 | @opindex mno-flat | |
ddf6fe37 AA |
31816 | @item -mflat |
31817 | @itemx -mno-flat | |
d77de738 ML |
31818 | With @option{-mflat}, the compiler does not generate save/restore instructions |
31819 | and uses a ``flat'' or single register window model. This model is compatible | |
31820 | with the regular register window model. The local registers and the input | |
31821 | registers (0--5) are still treated as ``call-saved'' registers and are | |
31822 | saved on the stack as needed. | |
31823 | ||
31824 | With @option{-mno-flat} (the default), the compiler generates save/restore | |
31825 | instructions (except for leaf functions). This is the normal operating mode. | |
31826 | ||
d77de738 ML |
31827 | @opindex mfpu |
31828 | @opindex mhard-float | |
ddf6fe37 AA |
31829 | @item -mfpu |
31830 | @itemx -mhard-float | |
d77de738 ML |
31831 | Generate output containing floating-point instructions. This is the |
31832 | default. | |
31833 | ||
d77de738 ML |
31834 | @opindex mno-fpu |
31835 | @opindex msoft-float | |
ddf6fe37 AA |
31836 | @item -mno-fpu |
31837 | @itemx -msoft-float | |
d77de738 ML |
31838 | Generate output containing library calls for floating point. |
31839 | @strong{Warning:} the requisite libraries are not available for all SPARC | |
31840 | targets. Normally the facilities of the machine's usual C compiler are | |
31841 | used, but this cannot be done directly in cross-compilation. You must make | |
31842 | your own arrangements to provide suitable library functions for | |
31843 | cross-compilation. The embedded targets @samp{sparc-*-aout} and | |
31844 | @samp{sparclite-*-*} do provide software floating-point support. | |
31845 | ||
31846 | @option{-msoft-float} changes the calling convention in the output file; | |
31847 | therefore, it is only useful if you compile @emph{all} of a program with | |
31848 | this option. In particular, you need to compile @file{libgcc.a}, the | |
31849 | library that comes with GCC, with @option{-msoft-float} in order for | |
31850 | this to work. | |
31851 | ||
d77de738 | 31852 | @opindex mhard-quad-float |
ddf6fe37 | 31853 | @item -mhard-quad-float |
d77de738 ML |
31854 | Generate output containing quad-word (long double) floating-point |
31855 | instructions. | |
31856 | ||
d77de738 | 31857 | @opindex msoft-quad-float |
ddf6fe37 | 31858 | @item -msoft-quad-float |
d77de738 ML |
31859 | Generate output containing library calls for quad-word (long double) |
31860 | floating-point instructions. The functions called are those specified | |
31861 | in the SPARC ABI@. This is the default. | |
31862 | ||
31863 | As of this writing, there are no SPARC implementations that have hardware | |
31864 | support for the quad-word floating-point instructions. They all invoke | |
31865 | a trap handler for one of these instructions, and then the trap handler | |
31866 | emulates the effect of the instruction. Because of the trap handler overhead, | |
31867 | this is much slower than calling the ABI library routines. Thus the | |
31868 | @option{-msoft-quad-float} option is the default. | |
31869 | ||
d77de738 ML |
31870 | @opindex mno-unaligned-doubles |
31871 | @opindex munaligned-doubles | |
ddf6fe37 AA |
31872 | @item -mno-unaligned-doubles |
31873 | @itemx -munaligned-doubles | |
d77de738 ML |
31874 | Assume that doubles have 8-byte alignment. This is the default. |
31875 | ||
31876 | With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte | |
31877 | alignment only if they are contained in another type, or if they have an | |
31878 | absolute address. Otherwise, it assumes they have 4-byte alignment. | |
31879 | Specifying this option avoids some rare compatibility problems with code | |
31880 | generated by other compilers. It is not the default because it results | |
31881 | in a performance loss, especially for floating-point code. | |
31882 | ||
d77de738 ML |
31883 | @opindex muser-mode |
31884 | @opindex mno-user-mode | |
ddf6fe37 AA |
31885 | @item -muser-mode |
31886 | @itemx -mno-user-mode | |
d77de738 ML |
31887 | Do not generate code that can only run in supervisor mode. This is relevant |
31888 | only for the @code{casa} instruction emitted for the LEON3 processor. This | |
31889 | is the default. | |
31890 | ||
d77de738 ML |
31891 | @opindex mfaster-structs |
31892 | @opindex mno-faster-structs | |
ddf6fe37 AA |
31893 | @item -mfaster-structs |
31894 | @itemx -mno-faster-structs | |
d77de738 ML |
31895 | With @option{-mfaster-structs}, the compiler assumes that structures |
31896 | should have 8-byte alignment. This enables the use of pairs of | |
31897 | @code{ldd} and @code{std} instructions for copies in structure | |
31898 | assignment, in place of twice as many @code{ld} and @code{st} pairs. | |
31899 | However, the use of this changed alignment directly violates the SPARC | |
31900 | ABI@. Thus, it's intended only for use on targets where the developer | |
31901 | acknowledges that their resulting code is not directly in line with | |
31902 | the rules of the ABI@. | |
31903 | ||
d77de738 ML |
31904 | @opindex mstd-struct-return |
31905 | @opindex mno-std-struct-return | |
ddf6fe37 AA |
31906 | @item -mstd-struct-return |
31907 | @itemx -mno-std-struct-return | |
d77de738 ML |
31908 | With @option{-mstd-struct-return}, the compiler generates checking code |
31909 | in functions returning structures or unions to detect size mismatches | |
31910 | between the two sides of function calls, as per the 32-bit ABI@. | |
31911 | ||
31912 | The default is @option{-mno-std-struct-return}. This option has no effect | |
31913 | in 64-bit mode. | |
31914 | ||
d77de738 ML |
31915 | @opindex mlra |
31916 | @opindex mno-lra | |
ddf6fe37 AA |
31917 | @item -mlra |
31918 | @itemx -mno-lra | |
d77de738 ML |
31919 | Enable Local Register Allocation. This is the default for SPARC since GCC 7 |
31920 | so @option{-mno-lra} needs to be passed to get old Reload. | |
31921 | ||
d77de738 | 31922 | @opindex mcpu |
ddf6fe37 | 31923 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
31924 | Set the instruction set, register set, and instruction scheduling parameters |
31925 | for machine type @var{cpu_type}. Supported values for @var{cpu_type} are | |
31926 | @samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc}, | |
31927 | @samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite}, | |
31928 | @samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701}, | |
31929 | @samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara}, | |
31930 | @samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and | |
31931 | @samp{m8}. | |
31932 | ||
31933 | Native Solaris and GNU/Linux toolchains also support the value @samp{native}, | |
31934 | which selects the best architecture option for the host processor. | |
31935 | @option{-mcpu=native} has no effect if GCC does not recognize | |
31936 | the processor. | |
31937 | ||
31938 | Default instruction scheduling parameters are used for values that select | |
31939 | an architecture and not an implementation. These are @samp{v7}, @samp{v8}, | |
31940 | @samp{sparclite}, @samp{sparclet}, @samp{v9}. | |
31941 | ||
31942 | Here is a list of each supported architecture and their supported | |
31943 | implementations. | |
31944 | ||
31945 | @table @asis | |
31946 | @item v7 | |
31947 | cypress, leon3v7 | |
31948 | ||
31949 | @item v8 | |
31950 | supersparc, hypersparc, leon, leon3, leon5 | |
31951 | ||
31952 | @item sparclite | |
31953 | f930, f934, sparclite86x | |
31954 | ||
31955 | @item sparclet | |
31956 | tsc701 | |
31957 | ||
31958 | @item v9 | |
31959 | ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4, | |
31960 | niagara7, m8 | |
31961 | @end table | |
31962 | ||
31963 | By default (unless configured otherwise), GCC generates code for the V7 | |
31964 | variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler | |
31965 | additionally optimizes it for the Cypress CY7C602 chip, as used in the | |
31966 | SPARCStation/SPARCServer 3xx series. This is also appropriate for the older | |
31967 | SPARCStation 1, 2, IPX etc. | |
31968 | ||
31969 | With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC | |
31970 | architecture. The only difference from V7 code is that the compiler emits | |
31971 | the integer multiply and integer divide instructions which exist in SPARC-V8 | |
31972 | but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally | |
31973 | optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and | |
31974 | 2000 series. | |
31975 | ||
31976 | With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of | |
31977 | the SPARC architecture. This adds the integer multiply, integer divide step | |
31978 | and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7. | |
31979 | With @option{-mcpu=f930}, the compiler additionally optimizes it for the | |
31980 | Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With | |
31981 | @option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu | |
31982 | MB86934 chip, which is the more recent SPARClite with FPU@. | |
31983 | ||
31984 | With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of | |
31985 | the SPARC architecture. This adds the integer multiply, multiply/accumulate, | |
31986 | integer divide step and scan (@code{ffs}) instructions which exist in SPARClet | |
31987 | but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally | |
31988 | optimizes it for the TEMIC SPARClet chip. | |
31989 | ||
31990 | With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC | |
31991 | architecture. This adds 64-bit integer and floating-point move instructions, | |
31992 | 3 additional floating-point condition code registers and conditional move | |
31993 | instructions. With @option{-mcpu=ultrasparc}, the compiler additionally | |
31994 | optimizes it for the Sun UltraSPARC I/II/IIi chips. With | |
31995 | @option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the | |
31996 | Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With | |
31997 | @option{-mcpu=niagara}, the compiler additionally optimizes it for | |
31998 | Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler | |
31999 | additionally optimizes it for Sun UltraSPARC T2 chips. With | |
32000 | @option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun | |
32001 | UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler | |
32002 | additionally optimizes it for Sun UltraSPARC T4 chips. With | |
32003 | @option{-mcpu=niagara7}, the compiler additionally optimizes it for | |
32004 | Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler | |
32005 | additionally optimizes it for Oracle M8 chips. | |
32006 | ||
d77de738 | 32007 | @opindex mtune |
ddf6fe37 | 32008 | @item -mtune=@var{cpu_type} |
d77de738 ML |
32009 | Set the instruction scheduling parameters for machine type |
32010 | @var{cpu_type}, but do not set the instruction set or register set that the | |
32011 | option @option{-mcpu=@var{cpu_type}} does. | |
32012 | ||
32013 | The same values for @option{-mcpu=@var{cpu_type}} can be used for | |
32014 | @option{-mtune=@var{cpu_type}}, but the only useful values are those | |
32015 | that select a particular CPU implementation. Those are | |
32016 | @samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon}, | |
32017 | @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934}, | |
32018 | @samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc}, | |
32019 | @samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3}, | |
32020 | @samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris | |
32021 | and GNU/Linux toolchains, @samp{native} can also be used. | |
32022 | ||
d77de738 ML |
32023 | @opindex mv8plus |
32024 | @opindex mno-v8plus | |
ddf6fe37 AA |
32025 | @item -mv8plus |
32026 | @itemx -mno-v8plus | |
d77de738 ML |
32027 | With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The |
32028 | difference from the V8 ABI is that the global and out registers are | |
32029 | considered 64 bits wide. This is enabled by default on Solaris in 32-bit | |
32030 | mode for all SPARC-V9 processors. | |
32031 | ||
d77de738 ML |
32032 | @opindex mvis |
32033 | @opindex mno-vis | |
ddf6fe37 AA |
32034 | @item -mvis |
32035 | @itemx -mno-vis | |
d77de738 ML |
32036 | With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC |
32037 | Visual Instruction Set extensions. The default is @option{-mno-vis}. | |
32038 | ||
d77de738 ML |
32039 | @opindex mvis2 |
32040 | @opindex mno-vis2 | |
ddf6fe37 AA |
32041 | @item -mvis2 |
32042 | @itemx -mno-vis2 | |
d77de738 ML |
32043 | With @option{-mvis2}, GCC generates code that takes advantage of |
32044 | version 2.0 of the UltraSPARC Visual Instruction Set extensions. The | |
32045 | default is @option{-mvis2} when targeting a cpu that supports such | |
32046 | instructions, such as UltraSPARC-III and later. Setting @option{-mvis2} | |
32047 | also sets @option{-mvis}. | |
32048 | ||
d77de738 ML |
32049 | @opindex mvis3 |
32050 | @opindex mno-vis3 | |
ddf6fe37 AA |
32051 | @item -mvis3 |
32052 | @itemx -mno-vis3 | |
d77de738 ML |
32053 | With @option{-mvis3}, GCC generates code that takes advantage of |
32054 | version 3.0 of the UltraSPARC Visual Instruction Set extensions. The | |
32055 | default is @option{-mvis3} when targeting a cpu that supports such | |
32056 | instructions, such as niagara-3 and later. Setting @option{-mvis3} | |
32057 | also sets @option{-mvis2} and @option{-mvis}. | |
32058 | ||
d77de738 ML |
32059 | @opindex mvis4 |
32060 | @opindex mno-vis4 | |
ddf6fe37 AA |
32061 | @item -mvis4 |
32062 | @itemx -mno-vis4 | |
d77de738 ML |
32063 | With @option{-mvis4}, GCC generates code that takes advantage of |
32064 | version 4.0 of the UltraSPARC Visual Instruction Set extensions. The | |
32065 | default is @option{-mvis4} when targeting a cpu that supports such | |
32066 | instructions, such as niagara-7 and later. Setting @option{-mvis4} | |
32067 | also sets @option{-mvis3}, @option{-mvis2} and @option{-mvis}. | |
32068 | ||
d77de738 ML |
32069 | @opindex mvis4b |
32070 | @opindex mno-vis4b | |
ddf6fe37 AA |
32071 | @item -mvis4b |
32072 | @itemx -mno-vis4b | |
d77de738 ML |
32073 | With @option{-mvis4b}, GCC generates code that takes advantage of |
32074 | version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus | |
32075 | the additional VIS instructions introduced in the Oracle SPARC | |
32076 | Architecture 2017. The default is @option{-mvis4b} when targeting a | |
32077 | cpu that supports such instructions, such as m8 and later. Setting | |
32078 | @option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3}, | |
32079 | @option{-mvis2} and @option{-mvis}. | |
32080 | ||
d77de738 ML |
32081 | @opindex mcbcond |
32082 | @opindex mno-cbcond | |
ddf6fe37 AA |
32083 | @item -mcbcond |
32084 | @itemx -mno-cbcond | |
d77de738 ML |
32085 | With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC |
32086 | Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond} | |
32087 | when targeting a CPU that supports such instructions, such as Niagara-4 and | |
32088 | later. | |
32089 | ||
d77de738 ML |
32090 | @opindex mfmaf |
32091 | @opindex mno-fmaf | |
ddf6fe37 AA |
32092 | @item -mfmaf |
32093 | @itemx -mno-fmaf | |
d77de738 ML |
32094 | With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC |
32095 | Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf} | |
32096 | when targeting a CPU that supports such instructions, such as Niagara-3 and | |
32097 | later. | |
32098 | ||
d77de738 ML |
32099 | @opindex mfsmuld |
32100 | @opindex mno-fsmuld | |
ddf6fe37 AA |
32101 | @item -mfsmuld |
32102 | @itemx -mno-fsmuld | |
d77de738 ML |
32103 | With @option{-mfsmuld}, GCC generates code that takes advantage of the |
32104 | Floating-point Multiply Single to Double (FsMULd) instruction. The default is | |
32105 | @option{-mfsmuld} when targeting a CPU supporting the architecture versions V8 | |
32106 | or V9 with FPU except @option{-mcpu=leon}. | |
32107 | ||
d77de738 ML |
32108 | @opindex mpopc |
32109 | @opindex mno-popc | |
ddf6fe37 AA |
32110 | @item -mpopc |
32111 | @itemx -mno-popc | |
d77de738 ML |
32112 | With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC |
32113 | Population Count instruction. The default is @option{-mpopc} | |
32114 | when targeting a CPU that supports such an instruction, such as Niagara-2 and | |
32115 | later. | |
32116 | ||
d77de738 ML |
32117 | @opindex msubxc |
32118 | @opindex mno-subxc | |
ddf6fe37 AA |
32119 | @item -msubxc |
32120 | @itemx -mno-subxc | |
d77de738 ML |
32121 | With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC |
32122 | Subtract-Extended-with-Carry instruction. The default is @option{-msubxc} | |
32123 | when targeting a CPU that supports such an instruction, such as Niagara-7 and | |
32124 | later. | |
32125 | ||
d77de738 | 32126 | @opindex mfix-at697f |
ddf6fe37 | 32127 | @item -mfix-at697f |
d77de738 ML |
32128 | Enable the documented workaround for the single erratum of the Atmel AT697F |
32129 | processor (which corresponds to erratum #13 of the AT697E processor). | |
32130 | ||
d77de738 | 32131 | @opindex mfix-ut699 |
ddf6fe37 | 32132 | @item -mfix-ut699 |
d77de738 ML |
32133 | Enable the documented workarounds for the floating-point errata and the data |
32134 | cache nullify errata of the UT699 processor. | |
32135 | ||
d77de738 | 32136 | @opindex mfix-ut700 |
ddf6fe37 | 32137 | @item -mfix-ut700 |
d77de738 ML |
32138 | Enable the documented workaround for the back-to-back store errata of |
32139 | the UT699E/UT700 processor. | |
32140 | ||
d77de738 | 32141 | @opindex mfix-gr712rc |
ddf6fe37 | 32142 | @item -mfix-gr712rc |
d77de738 ML |
32143 | Enable the documented workaround for the back-to-back store errata of |
32144 | the GR712RC processor. | |
32145 | @end table | |
32146 | ||
32147 | These @samp{-m} options are supported in addition to the above | |
32148 | on SPARC-V9 processors in 64-bit environments: | |
32149 | ||
32150 | @table @gcctabopt | |
d77de738 ML |
32151 | @opindex m32 |
32152 | @opindex m64 | |
ddf6fe37 AA |
32153 | @item -m32 |
32154 | @itemx -m64 | |
d77de738 ML |
32155 | Generate code for a 32-bit or 64-bit environment. |
32156 | The 32-bit environment sets int, long and pointer to 32 bits. | |
32157 | The 64-bit environment sets int to 32 bits and long and pointer | |
32158 | to 64 bits. | |
32159 | ||
d77de738 | 32160 | @opindex mcmodel |
ddf6fe37 | 32161 | @item -mcmodel=@var{which} |
d77de738 ML |
32162 | Set the code model to one of |
32163 | ||
32164 | @table @samp | |
32165 | @item medlow | |
32166 | The Medium/Low code model: 64-bit addresses, programs | |
32167 | must be linked in the low 32 bits of memory. Programs can be statically | |
32168 | or dynamically linked. | |
32169 | ||
32170 | @item medmid | |
32171 | The Medium/Middle code model: 64-bit addresses, programs | |
32172 | must be linked in the low 44 bits of memory, the text and data segments must | |
32173 | be less than 2GB in size and the data segment must be located within 2GB of | |
32174 | the text segment. | |
32175 | ||
32176 | @item medany | |
32177 | The Medium/Anywhere code model: 64-bit addresses, programs | |
32178 | may be linked anywhere in memory, the text and data segments must be less | |
32179 | than 2GB in size and the data segment must be located within 2GB of the | |
32180 | text segment. | |
32181 | ||
32182 | @item embmedany | |
32183 | The Medium/Anywhere code model for embedded systems: | |
32184 | 64-bit addresses, the text and data segments must be less than 2GB in | |
32185 | size, both starting anywhere in memory (determined at link time). The | |
32186 | global register %g4 points to the base of the data segment. Programs | |
32187 | are statically linked and PIC is not supported. | |
32188 | @end table | |
32189 | ||
d77de738 | 32190 | @opindex mmemory-model |
ddf6fe37 | 32191 | @item -mmemory-model=@var{mem-model} |
d77de738 ML |
32192 | Set the memory model in force on the processor to one of |
32193 | ||
32194 | @table @samp | |
32195 | @item default | |
32196 | The default memory model for the processor and operating system. | |
32197 | ||
32198 | @item rmo | |
32199 | Relaxed Memory Order | |
32200 | ||
32201 | @item pso | |
32202 | Partial Store Order | |
32203 | ||
32204 | @item tso | |
32205 | Total Store Order | |
32206 | ||
32207 | @item sc | |
32208 | Sequential Consistency | |
32209 | @end table | |
32210 | ||
32211 | These memory models are formally defined in Appendix D of the SPARC-V9 | |
32212 | architecture manual, as set in the processor's @code{PSTATE.MM} field. | |
32213 | ||
d77de738 ML |
32214 | @opindex mstack-bias |
32215 | @opindex mno-stack-bias | |
ddf6fe37 AA |
32216 | @item -mstack-bias |
32217 | @itemx -mno-stack-bias | |
d77de738 ML |
32218 | With @option{-mstack-bias}, GCC assumes that the stack pointer, and |
32219 | frame pointer if present, are offset by @minus{}2047 which must be added back | |
32220 | when making stack frame references. This is the default in 64-bit mode. | |
32221 | Otherwise, assume no such offset is present. | |
32222 | @end table | |
32223 | ||
32224 | @node System V Options | |
32225 | @subsection Options for System V | |
32226 | ||
32227 | These additional options are available on System V Release 4 for | |
32228 | compatibility with other compilers on those systems: | |
32229 | ||
32230 | @table @gcctabopt | |
d77de738 | 32231 | @opindex G |
ddf6fe37 | 32232 | @item -G |
d77de738 ML |
32233 | Create a shared object. |
32234 | It is recommended that @option{-symbolic} or @option{-shared} be used instead. | |
32235 | ||
d77de738 | 32236 | @opindex Qy |
ddf6fe37 | 32237 | @item -Qy |
d77de738 ML |
32238 | Identify the versions of each tool used by the compiler, in a |
32239 | @code{.ident} assembler directive in the output. | |
32240 | ||
d77de738 | 32241 | @opindex Qn |
ddf6fe37 | 32242 | @item -Qn |
d77de738 ML |
32243 | Refrain from adding @code{.ident} directives to the output file (this is |
32244 | the default). | |
32245 | ||
d77de738 | 32246 | @opindex YP |
ddf6fe37 | 32247 | @item -YP,@var{dirs} |
d77de738 ML |
32248 | Search the directories @var{dirs}, and no others, for libraries |
32249 | specified with @option{-l}. | |
32250 | ||
d77de738 | 32251 | @opindex Ym |
ddf6fe37 | 32252 | @item -Ym,@var{dir} |
d77de738 ML |
32253 | Look in the directory @var{dir} to find the M4 preprocessor. |
32254 | The assembler uses this option. | |
32255 | @c This is supposed to go with a -Yd for predefined M4 macro files, but | |
32256 | @c the generic assembler that comes with Solaris takes just -Ym. | |
32257 | @end table | |
32258 | ||
32259 | @node V850 Options | |
32260 | @subsection V850 Options | |
32261 | @cindex V850 Options | |
32262 | ||
32263 | These @samp{-m} options are defined for V850 implementations: | |
32264 | ||
32265 | @table @gcctabopt | |
d77de738 ML |
32266 | @opindex mlong-calls |
32267 | @opindex mno-long-calls | |
ddf6fe37 AA |
32268 | @item -mlong-calls |
32269 | @itemx -mno-long-calls | |
d77de738 ML |
32270 | Treat all calls as being far away (near). If calls are assumed to be |
32271 | far away, the compiler always loads the function's address into a | |
32272 | register, and calls indirect through the pointer. | |
32273 | ||
d77de738 ML |
32274 | @opindex mno-ep |
32275 | @opindex mep | |
ddf6fe37 AA |
32276 | @item -mno-ep |
32277 | @itemx -mep | |
d77de738 ML |
32278 | Do not optimize (do optimize) basic blocks that use the same index |
32279 | pointer 4 or more times to copy pointer into the @code{ep} register, and | |
32280 | use the shorter @code{sld} and @code{sst} instructions. The @option{-mep} | |
32281 | option is on by default if you optimize. | |
32282 | ||
d77de738 ML |
32283 | @opindex mno-prolog-function |
32284 | @opindex mprolog-function | |
ddf6fe37 AA |
32285 | @item -mno-prolog-function |
32286 | @itemx -mprolog-function | |
d77de738 ML |
32287 | Do not use (do use) external functions to save and restore registers |
32288 | at the prologue and epilogue of a function. The external functions | |
32289 | are slower, but use less code space if more than one function saves | |
32290 | the same number of registers. The @option{-mprolog-function} option | |
32291 | is on by default if you optimize. | |
32292 | ||
d77de738 | 32293 | @opindex mspace |
ddf6fe37 | 32294 | @item -mspace |
d77de738 ML |
32295 | Try to make the code as small as possible. At present, this just turns |
32296 | on the @option{-mep} and @option{-mprolog-function} options. | |
32297 | ||
d77de738 | 32298 | @opindex mtda |
ddf6fe37 | 32299 | @item -mtda=@var{n} |
d77de738 ML |
32300 | Put static or global variables whose size is @var{n} bytes or less into |
32301 | the tiny data area that register @code{ep} points to. The tiny data | |
32302 | area can hold up to 256 bytes in total (128 bytes for byte references). | |
32303 | ||
d77de738 | 32304 | @opindex msda |
ddf6fe37 | 32305 | @item -msda=@var{n} |
d77de738 ML |
32306 | Put static or global variables whose size is @var{n} bytes or less into |
32307 | the small data area that register @code{gp} points to. The small data | |
32308 | area can hold up to 64 kilobytes. | |
32309 | ||
d77de738 | 32310 | @opindex mzda |
ddf6fe37 | 32311 | @item -mzda=@var{n} |
d77de738 ML |
32312 | Put static or global variables whose size is @var{n} bytes or less into |
32313 | the first 32 kilobytes of memory. | |
32314 | ||
d77de738 | 32315 | @opindex mv850 |
ddf6fe37 | 32316 | @item -mv850 |
d77de738 ML |
32317 | Specify that the target processor is the V850. |
32318 | ||
d77de738 | 32319 | @opindex mv850e3v5 |
ddf6fe37 | 32320 | @item -mv850e3v5 |
d77de738 ML |
32321 | Specify that the target processor is the V850E3V5. The preprocessor |
32322 | constant @code{__v850e3v5__} is defined if this option is used. | |
32323 | ||
d77de738 | 32324 | @opindex mv850e2v4 |
ddf6fe37 | 32325 | @item -mv850e2v4 |
d77de738 ML |
32326 | Specify that the target processor is the V850E3V5. This is an alias for |
32327 | the @option{-mv850e3v5} option. | |
32328 | ||
d77de738 | 32329 | @opindex mv850e2v3 |
ddf6fe37 | 32330 | @item -mv850e2v3 |
d77de738 ML |
32331 | Specify that the target processor is the V850E2V3. The preprocessor |
32332 | constant @code{__v850e2v3__} is defined if this option is used. | |
32333 | ||
d77de738 | 32334 | @opindex mv850e2 |
ddf6fe37 | 32335 | @item -mv850e2 |
d77de738 ML |
32336 | Specify that the target processor is the V850E2. The preprocessor |
32337 | constant @code{__v850e2__} is defined if this option is used. | |
32338 | ||
d77de738 | 32339 | @opindex mv850e1 |
ddf6fe37 | 32340 | @item -mv850e1 |
d77de738 ML |
32341 | Specify that the target processor is the V850E1. The preprocessor |
32342 | constants @code{__v850e1__} and @code{__v850e__} are defined if | |
32343 | this option is used. | |
32344 | ||
d77de738 | 32345 | @opindex mv850es |
ddf6fe37 | 32346 | @item -mv850es |
d77de738 ML |
32347 | Specify that the target processor is the V850ES. This is an alias for |
32348 | the @option{-mv850e1} option. | |
32349 | ||
d77de738 | 32350 | @opindex mv850e |
ddf6fe37 | 32351 | @item -mv850e |
d77de738 ML |
32352 | Specify that the target processor is the V850E@. The preprocessor |
32353 | constant @code{__v850e__} is defined if this option is used. | |
32354 | ||
32355 | If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1} | |
32356 | nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5} | |
32357 | are defined then a default target processor is chosen and the | |
32358 | relevant @samp{__v850*__} preprocessor constant is defined. | |
32359 | ||
32360 | The preprocessor constants @code{__v850} and @code{__v851__} are always | |
32361 | defined, regardless of which processor variant is the target. | |
32362 | ||
d77de738 ML |
32363 | @opindex mdisable-callt |
32364 | @opindex mno-disable-callt | |
ddf6fe37 AA |
32365 | @item -mdisable-callt |
32366 | @itemx -mno-disable-callt | |
d77de738 ML |
32367 | This option suppresses generation of the @code{CALLT} instruction for the |
32368 | v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850 | |
32369 | architecture. | |
32370 | ||
32371 | This option is enabled by default when the RH850 ABI is | |
32372 | in use (see @option{-mrh850-abi}), and disabled by default when the | |
32373 | GCC ABI is in use. If @code{CALLT} instructions are being generated | |
32374 | then the C preprocessor symbol @code{__V850_CALLT__} is defined. | |
32375 | ||
d77de738 ML |
32376 | @opindex mrelax |
32377 | @opindex mno-relax | |
ddf6fe37 AA |
32378 | @item -mrelax |
32379 | @itemx -mno-relax | |
d77de738 ML |
32380 | Pass on (or do not pass on) the @option{-mrelax} command-line option |
32381 | to the assembler. | |
32382 | ||
d77de738 ML |
32383 | @opindex mlong-jumps |
32384 | @opindex mno-long-jumps | |
ddf6fe37 AA |
32385 | @item -mlong-jumps |
32386 | @itemx -mno-long-jumps | |
d77de738 ML |
32387 | Disable (or re-enable) the generation of PC-relative jump instructions. |
32388 | ||
d77de738 ML |
32389 | @opindex msoft-float |
32390 | @opindex mhard-float | |
ddf6fe37 AA |
32391 | @item -msoft-float |
32392 | @itemx -mhard-float | |
d77de738 ML |
32393 | Disable (or re-enable) the generation of hardware floating point |
32394 | instructions. This option is only significant when the target | |
32395 | architecture is @samp{V850E2V3} or higher. If hardware floating point | |
32396 | instructions are being generated then the C preprocessor symbol | |
32397 | @code{__FPU_OK__} is defined, otherwise the symbol | |
32398 | @code{__NO_FPU__} is defined. | |
32399 | ||
d77de738 | 32400 | @opindex mloop |
ddf6fe37 | 32401 | @item -mloop |
d77de738 ML |
32402 | Enables the use of the e3v5 LOOP instruction. The use of this |
32403 | instruction is not enabled by default when the e3v5 architecture is | |
32404 | selected because its use is still experimental. | |
32405 | ||
d77de738 ML |
32406 | @opindex mrh850-abi |
32407 | @opindex mghs | |
ddf6fe37 AA |
32408 | @item -mrh850-abi |
32409 | @itemx -mghs | |
d77de738 ML |
32410 | Enables support for the RH850 version of the V850 ABI. This is the |
32411 | default. With this version of the ABI the following rules apply: | |
32412 | ||
32413 | @itemize | |
32414 | @item | |
32415 | Integer sized structures and unions are returned via a memory pointer | |
32416 | rather than a register. | |
32417 | ||
32418 | @item | |
32419 | Large structures and unions (more than 8 bytes in size) are passed by | |
32420 | value. | |
32421 | ||
32422 | @item | |
32423 | Functions are aligned to 16-bit boundaries. | |
32424 | ||
32425 | @item | |
32426 | The @option{-m8byte-align} command-line option is supported. | |
32427 | ||
32428 | @item | |
32429 | The @option{-mdisable-callt} command-line option is enabled by | |
32430 | default. The @option{-mno-disable-callt} command-line option is not | |
32431 | supported. | |
32432 | @end itemize | |
32433 | ||
32434 | When this version of the ABI is enabled the C preprocessor symbol | |
32435 | @code{__V850_RH850_ABI__} is defined. | |
32436 | ||
d77de738 | 32437 | @opindex mgcc-abi |
ddf6fe37 | 32438 | @item -mgcc-abi |
d77de738 ML |
32439 | Enables support for the old GCC version of the V850 ABI. With this |
32440 | version of the ABI the following rules apply: | |
32441 | ||
32442 | @itemize | |
32443 | @item | |
32444 | Integer sized structures and unions are returned in register @code{r10}. | |
32445 | ||
32446 | @item | |
32447 | Large structures and unions (more than 8 bytes in size) are passed by | |
32448 | reference. | |
32449 | ||
32450 | @item | |
32451 | Functions are aligned to 32-bit boundaries, unless optimizing for | |
32452 | size. | |
32453 | ||
32454 | @item | |
32455 | The @option{-m8byte-align} command-line option is not supported. | |
32456 | ||
32457 | @item | |
32458 | The @option{-mdisable-callt} command-line option is supported but not | |
32459 | enabled by default. | |
32460 | @end itemize | |
32461 | ||
32462 | When this version of the ABI is enabled the C preprocessor symbol | |
32463 | @code{__V850_GCC_ABI__} is defined. | |
32464 | ||
d77de738 ML |
32465 | @opindex m8byte-align |
32466 | @opindex mno-8byte-align | |
ddf6fe37 AA |
32467 | @item -m8byte-align |
32468 | @itemx -mno-8byte-align | |
d77de738 ML |
32469 | Enables support for @code{double} and @code{long long} types to be |
32470 | aligned on 8-byte boundaries. The default is to restrict the | |
32471 | alignment of all objects to at most 4-bytes. When | |
32472 | @option{-m8byte-align} is in effect the C preprocessor symbol | |
32473 | @code{__V850_8BYTE_ALIGN__} is defined. | |
32474 | ||
d77de738 | 32475 | @opindex mbig-switch |
ddf6fe37 | 32476 | @item -mbig-switch |
d77de738 ML |
32477 | Generate code suitable for big switch tables. Use this option only if |
32478 | the assembler/linker complain about out of range branches within a switch | |
32479 | table. | |
32480 | ||
d77de738 | 32481 | @opindex mapp-regs |
ddf6fe37 | 32482 | @item -mapp-regs |
d77de738 ML |
32483 | This option causes r2 and r5 to be used in the code generated by |
32484 | the compiler. This setting is the default. | |
32485 | ||
d77de738 | 32486 | @opindex mno-app-regs |
ddf6fe37 | 32487 | @item -mno-app-regs |
d77de738 ML |
32488 | This option causes r2 and r5 to be treated as fixed registers. |
32489 | ||
32490 | @end table | |
32491 | ||
32492 | @node VAX Options | |
32493 | @subsection VAX Options | |
32494 | @cindex VAX options | |
32495 | ||
32496 | These @samp{-m} options are defined for the VAX: | |
32497 | ||
32498 | @table @gcctabopt | |
d77de738 | 32499 | @opindex munix |
ddf6fe37 | 32500 | @item -munix |
d77de738 ML |
32501 | Do not output certain jump instructions (@code{aobleq} and so on) |
32502 | that the Unix assembler for the VAX cannot handle across long | |
32503 | ranges. | |
32504 | ||
d77de738 | 32505 | @opindex mgnu |
ddf6fe37 | 32506 | @item -mgnu |
d77de738 ML |
32507 | Do output those jump instructions, on the assumption that the |
32508 | GNU assembler is being used. | |
32509 | ||
d77de738 | 32510 | @opindex mg |
ddf6fe37 | 32511 | @item -mg |
d77de738 ML |
32512 | Output code for G-format floating-point numbers instead of D-format. |
32513 | ||
d77de738 ML |
32514 | @opindex mlra |
32515 | @opindex mno-lra | |
ddf6fe37 AA |
32516 | @item -mlra |
32517 | @itemx -mno-lra | |
d77de738 ML |
32518 | Enable Local Register Allocation. This is still experimental for the VAX, |
32519 | so by default the compiler uses standard reload. | |
32520 | @end table | |
32521 | ||
32522 | @node Visium Options | |
32523 | @subsection Visium Options | |
32524 | @cindex Visium options | |
32525 | ||
32526 | @table @gcctabopt | |
32527 | ||
d77de738 | 32528 | @opindex mdebug |
ddf6fe37 | 32529 | @item -mdebug |
d77de738 ML |
32530 | A program which performs file I/O and is destined to run on an MCM target |
32531 | should be linked with this option. It causes the libraries libc.a and | |
32532 | libdebug.a to be linked. The program should be run on the target under | |
32533 | the control of the GDB remote debugging stub. | |
32534 | ||
d77de738 | 32535 | @opindex msim |
ddf6fe37 | 32536 | @item -msim |
d77de738 ML |
32537 | A program which performs file I/O and is destined to run on the simulator |
32538 | should be linked with option. This causes libraries libc.a and libsim.a to | |
32539 | be linked. | |
32540 | ||
d77de738 ML |
32541 | @opindex mfpu |
32542 | @opindex mhard-float | |
ddf6fe37 AA |
32543 | @item -mfpu |
32544 | @itemx -mhard-float | |
d77de738 ML |
32545 | Generate code containing floating-point instructions. This is the |
32546 | default. | |
32547 | ||
d77de738 ML |
32548 | @opindex mno-fpu |
32549 | @opindex msoft-float | |
ddf6fe37 AA |
32550 | @item -mno-fpu |
32551 | @itemx -msoft-float | |
d77de738 ML |
32552 | Generate code containing library calls for floating-point. |
32553 | ||
32554 | @option{-msoft-float} changes the calling convention in the output file; | |
32555 | therefore, it is only useful if you compile @emph{all} of a program with | |
32556 | this option. In particular, you need to compile @file{libgcc.a}, the | |
32557 | library that comes with GCC, with @option{-msoft-float} in order for | |
32558 | this to work. | |
32559 | ||
d77de738 | 32560 | @opindex mcpu |
ddf6fe37 | 32561 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
32562 | Set the instruction set, register set, and instruction scheduling parameters |
32563 | for machine type @var{cpu_type}. Supported values for @var{cpu_type} are | |
32564 | @samp{mcm}, @samp{gr5} and @samp{gr6}. | |
32565 | ||
32566 | @samp{mcm} is a synonym of @samp{gr5} present for backward compatibility. | |
32567 | ||
32568 | By default (unless configured otherwise), GCC generates code for the GR5 | |
32569 | variant of the Visium architecture. | |
32570 | ||
32571 | With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium | |
32572 | architecture. The only difference from GR5 code is that the compiler will | |
32573 | generate block move instructions. | |
32574 | ||
d77de738 | 32575 | @opindex mtune |
ddf6fe37 | 32576 | @item -mtune=@var{cpu_type} |
d77de738 ML |
32577 | Set the instruction scheduling parameters for machine type @var{cpu_type}, |
32578 | but do not set the instruction set or register set that the option | |
32579 | @option{-mcpu=@var{cpu_type}} would. | |
32580 | ||
d77de738 | 32581 | @opindex msv-mode |
ddf6fe37 | 32582 | @item -msv-mode |
d77de738 ML |
32583 | Generate code for the supervisor mode, where there are no restrictions on |
32584 | the access to general registers. This is the default. | |
32585 | ||
d77de738 | 32586 | @opindex muser-mode |
ddf6fe37 | 32587 | @item -muser-mode |
d77de738 ML |
32588 | Generate code for the user mode, where the access to some general registers |
32589 | is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this | |
32590 | mode; on the GR6, only registers r29 to r31 are affected. | |
32591 | @end table | |
32592 | ||
32593 | @node VMS Options | |
32594 | @subsection VMS Options | |
32595 | ||
32596 | These @samp{-m} options are defined for the VMS implementations: | |
32597 | ||
32598 | @table @gcctabopt | |
d77de738 | 32599 | @opindex mvms-return-codes |
ddf6fe37 | 32600 | @item -mvms-return-codes |
d77de738 ML |
32601 | Return VMS condition codes from @code{main}. The default is to return POSIX-style |
32602 | condition (e.g.@: error) codes. | |
32603 | ||
d77de738 | 32604 | @opindex mdebug-main=@var{prefix} |
ddf6fe37 | 32605 | @item -mdebug-main=@var{prefix} |
d77de738 ML |
32606 | Flag the first routine whose name starts with @var{prefix} as the main |
32607 | routine for the debugger. | |
32608 | ||
d77de738 | 32609 | @opindex mmalloc64 |
ddf6fe37 | 32610 | @item -mmalloc64 |
d77de738 ML |
32611 | Default to 64-bit memory allocation routines. |
32612 | ||
d77de738 | 32613 | @opindex mpointer-size=@var{size} |
ddf6fe37 | 32614 | @item -mpointer-size=@var{size} |
d77de738 ML |
32615 | Set the default size of pointers. Possible options for @var{size} are |
32616 | @samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long} | |
32617 | for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers. | |
32618 | The later option disables @code{pragma pointer_size}. | |
32619 | @end table | |
32620 | ||
32621 | @node VxWorks Options | |
32622 | @subsection VxWorks Options | |
32623 | @cindex VxWorks Options | |
32624 | ||
32625 | The options in this section are defined for all VxWorks targets. | |
32626 | Options specific to the target hardware are listed with the other | |
32627 | options for that target. | |
32628 | ||
32629 | @table @gcctabopt | |
d77de738 | 32630 | @opindex mrtp |
ddf6fe37 | 32631 | @item -mrtp |
d77de738 ML |
32632 | GCC can generate code for both VxWorks kernels and real time processes |
32633 | (RTPs). This option switches from the former to the latter. It also | |
32634 | defines the preprocessor macro @code{__RTP__}. | |
32635 | ||
b6f4b000 AO |
32636 | @opindex msmp |
32637 | @item -msmp | |
32638 | Select SMP runtimes for linking. Not available on architectures other | |
32639 | than PowerPC, nor on VxWorks version 7 or later, in which the selection | |
32640 | is part of the VxWorks build configuration and the library paths are the | |
32641 | same for either choice. | |
32642 | ||
d77de738 | 32643 | @opindex non-static |
ddf6fe37 | 32644 | @item -non-static |
d77de738 ML |
32645 | Link an RTP executable against shared libraries rather than static |
32646 | libraries. The options @option{-static} and @option{-shared} can | |
32647 | also be used for RTPs (@pxref{Link Options}); @option{-static} | |
32648 | is the default. | |
32649 | ||
d77de738 ML |
32650 | @opindex Bstatic |
32651 | @opindex Bdynamic | |
ddf6fe37 AA |
32652 | @item -Bstatic |
32653 | @itemx -Bdynamic | |
d77de738 ML |
32654 | These options are passed down to the linker. They are defined for |
32655 | compatibility with Diab. | |
32656 | ||
d77de738 | 32657 | @opindex Xbind-lazy |
ddf6fe37 | 32658 | @item -Xbind-lazy |
d77de738 ML |
32659 | Enable lazy binding of function calls. This option is equivalent to |
32660 | @option{-Wl,-z,now} and is defined for compatibility with Diab. | |
32661 | ||
d77de738 | 32662 | @opindex Xbind-now |
ddf6fe37 | 32663 | @item -Xbind-now |
d77de738 ML |
32664 | Disable lazy binding of function calls. This option is the default and |
32665 | is defined for compatibility with Diab. | |
32666 | @end table | |
32667 | ||
32668 | @node x86 Options | |
32669 | @subsection x86 Options | |
32670 | @cindex x86 Options | |
32671 | ||
32672 | These @samp{-m} options are defined for the x86 family of computers. | |
32673 | ||
32674 | @table @gcctabopt | |
32675 | ||
d77de738 | 32676 | @opindex march |
ddf6fe37 | 32677 | @item -march=@var{cpu-type} |
d77de738 ML |
32678 | Generate instructions for the machine type @var{cpu-type}. In contrast to |
32679 | @option{-mtune=@var{cpu-type}}, which merely tunes the generated code | |
32680 | for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC | |
32681 | to generate code that may not run at all on processors other than the one | |
32682 | indicated. Specifying @option{-march=@var{cpu-type}} implies | |
32683 | @option{-mtune=@var{cpu-type}}, except where noted otherwise. | |
32684 | ||
32685 | The choices for @var{cpu-type} are: | |
32686 | ||
32687 | @table @samp | |
32688 | @item native | |
32689 | This selects the CPU to generate code for at compilation time by determining | |
32690 | the processor type of the compiling machine. Using @option{-march=native} | |
32691 | enables all instruction subsets supported by the local machine (hence | |
32692 | the result might not run on different machines). Using @option{-mtune=native} | |
32693 | produces code optimized for the local machine under the constraints | |
32694 | of the selected instruction set. | |
32695 | ||
32696 | @item x86-64 | |
32697 | A generic CPU with 64-bit extensions. | |
32698 | ||
32699 | @item x86-64-v2 | |
32700 | @itemx x86-64-v3 | |
32701 | @itemx x86-64-v4 | |
32702 | These choices for @var{cpu-type} select the corresponding | |
32703 | micro-architecture level from the x86-64 psABI. On ABIs other than | |
32704 | the x86-64 psABI they select the same CPU features as the x86-64 psABI | |
32705 | documents for the particular micro-architecture level. | |
32706 | ||
32707 | Since these @var{cpu-type} values do not have a corresponding | |
32708 | @option{-mtune} setting, using @option{-march} with these values enables | |
32709 | generic tuning. Specific tuning can be enabled using the | |
32710 | @option{-mtune=@var{other-cpu-type}} option with an appropriate | |
32711 | @var{other-cpu-type} value. | |
32712 | ||
32713 | @item i386 | |
32714 | Original Intel i386 CPU@. | |
32715 | ||
32716 | @item i486 | |
32717 | Intel i486 CPU@. (No scheduling is implemented for this chip.) | |
32718 | ||
32719 | @item i586 | |
32720 | @itemx pentium | |
32721 | Intel Pentium CPU with no MMX support. | |
32722 | ||
32723 | @item lakemont | |
32724 | Intel Lakemont MCU, based on Intel Pentium CPU. | |
32725 | ||
32726 | @item pentium-mmx | |
32727 | Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support. | |
32728 | ||
32729 | @item pentiumpro | |
32730 | Intel Pentium Pro CPU@. | |
32731 | ||
32732 | @item i686 | |
32733 | When used with @option{-march}, the Pentium Pro | |
32734 | instruction set is used, so the code runs on all i686 family chips. | |
32735 | When used with @option{-mtune}, it has the same meaning as @samp{generic}. | |
32736 | ||
32737 | @item pentium2 | |
32738 | Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction | |
32739 | set support. | |
32740 | ||
32741 | @item pentium3 | |
32742 | @itemx pentium3m | |
32743 | Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE | |
32744 | instruction set support. | |
32745 | ||
32746 | @item pentium-m | |
32747 | Intel Pentium M; low-power version of Intel Pentium III CPU | |
32748 | with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino | |
32749 | notebooks. | |
32750 | ||
32751 | @item pentium4 | |
32752 | @itemx pentium4m | |
32753 | Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support. | |
32754 | ||
32755 | @item prescott | |
32756 | Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR | |
32757 | instruction set support. | |
32758 | ||
32759 | @item nocona | |
32760 | Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE, | |
32761 | SSE2, SSE3 and FXSR instruction set support. | |
32762 | ||
32763 | @item core2 | |
32764 | Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16, | |
32765 | SAHF and FXSR instruction set support. | |
32766 | ||
32767 | @item nehalem | |
32768 | Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
32769 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support. | |
32770 | ||
32771 | @item westmere | |
32772 | Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
32773 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support. | |
32774 | ||
32775 | @item sandybridge | |
32776 | Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
32777 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set | |
32778 | support. | |
32779 | ||
32780 | @item ivybridge | |
32781 | Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
32782 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND | |
32783 | and F16C instruction set support. | |
32784 | ||
32785 | @item haswell | |
32786 | Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32787 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32788 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support. | |
32789 | ||
32790 | @item broadwell | |
32791 | Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32792 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32793 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW | |
32794 | instruction set support. | |
32795 | ||
32796 | @item skylake | |
32797 | Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32798 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32799 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
32800 | CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support. | |
32801 | ||
32802 | @item bonnell | |
32803 | Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3 | |
32804 | instruction set support. | |
32805 | ||
32806 | @item silvermont | |
32807 | Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32808 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND | |
32809 | instruction set support. | |
32810 | ||
32811 | @item goldmont | |
32812 | Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32813 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA, | |
32814 | RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction | |
32815 | set support. | |
32816 | ||
32817 | @item goldmont-plus | |
32818 | Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32819 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, | |
32820 | SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, | |
32821 | RDPID and SGX instruction set support. | |
32822 | ||
32823 | @item tremont | |
32824 | Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32825 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA, | |
32826 | RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID, | |
32827 | SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set | |
32828 | support. | |
32829 | ||
32830 | @item sierraforest | |
32831 | Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32832 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
32833 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
32834 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
32835 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
503643e8 LC |
32836 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD and UINTR instruction set |
32837 | support. | |
d77de738 ML |
32838 | |
32839 | @item grandridge | |
32840 | Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32841 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
32842 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
32843 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
32844 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
503643e8 LC |
32845 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD, UINTR and RAOINT |
32846 | instruction set support. | |
d77de738 | 32847 | |
a5088dc3 MZ |
32848 | @item arrowlake |
32849 | Intel Arrow Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32850 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
32851 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
32852 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
32853 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
32854 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set support. | |
32855 | ||
32856 | @item arrowlake-s | |
32857 | Intel Arrow Lake S CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32858 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
32859 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
32860 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
32861 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
32862 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, SM3 | |
32863 | and SM4 instruction set support. | |
32864 | ||
7370c479 HJ |
32865 | @item clearwaterforest |
32866 | Intel Clearwater Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, | |
32867 | SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, | |
32868 | XSAVEC, XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, | |
32869 | MOVDIRI, MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, | |
32870 | LZCNT, PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
32871 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, SM3, SM4, | |
32872 | USER_MSR and PREFETCHI instruction set support. | |
32873 | ||
f019251a HJ |
32874 | @item pantherlake |
32875 | Intel Panther Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32876 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
32877 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
32878 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
32879 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
32880 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, SM3, SM4 | |
32881 | and PREFETCHI instruction set support. | |
32882 | ||
d77de738 ML |
32883 | @item knl |
32884 | Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32885 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32886 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32887 | AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1 instruction set support. | |
32888 | ||
32889 | @item knm | |
32890 | Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32891 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32892 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32893 | AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1, AVX5124VNNIW, | |
32894 | AVX5124FMAPS and AVX512VPOPCNTDQ instruction set support. | |
32895 | ||
32896 | @item skylake-avx512 | |
32897 | Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32898 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32899 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32900 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, | |
32901 | AVX512DQ and AVX512CD instruction set support. | |
32902 | ||
32903 | @item cannonlake | |
32904 | Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, | |
32905 | SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, | |
32906 | FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, | |
32907 | PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, | |
32908 | AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set | |
32909 | support. | |
32910 | ||
32911 | @item icelake-client | |
32912 | Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32913 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32914 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32915 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
32916 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2 | |
32917 | , VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support. | |
32918 | ||
32919 | @item icelake-server | |
32920 | Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32921 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32922 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32923 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
32924 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2 | |
32925 | , VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB | |
32926 | instruction set support. | |
32927 | ||
32928 | @item cascadelake | |
32929 | Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32930 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32931 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
32932 | CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ, | |
32933 | AVX512CD and AVX512VNNI instruction set support. | |
32934 | ||
32935 | @item cooperlake | |
32936 | Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32937 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32938 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
32939 | CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ, | |
32940 | AVX512CD, AVX512VNNI and AVX512BF16 instruction set support. | |
32941 | ||
32942 | @item tigerlake | |
32943 | Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32944 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32945 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
32946 | CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD | |
32947 | PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
32948 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB, | |
32949 | AVX512VP2INTERSECT and KEYLOCKER instruction set support. | |
32950 | ||
32951 | @item sapphirerapids | |
32952 | Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32953 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32954 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32955 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
32956 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
32957 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB, | |
32958 | MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK, | |
29ecb952 | 32959 | UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16 and AVX512BF16 |
d77de738 ML |
32960 | instruction set support. |
32961 | ||
32962 | @item alderlake | |
32963 | Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32964 | SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES, | |
32965 | XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B, | |
32966 | CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU, | |
32967 | VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set | |
32968 | support. | |
32969 | ||
32970 | @item rocketlake | |
32971 | Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3 | |
32972 | , SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32973 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
32974 | CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD | |
32975 | PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
32976 | VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support. | |
32977 | ||
32978 | @item graniterapids | |
32979 | Intel graniterapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32980 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32981 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32982 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
32983 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
32984 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB, | |
38daaaa9 HJ |
32985 | MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK, |
32986 | UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16, AVX512BF16, AMX-FP16 | |
32987 | and PREFETCHI instruction set support. | |
d77de738 | 32988 | |
a0cb65d3 MZ |
32989 | @item graniterapids-d |
32990 | Intel graniterapids D CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32991 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32992 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32993 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
32994 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
32995 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB, | |
38daaaa9 HJ |
32996 | MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK, |
32997 | UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16, AVX512BF16, AMX-FP16, | |
32998 | PREFETCHI and AMX-COMPLEX instruction set support. | |
a0cb65d3 | 32999 | |
d77de738 ML |
33000 | @item k6 |
33001 | AMD K6 CPU with MMX instruction set support. | |
33002 | ||
33003 | @item k6-2 | |
33004 | @itemx k6-3 | |
33005 | Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support. | |
33006 | ||
33007 | @item athlon | |
33008 | @itemx athlon-tbird | |
33009 | AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions | |
33010 | support. | |
33011 | ||
33012 | @item athlon-4 | |
33013 | @itemx athlon-xp | |
33014 | @itemx athlon-mp | |
33015 | Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE | |
33016 | instruction set support. | |
33017 | ||
33018 | @item k8 | |
33019 | @itemx opteron | |
33020 | @itemx athlon64 | |
33021 | @itemx athlon-fx | |
33022 | Processors based on the AMD K8 core with x86-64 instruction set support, | |
33023 | including the AMD Opteron, Athlon 64, and Athlon 64 FX processors. | |
33024 | (This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit | |
33025 | instruction set extensions.) | |
33026 | ||
33027 | @item k8-sse3 | |
33028 | @itemx opteron-sse3 | |
33029 | @itemx athlon64-sse3 | |
33030 | Improved versions of AMD K8 cores with SSE3 instruction set support. | |
33031 | ||
33032 | @item amdfam10 | |
33033 | @itemx barcelona | |
33034 | CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This | |
33035 | supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit | |
33036 | instruction set extensions.) | |
33037 | ||
33038 | @item bdver1 | |
33039 | CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This | |
33040 | supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, | |
33041 | SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.) | |
33042 | ||
33043 | @item bdver2 | |
33044 | AMD Family 15h core based CPUs with x86-64 instruction set support. (This | |
33045 | supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, | |
33046 | SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set | |
33047 | extensions.) | |
33048 | ||
33049 | @item bdver3 | |
33050 | AMD Family 15h core based CPUs with x86-64 instruction set support. (This | |
33051 | supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES, | |
33052 | PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and | |
33053 | 64-bit instruction set extensions.) | |
33054 | ||
33055 | @item bdver4 | |
33056 | AMD Family 15h core based CPUs with x86-64 instruction set support. (This | |
33057 | supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP, | |
33058 | AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, | |
33059 | SSE4.2, ABM and 64-bit instruction set extensions.) | |
33060 | ||
33061 | @item znver1 | |
33062 | AMD Family 17h core based CPUs with x86-64 instruction set support. (This | |
33063 | supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX, | |
33064 | SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, | |
33065 | SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit | |
33066 | instruction set extensions.) | |
33067 | ||
33068 | @item znver2 | |
33069 | AMD Family 17h core based CPUs with x86-64 instruction set support. (This | |
33070 | supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, | |
33071 | MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, | |
33072 | SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, | |
33073 | WBNOINVD, and 64-bit instruction set extensions.) | |
33074 | ||
33075 | @item znver3 | |
33076 | AMD Family 19h core based CPUs with x86-64 instruction set support. (This | |
33077 | supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, | |
33078 | MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, | |
33079 | SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, | |
33080 | WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.) | |
33081 | ||
33082 | @item znver4 | |
33083 | AMD Family 19h core based CPUs with x86-64 instruction set support. (This | |
33084 | supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, | |
33085 | MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, | |
33086 | SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, | |
33087 | WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD, | |
33088 | AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI, | |
33089 | AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.) | |
33090 | ||
33091 | @item btver1 | |
33092 | CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This | |
33093 | supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit | |
33094 | instruction set extensions.) | |
33095 | ||
33096 | @item btver2 | |
33097 | CPUs based on AMD Family 16h cores with x86-64 instruction set support. This | |
33098 | includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM, | |
33099 | SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions. | |
33100 | ||
33101 | @item winchip-c6 | |
33102 | IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction | |
33103 | set support. | |
33104 | ||
33105 | @item winchip2 | |
33106 | IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@: | |
33107 | instruction set support. | |
33108 | ||
33109 | @item c3 | |
33110 | VIA C3 CPU with MMX and 3DNow!@: instruction set support. | |
33111 | (No scheduling is implemented for this chip.) | |
33112 | ||
33113 | @item c3-2 | |
33114 | VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support. | |
33115 | (No scheduling is implemented for this chip.) | |
33116 | ||
33117 | @item c7 | |
33118 | VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support. | |
33119 | (No scheduling is implemented for this chip.) | |
33120 | ||
33121 | @item samuel-2 | |
33122 | VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support. | |
33123 | (No scheduling is implemented for this chip.) | |
33124 | ||
33125 | @item nehemiah | |
33126 | VIA Eden Nehemiah CPU with MMX and SSE instruction set support. | |
33127 | (No scheduling is implemented for this chip.) | |
33128 | ||
33129 | @item esther | |
33130 | VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support. | |
33131 | (No scheduling is implemented for this chip.) | |
33132 | ||
33133 | @item eden-x2 | |
33134 | VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support. | |
33135 | (No scheduling is implemented for this chip.) | |
33136 | ||
33137 | @item eden-x4 | |
33138 | VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, | |
33139 | AVX and AVX2 instruction set support. | |
33140 | (No scheduling is implemented for this chip.) | |
33141 | ||
33142 | @item nano | |
33143 | Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 | |
33144 | instruction set support. | |
33145 | (No scheduling is implemented for this chip.) | |
33146 | ||
33147 | @item nano-1000 | |
33148 | VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 | |
33149 | instruction set support. | |
33150 | (No scheduling is implemented for this chip.) | |
33151 | ||
33152 | @item nano-2000 | |
33153 | VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 | |
33154 | instruction set support. | |
33155 | (No scheduling is implemented for this chip.) | |
33156 | ||
33157 | @item nano-3000 | |
33158 | VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 | |
33159 | instruction set support. | |
33160 | (No scheduling is implemented for this chip.) | |
33161 | ||
33162 | @item nano-x2 | |
33163 | VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 | |
33164 | instruction set support. | |
33165 | (No scheduling is implemented for this chip.) | |
33166 | ||
33167 | @item nano-x4 | |
33168 | VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 | |
33169 | instruction set support. | |
33170 | (No scheduling is implemented for this chip.) | |
33171 | ||
33172 | @item lujiazui | |
33173 | ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, | |
33174 | SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16, | |
33175 | ABM, BMI, BMI2, F16C, FXSR, RDSEED instruction set support. | |
33176 | ||
33177 | @item geode | |
33178 | AMD Geode embedded processor with MMX and 3DNow!@: instruction set support. | |
33179 | @end table | |
33180 | ||
d77de738 | 33181 | @opindex mtune |
ddf6fe37 | 33182 | @item -mtune=@var{cpu-type} |
d77de738 ML |
33183 | Tune to @var{cpu-type} everything applicable about the generated code, except |
33184 | for the ABI and the set of available instructions. | |
33185 | While picking a specific @var{cpu-type} schedules things appropriately | |
33186 | for that particular chip, the compiler does not generate any code that | |
33187 | cannot run on the default machine type unless you use a | |
33188 | @option{-march=@var{cpu-type}} option. | |
33189 | For example, if GCC is configured for i686-pc-linux-gnu | |
33190 | then @option{-mtune=pentium4} generates code that is tuned for Pentium 4 | |
33191 | but still runs on i686 machines. | |
33192 | ||
33193 | The choices for @var{cpu-type} are the same as for @option{-march}. | |
33194 | In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}: | |
33195 | ||
33196 | @table @samp | |
33197 | @item generic | |
33198 | Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors. | |
33199 | If you know the CPU on which your code will run, then you should use | |
33200 | the corresponding @option{-mtune} or @option{-march} option instead of | |
33201 | @option{-mtune=generic}. But, if you do not know exactly what CPU users | |
33202 | of your application will have, then you should use this option. | |
33203 | ||
33204 | As new processors are deployed in the marketplace, the behavior of this | |
33205 | option will change. Therefore, if you upgrade to a newer version of | |
33206 | GCC, code generation controlled by this option will change to reflect | |
33207 | the processors | |
33208 | that are most common at the time that version of GCC is released. | |
33209 | ||
33210 | There is no @option{-march=generic} option because @option{-march} | |
33211 | indicates the instruction set the compiler can use, and there is no | |
33212 | generic instruction set applicable to all processors. In contrast, | |
33213 | @option{-mtune} indicates the processor (or, in this case, collection of | |
33214 | processors) for which the code is optimized. | |
33215 | ||
33216 | @item intel | |
33217 | Produce code optimized for the most current Intel processors, which are | |
33218 | Haswell and Silvermont for this version of GCC. If you know the CPU | |
33219 | on which your code will run, then you should use the corresponding | |
33220 | @option{-mtune} or @option{-march} option instead of @option{-mtune=intel}. | |
33221 | But, if you want your application performs better on both Haswell and | |
33222 | Silvermont, then you should use this option. | |
33223 | ||
33224 | As new Intel processors are deployed in the marketplace, the behavior of | |
33225 | this option will change. Therefore, if you upgrade to a newer version of | |
33226 | GCC, code generation controlled by this option will change to reflect | |
33227 | the most current Intel processors at the time that version of GCC is | |
33228 | released. | |
33229 | ||
33230 | There is no @option{-march=intel} option because @option{-march} indicates | |
33231 | the instruction set the compiler can use, and there is no common | |
33232 | instruction set applicable to all processors. In contrast, | |
33233 | @option{-mtune} indicates the processor (or, in this case, collection of | |
33234 | processors) for which the code is optimized. | |
33235 | @end table | |
33236 | ||
d77de738 | 33237 | @opindex mcpu |
ddf6fe37 | 33238 | @item -mcpu=@var{cpu-type} |
d77de738 ML |
33239 | A deprecated synonym for @option{-mtune}. |
33240 | ||
d77de738 | 33241 | @opindex mfpmath |
ddf6fe37 | 33242 | @item -mfpmath=@var{unit} |
d77de738 ML |
33243 | Generate floating-point arithmetic for selected unit @var{unit}. The choices |
33244 | for @var{unit} are: | |
33245 | ||
33246 | @table @samp | |
33247 | @item 387 | |
33248 | Use the standard 387 floating-point coprocessor present on the majority of chips and | |
33249 | emulated otherwise. Code compiled with this option runs almost everywhere. | |
33250 | The temporary results are computed in 80-bit precision instead of the precision | |
33251 | specified by the type, resulting in slightly different results compared to most | |
33252 | of other chips. See @option{-ffloat-store} for more detailed description. | |
33253 | ||
33254 | This is the default choice for non-Darwin x86-32 targets. | |
33255 | ||
33256 | @item sse | |
33257 | Use scalar floating-point instructions present in the SSE instruction set. | |
33258 | This instruction set is supported by Pentium III and newer chips, | |
33259 | and in the AMD line | |
33260 | by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE | |
33261 | instruction set supports only single-precision arithmetic, thus the double and | |
33262 | extended-precision arithmetic are still done using 387. A later version, present | |
33263 | only in Pentium 4 and AMD x86-64 chips, supports double-precision | |
33264 | arithmetic too. | |
33265 | ||
33266 | For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse} | |
33267 | or @option{-msse2} switches to enable SSE extensions and make this option | |
33268 | effective. For the x86-64 compiler, these extensions are enabled by default. | |
33269 | ||
33270 | The resulting code should be considerably faster in the majority of cases and avoid | |
33271 | the numerical instability problems of 387 code, but may break some existing | |
33272 | code that expects temporaries to be 80 bits. | |
33273 | ||
33274 | This is the default choice for the x86-64 compiler, Darwin x86-32 targets, | |
33275 | and the default choice for x86-32 targets with the SSE2 instruction set | |
33276 | when @option{-ffast-math} is enabled. | |
33277 | ||
33278 | @item sse,387 | |
33279 | @itemx sse+387 | |
33280 | @itemx both | |
33281 | Attempt to utilize both instruction sets at once. This effectively doubles the | |
33282 | amount of available registers, and on chips with separate execution units for | |
33283 | 387 and SSE the execution resources too. Use this option with care, as it is | |
33284 | still experimental, because the GCC register allocator does not model separate | |
33285 | functional units well, resulting in unstable performance. | |
33286 | @end table | |
33287 | ||
d77de738 | 33288 | @opindex masm=@var{dialect} |
ddf6fe37 | 33289 | @item -masm=@var{dialect} |
d77de738 ML |
33290 | Output assembly instructions using selected @var{dialect}. Also affects |
33291 | which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and | |
33292 | extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect | |
33293 | order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does | |
33294 | not support @samp{intel}. | |
33295 | ||
d77de738 ML |
33296 | @opindex mieee-fp |
33297 | @opindex mno-ieee-fp | |
ddf6fe37 AA |
33298 | @item -mieee-fp |
33299 | @itemx -mno-ieee-fp | |
d77de738 ML |
33300 | Control whether or not the compiler uses IEEE floating-point |
33301 | comparisons. These correctly handle the case where the result of a | |
33302 | comparison is unordered. | |
33303 | ||
30348d30 | 33304 | @opindex m80387 |
d77de738 | 33305 | @opindex mhard-float |
ddf6fe37 AA |
33306 | @item -m80387 |
33307 | @itemx -mhard-float | |
d77de738 ML |
33308 | Generate output containing 80387 instructions for floating point. |
33309 | ||
d77de738 ML |
33310 | @opindex no-80387 |
33311 | @opindex msoft-float | |
ddf6fe37 AA |
33312 | @item -mno-80387 |
33313 | @itemx -msoft-float | |
d77de738 ML |
33314 | Generate output containing library calls for floating point. |
33315 | ||
33316 | @strong{Warning:} the requisite libraries are not part of GCC@. | |
33317 | Normally the facilities of the machine's usual C compiler are used, but | |
33318 | this cannot be done directly in cross-compilation. You must make your | |
33319 | own arrangements to provide suitable library functions for | |
33320 | cross-compilation. | |
33321 | ||
33322 | On machines where a function returns floating-point results in the 80387 | |
33323 | register stack, some floating-point opcodes may be emitted even if | |
33324 | @option{-msoft-float} is used. | |
33325 | ||
d77de738 ML |
33326 | @opindex mno-fp-ret-in-387 |
33327 | @opindex mfp-ret-in-387 | |
ddf6fe37 | 33328 | @item -mno-fp-ret-in-387 |
d77de738 ML |
33329 | Do not use the FPU registers for return values of functions. |
33330 | ||
33331 | The usual calling convention has functions return values of types | |
33332 | @code{float} and @code{double} in an FPU register, even if there | |
33333 | is no FPU@. The idea is that the operating system should emulate | |
33334 | an FPU@. | |
33335 | ||
33336 | The option @option{-mno-fp-ret-in-387} causes such values to be returned | |
33337 | in ordinary CPU registers instead. | |
33338 | ||
d77de738 ML |
33339 | @opindex mno-fancy-math-387 |
33340 | @opindex mfancy-math-387 | |
ddf6fe37 | 33341 | @item -mno-fancy-math-387 |
d77de738 ML |
33342 | Some 387 emulators do not support the @code{sin}, @code{cos} and |
33343 | @code{sqrt} instructions for the 387. Specify this option to avoid | |
33344 | generating those instructions. | |
33345 | This option is overridden when @option{-march} | |
33346 | indicates that the target CPU always has an FPU and so the | |
33347 | instruction does not need emulation. These | |
33348 | instructions are not generated unless you also use the | |
33349 | @option{-funsafe-math-optimizations} switch. | |
33350 | ||
d77de738 ML |
33351 | @opindex malign-double |
33352 | @opindex mno-align-double | |
ddf6fe37 AA |
33353 | @item -malign-double |
33354 | @itemx -mno-align-double | |
d77de738 ML |
33355 | Control whether GCC aligns @code{double}, @code{long double}, and |
33356 | @code{long long} variables on a two-word boundary or a one-word | |
33357 | boundary. Aligning @code{double} variables on a two-word boundary | |
33358 | produces code that runs somewhat faster on a Pentium at the | |
33359 | expense of more memory. | |
33360 | ||
33361 | On x86-64, @option{-malign-double} is enabled by default. | |
33362 | ||
33363 | @strong{Warning:} if you use the @option{-malign-double} switch, | |
33364 | structures containing the above types are aligned differently than | |
33365 | the published application binary interface specifications for the x86-32 | |
33366 | and are not binary compatible with structures in code compiled | |
33367 | without that switch. | |
33368 | ||
d77de738 ML |
33369 | @opindex m96bit-long-double |
33370 | @opindex m128bit-long-double | |
ddf6fe37 AA |
33371 | @item -m96bit-long-double |
33372 | @itemx -m128bit-long-double | |
d77de738 ML |
33373 | These switches control the size of @code{long double} type. The x86-32 |
33374 | application binary interface specifies the size to be 96 bits, | |
33375 | so @option{-m96bit-long-double} is the default in 32-bit mode. | |
33376 | ||
33377 | Modern architectures (Pentium and newer) prefer @code{long double} | |
33378 | to be aligned to an 8- or 16-byte boundary. In arrays or structures | |
33379 | conforming to the ABI, this is not possible. So specifying | |
33380 | @option{-m128bit-long-double} aligns @code{long double} | |
33381 | to a 16-byte boundary by padding the @code{long double} with an additional | |
33382 | 32-bit zero. | |
33383 | ||
33384 | In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as | |
33385 | its ABI specifies that @code{long double} is aligned on 16-byte boundary. | |
33386 | ||
33387 | Notice that neither of these options enable any extra precision over the x87 | |
33388 | standard of 80 bits for a @code{long double}. | |
33389 | ||
33390 | @strong{Warning:} if you override the default value for your target ABI, this | |
33391 | changes the size of | |
33392 | structures and arrays containing @code{long double} variables, | |
33393 | as well as modifying the function calling convention for functions taking | |
33394 | @code{long double}. Hence they are not binary-compatible | |
33395 | with code compiled without that switch. | |
33396 | ||
d77de738 ML |
33397 | @opindex mlong-double-64 |
33398 | @opindex mlong-double-80 | |
33399 | @opindex mlong-double-128 | |
ddf6fe37 AA |
33400 | @item -mlong-double-64 |
33401 | @itemx -mlong-double-80 | |
33402 | @itemx -mlong-double-128 | |
d77de738 ML |
33403 | These switches control the size of @code{long double} type. A size |
33404 | of 64 bits makes the @code{long double} type equivalent to the @code{double} | |
33405 | type. This is the default for 32-bit Bionic C library. A size | |
33406 | of 128 bits makes the @code{long double} type equivalent to the | |
33407 | @code{__float128} type. This is the default for 64-bit Bionic C library. | |
33408 | ||
33409 | @strong{Warning:} if you override the default value for your target ABI, this | |
33410 | changes the size of | |
33411 | structures and arrays containing @code{long double} variables, | |
33412 | as well as modifying the function calling convention for functions taking | |
33413 | @code{long double}. Hence they are not binary-compatible | |
33414 | with code compiled without that switch. | |
33415 | ||
d77de738 | 33416 | @opindex malign-data |
ddf6fe37 | 33417 | @item -malign-data=@var{type} |
d77de738 ML |
33418 | Control how GCC aligns variables. Supported values for @var{type} are |
33419 | @samp{compat} uses increased alignment value compatible uses GCC 4.8 | |
33420 | and earlier, @samp{abi} uses alignment value as specified by the | |
33421 | psABI, and @samp{cacheline} uses increased alignment value to match | |
33422 | the cache line size. @samp{compat} is the default. | |
33423 | ||
d77de738 | 33424 | @opindex mlarge-data-threshold |
ddf6fe37 | 33425 | @item -mlarge-data-threshold=@var{threshold} |
1a64156c UB |
33426 | When @option{-mcmodel=medium} or @option{-mcmodel=large} is specified, data |
33427 | objects larger than @var{threshold} are placed in large data sections. The | |
33428 | default is 65535. | |
d77de738 | 33429 | |
d77de738 | 33430 | @opindex mrtd |
ddf6fe37 | 33431 | @item -mrtd |
d77de738 ML |
33432 | Use a different function-calling convention, in which functions that |
33433 | take a fixed number of arguments return with the @code{ret @var{num}} | |
33434 | instruction, which pops their arguments while returning. This saves one | |
33435 | instruction in the caller since there is no need to pop the arguments | |
33436 | there. | |
33437 | ||
33438 | You can specify that an individual function is called with this calling | |
33439 | sequence with the function attribute @code{stdcall}. You can also | |
33440 | override the @option{-mrtd} option by using the function attribute | |
33441 | @code{cdecl}. @xref{Function Attributes}. | |
33442 | ||
33443 | @strong{Warning:} this calling convention is incompatible with the one | |
33444 | normally used on Unix, so you cannot use it if you need to call | |
33445 | libraries compiled with the Unix compiler. | |
33446 | ||
33447 | Also, you must provide function prototypes for all functions that | |
33448 | take variable numbers of arguments (including @code{printf}); | |
33449 | otherwise incorrect code is generated for calls to those | |
33450 | functions. | |
33451 | ||
33452 | In addition, seriously incorrect code results if you call a | |
33453 | function with too many arguments. (Normally, extra arguments are | |
33454 | harmlessly ignored.) | |
33455 | ||
d77de738 | 33456 | @opindex mregparm |
ddf6fe37 | 33457 | @item -mregparm=@var{num} |
d77de738 ML |
33458 | Control how many registers are used to pass integer arguments. By |
33459 | default, no registers are used to pass arguments, and at most 3 | |
33460 | registers can be used. You can control this behavior for a specific | |
33461 | function by using the function attribute @code{regparm}. | |
33462 | @xref{Function Attributes}. | |
33463 | ||
33464 | @strong{Warning:} if you use this switch, and | |
33465 | @var{num} is nonzero, then you must build all modules with the same | |
33466 | value, including any libraries. This includes the system libraries and | |
33467 | startup modules. | |
33468 | ||
d77de738 | 33469 | @opindex msseregparm |
ddf6fe37 | 33470 | @item -msseregparm |
d77de738 ML |
33471 | Use SSE register passing conventions for float and double arguments |
33472 | and return values. You can control this behavior for a specific | |
33473 | function by using the function attribute @code{sseregparm}. | |
33474 | @xref{Function Attributes}. | |
33475 | ||
33476 | @strong{Warning:} if you use this switch then you must build all | |
33477 | modules with the same value, including any libraries. This includes | |
33478 | the system libraries and startup modules. | |
33479 | ||
d77de738 | 33480 | @opindex mvect8-ret-in-mem |
ddf6fe37 | 33481 | @item -mvect8-ret-in-mem |
d77de738 ML |
33482 | Return 8-byte vectors in memory instead of MMX registers. This is the |
33483 | default on VxWorks to match the ABI of the Sun Studio compilers until | |
33484 | version 12. @emph{Only} use this option if you need to remain | |
33485 | compatible with existing code produced by those previous compiler | |
33486 | versions or older versions of GCC@. | |
33487 | ||
d77de738 ML |
33488 | @opindex mpc32 |
33489 | @opindex mpc64 | |
33490 | @opindex mpc80 | |
ddf6fe37 AA |
33491 | @item -mpc32 |
33492 | @itemx -mpc64 | |
33493 | @itemx -mpc80 | |
d77de738 ML |
33494 | |
33495 | Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32} | |
33496 | is specified, the significands of results of floating-point operations are | |
33497 | rounded to 24 bits (single precision); @option{-mpc64} rounds the | |
33498 | significands of results of floating-point operations to 53 bits (double | |
33499 | precision) and @option{-mpc80} rounds the significands of results of | |
33500 | floating-point operations to 64 bits (extended double precision), which is | |
33501 | the default. When this option is used, floating-point operations in higher | |
33502 | precisions are not available to the programmer without setting the FPU | |
33503 | control word explicitly. | |
33504 | ||
33505 | Setting the rounding of floating-point operations to less than the default | |
33506 | 80 bits can speed some programs by 2% or more. Note that some mathematical | |
33507 | libraries assume that extended-precision (80-bit) floating-point operations | |
33508 | are enabled by default; routines in such libraries could suffer significant | |
33509 | loss of accuracy, typically through so-called ``catastrophic cancellation'', | |
33510 | when this option is used to set the precision to less than extended precision. | |
33511 | ||
e54375d8 | 33512 | @opindex mdaz-ftz |
ddf6fe37 | 33513 | @item -mdaz-ftz |
e54375d8 | 33514 | |
33515 | The flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register | |
33516 | are used to control floating-point calculations.SSE and AVX instructions | |
33517 | including scalar and vector instructions could benefit from enabling the FTZ | |
33518 | and DAZ flags when @option{-mdaz-ftz} is specified. Don't set FTZ/DAZ flags | |
33519 | when @option{-mno-daz-ftz} or @option{-shared} is specified, @option{-mdaz-ftz} | |
33520 | will set FTZ/DAZ flags even with @option{-shared}. | |
33521 | ||
d77de738 | 33522 | @opindex mstackrealign |
ddf6fe37 | 33523 | @item -mstackrealign |
d77de738 ML |
33524 | Realign the stack at entry. On the x86, the @option{-mstackrealign} |
33525 | option generates an alternate prologue and epilogue that realigns the | |
33526 | run-time stack if necessary. This supports mixing legacy codes that keep | |
33527 | 4-byte stack alignment with modern codes that keep 16-byte stack alignment for | |
33528 | SSE compatibility. See also the attribute @code{force_align_arg_pointer}, | |
33529 | applicable to individual functions. | |
33530 | ||
d77de738 | 33531 | @opindex mpreferred-stack-boundary |
ddf6fe37 | 33532 | @item -mpreferred-stack-boundary=@var{num} |
d77de738 ML |
33533 | Attempt to keep the stack boundary aligned to a 2 raised to @var{num} |
33534 | byte boundary. If @option{-mpreferred-stack-boundary} is not specified, | |
33535 | the default is 4 (16 bytes or 128 bits). | |
33536 | ||
33537 | @strong{Warning:} When generating code for the x86-64 architecture with | |
33538 | SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be | |
33539 | used to keep the stack boundary aligned to 8 byte boundary. Since | |
33540 | x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and | |
33541 | intended to be used in controlled environment where stack space is | |
33542 | important limitation. This option leads to wrong code when functions | |
33543 | compiled with 16 byte stack alignment (such as functions from a standard | |
33544 | library) are called with misaligned stack. In this case, SSE | |
33545 | instructions may lead to misaligned memory access traps. In addition, | |
33546 | variable arguments are handled incorrectly for 16 byte aligned | |
33547 | objects (including x87 long double and __int128), leading to wrong | |
33548 | results. You must build all modules with | |
33549 | @option{-mpreferred-stack-boundary=3}, including any libraries. This | |
33550 | includes the system libraries and startup modules. | |
33551 | ||
d77de738 | 33552 | @opindex mincoming-stack-boundary |
ddf6fe37 | 33553 | @item -mincoming-stack-boundary=@var{num} |
d77de738 ML |
33554 | Assume the incoming stack is aligned to a 2 raised to @var{num} byte |
33555 | boundary. If @option{-mincoming-stack-boundary} is not specified, | |
33556 | the one specified by @option{-mpreferred-stack-boundary} is used. | |
33557 | ||
33558 | On Pentium and Pentium Pro, @code{double} and @code{long double} values | |
33559 | should be aligned to an 8-byte boundary (see @option{-malign-double}) or | |
33560 | suffer significant run time performance penalties. On Pentium III, the | |
33561 | Streaming SIMD Extension (SSE) data type @code{__m128} may not work | |
33562 | properly if it is not 16-byte aligned. | |
33563 | ||
33564 | To ensure proper alignment of this values on the stack, the stack boundary | |
33565 | must be as aligned as that required by any value stored on the stack. | |
33566 | Further, every function must be generated such that it keeps the stack | |
33567 | aligned. Thus calling a function compiled with a higher preferred | |
33568 | stack boundary from a function compiled with a lower preferred stack | |
33569 | boundary most likely misaligns the stack. It is recommended that | |
33570 | libraries that use callbacks always use the default setting. | |
33571 | ||
33572 | This extra alignment does consume extra stack space, and generally | |
33573 | increases code size. Code that is sensitive to stack space usage, such | |
33574 | as embedded systems and operating system kernels, may want to reduce the | |
33575 | preferred alignment to @option{-mpreferred-stack-boundary=2}. | |
33576 | ||
33577 | @need 200 | |
d77de738 | 33578 | @opindex mmmx |
ddf6fe37 | 33579 | @item -mmmx |
d77de738 | 33580 | @need 200 |
d77de738 | 33581 | @opindex msse |
ddf6fe37 | 33582 | @itemx -msse |
d77de738 | 33583 | @need 200 |
d77de738 | 33584 | @opindex msse2 |
ddf6fe37 | 33585 | @itemx -msse2 |
d77de738 | 33586 | @need 200 |
d77de738 | 33587 | @opindex msse3 |
ddf6fe37 | 33588 | @itemx -msse3 |
d77de738 | 33589 | @need 200 |
d77de738 | 33590 | @opindex mssse3 |
ddf6fe37 | 33591 | @itemx -mssse3 |
d77de738 | 33592 | @need 200 |
d77de738 | 33593 | @opindex msse4 |
ddf6fe37 | 33594 | @itemx -msse4 |
d77de738 | 33595 | @need 200 |
d77de738 | 33596 | @opindex msse4a |
ddf6fe37 | 33597 | @itemx -msse4a |
d77de738 | 33598 | @need 200 |
d77de738 | 33599 | @opindex msse4.1 |
ddf6fe37 | 33600 | @itemx -msse4.1 |
d77de738 | 33601 | @need 200 |
d77de738 | 33602 | @opindex msse4.2 |
ddf6fe37 | 33603 | @itemx -msse4.2 |
d77de738 | 33604 | @need 200 |
d77de738 | 33605 | @opindex mavx |
ddf6fe37 | 33606 | @itemx -mavx |
d77de738 | 33607 | @need 200 |
d77de738 | 33608 | @opindex mavx2 |
ddf6fe37 | 33609 | @itemx -mavx2 |
d77de738 | 33610 | @need 200 |
d77de738 | 33611 | @opindex mavx512f |
ddf6fe37 | 33612 | @itemx -mavx512f |
d77de738 | 33613 | @need 200 |
d77de738 | 33614 | @opindex mavx512pf |
ddf6fe37 | 33615 | @itemx -mavx512pf |
d77de738 | 33616 | @need 200 |
d77de738 | 33617 | @opindex mavx512er |
ddf6fe37 | 33618 | @itemx -mavx512er |
d77de738 | 33619 | @need 200 |
d77de738 | 33620 | @opindex mavx512cd |
ddf6fe37 | 33621 | @itemx -mavx512cd |
d77de738 | 33622 | @need 200 |
d77de738 | 33623 | @opindex mavx512vl |
ddf6fe37 | 33624 | @itemx -mavx512vl |
d77de738 | 33625 | @need 200 |
d77de738 | 33626 | @opindex mavx512bw |
ddf6fe37 | 33627 | @itemx -mavx512bw |
d77de738 | 33628 | @need 200 |
d77de738 | 33629 | @opindex mavx512dq |
ddf6fe37 | 33630 | @itemx -mavx512dq |
d77de738 | 33631 | @need 200 |
d77de738 | 33632 | @opindex mavx512ifma |
ddf6fe37 | 33633 | @itemx -mavx512ifma |
d77de738 | 33634 | @need 200 |
d77de738 | 33635 | @opindex mavx512vbmi |
ddf6fe37 | 33636 | @itemx -mavx512vbmi |
d77de738 | 33637 | @need 200 |
d77de738 | 33638 | @opindex msha |
ddf6fe37 | 33639 | @itemx -msha |
d77de738 | 33640 | @need 200 |
d77de738 | 33641 | @opindex maes |
ddf6fe37 | 33642 | @itemx -maes |
d77de738 | 33643 | @need 200 |
d77de738 | 33644 | @opindex mpclmul |
ddf6fe37 | 33645 | @itemx -mpclmul |
d77de738 | 33646 | @need 200 |
d77de738 | 33647 | @opindex mclflushopt |
ddf6fe37 | 33648 | @itemx -mclflushopt |
d77de738 | 33649 | @need 200 |
d77de738 | 33650 | @opindex mclwb |
ddf6fe37 | 33651 | @itemx -mclwb |
d77de738 | 33652 | @need 200 |
d77de738 | 33653 | @opindex mfsgsbase |
ddf6fe37 | 33654 | @itemx -mfsgsbase |
d77de738 | 33655 | @need 200 |
d77de738 | 33656 | @opindex mptwrite |
ddf6fe37 | 33657 | @itemx -mptwrite |
d77de738 | 33658 | @need 200 |
d77de738 | 33659 | @opindex mrdrnd |
ddf6fe37 | 33660 | @itemx -mrdrnd |
d77de738 | 33661 | @need 200 |
d77de738 | 33662 | @opindex mf16c |
ddf6fe37 | 33663 | @itemx -mf16c |
d77de738 | 33664 | @need 200 |
d77de738 | 33665 | @opindex mfma |
ddf6fe37 | 33666 | @itemx -mfma |
d77de738 | 33667 | @need 200 |
d77de738 | 33668 | @opindex mpconfig |
ddf6fe37 | 33669 | @itemx -mpconfig |
d77de738 | 33670 | @need 200 |
d77de738 | 33671 | @opindex mwbnoinvd |
ddf6fe37 | 33672 | @itemx -mwbnoinvd |
d77de738 | 33673 | @need 200 |
d77de738 | 33674 | @opindex mfma4 |
ddf6fe37 | 33675 | @itemx -mfma4 |
d77de738 | 33676 | @need 200 |
d77de738 | 33677 | @opindex mprfchw |
ddf6fe37 | 33678 | @itemx -mprfchw |
d77de738 | 33679 | @need 200 |
d77de738 | 33680 | @opindex mrdpid |
ddf6fe37 | 33681 | @itemx -mrdpid |
d77de738 | 33682 | @need 200 |
d77de738 | 33683 | @opindex mprefetchwt1 |
ddf6fe37 | 33684 | @itemx -mprefetchwt1 |
d77de738 | 33685 | @need 200 |
d77de738 | 33686 | @opindex mrdseed |
ddf6fe37 | 33687 | @itemx -mrdseed |
d77de738 | 33688 | @need 200 |
d77de738 | 33689 | @opindex msgx |
ddf6fe37 | 33690 | @itemx -msgx |
d77de738 | 33691 | @need 200 |
d77de738 | 33692 | @opindex mxop |
ddf6fe37 | 33693 | @itemx -mxop |
d77de738 | 33694 | @need 200 |
d77de738 | 33695 | @opindex mlwp |
ddf6fe37 | 33696 | @itemx -mlwp |
d77de738 | 33697 | @need 200 |
d77de738 | 33698 | @opindex m3dnow |
ddf6fe37 | 33699 | @itemx -m3dnow |
d77de738 | 33700 | @need 200 |
d77de738 | 33701 | @opindex m3dnowa |
ddf6fe37 | 33702 | @itemx -m3dnowa |
d77de738 | 33703 | @need 200 |
d77de738 | 33704 | @opindex mpopcnt |
ddf6fe37 | 33705 | @itemx -mpopcnt |
d77de738 | 33706 | @need 200 |
d77de738 | 33707 | @opindex mabm |
ddf6fe37 | 33708 | @itemx -mabm |
d77de738 | 33709 | @need 200 |
d77de738 | 33710 | @opindex madx |
ddf6fe37 | 33711 | @itemx -madx |
d77de738 | 33712 | @need 200 |
d77de738 | 33713 | @opindex mbmi |
ddf6fe37 | 33714 | @itemx -mbmi |
d77de738 | 33715 | @need 200 |
d77de738 | 33716 | @opindex mbmi2 |
ddf6fe37 | 33717 | @itemx -mbmi2 |
d77de738 | 33718 | @need 200 |
d77de738 | 33719 | @opindex mlzcnt |
ddf6fe37 | 33720 | @itemx -mlzcnt |
d77de738 | 33721 | @need 200 |
d77de738 | 33722 | @opindex mfxsr |
ddf6fe37 | 33723 | @itemx -mfxsr |
d77de738 | 33724 | @need 200 |
d77de738 | 33725 | @opindex mxsave |
ddf6fe37 | 33726 | @itemx -mxsave |
d77de738 | 33727 | @need 200 |
d77de738 | 33728 | @opindex mxsaveopt |
ddf6fe37 | 33729 | @itemx -mxsaveopt |
d77de738 | 33730 | @need 200 |
d77de738 | 33731 | @opindex mxsavec |
ddf6fe37 | 33732 | @itemx -mxsavec |
d77de738 | 33733 | @need 200 |
d77de738 | 33734 | @opindex mxsaves |
ddf6fe37 | 33735 | @itemx -mxsaves |
d77de738 | 33736 | @need 200 |
d77de738 | 33737 | @opindex mrtm |
ddf6fe37 | 33738 | @itemx -mrtm |
d77de738 | 33739 | @need 200 |
d77de738 | 33740 | @opindex mhle |
ddf6fe37 | 33741 | @itemx -mhle |
d77de738 | 33742 | @need 200 |
d77de738 | 33743 | @opindex mtbm |
ddf6fe37 | 33744 | @itemx -mtbm |
d77de738 | 33745 | @need 200 |
d77de738 | 33746 | @opindex mmwaitx |
ddf6fe37 | 33747 | @itemx -mmwaitx |
d77de738 | 33748 | @need 200 |
d77de738 | 33749 | @opindex mclzero |
ddf6fe37 | 33750 | @itemx -mclzero |
d77de738 | 33751 | @need 200 |
d77de738 | 33752 | @opindex mpku |
ddf6fe37 | 33753 | @itemx -mpku |
d77de738 | 33754 | @need 200 |
d77de738 | 33755 | @opindex mavx512vbmi2 |
ddf6fe37 | 33756 | @itemx -mavx512vbmi2 |
d77de738 | 33757 | @need 200 |
d77de738 | 33758 | @opindex mavx512bf16 |
ddf6fe37 | 33759 | @itemx -mavx512bf16 |
d77de738 | 33760 | @need 200 |
d77de738 | 33761 | @opindex mavx512fp16 |
ddf6fe37 | 33762 | @itemx -mavx512fp16 |
d77de738 | 33763 | @need 200 |
d77de738 | 33764 | @opindex mgfni |
ddf6fe37 | 33765 | @itemx -mgfni |
d77de738 | 33766 | @need 200 |
d77de738 | 33767 | @opindex mvaes |
ddf6fe37 | 33768 | @itemx -mvaes |
d77de738 | 33769 | @need 200 |
d77de738 | 33770 | @opindex mwaitpkg |
ddf6fe37 | 33771 | @itemx -mwaitpkg |
d77de738 | 33772 | @need 200 |
d77de738 | 33773 | @opindex mvpclmulqdq |
ddf6fe37 | 33774 | @itemx -mvpclmulqdq |
d77de738 | 33775 | @need 200 |
d77de738 | 33776 | @opindex mavx512bitalg |
ddf6fe37 | 33777 | @itemx -mavx512bitalg |
d77de738 | 33778 | @need 200 |
d77de738 | 33779 | @opindex mmovdiri |
ddf6fe37 | 33780 | @itemx -mmovdiri |
d77de738 | 33781 | @need 200 |
d77de738 | 33782 | @opindex mmovdir64b |
ddf6fe37 | 33783 | @itemx -mmovdir64b |
d77de738 | 33784 | @need 200 |
d77de738 | 33785 | @opindex menqcmd |
d77de738 | 33786 | @opindex muintr |
ddf6fe37 AA |
33787 | @itemx -menqcmd |
33788 | @itemx -muintr | |
d77de738 | 33789 | @need 200 |
d77de738 | 33790 | @opindex mtsxldtrk |
ddf6fe37 | 33791 | @itemx -mtsxldtrk |
d77de738 | 33792 | @need 200 |
d77de738 | 33793 | @opindex mavx512vpopcntdq |
ddf6fe37 | 33794 | @itemx -mavx512vpopcntdq |
d77de738 | 33795 | @need 200 |
d77de738 | 33796 | @opindex mavx512vp2intersect |
ddf6fe37 | 33797 | @itemx -mavx512vp2intersect |
d77de738 | 33798 | @need 200 |
d77de738 | 33799 | @opindex mavx5124fmaps |
ddf6fe37 | 33800 | @itemx -mavx5124fmaps |
d77de738 | 33801 | @need 200 |
d77de738 | 33802 | @opindex mavx512vnni |
ddf6fe37 | 33803 | @itemx -mavx512vnni |
d77de738 | 33804 | @need 200 |
d77de738 | 33805 | @opindex mavxvnni |
ddf6fe37 | 33806 | @itemx -mavxvnni |
d77de738 | 33807 | @need 200 |
d77de738 | 33808 | @opindex mavx5124vnniw |
ddf6fe37 | 33809 | @itemx -mavx5124vnniw |
d77de738 | 33810 | @need 200 |
d77de738 | 33811 | @opindex mcldemote |
ddf6fe37 | 33812 | @itemx -mcldemote |
d77de738 | 33813 | @need 200 |
d77de738 | 33814 | @opindex mserialize |
ddf6fe37 | 33815 | @itemx -mserialize |
d77de738 | 33816 | @need 200 |
d77de738 | 33817 | @opindex mamx-tile |
ddf6fe37 | 33818 | @itemx -mamx-tile |
d77de738 | 33819 | @need 200 |
d77de738 | 33820 | @opindex mamx-int8 |
ddf6fe37 | 33821 | @itemx -mamx-int8 |
d77de738 | 33822 | @need 200 |
d77de738 | 33823 | @opindex mamx-bf16 |
ddf6fe37 | 33824 | @itemx -mamx-bf16 |
d77de738 | 33825 | @need 200 |
d77de738 | 33826 | @opindex mhreset |
d77de738 | 33827 | @opindex mkl |
ddf6fe37 AA |
33828 | @itemx -mhreset |
33829 | @itemx -mkl | |
d77de738 | 33830 | @need 200 |
d77de738 | 33831 | @opindex mwidekl |
ddf6fe37 | 33832 | @itemx -mwidekl |
d77de738 | 33833 | @need 200 |
d77de738 | 33834 | @opindex mavxifma |
ddf6fe37 | 33835 | @itemx -mavxifma |
d77de738 | 33836 | @need 200 |
d77de738 | 33837 | @opindex mavxvnniint8 |
ddf6fe37 | 33838 | @itemx -mavxvnniint8 |
d77de738 | 33839 | @need 200 |
d77de738 | 33840 | @opindex mavxneconvert |
ddf6fe37 | 33841 | @itemx -mavxneconvert |
d77de738 | 33842 | @need 200 |
d77de738 | 33843 | @opindex mcmpccxadd |
ddf6fe37 | 33844 | @itemx -mcmpccxadd |
d77de738 | 33845 | @need 200 |
d77de738 | 33846 | @opindex mamx-fp16 |
ddf6fe37 | 33847 | @itemx -mamx-fp16 |
d77de738 | 33848 | @need 200 |
d77de738 | 33849 | @opindex mprefetchi |
ddf6fe37 | 33850 | @itemx -mprefetchi |
d77de738 | 33851 | @need 200 |
d77de738 | 33852 | @opindex mraoint |
ddf6fe37 | 33853 | @itemx -mraoint |
efa6a82b HJ |
33854 | @need 200 |
33855 | @opindex mamx-complex | |
33856 | @itemx -mamx-complex | |
1dbc1081 KL |
33857 | @need 200 |
33858 | @opindex mavxvnniint16 | |
33859 | @itemx -mavxvnniint16 | |
8643bcba HJ |
33860 | @need 200 |
33861 | @opindex msm3 | |
33862 | @itemx -msm3 | |
86446132 HJ |
33863 | @need 200 |
33864 | @opindex msha512 | |
33865 | @itemx -msha512 | |
37bdeb8f HJ |
33866 | @need 200 |
33867 | @opindex msm4 | |
33868 | @itemx -msm4 | |
e686416b KL |
33869 | @need 200 |
33870 | @opindex mapxf | |
33871 | @itemx -mapxf | |
5fbd91b1 HL |
33872 | @need 200 |
33873 | @opindex musermsr | |
33874 | @itemx -musermsr | |
d77de738 | 33875 | These switches enable the use of instructions in the MMX, SSE, |
d77de738 ML |
33876 | AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA, |
33877 | AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG, | |
33878 | WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP, | |
33879 | 3DNow!@:, enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE, | |
33880 | XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2, | |
33881 | GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16, | |
33882 | ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE, | |
29ecb952 | 33883 | UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512-FP16, |
efa6a82b | 33884 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT, |
5fbd91b1 HL |
33885 | AMX-COMPLEX, AVXVNNIINT16, SM3, SHA512, SM4, APX_F, USER_MSR or CLDEMOTE |
33886 | extended instruction sets. Each has a corresponding @option{-mno-} option | |
33887 | to disable use of these instructions. | |
d77de738 ML |
33888 | |
33889 | These extensions are also available as built-in functions: see | |
33890 | @ref{x86 Built-in Functions}, for details of the functions enabled and | |
33891 | disabled by these switches. | |
33892 | ||
33893 | To generate SSE/SSE2 instructions automatically from floating-point | |
33894 | code (as opposed to 387 instructions), see @option{-mfpmath=sse}. | |
33895 | ||
33896 | GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it | |
33897 | generates new AVX instructions or AVX equivalence for all SSEx instructions | |
33898 | when needed. | |
33899 | ||
33900 | These options enable GCC to use these extended instructions in | |
33901 | generated code, even without @option{-mfpmath=sse}. Applications that | |
33902 | perform run-time CPU detection must compile separate files for each | |
33903 | supported architecture, using the appropriate flags. In particular, | |
33904 | the file containing the CPU detection code should be compiled without | |
33905 | these options. | |
33906 | ||
d77de738 | 33907 | @opindex mdump-tune-features |
ddf6fe37 | 33908 | @item -mdump-tune-features |
d77de738 ML |
33909 | This option instructs GCC to dump the names of the x86 performance |
33910 | tuning features and default settings. The names can be used in | |
33911 | @option{-mtune-ctrl=@var{feature-list}}. | |
33912 | ||
d77de738 | 33913 | @opindex mtune-ctrl=@var{feature-list} |
ddf6fe37 | 33914 | @item -mtune-ctrl=@var{feature-list} |
d77de738 ML |
33915 | This option is used to do fine grain control of x86 code generation features. |
33916 | @var{feature-list} is a comma separated list of @var{feature} names. See also | |
33917 | @option{-mdump-tune-features}. When specified, the @var{feature} is turned | |
33918 | on if it is not preceded with @samp{^}, otherwise, it is turned off. | |
33919 | @option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC | |
33920 | developers. Using it may lead to code paths not covered by testing and can | |
33921 | potentially result in compiler ICEs or runtime errors. | |
33922 | ||
d77de738 | 33923 | @opindex mno-default |
ddf6fe37 | 33924 | @item -mno-default |
d77de738 ML |
33925 | This option instructs GCC to turn off all tunable features. See also |
33926 | @option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}. | |
33927 | ||
d77de738 | 33928 | @opindex mcld |
ddf6fe37 | 33929 | @item -mcld |
d77de738 ML |
33930 | This option instructs GCC to emit a @code{cld} instruction in the prologue |
33931 | of functions that use string instructions. String instructions depend on | |
33932 | the DF flag to select between autoincrement or autodecrement mode. While the | |
33933 | ABI specifies the DF flag to be cleared on function entry, some operating | |
33934 | systems violate this specification by not clearing the DF flag in their | |
33935 | exception dispatchers. The exception handler can be invoked with the DF flag | |
33936 | set, which leads to wrong direction mode when string instructions are used. | |
33937 | This option can be enabled by default on 32-bit x86 targets by configuring | |
33938 | GCC with the @option{--enable-cld} configure option. Generation of @code{cld} | |
33939 | instructions can be suppressed with the @option{-mno-cld} compiler option | |
33940 | in this case. | |
33941 | ||
d77de738 | 33942 | @opindex mvzeroupper |
ddf6fe37 | 33943 | @item -mvzeroupper |
d77de738 ML |
33944 | This option instructs GCC to emit a @code{vzeroupper} instruction |
33945 | before a transfer of control flow out of the function to minimize | |
33946 | the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper} | |
33947 | intrinsics. | |
33948 | ||
d77de738 | 33949 | @opindex mprefer-avx128 |
ddf6fe37 | 33950 | @item -mprefer-avx128 |
d77de738 ML |
33951 | This option instructs GCC to use 128-bit AVX instructions instead of |
33952 | 256-bit AVX instructions in the auto-vectorizer. | |
33953 | ||
d77de738 | 33954 | @opindex mprefer-vector-width |
ddf6fe37 | 33955 | @item -mprefer-vector-width=@var{opt} |
d77de738 ML |
33956 | This option instructs GCC to use @var{opt}-bit vector width in instructions |
33957 | instead of default on the selected platform. | |
33958 | ||
ad5b757d UB |
33959 | @opindex mpartial-vector-fp-math |
33960 | @item -mpartial-vector-fp-math | |
33961 | This option enables GCC to generate floating-point operations that might | |
33962 | affect the set of floating-point status flags on partial vectors, where | |
33963 | vector elements reside in the low part of the 128-bit SSE register. Unless | |
33964 | @option{-fno-trapping-math} is specified, the compiler guarantees correct | |
33965 | behavior by sanitizing all input operands to have zeroes in the unused | |
33966 | upper part of the vector register. Note that by using built-in functions | |
33967 | or inline assembly with partial vector arguments, NaNs, denormal or invalid | |
33968 | values can leak into the upper part of the vector, causing possible | |
33969 | performance issues when @option{-fno-trapping-math} is in effect. These | |
33970 | issues can be mitigated by manually sanitizing the upper part of the partial | |
33971 | vector argument register or by using @option{-mdaz-ftz} to set | |
33972 | denormals-are-zero (DAZ) flag in the MXCSR register. | |
33973 | ||
33974 | This option is enabled by default. | |
33975 | ||
d77de738 | 33976 | @opindex mmove-max |
ddf6fe37 | 33977 | @item -mmove-max=@var{bits} |
d77de738 ML |
33978 | This option instructs GCC to set the maximum number of bits can be |
33979 | moved from memory to memory efficiently to @var{bits}. The valid | |
33980 | @var{bits} are 128, 256 and 512. | |
33981 | ||
d77de738 | 33982 | @opindex mstore-max |
ddf6fe37 | 33983 | @item -mstore-max=@var{bits} |
d77de738 ML |
33984 | This option instructs GCC to set the maximum number of bits can be |
33985 | stored to memory efficiently to @var{bits}. The valid @var{bits} are | |
33986 | 128, 256 and 512. | |
33987 | ||
33988 | @table @samp | |
33989 | @item none | |
33990 | No extra limitations applied to GCC other than defined by the selected platform. | |
33991 | ||
33992 | @item 128 | |
33993 | Prefer 128-bit vector width for instructions. | |
33994 | ||
33995 | @item 256 | |
33996 | Prefer 256-bit vector width for instructions. | |
33997 | ||
33998 | @item 512 | |
33999 | Prefer 512-bit vector width for instructions. | |
34000 | @end table | |
34001 | ||
d77de738 | 34002 | @opindex mcx16 |
ddf6fe37 | 34003 | @item -mcx16 |
d77de738 ML |
34004 | This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit |
34005 | code to implement compare-and-exchange operations on 16-byte aligned 128-bit | |
34006 | objects. This is useful for atomic updates of data structures exceeding one | |
34007 | machine word in size. The compiler uses this instruction to implement | |
34008 | @ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on | |
34009 | 128-bit integers, a library call is always used. | |
34010 | ||
d77de738 | 34011 | @opindex msahf |
ddf6fe37 | 34012 | @item -msahf |
d77de738 ML |
34013 | This option enables generation of @code{SAHF} instructions in 64-bit code. |
34014 | Early Intel Pentium 4 CPUs with Intel 64 support, | |
34015 | prior to the introduction of Pentium 4 G1 step in December 2005, | |
34016 | lacked the @code{LAHF} and @code{SAHF} instructions | |
34017 | which are supported by AMD64. | |
34018 | These are load and store instructions, respectively, for certain status flags. | |
34019 | In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod}, | |
34020 | @code{drem}, and @code{remainder} built-in functions; | |
34021 | see @ref{Other Builtins} for details. | |
34022 | ||
d77de738 | 34023 | @opindex mmovbe |
ddf6fe37 | 34024 | @item -mmovbe |
d77de738 ML |
34025 | This option enables use of the @code{movbe} instruction to implement |
34026 | @code{__builtin_bswap32} and @code{__builtin_bswap64}. | |
34027 | ||
d77de738 | 34028 | @opindex mshstk |
ddf6fe37 | 34029 | @item -mshstk |
d77de738 ML |
34030 | The @option{-mshstk} option enables shadow stack built-in functions |
34031 | from x86 Control-flow Enforcement Technology (CET). | |
34032 | ||
d77de738 | 34033 | @opindex mcrc32 |
ddf6fe37 | 34034 | @item -mcrc32 |
d77de738 ML |
34035 | This option enables built-in functions @code{__builtin_ia32_crc32qi}, |
34036 | @code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and | |
34037 | @code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction. | |
34038 | ||
d77de738 | 34039 | @opindex mmwait |
ddf6fe37 | 34040 | @item -mmwait |
d77de738 ML |
34041 | This option enables built-in functions @code{__builtin_ia32_monitor}, |
34042 | and @code{__builtin_ia32_mwait} to generate the @code{monitor} and | |
34043 | @code{mwait} machine instructions. | |
34044 | ||
d77de738 | 34045 | @opindex mrecip |
ddf6fe37 | 34046 | @item -mrecip |
d77de738 ML |
34047 | This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions |
34048 | (and their vectorized variants @code{RCPPS} and @code{RSQRTPS}) | |
34049 | with an additional Newton-Raphson step | |
34050 | to increase precision instead of @code{DIVSS} and @code{SQRTSS} | |
34051 | (and their vectorized | |
34052 | variants) for single-precision floating-point arguments. These instructions | |
34053 | are generated only when @option{-funsafe-math-optimizations} is enabled | |
34054 | together with @option{-ffinite-math-only} and @option{-fno-trapping-math}. | |
34055 | Note that while the throughput of the sequence is higher than the throughput | |
34056 | of the non-reciprocal instruction, the precision of the sequence can be | |
34057 | decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994). | |
34058 | ||
34059 | Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS} | |
34060 | (or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option | |
34061 | combination), and doesn't need @option{-mrecip}. | |
34062 | ||
34063 | Also note that GCC emits the above sequence with additional Newton-Raphson step | |
34064 | for vectorized single-float division and vectorized @code{sqrtf(@var{x})} | |
34065 | already with @option{-ffast-math} (or the above option combination), and | |
34066 | doesn't need @option{-mrecip}. | |
34067 | ||
d77de738 | 34068 | @opindex mrecip=opt |
ddf6fe37 | 34069 | @item -mrecip=@var{opt} |
d77de738 ML |
34070 | This option controls which reciprocal estimate instructions |
34071 | may be used. @var{opt} is a comma-separated list of options, which may | |
34072 | be preceded by a @samp{!} to invert the option: | |
34073 | ||
34074 | @table @samp | |
34075 | @item all | |
34076 | Enable all estimate instructions. | |
34077 | ||
34078 | @item default | |
34079 | Enable the default instructions, equivalent to @option{-mrecip}. | |
34080 | ||
34081 | @item none | |
34082 | Disable all estimate instructions, equivalent to @option{-mno-recip}. | |
34083 | ||
34084 | @item div | |
34085 | Enable the approximation for scalar division. | |
34086 | ||
34087 | @item vec-div | |
34088 | Enable the approximation for vectorized division. | |
34089 | ||
34090 | @item sqrt | |
34091 | Enable the approximation for scalar square root. | |
34092 | ||
34093 | @item vec-sqrt | |
34094 | Enable the approximation for vectorized square root. | |
34095 | @end table | |
34096 | ||
34097 | So, for example, @option{-mrecip=all,!sqrt} enables | |
34098 | all of the reciprocal approximations, except for square root. | |
34099 | ||
d77de738 | 34100 | @opindex mveclibabi |
ddf6fe37 | 34101 | @item -mveclibabi=@var{type} |
d77de738 ML |
34102 | Specifies the ABI type to use for vectorizing intrinsics using an |
34103 | external library. Supported values for @var{type} are @samp{svml} | |
34104 | for the Intel short | |
34105 | vector math library and @samp{acml} for the AMD math core library. | |
34106 | To use this option, both @option{-ftree-vectorize} and | |
34107 | @option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML | |
34108 | ABI-compatible library must be specified at link time. | |
34109 | ||
34110 | GCC currently emits calls to @code{vmldExp2}, | |
34111 | @code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2}, | |
34112 | @code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2}, | |
34113 | @code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2}, | |
34114 | @code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2}, | |
34115 | @code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4}, | |
34116 | @code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4}, | |
34117 | @code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4}, | |
34118 | @code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4}, | |
34119 | @code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for corresponding | |
34120 | function type when @option{-mveclibabi=svml} is used, and @code{__vrd2_sin}, | |
34121 | @code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2}, | |
34122 | @code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf}, | |
34123 | @code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f}, | |
34124 | @code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type | |
34125 | when @option{-mveclibabi=acml} is used. | |
34126 | ||
d77de738 | 34127 | @opindex mabi |
ddf6fe37 | 34128 | @item -mabi=@var{name} |
d77de738 ML |
34129 | Generate code for the specified calling convention. Permissible values |
34130 | are @samp{sysv} for the ABI used on GNU/Linux and other systems, and | |
34131 | @samp{ms} for the Microsoft ABI. The default is to use the Microsoft | |
34132 | ABI when targeting Microsoft Windows and the SysV ABI on all other systems. | |
34133 | You can control this behavior for specific functions by | |
34134 | using the function attributes @code{ms_abi} and @code{sysv_abi}. | |
34135 | @xref{Function Attributes}. | |
34136 | ||
d77de738 | 34137 | @opindex mforce-indirect-call |
ddf6fe37 | 34138 | @item -mforce-indirect-call |
d77de738 ML |
34139 | Force all calls to functions to be indirect. This is useful |
34140 | when using Intel Processor Trace where it generates more precise timing | |
34141 | information for function calls. | |
34142 | ||
d77de738 | 34143 | @opindex mmanual-endbr |
ddf6fe37 | 34144 | @item -mmanual-endbr |
d77de738 ML |
34145 | Insert ENDBR instruction at function entry only via the @code{cf_check} |
34146 | function attribute. This is useful when used with the option | |
34147 | @option{-fcf-protection=branch} to control ENDBR insertion at the | |
34148 | function entry. | |
34149 | ||
d77de738 | 34150 | @opindex mcet-switch |
ddf6fe37 | 34151 | @item -mcet-switch |
d77de738 ML |
34152 | By default, CET instrumentation is turned off on switch statements that |
34153 | use a jump table and indirect branch track is disabled. Since jump | |
34154 | tables are stored in read-only memory, this does not result in a direct | |
34155 | loss of hardening. But if the jump table index is attacker-controlled, | |
34156 | the indirect jump may not be constrained by CET. This option turns on | |
34157 | CET instrumentation to enable indirect branch track for switch statements | |
34158 | with jump tables which leads to the jump targets reachable via any indirect | |
34159 | jumps. | |
34160 | ||
d77de738 ML |
34161 | @opindex mcall-ms2sysv-xlogues |
34162 | @opindex mno-call-ms2sysv-xlogues | |
ddf6fe37 | 34163 | @item -mcall-ms2sysv-xlogues |
d77de738 ML |
34164 | Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a |
34165 | System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By | |
34166 | default, the code for saving and restoring these registers is emitted inline, | |
34167 | resulting in fairly lengthy prologues and epilogues. Using | |
34168 | @option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that | |
34169 | use stubs in the static portion of libgcc to perform these saves and restores, | |
34170 | thus reducing function size at the cost of a few extra instructions. | |
34171 | ||
d77de738 | 34172 | @opindex mtls-dialect |
ddf6fe37 | 34173 | @item -mtls-dialect=@var{type} |
d77de738 ML |
34174 | Generate code to access thread-local storage using the @samp{gnu} or |
34175 | @samp{gnu2} conventions. @samp{gnu} is the conservative default; | |
34176 | @samp{gnu2} is more efficient, but it may add compile- and run-time | |
34177 | requirements that cannot be satisfied on all systems. | |
34178 | ||
d77de738 ML |
34179 | @opindex mpush-args |
34180 | @opindex mno-push-args | |
ddf6fe37 AA |
34181 | @item -mpush-args |
34182 | @itemx -mno-push-args | |
d77de738 ML |
34183 | Use PUSH operations to store outgoing parameters. This method is shorter |
34184 | and usually equally fast as method using SUB/MOV operations and is enabled | |
34185 | by default. In some cases disabling it may improve performance because of | |
34186 | improved scheduling and reduced dependencies. | |
34187 | ||
d77de738 | 34188 | @opindex maccumulate-outgoing-args |
ddf6fe37 | 34189 | @item -maccumulate-outgoing-args |
d77de738 ML |
34190 | If enabled, the maximum amount of space required for outgoing arguments is |
34191 | computed in the function prologue. This is faster on most modern CPUs | |
34192 | because of reduced dependencies, improved scheduling and reduced stack usage | |
34193 | when the preferred stack boundary is not equal to 2. The drawback is a notable | |
34194 | increase in code size. This switch implies @option{-mno-push-args}. | |
34195 | ||
d77de738 | 34196 | @opindex mthreads |
ddf6fe37 | 34197 | @item -mthreads |
d77de738 ML |
34198 | Support thread-safe exception handling on MinGW. Programs that rely |
34199 | on thread-safe exception handling must compile and link all code with the | |
34200 | @option{-mthreads} option. When compiling, @option{-mthreads} defines | |
34201 | @option{-D_MT}; when linking, it links in a special thread helper library | |
34202 | @option{-lmingwthrd} which cleans up per-thread exception-handling data. | |
34203 | ||
d77de738 ML |
34204 | @opindex mms-bitfields |
34205 | @opindex mno-ms-bitfields | |
ddf6fe37 AA |
34206 | @item -mms-bitfields |
34207 | @itemx -mno-ms-bitfields | |
d77de738 ML |
34208 | |
34209 | Enable/disable bit-field layout compatible with the native Microsoft | |
34210 | Windows compiler. | |
34211 | ||
34212 | If @code{packed} is used on a structure, or if bit-fields are used, | |
34213 | it may be that the Microsoft ABI lays out the structure differently | |
34214 | than the way GCC normally does. Particularly when moving packed | |
34215 | data between functions compiled with GCC and the native Microsoft compiler | |
34216 | (either via function call or as data in a file), it may be necessary to access | |
34217 | either format. | |
34218 | ||
34219 | This option is enabled by default for Microsoft Windows | |
34220 | targets. This behavior can also be controlled locally by use of variable | |
34221 | or type attributes. For more information, see @ref{x86 Variable Attributes} | |
34222 | and @ref{x86 Type Attributes}. | |
34223 | ||
34224 | The Microsoft structure layout algorithm is fairly simple with the exception | |
34225 | of the bit-field packing. | |
34226 | The padding and alignment of members of structures and whether a bit-field | |
34227 | can straddle a storage-unit boundary are determine by these rules: | |
34228 | ||
34229 | @enumerate | |
34230 | @item Structure members are stored sequentially in the order in which they are | |
34231 | declared: the first member has the lowest memory address and the last member | |
34232 | the highest. | |
34233 | ||
34234 | @item Every data object has an alignment requirement. The alignment requirement | |
34235 | for all data except structures, unions, and arrays is either the size of the | |
34236 | object or the current packing size (specified with either the | |
34237 | @code{aligned} attribute or the @code{pack} pragma), | |
34238 | whichever is less. For structures, unions, and arrays, | |
34239 | the alignment requirement is the largest alignment requirement of its members. | |
34240 | Every object is allocated an offset so that: | |
34241 | ||
34242 | @smallexample | |
34243 | offset % alignment_requirement == 0 | |
34244 | @end smallexample | |
34245 | ||
34246 | @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation | |
34247 | unit if the integral types are the same size and if the next bit-field fits | |
34248 | into the current allocation unit without crossing the boundary imposed by the | |
34249 | common alignment requirements of the bit-fields. | |
34250 | @end enumerate | |
34251 | ||
34252 | MSVC interprets zero-length bit-fields in the following ways: | |
34253 | ||
34254 | @enumerate | |
34255 | @item If a zero-length bit-field is inserted between two bit-fields that | |
34256 | are normally coalesced, the bit-fields are not coalesced. | |
34257 | ||
34258 | For example: | |
34259 | ||
34260 | @smallexample | |
34261 | struct | |
34262 | @{ | |
34263 | unsigned long bf_1 : 12; | |
34264 | unsigned long : 0; | |
34265 | unsigned long bf_2 : 12; | |
34266 | @} t1; | |
34267 | @end smallexample | |
34268 | ||
34269 | @noindent | |
34270 | The size of @code{t1} is 8 bytes with the zero-length bit-field. If the | |
34271 | zero-length bit-field were removed, @code{t1}'s size would be 4 bytes. | |
34272 | ||
34273 | @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the | |
34274 | alignment of the zero-length bit-field is greater than the member that follows it, | |
34275 | @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field. | |
34276 | ||
34277 | For example: | |
34278 | ||
34279 | @smallexample | |
34280 | struct | |
34281 | @{ | |
34282 | char foo : 4; | |
34283 | short : 0; | |
34284 | char bar; | |
34285 | @} t2; | |
34286 | ||
34287 | struct | |
34288 | @{ | |
34289 | char foo : 4; | |
34290 | short : 0; | |
34291 | double bar; | |
34292 | @} t3; | |
34293 | @end smallexample | |
34294 | ||
34295 | @noindent | |
34296 | For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1. | |
34297 | Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length | |
34298 | bit-field does not affect the alignment of @code{bar} or, as a result, the size | |
34299 | of the structure. | |
34300 | ||
34301 | Taking this into account, it is important to note the following: | |
34302 | ||
34303 | @enumerate | |
34304 | @item If a zero-length bit-field follows a normal bit-field, the type of the | |
34305 | zero-length bit-field may affect the alignment of the structure as whole. For | |
34306 | example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a | |
34307 | normal bit-field, and is of type short. | |
34308 | ||
34309 | @item Even if a zero-length bit-field is not followed by a normal bit-field, it may | |
34310 | still affect the alignment of the structure: | |
34311 | ||
34312 | @smallexample | |
34313 | struct | |
34314 | @{ | |
34315 | char foo : 6; | |
34316 | long : 0; | |
34317 | @} t4; | |
34318 | @end smallexample | |
34319 | ||
34320 | @noindent | |
34321 | Here, @code{t4} takes up 4 bytes. | |
34322 | @end enumerate | |
34323 | ||
34324 | @item Zero-length bit-fields following non-bit-field members are ignored: | |
34325 | ||
34326 | @smallexample | |
34327 | struct | |
34328 | @{ | |
34329 | char foo; | |
34330 | long : 0; | |
34331 | char bar; | |
34332 | @} t5; | |
34333 | @end smallexample | |
34334 | ||
34335 | @noindent | |
34336 | Here, @code{t5} takes up 2 bytes. | |
34337 | @end enumerate | |
34338 | ||
34339 | ||
d77de738 ML |
34340 | @opindex mno-align-stringops |
34341 | @opindex malign-stringops | |
ddf6fe37 | 34342 | @item -mno-align-stringops |
d77de738 ML |
34343 | Do not align the destination of inlined string operations. This switch reduces |
34344 | code size and improves performance in case the destination is already aligned, | |
34345 | but GCC doesn't know about it. | |
34346 | ||
d77de738 | 34347 | @opindex minline-all-stringops |
ddf6fe37 | 34348 | @item -minline-all-stringops |
d77de738 ML |
34349 | By default GCC inlines string operations only when the destination is |
34350 | known to be aligned to least a 4-byte boundary. | |
34351 | This enables more inlining and increases code | |
34352 | size, but may improve performance of code that depends on fast | |
34353 | @code{memcpy} and @code{memset} for short lengths. | |
34354 | The option enables inline expansion of @code{strlen} for all | |
34355 | pointer alignments. | |
34356 | ||
d77de738 | 34357 | @opindex minline-stringops-dynamically |
ddf6fe37 | 34358 | @item -minline-stringops-dynamically |
d77de738 ML |
34359 | For string operations of unknown size, use run-time checks with |
34360 | inline code for small blocks and a library call for large blocks. | |
34361 | ||
d77de738 | 34362 | @opindex mstringop-strategy=@var{alg} |
ddf6fe37 | 34363 | @item -mstringop-strategy=@var{alg} |
d77de738 ML |
34364 | Override the internal decision heuristic for the particular algorithm to use |
34365 | for inlining string operations. The allowed values for @var{alg} are: | |
34366 | ||
34367 | @table @samp | |
34368 | @item rep_byte | |
34369 | @itemx rep_4byte | |
34370 | @itemx rep_8byte | |
34371 | Expand using i386 @code{rep} prefix of the specified size. | |
34372 | ||
34373 | @item byte_loop | |
34374 | @itemx loop | |
34375 | @itemx unrolled_loop | |
34376 | Expand into an inline loop. | |
34377 | ||
34378 | @item libcall | |
34379 | Always use a library call. | |
34380 | @end table | |
34381 | ||
d77de738 | 34382 | @opindex mmemcpy-strategy=@var{strategy} |
ddf6fe37 | 34383 | @item -mmemcpy-strategy=@var{strategy} |
d77de738 ML |
34384 | Override the internal decision heuristic to decide if @code{__builtin_memcpy} |
34385 | should be inlined and what inline algorithm to use when the expected size | |
34386 | of the copy operation is known. @var{strategy} | |
34387 | is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets. | |
34388 | @var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies | |
34389 | the max byte size with which inline algorithm @var{alg} is allowed. For the last | |
34390 | triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets | |
34391 | in the list must be specified in increasing order. The minimal byte size for | |
34392 | @var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the | |
34393 | preceding range. | |
34394 | ||
d77de738 | 34395 | @opindex mmemset-strategy=@var{strategy} |
ddf6fe37 | 34396 | @item -mmemset-strategy=@var{strategy} |
d77de738 ML |
34397 | The option is similar to @option{-mmemcpy-strategy=} except that it is to control |
34398 | @code{__builtin_memset} expansion. | |
34399 | ||
d77de738 | 34400 | @opindex momit-leaf-frame-pointer |
ddf6fe37 | 34401 | @item -momit-leaf-frame-pointer |
d77de738 ML |
34402 | Don't keep the frame pointer in a register for leaf functions. This |
34403 | avoids the instructions to save, set up, and restore frame pointers and | |
34404 | makes an extra register available in leaf functions. The option | |
34405 | @option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions, | |
34406 | which might make debugging harder. | |
34407 | ||
ddf6fe37 | 34408 | @opindex mtls-direct-seg-refs |
d77de738 ML |
34409 | @item -mtls-direct-seg-refs |
34410 | @itemx -mno-tls-direct-seg-refs | |
d77de738 ML |
34411 | Controls whether TLS variables may be accessed with offsets from the |
34412 | TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit), | |
34413 | or whether the thread base pointer must be added. Whether or not this | |
34414 | is valid depends on the operating system, and whether it maps the | |
34415 | segment to cover the entire TLS area. | |
34416 | ||
34417 | For systems that use the GNU C Library, the default is on. | |
34418 | ||
ddf6fe37 | 34419 | @opindex msse2avx |
d77de738 ML |
34420 | @item -msse2avx |
34421 | @itemx -mno-sse2avx | |
d77de738 ML |
34422 | Specify that the assembler should encode SSE instructions with VEX |
34423 | prefix. The option @option{-mavx} turns this on by default. | |
34424 | ||
ddf6fe37 | 34425 | @opindex mfentry |
d77de738 ML |
34426 | @item -mfentry |
34427 | @itemx -mno-fentry | |
d77de738 ML |
34428 | If profiling is active (@option{-pg}), put the profiling |
34429 | counter call before the prologue. | |
34430 | Note: On x86 architectures the attribute @code{ms_hook_prologue} | |
34431 | isn't possible at the moment for @option{-mfentry} and @option{-pg}. | |
34432 | ||
ddf6fe37 | 34433 | @opindex mrecord-mcount |
d77de738 ML |
34434 | @item -mrecord-mcount |
34435 | @itemx -mno-record-mcount | |
d77de738 ML |
34436 | If profiling is active (@option{-pg}), generate a __mcount_loc section |
34437 | that contains pointers to each profiling call. This is useful for | |
34438 | automatically patching and out calls. | |
34439 | ||
ddf6fe37 | 34440 | @opindex mnop-mcount |
d77de738 ML |
34441 | @item -mnop-mcount |
34442 | @itemx -mno-nop-mcount | |
d77de738 ML |
34443 | If profiling is active (@option{-pg}), generate the calls to |
34444 | the profiling functions as NOPs. This is useful when they | |
34445 | should be patched in later dynamically. This is likely only | |
34446 | useful together with @option{-mrecord-mcount}. | |
34447 | ||
d77de738 | 34448 | @opindex minstrument-return |
ddf6fe37 | 34449 | @item -minstrument-return=@var{type} |
d77de738 ML |
34450 | Instrument function exit in -pg -mfentry instrumented functions with |
34451 | call to specified function. This only instruments true returns ending | |
34452 | with ret, but not sibling calls ending with jump. Valid types | |
34453 | are @var{none} to not instrument, @var{call} to generate a call to __return__, | |
34454 | or @var{nop5} to generate a 5 byte nop. | |
34455 | ||
ddf6fe37 | 34456 | @opindex mrecord-return |
d77de738 ML |
34457 | @item -mrecord-return |
34458 | @itemx -mno-record-return | |
d77de738 ML |
34459 | Generate a __return_loc section pointing to all return instrumentation code. |
34460 | ||
d77de738 | 34461 | @opindex mfentry-name |
ddf6fe37 | 34462 | @item -mfentry-name=@var{name} |
d77de738 ML |
34463 | Set name of __fentry__ symbol called at function entry for -pg -mfentry functions. |
34464 | ||
d77de738 | 34465 | @opindex mfentry-section |
ddf6fe37 | 34466 | @item -mfentry-section=@var{name} |
d77de738 ML |
34467 | Set name of section to record -mrecord-mcount calls (default __mcount_loc). |
34468 | ||
ddf6fe37 | 34469 | @opindex mskip-rax-setup |
d77de738 ML |
34470 | @item -mskip-rax-setup |
34471 | @itemx -mno-skip-rax-setup | |
d77de738 ML |
34472 | When generating code for the x86-64 architecture with SSE extensions |
34473 | disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX | |
34474 | register when there are no variable arguments passed in vector registers. | |
34475 | ||
34476 | @strong{Warning:} Since RAX register is used to avoid unnecessarily | |
34477 | saving vector registers on stack when passing variable arguments, the | |
34478 | impacts of this option are callees may waste some stack space, | |
34479 | misbehave or jump to a random location. GCC 4.4 or newer don't have | |
34480 | those issues, regardless the RAX register value. | |
34481 | ||
ddf6fe37 | 34482 | @opindex m8bit-idiv |
d77de738 ML |
34483 | @item -m8bit-idiv |
34484 | @itemx -mno-8bit-idiv | |
d77de738 ML |
34485 | On some processors, like Intel Atom, 8-bit unsigned integer divide is |
34486 | much faster than 32-bit/64-bit integer divide. This option generates a | |
34487 | run-time check. If both dividend and divisor are within range of 0 | |
34488 | to 255, 8-bit unsigned integer divide is used instead of | |
34489 | 32-bit/64-bit integer divide. | |
34490 | ||
d77de738 ML |
34491 | @opindex mavx256-split-unaligned-load |
34492 | @opindex mavx256-split-unaligned-store | |
ddf6fe37 AA |
34493 | @item -mavx256-split-unaligned-load |
34494 | @itemx -mavx256-split-unaligned-store | |
d77de738 ML |
34495 | Split 32-byte AVX unaligned load and store. |
34496 | ||
d77de738 ML |
34497 | @opindex mstack-protector-guard |
34498 | @opindex mstack-protector-guard-reg | |
34499 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
34500 | @item -mstack-protector-guard=@var{guard} |
34501 | @itemx -mstack-protector-guard-reg=@var{reg} | |
34502 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
34503 | Generate stack protection code using canary at @var{guard}. Supported |
34504 | locations are @samp{global} for global canary or @samp{tls} for per-thread | |
34505 | canary in the TLS block (the default). This option has effect only when | |
34506 | @option{-fstack-protector} or @option{-fstack-protector-all} is specified. | |
34507 | ||
34508 | With the latter choice the options | |
34509 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
34510 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
34511 | which segment register (@code{%fs} or @code{%gs}) to use as base register | |
34512 | for reading the canary, and from what offset from that base register. | |
34513 | The default for those is as specified in the relevant ABI. | |
34514 | ||
d77de738 | 34515 | @opindex mgeneral-regs-only |
ddf6fe37 | 34516 | @item -mgeneral-regs-only |
d77de738 ML |
34517 | Generate code that uses only the general-purpose registers. This |
34518 | prevents the compiler from using floating-point, vector, mask and bound | |
34519 | registers. | |
34520 | ||
d77de738 | 34521 | @opindex mrelax-cmpxchg-loop |
ddf6fe37 | 34522 | @item -mrelax-cmpxchg-loop |
85966f0d AM |
34523 | When emitting a compare-and-swap loop for @ref{__sync Builtins} |
34524 | and @ref{__atomic Builtins} lacking a native instruction, optimize | |
34525 | for the highly contended case by issuing an atomic load before the | |
34526 | @code{CMPXCHG} instruction, and using the @code{PAUSE} instruction | |
34527 | to save CPU power when restarting the loop. | |
d77de738 | 34528 | |
d77de738 | 34529 | @opindex mindirect-branch |
ddf6fe37 | 34530 | @item -mindirect-branch=@var{choice} |
d77de738 ML |
34531 | Convert indirect call and jump with @var{choice}. The default is |
34532 | @samp{keep}, which keeps indirect call and jump unmodified. | |
34533 | @samp{thunk} converts indirect call and jump to call and return thunk. | |
34534 | @samp{thunk-inline} converts indirect call and jump to inlined call | |
34535 | and return thunk. @samp{thunk-extern} converts indirect call and jump | |
34536 | to external call and return thunk provided in a separate object file. | |
34537 | You can control this behavior for a specific function by using the | |
34538 | function attribute @code{indirect_branch}. @xref{Function Attributes}. | |
34539 | ||
34540 | Note that @option{-mcmodel=large} is incompatible with | |
34541 | @option{-mindirect-branch=thunk} and | |
34542 | @option{-mindirect-branch=thunk-extern} since the thunk function may | |
34543 | not be reachable in the large code model. | |
34544 | ||
34545 | Note that @option{-mindirect-branch=thunk-extern} is compatible with | |
34546 | @option{-fcf-protection=branch} since the external thunk can be made | |
34547 | to enable control-flow check. | |
34548 | ||
d77de738 | 34549 | @opindex mfunction-return |
ddf6fe37 | 34550 | @item -mfunction-return=@var{choice} |
d77de738 ML |
34551 | Convert function return with @var{choice}. The default is @samp{keep}, |
34552 | which keeps function return unmodified. @samp{thunk} converts function | |
34553 | return to call and return thunk. @samp{thunk-inline} converts function | |
34554 | return to inlined call and return thunk. @samp{thunk-extern} converts | |
34555 | function return to external call and return thunk provided in a separate | |
34556 | object file. You can control this behavior for a specific function by | |
34557 | using the function attribute @code{function_return}. | |
34558 | @xref{Function Attributes}. | |
34559 | ||
34560 | Note that @option{-mindirect-return=thunk-extern} is compatible with | |
34561 | @option{-fcf-protection=branch} since the external thunk can be made | |
34562 | to enable control-flow check. | |
34563 | ||
34564 | Note that @option{-mcmodel=large} is incompatible with | |
34565 | @option{-mfunction-return=thunk} and | |
34566 | @option{-mfunction-return=thunk-extern} since the thunk function may | |
34567 | not be reachable in the large code model. | |
34568 | ||
34569 | ||
d77de738 | 34570 | @opindex mindirect-branch-register |
ddf6fe37 | 34571 | @item -mindirect-branch-register |
d77de738 ML |
34572 | Force indirect call and jump via register. |
34573 | ||
d77de738 | 34574 | @opindex mharden-sls |
ddf6fe37 | 34575 | @item -mharden-sls=@var{choice} |
d77de738 ML |
34576 | Generate code to mitigate against straight line speculation (SLS) with |
34577 | @var{choice}. The default is @samp{none} which disables all SLS | |
34578 | hardening. @samp{return} enables SLS hardening for function returns. | |
34579 | @samp{indirect-jmp} enables SLS hardening for indirect jumps. | |
34580 | @samp{all} enables all SLS hardening. | |
34581 | ||
d77de738 | 34582 | @opindex mindirect-branch-cs-prefix |
ddf6fe37 | 34583 | @item -mindirect-branch-cs-prefix |
d77de738 ML |
34584 | Add CS prefix to call and jmp to indirect thunk with branch target in |
34585 | r8-r15 registers so that the call and jmp instruction length is 6 bytes | |
34586 | to allow them to be replaced with @samp{lfence; call *%r8-r15} or | |
34587 | @samp{lfence; jmp *%r8-r15} at run-time. | |
34588 | ||
34589 | @end table | |
34590 | ||
34591 | These @samp{-m} switches are supported in addition to the above | |
34592 | on x86-64 processors in 64-bit environments. | |
34593 | ||
34594 | @table @gcctabopt | |
d77de738 ML |
34595 | @opindex m32 |
34596 | @opindex m64 | |
34597 | @opindex mx32 | |
34598 | @opindex m16 | |
34599 | @opindex miamcu | |
ddf6fe37 AA |
34600 | @item -m32 |
34601 | @itemx -m64 | |
34602 | @itemx -mx32 | |
34603 | @itemx -m16 | |
34604 | @itemx -miamcu | |
d77de738 ML |
34605 | Generate code for a 16-bit, 32-bit or 64-bit environment. |
34606 | The @option{-m32} option sets @code{int}, @code{long}, and pointer types | |
34607 | to 32 bits, and | |
eeb92704 | 34608 | generates code that runs in 32-bit mode. |
d77de738 ML |
34609 | |
34610 | The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer | |
34611 | types to 64 bits, and generates code for the x86-64 architecture. | |
34612 | For Darwin only the @option{-m64} option also turns off the @option{-fno-pic} | |
34613 | and @option{-mdynamic-no-pic} options. | |
34614 | ||
34615 | The @option{-mx32} option sets @code{int}, @code{long}, and pointer types | |
34616 | to 32 bits, and | |
34617 | generates code for the x86-64 architecture. | |
34618 | ||
34619 | The @option{-m16} option is the same as @option{-m32}, except for that | |
34620 | it outputs the @code{.code16gcc} assembly directive at the beginning of | |
34621 | the assembly output so that the binary can run in 16-bit mode. | |
34622 | ||
34623 | The @option{-miamcu} option generates code which conforms to Intel MCU | |
34624 | psABI. It requires the @option{-m32} option to be turned on. | |
34625 | ||
d77de738 ML |
34626 | @opindex mno-red-zone |
34627 | @opindex mred-zone | |
ddf6fe37 | 34628 | @item -mno-red-zone |
d77de738 ML |
34629 | Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated |
34630 | by the x86-64 ABI; it is a 128-byte area beyond the location of the | |
34631 | stack pointer that is not modified by signal or interrupt handlers | |
34632 | and therefore can be used for temporary data without adjusting the stack | |
34633 | pointer. The flag @option{-mno-red-zone} disables this red zone. | |
34634 | ||
d77de738 | 34635 | @opindex mcmodel=small |
ddf6fe37 | 34636 | @item -mcmodel=small |
d77de738 ML |
34637 | Generate code for the small code model: the program and its symbols must |
34638 | be linked in the lower 2 GB of the address space. Pointers are 64 bits. | |
34639 | Programs can be statically or dynamically linked. This is the default | |
34640 | code model. | |
34641 | ||
d77de738 | 34642 | @opindex mcmodel=kernel |
ddf6fe37 | 34643 | @item -mcmodel=kernel |
d77de738 ML |
34644 | Generate code for the kernel code model. The kernel runs in the |
34645 | negative 2 GB of the address space. | |
34646 | This model has to be used for Linux kernel code. | |
34647 | ||
d77de738 | 34648 | @opindex mcmodel=medium |
ddf6fe37 | 34649 | @item -mcmodel=medium |
d77de738 ML |
34650 | Generate code for the medium model: the program is linked in the lower 2 |
34651 | GB of the address space. Small symbols are also placed there. Symbols | |
34652 | with sizes larger than @option{-mlarge-data-threshold} are put into | |
34653 | large data or BSS sections and can be located above 2GB. Programs can | |
34654 | be statically or dynamically linked. | |
34655 | ||
d77de738 | 34656 | @opindex mcmodel=large |
ddf6fe37 | 34657 | @item -mcmodel=large |
d77de738 ML |
34658 | Generate code for the large model. This model makes no assumptions |
34659 | about addresses and sizes of sections. | |
34660 | ||
d77de738 | 34661 | @opindex maddress-mode=long |
ddf6fe37 | 34662 | @item -maddress-mode=long |
d77de738 ML |
34663 | Generate code for long address mode. This is only supported for 64-bit |
34664 | and x32 environments. It is the default address mode for 64-bit | |
34665 | environments. | |
34666 | ||
d77de738 | 34667 | @opindex maddress-mode=short |
ddf6fe37 | 34668 | @item -maddress-mode=short |
d77de738 ML |
34669 | Generate code for short address mode. This is only supported for 32-bit |
34670 | and x32 environments. It is the default address mode for 32-bit and | |
34671 | x32 environments. | |
34672 | ||
ddf6fe37 | 34673 | @opindex mneeded |
d77de738 ML |
34674 | @item -mneeded |
34675 | @itemx -mno-needed | |
d77de738 ML |
34676 | Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to |
34677 | indicate the micro-architecture ISA level required to execute the binary. | |
34678 | ||
d77de738 ML |
34679 | @opindex mno-direct-extern-access |
34680 | @opindex mdirect-extern-access | |
ddf6fe37 | 34681 | @item -mno-direct-extern-access |
d77de738 ML |
34682 | Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer |
34683 | to access external symbols. With @option{-fpic} or @option{-fPIC}, | |
34684 | treat access to protected symbols as local symbols. The default is | |
34685 | @option{-mdirect-extern-access}. | |
34686 | ||
34687 | @strong{Warning:} shared libraries compiled with | |
34688 | @option{-mno-direct-extern-access} and executable compiled with | |
34689 | @option{-mdirect-extern-access} may not be binary compatible if | |
34690 | protected symbols are used in shared libraries and executable. | |
ce51e843 | 34691 | |
ce51e843 ML |
34692 | @opindex munroll-only-small-loops |
34693 | @opindex mno-unroll-only-small-loops | |
ddf6fe37 | 34694 | @item -munroll-only-small-loops |
ce51e843 ML |
34695 | Controls conservative small loop unrolling. It is default enabled by |
34696 | O2, and unrolls loop with less than 4 insns by 1 time. Explicit | |
34697 | -f[no-]unroll-[all-]loops would disable this flag to avoid any | |
34698 | unintended unrolling behavior that user does not want. | |
bb576017 | 34699 | |
bb576017 | 34700 | @opindex mlam |
ddf6fe37 | 34701 | @item -mlam=@var{choice} |
bb576017 | 34702 | LAM(linear-address masking) allows special bits in the pointer to be used |
34703 | for metadata. The default is @samp{none}. With @samp{u48}, pointer bits in | |
34704 | positions 62:48 can be used for metadata; With @samp{u57}, pointer bits in | |
34705 | positions 62:57 can be used for metadata. | |
d77de738 ML |
34706 | @end table |
34707 | ||
34708 | @node x86 Windows Options | |
34709 | @subsection x86 Windows Options | |
34710 | @cindex x86 Windows Options | |
34711 | @cindex Windows Options for x86 | |
34712 | ||
34713 | These additional options are available for Microsoft Windows targets: | |
34714 | ||
34715 | @table @gcctabopt | |
d77de738 | 34716 | @opindex mconsole |
ddf6fe37 | 34717 | @item -mconsole |
d77de738 ML |
34718 | This option |
34719 | specifies that a console application is to be generated, by | |
34720 | instructing the linker to set the PE header subsystem type | |
34721 | required for console applications. | |
34722 | This option is available for Cygwin and MinGW targets and is | |
34723 | enabled by default on those targets. | |
34724 | ||
453cb585 PR |
34725 | @opindex mcrtdll |
34726 | @item -mcrtdll=@var{library} | |
34727 | Preprocess, compile or link with specified C RunTime DLL @var{library}. | |
34728 | This option adjust predefined macros @code{__CRTDLL__}, @code{__MSVCRT__} | |
34729 | and @code{__MSVCRT_VERSION__} for specified CRT @var{library}, choose | |
34730 | start file for CRT @var{library} and link with CRT @var{library}. | |
34731 | Recognized CRT library names for proprocessor are: | |
34732 | @code{crtdll}, @code{msvcrt10}, @code{msvcrt20}, @code{msvcrt40}, | |
34733 | @code{msvcrt-os}, @code{msvcr70}, @code{msvcr80}, @code{msvcr90}, | |
34734 | @code{msvcr100}, @code{msvcr110}, @code{msvcr120} and @code{ucrt}. | |
34735 | If this options is not specified then the default MinGW import library | |
34736 | @code{msvcrt} is used for linking and no other adjustment for | |
34737 | preprocessor is done. MinGW import library @code{msvcrt} is just a | |
34738 | symlink to (or a copy of) another MinGW CRT import library | |
34739 | chosen during MinGW compilation. MinGW import library @code{msvcrt-os} | |
34740 | is for Windows system CRT DLL library @code{msvcrt.dll} and | |
34741 | in most cases is the default MinGW import library. | |
34742 | Generally speaking, changing the CRT DLL requires recompiling | |
34743 | the entire MinGW CRT. This option is for experimental and testing | |
34744 | purposes only. | |
34745 | This option is available for MinGW targets. | |
34746 | ||
d77de738 | 34747 | @opindex mdll |
ddf6fe37 | 34748 | @item -mdll |
d77de738 ML |
34749 | This option is available for Cygwin and MinGW targets. It |
34750 | specifies that a DLL---a dynamic link library---is to be | |
34751 | generated, enabling the selection of the required runtime | |
34752 | startup object and entry point. | |
34753 | ||
d77de738 | 34754 | @opindex mnop-fun-dllimport |
ddf6fe37 | 34755 | @item -mnop-fun-dllimport |
d77de738 ML |
34756 | This option is available for Cygwin and MinGW targets. It |
34757 | specifies that the @code{dllimport} attribute should be ignored. | |
34758 | ||
d77de738 | 34759 | @opindex mthreads |
ddf6fe37 | 34760 | @item -mthreads |
d77de738 ML |
34761 | This option is available for MinGW targets. It specifies |
34762 | that MinGW-specific thread support is to be used. | |
34763 | ||
d77de738 | 34764 | @opindex municode |
ddf6fe37 | 34765 | @item -municode |
d77de738 ML |
34766 | This option is available for MinGW-w64 targets. It causes |
34767 | the @code{UNICODE} preprocessor macro to be predefined, and | |
34768 | chooses Unicode-capable runtime startup code. | |
34769 | ||
d77de738 | 34770 | @opindex mwin32 |
ddf6fe37 | 34771 | @item -mwin32 |
d77de738 ML |
34772 | This option is available for Cygwin and MinGW targets. It |
34773 | specifies that the typical Microsoft Windows predefined macros are to | |
34774 | be set in the pre-processor, but does not influence the choice | |
34775 | of runtime library/startup code. | |
34776 | ||
d77de738 | 34777 | @opindex mwindows |
ddf6fe37 | 34778 | @item -mwindows |
d77de738 ML |
34779 | This option is available for Cygwin and MinGW targets. It |
34780 | specifies that a GUI application is to be generated by | |
34781 | instructing the linker to set the PE header subsystem type | |
34782 | appropriately. | |
34783 | ||
d77de738 ML |
34784 | @opindex fno-set-stack-executable |
34785 | @opindex fset-stack-executable | |
ddf6fe37 | 34786 | @item -fno-set-stack-executable |
d77de738 ML |
34787 | This option is available for MinGW targets. It specifies that |
34788 | the executable flag for the stack used by nested functions isn't | |
34789 | set. This is necessary for binaries running in kernel mode of | |
34790 | Microsoft Windows, as there the User32 API, which is used to set executable | |
34791 | privileges, isn't available. | |
34792 | ||
d77de738 ML |
34793 | @opindex fno-writable-relocated-rdata |
34794 | @opindex fwritable-relocated-rdata | |
ddf6fe37 | 34795 | @item -fwritable-relocated-rdata |
d77de738 ML |
34796 | This option is available for MinGW and Cygwin targets. It specifies |
34797 | that relocated-data in read-only section is put into the @code{.data} | |
34798 | section. This is a necessary for older runtimes not supporting | |
34799 | modification of @code{.rdata} sections for pseudo-relocation. | |
34800 | ||
d77de738 | 34801 | @opindex mpe-aligned-commons |
ddf6fe37 | 34802 | @item -mpe-aligned-commons |
d77de738 ML |
34803 | This option is available for Cygwin and MinGW targets. It |
34804 | specifies that the GNU extension to the PE file format that | |
34805 | permits the correct alignment of COMMON variables should be | |
34806 | used when generating code. It is enabled by default if | |
34807 | GCC detects that the target assembler found during configuration | |
34808 | supports the feature. | |
34809 | @end table | |
34810 | ||
34811 | See also under @ref{x86 Options} for standard options. | |
34812 | ||
34813 | @node Xstormy16 Options | |
34814 | @subsection Xstormy16 Options | |
34815 | @cindex Xstormy16 Options | |
34816 | ||
34817 | These options are defined for Xstormy16: | |
34818 | ||
34819 | @table @gcctabopt | |
d77de738 | 34820 | @opindex msim |
ddf6fe37 | 34821 | @item -msim |
d77de738 ML |
34822 | Choose startup files and linker script suitable for the simulator. |
34823 | @end table | |
34824 | ||
34825 | @node Xtensa Options | |
34826 | @subsection Xtensa Options | |
34827 | @cindex Xtensa Options | |
34828 | ||
34829 | These options are supported for Xtensa targets: | |
34830 | ||
34831 | @table @gcctabopt | |
d77de738 ML |
34832 | @opindex mconst16 |
34833 | @opindex mno-const16 | |
ddf6fe37 AA |
34834 | @item -mconst16 |
34835 | @itemx -mno-const16 | |
d77de738 ML |
34836 | Enable or disable use of @code{CONST16} instructions for loading |
34837 | constant values. The @code{CONST16} instruction is currently not a | |
34838 | standard option from Tensilica. When enabled, @code{CONST16} | |
34839 | instructions are always used in place of the standard @code{L32R} | |
34840 | instructions. The use of @code{CONST16} is enabled by default only if | |
34841 | the @code{L32R} instruction is not available. | |
34842 | ||
d77de738 ML |
34843 | @opindex mfused-madd |
34844 | @opindex mno-fused-madd | |
ddf6fe37 AA |
34845 | @item -mfused-madd |
34846 | @itemx -mno-fused-madd | |
d77de738 ML |
34847 | Enable or disable use of fused multiply/add and multiply/subtract |
34848 | instructions in the floating-point option. This has no effect if the | |
34849 | floating-point option is not also enabled. Disabling fused multiply/add | |
34850 | and multiply/subtract instructions forces the compiler to use separate | |
34851 | instructions for the multiply and add/subtract operations. This may be | |
34852 | desirable in some cases where strict IEEE 754-compliant results are | |
34853 | required: the fused multiply add/subtract instructions do not round the | |
34854 | intermediate result, thereby producing results with @emph{more} bits of | |
34855 | precision than specified by the IEEE standard. Disabling fused multiply | |
34856 | add/subtract instructions also ensures that the program output is not | |
34857 | sensitive to the compiler's ability to combine multiply and add/subtract | |
34858 | operations. | |
34859 | ||
d77de738 ML |
34860 | @opindex mserialize-volatile |
34861 | @opindex mno-serialize-volatile | |
ddf6fe37 AA |
34862 | @item -mserialize-volatile |
34863 | @itemx -mno-serialize-volatile | |
d77de738 ML |
34864 | When this option is enabled, GCC inserts @code{MEMW} instructions before |
34865 | @code{volatile} memory references to guarantee sequential consistency. | |
34866 | The default is @option{-mserialize-volatile}. Use | |
34867 | @option{-mno-serialize-volatile} to omit the @code{MEMW} instructions. | |
34868 | ||
d77de738 | 34869 | @opindex mforce-no-pic |
ddf6fe37 | 34870 | @item -mforce-no-pic |
d77de738 ML |
34871 | For targets, like GNU/Linux, where all user-mode Xtensa code must be |
34872 | position-independent code (PIC), this option disables PIC for compiling | |
34873 | kernel code. | |
34874 | ||
d77de738 ML |
34875 | @opindex mtext-section-literals |
34876 | @opindex mno-text-section-literals | |
ddf6fe37 AA |
34877 | @item -mtext-section-literals |
34878 | @itemx -mno-text-section-literals | |
d77de738 ML |
34879 | These options control the treatment of literal pools. The default is |
34880 | @option{-mno-text-section-literals}, which places literals in a separate | |
34881 | section in the output file. This allows the literal pool to be placed | |
34882 | in a data RAM/ROM, and it also allows the linker to combine literal | |
34883 | pools from separate object files to remove redundant literals and | |
34884 | improve code size. With @option{-mtext-section-literals}, the literals | |
34885 | are interspersed in the text section in order to keep them as close as | |
34886 | possible to their references. This may be necessary for large assembly | |
34887 | files. Literals for each function are placed right before that function. | |
34888 | ||
d77de738 ML |
34889 | @opindex mauto-litpools |
34890 | @opindex mno-auto-litpools | |
ddf6fe37 AA |
34891 | @item -mauto-litpools |
34892 | @itemx -mno-auto-litpools | |
d77de738 ML |
34893 | These options control the treatment of literal pools. The default is |
34894 | @option{-mno-auto-litpools}, which places literals in a separate | |
34895 | section in the output file unless @option{-mtext-section-literals} is | |
34896 | used. With @option{-mauto-litpools} the literals are interspersed in | |
34897 | the text section by the assembler. Compiler does not produce explicit | |
34898 | @code{.literal} directives and loads literals into registers with | |
34899 | @code{MOVI} instructions instead of @code{L32R} to let the assembler | |
34900 | do relaxation and place literals as necessary. This option allows | |
34901 | assembler to create several literal pools per function and assemble | |
34902 | very big functions, which may not be possible with | |
34903 | @option{-mtext-section-literals}. | |
34904 | ||
d77de738 ML |
34905 | @opindex mtarget-align |
34906 | @opindex mno-target-align | |
ddf6fe37 AA |
34907 | @item -mtarget-align |
34908 | @itemx -mno-target-align | |
d77de738 ML |
34909 | When this option is enabled, GCC instructs the assembler to |
34910 | automatically align instructions to reduce branch penalties at the | |
34911 | expense of some code density. The assembler attempts to widen density | |
34912 | instructions to align branch targets and the instructions following call | |
34913 | instructions. If there are not enough preceding safe density | |
34914 | instructions to align a target, no widening is performed. The | |
34915 | default is @option{-mtarget-align}. These options do not affect the | |
34916 | treatment of auto-aligned instructions like @code{LOOP}, which the | |
34917 | assembler always aligns, either by widening density instructions or | |
34918 | by inserting NOP instructions. | |
34919 | ||
d77de738 ML |
34920 | @opindex mlongcalls |
34921 | @opindex mno-longcalls | |
ddf6fe37 AA |
34922 | @item -mlongcalls |
34923 | @itemx -mno-longcalls | |
d77de738 ML |
34924 | When this option is enabled, GCC instructs the assembler to translate |
34925 | direct calls to indirect calls unless it can determine that the target | |
34926 | of a direct call is in the range allowed by the call instruction. This | |
34927 | translation typically occurs for calls to functions in other source | |
34928 | files. Specifically, the assembler translates a direct @code{CALL} | |
34929 | instruction into an @code{L32R} followed by a @code{CALLX} instruction. | |
34930 | The default is @option{-mno-longcalls}. This option should be used in | |
34931 | programs where the call target can potentially be out of range. This | |
34932 | option is implemented in the assembler, not the compiler, so the | |
34933 | assembly code generated by GCC still shows direct call | |
34934 | instructions---look at the disassembled object code to see the actual | |
34935 | instructions. Note that the assembler uses an indirect call for | |
34936 | every cross-file call, not just those that really are out of range. | |
34937 | ||
d77de738 | 34938 | @opindex mabi |
ddf6fe37 | 34939 | @item -mabi=@var{name} |
d77de738 ML |
34940 | Generate code for the specified ABI@. Permissible values are: @samp{call0}, |
34941 | @samp{windowed}. Default ABI is chosen by the Xtensa core configuration. | |
34942 | ||
d77de738 | 34943 | @opindex mabi=call0 |
ddf6fe37 | 34944 | @item -mabi=call0 |
d77de738 ML |
34945 | When this option is enabled function parameters are passed in registers |
34946 | @code{a2} through @code{a7}, registers @code{a12} through @code{a15} are | |
34947 | caller-saved, and register @code{a15} may be used as a frame pointer. | |
34948 | When this version of the ABI is enabled the C preprocessor symbol | |
34949 | @code{__XTENSA_CALL0_ABI__} is defined. | |
34950 | ||
d77de738 | 34951 | @opindex mabi=windowed |
ddf6fe37 | 34952 | @item -mabi=windowed |
d77de738 ML |
34953 | When this option is enabled function parameters are passed in registers |
34954 | @code{a10} through @code{a15}, and called function rotates register window | |
34955 | by 8 registers on entry so that its arguments are found in registers | |
34956 | @code{a2} through @code{a7}. Register @code{a7} may be used as a frame | |
34957 | pointer. Register window is rotated 8 registers back upon return. | |
34958 | When this version of the ABI is enabled the C preprocessor symbol | |
34959 | @code{__XTENSA_WINDOWED_ABI__} is defined. | |
34960 | ||
d77de738 | 34961 | @opindex mextra-l32r-costs |
ddf6fe37 | 34962 | @item -mextra-l32r-costs=@var{n} |
d77de738 ML |
34963 | Specify an extra cost of instruction RAM/ROM access for @code{L32R} |
34964 | instructions, in clock cycles. This affects, when optimizing for speed, | |
34965 | whether loading a constant from literal pool using @code{L32R} or | |
34966 | synthesizing the constant from a small one with a couple of arithmetic | |
34967 | instructions. The default value is 0. | |
675b390e MF |
34968 | |
34969 | @opindex mstrict-align | |
34970 | @opindex mno-strict-align | |
34971 | @item -mstrict-align | |
34972 | @itemx -mno-strict-align | |
34973 | Avoid or allow generating memory accesses that may not be aligned on a natural | |
34974 | object boundary as described in the architecture specification. | |
34975 | The default is @option{-mno-strict-align} for cores that support both | |
34976 | unaligned loads and stores in hardware and @option{-mstrict-align} for all | |
34977 | other cores. | |
34978 | ||
d77de738 ML |
34979 | @end table |
34980 | ||
34981 | @node zSeries Options | |
34982 | @subsection zSeries Options | |
34983 | @cindex zSeries options | |
34984 | ||
34985 | These are listed under @xref{S/390 and zSeries Options}. | |
34986 | ||
34987 | ||
34988 | @c man end | |
34989 | ||
34990 | @node Spec Files | |
34991 | @section Specifying Subprocesses and the Switches to Pass to Them | |
34992 | @cindex Spec Files | |
34993 | ||
34994 | @command{gcc} is a driver program. It performs its job by invoking a | |
34995 | sequence of other programs to do the work of compiling, assembling and | |
34996 | linking. GCC interprets its command-line parameters and uses these to | |
34997 | deduce which programs it should invoke, and which command-line options | |
34998 | it ought to place on their command lines. This behavior is controlled | |
34999 | by @dfn{spec strings}. In most cases there is one spec string for each | |
35000 | program that GCC can invoke, but a few programs have multiple spec | |
35001 | strings to control their behavior. The spec strings built into GCC can | |
35002 | be overridden by using the @option{-specs=} command-line switch to specify | |
35003 | a spec file. | |
35004 | ||
35005 | @dfn{Spec files} are plain-text files that are used to construct spec | |
35006 | strings. They consist of a sequence of directives separated by blank | |
35007 | lines. The type of directive is determined by the first non-whitespace | |
35008 | character on the line, which can be one of the following: | |
35009 | ||
35010 | @table @code | |
35011 | @item %@var{command} | |
35012 | Issues a @var{command} to the spec file processor. The commands that can | |
35013 | appear here are: | |
35014 | ||
35015 | @table @code | |
d77de738 | 35016 | @cindex @code{%include} |
f33d7a88 | 35017 | @item %include <@var{file}> |
d77de738 ML |
35018 | Search for @var{file} and insert its text at the current point in the |
35019 | specs file. | |
35020 | ||
d77de738 | 35021 | @cindex @code{%include_noerr} |
f33d7a88 | 35022 | @item %include_noerr <@var{file}> |
d77de738 ML |
35023 | Just like @samp{%include}, but do not generate an error message if the include |
35024 | file cannot be found. | |
35025 | ||
d77de738 | 35026 | @cindex @code{%rename} |
f33d7a88 | 35027 | @item %rename @var{old_name} @var{new_name} |
d77de738 ML |
35028 | Rename the spec string @var{old_name} to @var{new_name}. |
35029 | ||
35030 | @end table | |
35031 | ||
35032 | @item *[@var{spec_name}]: | |
35033 | This tells the compiler to create, override or delete the named spec | |
35034 | string. All lines after this directive up to the next directive or | |
35035 | blank line are considered to be the text for the spec string. If this | |
35036 | results in an empty string then the spec is deleted. (Or, if the | |
35037 | spec did not exist, then nothing happens.) Otherwise, if the spec | |
35038 | does not currently exist a new spec is created. If the spec does | |
35039 | exist then its contents are overridden by the text of this | |
35040 | directive, unless the first character of that text is the @samp{+} | |
35041 | character, in which case the text is appended to the spec. | |
35042 | ||
35043 | @item [@var{suffix}]: | |
35044 | Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive | |
35045 | and up to the next directive or blank line are considered to make up the | |
35046 | spec string for the indicated suffix. When the compiler encounters an | |
35047 | input file with the named suffix, it processes the spec string in | |
35048 | order to work out how to compile that file. For example: | |
35049 | ||
35050 | @smallexample | |
35051 | .ZZ: | |
35052 | z-compile -input %i | |
35053 | @end smallexample | |
35054 | ||
35055 | This says that any input file whose name ends in @samp{.ZZ} should be | |
35056 | passed to the program @samp{z-compile}, which should be invoked with the | |
35057 | command-line switch @option{-input} and with the result of performing the | |
35058 | @samp{%i} substitution. (See below.) | |
35059 | ||
35060 | As an alternative to providing a spec string, the text following a | |
35061 | suffix directive can be one of the following: | |
35062 | ||
35063 | @table @code | |
35064 | @item @@@var{language} | |
35065 | This says that the suffix is an alias for a known @var{language}. This is | |
35066 | similar to using the @option{-x} command-line switch to GCC to specify a | |
35067 | language explicitly. For example: | |
35068 | ||
35069 | @smallexample | |
35070 | .ZZ: | |
35071 | @@c++ | |
35072 | @end smallexample | |
35073 | ||
35074 | Says that .ZZ files are, in fact, C++ source files. | |
35075 | ||
35076 | @item #@var{name} | |
35077 | This causes an error messages saying: | |
35078 | ||
35079 | @smallexample | |
35080 | @var{name} compiler not installed on this system. | |
35081 | @end smallexample | |
35082 | @end table | |
35083 | ||
35084 | GCC already has an extensive list of suffixes built into it. | |
35085 | This directive adds an entry to the end of the list of suffixes, but | |
35086 | since the list is searched from the end backwards, it is effectively | |
35087 | possible to override earlier entries using this technique. | |
35088 | ||
35089 | @end table | |
35090 | ||
35091 | GCC has the following spec strings built into it. Spec files can | |
35092 | override these strings or create their own. Note that individual | |
35093 | targets can also add their own spec strings to this list. | |
35094 | ||
35095 | @smallexample | |
35096 | asm Options to pass to the assembler | |
35097 | asm_final Options to pass to the assembler post-processor | |
35098 | cpp Options to pass to the C preprocessor | |
35099 | cc1 Options to pass to the C compiler | |
35100 | cc1plus Options to pass to the C++ compiler | |
35101 | endfile Object files to include at the end of the link | |
35102 | link Options to pass to the linker | |
35103 | lib Libraries to include on the command line to the linker | |
35104 | libgcc Decides which GCC support library to pass to the linker | |
35105 | linker Sets the name of the linker | |
35106 | predefines Defines to be passed to the C preprocessor | |
35107 | signed_char Defines to pass to CPP to say whether @code{char} is signed | |
35108 | by default | |
35109 | startfile Object files to include at the start of the link | |
35110 | @end smallexample | |
35111 | ||
35112 | Here is a small example of a spec file: | |
35113 | ||
35114 | @smallexample | |
35115 | %rename lib old_lib | |
35116 | ||
35117 | *lib: | |
35118 | --start-group -lgcc -lc -leval1 --end-group %(old_lib) | |
35119 | @end smallexample | |
35120 | ||
35121 | This example renames the spec called @samp{lib} to @samp{old_lib} and | |
35122 | then overrides the previous definition of @samp{lib} with a new one. | |
35123 | The new definition adds in some extra command-line options before | |
35124 | including the text of the old definition. | |
35125 | ||
35126 | @dfn{Spec strings} are a list of command-line options to be passed to their | |
35127 | corresponding program. In addition, the spec strings can contain | |
35128 | @samp{%}-prefixed sequences to substitute variable text or to | |
35129 | conditionally insert text into the command line. Using these constructs | |
35130 | it is possible to generate quite complex command lines. | |
35131 | ||
35132 | Here is a table of all defined @samp{%}-sequences for spec | |
35133 | strings. Note that spaces are not generated automatically around the | |
35134 | results of expanding these sequences. Therefore you can concatenate them | |
35135 | together or combine them with constant text in a single argument. | |
35136 | ||
35137 | @table @code | |
35138 | @item %% | |
35139 | Substitute one @samp{%} into the program name or argument. | |
35140 | ||
35141 | @item %" | |
35142 | Substitute an empty argument. | |
35143 | ||
35144 | @item %i | |
35145 | Substitute the name of the input file being processed. | |
35146 | ||
35147 | @item %b | |
35148 | Substitute the basename for outputs related with the input file being | |
35149 | processed. This is often the substring up to (and not including) the | |
35150 | last period and not including the directory but, unless %w is active, it | |
35151 | expands to the basename for auxiliary outputs, which may be influenced | |
35152 | by an explicit output name, and by various other options that control | |
35153 | how auxiliary outputs are named. | |
35154 | ||
35155 | @item %B | |
35156 | This is the same as @samp{%b}, but include the file suffix (text after | |
35157 | the last period). Without %w, it expands to the basename for dump | |
35158 | outputs. | |
35159 | ||
35160 | @item %d | |
35161 | Marks the argument containing or following the @samp{%d} as a | |
35162 | temporary file name, so that that file is deleted if GCC exits | |
35163 | successfully. Unlike @samp{%g}, this contributes no text to the | |
35164 | argument. | |
35165 | ||
35166 | @item %g@var{suffix} | |
35167 | Substitute a file name that has suffix @var{suffix} and is chosen | |
35168 | once per compilation, and mark the argument in the same way as | |
35169 | @samp{%d}. To reduce exposure to denial-of-service attacks, the file | |
35170 | name is now chosen in a way that is hard to predict even when previously | |
35171 | chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s} | |
35172 | might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches | |
35173 | the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is | |
35174 | treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g} | |
35175 | was simply substituted with a file name chosen once per compilation, | |
35176 | without regard to any appended suffix (which was therefore treated | |
35177 | just like ordinary text), making such attacks more likely to succeed. | |
35178 | ||
35179 | @item %u@var{suffix} | |
35180 | Like @samp{%g}, but generates a new temporary file name | |
35181 | each time it appears instead of once per compilation. | |
35182 | ||
35183 | @item %U@var{suffix} | |
35184 | Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a | |
35185 | new one if there is no such last file name. In the absence of any | |
35186 | @samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share | |
35187 | the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s} | |
35188 | involves the generation of two distinct file names, one | |
35189 | for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was | |
35190 | simply substituted with a file name chosen for the previous @samp{%u}, | |
35191 | without regard to any appended suffix. | |
35192 | ||
35193 | @item %j@var{suffix} | |
35194 | Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is | |
35195 | writable, and if @option{-save-temps} is not used; | |
35196 | otherwise, substitute the name | |
35197 | of a temporary file, just like @samp{%u}. This temporary file is not | |
35198 | meant for communication between processes, but rather as a junk | |
35199 | disposal mechanism. | |
35200 | ||
35201 | @item %|@var{suffix} | |
35202 | @itemx %m@var{suffix} | |
35203 | Like @samp{%g}, except if @option{-pipe} is in effect. In that case | |
35204 | @samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at | |
35205 | all. These are the two most common ways to instruct a program that it | |
35206 | should read from standard input or write to standard output. If you | |
35207 | need something more elaborate you can use an @samp{%@{pipe:@code{X}@}} | |
35208 | construct: see for example @file{gcc/fortran/lang-specs.h}. | |
35209 | ||
35210 | @item %.@var{SUFFIX} | |
35211 | Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args | |
35212 | when it is subsequently output with @samp{%*}. @var{SUFFIX} is | |
35213 | terminated by the next space or %. | |
35214 | ||
35215 | @item %w | |
35216 | Marks the argument containing or following the @samp{%w} as the | |
35217 | designated output file of this compilation. This puts the argument | |
35218 | into the sequence of arguments that @samp{%o} substitutes. | |
35219 | ||
35220 | @item %V | |
35221 | Indicates that this compilation produces no output file. | |
35222 | ||
35223 | @item %o | |
35224 | Substitutes the names of all the output files, with spaces | |
35225 | automatically placed around them. You should write spaces | |
35226 | around the @samp{%o} as well or the results are undefined. | |
35227 | @samp{%o} is for use in the specs for running the linker. | |
35228 | Input files whose names have no recognized suffix are not compiled | |
35229 | at all, but they are included among the output files, so they are | |
35230 | linked. | |
35231 | ||
35232 | @item %O | |
35233 | Substitutes the suffix for object files. Note that this is | |
35234 | handled specially when it immediately follows @samp{%g, %u, or %U}, | |
35235 | because of the need for those to form complete file names. The | |
35236 | handling is such that @samp{%O} is treated exactly as if it had already | |
35237 | been substituted, except that @samp{%g, %u, and %U} do not currently | |
35238 | support additional @var{suffix} characters following @samp{%O} as they do | |
35239 | following, for example, @samp{.o}. | |
35240 | ||
35241 | @item %I | |
35242 | Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}), | |
35243 | @option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}), | |
35244 | @option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options) | |
35245 | and @option{-imultilib} as necessary. | |
35246 | ||
35247 | @item %s | |
35248 | Current argument is the name of a library or startup file of some sort. | |
35249 | Search for that file in a standard list of directories and substitute | |
35250 | the full name found. The current working directory is included in the | |
35251 | list of directories scanned. | |
35252 | ||
35253 | @item %T | |
35254 | Current argument is the name of a linker script. Search for that file | |
35255 | in the current list of directories to scan for libraries. If the file | |
35256 | is located insert a @option{--script} option into the command line | |
35257 | followed by the full path name found. If the file is not found then | |
35258 | generate an error message. Note: the current working directory is not | |
35259 | searched. | |
35260 | ||
35261 | @item %e@var{str} | |
35262 | Print @var{str} as an error message. @var{str} is terminated by a newline. | |
35263 | Use this when inconsistent options are detected. | |
35264 | ||
35265 | @item %n@var{str} | |
35266 | Print @var{str} as a notice. @var{str} is terminated by a newline. | |
35267 | ||
35268 | @item %(@var{name}) | |
35269 | Substitute the contents of spec string @var{name} at this point. | |
35270 | ||
35271 | @item %x@{@var{option}@} | |
35272 | Accumulate an option for @samp{%X}. | |
35273 | ||
35274 | @item %X | |
35275 | Output the accumulated linker options specified by a @samp{%x} spec string. | |
35276 | ||
35277 | @item %Y | |
35278 | Output the accumulated assembler options specified by @option{-Wa}. | |
35279 | ||
35280 | @item %Z | |
35281 | Output the accumulated preprocessor options specified by @option{-Wp}. | |
35282 | ||
35283 | @item %M | |
35284 | Output @code{multilib_os_dir}. | |
35285 | ||
35286 | @item %R | |
35287 | Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}. | |
35288 | ||
35289 | @item %a | |
35290 | Process the @code{asm} spec. This is used to compute the | |
35291 | switches to be passed to the assembler. | |
35292 | ||
35293 | @item %A | |
35294 | Process the @code{asm_final} spec. This is a spec string for | |
35295 | passing switches to an assembler post-processor, if such a program is | |
35296 | needed. | |
35297 | ||
35298 | @item %l | |
35299 | Process the @code{link} spec. This is the spec for computing the | |
35300 | command line passed to the linker. Typically it makes use of the | |
35301 | @samp{%L %G %S %D and %E} sequences. | |
35302 | ||
35303 | @item %D | |
35304 | Dump out a @option{-L} option for each directory that GCC believes might | |
35305 | contain startup files. If the target supports multilibs then the | |
35306 | current multilib directory is prepended to each of these paths. | |
35307 | ||
35308 | @item %L | |
35309 | Process the @code{lib} spec. This is a spec string for deciding which | |
35310 | libraries are included on the command line to the linker. | |
35311 | ||
35312 | @item %G | |
35313 | Process the @code{libgcc} spec. This is a spec string for deciding | |
35314 | which GCC support library is included on the command line to the linker. | |
35315 | ||
35316 | @item %S | |
35317 | Process the @code{startfile} spec. This is a spec for deciding which | |
35318 | object files are the first ones passed to the linker. Typically | |
35319 | this might be a file named @file{crt0.o}. | |
35320 | ||
35321 | @item %E | |
35322 | Process the @code{endfile} spec. This is a spec string that specifies | |
35323 | the last object files that are passed to the linker. | |
35324 | ||
35325 | @item %C | |
35326 | Process the @code{cpp} spec. This is used to construct the arguments | |
35327 | to be passed to the C preprocessor. | |
35328 | ||
35329 | @item %1 | |
35330 | Process the @code{cc1} spec. This is used to construct the options to be | |
35331 | passed to the actual C compiler (@command{cc1}). | |
35332 | ||
35333 | @item %2 | |
35334 | Process the @code{cc1plus} spec. This is used to construct the options to be | |
35335 | passed to the actual C++ compiler (@command{cc1plus}). | |
35336 | ||
35337 | @item %* | |
35338 | Substitute the variable part of a matched option. See below. | |
35339 | Note that each comma in the substituted string is replaced by | |
35340 | a single space. | |
35341 | ||
35342 | @item %<S | |
35343 | Remove all occurrences of @code{-S} from the command line. Note---this | |
35344 | command is position dependent. @samp{%} commands in the spec string | |
35345 | before this one see @code{-S}, @samp{%} commands in the spec string | |
35346 | after this one do not. | |
35347 | ||
35348 | @item %<S* | |
35349 | Similar to @samp{%<S}, but match all switches beginning with @code{-S}. | |
35350 | ||
35351 | @item %>S | |
35352 | Similar to @samp{%<S}, but keep @code{-S} in the GCC command line. | |
35353 | ||
35354 | @item %:@var{function}(@var{args}) | |
35355 | Call the named function @var{function}, passing it @var{args}. | |
35356 | @var{args} is first processed as a nested spec string, then split | |
35357 | into an argument vector in the usual fashion. The function returns | |
35358 | a string which is processed as if it had appeared literally as part | |
35359 | of the current spec. | |
35360 | ||
35361 | The following built-in spec functions are provided: | |
35362 | ||
35363 | @table @code | |
35364 | @item @code{getenv} | |
35365 | The @code{getenv} spec function takes two arguments: an environment | |
35366 | variable name and a string. If the environment variable is not | |
35367 | defined, a fatal error is issued. Otherwise, the return value is the | |
35368 | value of the environment variable concatenated with the string. For | |
35369 | example, if @env{TOPDIR} is defined as @file{/path/to/top}, then: | |
35370 | ||
35371 | @smallexample | |
35372 | %:getenv(TOPDIR /include) | |
35373 | @end smallexample | |
35374 | ||
35375 | expands to @file{/path/to/top/include}. | |
35376 | ||
35377 | @item @code{if-exists} | |
35378 | The @code{if-exists} spec function takes one argument, an absolute | |
35379 | pathname to a file. If the file exists, @code{if-exists} returns the | |
35380 | pathname. Here is a small example of its usage: | |
35381 | ||
35382 | @smallexample | |
35383 | *startfile: | |
35384 | crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s | |
35385 | @end smallexample | |
35386 | ||
35387 | @item @code{if-exists-else} | |
35388 | The @code{if-exists-else} spec function is similar to the @code{if-exists} | |
35389 | spec function, except that it takes two arguments. The first argument is | |
35390 | an absolute pathname to a file. If the file exists, @code{if-exists-else} | |
35391 | returns the pathname. If it does not exist, it returns the second argument. | |
35392 | This way, @code{if-exists-else} can be used to select one file or another, | |
35393 | based on the existence of the first. Here is a small example of its usage: | |
35394 | ||
35395 | @smallexample | |
35396 | *startfile: | |
35397 | crt0%O%s %:if-exists(crti%O%s) \ | |
35398 | %:if-exists-else(crtbeginT%O%s crtbegin%O%s) | |
35399 | @end smallexample | |
35400 | ||
35401 | @item @code{if-exists-then-else} | |
35402 | The @code{if-exists-then-else} spec function takes at least two arguments | |
35403 | and an optional third one. The first argument is an absolute pathname to a | |
35404 | file. If the file exists, the function returns the second argument. | |
35405 | If the file does not exist, the function returns the third argument if there | |
35406 | is one, or NULL otherwise. This can be used to expand one text, or optionally | |
35407 | another, based on the existence of a file. Here is a small example of its | |
35408 | usage: | |
35409 | ||
35410 | @smallexample | |
35411 | -l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net) | |
35412 | @end smallexample | |
35413 | ||
35414 | @item @code{sanitize} | |
35415 | The @code{sanitize} spec function takes no arguments. It returns non-NULL if | |
35416 | any address, thread or undefined behavior sanitizers are active. | |
35417 | ||
35418 | @smallexample | |
35419 | %@{%:sanitize(address):-funwind-tables@} | |
35420 | @end smallexample | |
35421 | ||
35422 | @item @code{replace-outfile} | |
35423 | The @code{replace-outfile} spec function takes two arguments. It looks for the | |
35424 | first argument in the outfiles array and replaces it with the second argument. Here | |
35425 | is a small example of its usage: | |
35426 | ||
35427 | @smallexample | |
35428 | %@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@} | |
35429 | @end smallexample | |
35430 | ||
35431 | @item @code{remove-outfile} | |
35432 | The @code{remove-outfile} spec function takes one argument. It looks for the | |
35433 | first argument in the outfiles array and removes it. Here is a small example | |
35434 | its usage: | |
35435 | ||
35436 | @smallexample | |
35437 | %:remove-outfile(-lm) | |
35438 | @end smallexample | |
35439 | ||
35440 | @item @code{version-compare} | |
35441 | The @code{version-compare} spec function takes four or five arguments of the following | |
35442 | form: | |
35443 | ||
35444 | @smallexample | |
35445 | <comparison-op> <arg1> [<arg2>] <switch> <result> | |
35446 | @end smallexample | |
35447 | ||
35448 | It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't. | |
35449 | The supported @code{comparison-op} values are: | |
35450 | ||
35451 | @table @code | |
35452 | @item >= | |
35453 | True if @code{switch} is a later (or same) version than @code{arg1} | |
35454 | ||
35455 | @item !> | |
35456 | Opposite of @code{>=} | |
35457 | ||
35458 | @item < | |
35459 | True if @code{switch} is an earlier version than @code{arg1} | |
35460 | ||
35461 | @item !< | |
35462 | Opposite of @code{<} | |
35463 | ||
35464 | @item >< | |
35465 | True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2} | |
35466 | ||
35467 | @item <> | |
35468 | True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later | |
35469 | @end table | |
35470 | ||
35471 | If the @code{switch} is not present at all, the condition is false unless the first character | |
35472 | of the @code{comparison-op} is @code{!}. | |
35473 | ||
35474 | @smallexample | |
35475 | %:version-compare(>= 10.3 mmacosx-version-min= -lmx) | |
35476 | @end smallexample | |
35477 | ||
35478 | The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was | |
35479 | passed. | |
35480 | ||
35481 | @item @code{include} | |
35482 | The @code{include} spec function behaves much like @code{%include}, with the advantage | |
35483 | that it can be nested inside a spec and thus be conditionalized. It takes one argument, | |
35484 | the filename, and looks for it in the startfile path. It always returns NULL. | |
35485 | ||
35486 | @smallexample | |
35487 | %@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@} | |
35488 | @end smallexample | |
35489 | ||
35490 | @item @code{pass-through-libs} | |
35491 | The @code{pass-through-libs} spec function takes any number of arguments. It | |
35492 | finds any @option{-l} options and any non-options ending in @file{.a} (which it | |
35493 | assumes are the names of linker input library archive files) and returns a | |
35494 | result containing all the found arguments each prepended by | |
35495 | @option{-plugin-opt=-pass-through=} and joined by spaces. This list is | |
35496 | intended to be passed to the LTO linker plugin. | |
35497 | ||
35498 | @smallexample | |
35499 | %:pass-through-libs(%G %L %G) | |
35500 | @end smallexample | |
35501 | ||
35502 | @item @code{print-asm-header} | |
35503 | The @code{print-asm-header} function takes no arguments and simply | |
35504 | prints a banner like: | |
35505 | ||
35506 | @smallexample | |
35507 | Assembler options | |
35508 | ================= | |
35509 | ||
35510 | Use "-Wa,OPTION" to pass "OPTION" to the assembler. | |
35511 | @end smallexample | |
35512 | ||
35513 | It is used to separate compiler options from assembler options | |
35514 | in the @option{--target-help} output. | |
35515 | ||
35516 | @item @code{gt} | |
35517 | The @code{gt} spec function takes two or more arguments. It returns @code{""} (the | |
35518 | empty string) if the second-to-last argument is greater than the last argument, and NULL | |
35519 | otherwise. The following example inserts the @code{link_gomp} spec if the last | |
35520 | @option{-ftree-parallelize-loops=} option given on the command line is greater than 1: | |
35521 | ||
35522 | @smallexample | |
35523 | %@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@} | |
35524 | @end smallexample | |
35525 | ||
35526 | @item @code{debug-level-gt} | |
35527 | The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the | |
35528 | empty string) if @code{debug_info_level} is greater than the specified number, and NULL | |
35529 | otherwise. | |
35530 | ||
35531 | @smallexample | |
35532 | %@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@} | |
35533 | @end smallexample | |
35534 | @end table | |
35535 | ||
35536 | @item %@{S@} | |
35537 | Substitutes the @code{-S} switch, if that switch is given to GCC@. | |
35538 | If that switch is not specified, this substitutes nothing. Note that | |
35539 | the leading dash is omitted when specifying this option, and it is | |
35540 | automatically inserted if the substitution is performed. Thus the spec | |
35541 | string @samp{%@{foo@}} matches the command-line option @option{-foo} | |
35542 | and outputs the command-line option @option{-foo}. | |
35543 | ||
35544 | @item %W@{S@} | |
35545 | Like %@{@code{S}@} but mark last argument supplied within as a file to be | |
35546 | deleted on failure. | |
35547 | ||
35548 | @item %@@@{S@} | |
35549 | Like %@{@code{S}@} but puts the result into a @code{FILE} and substitutes | |
35550 | @code{@@FILE} if an @code{@@file} argument has been supplied. | |
35551 | ||
35552 | @item %@{S*@} | |
35553 | Substitutes all the switches specified to GCC whose names start | |
35554 | with @code{-S}, but which also take an argument. This is used for | |
35555 | switches like @option{-o}, @option{-D}, @option{-I}, etc. | |
35556 | GCC considers @option{-o foo} as being | |
35557 | one switch whose name starts with @samp{o}. %@{o*@} substitutes this | |
35558 | text, including the space. Thus two arguments are generated. | |
35559 | ||
35560 | @item %@{S*&T*@} | |
35561 | Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options | |
35562 | (the order of @code{S} and @code{T} in the spec is not significant). | |
35563 | There can be any number of ampersand-separated variables; for each the | |
35564 | wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}. | |
35565 | ||
35566 | @item %@{S:X@} | |
35567 | Substitutes @code{X}, if the @option{-S} switch is given to GCC@. | |
35568 | ||
35569 | @item %@{!S:X@} | |
35570 | Substitutes @code{X}, if the @option{-S} switch is @emph{not} given to GCC@. | |
35571 | ||
35572 | @item %@{S*:X@} | |
35573 | Substitutes @code{X} if one or more switches whose names start with | |
35574 | @code{-S} are specified to GCC@. Normally @code{X} is substituted only | |
35575 | once, no matter how many such switches appeared. However, if @code{%*} | |
35576 | appears somewhere in @code{X}, then @code{X} is substituted once | |
35577 | for each matching switch, with the @code{%*} replaced by the part of | |
35578 | that switch matching the @code{*}. | |
35579 | ||
35580 | If @code{%*} appears as the last part of a spec sequence then a space | |
35581 | is added after the end of the last substitution. If there is more | |
35582 | text in the sequence, however, then a space is not generated. This | |
35583 | allows the @code{%*} substitution to be used as part of a larger | |
35584 | string. For example, a spec string like this: | |
35585 | ||
35586 | @smallexample | |
35587 | %@{mcu=*:--script=%*/memory.ld@} | |
35588 | @end smallexample | |
35589 | ||
35590 | @noindent | |
35591 | when matching an option like @option{-mcu=newchip} produces: | |
35592 | ||
35593 | @smallexample | |
35594 | --script=newchip/memory.ld | |
35595 | @end smallexample | |
35596 | ||
35597 | @item %@{.S:X@} | |
35598 | Substitutes @code{X}, if processing a file with suffix @code{S}. | |
35599 | ||
35600 | @item %@{!.S:X@} | |
35601 | Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}. | |
35602 | ||
35603 | @item %@{,S:X@} | |
35604 | Substitutes @code{X}, if processing a file for language @code{S}. | |
35605 | ||
35606 | @item %@{!,S:X@} | |
35607 | Substitutes @code{X}, if not processing a file for language @code{S}. | |
35608 | ||
35609 | @item %@{S|P:X@} | |
35610 | Substitutes @code{X} if either @code{-S} or @code{-P} is given to | |
35611 | GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and | |
35612 | @code{*} sequences as well, although they have a stronger binding than | |
35613 | the @samp{|}. If @code{%*} appears in @code{X}, all of the | |
35614 | alternatives must be starred, and only the first matching alternative | |
35615 | is substituted. | |
35616 | ||
35617 | For example, a spec string like this: | |
35618 | ||
35619 | @smallexample | |
35620 | %@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@} | |
35621 | @end smallexample | |
35622 | ||
35623 | @noindent | |
35624 | outputs the following command-line options from the following input | |
35625 | command-line options: | |
35626 | ||
35627 | @smallexample | |
35628 | fred.c -foo -baz | |
35629 | jim.d -bar -boggle | |
35630 | -d fred.c -foo -baz -boggle | |
35631 | -d jim.d -bar -baz -boggle | |
35632 | @end smallexample | |
35633 | ||
35634 | @item %@{%:@var{function}(@var{args}):X@} | |
35635 | ||
35636 | Call function named @var{function} with args @var{args}. If the | |
35637 | function returns non-NULL, then @code{X} is substituted, if it returns | |
35638 | NULL, it isn't substituted. | |
35639 | ||
35640 | @item %@{S:X; T:Y; :D@} | |
35641 | ||
35642 | If @code{S} is given to GCC, substitutes @code{X}; else if @code{T} is | |
35643 | given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can | |
35644 | be as many clauses as you need. This may be combined with @code{.}, | |
35645 | @code{,}, @code{!}, @code{|}, and @code{*} as needed. | |
35646 | ||
35647 | ||
35648 | @end table | |
35649 | ||
35650 | The switch matching text @code{S} in a @samp{%@{S@}}, @samp{%@{S:X@}} | |
35651 | or similar construct can use a backslash to ignore the special meaning | |
35652 | of the character following it, thus allowing literal matching of a | |
35653 | character that is otherwise specially treated. For example, | |
35654 | @samp{%@{std=iso9899\:1999:X@}} substitutes @code{X} if the | |
35655 | @option{-std=iso9899:1999} option is given. | |
35656 | ||
35657 | The conditional text @code{X} in a @samp{%@{S:X@}} or similar | |
35658 | construct may contain other nested @samp{%} constructs or spaces, or | |
35659 | even newlines. They are processed as usual, as described above. | |
35660 | Trailing white space in @code{X} is ignored. White space may also | |
35661 | appear anywhere on the left side of the colon in these constructs, | |
35662 | except between @code{.} or @code{*} and the corresponding word. | |
35663 | ||
35664 | The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are | |
35665 | handled specifically in these constructs. If another value of | |
35666 | @option{-O} or the negated form of a @option{-f}, @option{-m}, or | |
35667 | @option{-W} switch is found later in the command line, the earlier | |
35668 | switch value is ignored, except with @{@code{S}*@} where @code{S} is | |
35669 | just one letter, which passes all matching options. | |
35670 | ||
35671 | The character @samp{|} at the beginning of the predicate text is used to | |
35672 | indicate that a command should be piped to the following command, but | |
35673 | only if @option{-pipe} is specified. | |
35674 | ||
35675 | It is built into GCC which switches take arguments and which do not. | |
35676 | (You might think it would be useful to generalize this to allow each | |
35677 | compiler's spec to say which switches take arguments. But this cannot | |
35678 | be done in a consistent fashion. GCC cannot even decide which input | |
35679 | files have been specified without knowing which switches take arguments, | |
35680 | and it must know which input files to compile in order to tell which | |
35681 | compilers to run). | |
35682 | ||
35683 | GCC also knows implicitly that arguments starting in @option{-l} are to be | |
35684 | treated as compiler output files, and passed to the linker in their | |
35685 | proper position among the other output files. | |
35686 | ||
35687 | @node Environment Variables | |
35688 | @section Environment Variables Affecting GCC | |
35689 | @cindex environment variables | |
35690 | ||
35691 | @c man begin ENVIRONMENT | |
35692 | This section describes several environment variables that affect how GCC | |
35693 | operates. Some of them work by specifying directories or prefixes to use | |
35694 | when searching for various kinds of files. Some are used to specify other | |
35695 | aspects of the compilation environment. | |
35696 | ||
35697 | Note that you can also specify places to search using options such as | |
35698 | @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These | |
35699 | take precedence over places specified using environment variables, which | |
35700 | in turn take precedence over those specified by the configuration of GCC@. | |
35701 | @xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint, | |
35702 | GNU Compiler Collection (GCC) Internals}. | |
35703 | ||
35704 | @table @env | |
f33d7a88 AA |
35705 | @vindex LANG |
35706 | @vindex LC_CTYPE | |
35707 | @c @vindex LC_COLLATE | |
35708 | @vindex LC_MESSAGES | |
35709 | @c @vindex LC_MONETARY | |
35710 | @c @vindex LC_NUMERIC | |
35711 | @c @vindex LC_TIME | |
35712 | @vindex LC_ALL | |
35713 | @cindex locale | |
d77de738 ML |
35714 | @item LANG |
35715 | @itemx LC_CTYPE | |
35716 | @c @itemx LC_COLLATE | |
35717 | @itemx LC_MESSAGES | |
35718 | @c @itemx LC_MONETARY | |
35719 | @c @itemx LC_NUMERIC | |
35720 | @c @itemx LC_TIME | |
35721 | @itemx LC_ALL | |
d77de738 ML |
35722 | These environment variables control the way that GCC uses |
35723 | localization information which allows GCC to work with different | |
35724 | national conventions. GCC inspects the locale categories | |
35725 | @env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do | |
35726 | so. These locale categories can be set to any value supported by your | |
35727 | installation. A typical value is @samp{en_GB.UTF-8} for English in the United | |
35728 | Kingdom encoded in UTF-8. | |
35729 | ||
35730 | The @env{LC_CTYPE} environment variable specifies character | |
35731 | classification. GCC uses it to determine the character boundaries in | |
35732 | a string; this is needed for some multibyte encodings that contain quote | |
35733 | and escape characters that are otherwise interpreted as a string | |
35734 | end or escape. | |
35735 | ||
35736 | The @env{LC_MESSAGES} environment variable specifies the language to | |
35737 | use in diagnostic messages. | |
35738 | ||
35739 | If the @env{LC_ALL} environment variable is set, it overrides the value | |
35740 | of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE} | |
35741 | and @env{LC_MESSAGES} default to the value of the @env{LANG} | |
35742 | environment variable. If none of these variables are set, GCC | |
35743 | defaults to traditional C English behavior. | |
35744 | ||
f33d7a88 | 35745 | @vindex TMPDIR |
d77de738 | 35746 | @item TMPDIR |
d77de738 ML |
35747 | If @env{TMPDIR} is set, it specifies the directory to use for temporary |
35748 | files. GCC uses temporary files to hold the output of one stage of | |
35749 | compilation which is to be used as input to the next stage: for example, | |
35750 | the output of the preprocessor, which is the input to the compiler | |
35751 | proper. | |
35752 | ||
f33d7a88 | 35753 | @vindex GCC_COMPARE_DEBUG |
d77de738 | 35754 | @item GCC_COMPARE_DEBUG |
d77de738 ML |
35755 | Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing |
35756 | @option{-fcompare-debug} to the compiler driver. See the documentation | |
35757 | of this option for more details. | |
35758 | ||
f33d7a88 | 35759 | @vindex GCC_EXEC_PREFIX |
d77de738 | 35760 | @item GCC_EXEC_PREFIX |
d77de738 ML |
35761 | If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the |
35762 | names of the subprograms executed by the compiler. No slash is added | |
35763 | when this prefix is combined with the name of a subprogram, but you can | |
35764 | specify a prefix that ends with a slash if you wish. | |
35765 | ||
35766 | If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out | |
35767 | an appropriate prefix to use based on the pathname it is invoked with. | |
35768 | ||
35769 | If GCC cannot find the subprogram using the specified prefix, it | |
35770 | tries looking in the usual places for the subprogram. | |
35771 | ||
35772 | The default value of @env{GCC_EXEC_PREFIX} is | |
35773 | @file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to | |
35774 | the installed compiler. In many cases @var{prefix} is the value | |
35775 | of @code{prefix} when you ran the @file{configure} script. | |
35776 | ||
35777 | Other prefixes specified with @option{-B} take precedence over this prefix. | |
35778 | ||
35779 | This prefix is also used for finding files such as @file{crt0.o} that are | |
35780 | used for linking. | |
35781 | ||
35782 | In addition, the prefix is used in an unusual way in finding the | |
35783 | directories to search for header files. For each of the standard | |
35784 | directories whose name normally begins with @samp{/usr/local/lib/gcc} | |
35785 | (more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries | |
35786 | replacing that beginning with the specified prefix to produce an | |
35787 | alternate directory name. Thus, with @option{-Bfoo/}, GCC searches | |
35788 | @file{foo/bar} just before it searches the standard directory | |
35789 | @file{/usr/local/lib/bar}. | |
35790 | If a standard directory begins with the configured | |
35791 | @var{prefix} then the value of @var{prefix} is replaced by | |
35792 | @env{GCC_EXEC_PREFIX} when looking for header files. | |
35793 | ||
f33d7a88 | 35794 | @vindex COMPILER_PATH |
d77de738 | 35795 | @item COMPILER_PATH |
d77de738 ML |
35796 | The value of @env{COMPILER_PATH} is a colon-separated list of |
35797 | directories, much like @env{PATH}. GCC tries the directories thus | |
35798 | specified when searching for subprograms, if it cannot find the | |
35799 | subprograms using @env{GCC_EXEC_PREFIX}. | |
35800 | ||
f33d7a88 | 35801 | @vindex LIBRARY_PATH |
d77de738 | 35802 | @item LIBRARY_PATH |
d77de738 ML |
35803 | The value of @env{LIBRARY_PATH} is a colon-separated list of |
35804 | directories, much like @env{PATH}. When configured as a native compiler, | |
35805 | GCC tries the directories thus specified when searching for special | |
35806 | linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking | |
35807 | using GCC also uses these directories when searching for ordinary | |
35808 | libraries for the @option{-l} option (but directories specified with | |
35809 | @option{-L} come first). | |
35810 | ||
f33d7a88 | 35811 | @vindex LANG |
d77de738 | 35812 | @cindex locale definition |
f33d7a88 | 35813 | @item LANG |
d77de738 ML |
35814 | This variable is used to pass locale information to the compiler. One way in |
35815 | which this information is used is to determine the character set to be used | |
35816 | when character literals, string literals and comments are parsed in C and C++. | |
35817 | When the compiler is configured to allow multibyte characters, | |
35818 | the following values for @env{LANG} are recognized: | |
35819 | ||
35820 | @table @samp | |
35821 | @item C-JIS | |
35822 | Recognize JIS characters. | |
35823 | @item C-SJIS | |
35824 | Recognize SJIS characters. | |
35825 | @item C-EUCJP | |
35826 | Recognize EUCJP characters. | |
35827 | @end table | |
35828 | ||
35829 | If @env{LANG} is not defined, or if it has some other value, then the | |
35830 | compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to | |
35831 | recognize and translate multibyte characters. | |
35832 | ||
f33d7a88 | 35833 | @vindex GCC_EXTRA_DIAGNOSTIC_OUTPUT |
d77de738 | 35834 | @item GCC_EXTRA_DIAGNOSTIC_OUTPUT |
d77de738 ML |
35835 | If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values, |
35836 | then additional text will be emitted to stderr when fix-it hints are | |
35837 | emitted. @option{-fdiagnostics-parseable-fixits} and | |
35838 | @option{-fno-diagnostics-parseable-fixits} take precedence over this | |
35839 | environment variable. | |
35840 | ||
35841 | @table @samp | |
35842 | @item fixits-v1 | |
35843 | Emit parseable fix-it hints, equivalent to | |
35844 | @option{-fdiagnostics-parseable-fixits}. In particular, columns are | |
35845 | expressed as a count of bytes, starting at byte 1 for the initial column. | |
35846 | ||
35847 | @item fixits-v2 | |
35848 | As @code{fixits-v1}, but columns are expressed as display columns, | |
35849 | as per @option{-fdiagnostics-column-unit=display}. | |
35850 | @end table | |
35851 | ||
35852 | @end table | |
35853 | ||
35854 | @noindent | |
35855 | Some additional environment variables affect the behavior of the | |
35856 | preprocessor. | |
35857 | ||
35858 | @include cppenv.texi | |
35859 | ||
35860 | @c man end | |
35861 | ||
35862 | @node Precompiled Headers | |
35863 | @section Using Precompiled Headers | |
35864 | @cindex precompiled headers | |
35865 | @cindex speed of compilation | |
35866 | ||
35867 | Often large projects have many header files that are included in every | |
35868 | source file. The time the compiler takes to process these header files | |
35869 | over and over again can account for nearly all of the time required to | |
35870 | build the project. To make builds faster, GCC allows you to | |
35871 | @dfn{precompile} a header file. | |
35872 | ||
35873 | To create a precompiled header file, simply compile it as you would any | |
35874 | other file, if necessary using the @option{-x} option to make the driver | |
35875 | treat it as a C or C++ header file. You may want to use a | |
35876 | tool like @command{make} to keep the precompiled header up-to-date when | |
35877 | the headers it contains change. | |
35878 | ||
35879 | A precompiled header file is searched for when @code{#include} is | |
35880 | seen in the compilation. As it searches for the included file | |
35881 | (@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the | |
35882 | compiler looks for a precompiled header in each directory just before it | |
35883 | looks for the include file in that directory. The name searched for is | |
35884 | the name specified in the @code{#include} with @samp{.gch} appended. If | |
35885 | the precompiled header file cannot be used, it is ignored. | |
35886 | ||
35887 | For instance, if you have @code{#include "all.h"}, and you have | |
35888 | @file{all.h.gch} in the same directory as @file{all.h}, then the | |
35889 | precompiled header file is used if possible, and the original | |
35890 | header is used otherwise. | |
35891 | ||
35892 | Alternatively, you might decide to put the precompiled header file in a | |
35893 | directory and use @option{-I} to ensure that directory is searched | |
35894 | before (or instead of) the directory containing the original header. | |
35895 | Then, if you want to check that the precompiled header file is always | |
35896 | used, you can put a file of the same name as the original header in this | |
35897 | directory containing an @code{#error} command. | |
35898 | ||
35899 | This also works with @option{-include}. So yet another way to use | |
35900 | precompiled headers, good for projects not designed with precompiled | |
35901 | header files in mind, is to simply take most of the header files used by | |
35902 | a project, include them from another header file, precompile that header | |
35903 | file, and @option{-include} the precompiled header. If the header files | |
35904 | have guards against multiple inclusion, they are skipped because | |
35905 | they've already been included (in the precompiled header). | |
35906 | ||
35907 | If you need to precompile the same header file for different | |
35908 | languages, targets, or compiler options, you can instead make a | |
35909 | @emph{directory} named like @file{all.h.gch}, and put each precompiled | |
35910 | header in the directory, perhaps using @option{-o}. It doesn't matter | |
35911 | what you call the files in the directory; every precompiled header in | |
35912 | the directory is considered. The first precompiled header | |
35913 | encountered in the directory that is valid for this compilation is | |
35914 | used; they're searched in no particular order. | |
35915 | ||
35916 | There are many other possibilities, limited only by your imagination, | |
35917 | good sense, and the constraints of your build system. | |
35918 | ||
35919 | A precompiled header file can be used only when these conditions apply: | |
35920 | ||
35921 | @itemize | |
35922 | @item | |
35923 | Only one precompiled header can be used in a particular compilation. | |
35924 | ||
35925 | @item | |
35926 | A precompiled header cannot be used once the first C token is seen. You | |
35927 | can have preprocessor directives before a precompiled header; you cannot | |
35928 | include a precompiled header from inside another header. | |
35929 | ||
35930 | @item | |
35931 | The precompiled header file must be produced for the same language as | |
35932 | the current compilation. You cannot use a C precompiled header for a C++ | |
35933 | compilation. | |
35934 | ||
35935 | @item | |
35936 | The precompiled header file must have been produced by the same compiler | |
35937 | binary as the current compilation is using. | |
35938 | ||
35939 | @item | |
35940 | Any macros defined before the precompiled header is included must | |
35941 | either be defined in the same way as when the precompiled header was | |
35942 | generated, or must not affect the precompiled header, which usually | |
35943 | means that they don't appear in the precompiled header at all. | |
35944 | ||
35945 | The @option{-D} option is one way to define a macro before a | |
35946 | precompiled header is included; using a @code{#define} can also do it. | |
35947 | There are also some options that define macros implicitly, like | |
35948 | @option{-O} and @option{-Wdeprecated}; the same rule applies to macros | |
35949 | defined this way. | |
35950 | ||
35951 | @item If debugging information is output when using the precompiled | |
35952 | header, using @option{-g} or similar, the same kind of debugging information | |
35953 | must have been output when building the precompiled header. However, | |
35954 | a precompiled header built using @option{-g} can be used in a compilation | |
35955 | when no debugging information is being output. | |
35956 | ||
35957 | @item The same @option{-m} options must generally be used when building | |
35958 | and using the precompiled header. @xref{Submodel Options}, | |
35959 | for any cases where this rule is relaxed. | |
35960 | ||
35961 | @item Each of the following options must be the same when building and using | |
35962 | the precompiled header: | |
35963 | ||
35964 | @gccoptlist{-fexceptions} | |
35965 | ||
35966 | @item | |
35967 | Some other command-line options starting with @option{-f}, | |
35968 | @option{-p}, or @option{-O} must be defined in the same way as when | |
35969 | the precompiled header was generated. At present, it's not clear | |
35970 | which options are safe to change and which are not; the safest choice | |
35971 | is to use exactly the same options when generating and using the | |
35972 | precompiled header. The following are known to be safe: | |
35973 | ||
43b72ede AA |
35974 | @gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock |
35975 | -fsched-spec -fsched-spec-load -fsched-spec-load-dangerous | |
35976 | -fsched-verbose=@var{number} -fschedule-insns -fvisibility= | |
d77de738 ML |
35977 | -pedantic-errors} |
35978 | ||
35979 | @item Address space layout randomization (ASLR) can lead to not binary identical | |
35980 | PCH files. If you rely on stable PCH file contents disable ASLR when generating | |
35981 | PCH files. | |
35982 | ||
35983 | @end itemize | |
35984 | ||
35985 | For all of these except the last, the compiler automatically | |
35986 | ignores the precompiled header if the conditions aren't met. If you | |
35987 | find an option combination that doesn't work and doesn't cause the | |
35988 | precompiled header to be ignored, please consider filing a bug report, | |
35989 | see @ref{Bugs}. | |
35990 | ||
35991 | If you do use differing options when generating and using the | |
35992 | precompiled header, the actual behavior is a mixture of the | |
35993 | behavior for the options. For instance, if you use @option{-g} to | |
35994 | generate the precompiled header but not when using it, you may or may | |
35995 | not get debugging information for routines in the precompiled header. | |
35996 | ||
35997 | @node C++ Modules | |
35998 | @section C++ Modules | |
35999 | @cindex speed of compilation | |
36000 | ||
36001 | Modules are a C++20 language feature. As the name suggests, they | |
36002 | provides a modular compilation system, intending to provide both | |
36003 | faster builds and better library isolation. The ``Merging Modules'' | |
36004 | paper @uref{https://wg21.link/p1103}, provides the easiest to read set | |
36005 | of changes to the standard, although it does not capture later | |
36006 | changes. | |
36007 | ||
36008 | @emph{G++'s modules support is not complete.} Other than bugs, the | |
36009 | known missing pieces are: | |
36010 | ||
36011 | @table @emph | |
36012 | ||
36013 | @item Private Module Fragment | |
36014 | The Private Module Fragment is recognized, but an error is emitted. | |
36015 | ||
36016 | @item Partition definition visibility rules | |
36017 | Entities may be defined in implementation partitions, and those | |
36018 | definitions are not available outside of the module. This is not | |
36019 | implemented, and the definitions are available to extra-module use. | |
36020 | ||
36021 | @item Textual merging of reachable GM entities | |
36022 | Entities may be multiply defined across different header-units. | |
36023 | These must be de-duplicated, and this is implemented across imports, | |
36024 | or when an import redefines a textually-defined entity. However the | |
36025 | reverse is not implemented---textually redefining an entity that has | |
36026 | been defined in an imported header-unit. A redefinition error is | |
36027 | emitted. | |
36028 | ||
36029 | @item Translation-Unit local referencing rules | |
36030 | Papers p1815 (@uref{https://wg21.link/p1815}) and p2003 | |
36031 | (@uref{https://wg21.link/p2003}) add limitations on which entities an | |
36032 | exported region may reference (for instance, the entities an exported | |
36033 | template definition may reference). These are not fully implemented. | |
36034 | ||
36035 | @item Standard Library Header Units | |
36036 | The Standard Library is not provided as importable header units. If | |
36037 | you want to import such units, you must explicitly build them first. | |
36038 | If you do not do this with care, you may have multiple declarations, | |
36039 | which the module machinery must merge---compiler resource usage can be | |
36040 | affected by how you partition header files into header units. | |
36041 | ||
36042 | @end table | |
36043 | ||
36044 | Modular compilation is @emph{not} enabled with just the | |
36045 | @option{-std=c++20} option. You must explicitly enable it with the | |
36046 | @option{-fmodules-ts} option. It is independent of the language | |
36047 | version selected, although in pre-C++20 versions, it is of course an | |
36048 | extension. | |
36049 | ||
36050 | No new source file suffixes are required or supported. If you wish to | |
36051 | use a non-standard suffix (@pxref{Overall Options}), you also need | |
36052 | to provide a @option{-x c++} option too.@footnote{Some users like to | |
36053 | distinguish module interface files with a new suffix, such as naming | |
36054 | the source @code{module.cppm}, which involves | |
36055 | teaching all tools about the new suffix. A different scheme, such as | |
36056 | naming @code{module-m.cpp} would be less invasive.} | |
36057 | ||
36058 | Compiling a module interface unit produces an additional output (to | |
36059 | the assembly or object file), called a Compiled Module Interface | |
36060 | (CMI). This encodes the exported declarations of the module. | |
36061 | Importing a module reads in the CMI. The import graph is a Directed | |
36062 | Acyclic Graph (DAG). You must build imports before the importer. | |
36063 | ||
36064 | Header files may themselves be compiled to header units, which are a | |
36065 | transitional ability aiming at faster compilation. The | |
36066 | @option{-fmodule-header} option is used to enable this, and implies | |
36067 | the @option{-fmodules-ts} option. These CMIs are named by the fully | |
36068 | resolved underlying header file, and thus may be a complete pathname | |
36069 | containing subdirectories. If the header file is found at an absolute | |
36070 | pathname, the CMI location is still relative to a CMI root directory. | |
36071 | ||
36072 | As header files often have no suffix, you commonly have to specify a | |
36073 | @option{-x} option to tell the compiler the source is a header file. | |
36074 | You may use @option{-x c++-header}, @option{-x c++-user-header} or | |
36075 | @option{-x c++-system-header}. When used in conjunction with | |
36076 | @option{-fmodules-ts}, these all imply an appropriate | |
36077 | @option{-fmodule-header} option. The latter two variants use the | |
36078 | user or system include path to search for the file specified. This | |
36079 | allows you to, for instance, compile standard library header files as | |
36080 | header units, without needing to know exactly where they are | |
36081 | installed. Specifying the language as one of these variants also | |
36082 | inhibits output of the object file, as header files have no associated | |
36083 | object file. | |
36084 | ||
36085 | The @option{-fmodule-only} option disables generation of the | |
36086 | associated object file for compiling a module interface. Only the CMI | |
36087 | is generated. This option is implied when using the | |
36088 | @option{-fmodule-header} option. | |
36089 | ||
36090 | The @option{-flang-info-include-translate} and | |
36091 | @option{-flang-info-include-translate-not} options notes whether | |
36092 | include translation occurs or not. With no argument, the first will | |
36093 | note all include translation. The second will note all | |
36094 | non-translations of include files not known to intentionally be | |
36095 | textual. With an argument, queries about include translation of a | |
36096 | header files with that particular trailing pathname are noted. You | |
36097 | may repeat this form to cover several different header files. This | |
36098 | option may be helpful in determining whether include translation is | |
36099 | happening---if it is working correctly, it behaves as if it isn't | |
36100 | there at all. | |
36101 | ||
36102 | The @option{-flang-info-module-cmi} option can be used to determine | |
36103 | where the compiler is reading a CMI from. Without the option, the | |
36104 | compiler is silent when such a read is successful. This option has an | |
36105 | optional argument, which will restrict the notification to just the | |
36106 | set of named modules or header units specified. | |
36107 | ||
36108 | The @option{-Winvalid-imported-macros} option causes all imported macros | |
36109 | to be resolved at the end of compilation. Without this, imported | |
36110 | macros are only resolved when expanded or (re)defined. This option | |
36111 | detects conflicting import definitions for all macros. | |
36112 | ||
36113 | For details of the @option{-fmodule-mapper} family of options, | |
36114 | @pxref{C++ Module Mapper}. | |
36115 | ||
36116 | @menu | |
36117 | * C++ Module Mapper:: Module Mapper | |
36118 | * C++ Module Preprocessing:: Module Preprocessing | |
36119 | * C++ Compiled Module Interface:: Compiled Module Interface | |
36120 | @end menu | |
36121 | ||
36122 | @node C++ Module Mapper | |
36123 | @subsection Module Mapper | |
36124 | @cindex C++ Module Mapper | |
36125 | ||
36126 | A module mapper provides a server or file that the compiler queries to | |
36127 | determine the mapping between module names and CMI files. It is also | |
36128 | used to build CMIs on demand. @emph{Mapper functionality is in its | |
36129 | infancy and is intended for experimentation with build system | |
36130 | interactions.} | |
36131 | ||
36132 | You can specify a mapper with the @option{-fmodule-mapper=@var{val}} | |
36133 | option or @env{CXX_MODULE_MAPPER} environment variable. The value may | |
36134 | have one of the following forms: | |
36135 | ||
36136 | @table @gcctabopt | |
36137 | ||
36138 | @item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]} | |
36139 | An optional hostname and a numeric port number to connect to. If the | |
36140 | hostname is omitted, the loopback address is used. If the hostname | |
36141 | corresponds to multiple IPV6 addresses, these are tried in turn, until | |
36142 | one is successful. If your host lacks IPv6, this form is | |
36143 | non-functional. If you must use IPv4 use | |
36144 | @option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}. | |
36145 | ||
36146 | @item =@var{socket}@r{[}?@var{ident}@r{]} | |
36147 | A local domain socket. If your host lacks local domain sockets, this | |
36148 | form is non-functional. | |
36149 | ||
36150 | @item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]} | |
36151 | A program to spawn, and communicate with on its stdin/stdout streams. | |
36152 | Your @var{PATH} environment variable is searched for the program. | |
36153 | Arguments are separated by space characters, (it is not possible for | |
36154 | one of the arguments delivered to the program to contain a space). An | |
36155 | exception is if @var{program} begins with @@. In that case | |
36156 | @var{program} (sans @@) is looked for in the compiler's internal | |
36157 | binary directory. Thus the sample mapper-server can be specified | |
36158 | with @code{@@g++-mapper-server}. | |
36159 | ||
36160 | @item <>@r{[}?@var{ident}@r{]} | |
36161 | @item <>@var{inout}@r{[}?@var{ident}@r{]} | |
36162 | @item <@var{in}>@var{out}@r{[}?@var{ident}@r{]} | |
36163 | Named pipes or file descriptors to communicate over. The first form, | |
36164 | @option{<>}, communicates over stdin and stdout. The other forms | |
36165 | allow you to specify a file descriptor or name a pipe. A numeric value | |
36166 | is interpreted as a file descriptor, otherwise named pipe is opened. | |
36167 | The second form specifies a bidirectional pipe and the last form | |
36168 | allows specifying two independent pipes. Using file descriptors | |
36169 | directly in this manner is fragile in general, as it can require the | |
36170 | cooperation of intermediate processes. In particular using stdin & | |
36171 | stdout is fraught with danger as other compiler options might also | |
36172 | cause the compiler to read stdin or write stdout, and it can have | |
36173 | unfortunate interactions with signal delivery from the terminal. | |
36174 | ||
36175 | @item @var{file}@r{[}?@var{ident}@r{]} | |
36176 | A mapping file consisting of space-separated module-name, filename | |
36177 | pairs, one per line. Only the mappings for the direct imports and any | |
36178 | module export name need be provided. If other mappings are provided, | |
36179 | they override those stored in any imported CMI files. A repository | |
36180 | root may be specified in the mapping file by using @samp{$root} as the | |
36181 | module name in the first active line. Use of this option will disable | |
36182 | any default module->CMI name mapping. | |
36183 | ||
36184 | @end table | |
36185 | ||
36186 | As shown, an optional @var{ident} may suffix the first word of the | |
36187 | option, indicated by a @samp{?} prefix. The value is used in the | |
36188 | initial handshake with the module server, or to specify a prefix on | |
36189 | mapping file lines. In the server case, the main source file name is | |
36190 | used if no @var{ident} is specified. In the file case, all non-blank | |
36191 | lines are significant, unless a value is specified, in which case only | |
36192 | lines beginning with @var{ident} are significant. The @var{ident} | |
36193 | must be separated by whitespace from the module name. Be aware that | |
36194 | @samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often | |
36195 | significant to the shell, and therefore may need quoting. | |
36196 | ||
36197 | The mapper is connected to or loaded lazily, when the first module | |
36198 | mapping is required. The networking protocols are only supported on | |
36199 | hosts that provide networking. If no mapper is specified a default is | |
36200 | provided. | |
36201 | ||
36202 | A project-specific mapper is expected to be provided by the build | |
36203 | system that invokes the compiler. It is not expected that a | |
36204 | general-purpose server is provided for all compilations. As such, the | |
36205 | server will know the build configuration, the compiler it invoked, and | |
36206 | the environment (such as working directory) in which that is | |
36207 | operating. As it may parallelize builds, several compilations may | |
36208 | connect to the same socket. | |
36209 | ||
36210 | The default mapper generates CMI files in a @samp{gcm.cache} | |
36211 | directory. CMI files have a @samp{.gcm} suffix. The module unit name | |
36212 | is used directly to provide the basename. Header units construct a | |
36213 | relative path using the underlying header file name. If the path is | |
36214 | already relative, a @samp{,} directory is prepended. Internal | |
36215 | @samp{..} components are translated to @samp{,,}. No attempt is made | |
36216 | to canonicalize these filenames beyond that done by the preprocessor's | |
36217 | include search algorithm, as in general it is ambiguous when symbolic | |
36218 | links are present. | |
36219 | ||
36220 | The mapper protocol was published as ``A Module Mapper'' | |
36221 | @uref{https://wg21.link/p1184}. The implementation is provided by | |
36222 | @command{libcody}, @uref{https://github.com/urnathan/libcody}, | |
36223 | which specifies the canonical protocol definition. A proof of concept | |
36224 | server implementation embedded in @command{make} was described in | |
36225 | ''Make Me A Module'', @uref{https://wg21.link/p1602}. | |
36226 | ||
36227 | @node C++ Module Preprocessing | |
36228 | @subsection Module Preprocessing | |
36229 | @cindex C++ Module Preprocessing | |
36230 | ||
36231 | Modules affect preprocessing because of header units and include | |
36232 | translation. Some uses of the preprocessor as a separate step either | |
36233 | do not produce a correct output, or require CMIs to be available. | |
36234 | ||
36235 | Header units import macros. These macros can affect later conditional | |
36236 | inclusion, which therefore can cascade to differing import sets. When | |
36237 | preprocessing, it is necessary to load the CMI. If a header unit is | |
36238 | unavailable, the preprocessor issues a warning and continue (when | |
36239 | not just preprocessing, an error is emitted). Detecting such imports | |
36240 | requires preprocessor tokenization of the input stream to phase 4 | |
36241 | (macro expansion). | |
36242 | ||
36243 | Include translation converts @code{#include}, @code{#include_next} and | |
36244 | @code{#import} directives to internal @code{import} declarations. | |
36245 | Whether a particular directive is translated is controlled by the | |
36246 | module mapper. Header unit names are canonicalized during | |
36247 | preprocessing. | |
36248 | ||
36249 | Dependency information can be emitted for macro import, extending the | |
36250 | functionality of @option{-MD} and @option{-MMD} options. Detection of | |
36251 | import declarations also requires phase 4 preprocessing, and thus | |
36252 | requires full preprocessing (or compilation). | |
36253 | ||
36254 | The @option{-M}, @option{-MM} and @option{-E -fdirectives-only} options halt | |
36255 | preprocessing before phase 4. | |
36256 | ||
36257 | The @option{-save-temps} option uses @option{-fdirectives-only} for | |
36258 | preprocessing, and preserve the macro definitions in the preprocessed | |
36259 | output. Usually you also want to use this option when explicitly | |
36260 | preprocessing a header-unit, or consuming such preprocessed output: | |
36261 | ||
36262 | @smallexample | |
36263 | g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii | |
36264 | g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii | |
36265 | @end smallexample | |
36266 | ||
36267 | @node C++ Compiled Module Interface | |
36268 | @subsection Compiled Module Interface | |
36269 | @cindex C++ Compiled Module Interface | |
36270 | ||
36271 | CMIs are an additional artifact when compiling named module | |
36272 | interfaces, partitions or header units. These are read when | |
36273 | importing. CMI contents are implementation-specific, and in GCC's | |
36274 | case tied to the compiler version. Consider them a rebuildable cache | |
36275 | artifact, not a distributable object. | |
36276 | ||
36277 | When creating an output CMI, any missing directory components are | |
36278 | created in a manner that is safe for concurrent builds creating | |
36279 | multiple, different, CMIs within a common subdirectory tree. | |
36280 | ||
36281 | CMI contents are written to a temporary file, which is then atomically | |
36282 | renamed. Observers either see old contents (if there is an | |
36283 | existing file), or complete new contents. They do not observe the | |
36284 | CMI during its creation. This is unlike object file writing, which | |
36285 | may be observed by an external process. | |
36286 | ||
36287 | CMIs are read in lazily, if the host OS provides @code{mmap} | |
36288 | functionality. Generally blocks are read when name lookup or template | |
36289 | instantiation occurs. To inhibit this, the @option{-fno-module-lazy} | |
36290 | option may be used. | |
36291 | ||
36292 | The @option{--param lazy-modules=@var{n}} parameter controls the limit | |
36293 | on the number of concurrently open module files during lazy loading. | |
36294 | Should more modules be imported, an LRU algorithm is used to determine | |
36295 | which files to close---until that file is needed again. This limit | |
36296 | may be exceeded with deep module dependency hierarchies. With large | |
36297 | code bases there may be more imports than the process limit of file | |
36298 | descriptors. By default, the limit is a few less than the per-process | |
36299 | file descriptor hard limit, if that is determinable.@footnote{Where | |
36300 | applicable the soft limit is incremented as needed towards the hard limit.} | |
36301 | ||
36302 | GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism. | |
36303 | You may use @command{readelf} to inspect them, although section | |
36304 | contents are largely undecipherable. There is a section named | |
36305 | @code{.gnu.c++.README}, which contains human-readable text. Other | |
36306 | than the first line, each line consists of @code{@var{tag}: @code{value}} | |
36307 | tuples. | |
36308 | ||
36309 | @smallexample | |
36310 | > @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm} | |
36311 | ||
36312 | String dump of section '.gnu.c++.README': | |
36313 | [ 0] GNU C++ primary module interface | |
36314 | [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454] | |
36315 | [ 6f] version: 2020/11/16-04:54 | |
36316 | [ 89] module: foo | |
36317 | [ 95] source: c_b.ii | |
36318 | [ a4] dialect: C++20/coroutines | |
36319 | [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc | |
36320 | [ ee] repository: gcm.cache | |
36321 | [ 104] buildtime: 2020/11/16 15:03:21 UTC | |
36322 | [ 127] localtime: 2020/11/16 07:03:21 PST | |
36323 | [ 14a] export: foo:part1 foo-part1.gcm | |
36324 | @end smallexample | |
36325 | ||
36326 | Amongst other things, this lists the source that was built, C++ | |
36327 | dialect used and imports of the module.@footnote{The precise contents | |
36328 | of this output may change.} The timestamp is the same value as that | |
36329 | provided by the @code{__DATE__} & @code{__TIME__} macros, and may be | |
36330 | explicitly specified with the environment variable | |
36331 | @code{SOURCE_DATE_EPOCH}. For further details | |
36332 | @pxref{Environment Variables}. | |
36333 | ||
36334 | A set of related CMIs may be copied, provided the relative pathnames | |
36335 | are preserved. | |
36336 | ||
36337 | The @code{.gnu.c++.README} contents do not affect CMI integrity, and | |
36338 | it may be removed or altered. The section numbering of the sections | |
36339 | whose names do not begin with @code{.gnu.c++.}, or are not the string | |
36340 | section is significant and must not be altered. |