]>
Commit | Line | Data |
---|---|---|
83ffe9cd | 1 | @c Copyright (C) 1988-2023 Free Software Foundation, Inc. |
d77de738 ML |
2 | @c This is part of the GCC manual. |
3 | @c For copying conditions, see the file gcc.texi. | |
4 | ||
5 | @ignore | |
6 | @c man begin INCLUDE | |
7 | @include gcc-vers.texi | |
8 | @c man end | |
9 | ||
10 | @c man begin COPYRIGHT | |
74d5206f | 11 | Copyright @copyright{} 1988-2023 Free Software Foundation, Inc. |
d77de738 ML |
12 | |
13 | Permission is granted to copy, distribute and/or modify this document | |
14 | under the terms of the GNU Free Documentation License, Version 1.3 or | |
15 | any later version published by the Free Software Foundation; with the | |
16 | Invariant Sections being ``GNU General Public License'' and ``Funding | |
17 | Free Software'', the Front-Cover texts being (a) (see below), and with | |
18 | the Back-Cover Texts being (b) (see below). A copy of the license is | |
19 | included in the gfdl(7) man page. | |
20 | ||
21 | (a) The FSF's Front-Cover Text is: | |
22 | ||
23 | A GNU Manual | |
24 | ||
25 | (b) The FSF's Back-Cover Text is: | |
26 | ||
27 | You have freedom to copy and modify this GNU Manual, like GNU | |
28 | software. Copies published by the Free Software Foundation raise | |
29 | funds for GNU development. | |
30 | @c man end | |
31 | @c Set file name and title for the man page. | |
32 | @setfilename gcc | |
33 | @settitle GNU project C and C++ compiler | |
34 | @c man begin SYNOPSIS | |
35 | gcc [@option{-c}|@option{-S}|@option{-E}] [@option{-std=}@var{standard}] | |
36 | [@option{-g}] [@option{-pg}] [@option{-O}@var{level}] | |
37 | [@option{-W}@var{warn}@dots{}] [@option{-Wpedantic}] | |
38 | [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}] | |
39 | [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}] | |
40 | [@option{-f}@var{option}@dots{}] [@option{-m}@var{machine-option}@dots{}] | |
41 | [@option{-o} @var{outfile}] [@@@var{file}] @var{infile}@dots{} | |
42 | ||
43 | Only the most useful options are listed here; see below for the | |
44 | remainder. @command{g++} accepts mostly the same options as @command{gcc}. | |
45 | @c man end | |
46 | @c man begin SEEALSO | |
47 | gpl(7), gfdl(7), fsf-funding(7), | |
48 | cpp(1), gcov(1), as(1), ld(1), gdb(1) | |
49 | and the Info entries for @file{gcc}, @file{cpp}, @file{as}, | |
50 | @file{ld}, @file{binutils} and @file{gdb}. | |
51 | @c man end | |
52 | @c man begin BUGS | |
53 | For instructions on reporting bugs, see | |
54 | @w{@value{BUGURL}}. | |
55 | @c man end | |
56 | @c man begin AUTHOR | |
57 | See the Info entry for @command{gcc}, or | |
58 | @w{@uref{https://gcc.gnu.org/onlinedocs/gcc/Contributors.html}}, | |
59 | for contributors to GCC@. | |
60 | @c man end | |
61 | @end ignore | |
62 | ||
63 | @node Invoking GCC | |
64 | @chapter GCC Command Options | |
65 | @cindex GCC command options | |
66 | @cindex command options | |
67 | @cindex options, GCC command | |
68 | ||
69 | @c man begin DESCRIPTION | |
70 | When you invoke GCC, it normally does preprocessing, compilation, | |
71 | assembly and linking. The ``overall options'' allow you to stop this | |
72 | process at an intermediate stage. For example, the @option{-c} option | |
73 | says not to run the linker. Then the output consists of object files | |
74 | output by the assembler. | |
75 | @xref{Overall Options,,Options Controlling the Kind of Output}. | |
76 | ||
77 | Other options are passed on to one or more stages of processing. Some options | |
78 | control the preprocessor and others the compiler itself. Yet other | |
79 | options control the assembler and linker; most of these are not | |
80 | documented here, since you rarely need to use any of them. | |
81 | ||
82 | @cindex C compilation options | |
83 | Most of the command-line options that you can use with GCC are useful | |
84 | for C programs; when an option is only useful with another language | |
85 | (usually C++), the explanation says so explicitly. If the description | |
86 | for a particular option does not mention a source language, you can use | |
87 | that option with all supported languages. | |
88 | ||
89 | @cindex cross compiling | |
90 | @cindex specifying machine version | |
91 | @cindex specifying compiler version and target machine | |
92 | @cindex compiler version, specifying | |
93 | @cindex target machine, specifying | |
94 | The usual way to run GCC is to run the executable called @command{gcc}, or | |
95 | @command{@var{machine}-gcc} when cross-compiling, or | |
96 | @command{@var{machine}-gcc-@var{version}} to run a specific version of GCC. | |
97 | When you compile C++ programs, you should invoke GCC as @command{g++} | |
98 | instead. @xref{Invoking G++,,Compiling C++ Programs}, | |
99 | for information about the differences in behavior between @command{gcc} | |
100 | and @command{g++} when compiling C++ programs. | |
101 | ||
102 | @cindex grouping options | |
103 | @cindex options, grouping | |
104 | The @command{gcc} program accepts options and file names as operands. Many | |
105 | options have multi-letter names; therefore multiple single-letter options | |
106 | may @emph{not} be grouped: @option{-dv} is very different from @w{@samp{-d | |
107 | -v}}. | |
108 | ||
109 | @cindex order of options | |
110 | @cindex options, order | |
111 | You can mix options and other arguments. For the most part, the order | |
112 | you use doesn't matter. Order does matter when you use several | |
113 | options of the same kind; for example, if you specify @option{-L} more | |
114 | than once, the directories are searched in the order specified. Also, | |
115 | the placement of the @option{-l} option is significant. | |
116 | ||
117 | Many options have long names starting with @samp{-f} or with | |
118 | @samp{-W}---for example, | |
119 | @option{-fmove-loop-invariants}, @option{-Wformat} and so on. Most of | |
120 | these have both positive and negative forms; the negative form of | |
121 | @option{-ffoo} is @option{-fno-foo}. This manual documents | |
122 | only one of these two forms, whichever one is not the default. | |
123 | ||
124 | Some options take one or more arguments typically separated either | |
125 | by a space or by the equals sign (@samp{=}) from the option name. | |
126 | Unless documented otherwise, an argument can be either numeric or | |
127 | a string. Numeric arguments must typically be small unsigned decimal | |
128 | or hexadecimal integers. Hexadecimal arguments must begin with | |
129 | the @samp{0x} prefix. Arguments to options that specify a size | |
130 | threshold of some sort may be arbitrarily large decimal or hexadecimal | |
131 | integers followed by a byte size suffix designating a multiple of bytes | |
132 | such as @code{kB} and @code{KiB} for kilobyte and kibibyte, respectively, | |
133 | @code{MB} and @code{MiB} for megabyte and mebibyte, @code{GB} and | |
134 | @code{GiB} for gigabyte and gigibyte, and so on. Such arguments are | |
135 | designated by @var{byte-size} in the following text. Refer to the NIST, | |
136 | IEC, and other relevant national and international standards for the full | |
137 | listing and explanation of the binary and decimal byte size prefixes. | |
138 | ||
139 | @c man end | |
140 | ||
141 | @xref{Option Index}, for an index to GCC's options. | |
142 | ||
143 | @menu | |
144 | * Option Summary:: Brief list of all options, without explanations. | |
145 | * Overall Options:: Controlling the kind of output: | |
146 | an executable, object files, assembler files, | |
147 | or preprocessed source. | |
148 | * Invoking G++:: Compiling C++ programs. | |
149 | * C Dialect Options:: Controlling the variant of C language compiled. | |
150 | * C++ Dialect Options:: Variations on C++. | |
151 | * Objective-C and Objective-C++ Dialect Options:: Variations on Objective-C | |
152 | and Objective-C++. | |
153 | * Diagnostic Message Formatting Options:: Controlling how diagnostics should | |
154 | be formatted. | |
155 | * Warning Options:: How picky should the compiler be? | |
156 | * Static Analyzer Options:: More expensive warnings. | |
157 | * Debugging Options:: Producing debuggable code. | |
158 | * Optimize Options:: How much optimization? | |
159 | * Instrumentation Options:: Enabling profiling and extra run-time error checking. | |
160 | * Preprocessor Options:: Controlling header files and macro definitions. | |
161 | Also, getting dependency information for Make. | |
162 | * Assembler Options:: Passing options to the assembler. | |
163 | * Link Options:: Specifying libraries and so on. | |
164 | * Directory Options:: Where to find header files and libraries. | |
165 | Where to find the compiler executable files. | |
166 | * Code Gen Options:: Specifying conventions for function calls, data layout | |
167 | and register usage. | |
168 | * Developer Options:: Printing GCC configuration info, statistics, and | |
169 | debugging dumps. | |
170 | * Submodel Options:: Target-specific options, such as compiling for a | |
171 | specific processor variant. | |
172 | * Spec Files:: How to pass switches to sub-processes. | |
173 | * Environment Variables:: Env vars that affect GCC. | |
174 | * Precompiled Headers:: Compiling a header once, and using it many times. | |
175 | * C++ Modules:: Experimental C++20 module system. | |
176 | @end menu | |
177 | ||
178 | @c man begin OPTIONS | |
179 | ||
180 | @node Option Summary | |
181 | @section Option Summary | |
182 | ||
183 | Here is a summary of all the options, grouped by type. Explanations are | |
184 | in the following sections. | |
185 | ||
186 | @table @emph | |
187 | @item Overall Options | |
188 | @xref{Overall Options,,Options Controlling the Kind of Output}. | |
43b72ede AA |
189 | @gccoptlist{-c -S -E -o @var{file} |
190 | -dumpbase @var{dumpbase} -dumpbase-ext @var{auxdropsuf} | |
191 | -dumpdir @var{dumppfx} -x @var{language} | |
192 | -v -### --help@r{[}=@var{class}@r{[},@dots{}@r{]]} --target-help --version | |
193 | -pass-exit-codes -pipe -specs=@var{file} -wrapper | |
194 | @@@var{file} -ffile-prefix-map=@var{old}=@var{new} -fcanon-prefix-map | |
195 | -fplugin=@var{file} -fplugin-arg-@var{name}=@var{arg} | |
d77de738 ML |
196 | -fdump-ada-spec@r{[}-slim@r{]} -fada-spec-parent=@var{unit} -fdump-go-spec=@var{file}} |
197 | ||
198 | @item C Language Options | |
199 | @xref{C Dialect Options,,Options Controlling C Dialect}. | |
43b72ede AA |
200 | @gccoptlist{-ansi -std=@var{standard} -aux-info @var{filename} |
201 | -fno-asm | |
202 | -fno-builtin -fno-builtin-@var{function} -fcond-mismatch | |
203 | -ffreestanding -fgimple -fgnu-tm -fgnu89-inline -fhosted | |
204 | -flax-vector-conversions -fms-extensions | |
205 | -foffload=@var{arg} -foffload-options=@var{arg} | |
206 | -fopenacc -fopenacc-dim=@var{geom} | |
207 | -fopenmp -fopenmp-simd -fopenmp-target-simd-clone@r{[}=@var{device-type}@r{]} | |
208 | -fpermitted-flt-eval-methods=@var{standard} | |
209 | -fplan9-extensions -fsigned-bitfields -funsigned-bitfields | |
210 | -fsigned-char -funsigned-char -fstrict-flex-arrays[=@var{n}] | |
d77de738 ML |
211 | -fsso-struct=@var{endianness}} |
212 | ||
213 | @item C++ Language Options | |
214 | @xref{C++ Dialect Options,,Options Controlling C++ Dialect}. | |
43b72ede AA |
215 | @gccoptlist{-fabi-version=@var{n} -fno-access-control |
216 | -faligned-new=@var{n} -fargs-in-order=@var{n} -fchar8_t -fcheck-new | |
217 | -fconstexpr-depth=@var{n} -fconstexpr-cache-depth=@var{n} | |
218 | -fconstexpr-loop-limit=@var{n} -fconstexpr-ops-limit=@var{n} | |
219 | -fno-elide-constructors | |
220 | -fno-enforce-eh-specs | |
221 | -fno-gnu-keywords | |
222 | -fno-implicit-templates | |
223 | -fno-implicit-inline-templates | |
224 | -fno-implement-inlines | |
225 | -fmodule-header@r{[}=@var{kind}@r{]} -fmodule-only -fmodules-ts | |
226 | -fmodule-implicit-inline | |
227 | -fno-module-lazy | |
228 | -fmodule-mapper=@var{specification} | |
229 | -fmodule-version-ignore | |
230 | -fms-extensions | |
231 | -fnew-inheriting-ctors | |
232 | -fnew-ttp-matching | |
233 | -fno-nonansi-builtins -fnothrow-opt -fno-operator-names | |
ef10cb86 | 234 | -fno-optional-diags |
43b72ede AA |
235 | -fno-pretty-templates |
236 | -fno-rtti -fsized-deallocation | |
237 | -ftemplate-backtrace-limit=@var{n} | |
238 | -ftemplate-depth=@var{n} | |
239 | -fno-threadsafe-statics -fuse-cxa-atexit | |
240 | -fno-weak -nostdinc++ | |
241 | -fvisibility-inlines-hidden | |
242 | -fvisibility-ms-compat | |
243 | -fext-numeric-literals | |
244 | -flang-info-include-translate@r{[}=@var{header}@r{]} | |
245 | -flang-info-include-translate-not | |
246 | -flang-info-module-cmi@r{[}=@var{module}@r{]} | |
247 | -stdlib=@var{libstdc++,libc++} | |
248 | -Wabi-tag -Wcatch-value -Wcatch-value=@var{n} | |
249 | -Wno-class-conversion -Wclass-memaccess | |
250 | -Wcomma-subscript -Wconditionally-supported | |
251 | -Wno-conversion-null -Wctad-maybe-unsupported | |
252 | -Wctor-dtor-privacy -Wdangling-reference | |
253 | -Wno-delete-incomplete | |
254 | -Wdelete-non-virtual-dtor -Wno-deprecated-array-compare | |
255 | -Wdeprecated-copy -Wdeprecated-copy-dtor | |
256 | -Wno-deprecated-enum-enum-conversion -Wno-deprecated-enum-float-conversion | |
b106f11d AC |
257 | -Weffc++ -Wno-elaborated-enum-base |
258 | -Wno-exceptions -Wextra-semi -Wno-inaccessible-base | |
43b72ede AA |
259 | -Wno-inherited-variadic-ctor -Wno-init-list-lifetime |
260 | -Winvalid-constexpr -Winvalid-imported-macros | |
261 | -Wno-invalid-offsetof -Wno-literal-suffix | |
262 | -Wmismatched-new-delete -Wmismatched-tags | |
263 | -Wmultiple-inheritance -Wnamespaces -Wnarrowing | |
264 | -Wnoexcept -Wnoexcept-type -Wnon-virtual-dtor | |
265 | -Wpessimizing-move -Wno-placement-new -Wplacement-new=@var{n} | |
266 | -Wrange-loop-construct -Wredundant-move -Wredundant-tags | |
267 | -Wreorder -Wregister | |
268 | -Wstrict-null-sentinel -Wno-subobject-linkage -Wtemplates | |
269 | -Wno-non-template-friend -Wold-style-cast | |
270 | -Woverloaded-virtual -Wno-pmf-conversions -Wself-move -Wsign-promo | |
271 | -Wsized-deallocation -Wsuggest-final-methods | |
272 | -Wsuggest-final-types -Wsuggest-override | |
273 | -Wno-terminate -Wuseless-cast -Wno-vexing-parse | |
274 | -Wvirtual-inheritance | |
d77de738 ML |
275 | -Wno-virtual-move-assign -Wvolatile -Wzero-as-null-pointer-constant} |
276 | ||
277 | @item Objective-C and Objective-C++ Language Options | |
278 | @xref{Objective-C and Objective-C++ Dialect Options,,Options Controlling | |
279 | Objective-C and Objective-C++ Dialects}. | |
43b72ede AA |
280 | @gccoptlist{-fconstant-string-class=@var{class-name} |
281 | -fgnu-runtime -fnext-runtime | |
282 | -fno-nil-receivers | |
283 | -fobjc-abi-version=@var{n} | |
284 | -fobjc-call-cxx-cdtors | |
285 | -fobjc-direct-dispatch | |
286 | -fobjc-exceptions | |
287 | -fobjc-gc | |
288 | -fobjc-nilcheck | |
289 | -fobjc-std=objc1 | |
290 | -fno-local-ivars | |
291 | -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]} | |
292 | -freplace-objc-classes | |
293 | -fzero-link | |
294 | -gen-decls | |
295 | -Wassign-intercept -Wno-property-assign-default | |
296 | -Wno-protocol -Wobjc-root-class -Wselector | |
297 | -Wstrict-selector-match | |
d77de738 ML |
298 | -Wundeclared-selector} |
299 | ||
300 | @item Diagnostic Message Formatting Options | |
301 | @xref{Diagnostic Message Formatting Options,,Options to Control Diagnostic Messages Formatting}. | |
43b72ede AA |
302 | @gccoptlist{-fmessage-length=@var{n} |
303 | -fdiagnostics-plain-output | |
304 | -fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]} | |
305 | -fdiagnostics-color=@r{[}auto@r{|}never@r{|}always@r{]} | |
306 | -fdiagnostics-urls=@r{[}auto@r{|}never@r{|}always@r{]} | |
307 | -fdiagnostics-format=@r{[}text@r{|}sarif-stderr@r{|}sarif-file@r{|}json@r{|}json-stderr@r{|}json-file@r{]} | |
308 | -fno-diagnostics-show-option -fno-diagnostics-show-caret | |
309 | -fno-diagnostics-show-labels -fno-diagnostics-show-line-numbers | |
310 | -fno-diagnostics-show-cwe | |
311 | -fno-diagnostics-show-rule | |
312 | -fdiagnostics-minimum-margin-width=@var{width} | |
313 | -fdiagnostics-parseable-fixits -fdiagnostics-generate-patch | |
314 | -fdiagnostics-show-template-tree -fno-elide-type | |
315 | -fdiagnostics-path-format=@r{[}none@r{|}separate-events@r{|}inline-events@r{]} | |
316 | -fdiagnostics-show-path-depths | |
317 | -fno-show-column | |
318 | -fdiagnostics-column-unit=@r{[}display@r{|}byte@r{]} | |
319 | -fdiagnostics-column-origin=@var{origin} | |
4f01ae37 DM |
320 | -fdiagnostics-escape-format=@r{[}unicode@r{|}bytes@r{]} |
321 | -fdiagnostics-text-art-charset=@r{[}none@r{|}ascii@r{|}unicode@r{|}emoji@r{]}} | |
d77de738 ML |
322 | |
323 | @item Warning Options | |
324 | @xref{Warning Options,,Options to Request or Suppress Warnings}. | |
43b72ede | 325 | @gccoptlist{-fsyntax-only -fmax-errors=@var{n} -Wpedantic |
ef10cb86 | 326 | -pedantic-errors -fpermissive |
43b72ede AA |
327 | -w -Wextra -Wall -Wabi=@var{n} |
328 | -Waddress -Wno-address-of-packed-member -Waggregate-return | |
329 | -Walloc-size-larger-than=@var{byte-size} -Walloc-zero | |
330 | -Walloca -Walloca-larger-than=@var{byte-size} | |
331 | -Wno-aggressive-loop-optimizations | |
332 | -Warith-conversion | |
333 | -Warray-bounds -Warray-bounds=@var{n} -Warray-compare | |
334 | -Wno-attributes -Wattribute-alias=@var{n} -Wno-attribute-alias | |
335 | -Wno-attribute-warning | |
336 | -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]} | |
337 | -Wbool-compare -Wbool-operation | |
338 | -Wno-builtin-declaration-mismatch | |
339 | -Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat | |
fad61bf7 | 340 | -Wc11-c23-compat |
43b72ede AA |
341 | -Wc++-compat -Wc++11-compat -Wc++14-compat -Wc++17-compat |
342 | -Wc++20-compat | |
343 | -Wno-c++11-extensions -Wno-c++14-extensions -Wno-c++17-extensions | |
344 | -Wno-c++20-extensions -Wno-c++23-extensions | |
345 | -Wcast-align -Wcast-align=strict -Wcast-function-type -Wcast-qual | |
346 | -Wchar-subscripts | |
347 | -Wclobbered -Wcomment | |
e1f45bea | 348 | -Wcompare-distinct-pointer-types |
43b72ede AA |
349 | -Wno-complain-wrong-lang |
350 | -Wconversion -Wno-coverage-mismatch -Wno-cpp | |
351 | -Wdangling-else -Wdangling-pointer -Wdangling-pointer=@var{n} | |
352 | -Wdate-time | |
353 | -Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init | |
354 | -Wdisabled-optimization | |
355 | -Wno-discarded-array-qualifiers -Wno-discarded-qualifiers | |
356 | -Wno-div-by-zero -Wdouble-promotion | |
357 | -Wduplicated-branches -Wduplicated-cond | |
358 | -Wempty-body -Wno-endif-labels -Wenum-compare -Wenum-conversion | |
359 | -Wenum-int-mismatch | |
360 | -Werror -Werror=* -Wexpansion-to-defined -Wfatal-errors | |
44e3f39a | 361 | -Wflex-array-member-not-at-end |
43b72ede AA |
362 | -Wfloat-conversion -Wfloat-equal -Wformat -Wformat=2 |
363 | -Wno-format-contains-nul -Wno-format-extra-args | |
364 | -Wformat-nonliteral -Wformat-overflow=@var{n} | |
365 | -Wformat-security -Wformat-signedness -Wformat-truncation=@var{n} | |
366 | -Wformat-y2k -Wframe-address | |
367 | -Wframe-larger-than=@var{byte-size} -Wno-free-nonheap-object | |
368 | -Wno-if-not-aligned -Wno-ignored-attributes | |
369 | -Wignored-qualifiers -Wno-incompatible-pointer-types | |
370 | -Wimplicit -Wimplicit-fallthrough -Wimplicit-fallthrough=@var{n} | |
371 | -Wno-implicit-function-declaration -Wno-implicit-int | |
372 | -Winfinite-recursion | |
373 | -Winit-self -Winline -Wno-int-conversion -Wint-in-bool-context | |
374 | -Wno-int-to-pointer-cast -Wno-invalid-memory-model | |
375 | -Winvalid-pch -Winvalid-utf8 -Wno-unicode -Wjump-misses-init | |
376 | -Wlarger-than=@var{byte-size} -Wlogical-not-parentheses -Wlogical-op | |
377 | -Wlong-long -Wno-lto-type-mismatch -Wmain -Wmaybe-uninitialized | |
378 | -Wmemset-elt-size -Wmemset-transposed-args | |
379 | -Wmisleading-indentation -Wmissing-attributes -Wmissing-braces | |
380 | -Wmissing-field-initializers -Wmissing-format-attribute | |
381 | -Wmissing-include-dirs -Wmissing-noreturn -Wno-missing-profile | |
382 | -Wno-multichar -Wmultistatement-macros -Wnonnull -Wnonnull-compare | |
383 | -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} | |
384 | -Wnull-dereference -Wno-odr | |
385 | -Wopenacc-parallelism | |
386 | -Wopenmp-simd | |
387 | -Wno-overflow -Woverlength-strings -Wno-override-init-side-effects | |
388 | -Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded | |
389 | -Wparentheses -Wno-pedantic-ms-format | |
390 | -Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast | |
391 | -Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls | |
392 | -Wrestrict -Wno-return-local-addr -Wreturn-type | |
393 | -Wno-scalar-storage-order -Wsequence-point | |
394 | -Wshadow -Wshadow=global -Wshadow=local -Wshadow=compatible-local | |
395 | -Wno-shadow-ivar | |
396 | -Wno-shift-count-negative -Wno-shift-count-overflow -Wshift-negative-value | |
397 | -Wno-shift-overflow -Wshift-overflow=@var{n} | |
398 | -Wsign-compare -Wsign-conversion | |
399 | -Wno-sizeof-array-argument | |
400 | -Wsizeof-array-div | |
401 | -Wsizeof-pointer-div -Wsizeof-pointer-memaccess | |
402 | -Wstack-protector -Wstack-usage=@var{byte-size} -Wstrict-aliasing | |
403 | -Wstrict-aliasing=n -Wstrict-overflow -Wstrict-overflow=@var{n} | |
404 | -Wstring-compare | |
405 | -Wno-stringop-overflow -Wno-stringop-overread | |
406 | -Wno-stringop-truncation -Wstrict-flex-arrays | |
407 | -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}malloc@r{]} | |
408 | -Wswitch -Wno-switch-bool -Wswitch-default -Wswitch-enum | |
409 | -Wno-switch-outside-range -Wno-switch-unreachable -Wsync-nand | |
410 | -Wsystem-headers -Wtautological-compare -Wtrampolines -Wtrigraphs | |
411 | -Wtrivial-auto-var-init -Wtsan -Wtype-limits -Wundef | |
412 | -Wuninitialized -Wunknown-pragmas | |
413 | -Wunsuffixed-float-constants -Wunused | |
414 | -Wunused-but-set-parameter -Wunused-but-set-variable | |
415 | -Wunused-const-variable -Wunused-const-variable=@var{n} | |
416 | -Wunused-function -Wunused-label -Wunused-local-typedefs | |
417 | -Wunused-macros | |
418 | -Wunused-parameter -Wno-unused-result | |
419 | -Wunused-value -Wunused-variable | |
420 | -Wno-varargs -Wvariadic-macros | |
421 | -Wvector-operation-performance | |
422 | -Wvla -Wvla-larger-than=@var{byte-size} -Wno-vla-larger-than | |
423 | -Wvolatile-register-var -Wwrite-strings | |
424 | -Wxor-used-as-pow | |
d77de738 ML |
425 | -Wzero-length-bounds} |
426 | ||
427 | @item Static Analyzer Options | |
428 | @gccoptlist{ | |
43b72ede AA |
429 | -fanalyzer |
430 | -fanalyzer-call-summaries | |
431 | -fanalyzer-checker=@var{name} | |
432 | -fno-analyzer-feasibility | |
433 | -fanalyzer-fine-grained | |
ce8cdf5b | 434 | -fanalyzer-show-events-in-system-headers |
43b72ede AA |
435 | -fno-analyzer-state-merge |
436 | -fno-analyzer-state-purge | |
437 | -fno-analyzer-suppress-followups | |
438 | -fanalyzer-transitivity | |
439 | -fno-analyzer-undo-inlining | |
440 | -fanalyzer-verbose-edges | |
441 | -fanalyzer-verbose-state-changes | |
442 | -fanalyzer-verbosity=@var{level} | |
443 | -fdump-analyzer | |
444 | -fdump-analyzer-callgraph | |
445 | -fdump-analyzer-exploded-graph | |
446 | -fdump-analyzer-exploded-nodes | |
447 | -fdump-analyzer-exploded-nodes-2 | |
448 | -fdump-analyzer-exploded-nodes-3 | |
449 | -fdump-analyzer-exploded-paths | |
450 | -fdump-analyzer-feasibility | |
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 | |
551935d1 AO |
645 | -fharden-control-flow-redundancy -fhardcfr-skip-leaf |
646 | -fhardcfr-check-exceptions -fhardcfr-check-returning-calls | |
647 | -fhardcfr-check-noreturn-calls=@r{[}always@r{|}no-xthrow@r{|}nothrow@r{|}never@r{]} | |
43b72ede AA |
648 | -fstack-protector -fstack-protector-all -fstack-protector-strong |
649 | -fstack-protector-explicit -fstack-check | |
650 | -fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} | |
651 | -fno-stack-limit -fsplit-stack | |
652 | -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} | |
653 | -fvtv-counts -fvtv-debug | |
654 | -finstrument-functions -finstrument-functions-once | |
655 | -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} | |
656 | -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{} | |
657 | -fprofile-prefix-map=@var{old}=@var{new}} | |
d77de738 ML |
658 | |
659 | @item Preprocessor Options | |
660 | @xref{Preprocessor Options,,Options Controlling the Preprocessor}. | |
43b72ede AA |
661 | @gccoptlist{-A@var{question}=@var{answer} |
662 | -A-@var{question}@r{[}=@var{answer}@r{]} | |
663 | -C -CC -D@var{macro}@r{[}=@var{defn}@r{]} | |
664 | -dD -dI -dM -dN -dU | |
665 | -fdebug-cpp -fdirectives-only -fdollars-in-identifiers | |
666 | -fexec-charset=@var{charset} -fextended-identifiers | |
667 | -finput-charset=@var{charset} -flarge-source-files | |
668 | -fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth} | |
669 | -fno-canonical-system-headers -fpch-deps -fpch-preprocess | |
670 | -fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion | |
671 | -fwide-exec-charset=@var{charset} -fworking-directory | |
672 | -H -imacros @var{file} -include @var{file} | |
673 | -M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mno-modules | |
674 | -no-integrated-cpp -P -pthread -remap | |
675 | -traditional -traditional-cpp -trigraphs | |
676 | -U@var{macro} -undef | |
d77de738 ML |
677 | -Wp,@var{option} -Xpreprocessor @var{option}} |
678 | ||
679 | @item Assembler Options | |
680 | @xref{Assembler Options,,Passing Options to the Assembler}. | |
681 | @gccoptlist{-Wa,@var{option} -Xassembler @var{option}} | |
682 | ||
683 | @item Linker Options | |
684 | @xref{Link Options,,Options for Linking}. | |
43b72ede AA |
685 | @gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library} |
686 | -nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++ | |
687 | -e @var{entry} --entry=@var{entry} | |
688 | -pie -pthread -r -rdynamic | |
689 | -s -static -static-pie -static-libgcc -static-libstdc++ | |
690 | -static-libasan -static-libtsan -static-liblsan -static-libubsan | |
691 | -shared -shared-libgcc -symbolic | |
692 | -T @var{script} -Wl,@var{option} -Xlinker @var{option} | |
d77de738 ML |
693 | -u @var{symbol} -z @var{keyword}} |
694 | ||
695 | @item Directory Options | |
696 | @xref{Directory Options,,Options for Directory Search}. | |
43b72ede AA |
697 | @gccoptlist{-B@var{prefix} -I@var{dir} -I- |
698 | -idirafter @var{dir} | |
699 | -imacros @var{file} -imultilib @var{dir} | |
700 | -iplugindir=@var{dir} -iprefix @var{file} | |
701 | -iquote @var{dir} -isysroot @var{dir} -isystem @var{dir} | |
702 | -iwithprefix @var{dir} -iwithprefixbefore @var{dir} | |
703 | -L@var{dir} -no-canonical-prefixes --no-sysroot-suffix | |
d77de738 ML |
704 | -nostdinc -nostdinc++ --sysroot=@var{dir}} |
705 | ||
706 | @item Code Generation Options | |
707 | @xref{Code Gen Options,,Options for Code Generation Conventions}. | |
43b72ede AA |
708 | @gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg} |
709 | -ffixed-@var{reg} -fexceptions | |
710 | -fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables | |
711 | -fasynchronous-unwind-tables | |
712 | -fno-gnu-unique | |
713 | -finhibit-size-directive -fcommon -fno-ident | |
714 | -fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt | |
715 | -fno-jump-tables -fno-bit-tests | |
716 | -frecord-gcc-switches | |
717 | -freg-struct-return -fshort-enums -fshort-wchar | |
718 | -fverbose-asm -fpack-struct[=@var{n}] | |
719 | -fleading-underscore -ftls-model=@var{model} | |
720 | -fstack-reuse=@var{reuse_level} | |
28d8c680 AB |
721 | -ftrampolines -ftrampoline-impl=@r{[}stack@r{|}heap@r{]} |
722 | -ftrapv -fwrapv | |
43b72ede | 723 | -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} |
d77de738 ML |
724 | -fstrict-volatile-bitfields -fsync-libcalls} |
725 | ||
726 | @item Developer Options | |
727 | @xref{Developer Options,,GCC Developer Options}. | |
43b72ede | 728 | @gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion |
d77de738 | 729 | -dumpfullversion -fcallgraph-info@r{[}=su,da@r{]} |
43b72ede AA |
730 | -fchecking -fchecking=@var{n} |
731 | -fdbg-cnt-list -fdbg-cnt=@var{counter-value-list} | |
732 | -fdisable-ipa-@var{pass_name} | |
733 | -fdisable-rtl-@var{pass_name} | |
734 | -fdisable-rtl-@var{pass-name}=@var{range-list} | |
735 | -fdisable-tree-@var{pass_name} | |
736 | -fdisable-tree-@var{pass-name}=@var{range-list} | |
737 | -fdump-debug -fdump-earlydebug | |
738 | -fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links | |
739 | -fdump-final-insns@r{[}=@var{file}@r{]} | |
740 | -fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline | |
741 | -fdump-lang-all | |
742 | -fdump-lang-@var{switch} | |
743 | -fdump-lang-@var{switch}-@var{options} | |
744 | -fdump-lang-@var{switch}-@var{options}=@var{filename} | |
745 | -fdump-passes | |
746 | -fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename} | |
747 | -fdump-statistics | |
748 | -fdump-tree-all | |
749 | -fdump-tree-@var{switch} | |
750 | -fdump-tree-@var{switch}-@var{options} | |
751 | -fdump-tree-@var{switch}-@var{options}=@var{filename} | |
752 | -fcompare-debug@r{[}=@var{opts}@r{]} -fcompare-debug-second | |
753 | -fenable-@var{kind}-@var{pass} | |
754 | -fenable-@var{kind}-@var{pass}=@var{range-list} | |
755 | -fira-verbose=@var{n} | |
756 | -flto-report -flto-report-wpa -fmem-report-wpa | |
757 | -fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report | |
758 | -fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]} | |
759 | -fmultiflags -fprofile-report | |
760 | -frandom-seed=@var{string} -fsched-verbose=@var{n} | |
761 | -fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose | |
762 | -fstats -fstack-usage -ftime-report -ftime-report-details | |
763 | -fvar-tracking-assignments-toggle -gtoggle | |
764 | -print-file-name=@var{library} -print-libgcc-file-name | |
765 | -print-multi-directory -print-multi-lib -print-multi-os-directory | |
766 | -print-prog-name=@var{program} -print-search-dirs -Q | |
767 | -print-sysroot -print-sysroot-headers-suffix | |
d77de738 ML |
768 | -save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}} |
769 | ||
770 | @item Machine-Dependent Options | |
771 | @xref{Submodel Options,,Machine-Dependent Options}. | |
772 | @c This list is ordered alphanumerically by subsection name. | |
773 | @c Try and put the significant identifier (CPU or system) first, | |
774 | @c so users have a clue at guessing where the ones they want will be. | |
775 | ||
776 | @emph{AArch64 Options} | |
43b72ede AA |
777 | @gccoptlist{-mabi=@var{name} -mbig-endian -mlittle-endian |
778 | -mgeneral-regs-only | |
779 | -mcmodel=tiny -mcmodel=small -mcmodel=large | |
780 | -mstrict-align -mno-strict-align | |
781 | -momit-leaf-frame-pointer | |
782 | -mtls-dialect=desc -mtls-dialect=traditional | |
783 | -mtls-size=@var{size} | |
784 | -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 | |
785 | -mlow-precision-recip-sqrt -mlow-precision-sqrt -mlow-precision-div | |
786 | -mpc-relative-literal-loads | |
787 | -msign-return-address=@var{scope} | |
d77de738 | 788 | -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf} |
43b72ede AA |
789 | +@var{b-key}]|@var{bti} |
790 | -mharden-sls=@var{opts} | |
791 | -march=@var{name} -mcpu=@var{name} -mtune=@var{name} | |
792 | -moverride=@var{string} -mverbose-cost-dump | |
793 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg} | |
794 | -mstack-protector-guard-offset=@var{offset} -mtrack-speculation | |
d77de738 ML |
795 | -moutline-atomics } |
796 | ||
797 | @emph{Adapteva Epiphany Options} | |
43b72ede AA |
798 | @gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs |
799 | -mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf | |
800 | -msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num} | |
801 | -mround-nearest -mlong-calls -mshort-calls -msmall16 | |
802 | -mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num} | |
d77de738 ML |
803 | -msplit-vecmove-early -m1reg-@var{reg}} |
804 | ||
805 | @emph{AMD GCN Options} | |
806 | @gccoptlist{-march=@var{gpu} -mtune=@var{gpu} -mstack-size=@var{bytes}} | |
807 | ||
808 | @emph{ARC Options} | |
43b72ede AA |
809 | @gccoptlist{-mbarrel-shifter -mjli-always |
810 | -mcpu=@var{cpu} -mA6 -mARC600 -mA7 -mARC700 | |
811 | -mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr | |
812 | -mea -mno-mpy -mmul32x16 -mmul64 -matomic | |
813 | -mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap | |
814 | -mcrc -mdsp-packa -mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape | |
815 | -mtelephony -mxy -misize -mannotate-align -marclinux -marclinux_prof | |
816 | -mlong-calls -mmedium-calls -msdata -mirq-ctrl-saved | |
817 | -mrgf-banked-regs -mlpc-width=@var{width} -G @var{num} | |
818 | -mvolatile-cache -mtp-regno=@var{regno} | |
819 | -malign-call -mauto-modify-reg -mbbit-peephole -mno-brcc | |
820 | -mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi | |
821 | -mexpand-adddi -mindexed-loads -mlra -mlra-priority-none | |
822 | -mlra-priority-compact -mlra-priority-noncompact -mmillicode | |
823 | -mmixed-code -mq-class -mRcq -mRcw -msize-level=@var{level} | |
824 | -mtune=@var{cpu} -mmultcost=@var{num} -mcode-density-frame | |
825 | -munalign-prob-threshold=@var{probability} -mmpy-option=@var{multo} | |
d77de738 ML |
826 | -mdiv-rem -mcode-density -mll64 -mfpu=@var{fpu} -mrf16 -mbranch-index} |
827 | ||
828 | @emph{ARM Options} | |
43b72ede AA |
829 | @gccoptlist{-mapcs-frame -mno-apcs-frame |
830 | -mabi=@var{name} | |
831 | -mapcs-stack-check -mno-apcs-stack-check | |
832 | -mapcs-reentrant -mno-apcs-reentrant | |
833 | -mgeneral-regs-only | |
834 | -msched-prolog -mno-sched-prolog | |
835 | -mlittle-endian -mbig-endian | |
836 | -mbe8 -mbe32 | |
837 | -mfloat-abi=@var{name} | |
d77de738 | 838 | -mfp16-format=@var{name} |
43b72ede AA |
839 | -mthumb-interwork -mno-thumb-interwork |
840 | -mcpu=@var{name} -march=@var{name} -mfpu=@var{name} | |
841 | -mtune=@var{name} -mprint-tune-info | |
842 | -mstructure-size-boundary=@var{n} | |
843 | -mabort-on-noreturn | |
844 | -mlong-calls -mno-long-calls | |
845 | -msingle-pic-base -mno-single-pic-base | |
846 | -mpic-register=@var{reg} | |
847 | -mnop-fun-dllimport | |
848 | -mpoke-function-name | |
849 | -mthumb -marm -mflip-thumb | |
850 | -mtpcs-frame -mtpcs-leaf-frame | |
851 | -mcaller-super-interworking -mcallee-super-interworking | |
852 | -mtp=@var{name} -mtls-dialect=@var{dialect} | |
853 | -mword-relocations | |
854 | -mfix-cortex-m3-ldrd | |
855 | -mfix-cortex-a57-aes-1742098 | |
856 | -mfix-cortex-a72-aes-1655431 | |
857 | -munaligned-access | |
858 | -mneon-for-64bits | |
859 | -mslow-flash-data | |
860 | -masm-syntax-unified | |
861 | -mrestrict-it | |
862 | -mverbose-cost-dump | |
863 | -mpure-code | |
864 | -mcmse | |
865 | -mfix-cmse-cve-2021-35465 | |
866 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset} | |
867 | -mfdpic | |
14fab5fb AC |
868 | -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}] |
869 | [+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]} | |
d77de738 ML |
870 | |
871 | @emph{AVR Options} | |
43b72ede AA |
872 | @gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args |
873 | -mbranch-cost=@var{cost} | |
874 | -mcall-prologues -mgas-isr-prologues -mint8 | |
875 | -mdouble=@var{bits} -mlong-double=@var{bits} | |
876 | -mn_flash=@var{size} -mno-interrupts | |
877 | -mmain-is-OS_task -mrelax -mrmw -mstrict-X -mtiny-stack | |
878 | -mfract-convert-truncate | |
879 | -mshort-calls -nodevicelib -nodevicespecs | |
d77de738 ML |
880 | -Waddr-space-convert -Wmisspelled-isr} |
881 | ||
882 | @emph{Blackfin Options} | |
43b72ede AA |
883 | @gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} |
884 | -msim -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer | |
885 | -mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly | |
886 | -mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library | |
887 | -mno-id-shared-library -mshared-library-id=@var{n} | |
888 | -mleaf-id-shared-library -mno-leaf-id-shared-library | |
889 | -msep-data -mno-sep-data -mlong-calls -mno-long-calls | |
890 | -mfast-fp -minline-plt -mmulticore -mcorea -mcoreb -msdram | |
d77de738 ML |
891 | -micplb} |
892 | ||
893 | @emph{C6X Options} | |
43b72ede | 894 | @gccoptlist{-mbig-endian -mlittle-endian -march=@var{cpu} |
d77de738 ML |
895 | -msim -msdata=@var{sdata-type}} |
896 | ||
897 | @emph{CRIS Options} | |
898 | @gccoptlist{-mcpu=@var{cpu} -march=@var{cpu} | |
43b72ede AA |
899 | -mtune=@var{cpu} -mmax-stack-frame=@var{n} |
900 | -metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects | |
901 | -mstack-align -mdata-align -mconst-align | |
902 | -m32-bit -m16-bit -m8-bit -mno-prologue-epilogue | |
903 | -melf -maout -sim -sim2 | |
d77de738 ML |
904 | -mmul-bug-workaround -mno-mul-bug-workaround} |
905 | ||
906 | @emph{C-SKY Options} | |
43b72ede AA |
907 | @gccoptlist{-march=@var{arch} -mcpu=@var{cpu} |
908 | -mbig-endian -EB -mlittle-endian -EL | |
909 | -mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu | |
910 | -mfloat-abi=@var{name} | |
911 | -melrw -mistack -mmp -mcp -mcache -msecurity -mtrust | |
912 | -mdsp -medsp -mvdsp | |
913 | -mdiv -msmart -mhigh-registers -manchor | |
914 | -mpushpop -mmultiple-stld -mconstpool -mstack-size -mccrt | |
d77de738 ML |
915 | -mbranch-cost=@var{n} -mcse-cc -msched-prolog -msim} |
916 | ||
917 | @emph{Darwin Options} | |
43b72ede AA |
918 | @gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal |
919 | -arch_only -bind_at_load -bundle -bundle_loader | |
920 | -client_name -compatibility_version -current_version | |
921 | -dead_strip | |
922 | -dependency-file -dylib_file -dylinker_install_name | |
923 | -dynamic -dynamiclib -exported_symbols_list | |
924 | -filelist -flat_namespace -force_cpusubtype_ALL | |
925 | -force_flat_namespace -headerpad_max_install_names | |
926 | -iframework | |
927 | -image_base -init -install_name -keep_private_externs | |
928 | -multi_module -multiply_defined -multiply_defined_unused | |
47b634a3 | 929 | -noall_load -no_dead_strip_inits_and_terms -nodefaultrpaths |
43b72ede AA |
930 | -nofixprebinding -nomultidefs -noprebind -noseglinkedit |
931 | -pagezero_size -prebind -prebind_all_twolevel_modules | |
932 | -private_bundle -read_only_relocs -sectalign | |
933 | -sectobjectsymbols -whyload -seg1addr | |
934 | -sectcreate -sectobjectsymbols -sectorder | |
935 | -segaddr -segs_read_only_addr -segs_read_write_addr | |
936 | -seg_addr_table -seg_addr_table_filename -seglinkedit | |
937 | -segprot -segs_read_only_addr -segs_read_write_addr | |
938 | -single_module -static -sub_library -sub_umbrella | |
939 | -twolevel_namespace -umbrella -undefined | |
940 | -unexported_symbols_list -weak_reference_mismatches | |
941 | -whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version} | |
d77de738 ML |
942 | -mkernel -mone-byte-bool} |
943 | ||
944 | @emph{DEC Alpha Options} | |
43b72ede AA |
945 | @gccoptlist{-mno-fp-regs -msoft-float |
946 | -mieee -mieee-with-inexact -mieee-conformant | |
947 | -mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} | |
948 | -mtrap-precision=@var{mode} -mbuild-constants | |
949 | -mcpu=@var{cpu-type} -mtune=@var{cpu-type} | |
950 | -mbwx -mmax -mfix -mcix | |
951 | -mfloat-vax -mfloat-ieee | |
952 | -mexplicit-relocs -msmall-data -mlarge-data | |
953 | -msmall-text -mlarge-text | |
d77de738 ML |
954 | -mmemory-latency=@var{time}} |
955 | ||
956 | @emph{eBPF Options} | |
9cbf4286 | 957 | @gccoptlist{-mbig-endian -mlittle-endian |
77d0f9ec | 958 | -mframe-limit=@var{bytes} -mxbpf -mco-re -mno-co-re -mjmpext |
14dab1a1 | 959 | -mjmp32 -malu32 -mv3-atomics -mbswap -msdiv -msmov -mcpu=@var{version} |
9cbf4286 | 960 | -masm=@var{dialect}} |
d77de738 ML |
961 | |
962 | @emph{FR30 Options} | |
963 | @gccoptlist{-msmall-model -mno-lsim} | |
964 | ||
965 | @emph{FT32 Options} | |
966 | @gccoptlist{-msim -mlra -mnodiv -mft32b -mcompress -mnopm} | |
967 | ||
968 | @emph{FRV Options} | |
43b72ede AA |
969 | @gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64 |
970 | -mhard-float -msoft-float | |
971 | -malloc-cc -mfixed-cc -mdword -mno-dword | |
972 | -mdouble -mno-double | |
973 | -mmedia -mno-media -mmuladd -mno-muladd | |
974 | -mfdpic -minline-plt -mgprel-ro -multilib-library-pic | |
975 | -mlinked-fp -mlong-calls -malign-labels | |
976 | -mlibrary-pic -macc-4 -macc-8 | |
977 | -mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move | |
978 | -moptimize-membar -mno-optimize-membar | |
979 | -mscc -mno-scc -mcond-exec -mno-cond-exec | |
980 | -mvliw-branch -mno-vliw-branch | |
981 | -mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec | |
982 | -mno-nested-cond-exec -mtomcat-stats | |
983 | -mTLS -mtls | |
d77de738 ML |
984 | -mcpu=@var{cpu}} |
985 | ||
986 | @emph{GNU/Linux Options} | |
43b72ede | 987 | @gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid |
d77de738 ML |
988 | -tno-android-cc -tno-android-ld} |
989 | ||
990 | @emph{H8/300 Options} | |
991 | @gccoptlist{-mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300} | |
992 | ||
993 | @emph{HPPA Options} | |
43b72ede AA |
994 | @gccoptlist{-march=@var{architecture-type} |
995 | -matomic-libcalls -mbig-switch | |
996 | -mcaller-copies -mdisable-fpregs -mdisable-indexing | |
997 | -mordered -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld | |
998 | -mfixed-range=@var{register-range} | |
999 | -mcoherent-ldcw -mjump-in-delay -mlinker-opt -mlong-calls | |
1000 | -mlong-load-store -mno-atomic-libcalls -mno-disable-fpregs | |
1001 | -mno-disable-indexing -mno-fast-indirect-calls -mno-gas | |
1002 | -mno-jump-in-delay -mno-long-load-store | |
1003 | -mno-portable-runtime -mno-soft-float | |
1004 | -mno-space-regs -msoft-float -mpa-risc-1-0 | |
1005 | -mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime | |
1006 | -mschedule=@var{cpu-type} -mspace-regs -msoft-mult -msio -mwsio | |
d77de738 ML |
1007 | -munix=@var{unix-std} -nolibdld -static -threads} |
1008 | ||
1009 | @emph{IA-64 Options} | |
43b72ede AA |
1010 | @gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic |
1011 | -mvolatile-asm-stop -mregister-names -msdata -mno-sdata | |
1012 | -mconstant-gp -mauto-pic -mfused-madd | |
1013 | -minline-float-divide-min-latency | |
1014 | -minline-float-divide-max-throughput | |
1015 | -mno-inline-float-divide | |
1016 | -minline-int-divide-min-latency | |
1017 | -minline-int-divide-max-throughput | |
1018 | -mno-inline-int-divide | |
1019 | -minline-sqrt-min-latency -minline-sqrt-max-throughput | |
1020 | -mno-inline-sqrt | |
1021 | -mdwarf2-asm -mearly-stop-bits | |
1022 | -mfixed-range=@var{register-range} -mtls-size=@var{tls-size} | |
1023 | -mtune=@var{cpu-type} -milp32 -mlp64 | |
1024 | -msched-br-data-spec -msched-ar-data-spec -msched-control-spec | |
1025 | -msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec | |
1026 | -msched-spec-ldc -msched-spec-control-ldc | |
1027 | -msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns | |
1028 | -msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path | |
1029 | -msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost | |
d77de738 ML |
1030 | -msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}} |
1031 | ||
1032 | @emph{LM32 Options} | |
43b72ede | 1033 | @gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled |
d77de738 ML |
1034 | -msign-extend-enabled -muser-enabled} |
1035 | ||
1036 | @emph{LoongArch Options} | |
43b72ede | 1037 | @gccoptlist{-march=@var{cpu-type} -mtune=@var{cpu-type} -mabi=@var{base-abi-type} |
bb4a8198 YY |
1038 | -mfpu=@var{fpu-type} -msimd=@var{simd-type} |
1039 | -msoft-float -msingle-float -mdouble-float -mlsx -mno-lsx -mlasx -mno-lasx | |
43b72ede AA |
1040 | -mbranch-cost=@var{n} -mcheck-zero-division -mno-check-zero-division |
1041 | -mcond-move-int -mno-cond-move-int | |
1042 | -mcond-move-float -mno-cond-move-float | |
1043 | -memcpy -mno-memcpy -mstrict-align -mno-strict-align | |
1044 | -mmax-inline-memcpy-size=@var{n} | |
e1b1cba1 | 1045 | -mexplicit-relocs=@var{style} -mexplicit-relocs -mno-explicit-relocs |
43b72ede | 1046 | -mdirect-extern-access -mno-direct-extern-access |
d77de738 ML |
1047 | -mcmodel=@var{code-model}} |
1048 | ||
1049 | @emph{M32R/D Options} | |
43b72ede AA |
1050 | @gccoptlist{-m32r2 -m32rx -m32r |
1051 | -mdebug | |
1052 | -malign-loops -mno-align-loops | |
1053 | -missue-rate=@var{number} | |
1054 | -mbranch-cost=@var{number} | |
1055 | -mmodel=@var{code-size-model-type} | |
1056 | -msdata=@var{sdata-type} | |
1057 | -mno-flush-func -mflush-func=@var{name} | |
1058 | -mno-flush-trap -mflush-trap=@var{number} | |
d77de738 ML |
1059 | -G @var{num}} |
1060 | ||
1061 | @emph{M32C Options} | |
1062 | @gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}} | |
1063 | ||
1064 | @emph{M680x0 Options} | |
43b72ede AA |
1065 | @gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune} |
1066 | -m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 | |
1067 | -m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407 | |
1068 | -mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020 | |
1069 | -mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort | |
1070 | -mno-short -mhard-float -m68881 -msoft-float -mpcrel | |
1071 | -malign-int -mstrict-align -msep-data -mno-sep-data | |
1072 | -mshared-library-id=n -mid-shared-library -mno-id-shared-library | |
d77de738 ML |
1073 | -mxgot -mno-xgot -mlong-jump-table-offsets} |
1074 | ||
1075 | @emph{MCore Options} | |
43b72ede AA |
1076 | @gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates |
1077 | -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields | |
1078 | -m4byte-functions -mno-4byte-functions -mcallgraph-data | |
1079 | -mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim | |
d77de738 ML |
1080 | -mlittle-endian -mbig-endian -m210 -m340 -mstack-increment} |
1081 | ||
d77de738 | 1082 | @emph{MicroBlaze Options} |
43b72ede AA |
1083 | @gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu} |
1084 | -mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift | |
1085 | -mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss | |
1086 | -mxl-multiply-high -mxl-float-convert -mxl-float-sqrt | |
1087 | -mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model} | |
d77de738 ML |
1088 | -mpic-data-is-text-relative} |
1089 | ||
1090 | @emph{MIPS Options} | |
43b72ede AA |
1091 | @gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} |
1092 | -mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5 | |
1093 | -mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6 | |
1094 | -mips16 -mno-mips16 -mflip-mips16 | |
1095 | -minterlink-compressed -mno-interlink-compressed | |
1096 | -minterlink-mips16 -mno-interlink-mips16 | |
1097 | -mabi=@var{abi} -mabicalls -mno-abicalls | |
1098 | -mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot | |
1099 | -mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float | |
1100 | -mno-float -msingle-float -mdouble-float | |
1101 | -modd-spreg -mno-odd-spreg | |
1102 | -mabs=@var{mode} -mnan=@var{encoding} | |
1103 | -mdsp -mno-dsp -mdspr2 -mno-dspr2 | |
1104 | -mmcu -mmno-mcu | |
1105 | -meva -mno-eva | |
1106 | -mvirt -mno-virt | |
1107 | -mxpa -mno-xpa | |
1108 | -mcrc -mno-crc | |
1109 | -mginv -mno-ginv | |
1110 | -mmicromips -mno-micromips | |
1111 | -mmsa -mno-msa | |
1112 | -mloongson-mmi -mno-loongson-mmi | |
1113 | -mloongson-ext -mno-loongson-ext | |
1114 | -mloongson-ext2 -mno-loongson-ext2 | |
1115 | -mfpu=@var{fpu-type} | |
1116 | -msmartmips -mno-smartmips | |
1117 | -mpaired-single -mno-paired-single -mdmx -mno-mdmx | |
1118 | -mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc | |
1119 | -mlong64 -mlong32 -msym32 -mno-sym32 | |
1120 | -G@var{num} -mlocal-sdata -mno-local-sdata | |
1121 | -mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt | |
1122 | -membedded-data -mno-embedded-data | |
1123 | -muninit-const-in-rodata -mno-uninit-const-in-rodata | |
1124 | -mcode-readable=@var{setting} | |
1125 | -msplit-addresses -mno-split-addresses | |
1126 | -mexplicit-relocs -mno-explicit-relocs | |
1127 | -mcheck-zero-division -mno-check-zero-division | |
1128 | -mdivide-traps -mdivide-breaks | |
1129 | -mload-store-pairs -mno-load-store-pairs | |
1130 | -munaligned-access -mno-unaligned-access | |
1131 | -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls | |
1132 | -mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp | |
1133 | -mfix-24k -mno-fix-24k | |
1134 | -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 | |
1135 | -mfix-r5900 -mno-fix-r5900 | |
1136 | -mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000 | |
1137 | -mfix-vr4120 -mno-fix-vr4120 | |
1138 | -mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1 | |
1139 | -mflush-func=@var{func} -mno-flush-func | |
1140 | -mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely | |
1141 | -mcompact-branches=@var{policy} | |
1142 | -mfp-exceptions -mno-fp-exceptions | |
1143 | -mvr4130-align -mno-vr4130-align -msynci -mno-synci | |
1144 | -mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4 | |
1145 | -mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address | |
d77de738 ML |
1146 | -mframe-header-opt -mno-frame-header-opt} |
1147 | ||
1148 | @emph{MMIX Options} | |
43b72ede AA |
1149 | @gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu |
1150 | -mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols | |
1151 | -melf -mbranch-predict -mno-branch-predict -mbase-addresses | |
d77de738 ML |
1152 | -mno-base-addresses -msingle-exit -mno-single-exit} |
1153 | ||
1154 | @emph{MN10300 Options} | |
43b72ede AA |
1155 | @gccoptlist{-mmult-bug -mno-mult-bug |
1156 | -mno-am33 -mam33 -mam33-2 -mam34 | |
1157 | -mtune=@var{cpu-type} | |
1158 | -mreturn-pointer-on-d0 | |
d77de738 ML |
1159 | -mno-crt0 -mrelax -mliw -msetlb} |
1160 | ||
1161 | @emph{Moxie Options} | |
1162 | @gccoptlist{-meb -mel -mmul.x -mno-crt0} | |
1163 | ||
1164 | @emph{MSP430 Options} | |
43b72ede AA |
1165 | @gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax |
1166 | -mwarn-mcu | |
1167 | -mcode-region= -mdata-region= | |
1168 | -msilicon-errata= -msilicon-errata-warn= | |
d77de738 ML |
1169 | -mhwmult= -minrt -mtiny-printf -mmax-inline-shift=} |
1170 | ||
1171 | @emph{NDS32 Options} | |
43b72ede AA |
1172 | @gccoptlist{-mbig-endian -mlittle-endian |
1173 | -mreduced-regs -mfull-regs | |
1174 | -mcmov -mno-cmov | |
1175 | -mext-perf -mno-ext-perf | |
1176 | -mext-perf2 -mno-ext-perf2 | |
1177 | -mext-string -mno-ext-string | |
1178 | -mv3push -mno-v3push | |
1179 | -m16bit -mno-16bit | |
1180 | -misr-vector-size=@var{num} | |
1181 | -mcache-block-size=@var{num} | |
1182 | -march=@var{arch} | |
1183 | -mcmodel=@var{code-model} | |
d77de738 ML |
1184 | -mctor-dtor -mrelax} |
1185 | ||
1186 | @emph{Nios II Options} | |
43b72ede AA |
1187 | @gccoptlist{-G @var{num} -mgpopt=@var{option} -mgpopt -mno-gpopt |
1188 | -mgprel-sec=@var{regexp} -mr0rel-sec=@var{regexp} | |
1189 | -mel -meb | |
1190 | -mno-bypass-cache -mbypass-cache | |
1191 | -mno-cache-volatile -mcache-volatile | |
1192 | -mno-fast-sw-div -mfast-sw-div | |
1193 | -mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx -mno-hw-div -mhw-div | |
1194 | -mcustom-@var{insn}=@var{N} -mno-custom-@var{insn} | |
1195 | -mcustom-fpu-cfg=@var{name} | |
1196 | -mhal -msmallc -msys-crt0=@var{name} -msys-lib=@var{name} | |
d77de738 ML |
1197 | -march=@var{arch} -mbmx -mno-bmx -mcdx -mno-cdx} |
1198 | ||
1199 | @emph{Nvidia PTX Options} | |
1200 | @gccoptlist{-m64 -mmainkernel -moptimize} | |
1201 | ||
1202 | @emph{OpenRISC Options} | |
43b72ede AA |
1203 | @gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div |
1204 | -msoft-mul -msoft-div | |
1205 | -msoft-float -mhard-float -mdouble-float -munordered-float | |
1206 | -mcmov -mror -mrori -msext -msfimm -mshftimm | |
d77de738 ML |
1207 | -mcmodel=@var{code-model}} |
1208 | ||
1209 | @emph{PDP-11 Options} | |
43b72ede AA |
1210 | @gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 |
1211 | -mint32 -mno-int16 -mint16 -mno-int32 | |
d77de738 ML |
1212 | -msplit -munix-asm -mdec-asm -mgnu-asm -mlra} |
1213 | ||
d77de738 ML |
1214 | @emph{PowerPC Options} |
1215 | See RS/6000 and PowerPC Options. | |
1216 | ||
1217 | @emph{PRU Options} | |
43b72ede | 1218 | @gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop |
f58e6d42 | 1219 | -mabi=@var{variant}} |
d77de738 ML |
1220 | |
1221 | @emph{RISC-V Options} | |
43b72ede AA |
1222 | @gccoptlist{-mbranch-cost=@var{N-instruction} |
1223 | -mplt -mno-plt | |
1224 | -mabi=@var{ABI-string} | |
1225 | -mfdiv -mno-fdiv | |
1226 | -mdiv -mno-div | |
1227 | -misa-spec=@var{ISA-spec-string} | |
1228 | -march=@var{ISA-string} | |
1229 | -mtune=@var{processor-string} | |
1230 | -mpreferred-stack-boundary=@var{num} | |
1231 | -msmall-data-limit=@var{N-bytes} | |
1232 | -msave-restore -mno-save-restore | |
1233 | -mshorten-memrefs -mno-shorten-memrefs | |
1234 | -mstrict-align -mno-strict-align | |
1235 | -mcmodel=medlow -mcmodel=medany | |
1236 | -mexplicit-relocs -mno-explicit-relocs | |
1237 | -mrelax -mno-relax | |
1238 | -mriscv-attribute -mno-riscv-attribute | |
1239 | -malign-data=@var{type} | |
1240 | -mbig-endian -mlittle-endian | |
1241 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} | |
1242 | -mstack-protector-guard-offset=@var{offset} | |
f797260a | 1243 | -mcsr-check -mno-csr-check |
df48285b | 1244 | -minline-atomics -mno-inline-atomics |
949f1ccf CM |
1245 | -minline-strlen -mno-inline-strlen |
1246 | -minline-strcmp -mno-inline-strcmp | |
1247 | -minline-strncmp -mno-inline-strncmp} | |
d77de738 ML |
1248 | |
1249 | @emph{RL78 Options} | |
43b72ede AA |
1250 | @gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs |
1251 | -mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14 | |
d77de738 ML |
1252 | -m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts} |
1253 | ||
1254 | @emph{RS/6000 and PowerPC Options} | |
43b72ede AA |
1255 | @gccoptlist{-mcpu=@var{cpu-type} |
1256 | -mtune=@var{cpu-type} | |
1257 | -mcmodel=@var{code-model} | |
1258 | -mpowerpc64 | |
1259 | -maltivec -mno-altivec | |
1260 | -mpowerpc-gpopt -mno-powerpc-gpopt | |
1261 | -mpowerpc-gfxopt -mno-powerpc-gfxopt | |
1262 | -mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd | |
1263 | -mfprnd -mno-fprnd | |
1264 | -mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp | |
1265 | -mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc | |
1266 | -m64 -m32 -mxl-compat -mno-xl-compat -mpe | |
1267 | -malign-power -malign-natural | |
1268 | -msoft-float -mhard-float -mmultiple -mno-multiple | |
1269 | -mupdate -mno-update | |
1270 | -mavoid-indexed-addresses -mno-avoid-indexed-addresses | |
1271 | -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align | |
1272 | -mstrict-align -mno-strict-align -mrelocatable | |
1273 | -mno-relocatable -mrelocatable-lib -mno-relocatable-lib | |
1274 | -mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian | |
1275 | -mdynamic-no-pic -mswdiv -msingle-pic-base | |
1276 | -mprioritize-restricted-insns=@var{priority} | |
1277 | -msched-costly-dep=@var{dependence_type} | |
1278 | -minsert-sched-nops=@var{scheme} | |
1279 | -mcall-aixdesc -mcall-eabi -mcall-freebsd | |
1280 | -mcall-linux -mcall-netbsd -mcall-openbsd | |
1281 | -mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi | |
1282 | -mtraceback=@var{traceback_type} | |
1283 | -maix-struct-return -msvr4-struct-return | |
1284 | -mabi=@var{abi-type} -msecure-plt -mbss-plt | |
1285 | -mlongcall -mno-longcall -mpltseq -mno-pltseq | |
1286 | -mblock-move-inline-limit=@var{num} | |
1287 | -mblock-compare-inline-limit=@var{num} | |
1288 | -mblock-compare-inline-loop-limit=@var{num} | |
1289 | -mno-block-ops-unaligned-vsx | |
1290 | -mstring-compare-inline-limit=@var{num} | |
1291 | -misel -mno-isel | |
1292 | -mvrsave -mno-vrsave | |
1293 | -mmulhw -mno-mulhw | |
1294 | -mdlmzb -mno-dlmzb | |
1295 | -mprototype -mno-prototype | |
1296 | -msim -mmvme -mads -myellowknife -memb -msdata | |
1297 | -msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num} | |
1298 | -mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision | |
1299 | -mno-recip-precision | |
1300 | -mveclibabi=@var{type} -mfriz -mno-friz | |
1301 | -mpointers-to-nested-functions -mno-pointers-to-nested-functions | |
1302 | -msave-toc-indirect -mno-save-toc-indirect | |
1303 | -mpower8-fusion -mno-mpower8-fusion -mpower8-vector -mno-power8-vector | |
1304 | -mcrypto -mno-crypto -mhtm -mno-htm | |
1305 | -mquad-memory -mno-quad-memory | |
1306 | -mquad-memory-atomic -mno-quad-memory-atomic | |
1307 | -mcompat-align-parm -mno-compat-align-parm | |
1308 | -mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware | |
1309 | -mgnu-attribute -mno-gnu-attribute | |
1310 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} | |
1311 | -mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed | |
1312 | -mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect | |
d77de738 ML |
1313 | -mprivileged -mno-privileged} |
1314 | ||
1315 | @emph{RX Options} | |
43b72ede AA |
1316 | @gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu |
1317 | -mcpu= | |
1318 | -mbig-endian-data -mlittle-endian-data | |
1319 | -msmall-data | |
1320 | -msim -mno-sim | |
1321 | -mas100-syntax -mno-as100-syntax | |
1322 | -mrelax | |
1323 | -mmax-constant-size= | |
1324 | -mint-register= | |
1325 | -mpid | |
1326 | -mallow-string-insns -mno-allow-string-insns | |
1327 | -mjsr | |
1328 | -mno-warn-multiple-fast-interrupts | |
d77de738 ML |
1329 | -msave-acc-in-interrupts} |
1330 | ||
1331 | @emph{S/390 and zSeries Options} | |
43b72ede AA |
1332 | @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} |
1333 | -mhard-float -msoft-float -mhard-dfp -mno-hard-dfp | |
1334 | -mlong-double-64 -mlong-double-128 | |
1335 | -mbackchain -mno-backchain -mpacked-stack -mno-packed-stack | |
1336 | -msmall-exec -mno-small-exec -mmvcle -mno-mvcle | |
1337 | -m64 -m31 -mdebug -mno-debug -mesa -mzarch | |
1338 | -mhtm -mvx -mzvector | |
1339 | -mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip | |
1340 | -mfused-madd -mno-fused-madd | |
1341 | -mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard | |
d77de738 ML |
1342 | -mhotpatch=@var{halfwords},@var{halfwords}} |
1343 | ||
d77de738 | 1344 | @emph{SH Options} |
43b72ede AA |
1345 | @gccoptlist{-m1 -m2 -m2e |
1346 | -m2a-nofpu -m2a-single-only -m2a-single -m2a | |
1347 | -m3 -m3e | |
1348 | -m4-nofpu -m4-single-only -m4-single -m4 | |
1349 | -m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al | |
1350 | -mb -ml -mdalign -mrelax | |
1351 | -mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave | |
1352 | -mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct | |
1353 | -mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy} | |
1354 | -mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range} | |
1355 | -maccumulate-outgoing-args | |
1356 | -matomic-model=@var{atomic-model} | |
1357 | -mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch | |
1358 | -mcbranch-force-delay-slot | |
1359 | -mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra | |
d77de738 ML |
1360 | -mpretend-cmove -mtas} |
1361 | ||
1362 | @emph{Solaris 2 Options} | |
43b72ede | 1363 | @gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text |
d77de738 ML |
1364 | -pthreads} |
1365 | ||
1366 | @emph{SPARC Options} | |
43b72ede AA |
1367 | @gccoptlist{-mcpu=@var{cpu-type} |
1368 | -mtune=@var{cpu-type} | |
1369 | -mcmodel=@var{code-model} | |
1370 | -mmemory-model=@var{mem-model} | |
1371 | -m32 -m64 -mapp-regs -mno-app-regs | |
1372 | -mfaster-structs -mno-faster-structs -mflat -mno-flat | |
1373 | -mfpu -mno-fpu -mhard-float -msoft-float | |
1374 | -mhard-quad-float -msoft-quad-float | |
1375 | -mstack-bias -mno-stack-bias | |
1376 | -mstd-struct-return -mno-std-struct-return | |
1377 | -munaligned-doubles -mno-unaligned-doubles | |
1378 | -muser-mode -mno-user-mode | |
1379 | -mv8plus -mno-v8plus -mvis -mno-vis | |
1380 | -mvis2 -mno-vis2 -mvis3 -mno-vis3 | |
1381 | -mvis4 -mno-vis4 -mvis4b -mno-vis4b | |
1382 | -mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld | |
1383 | -mpopc -mno-popc -msubxc -mno-subxc | |
1384 | -mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc | |
d77de738 ML |
1385 | -mlra -mno-lra} |
1386 | ||
1387 | @emph{System V Options} | |
1388 | @gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}} | |
1389 | ||
1390 | @emph{V850 Options} | |
43b72ede AA |
1391 | @gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep |
1392 | -mprolog-function -mno-prolog-function -mspace | |
1393 | -mtda=@var{n} -msda=@var{n} -mzda=@var{n} | |
1394 | -mapp-regs -mno-app-regs | |
1395 | -mdisable-callt -mno-disable-callt | |
1396 | -mv850e2v3 -mv850e2 -mv850e1 -mv850es | |
1397 | -mv850e -mv850 -mv850e3v5 | |
1398 | -mloop | |
1399 | -mrelax | |
1400 | -mlong-jumps | |
1401 | -msoft-float | |
1402 | -mhard-float | |
1403 | -mgcc-abi | |
1404 | -mrh850-abi | |
d77de738 ML |
1405 | -mbig-switch} |
1406 | ||
1407 | @emph{VAX Options} | |
1408 | @gccoptlist{-mg -mgnu -munix -mlra} | |
1409 | ||
1410 | @emph{Visium Options} | |
43b72ede | 1411 | @gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float |
d77de738 ML |
1412 | -mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode} |
1413 | ||
1414 | @emph{VMS Options} | |
43b72ede | 1415 | @gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64 |
d77de738 ML |
1416 | -mpointer-size=@var{size}} |
1417 | ||
1418 | @emph{VxWorks Options} | |
b6f4b000 | 1419 | @gccoptlist{-mrtp -msmp -non-static -Bstatic -Bdynamic |
d77de738 ML |
1420 | -Xbind-lazy -Xbind-now} |
1421 | ||
1422 | @emph{x86 Options} | |
43b72ede AA |
1423 | @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} |
1424 | -mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default | |
1425 | -mfpmath=@var{unit} | |
1426 | -masm=@var{dialect} -mno-fancy-math-387 | |
1427 | -mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float | |
1428 | -mno-wide-multiply -mrtd -malign-double | |
1429 | -mpreferred-stack-boundary=@var{num} | |
1430 | -mincoming-stack-boundary=@var{num} | |
1431 | -mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait | |
1432 | -mrecip -mrecip=@var{opt} | |
1433 | -mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt} | |
ad5b757d | 1434 | -mpartial-vector-fp-math |
43b72ede AA |
1435 | -mmove-max=@var{bits} -mstore-max=@var{bits} |
1436 | -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx | |
1437 | -mavx2 -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl | |
1438 | -mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes | |
1439 | -mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd | |
1440 | -mptwrite -mprefetchwt1 -mclflushopt -mclwb -mxsavec -mxsaves | |
1441 | -msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop | |
1442 | -madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp | |
1443 | -mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg | |
1444 | -mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call | |
1445 | -mavx512vbmi2 -mavx512bf16 -menqcmd | |
1446 | -mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq | |
1447 | -mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid | |
1448 | -mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk | |
1449 | -mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni | |
1450 | -mavx512fp16 -mavxifma -mavxvnniint8 -mavxneconvert -mcmpccxadd -mamx-fp16 | |
e686416b | 1451 | -mprefetchi -mraoint -mamx-complex -mavxvnniint16 -msm3 -msha512 -msm4 -mapxf |
5fbd91b1 | 1452 | -musermsr |
43b72ede AA |
1453 | -mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops |
1454 | -minline-stringops-dynamically -mstringop-strategy=@var{alg} | |
1455 | -mkl -mwidekl | |
1456 | -mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy} | |
1457 | -mpush-args -maccumulate-outgoing-args -m128bit-long-double | |
1458 | -m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128 | |
1459 | -mregparm=@var{num} -msseregparm | |
1460 | -mveclibabi=@var{type} -mvect8-ret-in-mem | |
1461 | -mpc32 -mpc64 -mpc80 -mdaz-ftz -mstackrealign | |
1462 | -momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs | |
1463 | -mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode} | |
1464 | -m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num} | |
1465 | -msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv | |
1466 | -minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name} | |
1467 | -mavx256-split-unaligned-load -mavx256-split-unaligned-store | |
1468 | -malign-data=@var{type} -mstack-protector-guard=@var{guard} | |
1469 | -mstack-protector-guard-reg=@var{reg} | |
1470 | -mstack-protector-guard-offset=@var{offset} | |
1471 | -mstack-protector-guard-symbol=@var{symbol} | |
1472 | -mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop | |
1473 | -mindirect-branch=@var{choice} -mfunction-return=@var{choice} | |
1474 | -mindirect-branch-register -mharden-sls=@var{choice} | |
1475 | -mindirect-branch-cs-prefix -mneeded -mno-direct-extern-access | |
bb576017 | 1476 | -munroll-only-small-loops -mlam=@var{choice}} |
d77de738 ML |
1477 | |
1478 | @emph{x86 Windows Options} | |
453cb585 | 1479 | @gccoptlist{-mconsole -mcrtdll=@var{library} -mcygwin -mno-cygwin -mdll |
43b72ede | 1480 | -mnop-fun-dllimport -mthread |
d77de738 ML |
1481 | -municode -mwin32 -mwindows -fno-set-stack-executable} |
1482 | ||
1483 | @emph{Xstormy16 Options} | |
1484 | @gccoptlist{-msim} | |
1485 | ||
1486 | @emph{Xtensa Options} | |
43b72ede AA |
1487 | @gccoptlist{-mconst16 -mno-const16 |
1488 | -mfused-madd -mno-fused-madd | |
1489 | -mforce-no-pic | |
1490 | -mserialize-volatile -mno-serialize-volatile | |
1491 | -mtext-section-literals -mno-text-section-literals | |
1492 | -mauto-litpools -mno-auto-litpools | |
1493 | -mtarget-align -mno-target-align | |
1494 | -mlongcalls -mno-longcalls | |
1495 | -mabi=@var{abi-type} | |
675b390e MF |
1496 | -mextra-l32r-costs=@var{cycles} |
1497 | -mstrict-align -mno-strict-align} | |
d77de738 ML |
1498 | |
1499 | @emph{zSeries Options} | |
1500 | See S/390 and zSeries Options. | |
1501 | @end table | |
1502 | ||
1503 | ||
1504 | @node Overall Options | |
1505 | @section Options Controlling the Kind of Output | |
1506 | ||
1507 | Compilation can involve up to four stages: preprocessing, compilation | |
1508 | proper, assembly and linking, always in that order. GCC is capable of | |
1509 | preprocessing and compiling several files either into several | |
1510 | assembler input files, or into one assembler input file; then each | |
1511 | assembler input file produces an object file, and linking combines all | |
1512 | the object files (those newly compiled, and those specified as input) | |
1513 | into an executable file. | |
1514 | ||
1515 | @cindex file name suffix | |
1516 | For any given input file, the file name suffix determines what kind of | |
1517 | compilation is done: | |
1518 | ||
1519 | @table @gcctabopt | |
1520 | @item @var{file}.c | |
1521 | C source code that must be preprocessed. | |
1522 | ||
1523 | @item @var{file}.i | |
1524 | C source code that should not be preprocessed. | |
1525 | ||
1526 | @item @var{file}.ii | |
1527 | C++ source code that should not be preprocessed. | |
1528 | ||
1529 | @item @var{file}.m | |
1530 | Objective-C source code. Note that you must link with the @file{libobjc} | |
1531 | library to make an Objective-C program work. | |
1532 | ||
1533 | @item @var{file}.mi | |
1534 | Objective-C source code that should not be preprocessed. | |
1535 | ||
1536 | @item @var{file}.mm | |
1537 | @itemx @var{file}.M | |
1538 | Objective-C++ source code. Note that you must link with the @file{libobjc} | |
1539 | library to make an Objective-C++ program work. Note that @samp{.M} refers | |
1540 | to a literal capital M@. | |
1541 | ||
1542 | @item @var{file}.mii | |
1543 | Objective-C++ source code that should not be preprocessed. | |
1544 | ||
1545 | @item @var{file}.h | |
1546 | C, C++, Objective-C or Objective-C++ header file to be turned into a | |
1547 | precompiled header (default), or C, C++ header file to be turned into an | |
1548 | Ada spec (via the @option{-fdump-ada-spec} switch). | |
1549 | ||
1550 | @item @var{file}.cc | |
1551 | @itemx @var{file}.cp | |
1552 | @itemx @var{file}.cxx | |
1553 | @itemx @var{file}.cpp | |
1554 | @itemx @var{file}.CPP | |
1555 | @itemx @var{file}.c++ | |
1556 | @itemx @var{file}.C | |
1557 | C++ source code that must be preprocessed. Note that in @samp{.cxx}, | |
1558 | the last two letters must both be literally @samp{x}. Likewise, | |
1559 | @samp{.C} refers to a literal capital C@. | |
1560 | ||
1561 | @item @var{file}.mm | |
1562 | @itemx @var{file}.M | |
1563 | Objective-C++ source code that must be preprocessed. | |
1564 | ||
1565 | @item @var{file}.mii | |
1566 | Objective-C++ source code that should not be preprocessed. | |
1567 | ||
1568 | @item @var{file}.hh | |
1569 | @itemx @var{file}.H | |
1570 | @itemx @var{file}.hp | |
1571 | @itemx @var{file}.hxx | |
1572 | @itemx @var{file}.hpp | |
1573 | @itemx @var{file}.HPP | |
1574 | @itemx @var{file}.h++ | |
1575 | @itemx @var{file}.tcc | |
1576 | C++ header file to be turned into a precompiled header or Ada spec. | |
1577 | ||
1578 | @item @var{file}.f | |
1579 | @itemx @var{file}.for | |
1580 | @itemx @var{file}.ftn | |
1581 | Fixed form Fortran source code that should not be preprocessed. | |
1582 | ||
1583 | @item @var{file}.F | |
1584 | @itemx @var{file}.FOR | |
1585 | @itemx @var{file}.fpp | |
1586 | @itemx @var{file}.FPP | |
1587 | @itemx @var{file}.FTN | |
1588 | Fixed form Fortran source code that must be preprocessed (with the traditional | |
1589 | preprocessor). | |
1590 | ||
1591 | @item @var{file}.f90 | |
1592 | @itemx @var{file}.f95 | |
1593 | @itemx @var{file}.f03 | |
1594 | @itemx @var{file}.f08 | |
1595 | Free form Fortran source code that should not be preprocessed. | |
1596 | ||
1597 | @item @var{file}.F90 | |
1598 | @itemx @var{file}.F95 | |
1599 | @itemx @var{file}.F03 | |
1600 | @itemx @var{file}.F08 | |
1601 | Free form Fortran source code that must be preprocessed (with the | |
1602 | traditional preprocessor). | |
1603 | ||
1604 | @item @var{file}.go | |
1605 | Go source code. | |
1606 | ||
1607 | @item @var{file}.d | |
1608 | D source code. | |
1609 | ||
1610 | @item @var{file}.di | |
1611 | D interface file. | |
1612 | ||
1613 | @item @var{file}.dd | |
1614 | D documentation code (Ddoc). | |
1615 | ||
1616 | @item @var{file}.ads | |
1617 | Ada source code file that contains a library unit declaration (a | |
1618 | declaration of a package, subprogram, or generic, or a generic | |
1619 | instantiation), or a library unit renaming declaration (a package, | |
1620 | generic, or subprogram renaming declaration). Such files are also | |
1621 | called @dfn{specs}. | |
1622 | ||
1623 | @item @var{file}.adb | |
1624 | Ada source code file containing a library unit body (a subprogram or | |
1625 | package body). Such files are also called @dfn{bodies}. | |
1626 | ||
1627 | @c GCC also knows about some suffixes for languages not yet included: | |
1628 | @c Ratfor: | |
1629 | @c @var{file}.r | |
1630 | ||
1631 | @item @var{file}.s | |
1632 | Assembler code. | |
1633 | ||
1634 | @item @var{file}.S | |
1635 | @itemx @var{file}.sx | |
1636 | Assembler code that must be preprocessed. | |
1637 | ||
1638 | @item @var{other} | |
1639 | An object file to be fed straight into linking. | |
1640 | Any file name with no recognized suffix is treated this way. | |
1641 | @end table | |
1642 | ||
1643 | @opindex x | |
1644 | You can specify the input language explicitly with the @option{-x} option: | |
1645 | ||
1646 | @table @gcctabopt | |
1647 | @item -x @var{language} | |
1648 | Specify explicitly the @var{language} for the following input files | |
1649 | (rather than letting the compiler choose a default based on the file | |
1650 | name suffix). This option applies to all following input files until | |
1651 | the next @option{-x} option. Possible values for @var{language} are: | |
1652 | @smallexample | |
1653 | c c-header cpp-output | |
1654 | c++ c++-header c++-system-header c++-user-header c++-cpp-output | |
1655 | objective-c objective-c-header objective-c-cpp-output | |
1656 | objective-c++ objective-c++-header objective-c++-cpp-output | |
1657 | assembler assembler-with-cpp | |
1658 | ada | |
1659 | d | |
1660 | f77 f77-cpp-input f95 f95-cpp-input | |
1661 | go | |
1662 | @end smallexample | |
1663 | ||
1664 | @item -x none | |
1665 | Turn off any specification of a language, so that subsequent files are | |
1666 | handled according to their file name suffixes (as they are if @option{-x} | |
1667 | has not been used at all). | |
1668 | @end table | |
1669 | ||
1670 | If you only want some of the stages of compilation, you can use | |
1671 | @option{-x} (or filename suffixes) to tell @command{gcc} where to start, and | |
1672 | one of the options @option{-c}, @option{-S}, or @option{-E} to say where | |
1673 | @command{gcc} is to stop. Note that some combinations (for example, | |
1674 | @samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all. | |
1675 | ||
1676 | @table @gcctabopt | |
d77de738 | 1677 | @opindex c |
ddf6fe37 | 1678 | @item -c |
d77de738 ML |
1679 | Compile or assemble the source files, but do not link. The linking |
1680 | stage simply is not done. The ultimate output is in the form of an | |
1681 | object file for each source file. | |
1682 | ||
1683 | By default, the object file name for a source file is made by replacing | |
1684 | the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}. | |
1685 | ||
1686 | Unrecognized input files, not requiring compilation or assembly, are | |
1687 | ignored. | |
1688 | ||
d77de738 | 1689 | @opindex S |
ddf6fe37 | 1690 | @item -S |
d77de738 ML |
1691 | Stop after the stage of compilation proper; do not assemble. The output |
1692 | is in the form of an assembler code file for each non-assembler input | |
1693 | file specified. | |
1694 | ||
1695 | By default, the assembler file name for a source file is made by | |
1696 | replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}. | |
1697 | ||
1698 | Input files that don't require compilation are ignored. | |
1699 | ||
d77de738 | 1700 | @opindex E |
ddf6fe37 | 1701 | @item -E |
d77de738 ML |
1702 | Stop after the preprocessing stage; do not run the compiler proper. The |
1703 | output is in the form of preprocessed source code, which is sent to the | |
1704 | standard output. | |
1705 | ||
1706 | Input files that don't require preprocessing are ignored. | |
1707 | ||
1708 | @cindex output file option | |
d77de738 | 1709 | @opindex o |
ddf6fe37 | 1710 | @item -o @var{file} |
d77de738 ML |
1711 | Place the primary output in file @var{file}. This applies to whatever |
1712 | sort of output is being produced, whether it be an executable file, an | |
1713 | object file, an assembler file or preprocessed C code. | |
1714 | ||
1715 | If @option{-o} is not specified, the default is to put an executable | |
1716 | file in @file{a.out}, the object file for | |
1717 | @file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its | |
1718 | assembler file in @file{@var{source}.s}, a precompiled header file in | |
1719 | @file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on | |
1720 | standard output. | |
1721 | ||
1722 | Though @option{-o} names only the primary output, it also affects the | |
1723 | naming of auxiliary and dump outputs. See the examples below. Unless | |
1724 | overridden, both auxiliary outputs and dump outputs are placed in the | |
1725 | same directory as the primary output. In auxiliary outputs, the suffix | |
1726 | of the input file is replaced with that of the auxiliary output file | |
1727 | type; in dump outputs, the suffix of the dump file is appended to the | |
1728 | input file suffix. In compilation commands, the base name of both | |
1729 | auxiliary and dump outputs is that of the primary output; in compile and | |
1730 | link commands, the primary output name, minus the executable suffix, is | |
1731 | combined with the input file name. If both share the same base name, | |
1732 | disregarding the suffix, the result of the combination is that base | |
1733 | name, otherwise, they are concatenated, separated by a dash. | |
1734 | ||
1735 | @smallexample | |
1736 | gcc -c foo.c ... | |
1737 | @end smallexample | |
1738 | ||
1739 | will use @file{foo.o} as the primary output, and place aux outputs and | |
1740 | dumps next to it, e.g., aux file @file{foo.dwo} for | |
1741 | @option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for | |
1742 | @option{-fdump-rtl-final}. | |
1743 | ||
1744 | If a non-linker output file is explicitly specified, aux and dump files | |
1745 | by default take the same base name: | |
1746 | ||
1747 | @smallexample | |
1748 | gcc -c foo.c -o dir/foobar.o ... | |
1749 | @end smallexample | |
1750 | ||
1751 | will name aux outputs @file{dir/foobar.*} and dump outputs | |
1752 | @file{dir/foobar.c.*}. | |
1753 | ||
1754 | A linker output will instead prefix aux and dump outputs: | |
1755 | ||
1756 | @smallexample | |
1757 | gcc foo.c bar.c -o dir/foobar ... | |
1758 | @end smallexample | |
1759 | ||
1760 | will generally name aux outputs @file{dir/foobar-foo.*} and | |
1761 | @file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and | |
1762 | @file{dir/foobar-bar.c.*}. | |
1763 | ||
1764 | The one exception to the above is when the executable shares the base | |
1765 | name with the single input: | |
1766 | ||
1767 | @smallexample | |
1768 | gcc foo.c -o dir/foo ... | |
1769 | @end smallexample | |
1770 | ||
1771 | in which case aux outputs are named @file{dir/foo.*} and dump outputs | |
1772 | named @file{dir/foo.c.*}. | |
1773 | ||
1774 | The location and the names of auxiliary and dump outputs can be adjusted | |
1775 | by the options @option{-dumpbase}, @option{-dumpbase-ext}, | |
1776 | @option{-dumpdir}, @option{-save-temps=cwd}, and | |
1777 | @option{-save-temps=obj}. | |
1778 | ||
1779 | ||
d77de738 | 1780 | @opindex dumpbase |
ddf6fe37 | 1781 | @item -dumpbase @var{dumpbase} |
d77de738 ML |
1782 | This option sets the base name for auxiliary and dump output files. It |
1783 | does not affect the name of the primary output file. Intermediate | |
1784 | outputs, when preserved, are not regarded as primary outputs, but as | |
1785 | auxiliary outputs: | |
1786 | ||
1787 | @smallexample | |
1788 | gcc -save-temps -S foo.c | |
1789 | @end smallexample | |
1790 | ||
1791 | saves the (no longer) temporary preprocessed file in @file{foo.i}, and | |
1792 | then compiles to the (implied) output file @file{foo.s}, whereas: | |
1793 | ||
1794 | @smallexample | |
1795 | gcc -save-temps -dumpbase save-foo -c foo.c | |
1796 | @end smallexample | |
1797 | ||
1798 | preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now | |
1799 | an intermediate, thus auxiliary output), and then assembles to the | |
1800 | (implied) output file @file{foo.o}. | |
1801 | ||
1802 | Absent this option, dump and aux files take their names from the input | |
1803 | file, or from the (non-linker) output file, if one is explicitly | |
1804 | specified: dump output files (e.g. those requested by @option{-fdump-*} | |
1805 | options) with the input name suffix, and aux output files (those | |
1806 | requested by other non-dump options, e.g. @code{-save-temps}, | |
1807 | @code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it. | |
1808 | ||
1809 | Similar suffix differentiation of dump and aux outputs can be attained | |
1810 | for explicitly-given @option{-dumpbase basename.suf} by also specifying | |
1811 | @option{-dumpbase-ext .suf}. | |
1812 | ||
1813 | If @var{dumpbase} is explicitly specified with any directory component, | |
1814 | any @var{dumppfx} specification (e.g. @option{-dumpdir} or | |
1815 | @option{-save-temps=*}) is ignored, and instead of appending to it, | |
1816 | @var{dumpbase} fully overrides it: | |
1817 | ||
1818 | @smallexample | |
1819 | gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \ | |
1820 | -dumpdir pfx- -save-temps=cwd ... | |
1821 | @end smallexample | |
1822 | ||
1823 | creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding | |
1824 | @file{dir/} in @option{-o}, the @file{./} prefix implied by | |
1825 | @option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}. | |
1826 | ||
1827 | When @option{-dumpbase} is specified in a command that compiles multiple | |
1828 | inputs, or that compiles and then links, it may be combined with | |
1829 | @var{dumppfx}, as specified under @option{-dumpdir}. Then, each input | |
1830 | file is compiled using the combined @var{dumppfx}, and default values | |
1831 | for @var{dumpbase} and @var{auxdropsuf} are computed for each input | |
1832 | file: | |
1833 | ||
1834 | @smallexample | |
1835 | gcc foo.c bar.c -c -dumpbase main ... | |
1836 | @end smallexample | |
1837 | ||
1838 | creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids | |
1839 | overwriting the auxiliary and dump outputs by using the @var{dumpbase} | |
1840 | as a prefix, creating auxiliary and dump outputs named @file{main-foo.*} | |
1841 | and @file{main-bar.*}. | |
1842 | ||
1843 | An empty string specified as @var{dumpbase} avoids the influence of the | |
1844 | output basename in the naming of auxiliary and dump outputs during | |
1845 | compilation, computing default values : | |
1846 | ||
1847 | @smallexample | |
1848 | gcc -c foo.c -o dir/foobar.o -dumpbase '' ... | |
1849 | @end smallexample | |
1850 | ||
1851 | will name aux outputs @file{dir/foo.*} and dump outputs | |
1852 | @file{dir/foo.c.*}. Note how their basenames are taken from the input | |
1853 | name, but the directory still defaults to that of the output. | |
1854 | ||
1855 | The empty-string dumpbase does not prevent the use of the output | |
1856 | basename for outputs during linking: | |
1857 | ||
1858 | @smallexample | |
1859 | gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ... | |
1860 | @end smallexample | |
1861 | ||
1862 | The compilation of the source files will name auxiliary outputs | |
1863 | @file{dir/foo.*} and @file{dir/bar.*}, and dump outputs | |
1864 | @file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during | |
1865 | linking will use @file{dir/foobar.} as the prefix for dumps and | |
1866 | auxiliary files. | |
1867 | ||
1868 | ||
d77de738 | 1869 | @opindex dumpbase-ext |
ddf6fe37 | 1870 | @item -dumpbase-ext @var{auxdropsuf} |
d77de738 ML |
1871 | When forming the name of an auxiliary (but not a dump) output file, drop |
1872 | trailing @var{auxdropsuf} from @var{dumpbase} before appending any | |
1873 | suffixes. If not specified, this option defaults to the suffix of a | |
1874 | default @var{dumpbase}, i.e., the suffix of the input file when | |
1875 | @option{-dumpbase} is not present in the command line, or @var{dumpbase} | |
1876 | is combined with @var{dumppfx}. | |
1877 | ||
1878 | @smallexample | |
1879 | gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ... | |
1880 | @end smallexample | |
1881 | ||
1882 | creates @file{dir/foo.o} as the main output, and generates auxiliary | |
1883 | outputs in @file{dir/x-foo.*}, taking the location of the primary | |
1884 | output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump | |
1885 | outputs retain the suffix: @file{dir/x-foo.c.*}. | |
1886 | ||
1887 | This option is disregarded if it does not match the suffix of a | |
1888 | specified @var{dumpbase}, except as an alternative to the executable | |
1889 | suffix when appending the linker output base name to @var{dumppfx}, as | |
1890 | specified below: | |
1891 | ||
1892 | @smallexample | |
1893 | gcc foo.c bar.c -o main.out -dumpbase-ext .out ... | |
1894 | @end smallexample | |
1895 | ||
1896 | creates @file{main.out} as the primary output, and avoids overwriting | |
1897 | the auxiliary and dump outputs by using the executable name minus | |
1898 | @var{auxdropsuf} as a prefix, creating auxiliary outputs named | |
1899 | @file{main-foo.*} and @file{main-bar.*} and dump outputs named | |
1900 | @file{main-foo.c.*} and @file{main-bar.c.*}. | |
1901 | ||
1902 | ||
d77de738 | 1903 | @opindex dumpdir |
ddf6fe37 | 1904 | @item -dumpdir @var{dumppfx} |
d77de738 ML |
1905 | When forming the name of an auxiliary or dump output file, use |
1906 | @var{dumppfx} as a prefix: | |
1907 | ||
1908 | @smallexample | |
1909 | gcc -dumpdir pfx- -c foo.c ... | |
1910 | @end smallexample | |
1911 | ||
1912 | creates @file{foo.o} as the primary output, and auxiliary outputs named | |
1913 | @file{pfx-foo.*}, combining the given @var{dumppfx} with the default | |
1914 | @var{dumpbase} derived from the default primary output, derived in turn | |
1915 | from the input name. Dump outputs also take the input name suffix: | |
1916 | @file{pfx-foo.c.*}. | |
1917 | ||
1918 | If @var{dumppfx} is to be used as a directory name, it must end with a | |
1919 | directory separator: | |
1920 | ||
1921 | @smallexample | |
1922 | gcc -dumpdir dir/ -c foo.c -o obj/bar.o ... | |
1923 | @end smallexample | |
1924 | ||
1925 | creates @file{obj/bar.o} as the primary output, and auxiliary outputs | |
1926 | named @file{dir/bar.*}, combining the given @var{dumppfx} with the | |
1927 | default @var{dumpbase} derived from the primary output name. Dump | |
1928 | outputs also take the input name suffix: @file{dir/bar.c.*}. | |
1929 | ||
1930 | It defaults to the location of the output file, unless the output | |
1931 | file is a special file like @code{/dev/null}. Options | |
1932 | @option{-save-temps=cwd} and @option{-save-temps=obj} override this | |
1933 | default, just like an explicit @option{-dumpdir} option. In case | |
1934 | multiple such options are given, the last one prevails: | |
1935 | ||
1936 | @smallexample | |
1937 | gcc -dumpdir pfx- -c foo.c -save-temps=obj ... | |
1938 | @end smallexample | |
1939 | ||
1940 | outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because | |
1941 | @option{-save-temps=*} overrides the @var{dumppfx} given by the earlier | |
1942 | @option{-dumpdir} option. It does not matter that @option{=obj} is the | |
1943 | default for @option{-save-temps}, nor that the output directory is | |
1944 | implicitly the current directory. Dump outputs are named | |
1945 | @file{foo.c.*}. | |
1946 | ||
1947 | When compiling from multiple input files, if @option{-dumpbase} is | |
1948 | specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash | |
1949 | are appended to (or override, if containing any directory components) an | |
1950 | explicit or defaulted @var{dumppfx}, so that each of the multiple | |
1951 | compilations gets differently-named aux and dump outputs. | |
1952 | ||
1953 | @smallexample | |
1954 | gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ... | |
1955 | @end smallexample | |
1956 | ||
1957 | outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and | |
1958 | @file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}. | |
1959 | Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*} | |
1960 | and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the | |
1961 | single-input compilation: | |
1962 | ||
1963 | @smallexample | |
1964 | gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ... | |
1965 | @end smallexample | |
1966 | ||
1967 | that, applying @option{-dumpbase} to a single source, does not compute | |
1968 | and append a separate @var{dumpbase} per input file. Its auxiliary and | |
1969 | dump outputs go in @file{dir/pfx-main.*}. | |
1970 | ||
1971 | When compiling and then linking from multiple input files, a defaulted | |
1972 | or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}- | |
1973 | transformation above (e.g. the compilation of @file{foo.c} and | |
1974 | @file{bar.c} above, but without @option{-c}). If neither | |
1975 | @option{-dumpdir} nor @option{-dumpbase} are given, the linker output | |
1976 | base name, minus @var{auxdropsuf}, if specified, or the executable | |
1977 | suffix otherwise, plus a dash is appended to the default @var{dumppfx} | |
1978 | instead. Note, however, that unlike earlier cases of linking: | |
1979 | ||
1980 | @smallexample | |
1981 | gcc foo.c bar.c -dumpdir dir/pfx- -o main ... | |
1982 | @end smallexample | |
1983 | ||
1984 | does not append the output name @file{main} to @var{dumppfx}, because | |
1985 | @option{-dumpdir} is explicitly specified. The goal is that the | |
1986 | explicitly-specified @var{dumppfx} may contain the specified output name | |
1987 | as part of the prefix, if desired; only an explicitly-specified | |
1988 | @option{-dumpbase} would be combined with it, in order to avoid simply | |
1989 | discarding a meaningful option. | |
1990 | ||
1991 | When compiling and then linking from a single input file, the linker | |
1992 | output base name will only be appended to the default @var{dumppfx} as | |
1993 | above if it does not share the base name with the single input file | |
1994 | name. This has been covered in single-input linking cases above, but | |
1995 | not with an explicit @option{-dumpdir} that inhibits the combination, | |
1996 | even if overridden by @option{-save-temps=*}: | |
1997 | ||
1998 | @smallexample | |
1999 | gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ... | |
2000 | @end smallexample | |
2001 | ||
2002 | Auxiliary outputs are named @file{foo.*}, and dump outputs | |
2003 | @file{foo.c.*}, in the current working directory as ultimately requested | |
2004 | by @option{-save-temps=cwd}. | |
2005 | ||
2006 | Summing it all up for an intuitive though slightly imprecise data flow: | |
2007 | the primary output name is broken into a directory part and a basename | |
2008 | part; @var{dumppfx} is set to the former, unless overridden by | |
2009 | @option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set | |
2010 | to the latter, unless overriden by @option{-dumpbase}. If there are | |
2011 | multiple inputs or linking, this @var{dumpbase} may be combined with | |
2012 | @var{dumppfx} and taken from each input file. Auxiliary output names | |
2013 | for each input are formed by combining @var{dumppfx}, @var{dumpbase} | |
2014 | minus suffix, and the auxiliary output suffix; dump output names are | |
2015 | only different in that the suffix from @var{dumpbase} is retained. | |
2016 | ||
2017 | When it comes to auxiliary and dump outputs created during LTO | |
2018 | recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as | |
2019 | given or as derived from the linker output name but not from inputs, | |
2020 | even in cases in which this combination would not otherwise be used as | |
2021 | such, is passed down with a trailing period replacing the compiler-added | |
2022 | dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper}; | |
2023 | being involved in linking, this program does not normally get any | |
2024 | @option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them. | |
2025 | ||
2026 | When running sub-compilers, @command{lto-wrapper} appends LTO stage | |
2027 | names to the received @var{dumppfx}, ensures it contains a directory | |
2028 | component so that it overrides any @option{-dumpdir}, and passes that as | |
2029 | @option{-dumpbase} to sub-compilers. | |
2030 | ||
d77de738 | 2031 | @opindex v |
ddf6fe37 | 2032 | @item -v |
d77de738 ML |
2033 | Print (on standard error output) the commands executed to run the stages |
2034 | of compilation. Also print the version number of the compiler driver | |
2035 | program and of the preprocessor and the compiler proper. | |
2036 | ||
d77de738 | 2037 | @opindex ### |
ddf6fe37 | 2038 | @item -### |
d77de738 ML |
2039 | Like @option{-v} except the commands are not executed and arguments |
2040 | are quoted unless they contain only alphanumeric characters or @code{./-_}. | |
2041 | This is useful for shell scripts to capture the driver-generated command lines. | |
2042 | ||
d77de738 | 2043 | @opindex help |
ddf6fe37 | 2044 | @item --help |
d77de738 ML |
2045 | Print (on the standard output) a description of the command-line options |
2046 | understood by @command{gcc}. If the @option{-v} option is also specified | |
2047 | then @option{--help} is also passed on to the various processes | |
2048 | invoked by @command{gcc}, so that they can display the command-line options | |
2049 | they accept. If the @option{-Wextra} option has also been specified | |
2050 | (prior to the @option{--help} option), then command-line options that | |
2051 | have no documentation associated with them are also displayed. | |
2052 | ||
d77de738 | 2053 | @opindex target-help |
ddf6fe37 | 2054 | @item --target-help |
d77de738 ML |
2055 | Print (on the standard output) a description of target-specific command-line |
2056 | options for each tool. For some targets extra target-specific | |
2057 | information may also be printed. | |
2058 | ||
2059 | @item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]} | |
2060 | Print (on the standard output) a description of the command-line | |
2061 | options understood by the compiler that fit into all specified classes | |
2062 | and qualifiers. These are the supported classes: | |
2063 | ||
2064 | @table @asis | |
2065 | @item @samp{optimizers} | |
2066 | Display all of the optimization options supported by the | |
2067 | compiler. | |
2068 | ||
2069 | @item @samp{warnings} | |
2070 | Display all of the options controlling warning messages | |
2071 | produced by the compiler. | |
2072 | ||
2073 | @item @samp{target} | |
2074 | Display target-specific options. Unlike the | |
2075 | @option{--target-help} option however, target-specific options of the | |
2076 | linker and assembler are not displayed. This is because those | |
2077 | tools do not currently support the extended @option{--help=} syntax. | |
2078 | ||
2079 | @item @samp{params} | |
2080 | Display the values recognized by the @option{--param} | |
2081 | option. | |
2082 | ||
2083 | @item @var{language} | |
2084 | Display the options supported for @var{language}, where | |
2085 | @var{language} is the name of one of the languages supported in this | |
2086 | version of GCC@. If an option is supported by all languages, one needs | |
2087 | to select @samp{common} class. | |
2088 | ||
2089 | @item @samp{common} | |
2090 | Display the options that are common to all languages. | |
2091 | @end table | |
2092 | ||
2093 | These are the supported qualifiers: | |
2094 | ||
2095 | @table @asis | |
2096 | @item @samp{undocumented} | |
2097 | Display only those options that are undocumented. | |
2098 | ||
2099 | @item @samp{joined} | |
2100 | Display options taking an argument that appears after an equal | |
2101 | sign in the same continuous piece of text, such as: | |
2102 | @samp{--help=target}. | |
2103 | ||
2104 | @item @samp{separate} | |
2105 | Display options taking an argument that appears as a separate word | |
2106 | following the original option, such as: @samp{-o output-file}. | |
2107 | @end table | |
2108 | ||
2109 | Thus for example to display all the undocumented target-specific | |
2110 | switches supported by the compiler, use: | |
2111 | ||
2112 | @smallexample | |
2113 | --help=target,undocumented | |
2114 | @end smallexample | |
2115 | ||
2116 | The sense of a qualifier can be inverted by prefixing it with the | |
2117 | @samp{^} character, so for example to display all binary warning | |
2118 | options (i.e., ones that are either on or off and that do not take an | |
2119 | argument) that have a description, use: | |
2120 | ||
2121 | @smallexample | |
2122 | --help=warnings,^joined,^undocumented | |
2123 | @end smallexample | |
2124 | ||
2125 | The argument to @option{--help=} should not consist solely of inverted | |
2126 | qualifiers. | |
2127 | ||
2128 | Combining several classes is possible, although this usually | |
2129 | restricts the output so much that there is nothing to display. One | |
2130 | case where it does work, however, is when one of the classes is | |
2131 | @var{target}. For example, to display all the target-specific | |
2132 | optimization options, use: | |
2133 | ||
2134 | @smallexample | |
2135 | --help=target,optimizers | |
2136 | @end smallexample | |
2137 | ||
2138 | The @option{--help=} option can be repeated on the command line. Each | |
2139 | successive use displays its requested class of options, skipping | |
2140 | those that have already been displayed. If @option{--help} is also | |
2141 | specified anywhere on the command line then this takes precedence | |
2142 | over any @option{--help=} option. | |
2143 | ||
2144 | If the @option{-Q} option appears on the command line before the | |
2145 | @option{--help=} option, then the descriptive text displayed by | |
2146 | @option{--help=} is changed. Instead of describing the displayed | |
2147 | options, an indication is given as to whether the option is enabled, | |
2148 | disabled or set to a specific value (assuming that the compiler | |
2149 | knows this at the point where the @option{--help=} option is used). | |
2150 | ||
2151 | Here is a truncated example from the ARM port of @command{gcc}: | |
2152 | ||
2153 | @smallexample | |
2154 | % gcc -Q -mabi=2 --help=target -c | |
2155 | The following options are target specific: | |
2156 | -mabi= 2 | |
2157 | -mabort-on-noreturn [disabled] | |
2158 | -mapcs [disabled] | |
2159 | @end smallexample | |
2160 | ||
2161 | The output is sensitive to the effects of previous command-line | |
2162 | options, so for example it is possible to find out which optimizations | |
2163 | are enabled at @option{-O2} by using: | |
2164 | ||
2165 | @smallexample | |
2166 | -Q -O2 --help=optimizers | |
2167 | @end smallexample | |
2168 | ||
2169 | Alternatively you can discover which binary optimizations are enabled | |
2170 | by @option{-O3} by using: | |
2171 | ||
2172 | @smallexample | |
2173 | gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts | |
2174 | gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts | |
2175 | diff /tmp/O2-opts /tmp/O3-opts | grep enabled | |
2176 | @end smallexample | |
2177 | ||
d77de738 | 2178 | @opindex version |
ddf6fe37 | 2179 | @item --version |
d77de738 ML |
2180 | Display the version number and copyrights of the invoked GCC@. |
2181 | ||
d77de738 | 2182 | @opindex pass-exit-codes |
ddf6fe37 | 2183 | @item -pass-exit-codes |
d77de738 ML |
2184 | Normally the @command{gcc} program exits with the code of 1 if any |
2185 | phase of the compiler returns a non-success return code. If you specify | |
2186 | @option{-pass-exit-codes}, the @command{gcc} program instead returns with | |
2187 | the numerically highest error produced by any phase returning an error | |
2188 | indication. The C, C++, and Fortran front ends return 4 if an internal | |
2189 | compiler error is encountered. | |
2190 | ||
d77de738 | 2191 | @opindex pipe |
ddf6fe37 | 2192 | @item -pipe |
d77de738 ML |
2193 | Use pipes rather than temporary files for communication between the |
2194 | various stages of compilation. This fails to work on some systems where | |
2195 | the assembler is unable to read from a pipe; but the GNU assembler has | |
2196 | no trouble. | |
2197 | ||
d77de738 | 2198 | @opindex specs |
ddf6fe37 | 2199 | @item -specs=@var{file} |
d77de738 ML |
2200 | Process @var{file} after the compiler reads in the standard @file{specs} |
2201 | file, in order to override the defaults which the @command{gcc} driver | |
2202 | program uses when determining what switches to pass to @command{cc1}, | |
2203 | @command{cc1plus}, @command{as}, @command{ld}, etc. More than one | |
2204 | @option{-specs=@var{file}} can be specified on the command line, and they | |
2205 | are processed in order, from left to right. @xref{Spec Files}, for | |
2206 | information about the format of the @var{file}. | |
2207 | ||
d77de738 | 2208 | @opindex wrapper |
ddf6fe37 | 2209 | @item -wrapper |
d77de738 ML |
2210 | Invoke all subcommands under a wrapper program. The name of the |
2211 | wrapper program and its parameters are passed as a comma separated | |
2212 | list. | |
2213 | ||
2214 | @smallexample | |
2215 | gcc -c t.c -wrapper gdb,--args | |
2216 | @end smallexample | |
2217 | ||
2218 | @noindent | |
2219 | This invokes all subprograms of @command{gcc} under | |
2220 | @samp{gdb --args}, thus the invocation of @command{cc1} is | |
2221 | @samp{gdb --args cc1 @dots{}}. | |
2222 | ||
d77de738 | 2223 | @opindex ffile-prefix-map |
ddf6fe37 | 2224 | @item -ffile-prefix-map=@var{old}=@var{new} |
d77de738 ML |
2225 | When compiling files residing in directory @file{@var{old}}, record |
2226 | any references to them in the result of the compilation as if the | |
2227 | files resided in directory @file{@var{new}} instead. Specifying this | |
2228 | option is equivalent to specifying all the individual | |
2229 | @option{-f*-prefix-map} options. This can be used to make reproducible | |
11543b27 | 2230 | builds that are location independent. Directories referenced by |
2eb0191a JJ |
2231 | directives are not affected by these options. See also |
2232 | @option{-fmacro-prefix-map}, @option{-fdebug-prefix-map}, | |
2233 | @option{-fprofile-prefix-map} and @option{-fcanon-prefix-map}. | |
2234 | ||
2eb0191a | 2235 | @opindex fcanon-prefix-map |
e54b01a1 | 2236 | @item -fcanon-prefix-map |
2eb0191a JJ |
2237 | For the @option{-f*-prefix-map} options normally comparison |
2238 | of @file{@var{old}} prefix against the filename that would be normally | |
2239 | referenced in the result of the compilation is done using textual | |
2240 | comparison of the prefixes, or ignoring character case for case insensitive | |
2241 | filesystems and considering slashes and backslashes as equal on DOS based | |
2242 | filesystems. The @option{-fcanon-prefix-map} causes such comparisons | |
2243 | to be done on canonicalized paths of @file{@var{old}} | |
2244 | and the referenced filename. | |
d77de738 | 2245 | |
d77de738 | 2246 | @opindex fplugin |
ddf6fe37 | 2247 | @item -fplugin=@var{name}.so |
d77de738 ML |
2248 | Load the plugin code in file @var{name}.so, assumed to be a |
2249 | shared object to be dlopen'd by the compiler. The base name of | |
2250 | the shared object file is used to identify the plugin for the | |
2251 | purposes of argument parsing (See | |
2252 | @option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below). | |
2253 | Each plugin should define the callback functions specified in the | |
2254 | Plugins API. | |
2255 | ||
d77de738 | 2256 | @opindex fplugin-arg |
ddf6fe37 | 2257 | @item -fplugin-arg-@var{name}-@var{key}=@var{value} |
d77de738 ML |
2258 | Define an argument called @var{key} with a value of @var{value} |
2259 | for the plugin called @var{name}. | |
2260 | ||
d77de738 | 2261 | @opindex fdump-ada-spec |
ddf6fe37 | 2262 | @item -fdump-ada-spec@r{[}-slim@r{]} |
d77de738 ML |
2263 | For C and C++ source and include files, generate corresponding Ada specs. |
2264 | @xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn, | |
2265 | GNAT User's Guide}, which provides detailed documentation on this feature. | |
2266 | ||
d77de738 | 2267 | @opindex fada-spec-parent |
ddf6fe37 | 2268 | @item -fada-spec-parent=@var{unit} |
d77de738 ML |
2269 | In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate |
2270 | Ada specs as child units of parent @var{unit}. | |
2271 | ||
d77de738 | 2272 | @opindex fdump-go-spec |
ddf6fe37 | 2273 | @item -fdump-go-spec=@var{file} |
d77de738 ML |
2274 | For input files in any language, generate corresponding Go |
2275 | declarations in @var{file}. This generates Go @code{const}, | |
2276 | @code{type}, @code{var}, and @code{func} declarations which may be a | |
2277 | useful way to start writing a Go interface to code written in some | |
2278 | other language. | |
2279 | ||
2280 | @include @value{srcdir}/../libiberty/at-file.texi | |
2281 | @end table | |
2282 | ||
2283 | @node Invoking G++ | |
2284 | @section Compiling C++ Programs | |
2285 | ||
2286 | @cindex suffixes for C++ source | |
2287 | @cindex C++ source file suffixes | |
2288 | C++ source files conventionally use one of the suffixes @samp{.C}, | |
2289 | @samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or | |
2290 | @samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp}, | |
2291 | @samp{.H}, or (for shared template code) @samp{.tcc}; and | |
2292 | preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes | |
2293 | files with these names and compiles them as C++ programs even if you | |
2294 | call the compiler the same way as for compiling C programs (usually | |
2295 | with the name @command{gcc}). | |
2296 | ||
2297 | @findex g++ | |
2298 | @findex c++ | |
2299 | However, the use of @command{gcc} does not add the C++ library. | |
2300 | @command{g++} is a program that calls GCC and automatically specifies linking | |
2301 | against the C++ library. It treats @samp{.c}, | |
2302 | @samp{.h} and @samp{.i} files as C++ source files instead of C source | |
2303 | files unless @option{-x} is used. This program is also useful when | |
2304 | precompiling a C header file with a @samp{.h} extension for use in C++ | |
2305 | compilations. On many systems, @command{g++} is also installed with | |
2306 | the name @command{c++}. | |
2307 | ||
2308 | @cindex invoking @command{g++} | |
2309 | When you compile C++ programs, you may specify many of the same | |
2310 | command-line options that you use for compiling programs in any | |
2311 | language; or command-line options meaningful for C and related | |
2312 | languages; or options that are meaningful only for C++ programs. | |
2313 | @xref{C Dialect Options,,Options Controlling C Dialect}, for | |
2314 | explanations of options for languages related to C@. | |
2315 | @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for | |
2316 | explanations of options that are meaningful only for C++ programs. | |
2317 | ||
2318 | @node C Dialect Options | |
2319 | @section Options Controlling C Dialect | |
2320 | @cindex dialect options | |
2321 | @cindex language dialect options | |
2322 | @cindex options, dialect | |
2323 | ||
2324 | The following options control the dialect of C (or languages derived | |
2325 | from C, such as C++, Objective-C and Objective-C++) that the compiler | |
2326 | accepts: | |
2327 | ||
2328 | @table @gcctabopt | |
2329 | @cindex ANSI support | |
2330 | @cindex ISO support | |
d77de738 | 2331 | @opindex ansi |
ddf6fe37 | 2332 | @item -ansi |
d77de738 ML |
2333 | In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is |
2334 | equivalent to @option{-std=c++98}. | |
2335 | ||
2336 | This turns off certain features of GCC that are incompatible with ISO | |
2337 | C90 (when compiling C code), or of standard C++ (when compiling C++ code), | |
2338 | such as the @code{asm} and @code{typeof} keywords, and | |
2339 | predefined macros such as @code{unix} and @code{vax} that identify the | |
2340 | type of system you are using. It also enables the undesirable and | |
2341 | rarely used ISO trigraph feature. For the C compiler, | |
2342 | it disables recognition of C++ style @samp{//} comments as well as | |
2343 | the @code{inline} keyword. | |
2344 | ||
2345 | The alternate keywords @code{__asm__}, @code{__extension__}, | |
2346 | @code{__inline__} and @code{__typeof__} continue to work despite | |
2347 | @option{-ansi}. You would not want to use them in an ISO C program, of | |
2348 | course, but it is useful to put them in header files that might be included | |
2349 | in compilations done with @option{-ansi}. Alternate predefined macros | |
2350 | such as @code{__unix__} and @code{__vax__} are also available, with or | |
2351 | without @option{-ansi}. | |
2352 | ||
2353 | The @option{-ansi} option does not cause non-ISO programs to be | |
2354 | rejected gratuitously. For that, @option{-Wpedantic} is required in | |
2355 | addition to @option{-ansi}. @xref{Warning Options}. | |
2356 | ||
2357 | The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi} | |
2358 | option is used. Some header files may notice this macro and refrain | |
2359 | from declaring certain functions or defining certain macros that the | |
2360 | ISO standard doesn't call for; this is to avoid interfering with any | |
2361 | programs that might use these names for other things. | |
2362 | ||
2363 | Functions that are normally built in but do not have semantics | |
2364 | defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in | |
2365 | functions when @option{-ansi} is used. @xref{Other Builtins,,Other | |
2366 | built-in functions provided by GCC}, for details of the functions | |
2367 | affected. | |
2368 | ||
d77de738 | 2369 | @opindex std |
ddf6fe37 | 2370 | @item -std= |
d77de738 ML |
2371 | Determine the language standard. @xref{Standards,,Language Standards |
2372 | Supported by GCC}, for details of these standard versions. This option | |
2373 | is currently only supported when compiling C or C++. | |
2374 | ||
2375 | The compiler can accept several base standards, such as @samp{c90} or | |
2376 | @samp{c++98}, and GNU dialects of those standards, such as | |
2377 | @samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the | |
2378 | compiler accepts all programs following that standard plus those | |
2379 | using GNU extensions that do not contradict it. For example, | |
2380 | @option{-std=c90} turns off certain features of GCC that are | |
2381 | incompatible with ISO C90, such as the @code{asm} and @code{typeof} | |
2382 | keywords, but not other GNU extensions that do not have a meaning in | |
2383 | ISO C90, such as omitting the middle term of a @code{?:} | |
2384 | expression. On the other hand, when a GNU dialect of a standard is | |
2385 | specified, all features supported by the compiler are enabled, even when | |
2386 | those features change the meaning of the base standard. As a result, some | |
2387 | strict-conforming programs may be rejected. The particular standard | |
2388 | is used by @option{-Wpedantic} to identify which features are GNU | |
2389 | extensions given that version of the standard. For example | |
2390 | @option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//} | |
2391 | comments, while @option{-std=gnu99 -Wpedantic} does not. | |
2392 | ||
2393 | A value for this option must be provided; possible values are | |
2394 | ||
2395 | @table @samp | |
2396 | @item c90 | |
2397 | @itemx c89 | |
2398 | @itemx iso9899:1990 | |
2399 | Support all ISO C90 programs (certain GNU extensions that conflict | |
2400 | with ISO C90 are disabled). Same as @option{-ansi} for C code. | |
2401 | ||
2402 | @item iso9899:199409 | |
2403 | ISO C90 as modified in amendment 1. | |
2404 | ||
2405 | @item c99 | |
2406 | @itemx c9x | |
2407 | @itemx iso9899:1999 | |
2408 | @itemx iso9899:199x | |
2409 | ISO C99. This standard is substantially completely supported, modulo | |
2410 | bugs and floating-point issues | |
2411 | (mainly but not entirely relating to optional C99 features from | |
2412 | Annexes F and G). See | |
2413 | @w{@uref{https://gcc.gnu.org/c99status.html}} for more information. The | |
2414 | names @samp{c9x} and @samp{iso9899:199x} are deprecated. | |
2415 | ||
2416 | @item c11 | |
2417 | @itemx c1x | |
2418 | @itemx iso9899:2011 | |
2419 | ISO C11, the 2011 revision of the ISO C standard. This standard is | |
2420 | substantially completely supported, modulo bugs, floating-point issues | |
2421 | (mainly but not entirely relating to optional C11 features from | |
2422 | Annexes F and G) and the optional Annexes K (Bounds-checking | |
2423 | interfaces) and L (Analyzability). The name @samp{c1x} is deprecated. | |
2424 | ||
2425 | @item c17 | |
2426 | @itemx c18 | |
2427 | @itemx iso9899:2017 | |
2428 | @itemx iso9899:2018 | |
2429 | ISO C17, the 2017 revision of the ISO C standard | |
2430 | (published in 2018). This standard is | |
2431 | same as C11 except for corrections of defects (all of which are also | |
2432 | applied with @option{-std=c11}) and a new value of | |
2433 | @code{__STDC_VERSION__}, and so is supported to the same extent as C11. | |
2434 | ||
fad61bf7 JM |
2435 | @item c23 |
2436 | @itemx c2x | |
2437 | @itemx iso9899:2024 | |
2438 | ISO C23, the 2023 revision of the ISO C standard (expected to be | |
2439 | published in 2024). The support for this version is experimental and | |
2440 | incomplete. The name @samp{c2x} is deprecated. | |
d77de738 ML |
2441 | |
2442 | @item gnu90 | |
2443 | @itemx gnu89 | |
2444 | GNU dialect of ISO C90 (including some C99 features). | |
2445 | ||
2446 | @item gnu99 | |
2447 | @itemx gnu9x | |
2448 | GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated. | |
2449 | ||
2450 | @item gnu11 | |
2451 | @itemx gnu1x | |
2452 | GNU dialect of ISO C11. | |
2453 | The name @samp{gnu1x} is deprecated. | |
2454 | ||
2455 | @item gnu17 | |
2456 | @itemx gnu18 | |
2457 | GNU dialect of ISO C17. This is the default for C code. | |
2458 | ||
fad61bf7 JM |
2459 | @item gnu23 |
2460 | @itemx gnu2x | |
d77de738 ML |
2461 | The next version of the ISO C standard, still under development, plus |
2462 | GNU extensions. The support for this version is experimental and | |
fad61bf7 | 2463 | incomplete. The name @samp{gnu2x} is deprecated. |
d77de738 ML |
2464 | |
2465 | @item c++98 | |
2466 | @itemx c++03 | |
2467 | The 1998 ISO C++ standard plus the 2003 technical corrigendum and some | |
2468 | additional defect reports. Same as @option{-ansi} for C++ code. | |
2469 | ||
2470 | @item gnu++98 | |
2471 | @itemx gnu++03 | |
2472 | GNU dialect of @option{-std=c++98}. | |
2473 | ||
2474 | @item c++11 | |
2475 | @itemx c++0x | |
2476 | The 2011 ISO C++ standard plus amendments. | |
2477 | The name @samp{c++0x} is deprecated. | |
2478 | ||
2479 | @item gnu++11 | |
2480 | @itemx gnu++0x | |
2481 | GNU dialect of @option{-std=c++11}. | |
2482 | The name @samp{gnu++0x} is deprecated. | |
2483 | ||
2484 | @item c++14 | |
2485 | @itemx c++1y | |
2486 | The 2014 ISO C++ standard plus amendments. | |
2487 | The name @samp{c++1y} is deprecated. | |
2488 | ||
2489 | @item gnu++14 | |
2490 | @itemx gnu++1y | |
2491 | GNU dialect of @option{-std=c++14}. | |
2492 | The name @samp{gnu++1y} is deprecated. | |
2493 | ||
2494 | @item c++17 | |
2495 | @itemx c++1z | |
2496 | The 2017 ISO C++ standard plus amendments. | |
2497 | The name @samp{c++1z} is deprecated. | |
2498 | ||
2499 | @item gnu++17 | |
2500 | @itemx gnu++1z | |
2501 | GNU dialect of @option{-std=c++17}. | |
2502 | This is the default for C++ code. | |
2503 | The name @samp{gnu++1z} is deprecated. | |
2504 | ||
2505 | @item c++20 | |
2506 | @itemx c++2a | |
2507 | The 2020 ISO C++ standard plus amendments. | |
2508 | Support is experimental, and could change in incompatible ways in | |
2509 | future releases. | |
2510 | The name @samp{c++2a} is deprecated. | |
2511 | ||
2512 | @item gnu++20 | |
2513 | @itemx gnu++2a | |
2514 | GNU dialect of @option{-std=c++20}. | |
2515 | Support is experimental, and could change in incompatible ways in | |
2516 | future releases. | |
2517 | The name @samp{gnu++2a} is deprecated. | |
2518 | ||
2519 | @item c++2b | |
2520 | @itemx c++23 | |
2521 | The next revision of the ISO C++ standard, planned for | |
2522 | 2023. Support is highly experimental, and will almost certainly | |
2523 | change in incompatible ways in future releases. | |
2524 | ||
2525 | @item gnu++2b | |
2526 | @itemx gnu++23 | |
2527 | GNU dialect of @option{-std=c++2b}. Support is highly experimental, | |
2528 | and will almost certainly change in incompatible ways in future | |
2529 | releases. | |
5388a43f MP |
2530 | |
2531 | @item c++2c | |
2532 | @itemx c++26 | |
2533 | The next revision of the ISO C++ standard, planned for | |
2534 | 2026. Support is highly experimental, and will almost certainly | |
2535 | change in incompatible ways in future releases. | |
2536 | ||
2537 | @item gnu++2c | |
2538 | @itemx gnu++26 | |
2539 | GNU dialect of @option{-std=c++2c}. Support is highly experimental, | |
2540 | and will almost certainly change in incompatible ways in future | |
2541 | releases. | |
d77de738 ML |
2542 | @end table |
2543 | ||
d77de738 | 2544 | @opindex aux-info |
ddf6fe37 | 2545 | @item -aux-info @var{filename} |
d77de738 ML |
2546 | Output to the given filename prototyped declarations for all functions |
2547 | declared and/or defined in a translation unit, including those in header | |
2548 | files. This option is silently ignored in any language other than C@. | |
2549 | ||
2550 | Besides declarations, the file indicates, in comments, the origin of | |
2551 | each declaration (source file and line), whether the declaration was | |
2552 | implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or | |
2553 | @samp{O} for old, respectively, in the first character after the line | |
2554 | number and the colon), and whether it came from a declaration or a | |
2555 | definition (@samp{C} or @samp{F}, respectively, in the following | |
2556 | character). In the case of function definitions, a K&R-style list of | |
2557 | arguments followed by their declarations is also provided, inside | |
2558 | comments, after the declaration. | |
2559 | ||
d77de738 ML |
2560 | @opindex fno-asm |
2561 | @opindex fasm | |
ddf6fe37 | 2562 | @item -fno-asm |
d77de738 ML |
2563 | Do not recognize @code{asm}, @code{inline} or @code{typeof} as a |
2564 | keyword, so that code can use these words as identifiers. You can use | |
2565 | the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__} | |
2566 | instead. In C, @option{-ansi} implies @option{-fno-asm}. | |
2567 | ||
2568 | In C++, @code{inline} is a standard keyword and is not affected by | |
2569 | this switch. You may want to use the @option{-fno-gnu-keywords} flag | |
2570 | instead, which disables @code{typeof} but not @code{asm} and | |
2571 | @code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}), | |
2572 | this switch only affects the @code{asm} and @code{typeof} keywords, | |
fad61bf7 JM |
2573 | since @code{inline} is a standard keyword in ISO C99. In C23 mode |
2574 | (@option{-std=c23} or @option{-std=gnu23}), this switch only affects | |
d77de738 | 2575 | the @code{asm} keyword, since @code{typeof} is a standard keyword in |
fad61bf7 | 2576 | ISO C23. |
d77de738 | 2577 | |
d77de738 ML |
2578 | @opindex fno-builtin |
2579 | @opindex fbuiltin | |
f33d7a88 | 2580 | @cindex built-in functions |
ddf6fe37 AA |
2581 | @item -fno-builtin |
2582 | @itemx -fno-builtin-@var{function} | |
d77de738 ML |
2583 | Don't recognize built-in functions that do not begin with |
2584 | @samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in | |
2585 | functions provided by GCC}, for details of the functions affected, | |
2586 | including those which are not built-in functions when @option{-ansi} or | |
2587 | @option{-std} options for strict ISO C conformance are used because they | |
2588 | do not have an ISO standard meaning. | |
2589 | ||
2590 | GCC normally generates special code to handle certain built-in functions | |
2591 | more efficiently; for instance, calls to @code{alloca} may become single | |
2592 | instructions which adjust the stack directly, and calls to @code{memcpy} | |
2593 | may become inline copy loops. The resulting code is often both smaller | |
2594 | and faster, but since the function calls no longer appear as such, you | |
2595 | cannot set a breakpoint on those calls, nor can you change the behavior | |
2596 | of the functions by linking with a different library. In addition, | |
2597 | when a function is recognized as a built-in function, GCC may use | |
2598 | information about that function to warn about problems with calls to | |
2599 | that function, or to generate more efficient code, even if the | |
2600 | resulting code still contains calls to that function. For example, | |
2601 | warnings are given with @option{-Wformat} for bad calls to | |
2602 | @code{printf} when @code{printf} is built in and @code{strlen} is | |
2603 | known not to modify global memory. | |
2604 | ||
2605 | With the @option{-fno-builtin-@var{function}} option | |
2606 | only the built-in function @var{function} is | |
2607 | disabled. @var{function} must not begin with @samp{__builtin_}. If a | |
2608 | function is named that is not built-in in this version of GCC, this | |
2609 | option is ignored. There is no corresponding | |
2610 | @option{-fbuiltin-@var{function}} option; if you wish to enable | |
2611 | built-in functions selectively when using @option{-fno-builtin} or | |
2612 | @option{-ffreestanding}, you may define macros such as: | |
2613 | ||
2614 | @smallexample | |
2615 | #define abs(n) __builtin_abs ((n)) | |
2616 | #define strcpy(d, s) __builtin_strcpy ((d), (s)) | |
2617 | @end smallexample | |
2618 | ||
d77de738 | 2619 | @opindex fcond-mismatch |
ddf6fe37 | 2620 | @item -fcond-mismatch |
d77de738 ML |
2621 | Allow conditional expressions with mismatched types in the second and |
2622 | third arguments. The value of such an expression is void. This option | |
2623 | is not supported for C++. | |
2624 | ||
d77de738 ML |
2625 | @opindex ffreestanding |
2626 | @cindex hosted environment | |
f33d7a88 | 2627 | @item -ffreestanding |
d77de738 ML |
2628 | |
2629 | Assert that compilation targets a freestanding environment. This | |
2630 | implies @option{-fno-builtin}. A freestanding environment | |
2631 | is one in which the standard library may not exist, and program startup may | |
2632 | not necessarily be at @code{main}. The most obvious example is an OS kernel. | |
2633 | This is equivalent to @option{-fno-hosted}. | |
2634 | ||
2635 | @xref{Standards,,Language Standards Supported by GCC}, for details of | |
2636 | freestanding and hosted environments. | |
2637 | ||
d77de738 | 2638 | @opindex fgimple |
ddf6fe37 | 2639 | @item -fgimple |
d77de738 ML |
2640 | |
2641 | Enable parsing of function definitions marked with @code{__GIMPLE}. | |
2642 | This is an experimental feature that allows unit testing of GIMPLE | |
2643 | passes. | |
2644 | ||
d77de738 | 2645 | @opindex fgnu-tm |
ddf6fe37 | 2646 | @item -fgnu-tm |
d77de738 ML |
2647 | When the option @option{-fgnu-tm} is specified, the compiler |
2648 | generates code for the Linux variant of Intel's current Transactional | |
2649 | Memory ABI specification document (Revision 1.1, May 6 2009). This is | |
2650 | an experimental feature whose interface may change in future versions | |
2651 | of GCC, as the official specification changes. Please note that not | |
2652 | all architectures are supported for this feature. | |
2653 | ||
2654 | For more information on GCC's support for transactional memory, | |
2655 | @xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU | |
2656 | Transactional Memory Library}. | |
2657 | ||
2658 | Note that the transactional memory feature is not supported with | |
2659 | non-call exceptions (@option{-fnon-call-exceptions}). | |
2660 | ||
d77de738 | 2661 | @opindex fgnu89-inline |
ddf6fe37 | 2662 | @item -fgnu89-inline |
d77de738 ML |
2663 | The option @option{-fgnu89-inline} tells GCC to use the traditional |
2664 | GNU semantics for @code{inline} functions when in C99 mode. | |
2665 | @xref{Inline,,An Inline Function is As Fast As a Macro}. | |
2666 | Using this option is roughly equivalent to adding the | |
2667 | @code{gnu_inline} function attribute to all inline functions | |
2668 | (@pxref{Function Attributes}). | |
2669 | ||
2670 | The option @option{-fno-gnu89-inline} explicitly tells GCC to use the | |
2671 | C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it | |
2672 | specifies the default behavior). | |
2673 | This option is not supported in @option{-std=c90} or | |
2674 | @option{-std=gnu90} mode. | |
2675 | ||
2676 | The preprocessor macros @code{__GNUC_GNU_INLINE__} and | |
2677 | @code{__GNUC_STDC_INLINE__} may be used to check which semantics are | |
2678 | in effect for @code{inline} functions. @xref{Common Predefined | |
2679 | Macros,,,cpp,The C Preprocessor}. | |
2680 | ||
d77de738 ML |
2681 | @opindex fhosted |
2682 | @cindex hosted environment | |
f33d7a88 | 2683 | @item -fhosted |
d77de738 ML |
2684 | |
2685 | Assert that compilation targets a hosted environment. This implies | |
2686 | @option{-fbuiltin}. A hosted environment is one in which the | |
2687 | entire standard library is available, and in which @code{main} has a return | |
2688 | type of @code{int}. Examples are nearly everything except a kernel. | |
2689 | This is equivalent to @option{-fno-freestanding}. | |
2690 | ||
d77de738 | 2691 | @opindex flax-vector-conversions |
ddf6fe37 | 2692 | @item -flax-vector-conversions |
d77de738 ML |
2693 | Allow implicit conversions between vectors with differing numbers of |
2694 | elements and/or incompatible element types. This option should not be | |
2695 | used for new code. | |
2696 | ||
d77de738 | 2697 | @opindex fms-extensions |
ddf6fe37 | 2698 | @item -fms-extensions |
d77de738 ML |
2699 | Accept some non-standard constructs used in Microsoft header files. |
2700 | ||
2701 | In C++ code, this allows member names in structures to be similar | |
2702 | to previous types declarations. | |
2703 | ||
2704 | @smallexample | |
2705 | typedef int UOW; | |
2706 | struct ABC @{ | |
2707 | UOW UOW; | |
2708 | @}; | |
2709 | @end smallexample | |
2710 | ||
2711 | Some cases of unnamed fields in structures and unions are only | |
2712 | accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union | |
2713 | fields within structs/unions}, for details. | |
2714 | ||
2715 | Note that this option is off for all targets except for x86 | |
2716 | targets using ms-abi. | |
2717 | ||
ddf6fe37 | 2718 | @opindex foffload |
d77de738 ML |
2719 | @cindex Offloading targets |
2720 | @cindex OpenACC offloading targets | |
2721 | @cindex OpenMP offloading targets | |
f33d7a88 AA |
2722 | @item -foffload=disable |
2723 | @itemx -foffload=default | |
2724 | @itemx -foffload=@var{target-list} | |
d77de738 ML |
2725 | Specify for which OpenMP and OpenACC offload targets code should be generated. |
2726 | The default behavior, equivalent to @option{-foffload=default}, is to generate | |
2727 | code for all supported offload targets. The @option{-foffload=disable} form | |
2728 | generates code only for the host fallback, while | |
2729 | @option{-foffload=@var{target-list}} generates code only for the specified | |
2730 | comma-separated list of offload targets. | |
2731 | ||
2732 | Offload targets are specified in GCC's internal target-triplet format. You can | |
2733 | run the compiler with @option{-v} to show the list of configured offload targets | |
2734 | under @code{OFFLOAD_TARGET_NAMES}. | |
2735 | ||
ddf6fe37 | 2736 | @opindex foffload-options |
d77de738 ML |
2737 | @cindex Offloading options |
2738 | @cindex OpenACC offloading options | |
2739 | @cindex OpenMP offloading options | |
f33d7a88 AA |
2740 | @item -foffload-options=@var{options} |
2741 | @itemx -foffload-options=@var{target-triplet-list}=@var{options} | |
d77de738 ML |
2742 | |
2743 | With @option{-foffload-options=@var{options}}, GCC passes the specified | |
2744 | @var{options} to the compilers for all enabled offloading targets. You can | |
2745 | specify options that apply only to a specific target or targets by using | |
2746 | the @option{-foffload-options=@var{target-list}=@var{options}} form. The | |
2747 | @var{target-list} is a comma-separated list in the same format as for the | |
2748 | @option{-foffload=} option. | |
2749 | ||
2750 | Typical command lines are | |
2751 | ||
2752 | @smallexample | |
4bcb46b3 | 2753 | -foffload-options='-fno-math-errno -ffinite-math-only' -foffload-options=nvptx-none=-latomic |
e9c1679c | 2754 | -foffload-options=amdgcn-amdhsa=-march=gfx906 |
d77de738 ML |
2755 | @end smallexample |
2756 | ||
d77de738 ML |
2757 | @opindex fopenacc |
2758 | @cindex OpenACC accelerator programming | |
f33d7a88 | 2759 | @item -fopenacc |
643a5223 TB |
2760 | Enable handling of OpenACC directives @samp{#pragma acc} in C/C++ and |
2761 | @samp{!$acc} in free-form Fortran and @samp{!$acc}, @samp{c$acc} and | |
2762 | @samp{*$acc} in fixed-form Fortran. When @option{-fopenacc} is specified, | |
2763 | the compiler generates accelerated code according to the OpenACC Application | |
d77de738 ML |
2764 | Programming Interface v2.6 @w{@uref{https://www.openacc.org}}. This option |
2765 | implies @option{-pthread}, and thus is only supported on targets that | |
2766 | have support for @option{-pthread}. | |
2767 | ||
d77de738 ML |
2768 | @opindex fopenacc-dim |
2769 | @cindex OpenACC accelerator programming | |
f33d7a88 | 2770 | @item -fopenacc-dim=@var{geom} |
d77de738 ML |
2771 | Specify default compute dimensions for parallel offload regions that do |
2772 | not explicitly specify. The @var{geom} value is a triple of | |
2773 | ':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size | |
2774 | can be omitted, to use a target-specific default value. | |
2775 | ||
d77de738 ML |
2776 | @opindex fopenmp |
2777 | @cindex OpenMP parallel | |
f33d7a88 | 2778 | @item -fopenmp |
75e5a467 | 2779 | Enable handling of OpenMP directives @samp{#pragma omp}, |
643a5223 | 2780 | @samp{[[omp::directive(...)]]}, @samp{[[omp::sequence(...)]]} and |
75e5a467 | 2781 | @samp{[[omp::decl(...)]]} in C/C++ and @samp{!$omp} in Fortran. It |
643a5223 TB |
2782 | additionally enables the conditional compilation sentinel @samp{!$} in |
2783 | Fortran. In fixed source form Fortran, the sentinels can also start with | |
2784 | @samp{c} or @samp{*}. When @option{-fopenmp} is specified, the | |
d77de738 ML |
2785 | compiler generates parallel code according to the OpenMP Application |
2786 | Program Interface v4.5 @w{@uref{https://www.openmp.org}}. This option | |
2787 | implies @option{-pthread}, and thus is only supported on targets that | |
2788 | have support for @option{-pthread}. @option{-fopenmp} implies | |
2789 | @option{-fopenmp-simd}. | |
2790 | ||
d77de738 ML |
2791 | @opindex fopenmp-simd |
2792 | @cindex OpenMP SIMD | |
2793 | @cindex SIMD | |
f33d7a88 | 2794 | @item -fopenmp-simd |
d77de738 | 2795 | Enable handling of OpenMP's @code{simd}, @code{declare simd}, |
1fab441d TB |
2796 | @code{declare reduction}, @code{assume}, @code{ordered}, @code{scan} |
2797 | and @code{loop} directive, and of combined or composite directives with | |
75e5a467 | 2798 | @code{simd} as constituent with @code{#pragma omp}, |
1fab441d | 2799 | @code{[[omp::directive(...)]]}, @code{[[omp::sequence(...)]]} and |
75e5a467 | 2800 | @code{[[omp::decl(...)]]} in C/C++ and @code{!$omp} in Fortran. It |
643a5223 TB |
2801 | additionally enables the conditional compilation sentinel @samp{!$} in |
2802 | Fortran. In fixed source form Fortran, the sentinels can also start with | |
2803 | @samp{c} or @samp{*}. Other OpenMP directives are ignored. Unless | |
2804 | @option{-fopenmp} is additionally specified, the @code{loop} region binds | |
2805 | to the current task region, independent of the specified @code{bind} clause. | |
d77de738 | 2806 | |
ddf6fe37 | 2807 | @opindex fopenmp-target-simd-clone |
f33d7a88 | 2808 | @cindex OpenMP target SIMD clone |
309e2d95 SL |
2809 | @item -fopenmp-target-simd-clone |
2810 | @item -fopenmp-target-simd-clone=@var{device-type} | |
309e2d95 SL |
2811 | In addition to generating SIMD clones for functions marked with the |
2812 | @code{declare simd} directive, GCC also generates clones | |
2813 | for functions marked with the OpenMP @code{declare target} directive | |
2814 | that are suitable for vectorization when this option is in effect. The | |
2815 | @var{device-type} may be one of @code{none}, @code{host}, @code{nohost}, | |
2816 | and @code{any}, which correspond to keywords for the @code{device_type} | |
2817 | clause of the @code{declare target} directive; clones are generated for | |
2818 | the intersection of devices specified. | |
2819 | @option{-fopenmp-target-simd-clone} is equivalent to | |
2820 | @option{-fopenmp-target-simd-clone=any} and | |
2821 | @option{-fno-openmp-target-simd-clone} is equivalent to | |
2822 | @option{-fopenmp-target-simd-clone=none}. | |
2823 | ||
2824 | At @option{-O2} and higher (but not @option{-Os} or @option{-Og}) this | |
2825 | optimization defaults to @option{-fopenmp-target-simd-clone=nohost}; otherwise | |
2826 | it is disabled by default. | |
2827 | ||
d77de738 ML |
2828 | @opindex fpermitted-flt-eval-methods |
2829 | @opindex fpermitted-flt-eval-methods=c11 | |
2830 | @opindex fpermitted-flt-eval-methods=ts-18661-3 | |
ddf6fe37 | 2831 | @item -fpermitted-flt-eval-methods=@var{style} |
d77de738 ML |
2832 | ISO/IEC TS 18661-3 defines new permissible values for |
2833 | @code{FLT_EVAL_METHOD} that indicate that operations and constants with | |
2834 | a semantic type that is an interchange or extended format should be | |
2835 | evaluated to the precision and range of that type. These new values are | |
2836 | a superset of those permitted under C99/C11, which does not specify the | |
2837 | meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code | |
2838 | conforming to C11 may not have been written expecting the possibility of | |
2839 | the new values. | |
2840 | ||
2841 | @option{-fpermitted-flt-eval-methods} specifies whether the compiler | |
2842 | should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11, | |
2843 | or the extended set of values specified in ISO/IEC TS 18661-3. | |
2844 | ||
2845 | @var{style} is either @code{c11} or @code{ts-18661-3} as appropriate. | |
2846 | ||
2847 | The default when in a standards compliant mode (@option{-std=c11} or similar) | |
2848 | is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU | |
2849 | dialect (@option{-std=gnu11} or similar) is | |
2850 | @option{-fpermitted-flt-eval-methods=ts-18661-3}. | |
2851 | ||
024f135a BB |
2852 | @opindex fdeps- |
2853 | The @samp{-fdeps-*} options are used to extract structured dependency | |
2854 | information for a source. This involves determining what resources provided by | |
2855 | other source files will be required to compile the source as well as what | |
2856 | resources are provided by the source. This information can be used to add | |
2857 | required dependencies between compilation rules of dependent sources based on | |
2858 | their contents rather than requiring such information be reflected within the | |
2859 | build tools as well. | |
2860 | ||
2861 | @opindex fdeps-file | |
2862 | @item -fdeps-file=@var{file} | |
2863 | Where to write structured dependency information. | |
2864 | ||
2865 | @opindex fdeps-format | |
2866 | @item -fdeps-format=@var{format} | |
2867 | The format to use for structured dependency information. @samp{p1689r5} is the | |
2868 | only supported format right now. Note that when this argument is specified, the | |
2869 | output of @samp{-MF} is stripped of some information (namely C++ modules) so | |
2870 | that it does not use extended makefile syntax not understood by most tools. | |
2871 | ||
2872 | @opindex fdeps-target | |
2873 | @item -fdeps-target=@var{file} | |
2874 | Analogous to @option{-MT} but for structured dependency information. This | |
2875 | indicates the target which will ultimately need any required resources and | |
2876 | provide any resources extracted from the source that may be required by other | |
2877 | sources. | |
2878 | ||
d77de738 | 2879 | @opindex fplan9-extensions |
ddf6fe37 | 2880 | @item -fplan9-extensions |
d77de738 ML |
2881 | Accept some non-standard constructs used in Plan 9 code. |
2882 | ||
2883 | This enables @option{-fms-extensions}, permits passing pointers to | |
2884 | structures with anonymous fields to functions that expect pointers to | |
2885 | elements of the type of the field, and permits referring to anonymous | |
2886 | fields declared using a typedef. @xref{Unnamed Fields,,Unnamed | |
2887 | struct/union fields within structs/unions}, for details. This is only | |
2888 | supported for C, not C++. | |
2889 | ||
d77de738 ML |
2890 | @opindex fsigned-bitfields |
2891 | @opindex funsigned-bitfields | |
2892 | @opindex fno-signed-bitfields | |
2893 | @opindex fno-unsigned-bitfields | |
ddf6fe37 AA |
2894 | @item -fsigned-bitfields |
2895 | @itemx -funsigned-bitfields | |
2896 | @itemx -fno-signed-bitfields | |
2897 | @itemx -fno-unsigned-bitfields | |
d77de738 ML |
2898 | These options control whether a bit-field is signed or unsigned, when the |
2899 | declaration does not use either @code{signed} or @code{unsigned}. By | |
2900 | default, such a bit-field is signed, because this is consistent: the | |
2901 | basic integer types such as @code{int} are signed types. | |
2902 | ||
d77de738 | 2903 | @opindex fsigned-char |
ddf6fe37 | 2904 | @item -fsigned-char |
d77de738 ML |
2905 | Let the type @code{char} be signed, like @code{signed char}. |
2906 | ||
2907 | Note that this is equivalent to @option{-fno-unsigned-char}, which is | |
2908 | the negative form of @option{-funsigned-char}. Likewise, the option | |
2909 | @option{-fno-signed-char} is equivalent to @option{-funsigned-char}. | |
2910 | ||
d77de738 | 2911 | @opindex funsigned-char |
ddf6fe37 | 2912 | @item -funsigned-char |
d77de738 ML |
2913 | Let the type @code{char} be unsigned, like @code{unsigned char}. |
2914 | ||
2915 | Each kind of machine has a default for what @code{char} should | |
2916 | be. It is either like @code{unsigned char} by default or like | |
2917 | @code{signed char} by default. | |
2918 | ||
2919 | Ideally, a portable program should always use @code{signed char} or | |
2920 | @code{unsigned char} when it depends on the signedness of an object. | |
2921 | But many programs have been written to use plain @code{char} and | |
2922 | expect it to be signed, or expect it to be unsigned, depending on the | |
2923 | machines they were written for. This option, and its inverse, let you | |
2924 | make such a program work with the opposite default. | |
2925 | ||
2926 | The type @code{char} is always a distinct type from each of | |
2927 | @code{signed char} or @code{unsigned char}, even though its behavior | |
2928 | is always just like one of those two. | |
2929 | ||
d77de738 ML |
2930 | @opindex fstrict-flex-arrays |
2931 | @opindex fno-strict-flex-arrays | |
ddf6fe37 | 2932 | @item -fstrict-flex-arrays |
d77de738 ML |
2933 | Control when to treat the trailing array of a structure as a flexible array |
2934 | member for the purpose of accessing the elements of such an array. | |
2935 | The positive form is equivalent to @option{-fstrict-flex-arrays=3}, which is the | |
2936 | strictest. A trailing array is treated as a flexible array member only when it | |
2937 | is declared as a flexible array member per C99 standard onwards. | |
2938 | The negative form is equivalent to @option{-fstrict-flex-arrays=0}, which is the | |
2939 | least strict. All trailing arrays of structures are treated as flexible array | |
2940 | members. | |
2941 | ||
d77de738 | 2942 | @opindex fstrict-flex-arrays=@var{level} |
ddf6fe37 | 2943 | @item -fstrict-flex-arrays=@var{level} |
d77de738 ML |
2944 | Control when to treat the trailing array of a structure as a flexible array |
2945 | member for the purpose of accessing the elements of such an array. The value | |
2946 | of @var{level} controls the level of strictness. | |
2947 | ||
2948 | The possible values of @var{level} are the same as for the | |
2949 | @code{strict_flex_array} attribute (@pxref{Variable Attributes}). | |
2950 | ||
2951 | You can control this behavior for a specific trailing array field of a | |
2952 | structure by using the variable attribute @code{strict_flex_array} attribute | |
2953 | (@pxref{Variable Attributes}). | |
2954 | ||
d77de738 | 2955 | @opindex fsso-struct |
ddf6fe37 | 2956 | @item -fsso-struct=@var{endianness} |
d77de738 ML |
2957 | Set the default scalar storage order of structures and unions to the |
2958 | specified endianness. The accepted values are @samp{big-endian}, | |
2959 | @samp{little-endian} and @samp{native} for the native endianness of | |
2960 | the target (the default). This option is not supported for C++. | |
2961 | ||
2962 | @strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate | |
2963 | code that is not binary compatible with code generated without it if the | |
2964 | specified endianness is not the native endianness of the target. | |
2965 | @end table | |
2966 | ||
2967 | @node C++ Dialect Options | |
2968 | @section Options Controlling C++ Dialect | |
2969 | ||
2970 | @cindex compiler options, C++ | |
2971 | @cindex C++ options, command-line | |
2972 | @cindex options, C++ | |
2973 | This section describes the command-line options that are only meaningful | |
2974 | for C++ programs. You can also use most of the GNU compiler options | |
2975 | regardless of what language your program is in. For example, you | |
2976 | might compile a file @file{firstClass.C} like this: | |
2977 | ||
2978 | @smallexample | |
2979 | g++ -g -fstrict-enums -O -c firstClass.C | |
2980 | @end smallexample | |
2981 | ||
2982 | @noindent | |
2983 | In this example, only @option{-fstrict-enums} is an option meant | |
2984 | only for C++ programs; you can use the other options with any | |
2985 | language supported by GCC@. | |
2986 | ||
2987 | Some options for compiling C programs, such as @option{-std}, are also | |
2988 | relevant for C++ programs. | |
2989 | @xref{C Dialect Options,,Options Controlling C Dialect}. | |
2990 | ||
2991 | Here is a list of options that are @emph{only} for compiling C++ programs: | |
2992 | ||
2993 | @table @gcctabopt | |
2994 | ||
d77de738 | 2995 | @opindex fabi-version |
ddf6fe37 | 2996 | @item -fabi-version=@var{n} |
d77de738 ML |
2997 | Use version @var{n} of the C++ ABI@. The default is version 0. |
2998 | ||
2999 | Version 0 refers to the version conforming most closely to | |
3000 | the C++ ABI specification. Therefore, the ABI obtained using version 0 | |
3001 | will change in different versions of G++ as ABI bugs are fixed. | |
3002 | ||
3003 | Version 1 is the version of the C++ ABI that first appeared in G++ 3.2. | |
3004 | ||
3005 | Version 2 is the version of the C++ ABI that first appeared in G++ | |
3006 | 3.4, and was the default through G++ 4.9. | |
3007 | ||
3008 | Version 3 corrects an error in mangling a constant address as a | |
3009 | template argument. | |
3010 | ||
3011 | Version 4, which first appeared in G++ 4.5, implements a standard | |
3012 | mangling for vector types. | |
3013 | ||
3014 | Version 5, which first appeared in G++ 4.6, corrects the mangling of | |
3015 | attribute const/volatile on function pointer types, decltype of a | |
3016 | plain decl, and use of a function parameter in the declaration of | |
3017 | another parameter. | |
3018 | ||
3019 | Version 6, which first appeared in G++ 4.7, corrects the promotion | |
3020 | behavior of C++11 scoped enums and the mangling of template argument | |
3021 | packs, const/static_cast, prefix ++ and --, and a class scope function | |
3022 | used as a template argument. | |
3023 | ||
3024 | Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a | |
3025 | builtin type and corrects the mangling of lambdas in default argument | |
3026 | scope. | |
3027 | ||
3028 | Version 8, which first appeared in G++ 4.9, corrects the substitution | |
3029 | behavior of function types with function-cv-qualifiers. | |
3030 | ||
3031 | Version 9, which first appeared in G++ 5.2, corrects the alignment of | |
3032 | @code{nullptr_t}. | |
3033 | ||
3034 | Version 10, which first appeared in G++ 6.1, adds mangling of | |
3035 | attributes that affect type identity, such as ia32 calling convention | |
3036 | attributes (e.g.@: @samp{stdcall}). | |
3037 | ||
3038 | Version 11, which first appeared in G++ 7, corrects the mangling of | |
3039 | sizeof... expressions and operator names. For multiple entities with | |
3040 | the same name within a function, that are declared in different scopes, | |
3041 | the mangling now changes starting with the twelfth occurrence. It also | |
3042 | implies @option{-fnew-inheriting-ctors}. | |
3043 | ||
3044 | Version 12, which first appeared in G++ 8, corrects the calling | |
3045 | conventions for empty classes on the x86_64 target and for classes | |
3046 | with only deleted copy/move constructors. It accidentally changes the | |
3047 | calling convention for classes with a deleted copy constructor and a | |
3048 | trivial move constructor. | |
3049 | ||
3050 | Version 13, which first appeared in G++ 8.2, fixes the accidental | |
3051 | change in version 12. | |
3052 | ||
3053 | Version 14, which first appeared in G++ 10, corrects the mangling of | |
3054 | the nullptr expression. | |
3055 | ||
3056 | Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI | |
3057 | tag regression. | |
3058 | ||
3059 | Version 16, which first appeared in G++ 11, changes the mangling of | |
3060 | @code{__alignof__} to be distinct from that of @code{alignof}, and | |
3061 | dependent operator names. | |
3062 | ||
3063 | Version 17, which first appeared in G++ 12, fixes layout of classes | |
3064 | that inherit from aggregate classes with default member initializers | |
3065 | in C++14 and up. | |
3066 | ||
3067 | Version 18, which first appeard in G++ 13, fixes manglings of lambdas | |
3068 | that have additional context. | |
3069 | ||
cd37325b JJ |
3070 | Version 19, which first appeard in G++ 14, fixes manglings of structured |
3071 | bindings to include ABI tags. | |
3072 | ||
d77de738 ML |
3073 | See also @option{-Wabi}. |
3074 | ||
d77de738 | 3075 | @opindex fabi-compat-version |
ddf6fe37 | 3076 | @item -fabi-compat-version=@var{n} |
d77de738 ML |
3077 | On targets that support strong aliases, G++ |
3078 | works around mangling changes by creating an alias with the correct | |
3079 | mangled name when defining a symbol with an incorrect mangled name. | |
3080 | This switch specifies which ABI version to use for the alias. | |
3081 | ||
3082 | With @option{-fabi-version=0} (the default), this defaults to 13 (GCC 8.2 | |
3083 | compatibility). If another ABI version is explicitly selected, this | |
3084 | defaults to 0. For compatibility with GCC versions 3.2 through 4.9, | |
3085 | use @option{-fabi-compat-version=2}. | |
3086 | ||
3087 | If this option is not provided but @option{-Wabi=@var{n}} is, that | |
3088 | version is used for compatibility aliases. If this option is provided | |
3089 | along with @option{-Wabi} (without the version), the version from this | |
3090 | option is used for the warning. | |
3091 | ||
d77de738 ML |
3092 | @opindex fno-access-control |
3093 | @opindex faccess-control | |
ddf6fe37 | 3094 | @item -fno-access-control |
d77de738 ML |
3095 | Turn off all access checking. This switch is mainly useful for working |
3096 | around bugs in the access control code. | |
3097 | ||
d77de738 | 3098 | @opindex faligned-new |
ddf6fe37 | 3099 | @item -faligned-new |
d77de738 ML |
3100 | Enable support for C++17 @code{new} of types that require more |
3101 | alignment than @code{void* ::operator new(std::size_t)} provides. A | |
3102 | numeric argument such as @code{-faligned-new=32} can be used to | |
3103 | specify how much alignment (in bytes) is provided by that function, | |
3104 | but few users will need to override the default of | |
3105 | @code{alignof(std::max_align_t)}. | |
3106 | ||
3107 | This flag is enabled by default for @option{-std=c++17}. | |
3108 | ||
d77de738 ML |
3109 | @opindex fchar8_t |
3110 | @opindex fno-char8_t | |
ddf6fe37 AA |
3111 | @item -fchar8_t |
3112 | @itemx -fno-char8_t | |
d77de738 ML |
3113 | Enable support for @code{char8_t} as adopted for C++20. This includes |
3114 | the addition of a new @code{char8_t} fundamental type, changes to the | |
3115 | types of UTF-8 string and character literals, new signatures for | |
3116 | user-defined literals, associated standard library updates, and new | |
3117 | @code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros. | |
3118 | ||
3119 | This option enables functions to be overloaded for ordinary and UTF-8 | |
3120 | strings: | |
3121 | ||
3122 | @smallexample | |
3123 | int f(const char *); // #1 | |
3124 | int f(const char8_t *); // #2 | |
3125 | int v1 = f("text"); // Calls #1 | |
3126 | int v2 = f(u8"text"); // Calls #2 | |
3127 | @end smallexample | |
3128 | ||
3129 | @noindent | |
3130 | and introduces new signatures for user-defined literals: | |
3131 | ||
3132 | @smallexample | |
3133 | int operator""_udl1(char8_t); | |
3134 | int v3 = u8'x'_udl1; | |
3135 | int operator""_udl2(const char8_t*, std::size_t); | |
3136 | int v4 = u8"text"_udl2; | |
3137 | template<typename T, T...> int operator""_udl3(); | |
3138 | int v5 = u8"text"_udl3; | |
3139 | @end smallexample | |
3140 | ||
3141 | @noindent | |
3142 | The change to the types of UTF-8 string and character literals introduces | |
3143 | incompatibilities with ISO C++11 and later standards. For example, the | |
3144 | following code is well-formed under ISO C++11, but is ill-formed when | |
3145 | @option{-fchar8_t} is specified. | |
3146 | ||
3147 | @smallexample | |
d77de738 ML |
3148 | const char *cp = u8"xx";// error: invalid conversion from |
3149 | // `const char8_t*' to `const char*' | |
3150 | int f(const char*); | |
3151 | auto v = f(u8"xx"); // error: invalid conversion from | |
3152 | // `const char8_t*' to `const char*' | |
3153 | std::string s@{u8"xx"@}; // error: no matching function for call to | |
3154 | // `std::basic_string<char>::basic_string()' | |
3155 | using namespace std::literals; | |
3156 | s = u8"xx"s; // error: conversion from | |
3157 | // `basic_string<char8_t>' to non-scalar | |
3158 | // type `basic_string<char>' requested | |
3159 | @end smallexample | |
3160 | ||
d77de738 | 3161 | @opindex fcheck-new |
ddf6fe37 | 3162 | @item -fcheck-new |
d77de738 ML |
3163 | Check that the pointer returned by @code{operator new} is non-null |
3164 | before attempting to modify the storage allocated. This check is | |
3165 | normally unnecessary because the C++ standard specifies that | |
3166 | @code{operator new} only returns @code{0} if it is declared | |
3167 | @code{throw()}, in which case the compiler always checks the | |
3168 | return value even without this option. In all other cases, when | |
3169 | @code{operator new} has a non-empty exception specification, memory | |
3170 | exhaustion is signalled by throwing @code{std::bad_alloc}. See also | |
3171 | @samp{new (nothrow)}. | |
3172 | ||
d77de738 ML |
3173 | @opindex fconcepts |
3174 | @opindex fconcepts-ts | |
ddf6fe37 AA |
3175 | @item -fconcepts |
3176 | @itemx -fconcepts-ts | |
d77de738 ML |
3177 | Enable support for the C++ Concepts feature for constraining template |
3178 | arguments. With @option{-std=c++20} and above, Concepts are part of | |
3179 | the language standard, so @option{-fconcepts} defaults to on. | |
3180 | ||
3181 | Some constructs that were allowed by the earlier C++ Extensions for | |
3182 | Concepts Technical Specification, ISO 19217 (2015), but didn't make it | |
3183 | into the standard, can additionally be enabled by | |
3184 | @option{-fconcepts-ts}. | |
3185 | ||
d77de738 | 3186 | @opindex fconstexpr-depth |
ddf6fe37 | 3187 | @item -fconstexpr-depth=@var{n} |
d77de738 ML |
3188 | Set the maximum nested evaluation depth for C++11 constexpr functions |
3189 | to @var{n}. A limit is needed to detect endless recursion during | |
3190 | constant expression evaluation. The minimum specified by the standard | |
3191 | is 512. | |
3192 | ||
d77de738 | 3193 | @opindex fconstexpr-cache-depth |
ddf6fe37 | 3194 | @item -fconstexpr-cache-depth=@var{n} |
d77de738 ML |
3195 | Set the maximum level of nested evaluation depth for C++11 constexpr |
3196 | functions that will be cached to @var{n}. This is a heuristic that | |
3197 | trades off compilation speed (when the cache avoids repeated | |
3198 | calculations) against memory consumption (when the cache grows very | |
3199 | large from highly recursive evaluations). The default is 8. Very few | |
3200 | users are likely to want to adjust it, but if your code does heavy | |
3201 | constexpr calculations you might want to experiment to find which | |
3202 | value works best for you. | |
3203 | ||
d77de738 | 3204 | @opindex fconstexpr-fp-except |
ddf6fe37 | 3205 | @item -fconstexpr-fp-except |
d77de738 ML |
3206 | Annex F of the C standard specifies that IEC559 floating point |
3207 | exceptions encountered at compile time should not stop compilation. | |
3208 | C++ compilers have historically not followed this guidance, instead | |
3209 | treating floating point division by zero as non-constant even though | |
3210 | it has a well defined value. This flag tells the compiler to give | |
3211 | Annex F priority over other rules saying that a particular operation | |
3212 | is undefined. | |
3213 | ||
3214 | @smallexample | |
3215 | constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except | |
3216 | @end smallexample | |
3217 | ||
d77de738 | 3218 | @opindex fconstexpr-loop-limit |
ddf6fe37 | 3219 | @item -fconstexpr-loop-limit=@var{n} |
d77de738 ML |
3220 | Set the maximum number of iterations for a loop in C++14 constexpr functions |
3221 | to @var{n}. A limit is needed to detect infinite loops during | |
3222 | constant expression evaluation. The default is 262144 (1<<18). | |
3223 | ||
d77de738 | 3224 | @opindex fconstexpr-ops-limit |
ddf6fe37 | 3225 | @item -fconstexpr-ops-limit=@var{n} |
d77de738 ML |
3226 | Set the maximum number of operations during a single constexpr evaluation. |
3227 | Even when number of iterations of a single loop is limited with the above limit, | |
3228 | if there are several nested loops and each of them has many iterations but still | |
3229 | smaller than the above limit, or if in a body of some loop or even outside | |
3230 | of a loop too many expressions need to be evaluated, the resulting constexpr | |
3231 | evaluation might take too long. | |
3232 | The default is 33554432 (1<<25). | |
3233 | ||
2efb237f | 3234 | @opindex fcontracts |
ddf6fe37 | 3235 | @item -fcontracts |
2efb237f JCI |
3236 | Enable experimental support for the C++ Contracts feature, as briefly |
3237 | added to and then removed from the C++20 working paper (N4820). The | |
3238 | implementation also includes proposed enhancements from papers P1290, | |
3239 | P1332, and P1429. This functionality is intended mostly for those | |
3240 | interested in experimentation towards refining the feature to get it | |
3241 | into shape for a future C++ standard. | |
3242 | ||
3243 | On violation of a checked contract, the violation handler is called. | |
3244 | Users can replace the violation handler by defining | |
3245 | @smallexample | |
4ace81b6 SL |
3246 | void |
3247 | handle_contract_violation (const std::experimental::contract_violation&); | |
2efb237f JCI |
3248 | @end smallexample |
3249 | ||
3250 | There are different sets of additional flags that can be used together | |
3251 | to specify which contracts will be checked and how, for N4820 | |
3252 | contracts, P1332 contracts, or P1429 contracts; these sets cannot be | |
3253 | used together. | |
3254 | ||
3255 | @table @gcctabopt | |
2efb237f | 3256 | @opindex fcontract-mode |
ddf6fe37 | 3257 | @item -fcontract-mode=[on|off] |
2efb237f JCI |
3258 | Control whether any contracts have any semantics at all. Defaults to on. |
3259 | ||
2efb237f | 3260 | @opindex fcontract-assumption-mode |
ddf6fe37 | 3261 | @item -fcontract-assumption-mode=[on|off] |
2efb237f JCI |
3262 | [N4820] Control whether contracts with level @samp{axiom} |
3263 | should have the assume semantic. Defaults to on. | |
3264 | ||
2efb237f | 3265 | @opindex fcontract-build-level |
ddf6fe37 | 3266 | @item -fcontract-build-level=[off|default|audit] |
2efb237f JCI |
3267 | [N4820] Specify which level of contracts to generate checks |
3268 | for. Defaults to @samp{default}. | |
3269 | ||
2efb237f | 3270 | @opindex fcontract-continuation-mode |
ddf6fe37 | 3271 | @item -fcontract-continuation-mode=[on|off] |
2efb237f JCI |
3272 | [N4820] Control whether to allow the program to continue executing |
3273 | after a contract violation. That is, do checked contracts have the | |
3274 | @samp{maybe} semantic described below rather than the @samp{never} | |
3275 | semantic. Defaults to off. | |
3276 | ||
2efb237f | 3277 | @opindex fcontract-role |
ddf6fe37 | 3278 | @item -fcontract-role=<name>:<default>,<audit>,<axiom> |
2efb237f JCI |
3279 | [P1332] Specify the concrete semantics for each contract level |
3280 | of a particular contract role. | |
3281 | ||
3282 | @item -fcontract-semantic=[default|audit|axiom]:<semantic> | |
3283 | [P1429] Specify the concrete semantic for a particular | |
3284 | contract level. | |
3285 | ||
2efb237f | 3286 | @opindex fcontract-strict-declarations |
ddf6fe37 | 3287 | @item -fcontract-strict-declarations=[on|off] |
2efb237f JCI |
3288 | Control whether to reject adding contracts to a function after its |
3289 | first declaration. Defaults to off. | |
3290 | @end table | |
3291 | ||
3292 | The possible concrete semantics for that can be specified with | |
3293 | @samp{-fcontract-role} or @samp{-fcontract-semantic} are: | |
3294 | ||
3295 | @table @code | |
3296 | @item ignore | |
3297 | This contract has no effect. | |
3298 | ||
3299 | @item assume | |
3300 | This contract is treated like C++23 @code{[[assume]]}. | |
3301 | ||
3302 | @item check_never_continue | |
3303 | @itemx never | |
3304 | @itemx abort | |
3305 | This contract is checked. If it fails, the violation handler is | |
3306 | called. If the handler returns, @code{std::terminate} is called. | |
3307 | ||
3308 | @item check_maybe_continue | |
3309 | @itemx maybe | |
3310 | This contract is checked. If it fails, the violation handler is | |
3311 | called. If the handler returns, execution continues normally. | |
3312 | @end table | |
3313 | ||
d77de738 | 3314 | @opindex fcoroutines |
ddf6fe37 | 3315 | @item -fcoroutines |
d77de738 ML |
3316 | Enable support for the C++ coroutines extension (experimental). |
3317 | ||
d77de738 ML |
3318 | @opindex fno-elide-constructors |
3319 | @opindex felide-constructors | |
ddf6fe37 | 3320 | @item -fno-elide-constructors |
d77de738 ML |
3321 | The C++ standard allows an implementation to omit creating a temporary |
3322 | that is only used to initialize another object of the same type. | |
3323 | Specifying this option disables that optimization, and forces G++ to | |
3324 | call the copy constructor in all cases. This option also causes G++ | |
3325 | to call trivial member functions which otherwise would be expanded inline. | |
3326 | ||
3327 | In C++17, the compiler is required to omit these temporaries, but this | |
3328 | option still affects trivial member functions. | |
3329 | ||
d77de738 ML |
3330 | @opindex fno-enforce-eh-specs |
3331 | @opindex fenforce-eh-specs | |
ddf6fe37 | 3332 | @item -fno-enforce-eh-specs |
d77de738 ML |
3333 | Don't generate code to check for violation of exception specifications |
3334 | at run time. This option violates the C++ standard, but may be useful | |
3335 | for reducing code size in production builds, much like defining | |
3336 | @code{NDEBUG}. This does not give user code permission to throw | |
3337 | exceptions in violation of the exception specifications; the compiler | |
3338 | still optimizes based on the specifications, so throwing an | |
3339 | unexpected exception results in undefined behavior at run time. | |
3340 | ||
d77de738 ML |
3341 | @opindex fextern-tls-init |
3342 | @opindex fno-extern-tls-init | |
ddf6fe37 AA |
3343 | @item -fextern-tls-init |
3344 | @itemx -fno-extern-tls-init | |
d77de738 ML |
3345 | The C++11 and OpenMP standards allow @code{thread_local} and |
3346 | @code{threadprivate} variables to have dynamic (runtime) | |
3347 | initialization. To support this, any use of such a variable goes | |
3348 | through a wrapper function that performs any necessary initialization. | |
3349 | When the use and definition of the variable are in the same | |
3350 | translation unit, this overhead can be optimized away, but when the | |
3351 | use is in a different translation unit there is significant overhead | |
3352 | even if the variable doesn't actually need dynamic initialization. If | |
3353 | the programmer can be sure that no use of the variable in a | |
3354 | non-defining TU needs to trigger dynamic initialization (either | |
3355 | because the variable is statically initialized, or a use of the | |
3356 | variable in the defining TU will be executed before any uses in | |
3357 | another TU), they can avoid this overhead with the | |
3358 | @option{-fno-extern-tls-init} option. | |
3359 | ||
3360 | On targets that support symbol aliases, the default is | |
3361 | @option{-fextern-tls-init}. On targets that do not support symbol | |
3362 | aliases, the default is @option{-fno-extern-tls-init}. | |
3363 | ||
d77de738 ML |
3364 | @opindex ffold-simple-inlines |
3365 | @opindex fno-fold-simple-inlines | |
ddf6fe37 AA |
3366 | @item -ffold-simple-inlines |
3367 | @itemx -fno-fold-simple-inlines | |
d77de738 ML |
3368 | Permit the C++ frontend to fold calls to @code{std::move}, @code{std::forward}, |
3369 | @code{std::addressof} and @code{std::as_const}. In contrast to inlining, this | |
3370 | means no debug information will be generated for such calls. Since these | |
3371 | functions are rarely interesting to debug, this flag is enabled by default | |
3372 | unless @option{-fno-inline} is active. | |
3373 | ||
d77de738 ML |
3374 | @opindex fno-gnu-keywords |
3375 | @opindex fgnu-keywords | |
ddf6fe37 | 3376 | @item -fno-gnu-keywords |
d77de738 ML |
3377 | Do not recognize @code{typeof} as a keyword, so that code can use this |
3378 | word as an identifier. You can use the keyword @code{__typeof__} instead. | |
3379 | This option is implied by the strict ISO C++ dialects: @option{-ansi}, | |
3380 | @option{-std=c++98}, @option{-std=c++11}, etc. | |
3381 | ||
d77de738 | 3382 | @opindex fimplicit-constexpr |
ddf6fe37 | 3383 | @item -fimplicit-constexpr |
d77de738 ML |
3384 | Make inline functions implicitly constexpr, if they satisfy the |
3385 | requirements for a constexpr function. This option can be used in | |
3386 | C++14 mode or later. This can result in initialization changing from | |
3387 | dynamic to static and other optimizations. | |
3388 | ||
d77de738 ML |
3389 | @opindex fno-implicit-templates |
3390 | @opindex fimplicit-templates | |
ddf6fe37 | 3391 | @item -fno-implicit-templates |
d77de738 ML |
3392 | Never emit code for non-inline templates that are instantiated |
3393 | implicitly (i.e.@: by use); only emit code for explicit instantiations. | |
3394 | If you use this option, you must take care to structure your code to | |
3395 | include all the necessary explicit instantiations to avoid getting | |
3396 | undefined symbols at link time. | |
3397 | @xref{Template Instantiation}, for more information. | |
3398 | ||
d77de738 ML |
3399 | @opindex fno-implicit-inline-templates |
3400 | @opindex fimplicit-inline-templates | |
ddf6fe37 | 3401 | @item -fno-implicit-inline-templates |
d77de738 ML |
3402 | Don't emit code for implicit instantiations of inline templates, either. |
3403 | The default is to handle inlines differently so that compiles with and | |
3404 | without optimization need the same set of explicit instantiations. | |
3405 | ||
d77de738 ML |
3406 | @opindex fno-implement-inlines |
3407 | @opindex fimplement-inlines | |
ddf6fe37 | 3408 | @item -fno-implement-inlines |
d77de738 ML |
3409 | To save space, do not emit out-of-line copies of inline functions |
3410 | controlled by @code{#pragma implementation}. This causes linker | |
3411 | errors if these functions are not inlined everywhere they are called. | |
3412 | ||
d77de738 ML |
3413 | @opindex fmodules-ts |
3414 | @opindex fno-modules-ts | |
ddf6fe37 AA |
3415 | @item -fmodules-ts |
3416 | @itemx -fno-modules-ts | |
d77de738 ML |
3417 | Enable support for C++20 modules (@pxref{C++ Modules}). The |
3418 | @option{-fno-modules-ts} is usually not needed, as that is the | |
3419 | default. Even though this is a C++20 feature, it is not currently | |
3420 | implicitly enabled by selecting that standard version. | |
3421 | ||
ddf6fe37 | 3422 | @opindex fmodule-header |
d77de738 ML |
3423 | @item -fmodule-header |
3424 | @itemx -fmodule-header=user | |
3425 | @itemx -fmodule-header=system | |
d77de738 ML |
3426 | Compile a header file to create an importable header unit. |
3427 | ||
d77de738 | 3428 | @opindex fmodule-implicit-inline |
ddf6fe37 | 3429 | @item -fmodule-implicit-inline |
d77de738 ML |
3430 | Member functions defined in their class definitions are not implicitly |
3431 | inline for modular code. This is different to traditional C++ | |
3432 | behavior, for good reasons. However, it may result in a difficulty | |
3433 | during code porting. This option makes such function definitions | |
3434 | implicitly inline. It does however generate an ABI incompatibility, | |
3435 | so you must use it everywhere or nowhere. (Such definitions outside | |
3436 | of a named module remain implicitly inline, regardless.) | |
3437 | ||
d77de738 ML |
3438 | @opindex fno-module-lazy |
3439 | @opindex fmodule-lazy | |
ddf6fe37 | 3440 | @item -fno-module-lazy |
d77de738 ML |
3441 | Disable lazy module importing and module mapper creation. |
3442 | ||
f33d7a88 AA |
3443 | @vindex CXX_MODULE_MAPPER @r{environment variable} |
3444 | @opindex fmodule-mapper | |
d77de738 ML |
3445 | @item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]} |
3446 | @itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...} | |
3447 | @itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]} | |
3448 | @itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]} | |
3449 | @itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]} | |
3450 | @itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]} | |
d77de738 ML |
3451 | An oracle to query for module name to filename mappings. If |
3452 | unspecified the @env{CXX_MODULE_MAPPER} environment variable is used, | |
3453 | and if that is unset, an in-process default is provided. | |
3454 | ||
d77de738 | 3455 | @opindex fmodule-only |
ddf6fe37 | 3456 | @item -fmodule-only |
d77de738 ML |
3457 | Only emit the Compiled Module Interface, inhibiting any object file. |
3458 | ||
d77de738 | 3459 | @opindex fms-extensions |
ddf6fe37 | 3460 | @item -fms-extensions |
d77de738 ML |
3461 | Disable Wpedantic warnings about constructs used in MFC, such as implicit |
3462 | int and getting a pointer to member function via non-standard syntax. | |
3463 | ||
d77de738 | 3464 | @opindex fnew-inheriting-ctors |
ddf6fe37 | 3465 | @item -fnew-inheriting-ctors |
d77de738 ML |
3466 | Enable the P0136 adjustment to the semantics of C++11 constructor |
3467 | inheritance. This is part of C++17 but also considered to be a Defect | |
3468 | Report against C++11 and C++14. This flag is enabled by default | |
3469 | unless @option{-fabi-version=10} or lower is specified. | |
3470 | ||
d77de738 | 3471 | @opindex fnew-ttp-matching |
ddf6fe37 | 3472 | @item -fnew-ttp-matching |
d77de738 ML |
3473 | Enable the P0522 resolution to Core issue 150, template template |
3474 | parameters and default arguments: this allows a template with default | |
3475 | template arguments as an argument for a template template parameter | |
3476 | with fewer template parameters. This flag is enabled by default for | |
3477 | @option{-std=c++17}. | |
3478 | ||
d77de738 ML |
3479 | @opindex fno-nonansi-builtins |
3480 | @opindex fnonansi-builtins | |
ddf6fe37 | 3481 | @item -fno-nonansi-builtins |
d77de738 ML |
3482 | Disable built-in declarations of functions that are not mandated by |
3483 | ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit}, | |
3484 | @code{index}, @code{bzero}, @code{conjf}, and other related functions. | |
3485 | ||
d77de738 | 3486 | @opindex fnothrow-opt |
ddf6fe37 | 3487 | @item -fnothrow-opt |
d77de738 ML |
3488 | Treat a @code{throw()} exception specification as if it were a |
3489 | @code{noexcept} specification to reduce or eliminate the text size | |
3490 | overhead relative to a function with no exception specification. If | |
3491 | the function has local variables of types with non-trivial | |
3492 | destructors, the exception specification actually makes the | |
3493 | function smaller because the EH cleanups for those variables can be | |
3494 | optimized away. The semantic effect is that an exception thrown out of | |
3495 | a function with such an exception specification results in a call | |
3496 | to @code{terminate} rather than @code{unexpected}. | |
3497 | ||
d77de738 ML |
3498 | @opindex fno-operator-names |
3499 | @opindex foperator-names | |
ddf6fe37 | 3500 | @item -fno-operator-names |
d77de738 ML |
3501 | Do not treat the operator name keywords @code{and}, @code{bitand}, |
3502 | @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as | |
3503 | synonyms as keywords. | |
3504 | ||
d77de738 ML |
3505 | @opindex fno-optional-diags |
3506 | @opindex foptional-diags | |
ddf6fe37 | 3507 | @item -fno-optional-diags |
d77de738 ML |
3508 | Disable diagnostics that the standard says a compiler does not need to |
3509 | issue. Currently, the only such diagnostic issued by G++ is the one for | |
3510 | a name having multiple meanings within a class. | |
3511 | ||
d77de738 ML |
3512 | @opindex fno-pretty-templates |
3513 | @opindex fpretty-templates | |
ddf6fe37 | 3514 | @item -fno-pretty-templates |
d77de738 ML |
3515 | When an error message refers to a specialization of a function |
3516 | template, the compiler normally prints the signature of the | |
3517 | template followed by the template arguments and any typedefs or | |
3518 | typenames in the signature (e.g.@: @code{void f(T) [with T = int]} | |
3519 | rather than @code{void f(int)}) so that it's clear which template is | |
3520 | involved. When an error message refers to a specialization of a class | |
3521 | template, the compiler omits any template arguments that match | |
3522 | the default template arguments for that template. If either of these | |
3523 | behaviors make it harder to understand the error message rather than | |
3524 | easier, you can use @option{-fno-pretty-templates} to disable them. | |
3525 | ||
d77de738 ML |
3526 | @opindex fno-rtti |
3527 | @opindex frtti | |
ddf6fe37 | 3528 | @item -fno-rtti |
d77de738 ML |
3529 | Disable generation of information about every class with virtual |
3530 | functions for use by the C++ run-time type identification features | |
3531 | (@code{dynamic_cast} and @code{typeid}). If you don't use those parts | |
3532 | of the language, you can save some space by using this flag. Note that | |
3533 | exception handling uses the same information, but G++ generates it as | |
3534 | needed. The @code{dynamic_cast} operator can still be used for casts that | |
3535 | do not require run-time type information, i.e.@: casts to @code{void *} or to | |
3536 | unambiguous base classes. | |
3537 | ||
3538 | Mixing code compiled with @option{-frtti} with that compiled with | |
3539 | @option{-fno-rtti} may not work. For example, programs may | |
3540 | fail to link if a class compiled with @option{-fno-rtti} is used as a base | |
3541 | for a class compiled with @option{-frtti}. | |
3542 | ||
d77de738 | 3543 | @opindex fsized-deallocation |
ddf6fe37 | 3544 | @item -fsized-deallocation |
d77de738 ML |
3545 | Enable the built-in global declarations |
3546 | @smallexample | |
3547 | void operator delete (void *, std::size_t) noexcept; | |
3548 | void operator delete[] (void *, std::size_t) noexcept; | |
3549 | @end smallexample | |
3550 | as introduced in C++14. This is useful for user-defined replacement | |
3551 | deallocation functions that, for example, use the size of the object | |
3552 | to make deallocation faster. Enabled by default under | |
3553 | @option{-std=c++14} and above. The flag @option{-Wsized-deallocation} | |
3554 | warns about places that might want to add a definition. | |
3555 | ||
d77de738 | 3556 | @opindex fstrict-enums |
ddf6fe37 | 3557 | @item -fstrict-enums |
d77de738 ML |
3558 | Allow the compiler to optimize using the assumption that a value of |
3559 | enumerated type can only be one of the values of the enumeration (as | |
3560 | defined in the C++ standard; basically, a value that can be | |
3561 | represented in the minimum number of bits needed to represent all the | |
3562 | enumerators). This assumption may not be valid if the program uses a | |
3563 | cast to convert an arbitrary integer value to the enumerated type. | |
d8a656d5 JW |
3564 | This option has no effect for an enumeration type with a fixed underlying |
3565 | type. | |
d77de738 | 3566 | |
d77de738 | 3567 | @opindex fstrong-eval-order |
ddf6fe37 | 3568 | @item -fstrong-eval-order |
d77de738 ML |
3569 | Evaluate member access, array subscripting, and shift expressions in |
3570 | left-to-right order, and evaluate assignment in right-to-left order, | |
3571 | as adopted for C++17. Enabled by default with @option{-std=c++17}. | |
3572 | @option{-fstrong-eval-order=some} enables just the ordering of member | |
3573 | access and shift expressions, and is the default without | |
3574 | @option{-std=c++17}. | |
3575 | ||
d77de738 | 3576 | @opindex ftemplate-backtrace-limit |
ddf6fe37 | 3577 | @item -ftemplate-backtrace-limit=@var{n} |
d77de738 ML |
3578 | Set the maximum number of template instantiation notes for a single |
3579 | warning or error to @var{n}. The default value is 10. | |
3580 | ||
d77de738 | 3581 | @opindex ftemplate-depth |
ddf6fe37 | 3582 | @item -ftemplate-depth=@var{n} |
d77de738 ML |
3583 | Set the maximum instantiation depth for template classes to @var{n}. |
3584 | A limit on the template instantiation depth is needed to detect | |
3585 | endless recursions during template class instantiation. ANSI/ISO C++ | |
3586 | conforming programs must not rely on a maximum depth greater than 17 | |
3587 | (changed to 1024 in C++11). The default value is 900, as the compiler | |
3588 | can run out of stack space before hitting 1024 in some situations. | |
3589 | ||
d77de738 ML |
3590 | @opindex fno-threadsafe-statics |
3591 | @opindex fthreadsafe-statics | |
ddf6fe37 | 3592 | @item -fno-threadsafe-statics |
d77de738 ML |
3593 | Do not emit the extra code to use the routines specified in the C++ |
3594 | ABI for thread-safe initialization of local statics. You can use this | |
3595 | option to reduce code size slightly in code that doesn't need to be | |
3596 | thread-safe. | |
3597 | ||
d77de738 | 3598 | @opindex fuse-cxa-atexit |
ddf6fe37 | 3599 | @item -fuse-cxa-atexit |
d77de738 ML |
3600 | Register destructors for objects with static storage duration with the |
3601 | @code{__cxa_atexit} function rather than the @code{atexit} function. | |
3602 | This option is required for fully standards-compliant handling of static | |
3603 | destructors, but only works if your C library supports | |
3604 | @code{__cxa_atexit}. | |
3605 | ||
d77de738 ML |
3606 | @opindex fno-use-cxa-get-exception-ptr |
3607 | @opindex fuse-cxa-get-exception-ptr | |
ddf6fe37 | 3608 | @item -fno-use-cxa-get-exception-ptr |
d77de738 ML |
3609 | Don't use the @code{__cxa_get_exception_ptr} runtime routine. This |
3610 | causes @code{std::uncaught_exception} to be incorrect, but is necessary | |
3611 | if the runtime routine is not available. | |
3612 | ||
d77de738 | 3613 | @opindex fvisibility-inlines-hidden |
ddf6fe37 | 3614 | @item -fvisibility-inlines-hidden |
d77de738 ML |
3615 | This switch declares that the user does not attempt to compare |
3616 | pointers to inline functions or methods where the addresses of the two functions | |
3617 | are taken in different shared objects. | |
3618 | ||
3619 | The effect of this is that GCC may, effectively, mark inline methods with | |
3620 | @code{__attribute__ ((visibility ("hidden")))} so that they do not | |
3621 | appear in the export table of a DSO and do not require a PLT indirection | |
3622 | when used within the DSO@. Enabling this option can have a dramatic effect | |
3623 | on load and link times of a DSO as it massively reduces the size of the | |
3624 | dynamic export table when the library makes heavy use of templates. | |
3625 | ||
3626 | The behavior of this switch is not quite the same as marking the | |
3627 | methods as hidden directly, because it does not affect static variables | |
3628 | local to the function or cause the compiler to deduce that | |
3629 | the function is defined in only one shared object. | |
3630 | ||
3631 | You may mark a method as having a visibility explicitly to negate the | |
3632 | effect of the switch for that method. For example, if you do want to | |
3633 | compare pointers to a particular inline method, you might mark it as | |
3634 | having default visibility. Marking the enclosing class with explicit | |
3635 | visibility has no effect. | |
3636 | ||
3637 | Explicitly instantiated inline methods are unaffected by this option | |
3638 | as their linkage might otherwise cross a shared library boundary. | |
3639 | @xref{Template Instantiation}. | |
3640 | ||
d77de738 | 3641 | @opindex fvisibility-ms-compat |
ddf6fe37 | 3642 | @item -fvisibility-ms-compat |
d77de738 ML |
3643 | This flag attempts to use visibility settings to make GCC's C++ |
3644 | linkage model compatible with that of Microsoft Visual Studio. | |
3645 | ||
3646 | The flag makes these changes to GCC's linkage model: | |
3647 | ||
3648 | @enumerate | |
3649 | @item | |
3650 | It sets the default visibility to @code{hidden}, like | |
3651 | @option{-fvisibility=hidden}. | |
3652 | ||
3653 | @item | |
3654 | Types, but not their members, are not hidden by default. | |
3655 | ||
3656 | @item | |
3657 | The One Definition Rule is relaxed for types without explicit | |
3658 | visibility specifications that are defined in more than one | |
3659 | shared object: those declarations are permitted if they are | |
3660 | permitted when this option is not used. | |
3661 | @end enumerate | |
3662 | ||
3663 | In new code it is better to use @option{-fvisibility=hidden} and | |
3664 | export those classes that are intended to be externally visible. | |
3665 | Unfortunately it is possible for code to rely, perhaps accidentally, | |
3666 | on the Visual Studio behavior. | |
3667 | ||
3668 | Among the consequences of these changes are that static data members | |
3669 | of the same type with the same name but defined in different shared | |
3670 | objects are different, so changing one does not change the other; | |
3671 | and that pointers to function members defined in different shared | |
3672 | objects may not compare equal. When this flag is given, it is a | |
3673 | violation of the ODR to define types with the same name differently. | |
3674 | ||
d77de738 ML |
3675 | @opindex fno-weak |
3676 | @opindex fweak | |
ddf6fe37 | 3677 | @item -fno-weak |
d77de738 ML |
3678 | Do not use weak symbol support, even if it is provided by the linker. |
3679 | By default, G++ uses weak symbols if they are available. This | |
3680 | option exists only for testing, and should not be used by end-users; | |
3681 | it results in inferior code and has no benefits. This option may | |
3682 | be removed in a future release of G++. | |
3683 | ||
d77de738 ML |
3684 | @opindex fext-numeric-literals |
3685 | @opindex fno-ext-numeric-literals | |
ddf6fe37 | 3686 | @item -fext-numeric-literals @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3687 | Accept imaginary, fixed-point, or machine-defined |
3688 | literal number suffixes as GNU extensions. | |
3689 | When this option is turned off these suffixes are treated | |
3690 | as C++11 user-defined literal numeric suffixes. | |
3691 | This is on by default for all pre-C++11 dialects and all GNU dialects: | |
3692 | @option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11}, | |
3693 | @option{-std=gnu++14}. | |
3694 | This option is off by default | |
3695 | for ISO C++11 onwards (@option{-std=c++11}, ...). | |
3696 | ||
d77de738 | 3697 | @opindex nostdinc++ |
ddf6fe37 | 3698 | @item -nostdinc++ |
d77de738 ML |
3699 | Do not search for header files in the standard directories specific to |
3700 | C++, but do still search the other standard directories. (This option | |
3701 | is used when building the C++ library.) | |
3702 | ||
ddf6fe37 AA |
3703 | @opindex flang-info-include-translate |
3704 | @opindex flang-info-include-translate-not | |
d77de738 ML |
3705 | @item -flang-info-include-translate |
3706 | @itemx -flang-info-include-translate-not | |
3707 | @itemx -flang-info-include-translate=@var{header} | |
d77de738 ML |
3708 | Inform of include translation events. The first will note accepted |
3709 | include translations, the second will note declined include | |
3710 | translations. The @var{header} form will inform of include | |
3711 | translations relating to that specific header. If @var{header} is of | |
3712 | the form @code{"user"} or @code{<system>} it will be resolved to a | |
3713 | specific user or system header using the include path. | |
3714 | ||
ddf6fe37 | 3715 | @opindex flang-info-module-cmi |
d77de738 ML |
3716 | @item -flang-info-module-cmi |
3717 | @itemx -flang-info-module-cmi=@var{module} | |
d77de738 ML |
3718 | Inform of Compiled Module Interface pathnames. The first will note |
3719 | all read CMI pathnames. The @var{module} form will not reading a | |
3720 | specific module's CMI. @var{module} may be a named module or a | |
3721 | header-unit (the latter indicated by either being a pathname containing | |
3722 | directory separators or enclosed in @code{<>} or @code{""}). | |
3723 | ||
d77de738 | 3724 | @opindex stdlib |
ddf6fe37 | 3725 | @item -stdlib=@var{libstdc++,libc++} |
d77de738 ML |
3726 | When G++ is configured to support this option, it allows specification of |
3727 | alternate C++ runtime libraries. Two options are available: @var{libstdc++} | |
3728 | (the default, native C++ runtime for G++) and @var{libc++} which is the | |
3729 | C++ runtime installed on some operating systems (e.g. Darwin versions from | |
3730 | Darwin11 onwards). The option switches G++ to use the headers from the | |
3731 | specified library and to emit @code{-lstdc++} or @code{-lc++} respectively, | |
3732 | when a C++ runtime is required for linking. | |
3733 | @end table | |
3734 | ||
3735 | In addition, these warning options have meanings only for C++ programs: | |
3736 | ||
3737 | @table @gcctabopt | |
d77de738 | 3738 | @opindex Wabi-tag |
ddf6fe37 | 3739 | @item -Wabi-tag @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3740 | Warn when a type with an ABI tag is used in a context that does not |
3741 | have that ABI tag. See @ref{C++ Attributes} for more information | |
3742 | about ABI tags. | |
3743 | ||
d77de738 ML |
3744 | @opindex Wcomma-subscript |
3745 | @opindex Wno-comma-subscript | |
ddf6fe37 | 3746 | @item -Wcomma-subscript @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3747 | Warn about uses of a comma expression within a subscripting expression. |
3748 | This usage was deprecated in C++20 and is going to be removed in C++23. | |
3749 | However, a comma expression wrapped in @code{( )} is not deprecated. Example: | |
3750 | ||
3751 | @smallexample | |
3752 | @group | |
3753 | void f(int *a, int b, int c) @{ | |
3754 | a[b,c]; // deprecated in C++20, invalid in C++23 | |
3755 | a[(b,c)]; // OK | |
3756 | @} | |
3757 | @end group | |
3758 | @end smallexample | |
3759 | ||
3760 | In C++23 it is valid to have comma separated expressions in a subscript | |
3761 | when an overloaded subscript operator is found and supports the right | |
3762 | number and types of arguments. G++ will accept the formerly valid syntax | |
3763 | for code that is not valid in C++23 but used to be valid but deprecated | |
3764 | in C++20 with a pedantic warning that can be disabled with | |
3765 | @option{-Wno-comma-subscript}. | |
3766 | ||
3767 | Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated}, | |
3768 | and with @option{-std=c++23} regardless of @option{-Wno-deprecated}. | |
3769 | ||
5fccebdb JM |
3770 | This warning is upgraded to an error by @option{-pedantic-errors} in |
3771 | C++23 mode or later. | |
3772 | ||
d77de738 ML |
3773 | @opindex Wctad-maybe-unsupported |
3774 | @opindex Wno-ctad-maybe-unsupported | |
ddf6fe37 | 3775 | @item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3776 | Warn when performing class template argument deduction (CTAD) on a type with |
3777 | no explicitly written deduction guides. This warning will point out cases | |
3778 | where CTAD succeeded only because the compiler synthesized the implicit | |
3779 | deduction guides, which might not be what the programmer intended. Certain | |
3780 | style guides allow CTAD only on types that specifically "opt-in"; i.e., on | |
3781 | types that are designed to support CTAD. This warning can be suppressed with | |
3782 | the following pattern: | |
3783 | ||
3784 | @smallexample | |
3785 | struct allow_ctad_t; // any name works | |
3786 | template <typename T> struct S @{ | |
3787 | S(T) @{ @} | |
3788 | @}; | |
4ace81b6 SL |
3789 | // Guide with incomplete parameter type will never be considered. |
3790 | S(allow_ctad_t) -> S<void>; | |
d77de738 ML |
3791 | @end smallexample |
3792 | ||
d77de738 ML |
3793 | @opindex Wctor-dtor-privacy |
3794 | @opindex Wno-ctor-dtor-privacy | |
ddf6fe37 | 3795 | @item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3796 | Warn when a class seems unusable because all the constructors or |
3797 | destructors in that class are private, and it has neither friends nor | |
3798 | public static member functions. Also warn if there are no non-private | |
3799 | methods, and there's at least one private member function that isn't | |
3800 | a constructor or destructor. | |
3801 | ||
d77de738 ML |
3802 | @opindex Wdangling-reference |
3803 | @opindex Wno-dangling-reference | |
ddf6fe37 | 3804 | @item -Wdangling-reference @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3805 | Warn when a reference is bound to a temporary whose lifetime has ended. |
3806 | For example: | |
3807 | ||
3808 | @smallexample | |
3809 | int n = 1; | |
3810 | const int& r = std::max(n - 1, n + 1); // r is dangling | |
3811 | @end smallexample | |
3812 | ||
3813 | In the example above, two temporaries are created, one for each | |
3814 | argument, and a reference to one of the temporaries is returned. | |
3815 | However, both temporaries are destroyed at the end of the full | |
3816 | expression, so the reference @code{r} is dangling. This warning | |
3817 | also detects dangling references in member initializer lists: | |
3818 | ||
3819 | @smallexample | |
3820 | const int& f(const int& i) @{ return i; @} | |
3821 | struct S @{ | |
3822 | const int &r; // r is dangling | |
3823 | S() : r(f(10)) @{ @} | |
3824 | @}; | |
3825 | @end smallexample | |
3826 | ||
3827 | Member functions are checked as well, but only their object argument: | |
3828 | ||
3829 | @smallexample | |
3830 | struct S @{ | |
3831 | const S& self () @{ return *this; @} | |
3832 | @}; | |
3833 | const S& s = S().self(); // s is dangling | |
3834 | @end smallexample | |
3835 | ||
3836 | Certain functions are safe in this respect, for example @code{std::use_facet}: | |
3837 | they take and return a reference, but they don't return one of its arguments, | |
3838 | which can fool the warning. Such functions can be excluded from the warning | |
3839 | by wrapping them in a @code{#pragma}: | |
3840 | ||
3841 | @smallexample | |
3842 | #pragma GCC diagnostic push | |
3843 | #pragma GCC diagnostic ignored "-Wdangling-reference" | |
3844 | const T& foo (const T&) @{ @dots{} @} | |
3845 | #pragma GCC diagnostic pop | |
3846 | @end smallexample | |
3847 | ||
ce51e843 ML |
3848 | @option{-Wdangling-reference} also warns about code like |
3849 | ||
3850 | @smallexample | |
3851 | auto p = std::minmax(1, 2); | |
3852 | @end smallexample | |
3853 | ||
3854 | where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and | |
3855 | both references dangle after the end of the full expression that contains | |
3856 | the call to @code{std::minmax}. | |
3857 | ||
d77de738 ML |
3858 | This warning is enabled by @option{-Wall}. |
3859 | ||
d77de738 ML |
3860 | @opindex Wdelete-non-virtual-dtor |
3861 | @opindex Wno-delete-non-virtual-dtor | |
ddf6fe37 | 3862 | @item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3863 | Warn when @code{delete} is used to destroy an instance of a class that |
3864 | has virtual functions and non-virtual destructor. It is unsafe to delete | |
3865 | an instance of a derived class through a pointer to a base class if the | |
3866 | base class does not have a virtual destructor. This warning is enabled | |
3867 | by @option{-Wall}. | |
3868 | ||
d77de738 ML |
3869 | @opindex Wdeprecated-copy |
3870 | @opindex Wno-deprecated-copy | |
ddf6fe37 | 3871 | @item -Wdeprecated-copy @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3872 | Warn that the implicit declaration of a copy constructor or copy |
3873 | assignment operator is deprecated if the class has a user-provided | |
3874 | copy constructor or copy assignment operator, in C++11 and up. This | |
3875 | warning is enabled by @option{-Wextra}. With | |
3876 | @option{-Wdeprecated-copy-dtor}, also deprecate if the class has a | |
3877 | user-provided destructor. | |
3878 | ||
d77de738 ML |
3879 | @opindex Wdeprecated-enum-enum-conversion |
3880 | @opindex Wno-deprecated-enum-enum-conversion | |
ddf6fe37 | 3881 | @item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3882 | Disable the warning about the case when the usual arithmetic conversions |
3883 | are applied on operands where one is of enumeration type and the other is | |
3884 | of a different enumeration type. This conversion was deprecated in C++20. | |
3885 | For example: | |
3886 | ||
3887 | @smallexample | |
3888 | enum E1 @{ e @}; | |
3889 | enum E2 @{ f @}; | |
3890 | int k = f - e; | |
3891 | @end smallexample | |
3892 | ||
3893 | @option{-Wdeprecated-enum-enum-conversion} is enabled by default with | |
3894 | @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled | |
3895 | by @option{-Wenum-conversion}. | |
3896 | ||
d77de738 ML |
3897 | @opindex Wdeprecated-enum-float-conversion |
3898 | @opindex Wno-deprecated-enum-float-conversion | |
ddf6fe37 | 3899 | @item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3900 | Disable the warning about the case when the usual arithmetic conversions |
3901 | are applied on operands where one is of enumeration type and the other is | |
3902 | of a floating-point type. This conversion was deprecated in C++20. For | |
3903 | example: | |
3904 | ||
3905 | @smallexample | |
3906 | enum E1 @{ e @}; | |
3907 | enum E2 @{ f @}; | |
3908 | bool b = e <= 3.7; | |
3909 | @end smallexample | |
3910 | ||
3911 | @option{-Wdeprecated-enum-float-conversion} is enabled by default with | |
3912 | @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled | |
3913 | by @option{-Wenum-conversion}. | |
3914 | ||
b106f11d AC |
3915 | @opindex Welaborated-enum-base |
3916 | @opindex Wno-elaborated-enum-base | |
3917 | @item -Wno-elaborated-enum-base | |
3918 | For C++11 and above, warn if an (invalid) additional enum-base is used | |
3919 | in an elaborated-type-specifier. That is, if an enum with given | |
3920 | underlying type and no enumerator list is used in a declaration other | |
3921 | than just a standalone declaration of the enum. Enabled by default. This | |
3922 | warning is upgraded to an error with -pedantic-errors. | |
3923 | ||
d77de738 ML |
3924 | @opindex Winit-list-lifetime |
3925 | @opindex Wno-init-list-lifetime | |
ddf6fe37 | 3926 | @item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3927 | Do not warn about uses of @code{std::initializer_list} that are likely |
3928 | to result in dangling pointers. Since the underlying array for an | |
3929 | @code{initializer_list} is handled like a normal C++ temporary object, | |
3930 | it is easy to inadvertently keep a pointer to the array past the end | |
3931 | of the array's lifetime. For example: | |
3932 | ||
3933 | @itemize @bullet | |
3934 | @item | |
3935 | If a function returns a temporary @code{initializer_list}, or a local | |
3936 | @code{initializer_list} variable, the array's lifetime ends at the end | |
3937 | of the return statement, so the value returned has a dangling pointer. | |
3938 | ||
3939 | @item | |
3940 | If a new-expression creates an @code{initializer_list}, the array only | |
3941 | lives until the end of the enclosing full-expression, so the | |
3942 | @code{initializer_list} in the heap has a dangling pointer. | |
3943 | ||
3944 | @item | |
3945 | When an @code{initializer_list} variable is assigned from a | |
3946 | brace-enclosed initializer list, the temporary array created for the | |
3947 | right side of the assignment only lives until the end of the | |
3948 | full-expression, so at the next statement the @code{initializer_list} | |
3949 | variable has a dangling pointer. | |
3950 | ||
3951 | @smallexample | |
3952 | // li's initial underlying array lives as long as li | |
3953 | std::initializer_list<int> li = @{ 1,2,3 @}; | |
3954 | // assignment changes li to point to a temporary array | |
3955 | li = @{ 4, 5 @}; | |
3956 | // now the temporary is gone and li has a dangling pointer | |
3957 | int i = li.begin()[0] // undefined behavior | |
3958 | @end smallexample | |
3959 | ||
3960 | @item | |
3961 | When a list constructor stores the @code{begin} pointer from the | |
3962 | @code{initializer_list} argument, this doesn't extend the lifetime of | |
3963 | the array, so if a class variable is constructed from a temporary | |
3964 | @code{initializer_list}, the pointer is left dangling by the end of | |
3965 | the variable declaration statement. | |
3966 | ||
3967 | @end itemize | |
3968 | ||
c85f8dbb MP |
3969 | @opindex Winvalid-constexpr |
3970 | @opindex Wno-invalid-constexpr | |
ddf6fe37 | 3971 | @item -Winvalid-constexpr |
c85f8dbb MP |
3972 | |
3973 | Warn when a function never produces a constant expression. In C++20 | |
3974 | and earlier, for every @code{constexpr} function and function template, | |
3975 | there must be at least one set of function arguments in at least one | |
3976 | instantiation such that an invocation of the function or constructor | |
3977 | could be an evaluated subexpression of a core constant expression. | |
3978 | C++23 removed this restriction, so it's possible to have a function | |
3979 | or a function template marked @code{constexpr} for which no invocation | |
3980 | satisfies the requirements of a core constant expression. | |
3981 | ||
3982 | This warning is enabled as a pedantic warning by default in C++20 and | |
3983 | earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in | |
3984 | which case it will be an ordinary warning. For example: | |
3985 | ||
3986 | @smallexample | |
3987 | void f (int& i); | |
3988 | constexpr void | |
3989 | g (int& i) | |
3990 | @{ | |
4ace81b6 SL |
3991 | // Warns by default in C++20, in C++23 only with -Winvalid-constexpr. |
3992 | f(i); | |
c85f8dbb MP |
3993 | @} |
3994 | @end smallexample | |
3995 | ||
d77de738 ML |
3996 | @opindex Winvalid-imported-macros |
3997 | @opindex Wno-invalid-imported-macros | |
ddf6fe37 | 3998 | @item -Winvalid-imported-macros |
d77de738 ML |
3999 | Verify all imported macro definitions are valid at the end of |
4000 | compilation. This is not enabled by default, as it requires | |
4001 | additional processing to determine. It may be useful when preparing | |
4002 | sets of header-units to ensure consistent macros. | |
4003 | ||
d77de738 ML |
4004 | @opindex Wliteral-suffix |
4005 | @opindex Wno-literal-suffix | |
ddf6fe37 | 4006 | @item -Wno-literal-suffix @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4007 | Do not warn when a string or character literal is followed by a |
4008 | ud-suffix which does not begin with an underscore. As a conforming | |
4009 | extension, GCC treats such suffixes as separate preprocessing tokens | |
4010 | in order to maintain backwards compatibility with code that uses | |
4011 | formatting macros from @code{<inttypes.h>}. For example: | |
4012 | ||
4013 | @smallexample | |
4014 | #define __STDC_FORMAT_MACROS | |
4015 | #include <inttypes.h> | |
4016 | #include <stdio.h> | |
4017 | ||
4018 | int main() @{ | |
4019 | int64_t i64 = 123; | |
4020 | printf("My int64: %" PRId64"\n", i64); | |
4021 | @} | |
4022 | @end smallexample | |
4023 | ||
4024 | In this case, @code{PRId64} is treated as a separate preprocessing token. | |
4025 | ||
4026 | This option also controls warnings when a user-defined literal | |
4027 | operator is declared with a literal suffix identifier that doesn't | |
4028 | begin with an underscore. Literal suffix identifiers that don't begin | |
4029 | with an underscore are reserved for future standardization. | |
4030 | ||
4031 | These warnings are enabled by default. | |
4032 | ||
d77de738 ML |
4033 | @opindex Wnarrowing |
4034 | @opindex Wno-narrowing | |
ddf6fe37 | 4035 | @item -Wno-narrowing @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4036 | For C++11 and later standards, narrowing conversions are diagnosed by default, |
4037 | as required by the standard. A narrowing conversion from a constant produces | |
4038 | an error, and a narrowing conversion from a non-constant produces a warning, | |
4039 | but @option{-Wno-narrowing} suppresses the diagnostic. | |
4040 | Note that this does not affect the meaning of well-formed code; | |
4041 | narrowing conversions are still considered ill-formed in SFINAE contexts. | |
4042 | ||
4043 | With @option{-Wnarrowing} in C++98, warn when a narrowing | |
4044 | conversion prohibited by C++11 occurs within | |
4045 | @samp{@{ @}}, e.g. | |
4046 | ||
4047 | @smallexample | |
4048 | int i = @{ 2.2 @}; // error: narrowing from double to int | |
4049 | @end smallexample | |
4050 | ||
4051 | This flag is included in @option{-Wall} and @option{-Wc++11-compat}. | |
4052 | ||
d77de738 ML |
4053 | @opindex Wnoexcept |
4054 | @opindex Wno-noexcept | |
ddf6fe37 | 4055 | @item -Wnoexcept @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4056 | Warn when a noexcept-expression evaluates to false because of a call |
4057 | to a function that does not have a non-throwing exception | |
4058 | specification (i.e. @code{throw()} or @code{noexcept}) but is known by | |
4059 | the compiler to never throw an exception. | |
4060 | ||
d77de738 ML |
4061 | @opindex Wnoexcept-type |
4062 | @opindex Wno-noexcept-type | |
ddf6fe37 | 4063 | @item -Wnoexcept-type @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4064 | Warn if the C++17 feature making @code{noexcept} part of a function |
4065 | type changes the mangled name of a symbol relative to C++14. Enabled | |
4066 | by @option{-Wabi} and @option{-Wc++17-compat}. | |
4067 | ||
4068 | As an example: | |
4069 | ||
4070 | @smallexample | |
4071 | template <class T> void f(T t) @{ t(); @}; | |
4072 | void g() noexcept; | |
4073 | void h() @{ f(g); @} | |
4074 | @end smallexample | |
4075 | ||
4076 | @noindent | |
4077 | In C++14, @code{f} calls @code{f<void(*)()>}, but in | |
4078 | C++17 it calls @code{f<void(*)()noexcept>}. | |
4079 | ||
d77de738 ML |
4080 | @opindex Wclass-memaccess |
4081 | @opindex Wno-class-memaccess | |
ddf6fe37 | 4082 | @item -Wclass-memaccess @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4083 | Warn when the destination of a call to a raw memory function such as |
4084 | @code{memset} or @code{memcpy} is an object of class type, and when writing | |
4085 | into such an object might bypass the class non-trivial or deleted constructor | |
4086 | or copy assignment, violate const-correctness or encapsulation, or corrupt | |
4087 | virtual table pointers. Modifying the representation of such objects may | |
4088 | violate invariants maintained by member functions of the class. For example, | |
4089 | the call to @code{memset} below is undefined because it modifies a non-trivial | |
4090 | class object and is, therefore, diagnosed. The safe way to either initialize | |
4091 | or clear the storage of objects of such types is by using the appropriate | |
4092 | constructor or assignment operator, if one is available. | |
4093 | @smallexample | |
4094 | std::string str = "abc"; | |
4095 | memset (&str, 0, sizeof str); | |
4096 | @end smallexample | |
4097 | The @option{-Wclass-memaccess} option is enabled by @option{-Wall}. | |
4098 | Explicitly casting the pointer to the class object to @code{void *} or | |
4099 | to a type that can be safely accessed by the raw memory function suppresses | |
4100 | the warning. | |
4101 | ||
d77de738 ML |
4102 | @opindex Wnon-virtual-dtor |
4103 | @opindex Wno-non-virtual-dtor | |
ddf6fe37 | 4104 | @item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4105 | Warn when a class has virtual functions and an accessible non-virtual |
4106 | destructor itself or in an accessible polymorphic base class, in which | |
4107 | case it is possible but unsafe to delete an instance of a derived | |
4108 | class through a pointer to the class itself or base class. This | |
4109 | warning is automatically enabled if @option{-Weffc++} is specified. | |
51f28e3a JW |
4110 | The @option{-Wdelete-non-virtual-dtor} option (enabled by @option{-Wall}) |
4111 | should be preferred because it warns about the unsafe cases without false | |
4112 | positives. | |
d77de738 | 4113 | |
d77de738 ML |
4114 | @opindex Wregister |
4115 | @opindex Wno-register | |
ddf6fe37 | 4116 | @item -Wregister @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4117 | Warn on uses of the @code{register} storage class specifier, except |
4118 | when it is part of the GNU @ref{Explicit Register Variables} extension. | |
4119 | The use of the @code{register} keyword as storage class specifier has | |
4120 | been deprecated in C++11 and removed in C++17. | |
4121 | Enabled by default with @option{-std=c++17}. | |
4122 | ||
d77de738 ML |
4123 | @opindex Wreorder |
4124 | @opindex Wno-reorder | |
4125 | @cindex reordering, warning | |
4126 | @cindex warning for reordering of member initializers | |
f33d7a88 | 4127 | @item -Wreorder @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4128 | Warn when the order of member initializers given in the code does not |
4129 | match the order in which they must be executed. For instance: | |
4130 | ||
4131 | @smallexample | |
4132 | struct A @{ | |
4133 | int i; | |
4134 | int j; | |
4135 | A(): j (0), i (1) @{ @} | |
4136 | @}; | |
4137 | @end smallexample | |
4138 | ||
4139 | @noindent | |
4140 | The compiler rearranges the member initializers for @code{i} | |
4141 | and @code{j} to match the declaration order of the members, emitting | |
4142 | a warning to that effect. This warning is enabled by @option{-Wall}. | |
4143 | ||
d77de738 ML |
4144 | @opindex Wpessimizing-move |
4145 | @opindex Wno-pessimizing-move | |
ddf6fe37 | 4146 | @item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4147 | This warning warns when a call to @code{std::move} prevents copy |
4148 | elision. A typical scenario when copy elision can occur is when returning in | |
4149 | a function with a class return type, when the expression being returned is the | |
4150 | name of a non-volatile automatic object, and is not a function parameter, and | |
4151 | has the same type as the function return type. | |
4152 | ||
4153 | @smallexample | |
4154 | struct T @{ | |
4155 | @dots{} | |
4156 | @}; | |
4157 | T fn() | |
4158 | @{ | |
4159 | T t; | |
4160 | @dots{} | |
4161 | return std::move (t); | |
4162 | @} | |
4163 | @end smallexample | |
4164 | ||
4165 | But in this example, the @code{std::move} call prevents copy elision. | |
4166 | ||
4167 | This warning is enabled by @option{-Wall}. | |
4168 | ||
d77de738 ML |
4169 | @opindex Wredundant-move |
4170 | @opindex Wno-redundant-move | |
ddf6fe37 | 4171 | @item -Wno-redundant-move @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4172 | This warning warns about redundant calls to @code{std::move}; that is, when |
4173 | a move operation would have been performed even without the @code{std::move} | |
4174 | call. This happens because the compiler is forced to treat the object as if | |
4175 | it were an rvalue in certain situations such as returning a local variable, | |
4176 | where copy elision isn't applicable. Consider: | |
4177 | ||
4178 | @smallexample | |
4179 | struct T @{ | |
4180 | @dots{} | |
4181 | @}; | |
4182 | T fn(T t) | |
4183 | @{ | |
4184 | @dots{} | |
4185 | return std::move (t); | |
4186 | @} | |
4187 | @end smallexample | |
4188 | ||
4189 | Here, the @code{std::move} call is redundant. Because G++ implements Core | |
4190 | Issue 1579, another example is: | |
4191 | ||
4192 | @smallexample | |
4193 | struct T @{ // convertible to U | |
4194 | @dots{} | |
4195 | @}; | |
4196 | struct U @{ | |
4197 | @dots{} | |
4198 | @}; | |
4199 | U fn() | |
4200 | @{ | |
4201 | T t; | |
4202 | @dots{} | |
4203 | return std::move (t); | |
4204 | @} | |
4205 | @end smallexample | |
4206 | In this example, copy elision isn't applicable because the type of the | |
4207 | expression being returned and the function return type differ, yet G++ | |
4208 | treats the return value as if it were designated by an rvalue. | |
4209 | ||
4210 | This warning is enabled by @option{-Wextra}. | |
4211 | ||
d77de738 ML |
4212 | @opindex Wrange-loop-construct |
4213 | @opindex Wno-range-loop-construct | |
ddf6fe37 | 4214 | @item -Wrange-loop-construct @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4215 | This warning warns when a C++ range-based for-loop is creating an unnecessary |
4216 | copy. This can happen when the range declaration is not a reference, but | |
4217 | probably should be. For example: | |
4218 | ||
4219 | @smallexample | |
4220 | struct S @{ char arr[128]; @}; | |
4221 | void fn () @{ | |
4222 | S arr[5]; | |
4223 | for (const auto x : arr) @{ @dots{} @} | |
4224 | @} | |
4225 | @end smallexample | |
4226 | ||
4227 | It does not warn when the type being copied is a trivially-copyable type whose | |
4228 | size is less than 64 bytes. | |
4229 | ||
4230 | This warning also warns when a loop variable in a range-based for-loop is | |
4231 | initialized with a value of a different type resulting in a copy. For example: | |
4232 | ||
4233 | @smallexample | |
4234 | void fn() @{ | |
4235 | int arr[10]; | |
4236 | for (const double &x : arr) @{ @dots{} @} | |
4237 | @} | |
4238 | @end smallexample | |
4239 | ||
4240 | In the example above, in every iteration of the loop a temporary value of | |
4241 | type @code{double} is created and destroyed, to which the reference | |
4242 | @code{const double &} is bound. | |
4243 | ||
4244 | This warning is enabled by @option{-Wall}. | |
4245 | ||
d77de738 ML |
4246 | @opindex Wredundant-tags |
4247 | @opindex Wno-redundant-tags | |
ddf6fe37 | 4248 | @item -Wredundant-tags @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4249 | Warn about redundant class-key and enum-key in references to class types |
4250 | and enumerated types in contexts where the key can be eliminated without | |
4251 | causing an ambiguity. For example: | |
4252 | ||
4253 | @smallexample | |
4254 | struct foo; | |
4255 | struct foo *p; // warn that keyword struct can be eliminated | |
4256 | @end smallexample | |
4257 | ||
4258 | @noindent | |
4259 | On the other hand, in this example there is no warning: | |
4260 | ||
4261 | @smallexample | |
4262 | struct foo; | |
4263 | void foo (); // "hides" struct foo | |
4264 | void bar (struct foo&); // no warning, keyword struct is necessary | |
4265 | @end smallexample | |
4266 | ||
d77de738 ML |
4267 | @opindex Wsubobject-linkage |
4268 | @opindex Wno-subobject-linkage | |
ddf6fe37 | 4269 | @item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4270 | Do not warn |
4271 | if a class type has a base or a field whose type uses the anonymous | |
4272 | namespace or depends on a type with no linkage. If a type A depends on | |
4273 | a type B with no or internal linkage, defining it in multiple | |
4274 | translation units would be an ODR violation because the meaning of B | |
4275 | is different in each translation unit. If A only appears in a single | |
4276 | translation unit, the best way to silence the warning is to give it | |
4277 | internal linkage by putting it in an anonymous namespace as well. The | |
4278 | compiler doesn't give this warning for types defined in the main .C | |
4279 | file, as those are unlikely to have multiple definitions. | |
4280 | @option{-Wsubobject-linkage} is enabled by default. | |
4281 | ||
d77de738 ML |
4282 | @opindex Weffc++ |
4283 | @opindex Wno-effc++ | |
ddf6fe37 | 4284 | @item -Weffc++ @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4285 | Warn about violations of the following style guidelines from Scott Meyers' |
4286 | @cite{Effective C++} series of books: | |
4287 | ||
4288 | @itemize @bullet | |
4289 | @item | |
4290 | Define a copy constructor and an assignment operator for classes | |
4291 | with dynamically-allocated memory. | |
4292 | ||
4293 | @item | |
4294 | Prefer initialization to assignment in constructors. | |
4295 | ||
4296 | @item | |
4297 | Have @code{operator=} return a reference to @code{*this}. | |
4298 | ||
4299 | @item | |
4300 | Don't try to return a reference when you must return an object. | |
4301 | ||
4302 | @item | |
4303 | Distinguish between prefix and postfix forms of increment and | |
4304 | decrement operators. | |
4305 | ||
4306 | @item | |
4307 | Never overload @code{&&}, @code{||}, or @code{,}. | |
4308 | ||
4309 | @end itemize | |
4310 | ||
4311 | This option also enables @option{-Wnon-virtual-dtor}, which is also | |
4312 | one of the effective C++ recommendations. However, the check is | |
4313 | extended to warn about the lack of virtual destructor in accessible | |
4314 | non-polymorphic bases classes too. | |
4315 | ||
4316 | When selecting this option, be aware that the standard library | |
4317 | headers do not obey all of these guidelines; use @samp{grep -v} | |
4318 | to filter out those warnings. | |
4319 | ||
d77de738 ML |
4320 | @opindex Wexceptions |
4321 | @opindex Wno-exceptions | |
ddf6fe37 | 4322 | @item -Wno-exceptions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4323 | Disable the warning about the case when an exception handler is shadowed by |
4324 | another handler, which can point out a wrong ordering of exception handlers. | |
4325 | ||
d77de738 ML |
4326 | @opindex Wstrict-null-sentinel |
4327 | @opindex Wno-strict-null-sentinel | |
ddf6fe37 | 4328 | @item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4329 | Warn about the use of an uncasted @code{NULL} as sentinel. When |
4330 | compiling only with GCC this is a valid sentinel, as @code{NULL} is defined | |
4331 | to @code{__null}. Although it is a null pointer constant rather than a | |
4332 | null pointer, it is guaranteed to be of the same size as a pointer. | |
4333 | But this use is not portable across different compilers. | |
4334 | ||
d77de738 ML |
4335 | @opindex Wno-non-template-friend |
4336 | @opindex Wnon-template-friend | |
ddf6fe37 | 4337 | @item -Wno-non-template-friend @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4338 | Disable warnings when non-template friend functions are declared |
4339 | within a template. In very old versions of GCC that predate implementation | |
4340 | of the ISO standard, declarations such as | |
4341 | @samp{friend int foo(int)}, where the name of the friend is an unqualified-id, | |
4342 | could be interpreted as a particular specialization of a template | |
4343 | function; the warning exists to diagnose compatibility problems, | |
4344 | and is enabled by default. | |
4345 | ||
d77de738 ML |
4346 | @opindex Wold-style-cast |
4347 | @opindex Wno-old-style-cast | |
ddf6fe37 | 4348 | @item -Wold-style-cast @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4349 | Warn if an old-style (C-style) cast to a non-void type is used within |
4350 | a C++ program. The new-style casts (@code{dynamic_cast}, | |
4351 | @code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are | |
4352 | less vulnerable to unintended effects and much easier to search for. | |
4353 | ||
d77de738 ML |
4354 | @opindex Woverloaded-virtual |
4355 | @opindex Wno-overloaded-virtual | |
4356 | @cindex overloaded virtual function, warning | |
4357 | @cindex warning for overloaded virtual function | |
f33d7a88 AA |
4358 | @item -Woverloaded-virtual @r{(C++ and Objective-C++ only)} |
4359 | @itemx -Woverloaded-virtual=@var{n} | |
d77de738 ML |
4360 | Warn when a function declaration hides virtual functions from a |
4361 | base class. For example, in: | |
4362 | ||
4363 | @smallexample | |
4364 | struct A @{ | |
4365 | virtual void f(); | |
4366 | @}; | |
4367 | ||
4368 | struct B: public A @{ | |
4369 | void f(int); // does not override | |
4370 | @}; | |
4371 | @end smallexample | |
4372 | ||
4373 | the @code{A} class version of @code{f} is hidden in @code{B}, and code | |
4374 | like: | |
4375 | ||
4376 | @smallexample | |
4377 | B* b; | |
4378 | b->f(); | |
4379 | @end smallexample | |
4380 | ||
4381 | @noindent | |
4382 | fails to compile. | |
4383 | ||
d82490d5 JW |
4384 | In cases where the different signatures are not an accident, the |
4385 | simplest solution is to add a using-declaration to the derived class | |
4386 | to un-hide the base function, e.g. add @code{using A::f;} to @code{B}. | |
4387 | ||
d77de738 ML |
4388 | The optional level suffix controls the behavior when all the |
4389 | declarations in the derived class override virtual functions in the | |
4390 | base class, even if not all of the base functions are overridden: | |
4391 | ||
4392 | @smallexample | |
4393 | struct C @{ | |
4394 | virtual void f(); | |
4395 | virtual void f(int); | |
4396 | @}; | |
4397 | ||
4398 | struct D: public C @{ | |
4399 | void f(int); // does override | |
4400 | @} | |
4401 | @end smallexample | |
4402 | ||
4403 | This pattern is less likely to be a mistake; if D is only used | |
4404 | virtually, the user might have decided that the base class semantics | |
4405 | for some of the overloads are fine. | |
4406 | ||
4407 | At level 1, this case does not warn; at level 2, it does. | |
4408 | @option{-Woverloaded-virtual} by itself selects level 2. Level 1 is | |
4409 | included in @option{-Wall}. | |
4410 | ||
d77de738 ML |
4411 | @opindex Wno-pmf-conversions |
4412 | @opindex Wpmf-conversions | |
ddf6fe37 | 4413 | @item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4414 | Disable the diagnostic for converting a bound pointer to member function |
4415 | to a plain pointer. | |
4416 | ||
d77de738 ML |
4417 | @opindex Wsign-promo |
4418 | @opindex Wno-sign-promo | |
ddf6fe37 | 4419 | @item -Wsign-promo @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4420 | Warn when overload resolution chooses a promotion from unsigned or |
4421 | enumerated type to a signed type, over a conversion to an unsigned type of | |
4422 | the same size. Previous versions of G++ tried to preserve | |
4423 | unsignedness, but the standard mandates the current behavior. | |
4424 | ||
d77de738 ML |
4425 | @opindex Wtemplates |
4426 | @opindex Wno-templates | |
ddf6fe37 | 4427 | @item -Wtemplates @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4428 | Warn when a primary template declaration is encountered. Some coding |
4429 | rules disallow templates, and this may be used to enforce that rule. | |
4430 | The warning is inactive inside a system header file, such as the STL, so | |
4431 | one can still use the STL. One may also instantiate or specialize | |
4432 | templates. | |
4433 | ||
d77de738 ML |
4434 | @opindex Wmismatched-new-delete |
4435 | @opindex Wno-mismatched-new-delete | |
ddf6fe37 | 4436 | @item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4437 | Warn for mismatches between calls to @code{operator new} or @code{operator |
4438 | delete} and the corresponding call to the allocation or deallocation function. | |
4439 | This includes invocations of C++ @code{operator delete} with pointers | |
4440 | returned from either mismatched forms of @code{operator new}, or from other | |
4441 | functions that allocate objects for which the @code{operator delete} isn't | |
4442 | a suitable deallocator, as well as calls to other deallocation functions | |
4443 | with pointers returned from @code{operator new} for which the deallocation | |
4444 | function isn't suitable. | |
4445 | ||
4446 | For example, the @code{delete} expression in the function below is diagnosed | |
4447 | because it doesn't match the array form of the @code{new} expression | |
4448 | the pointer argument was returned from. Similarly, the call to @code{free} | |
4449 | is also diagnosed. | |
4450 | ||
4451 | @smallexample | |
4452 | void f () | |
4453 | @{ | |
4454 | int *a = new int[n]; | |
4455 | delete a; // warning: mismatch in array forms of expressions | |
4456 | ||
4457 | char *p = new char[n]; | |
4458 | free (p); // warning: mismatch between new and free | |
4459 | @} | |
4460 | @end smallexample | |
4461 | ||
4462 | The related option @option{-Wmismatched-dealloc} diagnoses mismatches | |
4463 | involving allocation and deallocation functions other than @code{operator | |
4464 | new} and @code{operator delete}. | |
4465 | ||
4466 | @option{-Wmismatched-new-delete} is included in @option{-Wall}. | |
4467 | ||
d77de738 ML |
4468 | @opindex Wmismatched-tags |
4469 | @opindex Wno-mismatched-tags | |
ddf6fe37 | 4470 | @item -Wmismatched-tags @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4471 | Warn for declarations of structs, classes, and class templates and their |
4472 | specializations with a class-key that does not match either the definition | |
4473 | or the first declaration if no definition is provided. | |
4474 | ||
4475 | For example, the declaration of @code{struct Object} in the argument list | |
4476 | of @code{draw} triggers the warning. To avoid it, either remove the redundant | |
4477 | class-key @code{struct} or replace it with @code{class} to match its definition. | |
4478 | @smallexample | |
4479 | class Object @{ | |
4480 | public: | |
4481 | virtual ~Object () = 0; | |
4482 | @}; | |
4483 | void draw (struct Object*); | |
4484 | @end smallexample | |
4485 | ||
4486 | It is not wrong to declare a class with the class-key @code{struct} as | |
4487 | the example above shows. The @option{-Wmismatched-tags} option is intended | |
4488 | to help achieve a consistent style of class declarations. In code that is | |
4489 | intended to be portable to Windows-based compilers the warning helps prevent | |
4490 | unresolved references due to the difference in the mangling of symbols | |
4491 | declared with different class-keys. The option can be used either on its | |
4492 | own or in conjunction with @option{-Wredundant-tags}. | |
4493 | ||
d77de738 ML |
4494 | @opindex Wmultiple-inheritance |
4495 | @opindex Wno-multiple-inheritance | |
ddf6fe37 | 4496 | @item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4497 | Warn when a class is defined with multiple direct base classes. Some |
4498 | coding rules disallow multiple inheritance, and this may be used to | |
4499 | enforce that rule. The warning is inactive inside a system header file, | |
4500 | such as the STL, so one can still use the STL. One may also define | |
4501 | classes that indirectly use multiple inheritance. | |
4502 | ||
d77de738 ML |
4503 | @opindex Wvirtual-inheritance |
4504 | @opindex Wno-virtual-inheritance | |
ddf6fe37 | 4505 | @item -Wvirtual-inheritance |
d77de738 ML |
4506 | Warn when a class is defined with a virtual direct base class. Some |
4507 | coding rules disallow multiple inheritance, and this may be used to | |
4508 | enforce that rule. The warning is inactive inside a system header file, | |
4509 | such as the STL, so one can still use the STL. One may also define | |
4510 | classes that indirectly use virtual inheritance. | |
4511 | ||
d77de738 ML |
4512 | @opindex Wvirtual-move-assign |
4513 | @opindex Wno-virtual-move-assign | |
ddf6fe37 | 4514 | @item -Wno-virtual-move-assign |
d77de738 ML |
4515 | Suppress warnings about inheriting from a virtual base with a |
4516 | non-trivial C++11 move assignment operator. This is dangerous because | |
4517 | if the virtual base is reachable along more than one path, it is | |
4518 | moved multiple times, which can mean both objects end up in the | |
4519 | moved-from state. If the move assignment operator is written to avoid | |
4520 | moving from a moved-from object, this warning can be disabled. | |
4521 | ||
d77de738 ML |
4522 | @opindex Wnamespaces |
4523 | @opindex Wno-namespaces | |
ddf6fe37 | 4524 | @item -Wnamespaces |
d77de738 ML |
4525 | Warn when a namespace definition is opened. Some coding rules disallow |
4526 | namespaces, and this may be used to enforce that rule. The warning is | |
4527 | inactive inside a system header file, such as the STL, so one can still | |
4528 | use the STL. One may also use using directives and qualified names. | |
4529 | ||
d77de738 ML |
4530 | @opindex Wterminate |
4531 | @opindex Wno-terminate | |
ddf6fe37 | 4532 | @item -Wno-terminate @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4533 | Disable the warning about a throw-expression that will immediately |
4534 | result in a call to @code{terminate}. | |
4535 | ||
d77de738 ML |
4536 | @opindex Wvexing-parse |
4537 | @opindex Wno-vexing-parse | |
ddf6fe37 | 4538 | @item -Wno-vexing-parse @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4539 | Warn about the most vexing parse syntactic ambiguity. This warns about |
4540 | the cases when a declaration looks like a variable definition, but the | |
4541 | C++ language requires it to be interpreted as a function declaration. | |
4542 | For instance: | |
4543 | ||
4544 | @smallexample | |
4545 | void f(double a) @{ | |
4546 | int i(); // extern int i (void); | |
4547 | int n(int(a)); // extern int n (int); | |
4548 | @} | |
4549 | @end smallexample | |
4550 | ||
4551 | Another example: | |
4552 | ||
4553 | @smallexample | |
4554 | struct S @{ S(int); @}; | |
4555 | void f(double a) @{ | |
4556 | S x(int(a)); // extern struct S x (int); | |
4557 | S y(int()); // extern struct S y (int (*) (void)); | |
4558 | S z(); // extern struct S z (void); | |
4559 | @} | |
4560 | @end smallexample | |
4561 | ||
4562 | The warning will suggest options how to deal with such an ambiguity; e.g., | |
4563 | it can suggest removing the parentheses or using braces instead. | |
4564 | ||
4565 | This warning is enabled by default. | |
4566 | ||
d77de738 ML |
4567 | @opindex Wno-class-conversion |
4568 | @opindex Wclass-conversion | |
ddf6fe37 | 4569 | @item -Wno-class-conversion @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4570 | Do not warn when a conversion function converts an |
4571 | object to the same type, to a base class of that type, or to void; such | |
4572 | a conversion function will never be called. | |
4573 | ||
d77de738 ML |
4574 | @opindex Wvolatile |
4575 | @opindex Wno-volatile | |
ddf6fe37 | 4576 | @item -Wvolatile @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4577 | Warn about deprecated uses of the @code{volatile} qualifier. This includes |
4578 | postfix and prefix @code{++} and @code{--} expressions of | |
4579 | @code{volatile}-qualified types, using simple assignments where the left | |
4580 | operand is a @code{volatile}-qualified non-class type for their value, | |
4581 | compound assignments where the left operand is a @code{volatile}-qualified | |
4582 | non-class type, @code{volatile}-qualified function return type, | |
4583 | @code{volatile}-qualified parameter type, and structured bindings of a | |
4584 | @code{volatile}-qualified type. This usage was deprecated in C++20. | |
4585 | ||
4586 | Enabled by default with @option{-std=c++20}. | |
4587 | ||
d77de738 ML |
4588 | @opindex Wzero-as-null-pointer-constant |
4589 | @opindex Wno-zero-as-null-pointer-constant | |
ddf6fe37 | 4590 | @item -Wzero-as-null-pointer-constant @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4591 | Warn when a literal @samp{0} is used as null pointer constant. This can |
4592 | be useful to facilitate the conversion to @code{nullptr} in C++11. | |
4593 | ||
d77de738 ML |
4594 | @opindex Waligned-new |
4595 | @opindex Wno-aligned-new | |
ddf6fe37 | 4596 | @item -Waligned-new |
d77de738 ML |
4597 | Warn about a new-expression of a type that requires greater alignment |
4598 | than the @code{alignof(std::max_align_t)} but uses an allocation | |
4599 | function without an explicit alignment parameter. This option is | |
4600 | enabled by @option{-Wall}. | |
4601 | ||
4602 | Normally this only warns about global allocation functions, but | |
4603 | @option{-Waligned-new=all} also warns about class member allocation | |
4604 | functions. | |
4605 | ||
d77de738 ML |
4606 | @opindex Wplacement-new |
4607 | @opindex Wno-placement-new | |
ddf6fe37 AA |
4608 | @item -Wno-placement-new |
4609 | @itemx -Wplacement-new=@var{n} | |
d77de738 ML |
4610 | Warn about placement new expressions with undefined behavior, such as |
4611 | constructing an object in a buffer that is smaller than the type of | |
4612 | the object. For example, the placement new expression below is diagnosed | |
4613 | because it attempts to construct an array of 64 integers in a buffer only | |
4614 | 64 bytes large. | |
4615 | @smallexample | |
4616 | char buf [64]; | |
4617 | new (buf) int[64]; | |
4618 | @end smallexample | |
4619 | This warning is enabled by default. | |
4620 | ||
4621 | @table @gcctabopt | |
4622 | @item -Wplacement-new=1 | |
4623 | This is the default warning level of @option{-Wplacement-new}. At this | |
4624 | level the warning is not issued for some strictly undefined constructs that | |
4625 | GCC allows as extensions for compatibility with legacy code. For example, | |
4626 | the following @code{new} expression is not diagnosed at this level even | |
4627 | though it has undefined behavior according to the C++ standard because | |
4628 | it writes past the end of the one-element array. | |
4629 | @smallexample | |
4630 | struct S @{ int n, a[1]; @}; | |
4631 | S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]); | |
4632 | new (s->a)int [32](); | |
4633 | @end smallexample | |
4634 | ||
4635 | @item -Wplacement-new=2 | |
4636 | At this level, in addition to diagnosing all the same constructs as at level | |
4637 | 1, a diagnostic is also issued for placement new expressions that construct | |
4638 | an object in the last member of structure whose type is an array of a single | |
4639 | element and whose size is less than the size of the object being constructed. | |
4640 | While the previous example would be diagnosed, the following construct makes | |
4641 | use of the flexible member array extension to avoid the warning at level 2. | |
4642 | @smallexample | |
4643 | struct S @{ int n, a[]; @}; | |
4644 | S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]); | |
4645 | new (s->a)int [32](); | |
4646 | @end smallexample | |
4647 | ||
4648 | @end table | |
4649 | ||
d77de738 ML |
4650 | @opindex Wcatch-value |
4651 | @opindex Wno-catch-value | |
ddf6fe37 AA |
4652 | @item -Wcatch-value |
4653 | @itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)} | |
d77de738 ML |
4654 | Warn about catch handlers that do not catch via reference. |
4655 | With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short) | |
4656 | warn about polymorphic class types that are caught by value. | |
4657 | With @option{-Wcatch-value=2} warn about all class types that are caught | |
4658 | by value. With @option{-Wcatch-value=3} warn about all types that are | |
4659 | not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}. | |
4660 | ||
d77de738 ML |
4661 | @opindex Wconditionally-supported |
4662 | @opindex Wno-conditionally-supported | |
ddf6fe37 | 4663 | @item -Wconditionally-supported @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4664 | Warn for conditionally-supported (C++11 [intro.defs]) constructs. |
4665 | ||
d77de738 ML |
4666 | @opindex Wdelete-incomplete |
4667 | @opindex Wno-delete-incomplete | |
ddf6fe37 | 4668 | @item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4669 | Do not warn when deleting a pointer to incomplete type, which may cause |
4670 | undefined behavior at runtime. This warning is enabled by default. | |
4671 | ||
d77de738 ML |
4672 | @opindex Wextra-semi |
4673 | @opindex Wno-extra-semi | |
ddf6fe37 | 4674 | @item -Wextra-semi @r{(C++, Objective-C++ only)} |
d77de738 ML |
4675 | Warn about redundant semicolons after in-class function definitions. |
4676 | ||
d77de738 ML |
4677 | @opindex Winaccessible-base |
4678 | @opindex Wno-inaccessible-base | |
ddf6fe37 | 4679 | @item -Wno-inaccessible-base @r{(C++, Objective-C++ only)} |
d77de738 ML |
4680 | This option controls warnings |
4681 | when a base class is inaccessible in a class derived from it due to | |
4682 | ambiguity. The warning is enabled by default. | |
4683 | Note that the warning for ambiguous virtual | |
4684 | bases is enabled by the @option{-Wextra} option. | |
4685 | @smallexample | |
4686 | @group | |
4687 | struct A @{ int a; @}; | |
4688 | ||
4689 | struct B : A @{ @}; | |
4690 | ||
4691 | struct C : B, A @{ @}; | |
4692 | @end group | |
4693 | @end smallexample | |
4694 | ||
d77de738 ML |
4695 | @opindex Winherited-variadic-ctor |
4696 | @opindex Wno-inherited-variadic-ctor | |
ddf6fe37 | 4697 | @item -Wno-inherited-variadic-ctor |
d77de738 ML |
4698 | Suppress warnings about use of C++11 inheriting constructors when the |
4699 | base class inherited from has a C variadic constructor; the warning is | |
4700 | on by default because the ellipsis is not inherited. | |
4701 | ||
d77de738 ML |
4702 | @opindex Wno-invalid-offsetof |
4703 | @opindex Winvalid-offsetof | |
ddf6fe37 | 4704 | @item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4705 | Suppress warnings from applying the @code{offsetof} macro to a non-POD |
4706 | type. According to the 2014 ISO C++ standard, applying @code{offsetof} | |
4707 | to a non-standard-layout type is undefined. In existing C++ implementations, | |
4708 | however, @code{offsetof} typically gives meaningful results. | |
4709 | This flag is for users who are aware that they are | |
4710 | writing nonportable code and who have deliberately chosen to ignore the | |
4711 | warning about it. | |
4712 | ||
4713 | The restrictions on @code{offsetof} may be relaxed in a future version | |
4714 | of the C++ standard. | |
4715 | ||
d77de738 ML |
4716 | @opindex Wsized-deallocation |
4717 | @opindex Wno-sized-deallocation | |
ddf6fe37 | 4718 | @item -Wsized-deallocation @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4719 | Warn about a definition of an unsized deallocation function |
4720 | @smallexample | |
4721 | void operator delete (void *) noexcept; | |
4722 | void operator delete[] (void *) noexcept; | |
4723 | @end smallexample | |
4724 | without a definition of the corresponding sized deallocation function | |
4725 | @smallexample | |
4726 | void operator delete (void *, std::size_t) noexcept; | |
4727 | void operator delete[] (void *, std::size_t) noexcept; | |
4728 | @end smallexample | |
4729 | or vice versa. Enabled by @option{-Wextra} along with | |
4730 | @option{-fsized-deallocation}. | |
4731 | ||
d77de738 ML |
4732 | @opindex Wno-suggest-final-types |
4733 | @opindex Wsuggest-final-types | |
ddf6fe37 | 4734 | @item -Wsuggest-final-types |
d77de738 ML |
4735 | Warn about types with virtual methods where code quality would be improved |
4736 | if the type were declared with the C++11 @code{final} specifier, | |
4737 | or, if possible, | |
4738 | declared in an anonymous namespace. This allows GCC to more aggressively | |
4739 | devirtualize the polymorphic calls. This warning is more effective with | |
4740 | link-time optimization, | |
4741 | where the information about the class hierarchy graph is | |
4742 | more complete. | |
4743 | ||
d77de738 ML |
4744 | @opindex Wno-suggest-final-methods |
4745 | @opindex Wsuggest-final-methods | |
ddf6fe37 | 4746 | @item -Wsuggest-final-methods |
d77de738 ML |
4747 | Warn about virtual methods where code quality would be improved if the method |
4748 | were declared with the C++11 @code{final} specifier, | |
4749 | or, if possible, its type were | |
4750 | declared in an anonymous namespace or with the @code{final} specifier. | |
4751 | This warning is | |
4752 | more effective with link-time optimization, where the information about the | |
4753 | class hierarchy graph is more complete. It is recommended to first consider | |
4754 | suggestions of @option{-Wsuggest-final-types} and then rebuild with new | |
4755 | annotations. | |
4756 | ||
d77de738 ML |
4757 | @opindex Wsuggest-override |
4758 | @opindex Wno-suggest-override | |
ddf6fe37 | 4759 | @item -Wsuggest-override |
d77de738 ML |
4760 | Warn about overriding virtual functions that are not marked with the |
4761 | @code{override} keyword. | |
4762 | ||
d77de738 ML |
4763 | @opindex Wuse-after-free |
4764 | @opindex Wno-use-after-free | |
ddf6fe37 AA |
4765 | @item -Wuse-after-free |
4766 | @itemx -Wuse-after-free=@var{n} | |
d77de738 ML |
4767 | Warn about uses of pointers to dynamically allocated objects that have |
4768 | been rendered indeterminate by a call to a deallocation function. | |
4769 | The warning is enabled at all optimization levels but may yield different | |
4770 | results with optimization than without. | |
4771 | ||
4772 | @table @gcctabopt | |
4773 | @item -Wuse-after-free=1 | |
4774 | At level 1 the warning attempts to diagnose only unconditional uses | |
4775 | of pointers made indeterminate by a deallocation call or a successful | |
4776 | call to @code{realloc}, regardless of whether or not the call resulted | |
4777 | in an actual reallocatio of memory. This includes double-@code{free} | |
4778 | calls as well as uses in arithmetic and relational expressions. Although | |
4779 | undefined, uses of indeterminate pointers in equality (or inequality) | |
4780 | expressions are not diagnosed at this level. | |
4781 | @item -Wuse-after-free=2 | |
4782 | At level 2, in addition to unconditional uses, the warning also diagnoses | |
4783 | conditional uses of pointers made indeterminate by a deallocation call. | |
4784 | As at level 2, uses in equality (or inequality) expressions are not | |
4785 | diagnosed. For example, the second call to @code{free} in the following | |
4786 | function is diagnosed at this level: | |
4787 | @smallexample | |
4788 | struct A @{ int refcount; void *data; @}; | |
4789 | ||
4790 | void release (struct A *p) | |
4791 | @{ | |
4792 | int refcount = --p->refcount; | |
4793 | free (p); | |
4794 | if (refcount == 0) | |
4795 | free (p->data); // warning: p may be used after free | |
4796 | @} | |
4797 | @end smallexample | |
4798 | @item -Wuse-after-free=3 | |
4799 | At level 3, the warning also diagnoses uses of indeterminate pointers in | |
4800 | equality expressions. All uses of indeterminate pointers are undefined | |
4801 | but equality tests sometimes appear after calls to @code{realloc} as | |
4802 | an attempt to determine whether the call resulted in relocating the object | |
4803 | to a different address. They are diagnosed at a separate level to aid | |
4804 | legacy code gradually transition to safe alternatives. For example, | |
4805 | the equality test in the function below is diagnosed at this level: | |
4806 | @smallexample | |
4807 | void adjust_pointers (int**, int); | |
4808 | ||
4809 | void grow (int **p, int n) | |
4810 | @{ | |
4811 | int **q = (int**)realloc (p, n *= 2); | |
4812 | if (q == p) | |
4813 | return; | |
4814 | adjust_pointers ((int**)q, n); | |
4815 | @} | |
4816 | @end smallexample | |
4817 | To avoid the warning at this level, store offsets into allocated memory | |
4818 | instead of pointers. This approach obviates needing to adjust the stored | |
4819 | pointers after reallocation. | |
4820 | @end table | |
4821 | ||
4822 | @option{-Wuse-after-free=2} is included in @option{-Wall}. | |
4823 | ||
d77de738 ML |
4824 | @opindex Wuseless-cast |
4825 | @opindex Wno-useless-cast | |
68783211 | 4826 | @item -Wuseless-cast @r{(C, Objective-C, C++ and Objective-C++ only)} |
d77de738 ML |
4827 | Warn when an expression is cast to its own type. This warning does not |
4828 | occur when a class object is converted to a non-reference type as that | |
4829 | is a way to create a temporary: | |
4830 | ||
4831 | @smallexample | |
4832 | struct S @{ @}; | |
4833 | void g (S&&); | |
4834 | void f (S&& arg) | |
4835 | @{ | |
4836 | g (S(arg)); // make arg prvalue so that it can bind to S&& | |
4837 | @} | |
4838 | @end smallexample | |
4839 | ||
d77de738 ML |
4840 | @opindex Wconversion-null |
4841 | @opindex Wno-conversion-null | |
ddf6fe37 | 4842 | @item -Wno-conversion-null @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4843 | Do not warn for conversions between @code{NULL} and non-pointer |
4844 | types. @option{-Wconversion-null} is enabled by default. | |
4845 | ||
4846 | @end table | |
4847 | ||
4848 | @node Objective-C and Objective-C++ Dialect Options | |
4849 | @section Options Controlling Objective-C and Objective-C++ Dialects | |
4850 | ||
4851 | @cindex compiler options, Objective-C and Objective-C++ | |
4852 | @cindex Objective-C and Objective-C++ options, command-line | |
4853 | @cindex options, Objective-C and Objective-C++ | |
4854 | (NOTE: This manual does not describe the Objective-C and Objective-C++ | |
4855 | languages themselves. @xref{Standards,,Language Standards | |
4856 | Supported by GCC}, for references.) | |
4857 | ||
4858 | This section describes the command-line options that are only meaningful | |
4859 | for Objective-C and Objective-C++ programs. You can also use most of | |
4860 | the language-independent GNU compiler options. | |
4861 | For example, you might compile a file @file{some_class.m} like this: | |
4862 | ||
4863 | @smallexample | |
4864 | gcc -g -fgnu-runtime -O -c some_class.m | |
4865 | @end smallexample | |
4866 | ||
4867 | @noindent | |
4868 | In this example, @option{-fgnu-runtime} is an option meant only for | |
4869 | Objective-C and Objective-C++ programs; you can use the other options with | |
4870 | any language supported by GCC@. | |
4871 | ||
4872 | Note that since Objective-C is an extension of the C language, Objective-C | |
4873 | compilations may also use options specific to the C front-end (e.g., | |
4874 | @option{-Wtraditional}). Similarly, Objective-C++ compilations may use | |
4875 | C++-specific options (e.g., @option{-Wabi}). | |
4876 | ||
4877 | Here is a list of options that are @emph{only} for compiling Objective-C | |
4878 | and Objective-C++ programs: | |
4879 | ||
4880 | @table @gcctabopt | |
d77de738 | 4881 | @opindex fconstant-string-class |
ddf6fe37 | 4882 | @item -fconstant-string-class=@var{class-name} |
d77de738 ML |
4883 | Use @var{class-name} as the name of the class to instantiate for each |
4884 | literal string specified with the syntax @code{@@"@dots{}"}. The default | |
4885 | class name is @code{NXConstantString} if the GNU runtime is being used, and | |
cdd4b3c0 | 4886 | @code{NSConstantString} if the NeXT runtime is being used (see below). On |
a335cf24 | 4887 | Darwin / macOS platforms, the @option{-fconstant-cfstrings} option, if |
cdd4b3c0 IS |
4888 | also present, overrides the @option{-fconstant-string-class} setting and cause |
4889 | @code{@@"@dots{}"} literals to be laid out as constant CoreFoundation strings. | |
4890 | Note that @option{-fconstant-cfstrings} is an alias for the target-specific | |
4891 | @option{-mconstant-cfstrings} equivalent. | |
d77de738 | 4892 | |
d77de738 | 4893 | @opindex fgnu-runtime |
ddf6fe37 | 4894 | @item -fgnu-runtime |
d77de738 ML |
4895 | Generate object code compatible with the standard GNU Objective-C |
4896 | runtime. This is the default for most types of systems. | |
4897 | ||
d77de738 | 4898 | @opindex fnext-runtime |
ddf6fe37 | 4899 | @item -fnext-runtime |
d77de738 | 4900 | Generate output compatible with the NeXT runtime. This is the default |
a335cf24 | 4901 | for NeXT-based systems, including Darwin / macOS. The macro |
d77de738 ML |
4902 | @code{__NEXT_RUNTIME__} is predefined if (and only if) this option is |
4903 | used. | |
4904 | ||
d77de738 ML |
4905 | @opindex fno-nil-receivers |
4906 | @opindex fnil-receivers | |
ddf6fe37 | 4907 | @item -fno-nil-receivers |
d77de738 ML |
4908 | Assume that all Objective-C message dispatches (@code{[receiver |
4909 | message:arg]}) in this translation unit ensure that the receiver is | |
4910 | not @code{nil}. This allows for more efficient entry points in the | |
4911 | runtime to be used. This option is only available in conjunction with | |
4912 | the NeXT runtime and ABI version 0 or 1. | |
4913 | ||
d77de738 | 4914 | @opindex fobjc-abi-version |
ddf6fe37 | 4915 | @item -fobjc-abi-version=@var{n} |
d77de738 ML |
4916 | Use version @var{n} of the Objective-C ABI for the selected runtime. |
4917 | This option is currently supported only for the NeXT runtime. In that | |
4918 | case, Version 0 is the traditional (32-bit) ABI without support for | |
4919 | properties and other Objective-C 2.0 additions. Version 1 is the | |
4920 | traditional (32-bit) ABI with support for properties and other | |
4921 | Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If | |
4922 | nothing is specified, the default is Version 0 on 32-bit target | |
4923 | machines, and Version 2 on 64-bit target machines. | |
4924 | ||
d77de738 | 4925 | @opindex fobjc-call-cxx-cdtors |
ddf6fe37 | 4926 | @item -fobjc-call-cxx-cdtors |
d77de738 ML |
4927 | For each Objective-C class, check if any of its instance variables is a |
4928 | C++ object with a non-trivial default constructor. If so, synthesize a | |
4929 | special @code{- (id) .cxx_construct} instance method which runs | |
4930 | non-trivial default constructors on any such instance variables, in order, | |
4931 | and then return @code{self}. Similarly, check if any instance variable | |
4932 | is a C++ object with a non-trivial destructor, and if so, synthesize a | |
4933 | special @code{- (void) .cxx_destruct} method which runs | |
4934 | all such default destructors, in reverse order. | |
4935 | ||
4936 | The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct} | |
4937 | methods thusly generated only operate on instance variables | |
4938 | declared in the current Objective-C class, and not those inherited | |
4939 | from superclasses. It is the responsibility of the Objective-C | |
4940 | runtime to invoke all such methods in an object's inheritance | |
4941 | hierarchy. The @code{- (id) .cxx_construct} methods are invoked | |
4942 | by the runtime immediately after a new object instance is allocated; | |
4943 | the @code{- (void) .cxx_destruct} methods are invoked immediately | |
4944 | before the runtime deallocates an object instance. | |
4945 | ||
4946 | As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has | |
4947 | support for invoking the @code{- (id) .cxx_construct} and | |
4948 | @code{- (void) .cxx_destruct} methods. | |
4949 | ||
d77de738 | 4950 | @opindex fobjc-direct-dispatch |
ddf6fe37 | 4951 | @item -fobjc-direct-dispatch |
d77de738 ML |
4952 | Allow fast jumps to the message dispatcher. On Darwin this is |
4953 | accomplished via the comm page. | |
4954 | ||
d77de738 | 4955 | @opindex fobjc-exceptions |
ddf6fe37 | 4956 | @item -fobjc-exceptions |
d77de738 ML |
4957 | Enable syntactic support for structured exception handling in |
4958 | Objective-C, similar to what is offered by C++. This option | |
4959 | is required to use the Objective-C keywords @code{@@try}, | |
4960 | @code{@@throw}, @code{@@catch}, @code{@@finally} and | |
4961 | @code{@@synchronized}. This option is available with both the GNU | |
4962 | runtime and the NeXT runtime (but not available in conjunction with | |
4963 | the NeXT runtime on Mac OS X 10.2 and earlier). | |
4964 | ||
d77de738 | 4965 | @opindex fobjc-gc |
ddf6fe37 | 4966 | @item -fobjc-gc |
d77de738 ML |
4967 | Enable garbage collection (GC) in Objective-C and Objective-C++ |
4968 | programs. This option is only available with the NeXT runtime; the | |
4969 | GNU runtime has a different garbage collection implementation that | |
4970 | does not require special compiler flags. | |
4971 | ||
d77de738 | 4972 | @opindex fobjc-nilcheck |
ddf6fe37 | 4973 | @item -fobjc-nilcheck |
d77de738 ML |
4974 | For the NeXT runtime with version 2 of the ABI, check for a nil |
4975 | receiver in method invocations before doing the actual method call. | |
4976 | This is the default and can be disabled using | |
4977 | @option{-fno-objc-nilcheck}. Class methods and super calls are never | |
4978 | checked for nil in this way no matter what this flag is set to. | |
4979 | Currently this flag does nothing when the GNU runtime, or an older | |
4980 | version of the NeXT runtime ABI, is used. | |
4981 | ||
d77de738 | 4982 | @opindex fobjc-std |
ddf6fe37 | 4983 | @item -fobjc-std=objc1 |
d77de738 ML |
4984 | Conform to the language syntax of Objective-C 1.0, the language |
4985 | recognized by GCC 4.0. This only affects the Objective-C additions to | |
4986 | the C/C++ language; it does not affect conformance to C/C++ standards, | |
4987 | which is controlled by the separate C/C++ dialect option flags. When | |
4988 | this option is used with the Objective-C or Objective-C++ compiler, | |
4989 | any Objective-C syntax that is not recognized by GCC 4.0 is rejected. | |
4990 | This is useful if you need to make sure that your Objective-C code can | |
4991 | be compiled with older versions of GCC@. | |
4992 | ||
d77de738 | 4993 | @opindex freplace-objc-classes |
ddf6fe37 | 4994 | @item -freplace-objc-classes |
d77de738 ML |
4995 | Emit a special marker instructing @command{ld(1)} not to statically link in |
4996 | the resulting object file, and allow @command{dyld(1)} to load it in at | |
4997 | run time instead. This is used in conjunction with the Fix-and-Continue | |
4998 | debugging mode, where the object file in question may be recompiled and | |
4999 | dynamically reloaded in the course of program execution, without the need | |
5000 | to restart the program itself. Currently, Fix-and-Continue functionality | |
5001 | is only available in conjunction with the NeXT runtime on Mac OS X 10.3 | |
5002 | and later. | |
5003 | ||
d77de738 | 5004 | @opindex fzero-link |
ddf6fe37 | 5005 | @item -fzero-link |
d77de738 ML |
5006 | When compiling for the NeXT runtime, the compiler ordinarily replaces calls |
5007 | to @code{objc_getClass("@dots{}")} (when the name of the class is known at | |
5008 | compile time) with static class references that get initialized at load time, | |
5009 | which improves run-time performance. Specifying the @option{-fzero-link} flag | |
5010 | suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")} | |
5011 | to be retained. This is useful in Zero-Link debugging mode, since it allows | |
5012 | for individual class implementations to be modified during program execution. | |
5013 | The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")} | |
5014 | regardless of command-line options. | |
5015 | ||
d77de738 ML |
5016 | @opindex fno-local-ivars |
5017 | @opindex flocal-ivars | |
ddf6fe37 | 5018 | @item -fno-local-ivars |
d77de738 ML |
5019 | By default instance variables in Objective-C can be accessed as if |
5020 | they were local variables from within the methods of the class they're | |
5021 | declared in. This can lead to shadowing between instance variables | |
5022 | and other variables declared either locally inside a class method or | |
5023 | globally with the same name. Specifying the @option{-fno-local-ivars} | |
5024 | flag disables this behavior thus avoiding variable shadowing issues. | |
5025 | ||
d77de738 | 5026 | @opindex fivar-visibility |
ddf6fe37 | 5027 | @item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]} |
d77de738 ML |
5028 | Set the default instance variable visibility to the specified option |
5029 | so that instance variables declared outside the scope of any access | |
5030 | modifier directives default to the specified visibility. | |
5031 | ||
d77de738 | 5032 | @opindex gen-decls |
ddf6fe37 | 5033 | @item -gen-decls |
d77de738 ML |
5034 | Dump interface declarations for all classes seen in the source file to a |
5035 | file named @file{@var{sourcename}.decl}. | |
5036 | ||
d77de738 ML |
5037 | @opindex Wassign-intercept |
5038 | @opindex Wno-assign-intercept | |
ddf6fe37 | 5039 | @item -Wassign-intercept @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5040 | Warn whenever an Objective-C assignment is being intercepted by the |
5041 | garbage collector. | |
5042 | ||
d77de738 ML |
5043 | @opindex Wproperty-assign-default |
5044 | @opindex Wno-property-assign-default | |
ddf6fe37 | 5045 | @item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5046 | Do not warn if a property for an Objective-C object has no assign |
5047 | semantics specified. | |
5048 | ||
d77de738 ML |
5049 | @opindex Wno-protocol |
5050 | @opindex Wprotocol | |
ddf6fe37 | 5051 | @item -Wno-protocol @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5052 | If a class is declared to implement a protocol, a warning is issued for |
5053 | every method in the protocol that is not implemented by the class. The | |
5054 | default behavior is to issue a warning for every method not explicitly | |
5055 | implemented in the class, even if a method implementation is inherited | |
5056 | from the superclass. If you use the @option{-Wno-protocol} option, then | |
5057 | methods inherited from the superclass are considered to be implemented, | |
5058 | and no warning is issued for them. | |
5059 | ||
d77de738 | 5060 | @opindex Wobjc-root-class |
ddf6fe37 | 5061 | @item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5062 | Warn if a class interface lacks a superclass. Most classes will inherit |
5063 | from @code{NSObject} (or @code{Object}) for example. When declaring | |
5064 | classes intended to be root classes, the warning can be suppressed by | |
5065 | marking their interfaces with @code{__attribute__((objc_root_class))}. | |
5066 | ||
d77de738 ML |
5067 | @opindex Wselector |
5068 | @opindex Wno-selector | |
ddf6fe37 | 5069 | @item -Wselector @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5070 | Warn if multiple methods of different types for the same selector are |
5071 | found during compilation. The check is performed on the list of methods | |
5072 | in the final stage of compilation. Additionally, a check is performed | |
5073 | for each selector appearing in a @code{@@selector(@dots{})} | |
5074 | expression, and a corresponding method for that selector has been found | |
5075 | during compilation. Because these checks scan the method table only at | |
5076 | the end of compilation, these warnings are not produced if the final | |
5077 | stage of compilation is not reached, for example because an error is | |
5078 | found during compilation, or because the @option{-fsyntax-only} option is | |
5079 | being used. | |
5080 | ||
d77de738 ML |
5081 | @opindex Wstrict-selector-match |
5082 | @opindex Wno-strict-selector-match | |
ddf6fe37 | 5083 | @item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5084 | Warn if multiple methods with differing argument and/or return types are |
5085 | found for a given selector when attempting to send a message using this | |
5086 | selector to a receiver of type @code{id} or @code{Class}. When this flag | |
5087 | is off (which is the default behavior), the compiler omits such warnings | |
5088 | if any differences found are confined to types that share the same size | |
5089 | and alignment. | |
5090 | ||
d77de738 ML |
5091 | @opindex Wundeclared-selector |
5092 | @opindex Wno-undeclared-selector | |
ddf6fe37 | 5093 | @item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5094 | Warn if a @code{@@selector(@dots{})} expression referring to an |
5095 | undeclared selector is found. A selector is considered undeclared if no | |
5096 | method with that name has been declared before the | |
5097 | @code{@@selector(@dots{})} expression, either explicitly in an | |
5098 | @code{@@interface} or @code{@@protocol} declaration, or implicitly in | |
5099 | an @code{@@implementation} section. This option always performs its | |
5100 | checks as soon as a @code{@@selector(@dots{})} expression is found, | |
5101 | while @option{-Wselector} only performs its checks in the final stage of | |
5102 | compilation. This also enforces the coding style convention | |
5103 | that methods and selectors must be declared before being used. | |
5104 | ||
d77de738 | 5105 | @opindex print-objc-runtime-info |
ddf6fe37 | 5106 | @item -print-objc-runtime-info |
d77de738 ML |
5107 | Generate C header describing the largest structure that is passed by |
5108 | value, if any. | |
5109 | ||
5110 | @end table | |
5111 | ||
5112 | @node Diagnostic Message Formatting Options | |
5113 | @section Options to Control Diagnostic Messages Formatting | |
5114 | @cindex options to control diagnostics formatting | |
5115 | @cindex diagnostic messages | |
5116 | @cindex message formatting | |
5117 | ||
5118 | Traditionally, diagnostic messages have been formatted irrespective of | |
5119 | the output device's aspect (e.g.@: its width, @dots{}). You can use the | |
5120 | options described below | |
5121 | to control the formatting algorithm for diagnostic messages, | |
5122 | e.g.@: how many characters per line, how often source location | |
5123 | information should be reported. Note that some language front ends may not | |
5124 | honor these options. | |
5125 | ||
5126 | @table @gcctabopt | |
d77de738 | 5127 | @opindex fmessage-length |
ddf6fe37 | 5128 | @item -fmessage-length=@var{n} |
d77de738 ML |
5129 | Try to format error messages so that they fit on lines of about |
5130 | @var{n} characters. If @var{n} is zero, then no line-wrapping is | |
5131 | done; each error message appears on a single line. This is the | |
5132 | default for all front ends. | |
5133 | ||
5134 | Note - this option also affects the display of the @samp{#error} and | |
5135 | @samp{#warning} pre-processor directives, and the @samp{deprecated} | |
5136 | function/type/variable attribute. It does not however affect the | |
5137 | @samp{pragma GCC warning} and @samp{pragma GCC error} pragmas. | |
5138 | ||
5139 | @item -fdiagnostics-plain-output | |
5140 | This option requests that diagnostic output look as plain as possible, which | |
5141 | may be useful when running @command{dejagnu} or other utilities that need to | |
5142 | parse diagnostics output and prefer that it remain more stable over time. | |
5143 | @option{-fdiagnostics-plain-output} is currently equivalent to the following | |
5144 | options: | |
43b72ede AA |
5145 | @gccoptlist{-fno-diagnostics-show-caret |
5146 | -fno-diagnostics-show-line-numbers | |
5147 | -fdiagnostics-color=never | |
5148 | -fdiagnostics-urls=never | |
4f01ae37 DM |
5149 | -fdiagnostics-path-format=separate-events |
5150 | -fdiagnostics-text-art-charset=none} | |
d77de738 ML |
5151 | In the future, if GCC changes the default appearance of its diagnostics, the |
5152 | corresponding option to disable the new behavior will be added to this list. | |
5153 | ||
d77de738 | 5154 | @opindex fdiagnostics-show-location |
ddf6fe37 | 5155 | @item -fdiagnostics-show-location=once |
d77de738 ML |
5156 | Only meaningful in line-wrapping mode. Instructs the diagnostic messages |
5157 | reporter to emit source location information @emph{once}; that is, in | |
5158 | case the message is too long to fit on a single physical line and has to | |
5159 | be wrapped, the source location won't be emitted (as prefix) again, | |
5160 | over and over, in subsequent continuation lines. This is the default | |
5161 | behavior. | |
5162 | ||
5163 | @item -fdiagnostics-show-location=every-line | |
5164 | Only meaningful in line-wrapping mode. Instructs the diagnostic | |
5165 | messages reporter to emit the same source location information (as | |
5166 | prefix) for physical lines that result from the process of breaking | |
5167 | a message which is too long to fit on a single line. | |
5168 | ||
ddf6fe37 | 5169 | @opindex fdiagnostics-color |
d77de738 ML |
5170 | @cindex highlight, color |
5171 | @vindex GCC_COLORS @r{environment variable} | |
f33d7a88 AA |
5172 | @item -fdiagnostics-color[=@var{WHEN}] |
5173 | @itemx -fno-diagnostics-color | |
d77de738 ML |
5174 | Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always}, |
5175 | or @samp{auto}. The default depends on how the compiler has been configured, | |
5176 | it can be any of the above @var{WHEN} options or also @samp{never} | |
5177 | if @env{GCC_COLORS} environment variable isn't present in the environment, | |
5178 | and @samp{auto} otherwise. | |
5179 | @samp{auto} makes GCC use color only when the standard error is a terminal, | |
5180 | and when not executing in an emacs shell. | |
5181 | The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are | |
5182 | aliases for @option{-fdiagnostics-color=always} and | |
5183 | @option{-fdiagnostics-color=never}, respectively. | |
5184 | ||
5185 | The colors are defined by the environment variable @env{GCC_COLORS}. | |
5186 | Its value is a colon-separated list of capabilities and Select Graphic | |
5187 | Rendition (SGR) substrings. SGR commands are interpreted by the | |
5188 | terminal or terminal emulator. (See the section in the documentation | |
5189 | of your text terminal for permitted values and their meanings as | |
5190 | character attributes.) These substring values are integers in decimal | |
5191 | representation and can be concatenated with semicolons. | |
5192 | Common values to concatenate include | |
5193 | @samp{1} for bold, | |
5194 | @samp{4} for underline, | |
5195 | @samp{5} for blink, | |
5196 | @samp{7} for inverse, | |
5197 | @samp{39} for default foreground color, | |
5198 | @samp{30} to @samp{37} for foreground colors, | |
5199 | @samp{90} to @samp{97} for 16-color mode foreground colors, | |
5200 | @samp{38;5;0} to @samp{38;5;255} | |
5201 | for 88-color and 256-color modes foreground colors, | |
5202 | @samp{49} for default background color, | |
5203 | @samp{40} to @samp{47} for background colors, | |
5204 | @samp{100} to @samp{107} for 16-color mode background colors, | |
5205 | and @samp{48;5;0} to @samp{48;5;255} | |
5206 | for 88-color and 256-color modes background colors. | |
5207 | ||
5208 | The default @env{GCC_COLORS} is | |
5209 | @smallexample | |
5210 | error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\ | |
5211 | quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\ | |
5212 | diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\ | |
5213 | type-diff=01;32:fnname=01;32:targs=35 | |
5214 | @end smallexample | |
5215 | @noindent | |
5216 | where @samp{01;31} is bold red, @samp{01;35} is bold magenta, | |
5217 | @samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue, | |
5218 | @samp{01} is bold, and @samp{31} is red. | |
5219 | Setting @env{GCC_COLORS} to the empty string disables colors. | |
5220 | Supported capabilities are as follows. | |
5221 | ||
5222 | @table @code | |
d77de738 | 5223 | @vindex error GCC_COLORS @r{capability} |
f33d7a88 | 5224 | @item error= |
d77de738 ML |
5225 | SGR substring for error: markers. |
5226 | ||
d77de738 | 5227 | @vindex warning GCC_COLORS @r{capability} |
f33d7a88 | 5228 | @item warning= |
d77de738 ML |
5229 | SGR substring for warning: markers. |
5230 | ||
d77de738 | 5231 | @vindex note GCC_COLORS @r{capability} |
f33d7a88 | 5232 | @item note= |
d77de738 ML |
5233 | SGR substring for note: markers. |
5234 | ||
d77de738 | 5235 | @vindex path GCC_COLORS @r{capability} |
f33d7a88 | 5236 | @item path= |
d77de738 ML |
5237 | SGR substring for colorizing paths of control-flow events as printed |
5238 | via @option{-fdiagnostics-path-format=}, such as the identifiers of | |
5239 | individual events and lines indicating interprocedural calls and returns. | |
5240 | ||
d77de738 | 5241 | @vindex range1 GCC_COLORS @r{capability} |
f33d7a88 | 5242 | @item range1= |
d77de738 ML |
5243 | SGR substring for first additional range. |
5244 | ||
d77de738 | 5245 | @vindex range2 GCC_COLORS @r{capability} |
f33d7a88 | 5246 | @item range2= |
d77de738 ML |
5247 | SGR substring for second additional range. |
5248 | ||
d77de738 | 5249 | @vindex locus GCC_COLORS @r{capability} |
f33d7a88 | 5250 | @item locus= |
d77de738 ML |
5251 | SGR substring for location information, @samp{file:line} or |
5252 | @samp{file:line:column} etc. | |
5253 | ||
d77de738 | 5254 | @vindex quote GCC_COLORS @r{capability} |
f33d7a88 | 5255 | @item quote= |
d77de738 ML |
5256 | SGR substring for information printed within quotes. |
5257 | ||
d77de738 | 5258 | @vindex fnname GCC_COLORS @r{capability} |
f33d7a88 | 5259 | @item fnname= |
d77de738 ML |
5260 | SGR substring for names of C++ functions. |
5261 | ||
d77de738 | 5262 | @vindex targs GCC_COLORS @r{capability} |
f33d7a88 | 5263 | @item targs= |
d77de738 ML |
5264 | SGR substring for C++ function template parameter bindings. |
5265 | ||
d77de738 | 5266 | @vindex fixit-insert GCC_COLORS @r{capability} |
f33d7a88 | 5267 | @item fixit-insert= |
d77de738 ML |
5268 | SGR substring for fix-it hints suggesting text to |
5269 | be inserted or replaced. | |
5270 | ||
d77de738 | 5271 | @vindex fixit-delete GCC_COLORS @r{capability} |
f33d7a88 | 5272 | @item fixit-delete= |
d77de738 ML |
5273 | SGR substring for fix-it hints suggesting text to |
5274 | be deleted. | |
5275 | ||
d77de738 | 5276 | @vindex diff-filename GCC_COLORS @r{capability} |
f33d7a88 | 5277 | @item diff-filename= |
d77de738 ML |
5278 | SGR substring for filename headers within generated patches. |
5279 | ||
d77de738 | 5280 | @vindex diff-hunk GCC_COLORS @r{capability} |
f33d7a88 | 5281 | @item diff-hunk= |
d77de738 ML |
5282 | SGR substring for the starts of hunks within generated patches. |
5283 | ||
d77de738 | 5284 | @vindex diff-delete GCC_COLORS @r{capability} |
f33d7a88 | 5285 | @item diff-delete= |
d77de738 ML |
5286 | SGR substring for deleted lines within generated patches. |
5287 | ||
d77de738 | 5288 | @vindex diff-insert GCC_COLORS @r{capability} |
f33d7a88 | 5289 | @item diff-insert= |
d77de738 ML |
5290 | SGR substring for inserted lines within generated patches. |
5291 | ||
d77de738 | 5292 | @vindex type-diff GCC_COLORS @r{capability} |
f33d7a88 | 5293 | @item type-diff= |
d77de738 ML |
5294 | SGR substring for highlighting mismatching types within template |
5295 | arguments in the C++ frontend. | |
5296 | @end table | |
5297 | ||
d77de738 ML |
5298 | @opindex fdiagnostics-urls |
5299 | @cindex urls | |
5300 | @vindex GCC_URLS @r{environment variable} | |
5301 | @vindex TERM_URLS @r{environment variable} | |
f33d7a88 | 5302 | @item -fdiagnostics-urls[=@var{WHEN}] |
d77de738 ML |
5303 | Use escape sequences to embed URLs in diagnostics. For example, when |
5304 | @option{-fdiagnostics-show-option} emits text showing the command-line | |
5305 | option controlling a diagnostic, embed a URL for documentation of that | |
5306 | option. | |
5307 | ||
5308 | @var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}. | |
5309 | @samp{auto} makes GCC use URL escape sequences only when the standard error | |
5310 | is a terminal, and when not executing in an emacs shell or any graphical | |
5311 | terminal which is known to be incompatible with this feature, see below. | |
5312 | ||
5313 | The default depends on how the compiler has been configured. | |
5314 | It can be any of the above @var{WHEN} options. | |
5315 | ||
5316 | GCC can also be configured (via the | |
5317 | @option{--with-diagnostics-urls=auto-if-env} configure-time option) | |
5318 | so that the default is affected by environment variables. | |
5319 | Under such a configuration, GCC defaults to using @samp{auto} | |
5320 | if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are | |
5321 | present and non-empty in the environment of the compiler, or @samp{never} | |
5322 | if neither are. | |
5323 | ||
5324 | However, even with @option{-fdiagnostics-urls=always} the behavior is | |
5325 | dependent on those environment variables: | |
5326 | If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in | |
5327 | diagnostics. If set to @samp{st}, URLs use ST escape sequences. | |
5328 | If set to @samp{bel}, the default, URLs use BEL escape sequences. | |
5329 | Any other non-empty value enables the feature. | |
5330 | If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback. | |
5331 | Note: ST is an ANSI escape sequence, string terminator @samp{ESC \}, | |
5332 | BEL is an ASCII character, CTRL-G that usually sounds like a beep. | |
5333 | ||
5334 | At this time GCC tries to detect also a few terminals that are known to | |
5335 | not implement the URL feature, and have bugs or at least had bugs in | |
5336 | some versions that are still in use, where the URL escapes are likely | |
5337 | to misbehave, i.e. print garbage on the screen. | |
5338 | That list is currently xfce4-terminal, certain known to be buggy | |
5339 | gnome-terminal versions, the linux console, and mingw. | |
5340 | This check can be skipped with the @option{-fdiagnostics-urls=always}. | |
5341 | ||
d77de738 ML |
5342 | @opindex fno-diagnostics-show-option |
5343 | @opindex fdiagnostics-show-option | |
ddf6fe37 | 5344 | @item -fno-diagnostics-show-option |
d77de738 ML |
5345 | By default, each diagnostic emitted includes text indicating the |
5346 | command-line option that directly controls the diagnostic (if such an | |
5347 | option is known to the diagnostic machinery). Specifying the | |
5348 | @option{-fno-diagnostics-show-option} flag suppresses that behavior. | |
5349 | ||
d77de738 ML |
5350 | @opindex fno-diagnostics-show-caret |
5351 | @opindex fdiagnostics-show-caret | |
ddf6fe37 | 5352 | @item -fno-diagnostics-show-caret |
d77de738 ML |
5353 | By default, each diagnostic emitted includes the original source line |
5354 | and a caret @samp{^} indicating the column. This option suppresses this | |
5355 | information. The source line is truncated to @var{n} characters, if | |
5356 | the @option{-fmessage-length=n} option is given. When the output is done | |
5357 | to the terminal, the width is limited to the width given by the | |
5358 | @env{COLUMNS} environment variable or, if not set, to the terminal width. | |
5359 | ||
d77de738 ML |
5360 | @opindex fno-diagnostics-show-labels |
5361 | @opindex fdiagnostics-show-labels | |
ddf6fe37 | 5362 | @item -fno-diagnostics-show-labels |
d77de738 ML |
5363 | By default, when printing source code (via @option{-fdiagnostics-show-caret}), |
5364 | diagnostics can label ranges of source code with pertinent information, such | |
5365 | as the types of expressions: | |
5366 | ||
5367 | @smallexample | |
5368 | printf ("foo %s bar", long_i + long_j); | |
5369 | ~^ ~~~~~~~~~~~~~~~ | |
5370 | | | | |
5371 | char * long int | |
5372 | @end smallexample | |
5373 | ||
5374 | This option suppresses the printing of these labels (in the example above, | |
5375 | the vertical bars and the ``char *'' and ``long int'' text). | |
5376 | ||
d77de738 ML |
5377 | @opindex fno-diagnostics-show-cwe |
5378 | @opindex fdiagnostics-show-cwe | |
ddf6fe37 | 5379 | @item -fno-diagnostics-show-cwe |
d77de738 ML |
5380 | Diagnostic messages can optionally have an associated |
5381 | @uref{https://cwe.mitre.org/index.html, CWE} identifier. | |
5382 | GCC itself only provides such metadata for some of the @option{-fanalyzer} | |
5383 | diagnostics. GCC plugins may also provide diagnostics with such metadata. | |
5384 | By default, if this information is present, it will be printed with | |
5385 | the diagnostic. This option suppresses the printing of this metadata. | |
5386 | ||
d77de738 ML |
5387 | @opindex fno-diagnostics-show-rules |
5388 | @opindex fdiagnostics-show-rules | |
ddf6fe37 | 5389 | @item -fno-diagnostics-show-rules |
d77de738 ML |
5390 | Diagnostic messages can optionally have rules associated with them, such |
5391 | as from a coding standard, or a specification. | |
5392 | GCC itself does not do this for any of its diagnostics, but plugins may do so. | |
5393 | By default, if this information is present, it will be printed with | |
5394 | the diagnostic. This option suppresses the printing of this metadata. | |
5395 | ||
d77de738 ML |
5396 | @opindex fno-diagnostics-show-line-numbers |
5397 | @opindex fdiagnostics-show-line-numbers | |
ddf6fe37 | 5398 | @item -fno-diagnostics-show-line-numbers |
d77de738 ML |
5399 | By default, when printing source code (via @option{-fdiagnostics-show-caret}), |
5400 | a left margin is printed, showing line numbers. This option suppresses this | |
5401 | left margin. | |
5402 | ||
d77de738 | 5403 | @opindex fdiagnostics-minimum-margin-width |
ddf6fe37 | 5404 | @item -fdiagnostics-minimum-margin-width=@var{width} |
d77de738 ML |
5405 | This option controls the minimum width of the left margin printed by |
5406 | @option{-fdiagnostics-show-line-numbers}. It defaults to 6. | |
5407 | ||
d77de738 | 5408 | @opindex fdiagnostics-parseable-fixits |
ddf6fe37 | 5409 | @item -fdiagnostics-parseable-fixits |
d77de738 ML |
5410 | Emit fix-it hints in a machine-parseable format, suitable for consumption |
5411 | by IDEs. For each fix-it, a line will be printed after the relevant | |
5412 | diagnostic, starting with the string ``fix-it:''. For example: | |
5413 | ||
5414 | @smallexample | |
5415 | fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all" | |
5416 | @end smallexample | |
5417 | ||
5418 | The location is expressed as a half-open range, expressed as a count of | |
5419 | bytes, starting at byte 1 for the initial column. In the above example, | |
5420 | bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the | |
5421 | given string: | |
5422 | ||
5423 | @smallexample | |
5424 | 00000000011111111112222222222 | |
5425 | 12345678901234567890123456789 | |
5426 | gtk_widget_showall (dlg); | |
5427 | ^^^^^^^^^^^^^^^^^^ | |
5428 | gtk_widget_show_all | |
5429 | @end smallexample | |
5430 | ||
5431 | The filename and replacement string escape backslash as ``\\", tab as ``\t'', | |
5432 | newline as ``\n'', double quotes as ``\"'', non-printable characters as octal | |
5433 | (e.g. vertical tab as ``\013''). | |
5434 | ||
5435 | An empty replacement string indicates that the given range is to be removed. | |
5436 | An empty range (e.g. ``45:3-45:3'') indicates that the string is to | |
5437 | be inserted at the given position. | |
5438 | ||
d77de738 | 5439 | @opindex fdiagnostics-generate-patch |
ddf6fe37 | 5440 | @item -fdiagnostics-generate-patch |
d77de738 ML |
5441 | Print fix-it hints to stderr in unified diff format, after any diagnostics |
5442 | are printed. For example: | |
5443 | ||
5444 | @smallexample | |
5445 | --- test.c | |
5446 | +++ test.c | |
5447 | @@ -42,5 +42,5 @@ | |
5448 | ||
5449 | void show_cb(GtkDialog *dlg) | |
5450 | @{ | |
5451 | - gtk_widget_showall(dlg); | |
5452 | + gtk_widget_show_all(dlg); | |
5453 | @} | |
5454 | ||
5455 | @end smallexample | |
5456 | ||
5457 | The diff may or may not be colorized, following the same rules | |
5458 | as for diagnostics (see @option{-fdiagnostics-color}). | |
5459 | ||
d77de738 | 5460 | @opindex fdiagnostics-show-template-tree |
ddf6fe37 | 5461 | @item -fdiagnostics-show-template-tree |
d77de738 ML |
5462 | |
5463 | In the C++ frontend, when printing diagnostics showing mismatching | |
5464 | template types, such as: | |
5465 | ||
5466 | @smallexample | |
5467 | could not convert 'std::map<int, std::vector<double> >()' | |
5468 | from 'map<[...],vector<double>>' to 'map<[...],vector<float>> | |
5469 | @end smallexample | |
5470 | ||
5471 | the @option{-fdiagnostics-show-template-tree} flag enables printing a | |
5472 | tree-like structure showing the common and differing parts of the types, | |
5473 | such as: | |
5474 | ||
5475 | @smallexample | |
5476 | map< | |
5477 | [...], | |
5478 | vector< | |
5479 | [double != float]>> | |
5480 | @end smallexample | |
5481 | ||
5482 | The parts that differ are highlighted with color (``double'' and | |
5483 | ``float'' in this case). | |
5484 | ||
d77de738 ML |
5485 | @opindex fno-elide-type |
5486 | @opindex felide-type | |
ddf6fe37 | 5487 | @item -fno-elide-type |
d77de738 ML |
5488 | By default when the C++ frontend prints diagnostics showing mismatching |
5489 | template types, common parts of the types are printed as ``[...]'' to | |
5490 | simplify the error message. For example: | |
5491 | ||
5492 | @smallexample | |
5493 | could not convert 'std::map<int, std::vector<double> >()' | |
5494 | from 'map<[...],vector<double>>' to 'map<[...],vector<float>> | |
5495 | @end smallexample | |
5496 | ||
5497 | Specifying the @option{-fno-elide-type} flag suppresses that behavior. | |
5498 | This flag also affects the output of the | |
5499 | @option{-fdiagnostics-show-template-tree} flag. | |
5500 | ||
d77de738 | 5501 | @opindex fdiagnostics-path-format |
ddf6fe37 | 5502 | @item -fdiagnostics-path-format=@var{KIND} |
d77de738 ML |
5503 | Specify how to print paths of control-flow events for diagnostics that |
5504 | have such a path associated with them. | |
5505 | ||
5506 | @var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events}, | |
5507 | the default. | |
5508 | ||
5509 | @samp{none} means to not print diagnostic paths. | |
5510 | ||
5511 | @samp{separate-events} means to print a separate ``note'' diagnostic for | |
5512 | each event within the diagnostic. For example: | |
5513 | ||
5514 | @smallexample | |
5515 | test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter | |
5516 | test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL | |
5517 | test.c:27:3: note: (2) when 'i < count' | |
5518 | test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1 | |
5519 | @end smallexample | |
5520 | ||
5521 | @samp{inline-events} means to print the events ``inline'' within the source | |
5522 | code. This view attempts to consolidate the events into runs of | |
5523 | sufficiently-close events, printing them as labelled ranges within the source. | |
5524 | ||
5525 | For example, the same events as above might be printed as: | |
5526 | ||
5527 | @smallexample | |
5528 | 'test': events 1-3 | |
5529 | | | |
5530 | | 25 | list = PyList_New(0); | |
5531 | | | ^~~~~~~~~~~~~ | |
5532 | | | | | |
5533 | | | (1) when 'PyList_New' fails, returning NULL | |
5534 | | 26 | | |
5535 | | 27 | for (i = 0; i < count; i++) @{ | |
5536 | | | ~~~ | |
5537 | | | | | |
5538 | | | (2) when 'i < count' | |
5539 | | 28 | item = PyLong_FromLong(random()); | |
5540 | | 29 | PyList_Append(list, item); | |
5541 | | | ~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5542 | | | | | |
5543 | | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1 | |
5544 | | | |
5545 | @end smallexample | |
5546 | ||
5547 | Interprocedural control flow is shown by grouping the events by stack frame, | |
5548 | and using indentation to show how stack frames are nested, pushed, and popped. | |
5549 | ||
5550 | For example: | |
5551 | ||
5552 | @smallexample | |
5553 | 'test': events 1-2 | |
5554 | | | |
5555 | | 133 | @{ | |
5556 | | | ^ | |
5557 | | | | | |
5558 | | | (1) entering 'test' | |
5559 | | 134 | boxed_int *obj = make_boxed_int (i); | |
5560 | | | ~~~~~~~~~~~~~~~~~~ | |
5561 | | | | | |
5562 | | | (2) calling 'make_boxed_int' | |
5563 | | | |
5564 | +--> 'make_boxed_int': events 3-4 | |
5565 | | | |
5566 | | 120 | @{ | |
5567 | | | ^ | |
5568 | | | | | |
5569 | | | (3) entering 'make_boxed_int' | |
5570 | | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int)); | |
5571 | | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5572 | | | | | |
5573 | | | (4) calling 'wrapped_malloc' | |
5574 | | | |
5575 | +--> 'wrapped_malloc': events 5-6 | |
5576 | | | |
5577 | | 7 | @{ | |
5578 | | | ^ | |
5579 | | | | | |
5580 | | | (5) entering 'wrapped_malloc' | |
5581 | | 8 | return malloc (size); | |
5582 | | | ~~~~~~~~~~~~~ | |
5583 | | | | | |
5584 | | | (6) calling 'malloc' | |
5585 | | | |
5586 | <-------------+ | |
5587 | | | |
5588 | 'test': event 7 | |
5589 | | | |
5590 | | 138 | free_boxed_int (obj); | |
5591 | | | ^~~~~~~~~~~~~~~~~~~~ | |
5592 | | | | | |
5593 | | | (7) calling 'free_boxed_int' | |
5594 | | | |
5595 | (etc) | |
5596 | @end smallexample | |
5597 | ||
d77de738 | 5598 | @opindex fdiagnostics-show-path-depths |
ddf6fe37 | 5599 | @item -fdiagnostics-show-path-depths |
d77de738 ML |
5600 | This option provides additional information when printing control-flow paths |
5601 | associated with a diagnostic. | |
5602 | ||
5603 | If this is option is provided then the stack depth will be printed for | |
5604 | each run of events within @option{-fdiagnostics-path-format=inline-events}. | |
5605 | If provided with @option{-fdiagnostics-path-format=separate-events}, then | |
5606 | the stack depth and function declaration will be appended when printing | |
5607 | each event. | |
5608 | ||
5609 | This is intended for use by GCC developers and plugin developers when | |
5610 | debugging diagnostics that report interprocedural control flow. | |
5611 | ||
d77de738 ML |
5612 | @opindex fno-show-column |
5613 | @opindex fshow-column | |
ddf6fe37 | 5614 | @item -fno-show-column |
d77de738 ML |
5615 | Do not print column numbers in diagnostics. This may be necessary if |
5616 | diagnostics are being scanned by a program that does not understand the | |
5617 | column numbers, such as @command{dejagnu}. | |
5618 | ||
d77de738 | 5619 | @opindex fdiagnostics-column-unit |
ddf6fe37 | 5620 | @item -fdiagnostics-column-unit=@var{UNIT} |
d77de738 ML |
5621 | Select the units for the column number. This affects traditional diagnostics |
5622 | (in the absence of @option{-fno-show-column}), as well as JSON format | |
5623 | diagnostics if requested. | |
5624 | ||
5625 | The default @var{UNIT}, @samp{display}, considers the number of display | |
5626 | columns occupied by each character. This may be larger than the number | |
5627 | of bytes required to encode the character, in the case of tab | |
5628 | characters, or it may be smaller, in the case of multibyte characters. | |
5629 | For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one | |
5630 | display column, and its UTF-8 encoding requires two bytes; the character | |
5631 | ``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and | |
5632 | its UTF-8 encoding requires four bytes. | |
5633 | ||
5634 | Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte | |
5635 | count in all cases, as was traditionally output by GCC prior to version 11.1.0. | |
5636 | ||
d77de738 | 5637 | @opindex fdiagnostics-column-origin |
ddf6fe37 | 5638 | @item -fdiagnostics-column-origin=@var{ORIGIN} |
d77de738 ML |
5639 | Select the origin for column numbers, i.e. the column number assigned to the |
5640 | first column. The default value of 1 corresponds to traditional GCC | |
5641 | behavior and to the GNU style guide. Some utilities may perform better with an | |
5642 | origin of 0; any non-negative value may be specified. | |
5643 | ||
d77de738 | 5644 | @opindex fdiagnostics-escape-format |
ddf6fe37 | 5645 | @item -fdiagnostics-escape-format=@var{FORMAT} |
d77de738 ML |
5646 | When GCC prints pertinent source lines for a diagnostic it normally attempts |
5647 | to print the source bytes directly. However, some diagnostics relate to encoding | |
5648 | issues in the source file, such as malformed UTF-8, or issues with Unicode | |
5649 | normalization. These diagnostics are flagged so that GCC will escape bytes | |
5650 | that are not printable ASCII when printing their pertinent source lines. | |
5651 | ||
5652 | This option controls how such bytes should be escaped. | |
5653 | ||
5654 | The default @var{FORMAT}, @samp{unicode} displays Unicode characters that | |
5655 | are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not | |
5656 | correspond to a Unicode character validly-encoded in UTF-8-encoded will be | |
5657 | displayed as hexadecimal in the form @samp{<XX>}. | |
5658 | ||
5659 | For example, a source line containing the string @samp{before} followed by the | |
5660 | Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding | |
5661 | 0xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by | |
5662 | the string @samp{after} will be printed for such a diagnostic as: | |
5663 | ||
5664 | @smallexample | |
5665 | before<U+03C0><BF>after | |
5666 | @end smallexample | |
5667 | ||
5668 | Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes | |
5669 | in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII | |
5670 | Unicode characters. For the example above, the following will be printed: | |
5671 | ||
5672 | @smallexample | |
5673 | before<CF><80><BF>after | |
5674 | @end smallexample | |
5675 | ||
4f01ae37 DM |
5676 | @opindex fdiagnostics-text-art-charset |
5677 | @item -fdiagnostics-text-art-charset=@var{CHARSET} | |
5678 | Some diagnostics can contain ``text art'' diagrams: visualizations created | |
5679 | from text, intended to be viewed in a monospaced font. | |
5680 | ||
5681 | This option selects which characters should be used for printing such | |
5682 | diagrams, if any. @var{CHARSET} is @samp{none}, @samp{ascii}, @samp{unicode}, | |
5683 | or @samp{emoji}. | |
5684 | ||
5685 | The @samp{none} value suppresses the printing of such diagrams. | |
5686 | The @samp{ascii} value will ensure that such diagrams are pure ASCII | |
5687 | (``ASCII art''). The @samp{unicode} value will allow for conservative use of | |
5688 | unicode drawing characters (such as box-drawing characters). The @samp{emoji} | |
5689 | value further adds the possibility of emoji in the output (such as emitting | |
5690 | U+26A0 WARNING SIGN followed by U+FE0F VARIATION SELECTOR-16 to select the | |
5691 | emoji variant of the character). | |
5692 | ||
04013e44 DM |
5693 | The default is @samp{emoji}, except when the environment variable @env{LANG} |
5694 | is set to @samp{C}, in which case the default is @samp{ascii}. | |
4f01ae37 | 5695 | |
d77de738 | 5696 | @opindex fdiagnostics-format |
ddf6fe37 | 5697 | @item -fdiagnostics-format=@var{FORMAT} |
d77de738 ML |
5698 | Select a different format for printing diagnostics. |
5699 | @var{FORMAT} is @samp{text}, @samp{sarif-stderr}, @samp{sarif-file}, | |
5700 | @samp{json}, @samp{json-stderr}, or @samp{json-file}. | |
5701 | ||
5702 | The default is @samp{text}. | |
5703 | ||
5704 | The @samp{sarif-stderr} and @samp{sarif-file} formats both emit | |
5705 | diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file | |
5706 | named @file{@var{source}.sarif}, respectively. | |
5707 | ||
5708 | The @samp{json} format is a synonym for @samp{json-stderr}. | |
5709 | The @samp{json-stderr} and @samp{json-file} formats are identical, apart from | |
5710 | where the JSON is emitted to - with the former, the JSON is emitted to stderr, | |
5711 | whereas with @samp{json-file} it is written to @file{@var{source}.gcc.json}. | |
5712 | ||
5713 | The emitted JSON consists of a top-level JSON array containing JSON objects | |
5714 | representing the diagnostics. The JSON is emitted as one line, without | |
5715 | formatting; the examples below have been formatted for clarity. | |
5716 | ||
5717 | Diagnostics can have child diagnostics. For example, this error and note: | |
5718 | ||
5719 | @smallexample | |
5720 | misleading-indentation.c:15:3: warning: this 'if' clause does not | |
5721 | guard... [-Wmisleading-indentation] | |
5722 | 15 | if (flag) | |
5723 | | ^~ | |
5724 | misleading-indentation.c:17:5: note: ...this statement, but the latter | |
5725 | is misleadingly indented as if it were guarded by the 'if' | |
5726 | 17 | y = 2; | |
5727 | | ^ | |
5728 | @end smallexample | |
5729 | ||
5730 | @noindent | |
5731 | might be printed in JSON form (after formatting) like this: | |
5732 | ||
5733 | @smallexample | |
5734 | [ | |
5735 | @{ | |
5736 | "kind": "warning", | |
5737 | "locations": [ | |
5738 | @{ | |
5739 | "caret": @{ | |
5740 | "display-column": 3, | |
5741 | "byte-column": 3, | |
5742 | "column": 3, | |
5743 | "file": "misleading-indentation.c", | |
5744 | "line": 15 | |
5745 | @}, | |
5746 | "finish": @{ | |
5747 | "display-column": 4, | |
5748 | "byte-column": 4, | |
5749 | "column": 4, | |
5750 | "file": "misleading-indentation.c", | |
5751 | "line": 15 | |
5752 | @} | |
5753 | @} | |
5754 | ], | |
5755 | "message": "this \u2018if\u2019 clause does not guard...", | |
5756 | "option": "-Wmisleading-indentation", | |
5757 | "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation", | |
5758 | "children": [ | |
5759 | @{ | |
5760 | "kind": "note", | |
5761 | "locations": [ | |
5762 | @{ | |
5763 | "caret": @{ | |
5764 | "display-column": 5, | |
5765 | "byte-column": 5, | |
5766 | "column": 5, | |
5767 | "file": "misleading-indentation.c", | |
5768 | "line": 17 | |
5769 | @} | |
5770 | @} | |
5771 | ], | |
5772 | "escape-source": false, | |
5773 | "message": "...this statement, but the latter is @dots{}" | |
5774 | @} | |
5775 | ] | |
5776 | "escape-source": false, | |
5777 | "column-origin": 1, | |
5778 | @} | |
5779 | ] | |
5780 | @end smallexample | |
5781 | ||
5782 | @noindent | |
5783 | where the @code{note} is a child of the @code{warning}. | |
5784 | ||
5785 | A diagnostic has a @code{kind}. If this is @code{warning}, then there is | |
5786 | an @code{option} key describing the command-line option controlling the | |
5787 | warning. | |
5788 | ||
5789 | A diagnostic can contain zero or more locations. Each location has an | |
5790 | optional @code{label} string and up to three positions within it: a | |
5791 | @code{caret} position and optional @code{start} and @code{finish} positions. | |
5792 | A position is described by a @code{file} name, a @code{line} number, and | |
5793 | three numbers indicating a column position: | |
5794 | @itemize @bullet | |
5795 | ||
5796 | @item | |
5797 | @code{display-column} counts display columns, accounting for tabs and | |
5798 | multibyte characters. | |
5799 | ||
5800 | @item | |
5801 | @code{byte-column} counts raw bytes. | |
5802 | ||
5803 | @item | |
5804 | @code{column} is equal to one of | |
5805 | the previous two, as dictated by the @option{-fdiagnostics-column-unit} | |
5806 | option. | |
5807 | ||
5808 | @end itemize | |
5809 | All three columns are relative to the origin specified by | |
5810 | @option{-fdiagnostics-column-origin}, which is typically equal to 1 but may | |
5811 | be set, for instance, to 0 for compatibility with other utilities that | |
5812 | number columns from 0. The column origin is recorded in the JSON output in | |
5813 | the @code{column-origin} tag. In the remaining examples below, the extra | |
5814 | column number outputs have been omitted for brevity. | |
5815 | ||
5816 | For example, this error: | |
5817 | ||
5818 | @smallexample | |
5819 | bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' @{aka | |
5820 | 'struct s'@} and 'T' @{aka 'struct t'@}) | |
5821 | 64 | return callee_4a () + callee_4b (); | |
5822 | | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~ | |
5823 | | | | | |
5824 | | | T @{aka struct t@} | |
5825 | | S @{aka struct s@} | |
5826 | @end smallexample | |
5827 | ||
5828 | @noindent | |
5829 | has three locations. Its primary location is at the ``+'' token at column | |
5830 | 23. It has two secondary locations, describing the left and right-hand sides | |
5831 | of the expression, which have labels. It might be printed in JSON form as: | |
5832 | ||
5833 | @smallexample | |
5834 | @{ | |
5835 | "children": [], | |
5836 | "kind": "error", | |
5837 | "locations": [ | |
5838 | @{ | |
5839 | "caret": @{ | |
5840 | "column": 23, "file": "bad-binary-ops.c", "line": 64 | |
5841 | @} | |
5842 | @}, | |
5843 | @{ | |
5844 | "caret": @{ | |
5845 | "column": 10, "file": "bad-binary-ops.c", "line": 64 | |
5846 | @}, | |
5847 | "finish": @{ | |
5848 | "column": 21, "file": "bad-binary-ops.c", "line": 64 | |
5849 | @}, | |
5850 | "label": "S @{aka struct s@}" | |
5851 | @}, | |
5852 | @{ | |
5853 | "caret": @{ | |
5854 | "column": 25, "file": "bad-binary-ops.c", "line": 64 | |
5855 | @}, | |
5856 | "finish": @{ | |
5857 | "column": 36, "file": "bad-binary-ops.c", "line": 64 | |
5858 | @}, | |
5859 | "label": "T @{aka struct t@}" | |
5860 | @} | |
5861 | ], | |
5862 | "escape-source": false, | |
5863 | "message": "invalid operands to binary + @dots{}" | |
5864 | @} | |
5865 | @end smallexample | |
5866 | ||
5867 | If a diagnostic contains fix-it hints, it has a @code{fixits} array, | |
5868 | consisting of half-open intervals, similar to the output of | |
5869 | @option{-fdiagnostics-parseable-fixits}. For example, this diagnostic | |
5870 | with a replacement fix-it hint: | |
5871 | ||
5872 | @smallexample | |
5873 | demo.c:8:15: error: 'struct s' has no member named 'colour'; did you | |
5874 | mean 'color'? | |
5875 | 8 | return ptr->colour; | |
5876 | | ^~~~~~ | |
5877 | | color | |
5878 | @end smallexample | |
5879 | ||
5880 | @noindent | |
5881 | might be printed in JSON form as: | |
5882 | ||
5883 | @smallexample | |
5884 | @{ | |
5885 | "children": [], | |
5886 | "fixits": [ | |
5887 | @{ | |
5888 | "next": @{ | |
5889 | "column": 21, | |
5890 | "file": "demo.c", | |
5891 | "line": 8 | |
5892 | @}, | |
5893 | "start": @{ | |
5894 | "column": 15, | |
5895 | "file": "demo.c", | |
5896 | "line": 8 | |
5897 | @}, | |
5898 | "string": "color" | |
5899 | @} | |
5900 | ], | |
5901 | "kind": "error", | |
5902 | "locations": [ | |
5903 | @{ | |
5904 | "caret": @{ | |
5905 | "column": 15, | |
5906 | "file": "demo.c", | |
5907 | "line": 8 | |
5908 | @}, | |
5909 | "finish": @{ | |
5910 | "column": 20, | |
5911 | "file": "demo.c", | |
5912 | "line": 8 | |
5913 | @} | |
5914 | @} | |
5915 | ], | |
5916 | "escape-source": false, | |
5917 | "message": "\u2018struct s\u2019 has no member named @dots{}" | |
5918 | @} | |
5919 | @end smallexample | |
5920 | ||
5921 | @noindent | |
5922 | where the fix-it hint suggests replacing the text from @code{start} up | |
5923 | to but not including @code{next} with @code{string}'s value. Deletions | |
5924 | are expressed via an empty value for @code{string}, insertions by | |
5925 | having @code{start} equal @code{next}. | |
5926 | ||
5927 | If the diagnostic has a path of control-flow events associated with it, | |
5928 | it has a @code{path} array of objects representing the events. Each | |
5929 | event object has a @code{description} string, a @code{location} object, | |
5930 | along with a @code{function} string and a @code{depth} number for | |
5931 | representing interprocedural paths. The @code{function} represents the | |
5932 | current function at that event, and the @code{depth} represents the | |
5933 | stack depth relative to some baseline: the higher, the more frames are | |
5934 | within the stack. | |
5935 | ||
5936 | For example, the intraprocedural example shown for | |
5937 | @option{-fdiagnostics-path-format=} might have this JSON for its path: | |
5938 | ||
5939 | @smallexample | |
5940 | "path": [ | |
5941 | @{ | |
5942 | "depth": 0, | |
5943 | "description": "when 'PyList_New' fails, returning NULL", | |
5944 | "function": "test", | |
5945 | "location": @{ | |
5946 | "column": 10, | |
5947 | "file": "test.c", | |
5948 | "line": 25 | |
5949 | @} | |
5950 | @}, | |
5951 | @{ | |
5952 | "depth": 0, | |
5953 | "description": "when 'i < count'", | |
5954 | "function": "test", | |
5955 | "location": @{ | |
5956 | "column": 3, | |
5957 | "file": "test.c", | |
5958 | "line": 27 | |
5959 | @} | |
5960 | @}, | |
5961 | @{ | |
5962 | "depth": 0, | |
5963 | "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1", | |
5964 | "function": "test", | |
5965 | "location": @{ | |
5966 | "column": 5, | |
5967 | "file": "test.c", | |
5968 | "line": 29 | |
5969 | @} | |
5970 | @} | |
5971 | ] | |
5972 | @end smallexample | |
5973 | ||
5974 | Diagnostics have a boolean attribute @code{escape-source}, hinting whether | |
5975 | non-ASCII bytes should be escaped when printing the pertinent lines of | |
5976 | source code (@code{true} for diagnostics involving source encoding issues). | |
5977 | ||
5978 | @end table | |
5979 | ||
5980 | @node Warning Options | |
5981 | @section Options to Request or Suppress Warnings | |
5982 | @cindex options to control warnings | |
5983 | @cindex warning messages | |
5984 | @cindex messages, warning | |
5985 | @cindex suppressing warnings | |
5986 | ||
5987 | Warnings are diagnostic messages that report constructions that | |
5988 | are not inherently erroneous but that are risky or suggest there | |
5989 | may have been an error. | |
5990 | ||
5991 | The following language-independent options do not enable specific | |
5992 | warnings but control the kinds of diagnostics produced by GCC@. | |
5993 | ||
5994 | @table @gcctabopt | |
5995 | @cindex syntax checking | |
d77de738 | 5996 | @opindex fsyntax-only |
ddf6fe37 | 5997 | @item -fsyntax-only |
d77de738 ML |
5998 | Check the code for syntax errors, but don't do anything beyond that. |
5999 | ||
d77de738 | 6000 | @opindex fmax-errors |
ddf6fe37 | 6001 | @item -fmax-errors=@var{n} |
d77de738 ML |
6002 | Limits the maximum number of error messages to @var{n}, at which point |
6003 | GCC bails out rather than attempting to continue processing the source | |
6004 | code. If @var{n} is 0 (the default), there is no limit on the number | |
6005 | of error messages produced. If @option{-Wfatal-errors} is also | |
6006 | specified, then @option{-Wfatal-errors} takes precedence over this | |
6007 | option. | |
6008 | ||
d77de738 | 6009 | @opindex w |
ddf6fe37 | 6010 | @item -w |
d77de738 ML |
6011 | Inhibit all warning messages. |
6012 | ||
d77de738 ML |
6013 | @opindex Werror |
6014 | @opindex Wno-error | |
ddf6fe37 | 6015 | @item -Werror |
d77de738 ML |
6016 | Make all warnings into errors. |
6017 | ||
d77de738 ML |
6018 | @opindex Werror= |
6019 | @opindex Wno-error= | |
ddf6fe37 | 6020 | @item -Werror= |
d77de738 ML |
6021 | Make the specified warning into an error. The specifier for a warning |
6022 | is appended; for example @option{-Werror=switch} turns the warnings | |
6023 | controlled by @option{-Wswitch} into errors. This switch takes a | |
6024 | negative form, to be used to negate @option{-Werror} for specific | |
6025 | warnings; for example @option{-Wno-error=switch} makes | |
6026 | @option{-Wswitch} warnings not be errors, even when @option{-Werror} | |
6027 | is in effect. | |
6028 | ||
6029 | The warning message for each controllable warning includes the | |
6030 | option that controls the warning. That option can then be used with | |
6031 | @option{-Werror=} and @option{-Wno-error=} as described above. | |
6032 | (Printing of the option in the warning message can be disabled using the | |
6033 | @option{-fno-diagnostics-show-option} flag.) | |
6034 | ||
6035 | Note that specifying @option{-Werror=}@var{foo} automatically implies | |
6036 | @option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not | |
6037 | imply anything. | |
6038 | ||
d77de738 ML |
6039 | @opindex Wfatal-errors |
6040 | @opindex Wno-fatal-errors | |
ddf6fe37 | 6041 | @item -Wfatal-errors |
d77de738 ML |
6042 | This option causes the compiler to abort compilation on the first error |
6043 | occurred rather than trying to keep going and printing further error | |
6044 | messages. | |
6045 | ||
6046 | @end table | |
6047 | ||
6048 | You can request many specific warnings with options beginning with | |
6049 | @samp{-W}, for example @option{-Wimplicit} to request warnings on | |
6050 | implicit declarations. Each of these specific warning options also | |
6051 | has a negative form beginning @samp{-Wno-} to turn off warnings; for | |
6052 | example, @option{-Wno-implicit}. This manual lists only one of the | |
6053 | two forms, whichever is not the default. For further | |
6054 | language-specific options also refer to @ref{C++ Dialect Options} and | |
6055 | @ref{Objective-C and Objective-C++ Dialect Options}. | |
6056 | Additional warnings can be produced by enabling the static analyzer; | |
6057 | @xref{Static Analyzer Options}. | |
6058 | ||
6059 | Some options, such as @option{-Wall} and @option{-Wextra}, turn on other | |
6060 | options, such as @option{-Wunused}, which may turn on further options, | |
6061 | such as @option{-Wunused-value}. The combined effect of positive and | |
6062 | negative forms is that more specific options have priority over less | |
6063 | specific ones, independently of their position in the command-line. For | |
6064 | options of the same specificity, the last one takes effect. Options | |
6065 | enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect | |
6066 | as if they appeared at the end of the command-line. | |
6067 | ||
6068 | When an unrecognized warning option is requested (e.g., | |
6069 | @option{-Wunknown-warning}), GCC emits a diagnostic stating | |
6070 | that the option is not recognized. However, if the @option{-Wno-} form | |
6071 | is used, the behavior is slightly different: no diagnostic is | |
6072 | produced for @option{-Wno-unknown-warning} unless other diagnostics | |
6073 | are being produced. This allows the use of new @option{-Wno-} options | |
6074 | with old compilers, but if something goes wrong, the compiler | |
6075 | warns that an unrecognized option is present. | |
6076 | ||
6077 | The effectiveness of some warnings depends on optimizations also being | |
6078 | enabled. For example @option{-Wsuggest-final-types} is more effective | |
6079 | with link-time optimization and some instances of other warnings may | |
6080 | not be issued at all unless optimization is enabled. While optimization | |
6081 | in general improves the efficacy of control and data flow sensitive | |
6082 | warnings, in some cases it may also cause false positives. | |
6083 | ||
6084 | @table @gcctabopt | |
d77de738 ML |
6085 | @opindex pedantic |
6086 | @opindex Wpedantic | |
6087 | @opindex Wno-pedantic | |
ddf6fe37 AA |
6088 | @item -Wpedantic |
6089 | @itemx -pedantic | |
d77de738 | 6090 | Issue all the warnings demanded by strict ISO C and ISO C++; |
5fccebdb JM |
6091 | diagnose all programs that use forbidden extensions, and some other |
6092 | programs that do not follow ISO C and ISO C++. This follows the version | |
6093 | of the ISO C or C++ standard specified by any @option{-std} option used. | |
d77de738 ML |
6094 | |
6095 | Valid ISO C and ISO C++ programs should compile properly with or without | |
6096 | this option (though a rare few require @option{-ansi} or a | |
5fccebdb | 6097 | @option{-std} option specifying the version of the standard)@. However, |
d77de738 | 6098 | without this option, certain GNU extensions and traditional C and C++ |
5fccebdb JM |
6099 | features are supported as well. With this option, they are diagnosed |
6100 | (or rejected with @option{-pedantic-errors}). | |
d77de738 ML |
6101 | |
6102 | @option{-Wpedantic} does not cause warning messages for use of the | |
6103 | alternate keywords whose names begin and end with @samp{__}. This alternate | |
6104 | format can also be used to disable warnings for non-ISO @samp{__intN} types, | |
6105 | i.e. @samp{__intN__}. | |
6106 | Pedantic warnings are also disabled in the expression that follows | |
6107 | @code{__extension__}. However, only system header files should use | |
6108 | these escape routes; application programs should avoid them. | |
6109 | @xref{Alternate Keywords}. | |
6110 | ||
5fccebdb JM |
6111 | Some warnings about non-conforming programs are controlled by options |
6112 | other than @option{-Wpedantic}; in many cases they are implied by | |
6113 | @option{-Wpedantic} but can be disabled separately by their specific | |
6114 | option, e.g. @option{-Wpedantic -Wno-pointer-sign}. | |
d77de738 ML |
6115 | |
6116 | Where the standard specified with @option{-std} represents a GNU | |
6117 | extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a | |
6118 | corresponding @dfn{base standard}, the version of ISO C on which the GNU | |
6119 | extended dialect is based. Warnings from @option{-Wpedantic} are given | |
6120 | where they are required by the base standard. (It does not make sense | |
6121 | for such warnings to be given only for features not in the specified GNU | |
6122 | C dialect, since by definition the GNU dialects of C include all | |
6123 | features the compiler supports with the given option, and there would be | |
6124 | nothing to warn about.) | |
6125 | ||
d77de738 | 6126 | @opindex pedantic-errors |
ddf6fe37 | 6127 | @item -pedantic-errors |
d77de738 ML |
6128 | Give an error whenever the @dfn{base standard} (see @option{-Wpedantic}) |
6129 | requires a diagnostic, in some cases where there is undefined behavior | |
6130 | at compile-time and in some other cases that do not prevent compilation | |
6131 | of programs that are valid according to the standard. This is not | |
5fccebdb JM |
6132 | equivalent to @option{-Werror=pedantic}: the latter option is unlikely to be |
6133 | useful, as it only makes errors of the diagnostics that are controlled by | |
6134 | @option{-Wpedantic}, whereas this option also affects required diagnostics that | |
6135 | are always enabled or controlled by options other than @option{-Wpedantic}. | |
6136 | ||
6137 | If you want the required diagnostics that are warnings by default to | |
6138 | be errors instead, but don't also want to enable the @option{-Wpedantic} | |
6139 | diagnostics, you can specify @option{-pedantic-errors -Wno-pedantic} | |
6140 | (or @option{-pedantic-errors -Wno-error=pedantic} to enable them but | |
6141 | only as warnings). | |
6142 | ||
6143 | Some required diagnostics are errors by default, but can be reduced to | |
6144 | warnings using @option{-fpermissive} or their specific warning option, | |
6145 | e.g. @option{-Wno-error=narrowing}. | |
6146 | ||
6147 | Some diagnostics for non-ISO practices are controlled by specific | |
6148 | warning options other than @option{-Wpedantic}, but are also made | |
6149 | errors by @option{-pedantic-errors}. For instance: | |
6150 | ||
6151 | @gccoptlist{ | |
6152 | -Wattributes @r{(for standard attributes)} | |
6153 | -Wchanges-meaning @r{(C++)} | |
6154 | -Wcomma-subscript @r{(C++23 or later)} | |
6155 | -Wdeclaration-after-statement @r{(C90 or earlier)} | |
b106f11d | 6156 | -Welaborated-enum-base @r{(C++11 or later)} |
5fccebdb JM |
6157 | -Wimplicit-int @r{(C99 or later)} |
6158 | -Wimplicit-function-declaration @r{(C99 or later)} | |
6159 | -Wincompatible-pointer-types | |
6160 | -Wint-conversion | |
6161 | -Wlong-long @r{(C90 or earlier)} | |
6162 | -Wmain | |
6163 | -Wnarrowing @r{(C++11 or later)} | |
6164 | -Wpointer-arith | |
6165 | -Wpointer-sign | |
6166 | -Wincompatible-pointer-types | |
6167 | -Wregister @r{(C++17 or later)} | |
6168 | -Wvla @r{(C90 or earlier)} | |
6169 | -Wwrite-strings @r{(C++11 or later)} | |
6170 | } | |
d77de738 | 6171 | |
ef10cb86 JM |
6172 | @opindex fpermissive |
6173 | @item -fpermissive | |
6174 | Downgrade some required diagnostics about nonconformant code from | |
6175 | errors to warnings. Thus, using @option{-fpermissive} allows some | |
6176 | nonconforming code to compile. Some C++ diagnostics are controlled | |
da4315f5 FW |
6177 | only by this flag, but it also downgrades some C and C++ diagnostics |
6178 | that have their own flag: | |
ef10cb86 JM |
6179 | |
6180 | @gccoptlist{ | |
6181 | -Wnarrowing @r{(C++)} | |
6182 | } | |
6183 | ||
da4315f5 FW |
6184 | The @option{-fpermissive} option is the default for historic C language |
6185 | modes (@option{-std=c89}, @option{-std=gnu89}, @option{-std=c90}, | |
6186 | @option{-std=gnu90}). | |
6187 | ||
d77de738 ML |
6188 | @opindex Wall |
6189 | @opindex Wno-all | |
ddf6fe37 | 6190 | @item -Wall |
d77de738 ML |
6191 | This enables all the warnings about constructions that some users |
6192 | consider questionable, and that are easy to avoid (or modify to | |
6193 | prevent the warning), even in conjunction with macros. This also | |
6194 | enables some language-specific warnings described in @ref{C++ Dialect | |
6195 | Options} and @ref{Objective-C and Objective-C++ Dialect Options}. | |
6196 | ||
6197 | @option{-Wall} turns on the following warning flags: | |
6198 | ||
43b72ede AA |
6199 | @gccoptlist{-Waddress |
6200 | -Warray-bounds=1 @r{(only with} @option{-O2}@r{)} | |
6201 | -Warray-compare | |
6202 | -Warray-parameter=2 @r{(C and Objective-C only)} | |
6203 | -Wbool-compare | |
6204 | -Wbool-operation | |
6205 | -Wc++11-compat -Wc++14-compat | |
6206 | -Wcatch-value @r{(C++ and Objective-C++ only)} | |
6207 | -Wchar-subscripts | |
6208 | -Wcomment | |
6209 | -Wdangling-pointer=2 | |
6210 | -Wduplicate-decl-specifier @r{(C and Objective-C only)} | |
6211 | -Wenum-compare @r{(in C/ObjC; this is on by default in C++)} | |
6212 | -Wenum-int-mismatch @r{(C and Objective-C only)} | |
6213 | -Wformat | |
6214 | -Wformat-overflow | |
6215 | -Wformat-truncation | |
6216 | -Wint-in-bool-context | |
6217 | -Wimplicit @r{(C and Objective-C only)} | |
6218 | -Wimplicit-int @r{(C and Objective-C only)} | |
6219 | -Wimplicit-function-declaration @r{(C and Objective-C only)} | |
6220 | -Winit-self @r{(only for C++)} | |
6221 | -Wlogical-not-parentheses | |
6222 | -Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)} | |
6223 | -Wmaybe-uninitialized | |
6224 | -Wmemset-elt-size | |
6225 | -Wmemset-transposed-args | |
6226 | -Wmisleading-indentation @r{(only for C/C++)} | |
6227 | -Wmismatched-dealloc | |
6228 | -Wmismatched-new-delete @r{(only for C/C++)} | |
6229 | -Wmissing-attributes | |
6230 | -Wmissing-braces @r{(only for C/ObjC)} | |
6231 | -Wmultistatement-macros | |
6232 | -Wnarrowing @r{(only for C++)} | |
6233 | -Wnonnull | |
6234 | -Wnonnull-compare | |
6235 | -Wopenmp-simd | |
6236 | -Wparentheses | |
6237 | -Wpessimizing-move @r{(only for C++)} | |
6238 | -Wpointer-sign | |
6239 | -Wrange-loop-construct @r{(only for C++)} | |
6240 | -Wreorder | |
6241 | -Wrestrict | |
6242 | -Wreturn-type | |
6243 | -Wself-move @r{(only for C++)} | |
6244 | -Wsequence-point | |
6245 | -Wsign-compare @r{(only in C++)} | |
6246 | -Wsizeof-array-div | |
6247 | -Wsizeof-pointer-div | |
6248 | -Wsizeof-pointer-memaccess | |
6249 | -Wstrict-aliasing | |
6250 | -Wstrict-overflow=1 | |
6251 | -Wswitch | |
6252 | -Wtautological-compare | |
6253 | -Wtrigraphs | |
6254 | -Wuninitialized | |
6255 | -Wunknown-pragmas | |
6256 | -Wunused-function | |
6257 | -Wunused-label | |
6258 | -Wunused-value | |
6259 | -Wunused-variable | |
6260 | -Wuse-after-free=2 | |
6261 | -Wvla-parameter @r{(C and Objective-C only)} | |
6262 | -Wvolatile-register-var | |
d77de738 ML |
6263 | -Wzero-length-bounds} |
6264 | ||
6265 | Note that some warning flags are not implied by @option{-Wall}. Some of | |
6266 | them warn about constructions that users generally do not consider | |
6267 | questionable, but which occasionally you might wish to check for; | |
6268 | others warn about constructions that are necessary or hard to avoid in | |
6269 | some cases, and there is no simple way to modify the code to suppress | |
6270 | the warning. Some of them are enabled by @option{-Wextra} but many of | |
6271 | them must be enabled individually. | |
6272 | ||
d77de738 ML |
6273 | @opindex W |
6274 | @opindex Wextra | |
6275 | @opindex Wno-extra | |
ddf6fe37 | 6276 | @item -Wextra |
d77de738 ML |
6277 | This enables some extra warning flags that are not enabled by |
6278 | @option{-Wall}. (This option used to be called @option{-W}. The older | |
6279 | name is still supported, but the newer name is more descriptive.) | |
6280 | ||
43b72ede AA |
6281 | @gccoptlist{-Wclobbered |
6282 | -Wcast-function-type | |
6283 | -Wdeprecated-copy @r{(C++ only)} | |
6284 | -Wempty-body | |
6285 | -Wenum-conversion @r{(C only)} | |
6286 | -Wignored-qualifiers | |
6287 | -Wimplicit-fallthrough=3 | |
6288 | -Wmissing-field-initializers | |
6289 | -Wmissing-parameter-type @r{(C only)} | |
6290 | -Wold-style-declaration @r{(C only)} | |
6291 | -Woverride-init | |
6292 | -Wsign-compare @r{(C only)} | |
6293 | -Wstring-compare | |
6294 | -Wredundant-move @r{(only for C++)} | |
6295 | -Wtype-limits | |
6296 | -Wuninitialized | |
6297 | -Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)} | |
6298 | -Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)} | |
d77de738 ML |
6299 | -Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}} |
6300 | ||
6301 | ||
6302 | The option @option{-Wextra} also prints warning messages for the | |
6303 | following cases: | |
6304 | ||
6305 | @itemize @bullet | |
6306 | ||
6307 | @item | |
6308 | A pointer is compared against integer zero with @code{<}, @code{<=}, | |
6309 | @code{>}, or @code{>=}. | |
6310 | ||
6311 | @item | |
6312 | (C++ only) An enumerator and a non-enumerator both appear in a | |
6313 | conditional expression. | |
6314 | ||
6315 | @item | |
6316 | (C++ only) Ambiguous virtual bases. | |
6317 | ||
6318 | @item | |
6319 | (C++ only) Subscripting an array that has been declared @code{register}. | |
6320 | ||
6321 | @item | |
6322 | (C++ only) Taking the address of a variable that has been declared | |
6323 | @code{register}. | |
6324 | ||
6325 | @item | |
6326 | (C++ only) A base class is not initialized in the copy constructor | |
6327 | of a derived class. | |
6328 | ||
6329 | @end itemize | |
6330 | ||
d77de738 ML |
6331 | @opindex Wabi |
6332 | @opindex Wno-abi | |
ddf6fe37 | 6333 | @item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)} |
d77de738 ML |
6334 | |
6335 | Warn about code affected by ABI changes. This includes code that may | |
6336 | not be compatible with the vendor-neutral C++ ABI as well as the psABI | |
6337 | for the particular target. | |
6338 | ||
6339 | Since G++ now defaults to updating the ABI with each major release, | |
6340 | normally @option{-Wabi} warns only about C++ ABI compatibility | |
6341 | problems if there is a check added later in a release series for an | |
6342 | ABI issue discovered since the initial release. @option{-Wabi} warns | |
6343 | about more things if an older ABI version is selected (with | |
6344 | @option{-fabi-version=@var{n}}). | |
6345 | ||
6346 | @option{-Wabi} can also be used with an explicit version number to | |
6347 | warn about C++ ABI compatibility with a particular @option{-fabi-version} | |
6348 | level, e.g.@: @option{-Wabi=2} to warn about changes relative to | |
6349 | @option{-fabi-version=2}. | |
6350 | ||
6351 | If an explicit version number is provided and | |
6352 | @option{-fabi-compat-version} is not specified, the version number | |
6353 | from this option is used for compatibility aliases. If no explicit | |
6354 | version number is provided with this option, but | |
6355 | @option{-fabi-compat-version} is specified, that version number is | |
6356 | used for C++ ABI warnings. | |
6357 | ||
6358 | Although an effort has been made to warn about | |
6359 | all such cases, there are probably some cases that are not warned about, | |
6360 | even though G++ is generating incompatible code. There may also be | |
6361 | cases where warnings are emitted even though the code that is generated | |
6362 | is compatible. | |
6363 | ||
6364 | You should rewrite your code to avoid these warnings if you are | |
6365 | concerned about the fact that code generated by G++ may not be binary | |
6366 | compatible with code generated by other compilers. | |
6367 | ||
6368 | Known incompatibilities in @option{-fabi-version=2} (which was the | |
6369 | default from GCC 3.4 to 4.9) include: | |
6370 | ||
6371 | @itemize @bullet | |
6372 | ||
6373 | @item | |
6374 | A template with a non-type template parameter of reference type was | |
6375 | mangled incorrectly: | |
6376 | @smallexample | |
6377 | extern int N; | |
6378 | template <int &> struct S @{@}; | |
6379 | void n (S<N>) @{2@} | |
6380 | @end smallexample | |
6381 | ||
6382 | This was fixed in @option{-fabi-version=3}. | |
6383 | ||
6384 | @item | |
6385 | SIMD vector types declared using @code{__attribute ((vector_size))} were | |
6386 | mangled in a non-standard way that does not allow for overloading of | |
6387 | functions taking vectors of different sizes. | |
6388 | ||
6389 | The mangling was changed in @option{-fabi-version=4}. | |
6390 | ||
6391 | @item | |
6392 | @code{__attribute ((const))} and @code{noreturn} were mangled as type | |
6393 | qualifiers, and @code{decltype} of a plain declaration was folded away. | |
6394 | ||
6395 | These mangling issues were fixed in @option{-fabi-version=5}. | |
6396 | ||
6397 | @item | |
6398 | Scoped enumerators passed as arguments to a variadic function are | |
6399 | promoted like unscoped enumerators, causing @code{va_arg} to complain. | |
6400 | On most targets this does not actually affect the parameter passing | |
6401 | ABI, as there is no way to pass an argument smaller than @code{int}. | |
6402 | ||
6403 | Also, the ABI changed the mangling of template argument packs, | |
6404 | @code{const_cast}, @code{static_cast}, prefix increment/decrement, and | |
6405 | a class scope function used as a template argument. | |
6406 | ||
6407 | These issues were corrected in @option{-fabi-version=6}. | |
6408 | ||
6409 | @item | |
6410 | Lambdas in default argument scope were mangled incorrectly, and the | |
6411 | ABI changed the mangling of @code{nullptr_t}. | |
6412 | ||
6413 | These issues were corrected in @option{-fabi-version=7}. | |
6414 | ||
6415 | @item | |
6416 | When mangling a function type with function-cv-qualifiers, the | |
6417 | un-qualified function type was incorrectly treated as a substitution | |
6418 | candidate. | |
6419 | ||
6420 | This was fixed in @option{-fabi-version=8}, the default for GCC 5.1. | |
6421 | ||
6422 | @item | |
6423 | @code{decltype(nullptr)} incorrectly had an alignment of 1, leading to | |
6424 | unaligned accesses. Note that this did not affect the ABI of a | |
6425 | function with a @code{nullptr_t} parameter, as parameters have a | |
6426 | minimum alignment. | |
6427 | ||
6428 | This was fixed in @option{-fabi-version=9}, the default for GCC 5.2. | |
6429 | ||
6430 | @item | |
6431 | Target-specific attributes that affect the identity of a type, such as | |
6432 | ia32 calling conventions on a function type (stdcall, regparm, etc.), | |
6433 | did not affect the mangled name, leading to name collisions when | |
6434 | function pointers were used as template arguments. | |
6435 | ||
6436 | This was fixed in @option{-fabi-version=10}, the default for GCC 6.1. | |
6437 | ||
6438 | @end itemize | |
6439 | ||
6440 | This option also enables warnings about psABI-related changes. | |
6441 | The known psABI changes at this point include: | |
6442 | ||
6443 | @itemize @bullet | |
6444 | ||
6445 | @item | |
6446 | For SysV/x86-64, unions with @code{long double} members are | |
6447 | passed in memory as specified in psABI. Prior to GCC 4.4, this was not | |
6448 | the case. For example: | |
6449 | ||
6450 | @smallexample | |
6451 | union U @{ | |
6452 | long double ld; | |
6453 | int i; | |
6454 | @}; | |
6455 | @end smallexample | |
6456 | ||
6457 | @noindent | |
6458 | @code{union U} is now always passed in memory. | |
6459 | ||
6460 | @end itemize | |
6461 | ||
e2f939d3 JM |
6462 | @item -Wno-changes-meaning @r{(C++ and Objective-C++ only)} |
6463 | C++ requires that unqualified uses of a name within a class have the | |
6464 | same meaning in the complete scope of the class, so declaring the name | |
6465 | after using it is ill-formed: | |
6466 | @smallexample | |
6467 | struct A; | |
6468 | struct B1 @{ A a; typedef A A; @}; // warning, 'A' changes meaning | |
6469 | struct B2 @{ A a; struct A @{ @}; @}; // error, 'A' changes meaning | |
6470 | @end smallexample | |
6471 | By default, the B1 case is only a warning because the two declarations | |
6472 | have the same type, while the B2 case is an error. Both diagnostics | |
6473 | can be disabled with @option{-Wno-changes-meaning}. Alternately, the | |
6474 | error case can be reduced to a warning with | |
6475 | @option{-Wno-error=changes-meaning} or @option{-fpermissive}. | |
6476 | ||
6477 | Both diagnostics are also suppressed by @option{-fms-extensions}. | |
6478 | ||
d77de738 ML |
6479 | @opindex Wchar-subscripts |
6480 | @opindex Wno-char-subscripts | |
ddf6fe37 | 6481 | @item -Wchar-subscripts |
d77de738 ML |
6482 | Warn if an array subscript has type @code{char}. This is a common cause |
6483 | of error, as programmers often forget that this type is signed on some | |
6484 | machines. | |
6485 | This warning is enabled by @option{-Wall}. | |
6486 | ||
d77de738 ML |
6487 | @opindex Wno-coverage-mismatch |
6488 | @opindex Wcoverage-mismatch | |
ddf6fe37 | 6489 | @item -Wno-coverage-mismatch |
d77de738 ML |
6490 | Warn if feedback profiles do not match when using the |
6491 | @option{-fprofile-use} option. | |
6492 | If a source file is changed between compiling with @option{-fprofile-generate} | |
6493 | and with @option{-fprofile-use}, the files with the profile feedback can fail | |
6494 | to match the source file and GCC cannot use the profile feedback | |
6495 | information. By default, this warning is enabled and is treated as an | |
6496 | error. @option{-Wno-coverage-mismatch} can be used to disable the | |
6497 | warning or @option{-Wno-error=coverage-mismatch} can be used to | |
6498 | disable the error. Disabling the error for this warning can result in | |
6499 | poorly optimized code and is useful only in the | |
6500 | case of very minor changes such as bug fixes to an existing code-base. | |
6501 | Completely disabling the warning is not recommended. | |
6502 | ||
d77de738 ML |
6503 | @opindex Wno-coverage-invalid-line-number |
6504 | @opindex Wcoverage-invalid-line-number | |
ddf6fe37 | 6505 | @item -Wno-coverage-invalid-line-number |
d77de738 ML |
6506 | Warn in case a function ends earlier than it begins due |
6507 | to an invalid linenum macros. The warning is emitted only | |
6508 | with @option{--coverage} enabled. | |
6509 | ||
6510 | By default, this warning is enabled and is treated as an | |
6511 | error. @option{-Wno-coverage-invalid-line-number} can be used to disable the | |
6512 | warning or @option{-Wno-error=coverage-invalid-line-number} can be used to | |
6513 | disable the error. | |
6514 | ||
d77de738 ML |
6515 | @opindex Wno-cpp |
6516 | @opindex Wcpp | |
ddf6fe37 | 6517 | @item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)} |
d77de738 ML |
6518 | Suppress warning messages emitted by @code{#warning} directives. |
6519 | ||
d77de738 ML |
6520 | @opindex Wdouble-promotion |
6521 | @opindex Wno-double-promotion | |
ddf6fe37 | 6522 | @item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
6523 | Give a warning when a value of type @code{float} is implicitly |
6524 | promoted to @code{double}. CPUs with a 32-bit ``single-precision'' | |
6525 | floating-point unit implement @code{float} in hardware, but emulate | |
6526 | @code{double} in software. On such a machine, doing computations | |
6527 | using @code{double} values is much more expensive because of the | |
6528 | overhead required for software emulation. | |
6529 | ||
6530 | It is easy to accidentally do computations with @code{double} because | |
6531 | floating-point literals are implicitly of type @code{double}. For | |
6532 | example, in: | |
6533 | @smallexample | |
6534 | @group | |
6535 | float area(float radius) | |
6536 | @{ | |
6537 | return 3.14159 * radius * radius; | |
6538 | @} | |
6539 | @end group | |
6540 | @end smallexample | |
6541 | the compiler performs the entire computation with @code{double} | |
6542 | because the floating-point literal is a @code{double}. | |
6543 | ||
d77de738 ML |
6544 | @opindex Wduplicate-decl-specifier |
6545 | @opindex Wno-duplicate-decl-specifier | |
ddf6fe37 | 6546 | @item -Wduplicate-decl-specifier @r{(C and Objective-C only)} |
d77de738 ML |
6547 | Warn if a declaration has duplicate @code{const}, @code{volatile}, |
6548 | @code{restrict} or @code{_Atomic} specifier. This warning is enabled by | |
6549 | @option{-Wall}. | |
6550 | ||
d77de738 ML |
6551 | @opindex Wformat |
6552 | @opindex Wno-format | |
6553 | @opindex ffreestanding | |
6554 | @opindex fno-builtin | |
6555 | @opindex Wformat= | |
ddf6fe37 AA |
6556 | @item -Wformat |
6557 | @itemx -Wformat=@var{n} | |
d77de738 ML |
6558 | Check calls to @code{printf} and @code{scanf}, etc., to make sure that |
6559 | the arguments supplied have types appropriate to the format string | |
6560 | specified, and that the conversions specified in the format string make | |
6561 | sense. This includes standard functions, and others specified by format | |
6562 | attributes (@pxref{Function Attributes}), in the @code{printf}, | |
6563 | @code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension, | |
6564 | not in the C standard) families (or other target-specific families). | |
6565 | Which functions are checked without format attributes having been | |
6566 | specified depends on the standard version selected, and such checks of | |
6567 | functions without the attribute specified are disabled by | |
6568 | @option{-ffreestanding} or @option{-fno-builtin}. | |
6569 | ||
6570 | The formats are checked against the format features supported by GNU | |
6571 | libc version 2.2. These include all ISO C90 and C99 features, as well | |
6572 | as features from the Single Unix Specification and some BSD and GNU | |
6573 | extensions. Other library implementations may not support all these | |
6574 | features; GCC does not support warning about features that go beyond a | |
6575 | particular library's limitations. However, if @option{-Wpedantic} is used | |
6576 | with @option{-Wformat}, warnings are given about format features not | |
6577 | in the selected standard version (but not for @code{strfmon} formats, | |
6578 | since those are not in any version of the C standard). @xref{C Dialect | |
6579 | Options,,Options Controlling C Dialect}. | |
6580 | ||
6581 | @table @gcctabopt | |
d77de738 ML |
6582 | @opindex Wformat |
6583 | @opindex Wformat=1 | |
ddf6fe37 AA |
6584 | @item -Wformat=1 |
6585 | @itemx -Wformat | |
d77de738 ML |
6586 | Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and |
6587 | @option{-Wno-format} is equivalent to @option{-Wformat=0}. Since | |
6588 | @option{-Wformat} also checks for null format arguments for several | |
6589 | functions, @option{-Wformat} also implies @option{-Wnonnull}. Some | |
6590 | aspects of this level of format checking can be disabled by the | |
6591 | options: @option{-Wno-format-contains-nul}, | |
6592 | @option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}. | |
6593 | @option{-Wformat} is enabled by @option{-Wall}. | |
6594 | ||
d77de738 | 6595 | @opindex Wformat=2 |
ddf6fe37 | 6596 | @item -Wformat=2 |
d77de738 ML |
6597 | Enable @option{-Wformat} plus additional format checks. Currently |
6598 | equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security | |
6599 | -Wformat-y2k}. | |
6600 | @end table | |
6601 | ||
d77de738 ML |
6602 | @opindex Wno-format-contains-nul |
6603 | @opindex Wformat-contains-nul | |
ddf6fe37 | 6604 | @item -Wno-format-contains-nul |
d77de738 ML |
6605 | If @option{-Wformat} is specified, do not warn about format strings that |
6606 | contain NUL bytes. | |
6607 | ||
d77de738 ML |
6608 | @opindex Wno-format-extra-args |
6609 | @opindex Wformat-extra-args | |
ddf6fe37 | 6610 | @item -Wno-format-extra-args |
d77de738 ML |
6611 | If @option{-Wformat} is specified, do not warn about excess arguments to a |
6612 | @code{printf} or @code{scanf} format function. The C standard specifies | |
6613 | that such arguments are ignored. | |
6614 | ||
6615 | Where the unused arguments lie between used arguments that are | |
6616 | specified with @samp{$} operand number specifications, normally | |
6617 | warnings are still given, since the implementation could not know what | |
6618 | type to pass to @code{va_arg} to skip the unused arguments. However, | |
6619 | in the case of @code{scanf} formats, this option suppresses the | |
6620 | warning if the unused arguments are all pointers, since the Single | |
6621 | Unix Specification says that such unused arguments are allowed. | |
6622 | ||
d77de738 ML |
6623 | @opindex Wformat-overflow |
6624 | @opindex Wno-format-overflow | |
ddf6fe37 AA |
6625 | @item -Wformat-overflow |
6626 | @itemx -Wformat-overflow=@var{level} | |
d77de738 ML |
6627 | Warn about calls to formatted input/output functions such as @code{sprintf} |
6628 | and @code{vsprintf} that might overflow the destination buffer. When the | |
6629 | exact number of bytes written by a format directive cannot be determined | |
6630 | at compile-time it is estimated based on heuristics that depend on the | |
6631 | @var{level} argument and on optimization. While enabling optimization | |
6632 | will in most cases improve the accuracy of the warning, it may also | |
6633 | result in false positives. | |
6634 | ||
6635 | @table @gcctabopt | |
d77de738 ML |
6636 | @opindex Wformat-overflow |
6637 | @opindex Wno-format-overflow | |
ddf6fe37 AA |
6638 | @item -Wformat-overflow |
6639 | @itemx -Wformat-overflow=1 | |
d77de738 ML |
6640 | Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat} |
6641 | employs a conservative approach that warns only about calls that most | |
6642 | likely overflow the buffer. At this level, numeric arguments to format | |
6643 | directives with unknown values are assumed to have the value of one, and | |
6644 | strings of unknown length to be empty. Numeric arguments that are known | |
6645 | to be bounded to a subrange of their type, or string arguments whose output | |
6646 | is bounded either by their directive's precision or by a finite set of | |
6647 | string literals, are assumed to take on the value within the range that | |
6648 | results in the most bytes on output. For example, the call to @code{sprintf} | |
6649 | below is diagnosed because even with both @var{a} and @var{b} equal to zero, | |
6650 | the terminating NUL character (@code{'\0'}) appended by the function | |
6651 | to the destination buffer will be written past its end. Increasing | |
6652 | the size of the buffer by a single byte is sufficient to avoid the | |
6653 | warning, though it may not be sufficient to avoid the overflow. | |
6654 | ||
6655 | @smallexample | |
6656 | void f (int a, int b) | |
6657 | @{ | |
6658 | char buf [13]; | |
6659 | sprintf (buf, "a = %i, b = %i\n", a, b); | |
6660 | @} | |
6661 | @end smallexample | |
6662 | ||
6663 | @item -Wformat-overflow=2 | |
6664 | Level @var{2} warns also about calls that might overflow the destination | |
6665 | buffer given an argument of sufficient length or magnitude. At level | |
6666 | @var{2}, unknown numeric arguments are assumed to have the minimum | |
6667 | representable value for signed types with a precision greater than 1, and | |
6668 | the maximum representable value otherwise. Unknown string arguments whose | |
6669 | length cannot be assumed to be bounded either by the directive's precision, | |
6670 | or by a finite set of string literals they may evaluate to, or the character | |
6671 | array they may point to, are assumed to be 1 character long. | |
6672 | ||
6673 | At level @var{2}, the call in the example above is again diagnosed, but | |
6674 | this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first | |
6675 | @code{%i} directive will write some of its digits beyond the end of | |
6676 | the destination buffer. To make the call safe regardless of the values | |
6677 | of the two variables, the size of the destination buffer must be increased | |
6678 | to at least 34 bytes. GCC includes the minimum size of the buffer in | |
6679 | an informational note following the warning. | |
6680 | ||
6681 | An alternative to increasing the size of the destination buffer is to | |
6682 | constrain the range of formatted values. The maximum length of string | |
6683 | arguments can be bounded by specifying the precision in the format | |
6684 | directive. When numeric arguments of format directives can be assumed | |
6685 | to be bounded by less than the precision of their type, choosing | |
6686 | an appropriate length modifier to the format specifier will reduce | |
6687 | the required buffer size. For example, if @var{a} and @var{b} in the | |
6688 | example above can be assumed to be within the precision of | |
6689 | the @code{short int} type then using either the @code{%hi} format | |
6690 | directive or casting the argument to @code{short} reduces the maximum | |
6691 | required size of the buffer to 24 bytes. | |
6692 | ||
6693 | @smallexample | |
6694 | void f (int a, int b) | |
6695 | @{ | |
6696 | char buf [23]; | |
6697 | sprintf (buf, "a = %hi, b = %i\n", a, (short)b); | |
6698 | @} | |
6699 | @end smallexample | |
6700 | @end table | |
6701 | ||
d77de738 ML |
6702 | @opindex Wno-format-zero-length |
6703 | @opindex Wformat-zero-length | |
ddf6fe37 | 6704 | @item -Wno-format-zero-length |
d77de738 ML |
6705 | If @option{-Wformat} is specified, do not warn about zero-length formats. |
6706 | The C standard specifies that zero-length formats are allowed. | |
6707 | ||
d77de738 ML |
6708 | @opindex Wformat-nonliteral |
6709 | @opindex Wno-format-nonliteral | |
ddf6fe37 | 6710 | @item -Wformat-nonliteral |
d77de738 ML |
6711 | If @option{-Wformat} is specified, also warn if the format string is not a |
6712 | string literal and so cannot be checked, unless the format function | |
6713 | takes its format arguments as a @code{va_list}. | |
6714 | ||
d77de738 ML |
6715 | @opindex Wformat-security |
6716 | @opindex Wno-format-security | |
ddf6fe37 | 6717 | @item -Wformat-security |
d77de738 ML |
6718 | If @option{-Wformat} is specified, also warn about uses of format |
6719 | functions that represent possible security problems. At present, this | |
6720 | warns about calls to @code{printf} and @code{scanf} functions where the | |
6721 | format string is not a string literal and there are no format arguments, | |
6722 | as in @code{printf (foo);}. This may be a security hole if the format | |
6723 | string came from untrusted input and contains @samp{%n}. (This is | |
6724 | currently a subset of what @option{-Wformat-nonliteral} warns about, but | |
6725 | in future warnings may be added to @option{-Wformat-security} that are not | |
6726 | included in @option{-Wformat-nonliteral}.) | |
6727 | ||
d77de738 ML |
6728 | @opindex Wformat-signedness |
6729 | @opindex Wno-format-signedness | |
ddf6fe37 | 6730 | @item -Wformat-signedness |
d77de738 ML |
6731 | If @option{-Wformat} is specified, also warn if the format string |
6732 | requires an unsigned argument and the argument is signed and vice versa. | |
6733 | ||
d77de738 ML |
6734 | @opindex Wformat-truncation |
6735 | @opindex Wno-format-truncation | |
ddf6fe37 AA |
6736 | @item -Wformat-truncation |
6737 | @itemx -Wformat-truncation=@var{level} | |
d77de738 ML |
6738 | Warn about calls to formatted input/output functions such as @code{snprintf} |
6739 | and @code{vsnprintf} that might result in output truncation. When the exact | |
6740 | number of bytes written by a format directive cannot be determined at | |
6741 | compile-time it is estimated based on heuristics that depend on | |
6742 | the @var{level} argument and on optimization. While enabling optimization | |
6743 | will in most cases improve the accuracy of the warning, it may also result | |
6744 | in false positives. Except as noted otherwise, the option uses the same | |
6745 | logic @option{-Wformat-overflow}. | |
6746 | ||
6747 | @table @gcctabopt | |
d77de738 ML |
6748 | @opindex Wformat-truncation |
6749 | @opindex Wno-format-truncation | |
ddf6fe37 AA |
6750 | @item -Wformat-truncation |
6751 | @itemx -Wformat-truncation=1 | |
d77de738 ML |
6752 | Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat} |
6753 | employs a conservative approach that warns only about calls to bounded | |
6754 | functions whose return value is unused and that will most likely result | |
6755 | in output truncation. | |
6756 | ||
6757 | @item -Wformat-truncation=2 | |
6758 | Level @var{2} warns also about calls to bounded functions whose return | |
6759 | value is used and that might result in truncation given an argument of | |
6760 | sufficient length or magnitude. | |
6761 | @end table | |
6762 | ||
d77de738 ML |
6763 | @opindex Wformat-y2k |
6764 | @opindex Wno-format-y2k | |
ddf6fe37 | 6765 | @item -Wformat-y2k |
d77de738 ML |
6766 | If @option{-Wformat} is specified, also warn about @code{strftime} |
6767 | formats that may yield only a two-digit year. | |
6768 | ||
d77de738 ML |
6769 | @opindex Wnonnull |
6770 | @opindex Wno-nonnull | |
ddf6fe37 | 6771 | @item -Wnonnull |
d77de738 ML |
6772 | Warn about passing a null pointer for arguments marked as |
6773 | requiring a non-null value by the @code{nonnull} function attribute. | |
6774 | ||
6775 | @option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It | |
6776 | can be disabled with the @option{-Wno-nonnull} option. | |
6777 | ||
d77de738 ML |
6778 | @opindex Wnonnull-compare |
6779 | @opindex Wno-nonnull-compare | |
ddf6fe37 | 6780 | @item -Wnonnull-compare |
d77de738 ML |
6781 | Warn when comparing an argument marked with the @code{nonnull} |
6782 | function attribute against null inside the function. | |
6783 | ||
6784 | @option{-Wnonnull-compare} is included in @option{-Wall}. It | |
6785 | can be disabled with the @option{-Wno-nonnull-compare} option. | |
6786 | ||
d77de738 ML |
6787 | @opindex Wnull-dereference |
6788 | @opindex Wno-null-dereference | |
ddf6fe37 | 6789 | @item -Wnull-dereference |
d77de738 ML |
6790 | Warn if the compiler detects paths that trigger erroneous or |
6791 | undefined behavior due to dereferencing a null pointer. This option | |
6792 | is only active when @option{-fdelete-null-pointer-checks} is active, | |
6793 | which is enabled by optimizations in most targets. The precision of | |
6794 | the warnings depends on the optimization options used. | |
6795 | ||
2ae5384d JM |
6796 | @opindex Wnrvo |
6797 | @opindex Wno-nrvo | |
6798 | @item -Wnrvo @r{(C++ and Objective-C++ only)} | |
6799 | Warn if the compiler does not elide the copy from a local variable to | |
6800 | the return value of a function in a context where it is allowed by | |
6801 | [class.copy.elision]. This elision is commonly known as the Named | |
6802 | Return Value Optimization. For instance, in the example below the | |
72cfa0f7 | 6803 | compiler cannot elide copies from both v1 and v2, so it elides neither. |
2ae5384d JM |
6804 | |
6805 | @smallexample | |
6806 | std::vector<int> f() | |
6807 | @{ | |
6808 | std::vector<int> v1, v2; | |
6809 | // ... | |
6810 | if (cond) return v1; | |
6811 | else return v2; // warning: not eliding copy | |
6812 | @} | |
6813 | @end smallexample | |
6814 | ||
d77de738 ML |
6815 | @opindex Winfinite-recursion |
6816 | @opindex Wno-infinite-recursion | |
ddf6fe37 | 6817 | @item -Winfinite-recursion |
d77de738 ML |
6818 | Warn about infinitely recursive calls. The warning is effective at all |
6819 | optimization levels but requires optimization in order to detect infinite | |
6820 | recursion in calls between two or more functions. | |
6821 | @option{-Winfinite-recursion} is included in @option{-Wall}. | |
6822 | ||
ce51e843 ML |
6823 | Compare with @option{-Wanalyzer-infinite-recursion} which provides a |
6824 | similar diagnostic, but is implemented in a different way (as part of | |
6825 | @option{-fanalyzer}). | |
6826 | ||
d77de738 ML |
6827 | @opindex Winit-self |
6828 | @opindex Wno-init-self | |
ddf6fe37 | 6829 | @item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
6830 | Warn about uninitialized variables that are initialized with themselves. |
6831 | Note this option can only be used with the @option{-Wuninitialized} option. | |
6832 | ||
6833 | For example, GCC warns about @code{i} being uninitialized in the | |
6834 | following snippet only when @option{-Winit-self} has been specified: | |
6835 | @smallexample | |
6836 | @group | |
6837 | int f() | |
6838 | @{ | |
6839 | int i = i; | |
6840 | return i; | |
6841 | @} | |
6842 | @end group | |
6843 | @end smallexample | |
6844 | ||
6845 | This warning is enabled by @option{-Wall} in C++. | |
6846 | ||
d77de738 ML |
6847 | @opindex Wimplicit-int |
6848 | @opindex Wno-implicit-int | |
ddf6fe37 | 6849 | @item -Wno-implicit-int @r{(C and Objective-C only)} |
d77de738 ML |
6850 | This option controls warnings when a declaration does not specify a type. |
6851 | This warning is enabled by default in C99 and later dialects of C, | |
6852 | and also by @option{-Wall}. | |
6853 | ||
5fccebdb JM |
6854 | This warning is upgraded to an error by @option{-pedantic-errors}. |
6855 | ||
d77de738 ML |
6856 | @opindex Wimplicit-function-declaration |
6857 | @opindex Wno-implicit-function-declaration | |
ddf6fe37 | 6858 | @item -Wno-implicit-function-declaration @r{(C and Objective-C only)} |
d77de738 ML |
6859 | This option controls warnings when a function is used before being declared. |
6860 | This warning is enabled by default in C99 and later dialects of C, | |
6861 | and also by @option{-Wall}. | |
5fccebdb JM |
6862 | |
6863 | This warning is upgraded to an error by @option{-pedantic-errors}. | |
d77de738 | 6864 | |
d77de738 ML |
6865 | @opindex Wimplicit |
6866 | @opindex Wno-implicit | |
ddf6fe37 | 6867 | @item -Wimplicit @r{(C and Objective-C only)} |
d77de738 ML |
6868 | Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}. |
6869 | This warning is enabled by @option{-Wall}. | |
6870 | ||
d77de738 ML |
6871 | @opindex Wimplicit-fallthrough |
6872 | @opindex Wno-implicit-fallthrough | |
ddf6fe37 | 6873 | @item -Wimplicit-fallthrough |
d77de738 ML |
6874 | @option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3} |
6875 | and @option{-Wno-implicit-fallthrough} is the same as | |
6876 | @option{-Wimplicit-fallthrough=0}. | |
6877 | ||
d77de738 | 6878 | @opindex Wimplicit-fallthrough= |
ddf6fe37 | 6879 | @item -Wimplicit-fallthrough=@var{n} |
d77de738 ML |
6880 | Warn when a switch case falls through. For example: |
6881 | ||
6882 | @smallexample | |
6883 | @group | |
6884 | switch (cond) | |
6885 | @{ | |
6886 | case 1: | |
6887 | a = 1; | |
6888 | break; | |
6889 | case 2: | |
6890 | a = 2; | |
6891 | case 3: | |
6892 | a = 3; | |
6893 | break; | |
6894 | @} | |
6895 | @end group | |
6896 | @end smallexample | |
6897 | ||
6898 | This warning does not warn when the last statement of a case cannot | |
6899 | fall through, e.g. when there is a return statement or a call to function | |
6900 | declared with the noreturn attribute. @option{-Wimplicit-fallthrough=} | |
6901 | also takes into account control flow statements, such as ifs, and only | |
6902 | warns when appropriate. E.g.@: | |
6903 | ||
6904 | @smallexample | |
6905 | @group | |
6906 | switch (cond) | |
6907 | @{ | |
6908 | case 1: | |
6909 | if (i > 3) @{ | |
6910 | bar (5); | |
6911 | break; | |
6912 | @} else if (i < 1) @{ | |
6913 | bar (0); | |
6914 | @} else | |
6915 | return; | |
6916 | default: | |
6917 | @dots{} | |
6918 | @} | |
6919 | @end group | |
6920 | @end smallexample | |
6921 | ||
6922 | Since there are occasions where a switch case fall through is desirable, | |
6923 | GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is | |
6924 | to be used along with a null statement to suppress this warning that | |
6925 | would normally occur: | |
6926 | ||
6927 | @smallexample | |
6928 | @group | |
6929 | switch (cond) | |
6930 | @{ | |
6931 | case 1: | |
6932 | bar (0); | |
6933 | __attribute__ ((fallthrough)); | |
6934 | default: | |
6935 | @dots{} | |
6936 | @} | |
6937 | @end group | |
6938 | @end smallexample | |
6939 | ||
6940 | C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough} | |
6941 | warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11 | |
6942 | or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension. | |
6943 | Instead of these attributes, it is also possible to add a fallthrough comment | |
6944 | to silence the warning. The whole body of the C or C++ style comment should | |
6945 | match the given regular expressions listed below. The option argument @var{n} | |
6946 | specifies what kind of comments are accepted: | |
6947 | ||
6948 | @itemize @bullet | |
6949 | ||
6950 | @item @option{-Wimplicit-fallthrough=0} disables the warning altogether. | |
6951 | ||
6952 | @item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular | |
6953 | expression, any comment is used as fallthrough comment. | |
6954 | ||
6955 | @item @option{-Wimplicit-fallthrough=2} case insensitively matches | |
6956 | @code{.*falls?[ \t-]*thr(ough|u).*} regular expression. | |
6957 | ||
6958 | @item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the | |
6959 | following regular expressions: | |
6960 | ||
6961 | @itemize @bullet | |
6962 | ||
6963 | @item @code{-fallthrough} | |
6964 | ||
6965 | @item @code{@@fallthrough@@} | |
6966 | ||
6967 | @item @code{lint -fallthrough[ \t]*} | |
6968 | ||
6969 | @item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?} | |
6970 | ||
6971 | @item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?} | |
6972 | ||
6973 | @item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?} | |
6974 | ||
6975 | @end itemize | |
6976 | ||
6977 | @item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the | |
6978 | following regular expressions: | |
6979 | ||
6980 | @itemize @bullet | |
6981 | ||
6982 | @item @code{-fallthrough} | |
6983 | ||
6984 | @item @code{@@fallthrough@@} | |
6985 | ||
6986 | @item @code{lint -fallthrough[ \t]*} | |
6987 | ||
6988 | @item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*} | |
6989 | ||
6990 | @end itemize | |
6991 | ||
6992 | @item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as | |
6993 | fallthrough comments, only attributes disable the warning. | |
6994 | ||
6995 | @end itemize | |
6996 | ||
6997 | The comment needs to be followed after optional whitespace and other comments | |
6998 | by @code{case} or @code{default} keywords or by a user label that precedes some | |
6999 | @code{case} or @code{default} label. | |
7000 | ||
7001 | @smallexample | |
7002 | @group | |
7003 | switch (cond) | |
7004 | @{ | |
7005 | case 1: | |
7006 | bar (0); | |
7007 | /* FALLTHRU */ | |
7008 | default: | |
7009 | @dots{} | |
7010 | @} | |
7011 | @end group | |
7012 | @end smallexample | |
7013 | ||
7014 | The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}. | |
7015 | ||
d77de738 ML |
7016 | @opindex Wif-not-aligned |
7017 | @opindex Wno-if-not-aligned | |
ddf6fe37 | 7018 | @item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
7019 | Control if warnings triggered by the @code{warn_if_not_aligned} attribute |
7020 | should be issued. These warnings are enabled by default. | |
7021 | ||
d77de738 ML |
7022 | @opindex Wignored-qualifiers |
7023 | @opindex Wno-ignored-qualifiers | |
ddf6fe37 | 7024 | @item -Wignored-qualifiers @r{(C and C++ only)} |
d77de738 ML |
7025 | Warn if the return type of a function has a type qualifier |
7026 | such as @code{const}. For ISO C such a type qualifier has no effect, | |
7027 | since the value returned by a function is not an lvalue. | |
7028 | For C++, the warning is only emitted for scalar types or @code{void}. | |
7029 | ISO C prohibits qualified @code{void} return types on function | |
7030 | definitions, so such return types always receive a warning | |
7031 | even without this option. | |
7032 | ||
7033 | This warning is also enabled by @option{-Wextra}. | |
7034 | ||
d77de738 ML |
7035 | @opindex Wignored-attributes |
7036 | @opindex Wno-ignored-attributes | |
ddf6fe37 | 7037 | @item -Wno-ignored-attributes @r{(C and C++ only)} |
d77de738 ML |
7038 | This option controls warnings when an attribute is ignored. |
7039 | This is different from the | |
7040 | @option{-Wattributes} option in that it warns whenever the compiler decides | |
7041 | to drop an attribute, not that the attribute is either unknown, used in a | |
7042 | wrong place, etc. This warning is enabled by default. | |
7043 | ||
d77de738 ML |
7044 | @opindex Wmain |
7045 | @opindex Wno-main | |
ddf6fe37 | 7046 | @item -Wmain |
d77de738 ML |
7047 | Warn if the type of @code{main} is suspicious. @code{main} should be |
7048 | a function with external linkage, returning int, taking either zero | |
7049 | arguments, two, or three arguments of appropriate types. This warning | |
7050 | is enabled by default in C++ and is enabled by either @option{-Wall} | |
7051 | or @option{-Wpedantic}. | |
7052 | ||
5fccebdb JM |
7053 | This warning is upgraded to an error by @option{-pedantic-errors}. |
7054 | ||
d77de738 ML |
7055 | @opindex Wmisleading-indentation |
7056 | @opindex Wno-misleading-indentation | |
ddf6fe37 | 7057 | @item -Wmisleading-indentation @r{(C and C++ only)} |
d77de738 ML |
7058 | Warn when the indentation of the code does not reflect the block structure. |
7059 | Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and | |
7060 | @code{for} clauses with a guarded statement that does not use braces, | |
7061 | followed by an unguarded statement with the same indentation. | |
7062 | ||
7063 | In the following example, the call to ``bar'' is misleadingly indented as | |
7064 | if it were guarded by the ``if'' conditional. | |
7065 | ||
7066 | @smallexample | |
7067 | if (some_condition ()) | |
7068 | foo (); | |
7069 | bar (); /* Gotcha: this is not guarded by the "if". */ | |
7070 | @end smallexample | |
7071 | ||
7072 | In the case of mixed tabs and spaces, the warning uses the | |
7073 | @option{-ftabstop=} option to determine if the statements line up | |
7074 | (defaulting to 8). | |
7075 | ||
7076 | The warning is not issued for code involving multiline preprocessor logic | |
7077 | such as the following example. | |
7078 | ||
7079 | @smallexample | |
7080 | if (flagA) | |
7081 | foo (0); | |
7082 | #if SOME_CONDITION_THAT_DOES_NOT_HOLD | |
7083 | if (flagB) | |
7084 | #endif | |
7085 | foo (1); | |
7086 | @end smallexample | |
7087 | ||
7088 | The warning is not issued after a @code{#line} directive, since this | |
7089 | typically indicates autogenerated code, and no assumptions can be made | |
7090 | about the layout of the file that the directive references. | |
7091 | ||
7092 | This warning is enabled by @option{-Wall} in C and C++. | |
7093 | ||
d77de738 ML |
7094 | @opindex Wmissing-attributes |
7095 | @opindex Wno-missing-attributes | |
ddf6fe37 | 7096 | @item -Wmissing-attributes |
d77de738 ML |
7097 | Warn when a declaration of a function is missing one or more attributes |
7098 | that a related function is declared with and whose absence may adversely | |
7099 | affect the correctness or efficiency of generated code. For example, | |
7100 | the warning is issued for declarations of aliases that use attributes | |
7101 | to specify less restrictive requirements than those of their targets. | |
7102 | This typically represents a potential optimization opportunity. | |
7103 | By contrast, the @option{-Wattribute-alias=2} option controls warnings | |
7104 | issued when the alias is more restrictive than the target, which could | |
7105 | lead to incorrect code generation. | |
7106 | Attributes considered include @code{alloc_align}, @code{alloc_size}, | |
7107 | @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc}, | |
7108 | @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure}, | |
7109 | @code{returns_nonnull}, and @code{returns_twice}. | |
7110 | ||
7111 | In C++, the warning is issued when an explicit specialization of a primary | |
7112 | template declared with attribute @code{alloc_align}, @code{alloc_size}, | |
7113 | @code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc}, | |
7114 | or @code{nonnull} is declared without it. Attributes @code{deprecated}, | |
7115 | @code{error}, and @code{warning} suppress the warning. | |
7116 | (@pxref{Function Attributes}). | |
7117 | ||
7118 | You can use the @code{copy} attribute to apply the same | |
7119 | set of attributes to a declaration as that on another declaration without | |
7120 | explicitly enumerating the attributes. This attribute can be applied | |
7121 | to declarations of functions (@pxref{Common Function Attributes}), | |
7122 | variables (@pxref{Common Variable Attributes}), or types | |
7123 | (@pxref{Common Type Attributes}). | |
7124 | ||
7125 | @option{-Wmissing-attributes} is enabled by @option{-Wall}. | |
7126 | ||
7127 | For example, since the declaration of the primary function template | |
7128 | below makes use of both attribute @code{malloc} and @code{alloc_size} | |
7129 | the declaration of the explicit specialization of the template is | |
7130 | diagnosed because it is missing one of the attributes. | |
7131 | ||
7132 | @smallexample | |
7133 | template <class T> | |
7134 | T* __attribute__ ((malloc, alloc_size (1))) | |
7135 | allocate (size_t); | |
7136 | ||
7137 | template <> | |
7138 | void* __attribute__ ((malloc)) // missing alloc_size | |
7139 | allocate<void> (size_t); | |
7140 | @end smallexample | |
7141 | ||
d77de738 ML |
7142 | @opindex Wmissing-braces |
7143 | @opindex Wno-missing-braces | |
ddf6fe37 | 7144 | @item -Wmissing-braces |
d77de738 ML |
7145 | Warn if an aggregate or union initializer is not fully bracketed. In |
7146 | the following example, the initializer for @code{a} is not fully | |
7147 | bracketed, but that for @code{b} is fully bracketed. | |
7148 | ||
7149 | @smallexample | |
7150 | int a[2][2] = @{ 0, 1, 2, 3 @}; | |
7151 | int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @}; | |
7152 | @end smallexample | |
7153 | ||
7154 | This warning is enabled by @option{-Wall}. | |
7155 | ||
d77de738 ML |
7156 | @opindex Wmissing-include-dirs |
7157 | @opindex Wno-missing-include-dirs | |
ddf6fe37 | 7158 | @item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)} |
72cfa0f7 | 7159 | Warn if a user-supplied include directory does not exist. This option is disabled |
d77de738 ML |
7160 | by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially |
7161 | enabled by default by warning for -I and -J, only. | |
7162 | ||
d77de738 ML |
7163 | @opindex Wmissing-profile |
7164 | @opindex Wno-missing-profile | |
ddf6fe37 | 7165 | @item -Wno-missing-profile |
d77de738 ML |
7166 | This option controls warnings if feedback profiles are missing when using the |
7167 | @option{-fprofile-use} option. | |
7168 | This option diagnoses those cases where a new function or a new file is added | |
7169 | between compiling with @option{-fprofile-generate} and with | |
7170 | @option{-fprofile-use}, without regenerating the profiles. | |
7171 | In these cases, the profile feedback data files do not contain any | |
7172 | profile feedback information for | |
7173 | the newly added function or file respectively. Also, in the case when profile | |
7174 | count data (.gcda) files are removed, GCC cannot use any profile feedback | |
7175 | information. In all these cases, warnings are issued to inform you that a | |
7176 | profile generation step is due. | |
7177 | Ignoring the warning can result in poorly optimized code. | |
7178 | @option{-Wno-missing-profile} can be used to | |
7179 | disable the warning, but this is not recommended and should be done only | |
7180 | when non-existent profile data is justified. | |
7181 | ||
d77de738 ML |
7182 | @opindex Wmismatched-dealloc |
7183 | @opindex Wno-mismatched-dealloc | |
ddf6fe37 | 7184 | @item -Wmismatched-dealloc |
d77de738 ML |
7185 | |
7186 | Warn for calls to deallocation functions with pointer arguments returned | |
7187 | from from allocations functions for which the former isn't a suitable | |
7188 | deallocator. A pair of functions can be associated as matching allocators | |
7189 | and deallocators by use of attribute @code{malloc}. Unless disabled by | |
7190 | the @option{-fno-builtin} option the standard functions @code{calloc}, | |
7191 | @code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding | |
7192 | forms of C++ @code{operator new} and @code{operator delete} are implicitly | |
7193 | associated as matching allocators and deallocators. In the following | |
7194 | example @code{mydealloc} is the deallocator for pointers returned from | |
7195 | @code{myalloc}. | |
7196 | ||
7197 | @smallexample | |
7198 | void mydealloc (void*); | |
7199 | ||
7200 | __attribute__ ((malloc (mydealloc, 1))) void* | |
7201 | myalloc (size_t); | |
7202 | ||
7203 | void f (void) | |
7204 | @{ | |
7205 | void *p = myalloc (32); | |
7206 | // @dots{}use p@dots{} | |
7207 | free (p); // warning: not a matching deallocator for myalloc | |
7208 | mydealloc (p); // ok | |
7209 | @} | |
7210 | @end smallexample | |
7211 | ||
7212 | In C++, the related option @option{-Wmismatched-new-delete} diagnoses | |
7213 | mismatches involving either @code{operator new} or @code{operator delete}. | |
7214 | ||
7215 | Option @option{-Wmismatched-dealloc} is included in @option{-Wall}. | |
7216 | ||
d77de738 ML |
7217 | @opindex Wmultistatement-macros |
7218 | @opindex Wno-multistatement-macros | |
ddf6fe37 | 7219 | @item -Wmultistatement-macros |
d77de738 ML |
7220 | Warn about unsafe multiple statement macros that appear to be guarded |
7221 | by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or | |
7222 | @code{while}, in which only the first statement is actually guarded after | |
7223 | the macro is expanded. | |
7224 | ||
7225 | For example: | |
7226 | ||
7227 | @smallexample | |
7228 | #define DOIT x++; y++ | |
7229 | if (c) | |
7230 | DOIT; | |
7231 | @end smallexample | |
7232 | ||
7233 | will increment @code{y} unconditionally, not just when @code{c} holds. | |
7234 | The can usually be fixed by wrapping the macro in a do-while loop: | |
7235 | @smallexample | |
7236 | #define DOIT do @{ x++; y++; @} while (0) | |
7237 | if (c) | |
7238 | DOIT; | |
7239 | @end smallexample | |
7240 | ||
7241 | This warning is enabled by @option{-Wall} in C and C++. | |
7242 | ||
d77de738 ML |
7243 | @opindex Wparentheses |
7244 | @opindex Wno-parentheses | |
ddf6fe37 | 7245 | @item -Wparentheses |
d77de738 ML |
7246 | Warn if parentheses are omitted in certain contexts, such |
7247 | as when there is an assignment in a context where a truth value | |
7248 | is expected, or when operators are nested whose precedence people | |
7249 | often get confused about. | |
7250 | ||
7251 | Also warn if a comparison like @code{x<=y<=z} appears; this is | |
7252 | equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different | |
7253 | interpretation from that of ordinary mathematical notation. | |
7254 | ||
7255 | Also warn for dangerous uses of the GNU extension to | |
7256 | @code{?:} with omitted middle operand. When the condition | |
7257 | in the @code{?}: operator is a boolean expression, the omitted value is | |
7258 | always 1. Often programmers expect it to be a value computed | |
7259 | inside the conditional expression instead. | |
7260 | ||
7261 | For C++ this also warns for some cases of unnecessary parentheses in | |
7262 | declarations, which can indicate an attempt at a function call instead | |
7263 | of a declaration: | |
7264 | @smallexample | |
7265 | @{ | |
7266 | // Declares a local variable called mymutex. | |
7267 | std::unique_lock<std::mutex> (mymutex); | |
7268 | // User meant std::unique_lock<std::mutex> lock (mymutex); | |
7269 | @} | |
7270 | @end smallexample | |
7271 | ||
7272 | This warning is enabled by @option{-Wall}. | |
7273 | ||
d77de738 ML |
7274 | @opindex Wself-move |
7275 | @opindex Wno-self-move | |
ddf6fe37 | 7276 | @item -Wno-self-move @r{(C++ and Objective-C++ only)} |
d77de738 ML |
7277 | This warning warns when a value is moved to itself with @code{std::move}. |
7278 | Such a @code{std::move} typically has no effect. | |
7279 | ||
7280 | @smallexample | |
7281 | struct T @{ | |
7282 | @dots{} | |
7283 | @}; | |
7284 | void fn() | |
7285 | @{ | |
7286 | T t; | |
7287 | @dots{} | |
7288 | t = std::move (t); | |
7289 | @} | |
7290 | @end smallexample | |
7291 | ||
7292 | This warning is enabled by @option{-Wall}. | |
7293 | ||
d77de738 ML |
7294 | @opindex Wsequence-point |
7295 | @opindex Wno-sequence-point | |
ddf6fe37 | 7296 | @item -Wsequence-point |
d77de738 ML |
7297 | Warn about code that may have undefined semantics because of violations |
7298 | of sequence point rules in the C and C++ standards. | |
7299 | ||
7300 | The C and C++ standards define the order in which expressions in a C/C++ | |
7301 | program are evaluated in terms of @dfn{sequence points}, which represent | |
7302 | a partial ordering between the execution of parts of the program: those | |
7303 | executed before the sequence point, and those executed after it. These | |
7304 | occur after the evaluation of a full expression (one which is not part | |
7305 | of a larger expression), after the evaluation of the first operand of a | |
7306 | @code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a | |
7307 | function is called (but after the evaluation of its arguments and the | |
7308 | expression denoting the called function), and in certain other places. | |
7309 | Other than as expressed by the sequence point rules, the order of | |
7310 | evaluation of subexpressions of an expression is not specified. All | |
7311 | these rules describe only a partial order rather than a total order, | |
7312 | since, for example, if two functions are called within one expression | |
7313 | with no sequence point between them, the order in which the functions | |
7314 | are called is not specified. However, the standards committee have | |
7315 | ruled that function calls do not overlap. | |
7316 | ||
7317 | It is not specified when between sequence points modifications to the | |
7318 | values of objects take effect. Programs whose behavior depends on this | |
7319 | have undefined behavior; the C and C++ standards specify that ``Between | |
7320 | the previous and next sequence point an object shall have its stored | |
7321 | value modified at most once by the evaluation of an expression. | |
7322 | Furthermore, the prior value shall be read only to determine the value | |
7323 | to be stored.''. If a program breaks these rules, the results on any | |
7324 | particular implementation are entirely unpredictable. | |
7325 | ||
7326 | Examples of code with undefined behavior are @code{a = a++;}, @code{a[n] | |
7327 | = b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not | |
7328 | diagnosed by this option, and it may give an occasional false positive | |
7329 | result, but in general it has been found fairly effective at detecting | |
7330 | this sort of problem in programs. | |
7331 | ||
7332 | The C++17 standard will define the order of evaluation of operands in | |
7333 | more cases: in particular it requires that the right-hand side of an | |
7334 | assignment be evaluated before the left-hand side, so the above | |
7335 | examples are no longer undefined. But this option will still warn | |
7336 | about them, to help people avoid writing code that is undefined in C | |
7337 | and earlier revisions of C++. | |
7338 | ||
7339 | The standard is worded confusingly, therefore there is some debate | |
7340 | over the precise meaning of the sequence point rules in subtle cases. | |
7341 | Links to discussions of the problem, including proposed formal | |
7342 | definitions, may be found on the GCC readings page, at | |
7343 | @uref{https://gcc.gnu.org/@/readings.html}. | |
7344 | ||
7345 | This warning is enabled by @option{-Wall} for C and C++. | |
7346 | ||
d77de738 ML |
7347 | @opindex Wno-return-local-addr |
7348 | @opindex Wreturn-local-addr | |
ddf6fe37 | 7349 | @item -Wno-return-local-addr |
d77de738 ML |
7350 | Do not warn about returning a pointer (or in C++, a reference) to a |
7351 | variable that goes out of scope after the function returns. | |
7352 | ||
d77de738 ML |
7353 | @opindex Wreturn-type |
7354 | @opindex Wno-return-type | |
ddf6fe37 | 7355 | @item -Wreturn-type |
d77de738 ML |
7356 | Warn whenever a function is defined with a return type that defaults |
7357 | to @code{int}. Also warn about any @code{return} statement with no | |
7358 | return value in a function whose return type is not @code{void} | |
7359 | (falling off the end of the function body is considered returning | |
7360 | without a value). | |
7361 | ||
7362 | For C only, warn about a @code{return} statement with an expression in a | |
7363 | function whose return type is @code{void}, unless the expression type is | |
7364 | also @code{void}. As a GNU extension, the latter case is accepted | |
7365 | without a warning unless @option{-Wpedantic} is used. Attempting | |
7366 | to use the return value of a non-@code{void} function other than @code{main} | |
7367 | that flows off the end by reaching the closing curly brace that terminates | |
7368 | the function is undefined. | |
7369 | ||
7370 | Unlike in C, in C++, flowing off the end of a non-@code{void} function other | |
7371 | than @code{main} results in undefined behavior even when the value of | |
7372 | the function is not used. | |
7373 | ||
7374 | This warning is enabled by default in C++ and by @option{-Wall} otherwise. | |
7375 | ||
d77de738 ML |
7376 | @opindex Wshift-count-negative |
7377 | @opindex Wno-shift-count-negative | |
ddf6fe37 | 7378 | @item -Wno-shift-count-negative |
d77de738 ML |
7379 | Controls warnings if a shift count is negative. |
7380 | This warning is enabled by default. | |
7381 | ||
d77de738 ML |
7382 | @opindex Wshift-count-overflow |
7383 | @opindex Wno-shift-count-overflow | |
ddf6fe37 | 7384 | @item -Wno-shift-count-overflow |
d77de738 ML |
7385 | Controls warnings if a shift count is greater than or equal to the bit width |
7386 | of the type. This warning is enabled by default. | |
7387 | ||
d77de738 ML |
7388 | @opindex Wshift-negative-value |
7389 | @opindex Wno-shift-negative-value | |
ddf6fe37 | 7390 | @item -Wshift-negative-value |
d77de738 ML |
7391 | Warn if left shifting a negative value. This warning is enabled by |
7392 | @option{-Wextra} in C99 (and newer) and C++11 to C++17 modes. | |
7393 | ||
d77de738 ML |
7394 | @opindex Wshift-overflow |
7395 | @opindex Wno-shift-overflow | |
ddf6fe37 AA |
7396 | @item -Wno-shift-overflow |
7397 | @itemx -Wshift-overflow=@var{n} | |
d77de738 ML |
7398 | These options control warnings about left shift overflows. |
7399 | ||
7400 | @table @gcctabopt | |
7401 | @item -Wshift-overflow=1 | |
7402 | This is the warning level of @option{-Wshift-overflow} and is enabled | |
7403 | by default in C99 and C++11 modes (and newer). This warning level does | |
7404 | not warn about left-shifting 1 into the sign bit. (However, in C, such | |
7405 | an overflow is still rejected in contexts where an integer constant expression | |
7406 | is required.) No warning is emitted in C++20 mode (and newer), as signed left | |
7407 | shifts always wrap. | |
7408 | ||
7409 | @item -Wshift-overflow=2 | |
7410 | This warning level also warns about left-shifting 1 into the sign bit, | |
7411 | unless C++14 mode (or newer) is active. | |
7412 | @end table | |
7413 | ||
d77de738 ML |
7414 | @opindex Wswitch |
7415 | @opindex Wno-switch | |
ddf6fe37 | 7416 | @item -Wswitch |
d77de738 ML |
7417 | Warn whenever a @code{switch} statement has an index of enumerated type |
7418 | and lacks a @code{case} for one or more of the named codes of that | |
7419 | enumeration. (The presence of a @code{default} label prevents this | |
7420 | warning.) @code{case} labels outside the enumeration range also | |
7421 | provoke warnings when this option is used (even if there is a | |
7422 | @code{default} label). | |
7423 | This warning is enabled by @option{-Wall}. | |
7424 | ||
d77de738 ML |
7425 | @opindex Wswitch-default |
7426 | @opindex Wno-switch-default | |
ddf6fe37 | 7427 | @item -Wswitch-default |
d77de738 ML |
7428 | Warn whenever a @code{switch} statement does not have a @code{default} |
7429 | case. | |
7430 | ||
d77de738 ML |
7431 | @opindex Wswitch-enum |
7432 | @opindex Wno-switch-enum | |
ddf6fe37 | 7433 | @item -Wswitch-enum |
d77de738 ML |
7434 | Warn whenever a @code{switch} statement has an index of enumerated type |
7435 | and lacks a @code{case} for one or more of the named codes of that | |
7436 | enumeration. @code{case} labels outside the enumeration range also | |
7437 | provoke warnings when this option is used. The only difference | |
7438 | between @option{-Wswitch} and this option is that this option gives a | |
7439 | warning about an omitted enumeration code even if there is a | |
7440 | @code{default} label. | |
7441 | ||
d77de738 ML |
7442 | @opindex Wswitch-bool |
7443 | @opindex Wno-switch-bool | |
ddf6fe37 | 7444 | @item -Wno-switch-bool |
d77de738 ML |
7445 | Do not warn when a @code{switch} statement has an index of boolean type |
7446 | and the case values are outside the range of a boolean type. | |
7447 | It is possible to suppress this warning by casting the controlling | |
7448 | expression to a type other than @code{bool}. For example: | |
7449 | @smallexample | |
7450 | @group | |
7451 | switch ((int) (a == 4)) | |
7452 | @{ | |
7453 | @dots{} | |
7454 | @} | |
7455 | @end group | |
7456 | @end smallexample | |
7457 | This warning is enabled by default for C and C++ programs. | |
7458 | ||
d77de738 ML |
7459 | @opindex Wswitch-outside-range |
7460 | @opindex Wno-switch-outside-range | |
ddf6fe37 | 7461 | @item -Wno-switch-outside-range |
d77de738 ML |
7462 | This option controls warnings when a @code{switch} case has a value |
7463 | that is outside of its | |
7464 | respective type range. This warning is enabled by default for | |
7465 | C and C++ programs. | |
7466 | ||
d77de738 ML |
7467 | @opindex Wswitch-unreachable |
7468 | @opindex Wno-switch-unreachable | |
ddf6fe37 | 7469 | @item -Wno-switch-unreachable |
d77de738 ML |
7470 | Do not warn when a @code{switch} statement contains statements between the |
7471 | controlling expression and the first case label, which will never be | |
7472 | executed. For example: | |
7473 | @smallexample | |
7474 | @group | |
7475 | switch (cond) | |
7476 | @{ | |
7477 | i = 15; | |
7478 | @dots{} | |
7479 | case 5: | |
7480 | @dots{} | |
7481 | @} | |
7482 | @end group | |
7483 | @end smallexample | |
7484 | @option{-Wswitch-unreachable} does not warn if the statement between the | |
7485 | controlling expression and the first case label is just a declaration: | |
7486 | @smallexample | |
7487 | @group | |
7488 | switch (cond) | |
7489 | @{ | |
7490 | int i; | |
7491 | @dots{} | |
7492 | case 5: | |
7493 | i = 5; | |
7494 | @dots{} | |
7495 | @} | |
7496 | @end group | |
7497 | @end smallexample | |
7498 | This warning is enabled by default for C and C++ programs. | |
7499 | ||
d77de738 ML |
7500 | @opindex Wsync-nand |
7501 | @opindex Wno-sync-nand | |
ddf6fe37 | 7502 | @item -Wsync-nand @r{(C and C++ only)} |
d77de738 ML |
7503 | Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch} |
7504 | built-in functions are used. These functions changed semantics in GCC 4.4. | |
7505 | ||
d77de738 ML |
7506 | @opindex Wtrivial-auto-var-init |
7507 | @opindex Wno-trivial-auto-var-init | |
ddf6fe37 | 7508 | @item -Wtrivial-auto-var-init |
d77de738 ML |
7509 | Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic |
7510 | variable. A common situation is an automatic variable that is declared | |
7511 | between the controlling expression and the first case label of a @code{switch} | |
7512 | statement. | |
7513 | ||
d77de738 ML |
7514 | @opindex Wunused-but-set-parameter |
7515 | @opindex Wno-unused-but-set-parameter | |
ddf6fe37 | 7516 | @item -Wunused-but-set-parameter |
d77de738 ML |
7517 | Warn whenever a function parameter is assigned to, but otherwise unused |
7518 | (aside from its declaration). | |
7519 | ||
7520 | To suppress this warning use the @code{unused} attribute | |
7521 | (@pxref{Variable Attributes}). | |
7522 | ||
7523 | This warning is also enabled by @option{-Wunused} together with | |
7524 | @option{-Wextra}. | |
7525 | ||
d77de738 ML |
7526 | @opindex Wunused-but-set-variable |
7527 | @opindex Wno-unused-but-set-variable | |
ddf6fe37 | 7528 | @item -Wunused-but-set-variable |
d77de738 ML |
7529 | Warn whenever a local variable is assigned to, but otherwise unused |
7530 | (aside from its declaration). | |
7531 | This warning is enabled by @option{-Wall}. | |
7532 | ||
7533 | To suppress this warning use the @code{unused} attribute | |
7534 | (@pxref{Variable Attributes}). | |
7535 | ||
7536 | This warning is also enabled by @option{-Wunused}, which is enabled | |
7537 | by @option{-Wall}. | |
7538 | ||
d77de738 ML |
7539 | @opindex Wunused-function |
7540 | @opindex Wno-unused-function | |
ddf6fe37 | 7541 | @item -Wunused-function |
d77de738 ML |
7542 | Warn whenever a static function is declared but not defined or a |
7543 | non-inline static function is unused. | |
7544 | This warning is enabled by @option{-Wall}. | |
7545 | ||
d77de738 ML |
7546 | @opindex Wunused-label |
7547 | @opindex Wno-unused-label | |
ddf6fe37 | 7548 | @item -Wunused-label |
d77de738 ML |
7549 | Warn whenever a label is declared but not used. |
7550 | This warning is enabled by @option{-Wall}. | |
7551 | ||
7552 | To suppress this warning use the @code{unused} attribute | |
7553 | (@pxref{Variable Attributes}). | |
7554 | ||
d77de738 ML |
7555 | @opindex Wunused-local-typedefs |
7556 | @opindex Wno-unused-local-typedefs | |
ddf6fe37 | 7557 | @item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)} |
d77de738 ML |
7558 | Warn when a typedef locally defined in a function is not used. |
7559 | This warning is enabled by @option{-Wall}. | |
7560 | ||
d77de738 ML |
7561 | @opindex Wunused-parameter |
7562 | @opindex Wno-unused-parameter | |
ddf6fe37 | 7563 | @item -Wunused-parameter |
d77de738 ML |
7564 | Warn whenever a function parameter is unused aside from its declaration. |
7565 | ||
7566 | To suppress this warning use the @code{unused} attribute | |
7567 | (@pxref{Variable Attributes}). | |
7568 | ||
d77de738 ML |
7569 | @opindex Wunused-result |
7570 | @opindex Wno-unused-result | |
ddf6fe37 | 7571 | @item -Wno-unused-result |
d77de738 ML |
7572 | Do not warn if a caller of a function marked with attribute |
7573 | @code{warn_unused_result} (@pxref{Function Attributes}) does not use | |
7574 | its return value. The default is @option{-Wunused-result}. | |
7575 | ||
d77de738 ML |
7576 | @opindex Wunused-variable |
7577 | @opindex Wno-unused-variable | |
ddf6fe37 | 7578 | @item -Wunused-variable |
d77de738 ML |
7579 | Warn whenever a local or static variable is unused aside from its |
7580 | declaration. This option implies @option{-Wunused-const-variable=1} for C, | |
7581 | but not for C++. This warning is enabled by @option{-Wall}. | |
7582 | ||
7583 | To suppress this warning use the @code{unused} attribute | |
7584 | (@pxref{Variable Attributes}). | |
7585 | ||
d77de738 ML |
7586 | @opindex Wunused-const-variable |
7587 | @opindex Wno-unused-const-variable | |
ddf6fe37 AA |
7588 | @item -Wunused-const-variable |
7589 | @itemx -Wunused-const-variable=@var{n} | |
d77de738 ML |
7590 | Warn whenever a constant static variable is unused aside from its declaration. |
7591 | @option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable} | |
7592 | for C, but not for C++. In C this declares variable storage, but in C++ this | |
7593 | is not an error since const variables take the place of @code{#define}s. | |
7594 | ||
7595 | To suppress this warning use the @code{unused} attribute | |
7596 | (@pxref{Variable Attributes}). | |
7597 | ||
7598 | @table @gcctabopt | |
7599 | @item -Wunused-const-variable=1 | |
7600 | This is the warning level that is enabled by @option{-Wunused-variable} for | |
7601 | C. It warns only about unused static const variables defined in the main | |
7602 | compilation unit, but not about static const variables declared in any | |
7603 | header included. | |
7604 | ||
7605 | @item -Wunused-const-variable=2 | |
7606 | This warning level also warns for unused constant static variables in | |
7607 | headers (excluding system headers). This is the warning level of | |
7608 | @option{-Wunused-const-variable} and must be explicitly requested since | |
7609 | in C++ this isn't an error and in C it might be harder to clean up all | |
7610 | headers included. | |
7611 | @end table | |
7612 | ||
d77de738 ML |
7613 | @opindex Wunused-value |
7614 | @opindex Wno-unused-value | |
ddf6fe37 | 7615 | @item -Wunused-value |
d77de738 ML |
7616 | Warn whenever a statement computes a result that is explicitly not |
7617 | used. To suppress this warning cast the unused expression to | |
7618 | @code{void}. This includes an expression-statement or the left-hand | |
7619 | side of a comma expression that contains no side effects. For example, | |
7620 | an expression such as @code{x[i,j]} causes a warning, while | |
7621 | @code{x[(void)i,j]} does not. | |
7622 | ||
7623 | This warning is enabled by @option{-Wall}. | |
7624 | ||
d77de738 ML |
7625 | @opindex Wunused |
7626 | @opindex Wno-unused | |
ddf6fe37 | 7627 | @item -Wunused |
d77de738 ML |
7628 | All the above @option{-Wunused} options combined. |
7629 | ||
7630 | In order to get a warning about an unused function parameter, you must | |
7631 | either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies | |
7632 | @option{-Wunused}), or separately specify @option{-Wunused-parameter}. | |
7633 | ||
d77de738 ML |
7634 | @opindex Wuninitialized |
7635 | @opindex Wno-uninitialized | |
ddf6fe37 | 7636 | @item -Wuninitialized |
d77de738 ML |
7637 | Warn if an object with automatic or allocated storage duration is used |
7638 | without having been initialized. In C++, also warn if a non-static | |
7639 | reference or non-static @code{const} member appears in a class without | |
7640 | constructors. | |
7641 | ||
7642 | In addition, passing a pointer (or in C++, a reference) to an uninitialized | |
7643 | object to a @code{const}-qualified argument of a built-in function known to | |
7644 | read the object is also diagnosed by this warning. | |
7645 | (@option{-Wmaybe-uninitialized} is issued for ordinary functions.) | |
7646 | ||
7647 | If you want to warn about code that uses the uninitialized value of the | |
7648 | variable in its own initializer, use the @option{-Winit-self} option. | |
7649 | ||
7650 | These warnings occur for individual uninitialized elements of | |
7651 | structure, union or array variables as well as for variables that are | |
7652 | uninitialized as a whole. They do not occur for variables or elements | |
7653 | declared @code{volatile}. Because these warnings depend on | |
7654 | optimization, the exact variables or elements for which there are | |
7655 | warnings depend on the precise optimization options and version of GCC | |
7656 | used. | |
7657 | ||
7658 | Note that there may be no warning about a variable that is used only | |
7659 | to compute a value that itself is never used, because such | |
7660 | computations may be deleted by data flow analysis before the warnings | |
7661 | are printed. | |
7662 | ||
7663 | In C++, this warning also warns about using uninitialized objects in | |
7664 | member-initializer-lists. For example, GCC warns about @code{b} being | |
7665 | uninitialized in the following snippet: | |
7666 | ||
7667 | @smallexample | |
7668 | struct A @{ | |
7669 | int a; | |
7670 | int b; | |
7671 | A() : a(b) @{ @} | |
7672 | @}; | |
7673 | @end smallexample | |
7674 | ||
d77de738 ML |
7675 | @opindex Winvalid-memory-model |
7676 | @opindex Wno-invalid-memory-model | |
ddf6fe37 | 7677 | @item -Wno-invalid-memory-model |
d77de738 ML |
7678 | This option controls warnings |
7679 | for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins}, | |
7680 | and the C11 atomic generic functions with a memory consistency argument | |
7681 | that is either invalid for the operation or outside the range of values | |
7682 | of the @code{memory_order} enumeration. For example, since the | |
7683 | @code{__atomic_store} and @code{__atomic_store_n} built-ins are only | |
7684 | defined for the relaxed, release, and sequentially consistent memory | |
7685 | orders the following code is diagnosed: | |
7686 | ||
7687 | @smallexample | |
7688 | void store (int *i) | |
7689 | @{ | |
7690 | __atomic_store_n (i, 0, memory_order_consume); | |
7691 | @} | |
7692 | @end smallexample | |
7693 | ||
7694 | @option{-Winvalid-memory-model} is enabled by default. | |
7695 | ||
d77de738 ML |
7696 | @opindex Wmaybe-uninitialized |
7697 | @opindex Wno-maybe-uninitialized | |
ddf6fe37 | 7698 | @item -Wmaybe-uninitialized |
d77de738 ML |
7699 | For an object with automatic or allocated storage duration, if there exists |
7700 | a path from the function entry to a use of the object that is initialized, | |
7701 | but there exist some other paths for which the object is not initialized, | |
7702 | the compiler emits a warning if it cannot prove the uninitialized paths | |
7703 | are not executed at run time. | |
7704 | ||
7705 | In addition, passing a pointer (or in C++, a reference) to an uninitialized | |
7706 | object to a @code{const}-qualified function argument is also diagnosed by | |
7707 | this warning. (@option{-Wuninitialized} is issued for built-in functions | |
7708 | known to read the object.) Annotating the function with attribute | |
7709 | @code{access (none)} indicates that the argument isn't used to access | |
7710 | the object and avoids the warning (@pxref{Common Function Attributes}). | |
7711 | ||
7712 | These warnings are only possible in optimizing compilation, because otherwise | |
7713 | GCC does not keep track of the state of variables. | |
7714 | ||
7715 | These warnings are made optional because GCC may not be able to determine when | |
7716 | the code is correct in spite of appearing to have an error. Here is one | |
7717 | example of how this can happen: | |
7718 | ||
7719 | @smallexample | |
7720 | @group | |
7721 | @{ | |
7722 | int x; | |
7723 | switch (y) | |
7724 | @{ | |
7725 | case 1: x = 1; | |
7726 | break; | |
7727 | case 2: x = 4; | |
7728 | break; | |
7729 | case 3: x = 5; | |
7730 | @} | |
7731 | foo (x); | |
7732 | @} | |
7733 | @end group | |
7734 | @end smallexample | |
7735 | ||
7736 | @noindent | |
7737 | If the value of @code{y} is always 1, 2 or 3, then @code{x} is | |
7738 | always initialized, but GCC doesn't know this. To suppress the | |
7739 | warning, you need to provide a default case with assert(0) or | |
7740 | similar code. | |
7741 | ||
7742 | @cindex @code{longjmp} warnings | |
7743 | This option also warns when a non-volatile automatic variable might be | |
7744 | changed by a call to @code{longjmp}. | |
7745 | The compiler sees only the calls to @code{setjmp}. It cannot know | |
7746 | where @code{longjmp} will be called; in fact, a signal handler could | |
7747 | call it at any point in the code. As a result, you may get a warning | |
7748 | even when there is in fact no problem because @code{longjmp} cannot | |
7749 | in fact be called at the place that would cause a problem. | |
7750 | ||
7751 | Some spurious warnings can be avoided if you declare all the functions | |
7752 | you use that never return as @code{noreturn}. @xref{Function | |
7753 | Attributes}. | |
7754 | ||
7755 | This warning is enabled by @option{-Wall} or @option{-Wextra}. | |
7756 | ||
d77de738 ML |
7757 | @opindex Wunknown-pragmas |
7758 | @opindex Wno-unknown-pragmas | |
7759 | @cindex warning for unknown pragmas | |
7760 | @cindex unknown pragmas, warning | |
7761 | @cindex pragmas, warning of unknown | |
f33d7a88 | 7762 | @item -Wunknown-pragmas |
d77de738 ML |
7763 | Warn when a @code{#pragma} directive is encountered that is not understood by |
7764 | GCC@. If this command-line option is used, warnings are even issued | |
7765 | for unknown pragmas in system header files. This is not the case if | |
7766 | the warnings are only enabled by the @option{-Wall} command-line option. | |
7767 | ||
d77de738 ML |
7768 | @opindex Wno-pragmas |
7769 | @opindex Wpragmas | |
ddf6fe37 | 7770 | @item -Wno-pragmas |
d77de738 ML |
7771 | Do not warn about misuses of pragmas, such as incorrect parameters, |
7772 | invalid syntax, or conflicts between pragmas. See also | |
7773 | @option{-Wunknown-pragmas}. | |
7774 | ||
d77de738 ML |
7775 | @opindex Wno-prio-ctor-dtor |
7776 | @opindex Wprio-ctor-dtor | |
ddf6fe37 | 7777 | @item -Wno-prio-ctor-dtor |
d77de738 ML |
7778 | Do not warn if a priority from 0 to 100 is used for constructor or destructor. |
7779 | The use of constructor and destructor attributes allow you to assign a | |
7780 | priority to the constructor/destructor to control its order of execution | |
7781 | before @code{main} is called or after it returns. The priority values must be | |
7782 | greater than 100 as the compiler reserves priority values between 0--100 for | |
7783 | the implementation. | |
7784 | ||
d77de738 ML |
7785 | @opindex Wstrict-aliasing |
7786 | @opindex Wno-strict-aliasing | |
ddf6fe37 | 7787 | @item -Wstrict-aliasing |
d77de738 ML |
7788 | This option is only active when @option{-fstrict-aliasing} is active. |
7789 | It warns about code that might break the strict aliasing rules that the | |
7790 | compiler is using for optimization. The warning does not catch all | |
7791 | cases, but does attempt to catch the more common pitfalls. It is | |
7792 | included in @option{-Wall}. | |
7793 | It is equivalent to @option{-Wstrict-aliasing=3} | |
7794 | ||
d77de738 | 7795 | @opindex Wstrict-aliasing=n |
ddf6fe37 | 7796 | @item -Wstrict-aliasing=n |
d77de738 ML |
7797 | This option is only active when @option{-fstrict-aliasing} is active. |
7798 | It warns about code that might break the strict aliasing rules that the | |
7799 | compiler is using for optimization. | |
7800 | Higher levels correspond to higher accuracy (fewer false positives). | |
7801 | Higher levels also correspond to more effort, similar to the way @option{-O} | |
7802 | works. | |
7803 | @option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}. | |
7804 | ||
7805 | Level 1: Most aggressive, quick, least accurate. | |
7806 | Possibly useful when higher levels | |
7807 | do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few | |
7808 | false negatives. However, it has many false positives. | |
7809 | Warns for all pointer conversions between possibly incompatible types, | |
7810 | even if never dereferenced. Runs in the front end only. | |
7811 | ||
7812 | Level 2: Aggressive, quick, not too precise. | |
7813 | May still have many false positives (not as many as level 1 though), | |
7814 | and few false negatives (but possibly more than level 1). | |
7815 | Unlike level 1, it only warns when an address is taken. Warns about | |
7816 | incomplete types. Runs in the front end only. | |
7817 | ||
7818 | Level 3 (default for @option{-Wstrict-aliasing}): | |
7819 | Should have very few false positives and few false | |
7820 | negatives. Slightly slower than levels 1 or 2 when optimization is enabled. | |
7821 | Takes care of the common pun+dereference pattern in the front end: | |
7822 | @code{*(int*)&some_float}. | |
7823 | If optimization is enabled, it also runs in the back end, where it deals | |
7824 | with multiple statement cases using flow-sensitive points-to information. | |
7825 | Only warns when the converted pointer is dereferenced. | |
7826 | Does not warn about incomplete types. | |
7827 | ||
d77de738 ML |
7828 | @opindex Wstrict-overflow |
7829 | @opindex Wno-strict-overflow | |
ddf6fe37 AA |
7830 | @item -Wstrict-overflow |
7831 | @itemx -Wstrict-overflow=@var{n} | |
d77de738 ML |
7832 | This option is only active when signed overflow is undefined. |
7833 | It warns about cases where the compiler optimizes based on the | |
7834 | assumption that signed overflow does not occur. Note that it does not | |
7835 | warn about all cases where the code might overflow: it only warns | |
7836 | about cases where the compiler implements some optimization. Thus | |
7837 | this warning depends on the optimization level. | |
7838 | ||
7839 | An optimization that assumes that signed overflow does not occur is | |
7840 | perfectly safe if the values of the variables involved are such that | |
7841 | overflow never does, in fact, occur. Therefore this warning can | |
7842 | easily give a false positive: a warning about code that is not | |
7843 | actually a problem. To help focus on important issues, several | |
7844 | warning levels are defined. No warnings are issued for the use of | |
7845 | undefined signed overflow when estimating how many iterations a loop | |
7846 | requires, in particular when determining whether a loop will be | |
7847 | executed at all. | |
7848 | ||
7849 | @table @gcctabopt | |
7850 | @item -Wstrict-overflow=1 | |
7851 | Warn about cases that are both questionable and easy to avoid. For | |
7852 | example the compiler simplifies | |
7853 | @code{x + 1 > x} to @code{1}. This level of | |
7854 | @option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels | |
7855 | are not, and must be explicitly requested. | |
7856 | ||
7857 | @item -Wstrict-overflow=2 | |
7858 | Also warn about other cases where a comparison is simplified to a | |
7859 | constant. For example: @code{abs (x) >= 0}. This can only be | |
7860 | simplified when signed integer overflow is undefined, because | |
7861 | @code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than | |
7862 | zero. @option{-Wstrict-overflow} (with no level) is the same as | |
7863 | @option{-Wstrict-overflow=2}. | |
7864 | ||
7865 | @item -Wstrict-overflow=3 | |
7866 | Also warn about other cases where a comparison is simplified. For | |
7867 | example: @code{x + 1 > 1} is simplified to @code{x > 0}. | |
7868 | ||
7869 | @item -Wstrict-overflow=4 | |
7870 | Also warn about other simplifications not covered by the above cases. | |
7871 | For example: @code{(x * 10) / 5} is simplified to @code{x * 2}. | |
7872 | ||
7873 | @item -Wstrict-overflow=5 | |
7874 | Also warn about cases where the compiler reduces the magnitude of a | |
7875 | constant involved in a comparison. For example: @code{x + 2 > y} is | |
7876 | simplified to @code{x + 1 >= y}. This is reported only at the | |
7877 | highest warning level because this simplification applies to many | |
7878 | comparisons, so this warning level gives a very large number of | |
7879 | false positives. | |
7880 | @end table | |
7881 | ||
d77de738 ML |
7882 | @opindex Wstring-compare |
7883 | @opindex Wno-string-compare | |
ddf6fe37 | 7884 | @item -Wstring-compare |
d77de738 ML |
7885 | Warn for calls to @code{strcmp} and @code{strncmp} whose result is |
7886 | determined to be either zero or non-zero in tests for such equality | |
7887 | owing to the length of one argument being greater than the size of | |
7888 | the array the other argument is stored in (or the bound in the case | |
7889 | of @code{strncmp}). Such calls could be mistakes. For example, | |
7890 | the call to @code{strcmp} below is diagnosed because its result is | |
7891 | necessarily non-zero irrespective of the contents of the array @code{a}. | |
7892 | ||
7893 | @smallexample | |
7894 | extern char a[4]; | |
7895 | void f (char *d) | |
7896 | @{ | |
7897 | strcpy (d, "string"); | |
7898 | @dots{} | |
7899 | if (0 == strcmp (a, d)) // cannot be true | |
7900 | puts ("a and d are the same"); | |
7901 | @} | |
7902 | @end smallexample | |
7903 | ||
7904 | @option{-Wstring-compare} is enabled by @option{-Wextra}. | |
7905 | ||
ddf6fe37 AA |
7906 | @opindex Wstringop-overflow |
7907 | @opindex Wno-stringop-overflow | |
d77de738 ML |
7908 | @item -Wno-stringop-overflow |
7909 | @item -Wstringop-overflow | |
7910 | @itemx -Wstringop-overflow=@var{type} | |
d77de738 ML |
7911 | Warn for calls to string manipulation functions such as @code{memcpy} and |
7912 | @code{strcpy} that are determined to overflow the destination buffer. The | |
7913 | optional argument is one greater than the type of Object Size Checking to | |
7914 | perform to determine the size of the destination. @xref{Object Size Checking}. | |
7915 | The argument is meaningful only for functions that operate on character arrays | |
7916 | but not for raw memory functions like @code{memcpy} which always make use | |
7917 | of Object Size type-0. The option also warns for calls that specify a size | |
7918 | in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes. | |
7919 | The option produces the best results with optimization enabled but can detect | |
7920 | a small subset of simple buffer overflows even without optimization in | |
7921 | calls to the GCC built-in functions like @code{__builtin_memcpy} that | |
7922 | correspond to the standard functions. In any case, the option warns about | |
7923 | just a subset of buffer overflows detected by the corresponding overflow | |
7924 | checking built-ins. For example, the option issues a warning for | |
7925 | the @code{strcpy} call below because it copies at least 5 characters | |
7926 | (the string @code{"blue"} including the terminating NUL) into the buffer | |
7927 | of size 4. | |
7928 | ||
7929 | @smallexample | |
7930 | enum Color @{ blue, purple, yellow @}; | |
7931 | const char* f (enum Color clr) | |
7932 | @{ | |
7933 | static char buf [4]; | |
7934 | const char *str; | |
7935 | switch (clr) | |
7936 | @{ | |
7937 | case blue: str = "blue"; break; | |
7938 | case purple: str = "purple"; break; | |
7939 | case yellow: str = "yellow"; break; | |
7940 | @} | |
7941 | ||
7942 | return strcpy (buf, str); // warning here | |
7943 | @} | |
7944 | @end smallexample | |
7945 | ||
7946 | Option @option{-Wstringop-overflow=2} is enabled by default. | |
7947 | ||
7948 | @table @gcctabopt | |
d77de738 ML |
7949 | @opindex Wstringop-overflow |
7950 | @opindex Wno-stringop-overflow | |
ddf6fe37 AA |
7951 | @item -Wstringop-overflow |
7952 | @itemx -Wstringop-overflow=1 | |
d77de738 ML |
7953 | The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking |
7954 | to determine the sizes of destination objects. At this setting the option | |
7955 | does not warn for writes past the end of subobjects of larger objects accessed | |
7956 | by pointers unless the size of the largest surrounding object is known. When | |
7957 | the destination may be one of several objects it is assumed to be the largest | |
7958 | one of them. On Linux systems, when optimization is enabled at this setting | |
7959 | the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro | |
7960 | is defined to a non-zero value. | |
7961 | ||
7962 | @item -Wstringop-overflow=2 | |
7963 | The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking | |
7964 | to determine the sizes of destination objects. At this setting the option | |
7965 | warns about overflows when writing to members of the largest complete | |
7966 | objects whose exact size is known. However, it does not warn for excessive | |
7967 | writes to the same members of unknown objects referenced by pointers since | |
7968 | they may point to arrays containing unknown numbers of elements. This is | |
7969 | the default setting of the option. | |
7970 | ||
7971 | @item -Wstringop-overflow=3 | |
7972 | The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking | |
7973 | to determine the sizes of destination objects. At this setting the option | |
7974 | warns about overflowing the smallest object or data member. This is the | |
7975 | most restrictive setting of the option that may result in warnings for safe | |
7976 | code. | |
7977 | ||
7978 | @item -Wstringop-overflow=4 | |
7979 | The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking | |
7980 | to determine the sizes of destination objects. At this setting the option | |
7981 | warns about overflowing any data members, and when the destination is | |
7982 | one of several objects it uses the size of the largest of them to decide | |
7983 | whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this | |
7984 | setting of the option may result in warnings for benign code. | |
7985 | @end table | |
7986 | ||
d77de738 ML |
7987 | @opindex Wstringop-overread |
7988 | @opindex Wno-stringop-overread | |
ddf6fe37 | 7989 | @item -Wno-stringop-overread |
d77de738 ML |
7990 | Warn for calls to string manipulation functions such as @code{memchr}, or |
7991 | @code{strcpy} that are determined to read past the end of the source | |
7992 | sequence. | |
7993 | ||
7994 | Option @option{-Wstringop-overread} is enabled by default. | |
7995 | ||
d77de738 ML |
7996 | @opindex Wstringop-truncation |
7997 | @opindex Wno-stringop-truncation | |
ddf6fe37 | 7998 | @item -Wno-stringop-truncation |
d77de738 ML |
7999 | Do not warn for calls to bounded string manipulation functions |
8000 | such as @code{strncat}, | |
8001 | @code{strncpy}, and @code{stpncpy} that may either truncate the copied string | |
8002 | or leave the destination unchanged. | |
8003 | ||
8004 | In the following example, the call to @code{strncat} specifies a bound that | |
8005 | is less than the length of the source string. As a result, the copy of | |
8006 | the source will be truncated and so the call is diagnosed. To avoid the | |
8007 | warning use @code{bufsize - strlen (buf) - 1)} as the bound. | |
8008 | ||
8009 | @smallexample | |
8010 | void append (char *buf, size_t bufsize) | |
8011 | @{ | |
8012 | strncat (buf, ".txt", 3); | |
8013 | @} | |
8014 | @end smallexample | |
8015 | ||
8016 | As another example, the following call to @code{strncpy} results in copying | |
8017 | to @code{d} just the characters preceding the terminating NUL, without | |
8018 | appending the NUL to the end. Assuming the result of @code{strncpy} is | |
8019 | necessarily a NUL-terminated string is a common mistake, and so the call | |
8020 | is diagnosed. To avoid the warning when the result is not expected to be | |
8021 | NUL-terminated, call @code{memcpy} instead. | |
8022 | ||
8023 | @smallexample | |
8024 | void copy (char *d, const char *s) | |
8025 | @{ | |
8026 | strncpy (d, s, strlen (s)); | |
8027 | @} | |
8028 | @end smallexample | |
8029 | ||
8030 | In the following example, the call to @code{strncpy} specifies the size | |
8031 | of the destination buffer as the bound. If the length of the source | |
8032 | string is equal to or greater than this size the result of the copy will | |
8033 | not be NUL-terminated. Therefore, the call is also diagnosed. To avoid | |
8034 | the warning, specify @code{sizeof buf - 1} as the bound and set the last | |
8035 | element of the buffer to @code{NUL}. | |
8036 | ||
8037 | @smallexample | |
8038 | void copy (const char *s) | |
8039 | @{ | |
8040 | char buf[80]; | |
8041 | strncpy (buf, s, sizeof buf); | |
8042 | @dots{} | |
8043 | @} | |
8044 | @end smallexample | |
8045 | ||
8046 | In situations where a character array is intended to store a sequence | |
8047 | of bytes with no terminating @code{NUL} such an array may be annotated | |
8048 | with attribute @code{nonstring} to avoid this warning. Such arrays, | |
8049 | however, are not suitable arguments to functions that expect | |
8050 | @code{NUL}-terminated strings. To help detect accidental misuses of | |
8051 | such arrays GCC issues warnings unless it can prove that the use is | |
8052 | safe. @xref{Common Variable Attributes}. | |
8053 | ||
2a27ae32 QZ |
8054 | @opindex Wstrict-flex-arrays |
8055 | @opindex Wno-strict-flex-arrays | |
ddf6fe37 | 8056 | @item -Wstrict-flex-arrays |
2a27ae32 QZ |
8057 | Warn about inproper usages of flexible array members |
8058 | according to the @var{level} of the @code{strict_flex_array (@var{level})} | |
8059 | attribute attached to the trailing array field of a structure if it's | |
8060 | available, otherwise according to the @var{level} of the option | |
8061 | @option{-fstrict-flex-arrays=@var{level}}. | |
8062 | ||
8063 | This option is effective only when @var{level} is bigger than 0. Otherwise, | |
8064 | it will be ignored with a warning. | |
8065 | ||
8066 | when @var{level}=1, warnings will be issued for a trailing array reference | |
8067 | of a structure that have 2 or more elements if the trailing array is referenced | |
8068 | as a flexible array member. | |
8069 | ||
8070 | when @var{level}=2, in addition to @var{level}=1, additional warnings will be | |
8071 | issued for a trailing one-element array reference of a structure | |
8072 | if the array is referenced as a flexible array member. | |
8073 | ||
8074 | when @var{level}=3, in addition to @var{level}=2, additional warnings will be | |
8075 | issued for a trailing zero-length array reference of a structure | |
8076 | if the array is referenced as a flexible array member. | |
8077 | ||
8078 | ||
d77de738 ML |
8079 | @opindex Wsuggest-attribute= |
8080 | @opindex Wno-suggest-attribute= | |
ddf6fe37 | 8081 | @item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]} |
d77de738 ML |
8082 | Warn for cases where adding an attribute may be beneficial. The |
8083 | attributes currently supported are listed below. | |
8084 | ||
8085 | @table @gcctabopt | |
d77de738 ML |
8086 | @opindex Wsuggest-attribute=pure |
8087 | @opindex Wno-suggest-attribute=pure | |
8088 | @opindex Wsuggest-attribute=const | |
8089 | @opindex Wno-suggest-attribute=const | |
8090 | @opindex Wsuggest-attribute=noreturn | |
8091 | @opindex Wno-suggest-attribute=noreturn | |
8092 | @opindex Wmissing-noreturn | |
8093 | @opindex Wno-missing-noreturn | |
8094 | @opindex Wsuggest-attribute=malloc | |
8095 | @opindex Wno-suggest-attribute=malloc | |
ddf6fe37 AA |
8096 | @item -Wsuggest-attribute=pure |
8097 | @itemx -Wsuggest-attribute=const | |
8098 | @itemx -Wsuggest-attribute=noreturn | |
8099 | @itemx -Wmissing-noreturn | |
8100 | @itemx -Wsuggest-attribute=malloc | |
d77de738 ML |
8101 | |
8102 | Warn about functions that might be candidates for attributes | |
8103 | @code{pure}, @code{const} or @code{noreturn} or @code{malloc}. The compiler | |
8104 | only warns for functions visible in other compilation units or (in the case of | |
8105 | @code{pure} and @code{const}) if it cannot prove that the function returns | |
8106 | normally. A function returns normally if it doesn't contain an infinite loop or | |
8107 | return abnormally by throwing, calling @code{abort} or trapping. This analysis | |
8108 | requires option @option{-fipa-pure-const}, which is enabled by default at | |
8109 | @option{-O} and higher. Higher optimization levels improve the accuracy | |
8110 | of the analysis. | |
8111 | ||
d77de738 ML |
8112 | @opindex Wsuggest-attribute=format |
8113 | @opindex Wmissing-format-attribute | |
8114 | @opindex Wno-suggest-attribute=format | |
8115 | @opindex Wno-missing-format-attribute | |
8116 | @opindex Wformat | |
8117 | @opindex Wno-format | |
ddf6fe37 AA |
8118 | @item -Wsuggest-attribute=format |
8119 | @itemx -Wmissing-format-attribute | |
d77de738 ML |
8120 | |
8121 | Warn about function pointers that might be candidates for @code{format} | |
8122 | attributes. Note these are only possible candidates, not absolute ones. | |
8123 | GCC guesses that function pointers with @code{format} attributes that | |
8124 | are used in assignment, initialization, parameter passing or return | |
8125 | statements should have a corresponding @code{format} attribute in the | |
8126 | resulting type. I.e.@: the left-hand side of the assignment or | |
8127 | initialization, the type of the parameter variable, or the return type | |
8128 | of the containing function respectively should also have a @code{format} | |
8129 | attribute to avoid the warning. | |
8130 | ||
8131 | GCC also warns about function definitions that might be | |
8132 | candidates for @code{format} attributes. Again, these are only | |
8133 | possible candidates. GCC guesses that @code{format} attributes | |
8134 | might be appropriate for any function that calls a function like | |
8135 | @code{vprintf} or @code{vscanf}, but this might not always be the | |
8136 | case, and some functions for which @code{format} attributes are | |
8137 | appropriate may not be detected. | |
8138 | ||
d77de738 ML |
8139 | @opindex Wsuggest-attribute=cold |
8140 | @opindex Wno-suggest-attribute=cold | |
ddf6fe37 | 8141 | @item -Wsuggest-attribute=cold |
d77de738 ML |
8142 | |
8143 | Warn about functions that might be candidates for @code{cold} attribute. This | |
8144 | is based on static detection and generally only warns about functions which | |
8145 | always leads to a call to another @code{cold} function such as wrappers of | |
8146 | C++ @code{throw} or fatal error reporting functions leading to @code{abort}. | |
8147 | @end table | |
8148 | ||
d880e093 MU |
8149 | @opindex Wno-alloc-size |
8150 | @opindex Walloc-size | |
8151 | @item -Walloc-size | |
8152 | Warn about calls to allocation functions decorated with attribute | |
8153 | @code{alloc_size} that specify insufficient size for the target type of | |
8154 | the pointer the result is assigned to, including those to the built-in | |
8155 | forms of the functions @code{aligned_alloc}, @code{alloca}, | |
8156 | @code{calloc}, | |
8157 | @code{malloc}, and @code{realloc}. | |
8158 | ||
d77de738 ML |
8159 | @opindex Wno-alloc-zero |
8160 | @opindex Walloc-zero | |
ddf6fe37 | 8161 | @item -Walloc-zero |
d77de738 ML |
8162 | Warn about calls to allocation functions decorated with attribute |
8163 | @code{alloc_size} that specify zero bytes, including those to the built-in | |
8164 | forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc}, | |
8165 | @code{malloc}, and @code{realloc}. Because the behavior of these functions | |
8166 | when called with a zero size differs among implementations (and in the case | |
8167 | of @code{realloc} has been deprecated) relying on it may result in subtle | |
8168 | portability bugs and should be avoided. | |
8169 | ||
d77de738 ML |
8170 | @opindex Walloc-size-larger-than= |
8171 | @opindex Wno-alloc-size-larger-than | |
ddf6fe37 | 8172 | @item -Walloc-size-larger-than=@var{byte-size} |
d77de738 ML |
8173 | Warn about calls to functions decorated with attribute @code{alloc_size} |
8174 | that attempt to allocate objects larger than the specified number of bytes, | |
8175 | or where the result of the size computation in an integer type with infinite | |
8176 | precision would exceed the value of @samp{PTRDIFF_MAX} on the target. | |
8177 | @option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default. | |
8178 | Warnings controlled by the option can be disabled either by specifying | |
8179 | @var{byte-size} of @samp{SIZE_MAX} or more or by | |
8180 | @option{-Wno-alloc-size-larger-than}. | |
8181 | @xref{Function Attributes}. | |
8182 | ||
d77de738 | 8183 | @opindex Wno-alloc-size-larger-than |
ddf6fe37 | 8184 | @item -Wno-alloc-size-larger-than |
d77de738 ML |
8185 | Disable @option{-Walloc-size-larger-than=} warnings. The option is |
8186 | equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or | |
8187 | larger. | |
8188 | ||
d77de738 ML |
8189 | @opindex Wno-alloca |
8190 | @opindex Walloca | |
ddf6fe37 | 8191 | @item -Walloca |
d77de738 ML |
8192 | This option warns on all uses of @code{alloca} in the source. |
8193 | ||
d77de738 ML |
8194 | @opindex Walloca-larger-than= |
8195 | @opindex Wno-alloca-larger-than | |
ddf6fe37 | 8196 | @item -Walloca-larger-than=@var{byte-size} |
d77de738 ML |
8197 | This option warns on calls to @code{alloca} with an integer argument whose |
8198 | value is either zero, or that is not bounded by a controlling predicate | |
8199 | that limits its value to at most @var{byte-size}. It also warns for calls | |
8200 | to @code{alloca} where the bound value is unknown. Arguments of non-integer | |
8201 | types are considered unbounded even if they appear to be constrained to | |
8202 | the expected range. | |
8203 | ||
8204 | For example, a bounded case of @code{alloca} could be: | |
8205 | ||
8206 | @smallexample | |
8207 | void func (size_t n) | |
8208 | @{ | |
8209 | void *p; | |
8210 | if (n <= 1000) | |
8211 | p = alloca (n); | |
8212 | else | |
8213 | p = malloc (n); | |
8214 | f (p); | |
8215 | @} | |
8216 | @end smallexample | |
8217 | ||
8218 | In the above example, passing @code{-Walloca-larger-than=1000} would not | |
8219 | issue a warning because the call to @code{alloca} is known to be at most | |
8220 | 1000 bytes. However, if @code{-Walloca-larger-than=500} were passed, | |
8221 | the compiler would emit a warning. | |
8222 | ||
8223 | Unbounded uses, on the other hand, are uses of @code{alloca} with no | |
8224 | controlling predicate constraining its integer argument. For example: | |
8225 | ||
8226 | @smallexample | |
8227 | void func () | |
8228 | @{ | |
8229 | void *p = alloca (n); | |
8230 | f (p); | |
8231 | @} | |
8232 | @end smallexample | |
8233 | ||
8234 | If @code{-Walloca-larger-than=500} were passed, the above would trigger | |
8235 | a warning, but this time because of the lack of bounds checking. | |
8236 | ||
8237 | Note, that even seemingly correct code involving signed integers could | |
8238 | cause a warning: | |
8239 | ||
8240 | @smallexample | |
8241 | void func (signed int n) | |
8242 | @{ | |
8243 | if (n < 500) | |
8244 | @{ | |
8245 | p = alloca (n); | |
8246 | f (p); | |
8247 | @} | |
8248 | @} | |
8249 | @end smallexample | |
8250 | ||
8251 | In the above example, @var{n} could be negative, causing a larger than | |
8252 | expected argument to be implicitly cast into the @code{alloca} call. | |
8253 | ||
8254 | This option also warns when @code{alloca} is used in a loop. | |
8255 | ||
8256 | @option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default | |
8257 | but is usually only effective when @option{-ftree-vrp} is active (default | |
8258 | for @option{-O2} and above). | |
8259 | ||
8260 | See also @option{-Wvla-larger-than=}@samp{byte-size}. | |
8261 | ||
d77de738 | 8262 | @opindex Wno-alloca-larger-than |
ddf6fe37 | 8263 | @item -Wno-alloca-larger-than |
d77de738 ML |
8264 | Disable @option{-Walloca-larger-than=} warnings. The option is |
8265 | equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger. | |
8266 | ||
d77de738 ML |
8267 | @opindex Warith-conversion |
8268 | @opindex Wno-arith-conversion | |
ddf6fe37 | 8269 | @item -Warith-conversion |
d77de738 ML |
8270 | Do warn about implicit conversions from arithmetic operations even |
8271 | when conversion of the operands to the same type cannot change their | |
8272 | values. This affects warnings from @option{-Wconversion}, | |
8273 | @option{-Wfloat-conversion}, and @option{-Wsign-conversion}. | |
8274 | ||
8275 | @smallexample | |
8276 | @group | |
8277 | void f (char c, int i) | |
8278 | @{ | |
8279 | c = c + i; // warns with @option{-Wconversion} | |
8280 | c = c + 1; // only warns with @option{-Warith-conversion} | |
8281 | @} | |
8282 | @end group | |
8283 | @end smallexample | |
8284 | ||
d77de738 ML |
8285 | @opindex Wno-array-bounds |
8286 | @opindex Warray-bounds | |
ddf6fe37 AA |
8287 | @item -Warray-bounds |
8288 | @itemx -Warray-bounds=@var{n} | |
d77de738 ML |
8289 | Warn about out of bounds subscripts or offsets into arrays. This warning |
8290 | is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp} | |
8291 | is active (the default for @option{-O2} and above) but a subset of instances | |
8292 | are issued even without optimization. | |
8293 | ||
710c9676 QZ |
8294 | By default, the trailing array of a structure will be treated as a flexible |
8295 | array member by @option{-Warray-bounds} or @option{-Warray-bounds=@var{n}} | |
8296 | if it is declared as either a flexible array member per C99 standard onwards | |
8297 | (@samp{[]}), a GCC zero-length array extension (@samp{[0]}), or an one-element | |
8298 | array (@samp{[1]}). As a result, out of bounds subscripts or offsets into | |
8299 | zero-length arrays or one-element arrays are not warned by default. | |
8300 | ||
8301 | You can add the option @option{-fstrict-flex-arrays} or | |
8302 | @option{-fstrict-flex-arrays=@var{level}} to control how this | |
8303 | option treat trailing array of a structure as a flexible array member: | |
8304 | ||
8305 | when @var{level}<=1, no change to the default behavior. | |
8306 | ||
8307 | when @var{level}=2, additional warnings will be issued for out of bounds | |
8308 | subscripts or offsets into one-element arrays; | |
8309 | ||
8310 | when @var{level}=3, in addition to @var{level}=2, additional warnings will be | |
8311 | issued for out of bounds subscripts or offsets into zero-length arrays. | |
8312 | ||
d77de738 ML |
8313 | @table @gcctabopt |
8314 | @item -Warray-bounds=1 | |
8315 | This is the default warning level of @option{-Warray-bounds} and is enabled | |
8316 | by @option{-Wall}; higher levels are not, and must be explicitly requested. | |
8317 | ||
8318 | @item -Warray-bounds=2 | |
710c9676 QZ |
8319 | This warning level also warns about the intermediate results of pointer |
8320 | arithmetic that may yield out of bounds values. This warning level may | |
8321 | give a larger number of false positives and is deactivated by default. | |
d77de738 ML |
8322 | @end table |
8323 | ||
d77de738 ML |
8324 | @opindex Warray-compare |
8325 | @opindex Wno-array-compare | |
ddf6fe37 | 8326 | @item -Warray-compare |
d77de738 ML |
8327 | Warn about equality and relational comparisons between two operands of array |
8328 | type. This comparison was deprecated in C++20. For example: | |
8329 | ||
8330 | @smallexample | |
8331 | int arr1[5]; | |
8332 | int arr2[5]; | |
8333 | bool same = arr1 == arr2; | |
8334 | @end smallexample | |
8335 | ||
8336 | @option{-Warray-compare} is enabled by @option{-Wall}. | |
8337 | ||
ddf6fe37 | 8338 | @opindex Wno-array-parameter |
d77de738 ML |
8339 | @item -Warray-parameter |
8340 | @itemx -Warray-parameter=@var{n} | |
d77de738 ML |
8341 | Warn about redeclarations of functions involving arguments of array or |
8342 | pointer types of inconsistent kinds or forms, and enable the detection | |
8343 | of out-of-bounds accesses to such parameters by warnings such as | |
8344 | @option{-Warray-bounds}. | |
8345 | ||
8346 | If the first function declaration uses the array form the bound specified | |
8347 | in the array is assumed to be the minimum number of elements expected to | |
8348 | be provided in calls to the function and the maximum number of elements | |
8349 | accessed by it. Failing to provide arguments of sufficient size or accessing | |
8350 | more than the maximum number of elements may be diagnosed by warnings such | |
8351 | as @option{-Warray-bounds}. At level 1 the warning diagnoses inconsistencies | |
8352 | involving array parameters declared using the @code{T[static N]} form. | |
8353 | ||
8354 | For example, the warning triggers for the following redeclarations because | |
8355 | the first one allows an array of any size to be passed to @code{f} while | |
8356 | the second one with the keyword @code{static} specifies that the array | |
8357 | argument must have at least four elements. | |
8358 | ||
8359 | @smallexample | |
8360 | void f (int[static 4]); | |
8361 | void f (int[]); // warning (inconsistent array form) | |
8362 | ||
8363 | void g (void) | |
8364 | @{ | |
8365 | int *p = (int *)malloc (4); | |
8366 | f (p); // warning (array too small) | |
8367 | @dots{} | |
8368 | @} | |
8369 | @end smallexample | |
8370 | ||
8371 | At level 2 the warning also triggers for redeclarations involving any other | |
8372 | inconsistency in array or pointer argument forms denoting array sizes. | |
8373 | Pointers and arrays of unspecified bound are considered equivalent and do | |
8374 | not trigger a warning. | |
8375 | ||
8376 | @smallexample | |
8377 | void g (int*); | |
8378 | void g (int[]); // no warning | |
8379 | void g (int[8]); // warning (inconsistent array bound) | |
8380 | @end smallexample | |
8381 | ||
8382 | @option{-Warray-parameter=2} is included in @option{-Wall}. The | |
8383 | @option{-Wvla-parameter} option triggers warnings for similar inconsistencies | |
8384 | involving Variable Length Array arguments. | |
8385 | ||
d77de738 ML |
8386 | @opindex Wattribute-alias |
8387 | @opindex Wno-attribute-alias | |
ddf6fe37 AA |
8388 | @item -Wattribute-alias=@var{n} |
8389 | @itemx -Wno-attribute-alias | |
d77de738 ML |
8390 | Warn about declarations using the @code{alias} and similar attributes whose |
8391 | target is incompatible with the type of the alias. | |
8392 | @xref{Function Attributes,,Declaring Attributes of Functions}. | |
8393 | ||
8394 | @table @gcctabopt | |
8395 | @item -Wattribute-alias=1 | |
8396 | The default warning level of the @option{-Wattribute-alias} option diagnoses | |
8397 | incompatibilities between the type of the alias declaration and that of its | |
8398 | target. Such incompatibilities are typically indicative of bugs. | |
8399 | ||
8400 | @item -Wattribute-alias=2 | |
8401 | ||
8402 | At this level @option{-Wattribute-alias} also diagnoses cases where | |
8403 | the attributes of the alias declaration are more restrictive than the | |
8404 | attributes applied to its target. These mismatches can potentially | |
8405 | result in incorrect code generation. In other cases they may be | |
8406 | benign and could be resolved simply by adding the missing attribute to | |
8407 | the target. For comparison, see the @option{-Wmissing-attributes} | |
8408 | option, which controls diagnostics when the alias declaration is less | |
8409 | restrictive than the target, rather than more restrictive. | |
8410 | ||
8411 | Attributes considered include @code{alloc_align}, @code{alloc_size}, | |
8412 | @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc}, | |
8413 | @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure}, | |
8414 | @code{returns_nonnull}, and @code{returns_twice}. | |
8415 | @end table | |
8416 | ||
8417 | @option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}. | |
8418 | This is the default. You can disable these warnings with either | |
8419 | @option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}. | |
8420 | ||
d77de738 ML |
8421 | @opindex Wbidi-chars= |
8422 | @opindex Wbidi-chars | |
8423 | @opindex Wno-bidi-chars | |
ddf6fe37 | 8424 | @item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]} |
d77de738 ML |
8425 | Warn about possibly misleading UTF-8 bidirectional control characters in |
8426 | comments, string literals, character constants, and identifiers. Such | |
8427 | characters can change left-to-right writing direction into right-to-left | |
8428 | (and vice versa), which can cause confusion between the logical order and | |
8429 | visual order. This may be dangerous; for instance, it may seem that a piece | |
8430 | of code is not commented out, whereas it in fact is. | |
8431 | ||
8432 | There are three levels of warning supported by GCC@. The default is | |
8433 | @option{-Wbidi-chars=unpaired}, which warns about improperly terminated | |
8434 | bidi contexts. @option{-Wbidi-chars=none} turns the warning off. | |
8435 | @option{-Wbidi-chars=any} warns about any use of bidirectional control | |
8436 | characters. | |
8437 | ||
8438 | By default, this warning does not warn about UCNs. It is, however, possible | |
8439 | to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or | |
8440 | @option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid, | |
8441 | and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous | |
8442 | @option{-Wbidi-chars=any} was specified. | |
8443 | ||
d77de738 ML |
8444 | @opindex Wno-bool-compare |
8445 | @opindex Wbool-compare | |
ddf6fe37 | 8446 | @item -Wbool-compare |
d77de738 ML |
8447 | Warn about boolean expression compared with an integer value different from |
8448 | @code{true}/@code{false}. For instance, the following comparison is | |
8449 | always false: | |
8450 | @smallexample | |
8451 | int n = 5; | |
8452 | @dots{} | |
8453 | if ((n > 1) == 2) @{ @dots{} @} | |
8454 | @end smallexample | |
8455 | This warning is enabled by @option{-Wall}. | |
8456 | ||
d77de738 ML |
8457 | @opindex Wno-bool-operation |
8458 | @opindex Wbool-operation | |
ddf6fe37 | 8459 | @item -Wbool-operation |
d77de738 ML |
8460 | Warn about suspicious operations on expressions of a boolean type. For |
8461 | instance, bitwise negation of a boolean is very likely a bug in the program. | |
8462 | For C, this warning also warns about incrementing or decrementing a boolean, | |
8463 | which rarely makes sense. (In C++, decrementing a boolean is always invalid. | |
8464 | Incrementing a boolean is invalid in C++17, and deprecated otherwise.) | |
8465 | ||
8466 | This warning is enabled by @option{-Wall}. | |
8467 | ||
d77de738 ML |
8468 | @opindex Wno-duplicated-branches |
8469 | @opindex Wduplicated-branches | |
ddf6fe37 | 8470 | @item -Wduplicated-branches |
d77de738 ML |
8471 | Warn when an if-else has identical branches. This warning detects cases like |
8472 | @smallexample | |
8473 | if (p != NULL) | |
8474 | return 0; | |
8475 | else | |
8476 | return 0; | |
8477 | @end smallexample | |
8478 | It doesn't warn when both branches contain just a null statement. This warning | |
8479 | also warn for conditional operators: | |
8480 | @smallexample | |
8481 | int i = x ? *p : *p; | |
8482 | @end smallexample | |
8483 | ||
d77de738 ML |
8484 | @opindex Wno-duplicated-cond |
8485 | @opindex Wduplicated-cond | |
ddf6fe37 | 8486 | @item -Wduplicated-cond |
d77de738 ML |
8487 | Warn about duplicated conditions in an if-else-if chain. For instance, |
8488 | warn for the following code: | |
8489 | @smallexample | |
8490 | if (p->q != NULL) @{ @dots{} @} | |
8491 | else if (p->q != NULL) @{ @dots{} @} | |
8492 | @end smallexample | |
8493 | ||
d77de738 ML |
8494 | @opindex Wno-frame-address |
8495 | @opindex Wframe-address | |
ddf6fe37 | 8496 | @item -Wframe-address |
d77de738 ML |
8497 | Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address} |
8498 | is called with an argument greater than 0. Such calls may return indeterminate | |
8499 | values or crash the program. The warning is included in @option{-Wall}. | |
8500 | ||
d77de738 ML |
8501 | @opindex Wno-discarded-qualifiers |
8502 | @opindex Wdiscarded-qualifiers | |
ddf6fe37 | 8503 | @item -Wno-discarded-qualifiers @r{(C and Objective-C only)} |
d77de738 ML |
8504 | Do not warn if type qualifiers on pointers are being discarded. |
8505 | Typically, the compiler warns if a @code{const char *} variable is | |
8506 | passed to a function that takes a @code{char *} parameter. This option | |
8507 | can be used to suppress such a warning. | |
8508 | ||
d77de738 ML |
8509 | @opindex Wno-discarded-array-qualifiers |
8510 | @opindex Wdiscarded-array-qualifiers | |
ddf6fe37 | 8511 | @item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)} |
d77de738 ML |
8512 | Do not warn if type qualifiers on arrays which are pointer targets |
8513 | are being discarded. Typically, the compiler warns if a | |
8514 | @code{const int (*)[]} variable is passed to a function that | |
8515 | takes a @code{int (*)[]} parameter. This option can be used to | |
8516 | suppress such a warning. | |
8517 | ||
d77de738 ML |
8518 | @opindex Wno-incompatible-pointer-types |
8519 | @opindex Wincompatible-pointer-types | |
ddf6fe37 | 8520 | @item -Wno-incompatible-pointer-types @r{(C and Objective-C only)} |
d77de738 ML |
8521 | Do not warn when there is a conversion between pointers that have incompatible |
8522 | types. This warning is for cases not covered by @option{-Wno-pointer-sign}, | |
8523 | which warns for pointer argument passing or assignment with different | |
8524 | signedness. | |
8525 | ||
5fccebdb JM |
8526 | This warning is upgraded to an error by @option{-pedantic-errors}. |
8527 | ||
d77de738 ML |
8528 | @opindex Wno-int-conversion |
8529 | @opindex Wint-conversion | |
ddf6fe37 | 8530 | @item -Wno-int-conversion @r{(C and Objective-C only)} |
d77de738 ML |
8531 | Do not warn about incompatible integer to pointer and pointer to integer |
8532 | conversions. This warning is about implicit conversions; for explicit | |
8533 | conversions the warnings @option{-Wno-int-to-pointer-cast} and | |
8534 | @option{-Wno-pointer-to-int-cast} may be used. | |
8535 | ||
5fccebdb JM |
8536 | This warning is upgraded to an error by @option{-pedantic-errors}. |
8537 | ||
d77de738 ML |
8538 | @opindex Wzero-length-bounds |
8539 | @opindex Wzero-length-bounds | |
ddf6fe37 | 8540 | @item -Wzero-length-bounds |
d77de738 ML |
8541 | Warn about accesses to elements of zero-length array members that might |
8542 | overlap other members of the same object. Declaring interior zero-length | |
8e9c65d3 | 8543 | arrays is discouraged because accesses to them are undefined. |
d77de738 ML |
8544 | @xref{Zero Length}. |
8545 | ||
8546 | For example, the first two stores in function @code{bad} are diagnosed | |
8547 | because the array elements overlap the subsequent members @code{b} and | |
8548 | @code{c}. The third store is diagnosed by @option{-Warray-bounds} | |
8549 | because it is beyond the bounds of the enclosing object. | |
8550 | ||
8551 | @smallexample | |
8552 | struct X @{ int a[0]; int b, c; @}; | |
8553 | struct X x; | |
8554 | ||
8555 | void bad (void) | |
8556 | @{ | |
8557 | x.a[0] = 0; // -Wzero-length-bounds | |
8558 | x.a[1] = 1; // -Wzero-length-bounds | |
8559 | x.a[2] = 2; // -Warray-bounds | |
8560 | @} | |
8561 | @end smallexample | |
8562 | ||
8563 | Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}. | |
8564 | ||
d77de738 ML |
8565 | @opindex Wno-div-by-zero |
8566 | @opindex Wdiv-by-zero | |
ddf6fe37 | 8567 | @item -Wno-div-by-zero |
d77de738 ML |
8568 | Do not warn about compile-time integer division by zero. Floating-point |
8569 | division by zero is not warned about, as it can be a legitimate way of | |
8570 | obtaining infinities and NaNs. | |
8571 | ||
d77de738 ML |
8572 | @opindex Wsystem-headers |
8573 | @opindex Wno-system-headers | |
8574 | @cindex warnings from system headers | |
8575 | @cindex system headers, warnings from | |
f33d7a88 | 8576 | @item -Wsystem-headers |
d77de738 ML |
8577 | Print warning messages for constructs found in system header files. |
8578 | Warnings from system headers are normally suppressed, on the assumption | |
8579 | that they usually do not indicate real problems and would only make the | |
8580 | compiler output harder to read. Using this command-line option tells | |
8581 | GCC to emit warnings from system headers as if they occurred in user | |
8582 | code. However, note that using @option{-Wall} in conjunction with this | |
8583 | option does @emph{not} warn about unknown pragmas in system | |
8584 | headers---for that, @option{-Wunknown-pragmas} must also be used. | |
8585 | ||
d77de738 ML |
8586 | @opindex Wtautological-compare |
8587 | @opindex Wno-tautological-compare | |
ddf6fe37 | 8588 | @item -Wtautological-compare |
d77de738 ML |
8589 | Warn if a self-comparison always evaluates to true or false. This |
8590 | warning detects various mistakes such as: | |
8591 | @smallexample | |
8592 | int i = 1; | |
8593 | @dots{} | |
8594 | if (i > i) @{ @dots{} @} | |
8595 | @end smallexample | |
8596 | ||
8597 | This warning also warns about bitwise comparisons that always evaluate | |
8598 | to true or false, for instance: | |
8599 | @smallexample | |
8600 | if ((a & 16) == 10) @{ @dots{} @} | |
8601 | @end smallexample | |
8602 | will always be false. | |
8603 | ||
8604 | This warning is enabled by @option{-Wall}. | |
8605 | ||
d77de738 ML |
8606 | @opindex Wtrampolines |
8607 | @opindex Wno-trampolines | |
ddf6fe37 | 8608 | @item -Wtrampolines |
d77de738 ML |
8609 | Warn about trampolines generated for pointers to nested functions. |
8610 | A trampoline is a small piece of data or code that is created at run | |
8611 | time on the stack when the address of a nested function is taken, and is | |
8612 | used to call the nested function indirectly. For some targets, it is | |
8613 | made up of data only and thus requires no special treatment. But, for | |
8614 | most targets, it is made up of code and thus requires the stack to be | |
8615 | made executable in order for the program to work properly. | |
8616 | ||
d77de738 ML |
8617 | @opindex Wfloat-equal |
8618 | @opindex Wno-float-equal | |
ddf6fe37 | 8619 | @item -Wfloat-equal |
d77de738 ML |
8620 | Warn if floating-point values are used in equality comparisons. |
8621 | ||
8622 | The idea behind this is that sometimes it is convenient (for the | |
8623 | programmer) to consider floating-point values as approximations to | |
8624 | infinitely precise real numbers. If you are doing this, then you need | |
8625 | to compute (by analyzing the code, or in some other way) the maximum or | |
8626 | likely maximum error that the computation introduces, and allow for it | |
8627 | when performing comparisons (and when producing output, but that's a | |
8628 | different problem). In particular, instead of testing for equality, you | |
8629 | should check to see whether the two values have ranges that overlap; and | |
8630 | this is done with the relational operators, so equality comparisons are | |
8631 | probably mistaken. | |
8632 | ||
d77de738 ML |
8633 | @opindex Wtraditional |
8634 | @opindex Wno-traditional | |
ddf6fe37 | 8635 | @item -Wtraditional @r{(C and Objective-C only)} |
d77de738 ML |
8636 | Warn about certain constructs that behave differently in traditional and |
8637 | ISO C@. Also warn about ISO C constructs that have no traditional C | |
8638 | equivalent, and/or problematic constructs that should be avoided. | |
8639 | ||
8640 | @itemize @bullet | |
8641 | @item | |
8642 | Macro parameters that appear within string literals in the macro body. | |
8643 | In traditional C macro replacement takes place within string literals, | |
8644 | but in ISO C it does not. | |
8645 | ||
8646 | @item | |
8647 | In traditional C, some preprocessor directives did not exist. | |
8648 | Traditional preprocessors only considered a line to be a directive | |
8649 | if the @samp{#} appeared in column 1 on the line. Therefore | |
8650 | @option{-Wtraditional} warns about directives that traditional C | |
8651 | understands but ignores because the @samp{#} does not appear as the | |
8652 | first character on the line. It also suggests you hide directives like | |
8653 | @code{#pragma} not understood by traditional C by indenting them. Some | |
8654 | traditional implementations do not recognize @code{#elif}, so this option | |
8655 | suggests avoiding it altogether. | |
8656 | ||
8657 | @item | |
8658 | A function-like macro that appears without arguments. | |
8659 | ||
8660 | @item | |
8661 | The unary plus operator. | |
8662 | ||
8663 | @item | |
8664 | The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point | |
8665 | constant suffixes. (Traditional C does support the @samp{L} suffix on integer | |
8666 | constants.) Note, these suffixes appear in macros defined in the system | |
8667 | headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}. | |
8668 | Use of these macros in user code might normally lead to spurious | |
8669 | warnings, however GCC's integrated preprocessor has enough context to | |
8670 | avoid warning in these cases. | |
8671 | ||
8672 | @item | |
8673 | A function declared external in one block and then used after the end of | |
8674 | the block. | |
8675 | ||
8676 | @item | |
8677 | A @code{switch} statement has an operand of type @code{long}. | |
8678 | ||
8679 | @item | |
8680 | A non-@code{static} function declaration follows a @code{static} one. | |
8681 | This construct is not accepted by some traditional C compilers. | |
8682 | ||
8683 | @item | |
8684 | The ISO type of an integer constant has a different width or | |
8685 | signedness from its traditional type. This warning is only issued if | |
8686 | the base of the constant is ten. I.e.@: hexadecimal or octal values, which | |
8687 | typically represent bit patterns, are not warned about. | |
8688 | ||
8689 | @item | |
8690 | Usage of ISO string concatenation is detected. | |
8691 | ||
8692 | @item | |
8693 | Initialization of automatic aggregates. | |
8694 | ||
8695 | @item | |
8696 | Identifier conflicts with labels. Traditional C lacks a separate | |
8697 | namespace for labels. | |
8698 | ||
8699 | @item | |
8700 | Initialization of unions. If the initializer is zero, the warning is | |
8701 | omitted. This is done under the assumption that the zero initializer in | |
8702 | user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing | |
8703 | initializer warnings and relies on default initialization to zero in the | |
8704 | traditional C case. | |
8705 | ||
8706 | @item | |
8707 | Conversions by prototypes between fixed/floating-point values and vice | |
8708 | versa. The absence of these prototypes when compiling with traditional | |
8709 | C causes serious problems. This is a subset of the possible | |
8710 | conversion warnings; for the full set use @option{-Wtraditional-conversion}. | |
8711 | ||
8712 | @item | |
8713 | Use of ISO C style function definitions. This warning intentionally is | |
8714 | @emph{not} issued for prototype declarations or variadic functions | |
8715 | because these ISO C features appear in your code when using | |
8716 | libiberty's traditional C compatibility macros, @code{PARAMS} and | |
8717 | @code{VPARAMS}. This warning is also bypassed for nested functions | |
8718 | because that feature is already a GCC extension and thus not relevant to | |
8719 | traditional C compatibility. | |
8720 | @end itemize | |
8721 | ||
d77de738 ML |
8722 | @opindex Wtraditional-conversion |
8723 | @opindex Wno-traditional-conversion | |
ddf6fe37 | 8724 | @item -Wtraditional-conversion @r{(C and Objective-C only)} |
d77de738 ML |
8725 | Warn if a prototype causes a type conversion that is different from what |
8726 | would happen to the same argument in the absence of a prototype. This | |
8727 | includes conversions of fixed point to floating and vice versa, and | |
8728 | conversions changing the width or signedness of a fixed-point argument | |
8729 | except when the same as the default promotion. | |
8730 | ||
d77de738 ML |
8731 | @opindex Wdeclaration-after-statement |
8732 | @opindex Wno-declaration-after-statement | |
ddf6fe37 | 8733 | @item -Wdeclaration-after-statement @r{(C and Objective-C only)} |
d77de738 ML |
8734 | Warn when a declaration is found after a statement in a block. This |
8735 | construct, known from C++, was introduced with ISO C99 and is by default | |
8736 | allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}. | |
8737 | ||
5fccebdb JM |
8738 | This warning is upgraded to an error by @option{-pedantic-errors}. |
8739 | ||
d77de738 ML |
8740 | @opindex Wshadow |
8741 | @opindex Wno-shadow | |
ddf6fe37 | 8742 | @item -Wshadow |
d77de738 ML |
8743 | Warn whenever a local variable or type declaration shadows another |
8744 | variable, parameter, type, class member (in C++), or instance variable | |
8745 | (in Objective-C) or whenever a built-in function is shadowed. Note | |
8746 | that in C++, the compiler warns if a local variable shadows an | |
8747 | explicit typedef, but not if it shadows a struct/class/enum. | |
8748 | If this warning is enabled, it includes also all instances of | |
8749 | local shadowing. This means that @option{-Wno-shadow=local} | |
8750 | and @option{-Wno-shadow=compatible-local} are ignored when | |
8751 | @option{-Wshadow} is used. | |
8752 | Same as @option{-Wshadow=global}. | |
8753 | ||
d77de738 ML |
8754 | @opindex Wno-shadow-ivar |
8755 | @opindex Wshadow-ivar | |
ddf6fe37 | 8756 | @item -Wno-shadow-ivar @r{(Objective-C only)} |
d77de738 ML |
8757 | Do not warn whenever a local variable shadows an instance variable in an |
8758 | Objective-C method. | |
8759 | ||
d77de738 | 8760 | @opindex Wshadow=global |
ddf6fe37 | 8761 | @item -Wshadow=global |
d77de738 ML |
8762 | Warn for any shadowing. |
8763 | Same as @option{-Wshadow}. | |
8764 | ||
d77de738 | 8765 | @opindex Wshadow=local |
ddf6fe37 | 8766 | @item -Wshadow=local |
d77de738 ML |
8767 | Warn when a local variable shadows another local variable or parameter. |
8768 | ||
d77de738 | 8769 | @opindex Wshadow=compatible-local |
ddf6fe37 | 8770 | @item -Wshadow=compatible-local |
d77de738 ML |
8771 | Warn when a local variable shadows another local variable or parameter |
8772 | whose type is compatible with that of the shadowing variable. In C++, | |
8773 | type compatibility here means the type of the shadowing variable can be | |
8774 | converted to that of the shadowed variable. The creation of this flag | |
8775 | (in addition to @option{-Wshadow=local}) is based on the idea that when | |
8776 | a local variable shadows another one of incompatible type, it is most | |
8777 | likely intentional, not a bug or typo, as shown in the following example: | |
8778 | ||
8779 | @smallexample | |
8780 | @group | |
8781 | for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i) | |
8782 | @{ | |
8783 | for (int i = 0; i < N; ++i) | |
8784 | @{ | |
8785 | ... | |
8786 | @} | |
8787 | ... | |
8788 | @} | |
8789 | @end group | |
8790 | @end smallexample | |
8791 | ||
8792 | Since the two variable @code{i} in the example above have incompatible types, | |
8793 | enabling only @option{-Wshadow=compatible-local} does not emit a warning. | |
8794 | Because their types are incompatible, if a programmer accidentally uses one | |
8795 | in place of the other, type checking is expected to catch that and emit an | |
8796 | error or warning. Use of this flag instead of @option{-Wshadow=local} can | |
8797 | possibly reduce the number of warnings triggered by intentional shadowing. | |
8798 | Note that this also means that shadowing @code{const char *i} by | |
8799 | @code{char *i} does not emit a warning. | |
8800 | ||
8801 | This warning is also enabled by @option{-Wshadow=local}. | |
8802 | ||
d77de738 ML |
8803 | @opindex Wlarger-than= |
8804 | @opindex Wlarger-than-@var{byte-size} | |
ddf6fe37 | 8805 | @item -Wlarger-than=@var{byte-size} |
d77de738 ML |
8806 | Warn whenever an object is defined whose size exceeds @var{byte-size}. |
8807 | @option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default. | |
8808 | Warnings controlled by the option can be disabled either by specifying | |
8809 | @var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}. | |
8810 | ||
8811 | Also warn for calls to bounded functions such as @code{memchr} or | |
8812 | @code{strnlen} that specify a bound greater than the largest possible | |
8813 | object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings | |
8814 | can only be disabled by @option{-Wno-larger-than}. | |
8815 | ||
d77de738 | 8816 | @opindex Wno-larger-than |
ddf6fe37 | 8817 | @item -Wno-larger-than |
d77de738 ML |
8818 | Disable @option{-Wlarger-than=} warnings. The option is equivalent |
8819 | to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger. | |
8820 | ||
d77de738 ML |
8821 | @opindex Wframe-larger-than= |
8822 | @opindex Wno-frame-larger-than | |
ddf6fe37 | 8823 | @item -Wframe-larger-than=@var{byte-size} |
d77de738 ML |
8824 | Warn if the size of a function frame exceeds @var{byte-size}. |
8825 | The computation done to determine the stack frame size is approximate | |
8826 | and not conservative. | |
8827 | The actual requirements may be somewhat greater than @var{byte-size} | |
8828 | even if you do not get a warning. In addition, any space allocated | |
8829 | via @code{alloca}, variable-length arrays, or related constructs | |
8830 | is not included by the compiler when determining | |
8831 | whether or not to issue a warning. | |
8832 | @option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default. | |
8833 | Warnings controlled by the option can be disabled either by specifying | |
8834 | @var{byte-size} of @samp{SIZE_MAX} or more or by | |
8835 | @option{-Wno-frame-larger-than}. | |
8836 | ||
d77de738 | 8837 | @opindex Wno-frame-larger-than |
ddf6fe37 | 8838 | @item -Wno-frame-larger-than |
d77de738 ML |
8839 | Disable @option{-Wframe-larger-than=} warnings. The option is equivalent |
8840 | to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger. | |
8841 | ||
d77de738 ML |
8842 | @opindex Wfree-nonheap-object |
8843 | @opindex Wno-free-nonheap-object | |
ddf6fe37 | 8844 | @item -Wfree-nonheap-object |
d77de738 ML |
8845 | Warn when attempting to deallocate an object that was either not allocated |
8846 | on the heap, or by using a pointer that was not returned from a prior call | |
8847 | to the corresponding allocation function. For example, because the call | |
8848 | to @code{stpcpy} returns a pointer to the terminating nul character and | |
8849 | not to the beginning of the object, the call to @code{free} below is | |
8850 | diagnosed. | |
8851 | ||
8852 | @smallexample | |
8853 | void f (char *p) | |
8854 | @{ | |
8855 | p = stpcpy (p, "abc"); | |
8856 | // ... | |
8857 | free (p); // warning | |
8858 | @} | |
8859 | @end smallexample | |
8860 | ||
8861 | @option{-Wfree-nonheap-object} is included in @option{-Wall}. | |
8862 | ||
d77de738 ML |
8863 | @opindex Wstack-usage |
8864 | @opindex Wno-stack-usage | |
ddf6fe37 | 8865 | @item -Wstack-usage=@var{byte-size} |
d77de738 ML |
8866 | Warn if the stack usage of a function might exceed @var{byte-size}. |
8867 | The computation done to determine the stack usage is conservative. | |
8868 | Any space allocated via @code{alloca}, variable-length arrays, or related | |
8869 | constructs is included by the compiler when determining whether or not to | |
8870 | issue a warning. | |
8871 | ||
8872 | The message is in keeping with the output of @option{-fstack-usage}. | |
8873 | ||
8874 | @itemize | |
8875 | @item | |
8876 | If the stack usage is fully static but exceeds the specified amount, it's: | |
8877 | ||
8878 | @smallexample | |
8879 | warning: stack usage is 1120 bytes | |
8880 | @end smallexample | |
8881 | @item | |
8882 | If the stack usage is (partly) dynamic but bounded, it's: | |
8883 | ||
8884 | @smallexample | |
8885 | warning: stack usage might be 1648 bytes | |
8886 | @end smallexample | |
8887 | @item | |
8888 | If the stack usage is (partly) dynamic and not bounded, it's: | |
8889 | ||
8890 | @smallexample | |
8891 | warning: stack usage might be unbounded | |
8892 | @end smallexample | |
8893 | @end itemize | |
8894 | ||
8895 | @option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default. | |
8896 | Warnings controlled by the option can be disabled either by specifying | |
8897 | @var{byte-size} of @samp{SIZE_MAX} or more or by | |
8898 | @option{-Wno-stack-usage}. | |
8899 | ||
d77de738 | 8900 | @opindex Wno-stack-usage |
ddf6fe37 | 8901 | @item -Wno-stack-usage |
d77de738 ML |
8902 | Disable @option{-Wstack-usage=} warnings. The option is equivalent |
8903 | to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger. | |
8904 | ||
d77de738 ML |
8905 | @opindex Wunsafe-loop-optimizations |
8906 | @opindex Wno-unsafe-loop-optimizations | |
ddf6fe37 | 8907 | @item -Wunsafe-loop-optimizations |
d77de738 ML |
8908 | Warn if the loop cannot be optimized because the compiler cannot |
8909 | assume anything on the bounds of the loop indices. With | |
8910 | @option{-funsafe-loop-optimizations} warn if the compiler makes | |
8911 | such assumptions. | |
8912 | ||
d77de738 ML |
8913 | @opindex Wno-pedantic-ms-format |
8914 | @opindex Wpedantic-ms-format | |
ddf6fe37 | 8915 | @item -Wno-pedantic-ms-format @r{(MinGW targets only)} |
d77de738 ML |
8916 | When used in combination with @option{-Wformat} |
8917 | and @option{-pedantic} without GNU extensions, this option | |
8918 | disables the warnings about non-ISO @code{printf} / @code{scanf} format | |
8919 | width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets, | |
8920 | which depend on the MS runtime. | |
8921 | ||
d77de738 ML |
8922 | @opindex Wpointer-arith |
8923 | @opindex Wno-pointer-arith | |
ddf6fe37 | 8924 | @item -Wpointer-arith |
d77de738 ML |
8925 | Warn about anything that depends on the ``size of'' a function type or |
8926 | of @code{void}. GNU C assigns these types a size of 1, for | |
8927 | convenience in calculations with @code{void *} pointers and pointers | |
8928 | to functions. In C++, warn also when an arithmetic operation involves | |
8929 | @code{NULL}. This warning is also enabled by @option{-Wpedantic}. | |
8930 | ||
5fccebdb JM |
8931 | This warning is upgraded to an error by @option{-pedantic-errors}. |
8932 | ||
d77de738 ML |
8933 | @opindex Wpointer-compare |
8934 | @opindex Wno-pointer-compare | |
ddf6fe37 | 8935 | @item -Wno-pointer-compare |
d77de738 ML |
8936 | Do not warn if a pointer is compared with a zero character constant. |
8937 | This usually | |
8938 | means that the pointer was meant to be dereferenced. For example: | |
8939 | ||
8940 | @smallexample | |
8941 | const char *p = foo (); | |
8942 | if (p == '\0') | |
8943 | return 42; | |
8944 | @end smallexample | |
8945 | ||
8946 | Note that the code above is invalid in C++11. | |
8947 | ||
8948 | This warning is enabled by default. | |
8949 | ||
d77de738 ML |
8950 | @opindex Wtsan |
8951 | @opindex Wno-tsan | |
ddf6fe37 | 8952 | @item -Wtsan |
d77de738 ML |
8953 | Warn about unsupported features in ThreadSanitizer. |
8954 | ||
8955 | ThreadSanitizer does not support @code{std::atomic_thread_fence} and | |
8956 | can report false positives. | |
8957 | ||
8958 | This warning is enabled by default. | |
8959 | ||
d77de738 ML |
8960 | @opindex Wtype-limits |
8961 | @opindex Wno-type-limits | |
ddf6fe37 | 8962 | @item -Wtype-limits |
d77de738 ML |
8963 | Warn if a comparison is always true or always false due to the limited |
8964 | range of the data type, but do not warn for constant expressions. For | |
8965 | example, warn if an unsigned variable is compared against zero with | |
8966 | @code{<} or @code{>=}. This warning is also enabled by | |
8967 | @option{-Wextra}. | |
8968 | ||
d77de738 ML |
8969 | @opindex Wabsolute-value |
8970 | @opindex Wno-absolute-value | |
ddf6fe37 | 8971 | @item -Wabsolute-value @r{(C and Objective-C only)} |
d77de738 ML |
8972 | Warn for calls to standard functions that compute the absolute value |
8973 | of an argument when a more appropriate standard function is available. | |
8974 | For example, calling @code{abs(3.14)} triggers the warning because the | |
8975 | appropriate function to call to compute the absolute value of a double | |
8976 | argument is @code{fabs}. The option also triggers warnings when the | |
8977 | argument in a call to such a function has an unsigned type. This | |
8978 | warning can be suppressed with an explicit type cast and it is also | |
8979 | enabled by @option{-Wextra}. | |
8980 | ||
8981 | @include cppwarnopts.texi | |
8982 | ||
d77de738 ML |
8983 | @opindex Wbad-function-cast |
8984 | @opindex Wno-bad-function-cast | |
ddf6fe37 | 8985 | @item -Wbad-function-cast @r{(C and Objective-C only)} |
d77de738 ML |
8986 | Warn when a function call is cast to a non-matching type. |
8987 | For example, warn if a call to a function returning an integer type | |
8988 | is cast to a pointer type. | |
8989 | ||
d77de738 ML |
8990 | @opindex Wc90-c99-compat |
8991 | @opindex Wno-c90-c99-compat | |
ddf6fe37 | 8992 | @item -Wc90-c99-compat @r{(C and Objective-C only)} |
d77de738 ML |
8993 | Warn about features not present in ISO C90, but present in ISO C99. |
8994 | For instance, warn about use of variable length arrays, @code{long long} | |
8995 | type, @code{bool} type, compound literals, designated initializers, and so | |
8996 | on. This option is independent of the standards mode. Warnings are disabled | |
8997 | in the expression that follows @code{__extension__}. | |
8998 | ||
d77de738 ML |
8999 | @opindex Wc99-c11-compat |
9000 | @opindex Wno-c99-c11-compat | |
ddf6fe37 | 9001 | @item -Wc99-c11-compat @r{(C and Objective-C only)} |
d77de738 ML |
9002 | Warn about features not present in ISO C99, but present in ISO C11. |
9003 | For instance, warn about use of anonymous structures and unions, | |
9004 | @code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier, | |
9005 | @code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword, | |
9006 | and so on. This option is independent of the standards mode. Warnings are | |
9007 | disabled in the expression that follows @code{__extension__}. | |
9008 | ||
fad61bf7 JM |
9009 | @opindex Wc11-c23-compat |
9010 | @opindex Wno-c11-c23-compat | |
9011 | @item -Wc11-c23-compat @r{(C and Objective-C only)} | |
9012 | @itemx -Wc11-c2x-compat @r{(C and Objective-C only)} | |
9013 | Warn about features not present in ISO C11, but present in ISO C23. | |
d77de738 ML |
9014 | For instance, warn about omitting the string in @code{_Static_assert}, |
9015 | use of @samp{[[]]} syntax for attributes, use of decimal | |
9016 | floating-point types, and so on. This option is independent of the | |
9017 | standards mode. Warnings are disabled in the expression that follows | |
fad61bf7 JM |
9018 | @code{__extension__}. The name @option{-Wc11-c2x-compat} is |
9019 | deprecated. | |
d77de738 | 9020 | |
fad61bf7 | 9021 | When not compiling in C23 mode, these warnings are upgraded to errors |
5fccebdb JM |
9022 | by @option{-pedantic-errors}. |
9023 | ||
d77de738 ML |
9024 | @opindex Wc++-compat |
9025 | @opindex Wno-c++-compat | |
ddf6fe37 | 9026 | @item -Wc++-compat @r{(C and Objective-C only)} |
d77de738 ML |
9027 | Warn about ISO C constructs that are outside of the common subset of |
9028 | ISO C and ISO C++, e.g.@: request for implicit conversion from | |
9029 | @code{void *} to a pointer to non-@code{void} type. | |
9030 | ||
d77de738 ML |
9031 | @opindex Wc++11-compat |
9032 | @opindex Wno-c++11-compat | |
ddf6fe37 | 9033 | @item -Wc++11-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9034 | Warn about C++ constructs whose meaning differs between ISO C++ 1998 |
9035 | and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords | |
9036 | in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is | |
9037 | enabled by @option{-Wall}. | |
9038 | ||
d77de738 ML |
9039 | @opindex Wc++14-compat |
9040 | @opindex Wno-c++14-compat | |
ddf6fe37 | 9041 | @item -Wc++14-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9042 | Warn about C++ constructs whose meaning differs between ISO C++ 2011 |
9043 | and ISO C++ 2014. This warning is enabled by @option{-Wall}. | |
9044 | ||
d77de738 ML |
9045 | @opindex Wc++17-compat |
9046 | @opindex Wno-c++17-compat | |
ddf6fe37 | 9047 | @item -Wc++17-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9048 | Warn about C++ constructs whose meaning differs between ISO C++ 2014 |
9049 | and ISO C++ 2017. This warning is enabled by @option{-Wall}. | |
9050 | ||
d77de738 ML |
9051 | @opindex Wc++20-compat |
9052 | @opindex Wno-c++20-compat | |
ddf6fe37 | 9053 | @item -Wc++20-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9054 | Warn about C++ constructs whose meaning differs between ISO C++ 2017 |
9055 | and ISO C++ 2020. This warning is enabled by @option{-Wall}. | |
9056 | ||
d77de738 ML |
9057 | @opindex Wc++11-extensions |
9058 | @opindex Wno-c++11-extensions | |
ddf6fe37 | 9059 | @item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9060 | Do not warn about C++11 constructs in code being compiled using |
9061 | an older C++ standard. Even without this option, some C++11 constructs | |
9062 | will only be diagnosed if @option{-Wpedantic} is used. | |
9063 | ||
d77de738 ML |
9064 | @opindex Wc++14-extensions |
9065 | @opindex Wno-c++14-extensions | |
ddf6fe37 | 9066 | @item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9067 | Do not warn about C++14 constructs in code being compiled using |
9068 | an older C++ standard. Even without this option, some C++14 constructs | |
9069 | will only be diagnosed if @option{-Wpedantic} is used. | |
9070 | ||
d77de738 ML |
9071 | @opindex Wc++17-extensions |
9072 | @opindex Wno-c++17-extensions | |
ddf6fe37 | 9073 | @item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9074 | Do not warn about C++17 constructs in code being compiled using |
9075 | an older C++ standard. Even without this option, some C++17 constructs | |
9076 | will only be diagnosed if @option{-Wpedantic} is used. | |
9077 | ||
d77de738 ML |
9078 | @opindex Wc++20-extensions |
9079 | @opindex Wno-c++20-extensions | |
ddf6fe37 | 9080 | @item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9081 | Do not warn about C++20 constructs in code being compiled using |
9082 | an older C++ standard. Even without this option, some C++20 constructs | |
9083 | will only be diagnosed if @option{-Wpedantic} is used. | |
9084 | ||
d77de738 ML |
9085 | @opindex Wc++23-extensions |
9086 | @opindex Wno-c++23-extensions | |
ddf6fe37 | 9087 | @item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
9088 | Do not warn about C++23 constructs in code being compiled using |
9089 | an older C++ standard. Even without this option, some C++23 constructs | |
9090 | will only be diagnosed if @option{-Wpedantic} is used. | |
9091 | ||
d77de738 ML |
9092 | @opindex Wcast-qual |
9093 | @opindex Wno-cast-qual | |
ddf6fe37 | 9094 | @item -Wcast-qual |
d77de738 ML |
9095 | Warn whenever a pointer is cast so as to remove a type qualifier from |
9096 | the target type. For example, warn if a @code{const char *} is cast | |
9097 | to an ordinary @code{char *}. | |
9098 | ||
9099 | Also warn when making a cast that introduces a type qualifier in an | |
9100 | unsafe way. For example, casting @code{char **} to @code{const char **} | |
9101 | is unsafe, as in this example: | |
9102 | ||
9103 | @smallexample | |
9104 | /* p is char ** value. */ | |
9105 | const char **q = (const char **) p; | |
9106 | /* Assignment of readonly string to const char * is OK. */ | |
9107 | *q = "string"; | |
9108 | /* Now char** pointer points to read-only memory. */ | |
9109 | **p = 'b'; | |
9110 | @end smallexample | |
9111 | ||
d77de738 ML |
9112 | @opindex Wcast-align |
9113 | @opindex Wno-cast-align | |
ddf6fe37 | 9114 | @item -Wcast-align |
d77de738 ML |
9115 | Warn whenever a pointer is cast such that the required alignment of the |
9116 | target is increased. For example, warn if a @code{char *} is cast to | |
9117 | an @code{int *} on machines where integers can only be accessed at | |
9118 | two- or four-byte boundaries. | |
9119 | ||
d77de738 | 9120 | @opindex Wcast-align=strict |
ddf6fe37 | 9121 | @item -Wcast-align=strict |
d77de738 ML |
9122 | Warn whenever a pointer is cast such that the required alignment of the |
9123 | target is increased. For example, warn if a @code{char *} is cast to | |
9124 | an @code{int *} regardless of the target machine. | |
9125 | ||
d77de738 ML |
9126 | @opindex Wcast-function-type |
9127 | @opindex Wno-cast-function-type | |
ddf6fe37 | 9128 | @item -Wcast-function-type |
d77de738 ML |
9129 | Warn when a function pointer is cast to an incompatible function pointer. |
9130 | In a cast involving function types with a variable argument list only | |
9131 | the types of initial arguments that are provided are considered. | |
9132 | Any parameter of pointer-type matches any other pointer-type. Any benign | |
9133 | differences in integral types are ignored, like @code{int} vs.@: @code{long} | |
9134 | on ILP32 targets. Likewise type qualifiers are ignored. The function | |
9135 | type @code{void (*) (void)} is special and matches everything, which can | |
9136 | be used to suppress this warning. | |
9137 | In a cast involving pointer to member types this warning warns whenever | |
9138 | the type cast is changing the pointer to member type. | |
9139 | This warning is enabled by @option{-Wextra}. | |
9140 | ||
d77de738 ML |
9141 | @opindex Wwrite-strings |
9142 | @opindex Wno-write-strings | |
ddf6fe37 | 9143 | @item -Wwrite-strings |
d77de738 ML |
9144 | When compiling C, give string constants the type @code{const |
9145 | char[@var{length}]} so that copying the address of one into a | |
9146 | non-@code{const} @code{char *} pointer produces a warning. These | |
9147 | warnings help you find at compile time code that can try to write | |
9148 | into a string constant, but only if you have been very careful about | |
9149 | using @code{const} in declarations and prototypes. Otherwise, it is | |
9150 | just a nuisance. This is why we did not make @option{-Wall} request | |
9151 | these warnings. | |
9152 | ||
9153 | When compiling C++, warn about the deprecated conversion from string | |
9154 | literals to @code{char *}. This warning is enabled by default for C++ | |
9155 | programs. | |
9156 | ||
5fccebdb JM |
9157 | This warning is upgraded to an error by @option{-pedantic-errors} in |
9158 | C++11 mode or later. | |
9159 | ||
d77de738 ML |
9160 | @opindex Wclobbered |
9161 | @opindex Wno-clobbered | |
f33d7a88 | 9162 | @item -Wclobbered |
d77de738 ML |
9163 | Warn for variables that might be changed by @code{longjmp} or |
9164 | @code{vfork}. This warning is also enabled by @option{-Wextra}. | |
9165 | ||
320dc51c TS |
9166 | @opindex Wcomplain-wrong-lang |
9167 | @opindex Wno-complain-wrong-lang | |
f33d7a88 | 9168 | @item -Wno-complain-wrong-lang |
320dc51c TS |
9169 | By default, language front ends complain when a command-line option is |
9170 | valid, but not applicable to that front end. | |
9171 | This may be disabled with @option{-Wno-complain-wrong-lang}, | |
9172 | which is mostly useful when invoking a single compiler driver for | |
9173 | multiple source files written in different languages, for example: | |
9174 | ||
9175 | @smallexample | |
9176 | $ g++ -fno-rtti a.cc b.f90 | |
9177 | @end smallexample | |
9178 | ||
9179 | The driver @file{g++} invokes the C++ front end to compile @file{a.cc} | |
9180 | and the Fortran front end to compile @file{b.f90}. | |
9181 | The latter front end diagnoses | |
9182 | @samp{f951: Warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for Fortran}, | |
9183 | which may be disabled with @option{-Wno-complain-wrong-lang}. | |
9184 | ||
e1f45bea JM |
9185 | @opindex Wcompare-distinct-pointer-types |
9186 | @item -Wcompare-distinct-pointer-types @r{(C and Objective-C only)} | |
9187 | Warn if pointers of distinct types are compared without a cast. This | |
9188 | warning is enabled by default. | |
9189 | ||
d77de738 ML |
9190 | @opindex Wconversion |
9191 | @opindex Wno-conversion | |
f33d7a88 | 9192 | @item -Wconversion |
d77de738 ML |
9193 | Warn for implicit conversions that may alter a value. This includes |
9194 | conversions between real and integer, like @code{abs (x)} when | |
9195 | @code{x} is @code{double}; conversions between signed and unsigned, | |
9196 | like @code{unsigned ui = -1}; and conversions to smaller types, like | |
9197 | @code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs | |
9198 | ((int) x)} and @code{ui = (unsigned) -1}, or if the value is not | |
9199 | changed by the conversion like in @code{abs (2.0)}. Warnings about | |
9200 | conversions between signed and unsigned integers can be disabled by | |
9201 | using @option{-Wno-sign-conversion}. | |
9202 | ||
9203 | For C++, also warn for confusing overload resolution for user-defined | |
9204 | conversions; and conversions that never use a type conversion | |
9205 | operator: conversions to @code{void}, the same type, a base class or a | |
9206 | reference to them. Warnings about conversions between signed and | |
9207 | unsigned integers are disabled by default in C++ unless | |
9208 | @option{-Wsign-conversion} is explicitly enabled. | |
9209 | ||
9210 | Warnings about conversion from arithmetic on a small type back to that | |
9211 | type are only given with @option{-Warith-conversion}. | |
9212 | ||
d77de738 ML |
9213 | @opindex Wdangling-else |
9214 | @opindex Wno-dangling-else | |
ddf6fe37 | 9215 | @item -Wdangling-else |
d77de738 ML |
9216 | Warn about constructions where there may be confusion to which |
9217 | @code{if} statement an @code{else} branch belongs. Here is an example of | |
9218 | such a case: | |
9219 | ||
9220 | @smallexample | |
9221 | @group | |
9222 | @{ | |
9223 | if (a) | |
9224 | if (b) | |
9225 | foo (); | |
9226 | else | |
9227 | bar (); | |
9228 | @} | |
9229 | @end group | |
9230 | @end smallexample | |
9231 | ||
9232 | In C/C++, every @code{else} branch belongs to the innermost possible | |
9233 | @code{if} statement, which in this example is @code{if (b)}. This is | |
9234 | often not what the programmer expected, as illustrated in the above | |
9235 | example by indentation the programmer chose. When there is the | |
9236 | potential for this confusion, GCC issues a warning when this flag | |
9237 | is specified. To eliminate the warning, add explicit braces around | |
9238 | the innermost @code{if} statement so there is no way the @code{else} | |
9239 | can belong to the enclosing @code{if}. The resulting code | |
9240 | looks like this: | |
9241 | ||
9242 | @smallexample | |
9243 | @group | |
9244 | @{ | |
9245 | if (a) | |
9246 | @{ | |
9247 | if (b) | |
9248 | foo (); | |
9249 | else | |
9250 | bar (); | |
9251 | @} | |
9252 | @} | |
9253 | @end group | |
9254 | @end smallexample | |
9255 | ||
9256 | This warning is enabled by @option{-Wparentheses}. | |
9257 | ||
d77de738 ML |
9258 | @opindex Wdangling-pointer |
9259 | @opindex Wno-dangling-pointer | |
ddf6fe37 AA |
9260 | @item -Wdangling-pointer |
9261 | @itemx -Wdangling-pointer=@var{n} | |
d77de738 ML |
9262 | Warn about uses of pointers (or C++ references) to objects with automatic |
9263 | storage duration after their lifetime has ended. This includes local | |
9264 | variables declared in nested blocks, compound literals and other unnamed | |
9265 | temporary objects. In addition, warn about storing the address of such | |
9266 | objects in escaped pointers. The warning is enabled at all optimization | |
9267 | levels but may yield different results with optimization than without. | |
9268 | ||
9269 | @table @gcctabopt | |
9270 | @item -Wdangling-pointer=1 | |
9271 | At level 1 the warning diagnoses only unconditional uses of dangling pointers. | |
9272 | For example | |
9273 | @smallexample | |
9274 | int f (int c1, int c2, x) | |
9275 | @{ | |
9276 | char *p = strchr ((char[])@{ c1, c2 @}, c3); | |
4ace81b6 SL |
9277 | // warning: dangling pointer to a compound literal |
9278 | return p ? *p : 'x'; | |
d77de738 ML |
9279 | @} |
9280 | @end smallexample | |
9281 | In the following function the store of the address of the local variable | |
9282 | @code{x} in the escaped pointer @code{*p} also triggers the warning. | |
9283 | @smallexample | |
9284 | void g (int **p) | |
9285 | @{ | |
9286 | int x = 7; | |
4ace81b6 SL |
9287 | // warning: storing the address of a local variable in *p |
9288 | *p = &x; | |
d77de738 ML |
9289 | @} |
9290 | @end smallexample | |
9291 | ||
9292 | @item -Wdangling-pointer=2 | |
9293 | At level 2, in addition to unconditional uses the warning also diagnoses | |
9294 | conditional uses of dangling pointers. | |
9295 | ||
9296 | For example, because the array @var{a} in the following function is out of | |
9297 | scope when the pointer @var{s} that was set to point is used, the warning | |
9298 | triggers at this level. | |
9299 | ||
9300 | @smallexample | |
9301 | void f (char *s) | |
9302 | @{ | |
9303 | if (!s) | |
9304 | @{ | |
9305 | char a[12] = "tmpname"; | |
9306 | s = a; | |
9307 | @} | |
4ace81b6 SL |
9308 | // warning: dangling pointer to a may be used |
9309 | strcat (s, ".tmp"); | |
d77de738 ML |
9310 | ... |
9311 | @} | |
9312 | @end smallexample | |
9313 | @end table | |
9314 | ||
9315 | @option{-Wdangling-pointer=2} is included in @option{-Wall}. | |
9316 | ||
d77de738 ML |
9317 | @opindex Wdate-time |
9318 | @opindex Wno-date-time | |
ddf6fe37 | 9319 | @item -Wdate-time |
d77de738 ML |
9320 | Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__} |
9321 | are encountered as they might prevent bit-wise-identical reproducible | |
9322 | compilations. | |
9323 | ||
d77de738 ML |
9324 | @opindex Wempty-body |
9325 | @opindex Wno-empty-body | |
ddf6fe37 | 9326 | @item -Wempty-body |
d77de738 ML |
9327 | Warn if an empty body occurs in an @code{if}, @code{else} or @code{do |
9328 | while} statement. This warning is also enabled by @option{-Wextra}. | |
9329 | ||
d77de738 ML |
9330 | @opindex Wendif-labels |
9331 | @opindex Wno-endif-labels | |
ddf6fe37 | 9332 | @item -Wno-endif-labels |
d77de738 ML |
9333 | Do not warn about stray tokens after @code{#else} and @code{#endif}. |
9334 | ||
d77de738 ML |
9335 | @opindex Wenum-compare |
9336 | @opindex Wno-enum-compare | |
ddf6fe37 | 9337 | @item -Wenum-compare |
d77de738 ML |
9338 | Warn about a comparison between values of different enumerated types. |
9339 | In C++ enumerated type mismatches in conditional expressions are also | |
9340 | diagnosed and the warning is enabled by default. In C this warning is | |
9341 | enabled by @option{-Wall}. | |
9342 | ||
d77de738 ML |
9343 | @opindex Wenum-conversion |
9344 | @opindex Wno-enum-conversion | |
ddf6fe37 | 9345 | @item -Wenum-conversion |
d77de738 ML |
9346 | Warn when a value of enumerated type is implicitly converted to a |
9347 | different enumerated type. This warning is enabled by @option{-Wextra} | |
9348 | in C@. | |
9349 | ||
d77de738 ML |
9350 | @opindex Wenum-int-mismatch |
9351 | @opindex Wno-enum-int-mismatch | |
ddf6fe37 | 9352 | @item -Wenum-int-mismatch @r{(C and Objective-C only)} |
d77de738 ML |
9353 | Warn about mismatches between an enumerated type and an integer type in |
9354 | declarations. For example: | |
9355 | ||
9356 | @smallexample | |
9357 | enum E @{ l = -1, z = 0, g = 1 @}; | |
9358 | int foo(void); | |
9359 | enum E foo(void); | |
9360 | @end smallexample | |
9361 | ||
9362 | In C, an enumerated type is compatible with @code{char}, a signed | |
9363 | integer type, or an unsigned integer type. However, since the choice | |
9364 | of the underlying type of an enumerated type is implementation-defined, | |
9365 | such mismatches may cause portability issues. In C++, such mismatches | |
9366 | are an error. In C, this warning is enabled by @option{-Wall} and | |
9367 | @option{-Wc++-compat}. | |
9368 | ||
d77de738 ML |
9369 | @opindex Wjump-misses-init |
9370 | @opindex Wno-jump-misses-init | |
ddf6fe37 | 9371 | @item -Wjump-misses-init @r{(C, Objective-C only)} |
d77de738 ML |
9372 | Warn if a @code{goto} statement or a @code{switch} statement jumps |
9373 | forward across the initialization of a variable, or jumps backward to a | |
9374 | label after the variable has been initialized. This only warns about | |
9375 | variables that are initialized when they are declared. This warning is | |
9376 | only supported for C and Objective-C; in C++ this sort of branch is an | |
9377 | error in any case. | |
9378 | ||
9379 | @option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It | |
9380 | can be disabled with the @option{-Wno-jump-misses-init} option. | |
9381 | ||
d77de738 ML |
9382 | @opindex Wsign-compare |
9383 | @opindex Wno-sign-compare | |
9384 | @cindex warning for comparison of signed and unsigned values | |
9385 | @cindex comparison of signed and unsigned values, warning | |
9386 | @cindex signed and unsigned values, comparison warning | |
f33d7a88 | 9387 | @item -Wsign-compare |
d77de738 ML |
9388 | Warn when a comparison between signed and unsigned values could produce |
9389 | an incorrect result when the signed value is converted to unsigned. | |
9390 | In C++, this warning is also enabled by @option{-Wall}. In C, it is | |
9391 | also enabled by @option{-Wextra}. | |
9392 | ||
d77de738 ML |
9393 | @opindex Wsign-conversion |
9394 | @opindex Wno-sign-conversion | |
ddf6fe37 | 9395 | @item -Wsign-conversion |
d77de738 ML |
9396 | Warn for implicit conversions that may change the sign of an integer |
9397 | value, like assigning a signed integer expression to an unsigned | |
9398 | integer variable. An explicit cast silences the warning. In C, this | |
9399 | option is enabled also by @option{-Wconversion}. | |
9400 | ||
44e3f39a QZ |
9401 | @opindex Wflex-array-member-not-at-end |
9402 | @opindex Wno-flex-array-member-not-at-end | |
9403 | @item -Wflex-array-member-not-at-end @r{(C and C++ only)} | |
9404 | Warn when a structure containing a C99 flexible array member as the last | |
9405 | field is not at the end of another structure. | |
9406 | This warning warns e.g. about | |
9407 | ||
9408 | @smallexample | |
9409 | struct flex @{ int length; char data[]; @}; | |
9410 | struct mid_flex @{ int m; struct flex flex_data; int n; @}; | |
9411 | @end smallexample | |
9412 | ||
d77de738 ML |
9413 | @opindex Wfloat-conversion |
9414 | @opindex Wno-float-conversion | |
ddf6fe37 | 9415 | @item -Wfloat-conversion |
d77de738 ML |
9416 | Warn for implicit conversions that reduce the precision of a real value. |
9417 | This includes conversions from real to integer, and from higher precision | |
9418 | real to lower precision real values. This option is also enabled by | |
9419 | @option{-Wconversion}. | |
9420 | ||
d77de738 ML |
9421 | @opindex Wno-scalar-storage-order |
9422 | @opindex Wscalar-storage-order | |
ddf6fe37 | 9423 | @item -Wno-scalar-storage-order |
d77de738 ML |
9424 | Do not warn on suspicious constructs involving reverse scalar storage order. |
9425 | ||
d77de738 ML |
9426 | @opindex Wsizeof-array-div |
9427 | @opindex Wno-sizeof-array-div | |
ddf6fe37 | 9428 | @item -Wsizeof-array-div |
d77de738 ML |
9429 | Warn about divisions of two sizeof operators when the first one is applied |
9430 | to an array and the divisor does not equal the size of the array element. | |
9431 | In such a case, the computation will not yield the number of elements in the | |
9432 | array, which is likely what the user intended. This warning warns e.g. about | |
9433 | @smallexample | |
9434 | int fn () | |
9435 | @{ | |
9436 | int arr[10]; | |
9437 | return sizeof (arr) / sizeof (short); | |
9438 | @} | |
9439 | @end smallexample | |
9440 | ||
9441 | This warning is enabled by @option{-Wall}. | |
9442 | ||
d77de738 ML |
9443 | @opindex Wsizeof-pointer-div |
9444 | @opindex Wno-sizeof-pointer-div | |
ddf6fe37 | 9445 | @item -Wsizeof-pointer-div |
d77de738 ML |
9446 | Warn for suspicious divisions of two sizeof expressions that divide |
9447 | the pointer size by the element size, which is the usual way to compute | |
9448 | the array size but won't work out correctly with pointers. This warning | |
9449 | warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is | |
9450 | not an array, but a pointer. This warning is enabled by @option{-Wall}. | |
9451 | ||
d77de738 ML |
9452 | @opindex Wsizeof-pointer-memaccess |
9453 | @opindex Wno-sizeof-pointer-memaccess | |
ddf6fe37 | 9454 | @item -Wsizeof-pointer-memaccess |
d77de738 ML |
9455 | Warn for suspicious length parameters to certain string and memory built-in |
9456 | functions if the argument uses @code{sizeof}. This warning triggers for | |
9457 | example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not | |
9458 | an array, but a pointer, and suggests a possible fix, or about | |
9459 | @code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess} | |
9460 | also warns about calls to bounded string copy functions like @code{strncat} | |
9461 | or @code{strncpy} that specify as the bound a @code{sizeof} expression of | |
9462 | the source array. For example, in the following function the call to | |
9463 | @code{strncat} specifies the size of the source string as the bound. That | |
9464 | is almost certainly a mistake and so the call is diagnosed. | |
9465 | @smallexample | |
9466 | void make_file (const char *name) | |
9467 | @{ | |
9468 | char path[PATH_MAX]; | |
9469 | strncpy (path, name, sizeof path - 1); | |
9470 | strncat (path, ".text", sizeof ".text"); | |
9471 | @dots{} | |
9472 | @} | |
9473 | @end smallexample | |
9474 | ||
9475 | The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}. | |
9476 | ||
d77de738 ML |
9477 | @opindex Wsizeof-array-argument |
9478 | @opindex Wno-sizeof-array-argument | |
ddf6fe37 | 9479 | @item -Wno-sizeof-array-argument |
d77de738 ML |
9480 | Do not warn when the @code{sizeof} operator is applied to a parameter that is |
9481 | declared as an array in a function definition. This warning is enabled by | |
9482 | default for C and C++ programs. | |
9483 | ||
d77de738 ML |
9484 | @opindex Wmemset-elt-size |
9485 | @opindex Wno-memset-elt-size | |
ddf6fe37 | 9486 | @item -Wmemset-elt-size |
d77de738 ML |
9487 | Warn for suspicious calls to the @code{memset} built-in function, if the |
9488 | first argument references an array, and the third argument is a number | |
9489 | equal to the number of elements, but not equal to the size of the array | |
9490 | in memory. This indicates that the user has omitted a multiplication by | |
9491 | the element size. This warning is enabled by @option{-Wall}. | |
9492 | ||
d77de738 ML |
9493 | @opindex Wmemset-transposed-args |
9494 | @opindex Wno-memset-transposed-args | |
ddf6fe37 | 9495 | @item -Wmemset-transposed-args |
d77de738 ML |
9496 | Warn for suspicious calls to the @code{memset} built-in function where |
9497 | the second argument is not zero and the third argument is zero. For | |
9498 | example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because | |
9499 | @code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic | |
9500 | is only emitted if the third argument is a literal zero. Otherwise, if | |
9501 | it is an expression that is folded to zero, or a cast of zero to some | |
9502 | type, it is far less likely that the arguments have been mistakenly | |
9503 | transposed and no warning is emitted. This warning is enabled | |
9504 | by @option{-Wall}. | |
9505 | ||
d77de738 ML |
9506 | @opindex Waddress |
9507 | @opindex Wno-address | |
ddf6fe37 | 9508 | @item -Waddress |
d77de738 ML |
9509 | Warn about suspicious uses of address expressions. These include comparing |
9510 | the address of a function or a declared object to the null pointer constant | |
9511 | such as in | |
9512 | @smallexample | |
9513 | void f (void); | |
9514 | void g (void) | |
9515 | @{ | |
9516 | if (!f) // warning: expression evaluates to false | |
9517 | abort (); | |
9518 | @} | |
9519 | @end smallexample | |
9520 | comparisons of a pointer to a string literal, such as in | |
9521 | @smallexample | |
9522 | void f (const char *x) | |
9523 | @{ | |
9524 | if (x == "abc") // warning: expression evaluates to false | |
9525 | puts ("equal"); | |
9526 | @} | |
9527 | @end smallexample | |
9528 | and tests of the results of pointer addition or subtraction for equality | |
9529 | to null, such as in | |
9530 | @smallexample | |
9531 | void f (const int *p, int i) | |
9532 | @{ | |
9533 | return p + i == NULL; | |
9534 | @} | |
9535 | @end smallexample | |
9536 | Such uses typically indicate a programmer error: the address of most | |
9537 | functions and objects necessarily evaluates to true (the exception are | |
9538 | weak symbols), so their use in a conditional might indicate missing | |
9539 | parentheses in a function call or a missing dereference in an array | |
9540 | expression. The subset of the warning for object pointers can be | |
9541 | suppressed by casting the pointer operand to an integer type such | |
9542 | as @code{intptr_t} or @code{uintptr_t}. | |
9543 | Comparisons against string literals result in unspecified behavior | |
9544 | and are not portable, and suggest the intent was to call @code{strcmp}. | |
9545 | The warning is suppressed if the suspicious expression is the result | |
9546 | of macro expansion. | |
9547 | @option{-Waddress} warning is enabled by @option{-Wall}. | |
9548 | ||
d77de738 ML |
9549 | @opindex Waddress-of-packed-member |
9550 | @opindex Wno-address-of-packed-member | |
ddf6fe37 | 9551 | @item -Wno-address-of-packed-member |
d77de738 ML |
9552 | Do not warn when the address of packed member of struct or union is taken, |
9553 | which usually results in an unaligned pointer value. This is | |
9554 | enabled by default. | |
9555 | ||
d77de738 ML |
9556 | @opindex Wlogical-op |
9557 | @opindex Wno-logical-op | |
ddf6fe37 | 9558 | @item -Wlogical-op |
d77de738 ML |
9559 | Warn about suspicious uses of logical operators in expressions. |
9560 | This includes using logical operators in contexts where a | |
9561 | bit-wise operator is likely to be expected. Also warns when | |
9562 | the operands of a logical operator are the same: | |
9563 | @smallexample | |
9564 | extern int a; | |
9565 | if (a < 0 && a < 0) @{ @dots{} @} | |
9566 | @end smallexample | |
9567 | ||
d77de738 ML |
9568 | @opindex Wlogical-not-parentheses |
9569 | @opindex Wno-logical-not-parentheses | |
ddf6fe37 | 9570 | @item -Wlogical-not-parentheses |
d77de738 ML |
9571 | Warn about logical not used on the left hand side operand of a comparison. |
9572 | This option does not warn if the right operand is considered to be a boolean | |
9573 | expression. Its purpose is to detect suspicious code like the following: | |
9574 | @smallexample | |
9575 | int a; | |
9576 | @dots{} | |
9577 | if (!a > 1) @{ @dots{} @} | |
9578 | @end smallexample | |
9579 | ||
9580 | It is possible to suppress the warning by wrapping the LHS into | |
9581 | parentheses: | |
9582 | @smallexample | |
9583 | if ((!a) > 1) @{ @dots{} @} | |
9584 | @end smallexample | |
9585 | ||
9586 | This warning is enabled by @option{-Wall}. | |
9587 | ||
d77de738 ML |
9588 | @opindex Waggregate-return |
9589 | @opindex Wno-aggregate-return | |
ddf6fe37 | 9590 | @item -Waggregate-return |
d77de738 ML |
9591 | Warn if any functions that return structures or unions are defined or |
9592 | called. (In languages where you can return an array, this also elicits | |
9593 | a warning.) | |
9594 | ||
d77de738 ML |
9595 | @opindex Wno-aggressive-loop-optimizations |
9596 | @opindex Waggressive-loop-optimizations | |
ddf6fe37 | 9597 | @item -Wno-aggressive-loop-optimizations |
d77de738 ML |
9598 | Warn if in a loop with constant number of iterations the compiler detects |
9599 | undefined behavior in some statement during one or more of the iterations. | |
9600 | ||
d77de738 ML |
9601 | @opindex Wno-attributes |
9602 | @opindex Wattributes | |
ddf6fe37 | 9603 | @item -Wno-attributes |
d77de738 ML |
9604 | Do not warn if an unexpected @code{__attribute__} is used, such as |
9605 | unrecognized attributes, function attributes applied to variables, | |
9606 | etc. This does not stop errors for incorrect use of supported | |
9607 | attributes. | |
9608 | ||
5fccebdb JM |
9609 | Warnings about ill-formed uses of standard attributes are upgraded to |
9610 | errors by @option{-pedantic-errors}. | |
9611 | ||
d77de738 | 9612 | Additionally, using @option{-Wno-attributes=}, it is possible to suppress |
094a609c | 9613 | warnings about unknown scoped attributes (in C++11 and C23). For example, |
d77de738 ML |
9614 | @option{-Wno-attributes=vendor::attr} disables warning about the following |
9615 | declaration: | |
9616 | ||
9617 | @smallexample | |
9618 | [[vendor::attr]] void f(); | |
9619 | @end smallexample | |
9620 | ||
9621 | It is also possible to disable warning about all attributes in a namespace | |
9622 | using @option{-Wno-attributes=vendor::} which prevents warning about both | |
9623 | of these declarations: | |
9624 | ||
9625 | @smallexample | |
9626 | [[vendor::safe]] void f(); | |
9627 | [[vendor::unsafe]] void f2(); | |
9628 | @end smallexample | |
9629 | ||
9630 | Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}. | |
9631 | ||
d77de738 ML |
9632 | @opindex Wno-builtin-declaration-mismatch |
9633 | @opindex Wbuiltin-declaration-mismatch | |
ddf6fe37 | 9634 | @item -Wno-builtin-declaration-mismatch |
d77de738 ML |
9635 | Warn if a built-in function is declared with an incompatible signature |
9636 | or as a non-function, or when a built-in function declared with a type | |
9637 | that does not include a prototype is called with arguments whose promoted | |
9638 | types do not match those expected by the function. When @option{-Wextra} | |
9639 | is specified, also warn when a built-in function that takes arguments is | |
9640 | declared without a prototype. The @option{-Wbuiltin-declaration-mismatch} | |
9641 | warning is enabled by default. To avoid the warning include the appropriate | |
9642 | header to bring the prototypes of built-in functions into scope. | |
9643 | ||
9644 | For example, the call to @code{memset} below is diagnosed by the warning | |
9645 | because the function expects a value of type @code{size_t} as its argument | |
9646 | but the type of @code{32} is @code{int}. With @option{-Wextra}, | |
9647 | the declaration of the function is diagnosed as well. | |
9648 | @smallexample | |
9649 | extern void* memset (); | |
9650 | void f (void *d) | |
9651 | @{ | |
9652 | memset (d, '\0', 32); | |
9653 | @} | |
9654 | @end smallexample | |
9655 | ||
d77de738 ML |
9656 | @opindex Wno-builtin-macro-redefined |
9657 | @opindex Wbuiltin-macro-redefined | |
ddf6fe37 | 9658 | @item -Wno-builtin-macro-redefined |
d77de738 ML |
9659 | Do not warn if certain built-in macros are redefined. This suppresses |
9660 | warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__}, | |
9661 | @code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}. | |
9662 | ||
d77de738 ML |
9663 | @opindex Wstrict-prototypes |
9664 | @opindex Wno-strict-prototypes | |
ddf6fe37 | 9665 | @item -Wstrict-prototypes @r{(C and Objective-C only)} |
d77de738 ML |
9666 | Warn if a function is declared or defined without specifying the |
9667 | argument types. (An old-style function definition is permitted without | |
9668 | a warning if preceded by a declaration that specifies the argument | |
9669 | types.) | |
9670 | ||
d77de738 ML |
9671 | @opindex Wold-style-declaration |
9672 | @opindex Wno-old-style-declaration | |
ddf6fe37 | 9673 | @item -Wold-style-declaration @r{(C and Objective-C only)} |
d77de738 ML |
9674 | Warn for obsolescent usages, according to the C Standard, in a |
9675 | declaration. For example, warn if storage-class specifiers like | |
9676 | @code{static} are not the first things in a declaration. This warning | |
9677 | is also enabled by @option{-Wextra}. | |
9678 | ||
d77de738 ML |
9679 | @opindex Wold-style-definition |
9680 | @opindex Wno-old-style-definition | |
ddf6fe37 | 9681 | @item -Wold-style-definition @r{(C and Objective-C only)} |
d77de738 ML |
9682 | Warn if an old-style function definition is used. A warning is given |
9683 | even if there is a previous prototype. A definition using @samp{()} | |
094a609c | 9684 | is not considered an old-style definition in C23 mode, because it is |
d77de738 ML |
9685 | equivalent to @samp{(void)} in that case, but is considered an |
9686 | old-style definition for older standards. | |
9687 | ||
d77de738 ML |
9688 | @opindex Wmissing-parameter-type |
9689 | @opindex Wno-missing-parameter-type | |
ddf6fe37 | 9690 | @item -Wmissing-parameter-type @r{(C and Objective-C only)} |
d77de738 ML |
9691 | A function parameter is declared without a type specifier in K&R-style |
9692 | functions: | |
9693 | ||
9694 | @smallexample | |
9695 | void foo(bar) @{ @} | |
9696 | @end smallexample | |
9697 | ||
9698 | This warning is also enabled by @option{-Wextra}. | |
9699 | ||
d77de738 ML |
9700 | @opindex Wmissing-prototypes |
9701 | @opindex Wno-missing-prototypes | |
ddf6fe37 | 9702 | @item -Wmissing-prototypes @r{(C and Objective-C only)} |
d77de738 ML |
9703 | Warn if a global function is defined without a previous prototype |
9704 | declaration. This warning is issued even if the definition itself | |
9705 | provides a prototype. Use this option to detect global functions | |
9706 | that do not have a matching prototype declaration in a header file. | |
9707 | This option is not valid for C++ because all function declarations | |
9708 | provide prototypes and a non-matching declaration declares an | |
9709 | overload rather than conflict with an earlier declaration. | |
9710 | Use @option{-Wmissing-declarations} to detect missing declarations in C++. | |
9711 | ||
ffc74822 HM |
9712 | @opindex Wmissing-variable-declarations |
9713 | @opindex Wno-missing-variable-declarations | |
9714 | @item -Wmissing-variable-declarations @r{(C and Objective-C only)} | |
9715 | Warn if a global variable is defined without a previous declaration. | |
9716 | Use this option to detect global variables that do not have a matching | |
9717 | extern declaration in a header file. | |
9718 | ||
d77de738 ML |
9719 | @opindex Wmissing-declarations |
9720 | @opindex Wno-missing-declarations | |
ddf6fe37 | 9721 | @item -Wmissing-declarations |
d77de738 ML |
9722 | Warn if a global function is defined without a previous declaration. |
9723 | Do so even if the definition itself provides a prototype. | |
9724 | Use this option to detect global functions that are not declared in | |
9725 | header files. In C, no warnings are issued for functions with previous | |
9726 | non-prototype declarations; use @option{-Wmissing-prototypes} to detect | |
9727 | missing prototypes. In C++, no warnings are issued for function templates, | |
9728 | or for inline functions, or for functions in anonymous namespaces. | |
9729 | ||
d77de738 ML |
9730 | @opindex Wmissing-field-initializers |
9731 | @opindex Wno-missing-field-initializers | |
9732 | @opindex W | |
9733 | @opindex Wextra | |
9734 | @opindex Wno-extra | |
ddf6fe37 | 9735 | @item -Wmissing-field-initializers |
d77de738 ML |
9736 | Warn if a structure's initializer has some fields missing. For |
9737 | example, the following code causes such a warning, because | |
9738 | @code{x.h} is implicitly zero: | |
9739 | ||
9740 | @smallexample | |
9741 | struct s @{ int f, g, h; @}; | |
9742 | struct s x = @{ 3, 4 @}; | |
9743 | @end smallexample | |
9744 | ||
0f8f1dee MP |
9745 | @c It's unclear if this behavior is desirable. See PR39589 and PR96868. |
9746 | In C this option does not warn about designated initializers, so the | |
9747 | following modification does not trigger a warning: | |
d77de738 ML |
9748 | |
9749 | @smallexample | |
9750 | struct s @{ int f, g, h; @}; | |
9751 | struct s x = @{ .f = 3, .g = 4 @}; | |
9752 | @end smallexample | |
9753 | ||
9754 | In C this option does not warn about the universal zero initializer | |
9755 | @samp{@{ 0 @}}: | |
9756 | ||
9757 | @smallexample | |
9758 | struct s @{ int f, g, h; @}; | |
9759 | struct s x = @{ 0 @}; | |
9760 | @end smallexample | |
9761 | ||
9762 | Likewise, in C++ this option does not warn about the empty @{ @} | |
9763 | initializer, for example: | |
9764 | ||
9765 | @smallexample | |
9766 | struct s @{ int f, g, h; @}; | |
9767 | s x = @{ @}; | |
9768 | @end smallexample | |
9769 | ||
9770 | This warning is included in @option{-Wextra}. To get other @option{-Wextra} | |
9771 | warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}. | |
9772 | ||
d77de738 ML |
9773 | @opindex Wmissing-requires |
9774 | @opindex Wno-missing-requires | |
ddf6fe37 | 9775 | @item -Wno-missing-requires |
d77de738 ML |
9776 | |
9777 | By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement: | |
9778 | ||
9779 | @smallexample | |
9780 | bool satisfied = requires @{ C<T> @}; | |
9781 | @end smallexample | |
9782 | ||
9783 | Here @samp{satisfied} will be true if @samp{C<T>} is a valid | |
9784 | expression, which it is for all T. Presumably the user meant to write | |
9785 | ||
9786 | @smallexample | |
9787 | bool satisfied = requires @{ requires C<T> @}; | |
9788 | @end smallexample | |
9789 | ||
9790 | so @samp{satisfied} is only true if concept @samp{C} is satisfied for | |
9791 | type @samp{T}. | |
9792 | ||
9793 | This warning can be disabled with @option{-Wno-missing-requires}. | |
9794 | ||
d77de738 ML |
9795 | @opindex Wmissing-template-keyword |
9796 | @opindex Wno-missing-template-keyword | |
ddf6fe37 | 9797 | @item -Wno-missing-template-keyword |
d77de738 ML |
9798 | |
9799 | The member access tokens ., -> and :: must be followed by the @code{template} | |
9800 | keyword if the parent object is dependent and the member being named is a | |
9801 | template. | |
9802 | ||
9803 | @smallexample | |
9804 | template <class X> | |
9805 | void DoStuff (X x) | |
9806 | @{ | |
9807 | x.template DoSomeOtherStuff<X>(); // Good. | |
9808 | x.DoMoreStuff<X>(); // Warning, x is dependent. | |
9809 | @} | |
9810 | @end smallexample | |
9811 | ||
9812 | In rare cases it is possible to get false positives. To silence this, wrap | |
9813 | the expression in parentheses. For example, the following is treated as a | |
9814 | template, even where m and N are integers: | |
9815 | ||
9816 | @smallexample | |
9817 | void NotATemplate (my_class t) | |
9818 | @{ | |
9819 | int N = 5; | |
9820 | ||
9821 | bool test = t.m < N > (0); // Treated as a template. | |
9822 | test = (t.m < N) > (0); // Same meaning, but not treated as a template. | |
9823 | @} | |
9824 | @end smallexample | |
9825 | ||
9826 | This warning can be disabled with @option{-Wno-missing-template-keyword}. | |
9827 | ||
d77de738 ML |
9828 | @opindex Wno-multichar |
9829 | @opindex Wmultichar | |
ddf6fe37 | 9830 | @item -Wno-multichar |
d77de738 ML |
9831 | Do not warn if a multicharacter constant (@samp{'FOOF'}) is used. |
9832 | Usually they indicate a typo in the user's code, as they have | |
9833 | implementation-defined values, and should not be used in portable code. | |
9834 | ||
d77de738 ML |
9835 | @opindex Wnormalized= |
9836 | @opindex Wnormalized | |
9837 | @opindex Wno-normalized | |
9838 | @cindex NFC | |
9839 | @cindex NFKC | |
9840 | @cindex character set, input normalization | |
f33d7a88 | 9841 | @item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} |
d77de738 ML |
9842 | In ISO C and ISO C++, two identifiers are different if they are |
9843 | different sequences of characters. However, sometimes when characters | |
9844 | outside the basic ASCII character set are used, you can have two | |
9845 | different character sequences that look the same. To avoid confusion, | |
9846 | the ISO 10646 standard sets out some @dfn{normalization rules} which | |
9847 | when applied ensure that two sequences that look the same are turned into | |
9848 | the same sequence. GCC can warn you if you are using identifiers that | |
9849 | have not been normalized; this option controls that warning. | |
9850 | ||
9851 | There are four levels of warning supported by GCC@. The default is | |
9852 | @option{-Wnormalized=nfc}, which warns about any identifier that is | |
9853 | not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the | |
9854 | recommended form for most uses. It is equivalent to | |
9855 | @option{-Wnormalized}. | |
9856 | ||
9857 | Unfortunately, there are some characters allowed in identifiers by | |
9858 | ISO C and ISO C++ that, when turned into NFC, are not allowed in | |
9859 | identifiers. That is, there's no way to use these symbols in portable | |
9860 | ISO C or C++ and have all your identifiers in NFC@. | |
9861 | @option{-Wnormalized=id} suppresses the warning for these characters. | |
9862 | It is hoped that future versions of the standards involved will correct | |
9863 | this, which is why this option is not the default. | |
9864 | ||
9865 | You can switch the warning off for all characters by writing | |
9866 | @option{-Wnormalized=none} or @option{-Wno-normalized}. You should | |
9867 | only do this if you are using some other normalization scheme (like | |
9868 | ``D''), because otherwise you can easily create bugs that are | |
9869 | literally impossible to see. | |
9870 | ||
9871 | Some characters in ISO 10646 have distinct meanings but look identical | |
9872 | in some fonts or display methodologies, especially once formatting has | |
9873 | been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL | |
9874 | LETTER N'', displays just like a regular @code{n} that has been | |
9875 | placed in a superscript. ISO 10646 defines the @dfn{NFKC} | |
9876 | normalization scheme to convert all these into a standard form as | |
9877 | well, and GCC warns if your code is not in NFKC if you use | |
9878 | @option{-Wnormalized=nfkc}. This warning is comparable to warning | |
9879 | about every identifier that contains the letter O because it might be | |
9880 | confused with the digit 0, and so is not the default, but may be | |
9881 | useful as a local coding convention if the programming environment | |
9882 | cannot be fixed to display these characters distinctly. | |
9883 | ||
d77de738 ML |
9884 | @opindex Wno-attribute-warning |
9885 | @opindex Wattribute-warning | |
ddf6fe37 | 9886 | @item -Wno-attribute-warning |
d77de738 ML |
9887 | Do not warn about usage of functions (@pxref{Function Attributes}) |
9888 | declared with @code{warning} attribute. By default, this warning is | |
9889 | enabled. @option{-Wno-attribute-warning} can be used to disable the | |
9890 | warning or @option{-Wno-error=attribute-warning} can be used to | |
9891 | disable the error when compiled with @option{-Werror} flag. | |
9892 | ||
d77de738 ML |
9893 | @opindex Wno-deprecated |
9894 | @opindex Wdeprecated | |
ddf6fe37 | 9895 | @item -Wno-deprecated |
d77de738 ML |
9896 | Do not warn about usage of deprecated features. @xref{Deprecated Features}. |
9897 | ||
d77de738 ML |
9898 | @opindex Wno-deprecated-declarations |
9899 | @opindex Wdeprecated-declarations | |
ddf6fe37 | 9900 | @item -Wno-deprecated-declarations |
d77de738 ML |
9901 | Do not warn about uses of functions (@pxref{Function Attributes}), |
9902 | variables (@pxref{Variable Attributes}), and types (@pxref{Type | |
9903 | Attributes}) marked as deprecated by using the @code{deprecated} | |
9904 | attribute. | |
9905 | ||
d77de738 ML |
9906 | @opindex Wno-overflow |
9907 | @opindex Woverflow | |
ddf6fe37 | 9908 | @item -Wno-overflow |
d77de738 ML |
9909 | Do not warn about compile-time overflow in constant expressions. |
9910 | ||
d77de738 ML |
9911 | @opindex Wno-odr |
9912 | @opindex Wodr | |
ddf6fe37 | 9913 | @item -Wno-odr |
d77de738 ML |
9914 | Warn about One Definition Rule violations during link-time optimization. |
9915 | Enabled by default. | |
9916 | ||
d77de738 ML |
9917 | @opindex Wopenacc-parallelism |
9918 | @opindex Wno-openacc-parallelism | |
9919 | @cindex OpenACC accelerator programming | |
f33d7a88 | 9920 | @item -Wopenacc-parallelism |
d77de738 ML |
9921 | Warn about potentially suboptimal choices related to OpenACC parallelism. |
9922 | ||
d77de738 ML |
9923 | @opindex Wopenmp-simd |
9924 | @opindex Wno-openmp-simd | |
ddf6fe37 | 9925 | @item -Wopenmp-simd |
d77de738 ML |
9926 | Warn if the vectorizer cost model overrides the OpenMP |
9927 | simd directive set by user. The @option{-fsimd-cost-model=unlimited} | |
9928 | option can be used to relax the cost model. | |
9929 | ||
d77de738 ML |
9930 | @opindex Woverride-init |
9931 | @opindex Wno-override-init | |
9932 | @opindex W | |
9933 | @opindex Wextra | |
9934 | @opindex Wno-extra | |
ddf6fe37 | 9935 | @item -Woverride-init @r{(C and Objective-C only)} |
d77de738 ML |
9936 | Warn if an initialized field without side effects is overridden when |
9937 | using designated initializers (@pxref{Designated Inits, , Designated | |
9938 | Initializers}). | |
9939 | ||
9940 | This warning is included in @option{-Wextra}. To get other | |
9941 | @option{-Wextra} warnings without this one, use @option{-Wextra | |
9942 | -Wno-override-init}. | |
9943 | ||
d77de738 ML |
9944 | @opindex Woverride-init-side-effects |
9945 | @opindex Wno-override-init-side-effects | |
ddf6fe37 | 9946 | @item -Wno-override-init-side-effects @r{(C and Objective-C only)} |
d77de738 ML |
9947 | Do not warn if an initialized field with side effects is overridden when |
9948 | using designated initializers (@pxref{Designated Inits, , Designated | |
9949 | Initializers}). This warning is enabled by default. | |
9950 | ||
d77de738 ML |
9951 | @opindex Wpacked |
9952 | @opindex Wno-packed | |
ddf6fe37 | 9953 | @item -Wpacked |
d77de738 ML |
9954 | Warn if a structure is given the packed attribute, but the packed |
9955 | attribute has no effect on the layout or size of the structure. | |
9956 | Such structures may be mis-aligned for little benefit. For | |
9957 | instance, in this code, the variable @code{f.x} in @code{struct bar} | |
9958 | is misaligned even though @code{struct bar} does not itself | |
9959 | have the packed attribute: | |
9960 | ||
9961 | @smallexample | |
9962 | @group | |
9963 | struct foo @{ | |
9964 | int x; | |
9965 | char a, b, c, d; | |
9966 | @} __attribute__((packed)); | |
9967 | struct bar @{ | |
9968 | char z; | |
9969 | struct foo f; | |
9970 | @}; | |
9971 | @end group | |
9972 | @end smallexample | |
9973 | ||
d77de738 ML |
9974 | @opindex Wpacked-bitfield-compat |
9975 | @opindex Wno-packed-bitfield-compat | |
ddf6fe37 | 9976 | @item -Wnopacked-bitfield-compat |
d77de738 ML |
9977 | The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute |
9978 | on bit-fields of type @code{char}. This was fixed in GCC 4.4 but | |
9979 | the change can lead to differences in the structure layout. GCC | |
9980 | informs you when the offset of such a field has changed in GCC 4.4. | |
9981 | For example there is no longer a 4-bit padding between field @code{a} | |
9982 | and @code{b} in this structure: | |
9983 | ||
9984 | @smallexample | |
9985 | struct foo | |
9986 | @{ | |
9987 | char a:4; | |
9988 | char b:8; | |
9989 | @} __attribute__ ((packed)); | |
9990 | @end smallexample | |
9991 | ||
9992 | This warning is enabled by default. Use | |
9993 | @option{-Wno-packed-bitfield-compat} to disable this warning. | |
9994 | ||
d77de738 ML |
9995 | @opindex Wpacked-not-aligned |
9996 | @opindex Wno-packed-not-aligned | |
ddf6fe37 | 9997 | @item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
9998 | Warn if a structure field with explicitly specified alignment in a |
9999 | packed struct or union is misaligned. For example, a warning will | |
10000 | be issued on @code{struct S}, like, @code{warning: alignment 1 of | |
10001 | 'struct S' is less than 8}, in this code: | |
10002 | ||
10003 | @smallexample | |
10004 | @group | |
10005 | struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @}; | |
10006 | struct __attribute__ ((packed)) S @{ | |
10007 | struct S8 s8; | |
10008 | @}; | |
10009 | @end group | |
10010 | @end smallexample | |
10011 | ||
10012 | This warning is enabled by @option{-Wall}. | |
10013 | ||
d77de738 ML |
10014 | @opindex Wpadded |
10015 | @opindex Wno-padded | |
ddf6fe37 | 10016 | @item -Wpadded |
d77de738 ML |
10017 | Warn if padding is included in a structure, either to align an element |
10018 | of the structure or to align the whole structure. Sometimes when this | |
10019 | happens it is possible to rearrange the fields of the structure to | |
10020 | reduce the padding and so make the structure smaller. | |
10021 | ||
d77de738 ML |
10022 | @opindex Wredundant-decls |
10023 | @opindex Wno-redundant-decls | |
ddf6fe37 | 10024 | @item -Wredundant-decls |
d77de738 ML |
10025 | Warn if anything is declared more than once in the same scope, even in |
10026 | cases where multiple declaration is valid and changes nothing. | |
10027 | ||
d77de738 ML |
10028 | @opindex Wrestrict |
10029 | @opindex Wno-restrict | |
ddf6fe37 | 10030 | @item -Wrestrict |
d77de738 ML |
10031 | Warn when an object referenced by a @code{restrict}-qualified parameter |
10032 | (or, in C++, a @code{__restrict}-qualified parameter) is aliased by another | |
10033 | argument, or when copies between such objects overlap. For example, | |
10034 | the call to the @code{strcpy} function below attempts to truncate the string | |
10035 | by replacing its initial characters with the last four. However, because | |
10036 | the call writes the terminating NUL into @code{a[4]}, the copies overlap and | |
10037 | the call is diagnosed. | |
10038 | ||
10039 | @smallexample | |
10040 | void foo (void) | |
10041 | @{ | |
10042 | char a[] = "abcd1234"; | |
10043 | strcpy (a, a + 4); | |
10044 | @dots{} | |
10045 | @} | |
10046 | @end smallexample | |
10047 | The @option{-Wrestrict} option detects some instances of simple overlap | |
10048 | even without optimization but works best at @option{-O2} and above. It | |
10049 | is included in @option{-Wall}. | |
10050 | ||
d77de738 ML |
10051 | @opindex Wnested-externs |
10052 | @opindex Wno-nested-externs | |
ddf6fe37 | 10053 | @item -Wnested-externs @r{(C and Objective-C only)} |
d77de738 ML |
10054 | Warn if an @code{extern} declaration is encountered within a function. |
10055 | ||
d77de738 ML |
10056 | @opindex Winline |
10057 | @opindex Wno-inline | |
ddf6fe37 | 10058 | @item -Winline |
d77de738 ML |
10059 | Warn if a function that is declared as inline cannot be inlined. |
10060 | Even with this option, the compiler does not warn about failures to | |
10061 | inline functions declared in system headers. | |
10062 | ||
10063 | The compiler uses a variety of heuristics to determine whether or not | |
10064 | to inline a function. For example, the compiler takes into account | |
10065 | the size of the function being inlined and the amount of inlining | |
10066 | that has already been done in the current function. Therefore, | |
10067 | seemingly insignificant changes in the source program can cause the | |
10068 | warnings produced by @option{-Winline} to appear or disappear. | |
10069 | ||
d77de738 | 10070 | @opindex Winterference-size |
ddf6fe37 | 10071 | @item -Winterference-size |
d77de738 ML |
10072 | Warn about use of C++17 @code{std::hardware_destructive_interference_size} |
10073 | without specifying its value with @option{--param destructive-interference-size}. | |
10074 | Also warn about questionable values for that option. | |
10075 | ||
10076 | This variable is intended to be used for controlling class layout, to | |
10077 | avoid false sharing in concurrent code: | |
10078 | ||
10079 | @smallexample | |
10080 | struct independent_fields @{ | |
4ace81b6 SL |
10081 | alignas(std::hardware_destructive_interference_size) |
10082 | std::atomic<int> one; | |
10083 | alignas(std::hardware_destructive_interference_size) | |
10084 | std::atomic<int> two; | |
d77de738 ML |
10085 | @}; |
10086 | @end smallexample | |
10087 | ||
10088 | Here @samp{one} and @samp{two} are intended to be far enough apart | |
10089 | that stores to one won't require accesses to the other to reload the | |
10090 | cache line. | |
10091 | ||
10092 | By default, @option{--param destructive-interference-size} and | |
10093 | @option{--param constructive-interference-size} are set based on the | |
10094 | current @option{-mtune} option, typically to the L1 cache line size | |
10095 | for the particular target CPU, sometimes to a range if tuning for a | |
10096 | generic target. So all translation units that depend on ABI | |
10097 | compatibility for the use of these variables must be compiled with | |
10098 | the same @option{-mtune} (or @option{-mcpu}). | |
10099 | ||
10100 | If ABI stability is important, such as if the use is in a header for a | |
10101 | library, you should probably not use the hardware interference size | |
10102 | variables at all. Alternatively, you can force a particular value | |
10103 | with @option{--param}. | |
10104 | ||
10105 | If you are confident that your use of the variable does not affect ABI | |
10106 | outside a single build of your project, you can turn off the warning | |
10107 | with @option{-Wno-interference-size}. | |
10108 | ||
d77de738 ML |
10109 | @opindex Wint-in-bool-context |
10110 | @opindex Wno-int-in-bool-context | |
ddf6fe37 | 10111 | @item -Wint-in-bool-context |
d77de738 ML |
10112 | Warn for suspicious use of integer values where boolean values are expected, |
10113 | such as conditional expressions (?:) using non-boolean integer constants in | |
10114 | boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed | |
10115 | integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise | |
10116 | for all kinds of multiplications regardless of the data type. | |
10117 | This warning is enabled by @option{-Wall}. | |
10118 | ||
d77de738 ML |
10119 | @opindex Wno-int-to-pointer-cast |
10120 | @opindex Wint-to-pointer-cast | |
ddf6fe37 | 10121 | @item -Wno-int-to-pointer-cast |
d77de738 ML |
10122 | Suppress warnings from casts to pointer type of an integer of a |
10123 | different size. In C++, casting to a pointer type of smaller size is | |
10124 | an error. @option{Wint-to-pointer-cast} is enabled by default. | |
10125 | ||
10126 | ||
d77de738 ML |
10127 | @opindex Wno-pointer-to-int-cast |
10128 | @opindex Wpointer-to-int-cast | |
ddf6fe37 | 10129 | @item -Wno-pointer-to-int-cast @r{(C and Objective-C only)} |
d77de738 ML |
10130 | Suppress warnings from casts from a pointer to an integer type of a |
10131 | different size. | |
10132 | ||
d77de738 ML |
10133 | @opindex Winvalid-pch |
10134 | @opindex Wno-invalid-pch | |
ddf6fe37 | 10135 | @item -Winvalid-pch |
d77de738 ML |
10136 | Warn if a precompiled header (@pxref{Precompiled Headers}) is found in |
10137 | the search path but cannot be used. | |
10138 | ||
d77de738 ML |
10139 | @opindex Winvalid-utf8 |
10140 | @opindex Wno-invalid-utf8 | |
ddf6fe37 | 10141 | @item -Winvalid-utf8 |
d77de738 ML |
10142 | Warn if an invalid UTF-8 character is found. |
10143 | This warning is on by default for C++23 if @option{-finput-charset=UTF-8} | |
10144 | is used and turned into error with @option{-pedantic-errors}. | |
10145 | ||
d77de738 ML |
10146 | @opindex Wunicode |
10147 | @opindex Wno-unicode | |
ddf6fe37 | 10148 | @item -Wno-unicode |
d77de738 ML |
10149 | Don't diagnose invalid forms of delimited or named escape sequences which are |
10150 | treated as separate tokens. @option{Wunicode} is enabled by default. | |
10151 | ||
d77de738 ML |
10152 | @opindex Wlong-long |
10153 | @opindex Wno-long-long | |
ddf6fe37 | 10154 | @item -Wlong-long |
d77de738 ML |
10155 | Warn if @code{long long} type is used. This is enabled by either |
10156 | @option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98 | |
10157 | modes. To inhibit the warning messages, use @option{-Wno-long-long}. | |
10158 | ||
5fccebdb JM |
10159 | This warning is upgraded to an error by @option{-pedantic-errors}. |
10160 | ||
d77de738 ML |
10161 | @opindex Wvariadic-macros |
10162 | @opindex Wno-variadic-macros | |
ddf6fe37 | 10163 | @item -Wvariadic-macros |
d77de738 ML |
10164 | Warn if variadic macros are used in ISO C90 mode, or if the GNU |
10165 | alternate syntax is used in ISO C99 mode. This is enabled by either | |
10166 | @option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning | |
10167 | messages, use @option{-Wno-variadic-macros}. | |
10168 | ||
d77de738 ML |
10169 | @opindex Wvarargs |
10170 | @opindex Wno-varargs | |
ddf6fe37 | 10171 | @item -Wno-varargs |
d77de738 ML |
10172 | Do not warn upon questionable usage of the macros used to handle variable |
10173 | arguments like @code{va_start}. These warnings are enabled by default. | |
10174 | ||
d77de738 ML |
10175 | @opindex Wvector-operation-performance |
10176 | @opindex Wno-vector-operation-performance | |
ddf6fe37 | 10177 | @item -Wvector-operation-performance |
d77de738 ML |
10178 | Warn if vector operation is not implemented via SIMD capabilities of the |
10179 | architecture. Mainly useful for the performance tuning. | |
10180 | Vector operation can be implemented @code{piecewise}, which means that the | |
10181 | scalar operation is performed on every vector element; | |
10182 | @code{in parallel}, which means that the vector operation is implemented | |
10183 | using scalars of wider type, which normally is more performance efficient; | |
10184 | and @code{as a single scalar}, which means that vector fits into a | |
10185 | scalar type. | |
10186 | ||
d77de738 ML |
10187 | @opindex Wvla |
10188 | @opindex Wno-vla | |
ddf6fe37 | 10189 | @item -Wvla |
d77de738 ML |
10190 | Warn if a variable-length array is used in the code. |
10191 | @option{-Wno-vla} prevents the @option{-Wpedantic} warning of | |
10192 | the variable-length array. | |
10193 | ||
5fccebdb JM |
10194 | This warning is upgraded to an error by @option{-pedantic-errors}. |
10195 | ||
d77de738 ML |
10196 | @opindex Wvla-larger-than= |
10197 | @opindex Wno-vla-larger-than | |
ddf6fe37 | 10198 | @item -Wvla-larger-than=@var{byte-size} |
d77de738 ML |
10199 | If this option is used, the compiler warns for declarations of |
10200 | variable-length arrays whose size is either unbounded, or bounded | |
10201 | by an argument that allows the array size to exceed @var{byte-size} | |
10202 | bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size} | |
10203 | works, but with variable-length arrays. | |
10204 | ||
10205 | Note that GCC may optimize small variable-length arrays of a known | |
10206 | value into plain arrays, so this warning may not get triggered for | |
10207 | such arrays. | |
10208 | ||
10209 | @option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but | |
10210 | is typically only effective when @option{-ftree-vrp} is active (default | |
10211 | for @option{-O2} and above). | |
10212 | ||
10213 | See also @option{-Walloca-larger-than=@var{byte-size}}. | |
10214 | ||
d77de738 | 10215 | @opindex Wno-vla-larger-than |
ddf6fe37 | 10216 | @item -Wno-vla-larger-than |
d77de738 ML |
10217 | Disable @option{-Wvla-larger-than=} warnings. The option is equivalent |
10218 | to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger. | |
10219 | ||
d77de738 | 10220 | @opindex Wno-vla-parameter |
ddf6fe37 | 10221 | @item -Wvla-parameter |
d77de738 ML |
10222 | Warn about redeclarations of functions involving arguments of Variable |
10223 | Length Array types of inconsistent kinds or forms, and enable the detection | |
10224 | of out-of-bounds accesses to such parameters by warnings such as | |
10225 | @option{-Warray-bounds}. | |
10226 | ||
10227 | If the first function declaration uses the VLA form the bound specified | |
10228 | in the array is assumed to be the minimum number of elements expected to | |
10229 | be provided in calls to the function and the maximum number of elements | |
10230 | accessed by it. Failing to provide arguments of sufficient size or | |
10231 | accessing more than the maximum number of elements may be diagnosed. | |
10232 | ||
10233 | For example, the warning triggers for the following redeclarations because | |
10234 | the first one allows an array of any size to be passed to @code{f} while | |
10235 | the second one specifies that the array argument must have at least @code{n} | |
10236 | elements. In addition, calling @code{f} with the associated VLA bound | |
10237 | parameter in excess of the actual VLA bound triggers a warning as well. | |
10238 | ||
10239 | @smallexample | |
10240 | void f (int n, int[n]); | |
4ace81b6 SL |
10241 | // warning: argument 2 previously declared as a VLA |
10242 | void f (int, int[]); | |
d77de738 ML |
10243 | |
10244 | void g (int n) | |
10245 | @{ | |
10246 | if (n > 4) | |
10247 | return; | |
10248 | int a[n]; | |
4ace81b6 SL |
10249 | // warning: access to a by f may be out of bounds |
10250 | f (sizeof a, a); | |
d77de738 ML |
10251 | @dots{} |
10252 | @} | |
10253 | ||
10254 | @end smallexample | |
10255 | ||
10256 | @option{-Wvla-parameter} is included in @option{-Wall}. The | |
10257 | @option{-Warray-parameter} option triggers warnings for similar problems | |
10258 | involving ordinary array arguments. | |
10259 | ||
d77de738 ML |
10260 | @opindex Wvolatile-register-var |
10261 | @opindex Wno-volatile-register-var | |
ddf6fe37 | 10262 | @item -Wvolatile-register-var |
d77de738 ML |
10263 | Warn if a register variable is declared volatile. The volatile |
10264 | modifier does not inhibit all optimizations that may eliminate reads | |
10265 | and/or writes to register variables. This warning is enabled by | |
10266 | @option{-Wall}. | |
10267 | ||
d77de738 ML |
10268 | @opindex Wxor-used-as-pow |
10269 | @opindex Wno-xor-used-as-pow | |
ddf6fe37 | 10270 | @item -Wxor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
10271 | Warn about uses of @code{^}, the exclusive or operator, where it appears |
10272 | the user meant exponentiation. Specifically, the warning occurs when the | |
10273 | left-hand side is the decimal constant 2 or 10 and the right-hand side | |
10274 | is also a decimal constant. | |
10275 | ||
10276 | In C and C++, @code{^} means exclusive or, whereas in some other languages | |
10277 | (e.g. TeX and some versions of BASIC) it means exponentiation. | |
10278 | ||
10279 | This warning is enabled by default. It can be silenced by converting one | |
10280 | of the operands to hexadecimal. | |
10281 | ||
d77de738 ML |
10282 | @opindex Wdisabled-optimization |
10283 | @opindex Wno-disabled-optimization | |
ddf6fe37 | 10284 | @item -Wdisabled-optimization |
d77de738 ML |
10285 | Warn if a requested optimization pass is disabled. This warning does |
10286 | not generally indicate that there is anything wrong with your code; it | |
10287 | merely indicates that GCC's optimizers are unable to handle the code | |
10288 | effectively. Often, the problem is that your code is too big or too | |
10289 | complex; GCC refuses to optimize programs when the optimization | |
10290 | itself is likely to take inordinate amounts of time. | |
10291 | ||
d77de738 ML |
10292 | @opindex Wpointer-sign |
10293 | @opindex Wno-pointer-sign | |
ddf6fe37 | 10294 | @item -Wpointer-sign @r{(C and Objective-C only)} |
d77de738 ML |
10295 | Warn for pointer argument passing or assignment with different signedness. |
10296 | This option is only supported for C and Objective-C@. It is implied by | |
10297 | @option{-Wall} and by @option{-Wpedantic}, which can be disabled with | |
10298 | @option{-Wno-pointer-sign}. | |
10299 | ||
5fccebdb JM |
10300 | This warning is upgraded to an error by @option{-pedantic-errors}. |
10301 | ||
d77de738 ML |
10302 | @opindex Wstack-protector |
10303 | @opindex Wno-stack-protector | |
ddf6fe37 | 10304 | @item -Wstack-protector |
d77de738 ML |
10305 | This option is only active when @option{-fstack-protector} is active. It |
10306 | warns about functions that are not protected against stack smashing. | |
10307 | ||
d77de738 ML |
10308 | @opindex Woverlength-strings |
10309 | @opindex Wno-overlength-strings | |
ddf6fe37 | 10310 | @item -Woverlength-strings |
d77de738 ML |
10311 | Warn about string constants that are longer than the ``minimum |
10312 | maximum'' length specified in the C standard. Modern compilers | |
10313 | generally allow string constants that are much longer than the | |
10314 | standard's minimum limit, but very portable programs should avoid | |
10315 | using longer strings. | |
10316 | ||
10317 | The limit applies @emph{after} string constant concatenation, and does | |
10318 | not count the trailing NUL@. In C90, the limit was 509 characters; in | |
10319 | C99, it was raised to 4095. C++98 does not specify a normative | |
10320 | minimum maximum, so we do not diagnose overlength strings in C++@. | |
10321 | ||
10322 | This option is implied by @option{-Wpedantic}, and can be disabled with | |
10323 | @option{-Wno-overlength-strings}. | |
10324 | ||
d77de738 ML |
10325 | @opindex Wunsuffixed-float-constants |
10326 | @opindex Wno-unsuffixed-float-constants | |
ddf6fe37 | 10327 | @item -Wunsuffixed-float-constants @r{(C and Objective-C only)} |
d77de738 ML |
10328 | |
10329 | Issue a warning for any floating constant that does not have | |
10330 | a suffix. When used together with @option{-Wsystem-headers} it | |
10331 | warns about such constants in system header files. This can be useful | |
10332 | when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma | |
10333 | from the decimal floating-point extension to C99. | |
10334 | ||
d77de738 ML |
10335 | @opindex Wlto-type-mismatch |
10336 | @opindex Wno-lto-type-mismatch | |
ddf6fe37 | 10337 | @item -Wno-lto-type-mismatch |
d77de738 ML |
10338 | |
10339 | During the link-time optimization, do not warn about type mismatches in | |
10340 | global declarations from different compilation units. | |
10341 | Requires @option{-flto} to be enabled. Enabled by default. | |
10342 | ||
d77de738 ML |
10343 | @opindex Wdesignated-init |
10344 | @opindex Wno-designated-init | |
ddf6fe37 | 10345 | @item -Wno-designated-init @r{(C and Objective-C only)} |
d77de738 ML |
10346 | Suppress warnings when a positional initializer is used to initialize |
10347 | a structure that has been marked with the @code{designated_init} | |
10348 | attribute. | |
10349 | ||
10350 | @end table | |
10351 | ||
10352 | @node Static Analyzer Options | |
10353 | @section Options That Control Static Analysis | |
10354 | ||
10355 | @table @gcctabopt | |
d77de738 ML |
10356 | @opindex analyzer |
10357 | @opindex fanalyzer | |
10358 | @opindex fno-analyzer | |
ddf6fe37 | 10359 | @item -fanalyzer |
d77de738 ML |
10360 | This option enables an static analysis of program flow which looks |
10361 | for ``interesting'' interprocedural paths through the | |
10362 | code, and issues warnings for problems found on them. | |
10363 | ||
10364 | This analysis is much more expensive than other GCC warnings. | |
10365 | ||
a90316c6 DM |
10366 | In technical terms, it performs coverage-guided symbolic execution of |
10367 | the code being compiled. It is neither sound nor complete: it can | |
10368 | have false positives and false negatives. It is a bug-finding tool, | |
10369 | rather than a tool for proving program correctness. | |
10370 | ||
10371 | The analyzer is only suitable for use on C code in this release. | |
10372 | ||
d77de738 ML |
10373 | Enabling this option effectively enables the following warnings: |
10374 | ||
43b72ede AA |
10375 | @gccoptlist{ |
10376 | -Wanalyzer-allocation-size | |
10377 | -Wanalyzer-deref-before-check | |
10378 | -Wanalyzer-double-fclose | |
10379 | -Wanalyzer-double-free | |
10380 | -Wanalyzer-exposure-through-output-file | |
10381 | -Wanalyzer-exposure-through-uninit-copy | |
10382 | -Wanalyzer-fd-access-mode-mismatch | |
10383 | -Wanalyzer-fd-double-close | |
10384 | -Wanalyzer-fd-leak | |
10385 | -Wanalyzer-fd-phase-mismatch | |
10386 | -Wanalyzer-fd-type-mismatch | |
10387 | -Wanalyzer-fd-use-after-close | |
10388 | -Wanalyzer-fd-use-without-check | |
10389 | -Wanalyzer-file-leak | |
10390 | -Wanalyzer-free-of-non-heap | |
10391 | -Wanalyzer-imprecise-fp-arithmetic | |
10392 | -Wanalyzer-infinite-recursion | |
10393 | -Wanalyzer-jump-through-null | |
10394 | -Wanalyzer-malloc-leak | |
10395 | -Wanalyzer-mismatching-deallocation | |
10396 | -Wanalyzer-null-argument | |
10397 | -Wanalyzer-null-dereference | |
10398 | -Wanalyzer-out-of-bounds | |
034d99e8 | 10399 | -Wanalyzer-overlapping-buffers |
43b72ede AA |
10400 | -Wanalyzer-possible-null-argument |
10401 | -Wanalyzer-possible-null-dereference | |
10402 | -Wanalyzer-putenv-of-auto-var | |
10403 | -Wanalyzer-shift-count-negative | |
10404 | -Wanalyzer-shift-count-overflow | |
10405 | -Wanalyzer-stale-setjmp-buffer | |
10406 | -Wanalyzer-unsafe-call-within-signal-handler | |
10407 | -Wanalyzer-use-after-free | |
10408 | -Wanalyzer-use-of-pointer-in-stale-stack-frame | |
10409 | -Wanalyzer-use-of-uninitialized-value | |
10410 | -Wanalyzer-va-arg-type-mismatch | |
10411 | -Wanalyzer-va-list-exhausted | |
10412 | -Wanalyzer-va-list-leak | |
10413 | -Wanalyzer-va-list-use-after-va-end | |
10414 | -Wanalyzer-write-to-const | |
10415 | -Wanalyzer-write-to-string-literal | |
d77de738 ML |
10416 | } |
10417 | @ignore | |
43b72ede AA |
10418 | -Wanalyzer-tainted-allocation-size |
10419 | -Wanalyzer-tainted-array-index | |
10420 | -Wanalyzer-tainted-divisor | |
10421 | -Wanalyzer-tainted-offset | |
10422 | -Wanalyzer-tainted-size | |
d77de738 ML |
10423 | @end ignore |
10424 | ||
10425 | This option is only available if GCC was configured with analyzer | |
10426 | support enabled. | |
10427 | ||
d77de738 ML |
10428 | @opindex Wanalyzer-too-complex |
10429 | @opindex Wno-analyzer-too-complex | |
ddf6fe37 | 10430 | @item -Wanalyzer-too-complex |
d77de738 ML |
10431 | If @option{-fanalyzer} is enabled, the analyzer uses various heuristics |
10432 | to attempt to explore the control flow and data flow in the program, | |
10433 | but these can be defeated by sufficiently complicated code. | |
10434 | ||
10435 | By default, the analysis silently stops if the code is too | |
10436 | complicated for the analyzer to fully explore and it reaches an internal | |
10437 | limit. The @option{-Wanalyzer-too-complex} option warns if this occurs. | |
10438 | ||
d77de738 ML |
10439 | @opindex Wanalyzer-allocation-size |
10440 | @opindex Wno-analyzer-allocation-size | |
ddf6fe37 | 10441 | @item -Wno-analyzer-allocation-size |
4ace81b6 SL |
10442 | This warning requires @option{-fanalyzer}, which enables it; |
10443 | to disable it, use @option{-Wno-analyzer-allocation-size}. | |
d77de738 ML |
10444 | |
10445 | This diagnostic warns for paths through the code in which a pointer to | |
10446 | a buffer is assigned to point at a buffer with a size that is not a | |
10447 | multiple of @code{sizeof (*pointer)}. | |
10448 | ||
10449 | See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}. | |
10450 | ||
ce51e843 ML |
10451 | @opindex Wanalyzer-deref-before-check |
10452 | @opindex Wno-analyzer-deref-before-check | |
ddf6fe37 | 10453 | @item -Wno-analyzer-deref-before-check |
ce51e843 ML |
10454 | This warning requires @option{-fanalyzer}, which enables it; use |
10455 | @option{-Wno-analyzer-deref-before-check} | |
10456 | to disable it. | |
10457 | ||
10458 | This diagnostic warns for paths through the code in which a pointer | |
10459 | is checked for @code{NULL} *after* it has already been | |
10460 | dereferenced, suggesting that the pointer could have been NULL. | |
10461 | Such cases suggest that the check for NULL is either redundant, | |
10462 | or that it needs to be moved to before the pointer is dereferenced. | |
10463 | ||
10464 | This diagnostic also considers values passed to a function argument | |
10465 | marked with @code{__attribute__((nonnull))} as requiring a non-NULL | |
10466 | value, and thus will complain if such values are checked for @code{NULL} | |
10467 | after returning from such a function call. | |
10468 | ||
10469 | This diagnostic is unlikely to be reported when any level of optimization | |
10470 | is enabled, as GCC's optimization logic will typically consider such | |
10471 | checks for NULL as being redundant, and optimize them away before the | |
10472 | analyzer "sees" them. Hence optimization should be disabled when | |
10473 | attempting to trigger this diagnostic. | |
10474 | ||
d77de738 ML |
10475 | @opindex Wanalyzer-double-fclose |
10476 | @opindex Wno-analyzer-double-fclose | |
ddf6fe37 | 10477 | @item -Wno-analyzer-double-fclose |
d77de738 ML |
10478 | This warning requires @option{-fanalyzer}, which enables it; use |
10479 | @option{-Wno-analyzer-double-fclose} to disable it. | |
10480 | ||
10481 | This diagnostic warns for paths through the code in which a @code{FILE *} | |
10482 | can have @code{fclose} called on it more than once. | |
10483 | ||
10484 | See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}. | |
10485 | ||
d77de738 ML |
10486 | @opindex Wanalyzer-double-free |
10487 | @opindex Wno-analyzer-double-free | |
ddf6fe37 | 10488 | @item -Wno-analyzer-double-free |
d77de738 ML |
10489 | This warning requires @option{-fanalyzer}, which enables it; use |
10490 | @option{-Wno-analyzer-double-free} to disable it. | |
10491 | ||
10492 | This diagnostic warns for paths through the code in which a pointer | |
10493 | can have a deallocator called on it more than once, either @code{free}, | |
10494 | or a deallocator referenced by attribute @code{malloc}. | |
10495 | ||
10496 | See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}. | |
10497 | ||
d77de738 ML |
10498 | @opindex Wanalyzer-exposure-through-output-file |
10499 | @opindex Wno-analyzer-exposure-through-output-file | |
ddf6fe37 | 10500 | @item -Wno-analyzer-exposure-through-output-file |
d77de738 ML |
10501 | This warning requires @option{-fanalyzer}, which enables it; use |
10502 | @option{-Wno-analyzer-exposure-through-output-file} | |
10503 | to disable it. | |
10504 | ||
10505 | This diagnostic warns for paths through the code in which a | |
10506 | security-sensitive value is written to an output file | |
10507 | (such as writing a password to a log file). | |
10508 | ||
10509 | See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}. | |
10510 | ||
d77de738 ML |
10511 | @opindex Wanalyzer-exposure-through-uninit-copy |
10512 | @opindex Wno-analyzer-exposure-through-uninit-copy | |
ddf6fe37 | 10513 | @item -Wanalyzer-exposure-through-uninit-copy |
d77de738 ML |
10514 | This warning requires both @option{-fanalyzer} and the use of a plugin |
10515 | to specify a function that copies across a ``trust boundary''. Use | |
10516 | @option{-Wno-analyzer-exposure-through-uninit-copy} to disable it. | |
10517 | ||
10518 | This diagnostic warns for ``infoleaks'' - paths through the code in which | |
10519 | uninitialized values are copied across a security boundary | |
10520 | (such as code within an OS kernel that copies a partially-initialized | |
10521 | struct on the stack to user space). | |
10522 | ||
10523 | See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}. | |
10524 | ||
d77de738 ML |
10525 | @opindex Wanalyzer-fd-access-mode-mismatch |
10526 | @opindex Wno-analyzer-fd-access-mode-mismatch | |
ddf6fe37 | 10527 | @item -Wno-analyzer-fd-access-mode-mismatch |
d77de738 ML |
10528 | This warning requires @option{-fanalyzer}, which enables it; use |
10529 | @option{-Wno-analyzer-fd-access-mode-mismatch} | |
10530 | to disable it. | |
10531 | ||
10532 | This diagnostic warns for paths through code in which a | |
10533 | @code{read} on a write-only file descriptor is attempted, or vice versa. | |
10534 | ||
10535 | This diagnostic also warns for code paths in a which a function with attribute | |
10536 | @code{fd_arg_read (N)} is called with a file descriptor opened with | |
10537 | @code{O_WRONLY} at referenced argument @code{N} or a function with attribute | |
10538 | @code{fd_arg_write (N)} is called with a file descriptor opened with | |
10539 | @code{O_RDONLY} at referenced argument @var{N}. | |
10540 | ||
d77de738 ML |
10541 | @opindex Wanalyzer-fd-double-close |
10542 | @opindex Wno-analyzer-fd-double-close | |
ddf6fe37 | 10543 | @item -Wno-analyzer-fd-double-close |
d77de738 ML |
10544 | This warning requires @option{-fanalyzer}, which enables it; use |
10545 | @option{-Wno-analyzer-fd-double-close} | |
10546 | to disable it. | |
10547 | ||
10548 | This diagnostic warns for paths through code in which a | |
10549 | file descriptor can be closed more than once. | |
10550 | ||
10551 | See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}. | |
10552 | ||
d77de738 ML |
10553 | @opindex Wanalyzer-fd-leak |
10554 | @opindex Wno-analyzer-fd-leak | |
ddf6fe37 | 10555 | @item -Wno-analyzer-fd-leak |
d77de738 ML |
10556 | This warning requires @option{-fanalyzer}, which enables it; use |
10557 | @option{-Wno-analyzer-fd-leak} | |
10558 | to disable it. | |
10559 | ||
10560 | This diagnostic warns for paths through code in which an | |
10561 | open file descriptor is leaked. | |
10562 | ||
10563 | See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}. | |
10564 | ||
86a90006 DM |
10565 | @opindex Wanalyzer-fd-phase-mismatch |
10566 | @opindex Wno-analyzer-fd-phase-mismatch | |
ddf6fe37 | 10567 | @item -Wno-analyzer-fd-phase-mismatch |
86a90006 DM |
10568 | This warning requires @option{-fanalyzer}, which enables it; use |
10569 | @option{-Wno-analyzer-fd-phase-mismatch} | |
10570 | to disable it. | |
10571 | ||
10572 | This diagnostic warns for paths through code in which an operation is | |
10573 | attempted in the wrong phase of a file descriptor's lifetime. | |
10574 | For example, it will warn on attempts to call @code{accept} on a stream | |
10575 | socket that has not yet had @code{listen} successfully called on it. | |
10576 | ||
10577 | See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}. | |
10578 | ||
86a90006 DM |
10579 | @opindex Wanalyzer-fd-type-mismatch |
10580 | @opindex Wno-analyzer-fd-type-mismatch | |
ddf6fe37 | 10581 | @item -Wno-analyzer-fd-type-mismatch |
86a90006 DM |
10582 | This warning requires @option{-fanalyzer}, which enables it; use |
10583 | @option{-Wno-analyzer-fd-type-mismatch} | |
10584 | to disable it. | |
10585 | ||
10586 | This diagnostic warns for paths through code in which an | |
10587 | operation is attempted on the wrong type of file descriptor. | |
10588 | For example, it will warn on attempts to use socket operations | |
10589 | on a file descriptor obtained via @code{open}, or when attempting | |
10590 | to use a stream socket operation on a datagram socket. | |
10591 | ||
d77de738 ML |
10592 | @opindex Wanalyzer-fd-use-after-close |
10593 | @opindex Wno-analyzer-fd-use-after-close | |
ddf6fe37 | 10594 | @item -Wno-analyzer-fd-use-after-close |
d77de738 ML |
10595 | This warning requires @option{-fanalyzer}, which enables it; use |
10596 | @option{-Wno-analyzer-fd-use-after-close} | |
10597 | to disable it. | |
10598 | ||
10599 | This diagnostic warns for paths through code in which a | |
10600 | read or write is called on a closed file descriptor. | |
10601 | ||
10602 | This diagnostic also warns for paths through code in which | |
10603 | a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)} | |
10604 | or @code{fd_arg_write (N)} is called with a closed file descriptor at | |
10605 | referenced argument @code{N}. | |
10606 | ||
d77de738 ML |
10607 | @opindex Wanalyzer-fd-use-without-check |
10608 | @opindex Wno-analyzer-fd-use-without-check | |
ddf6fe37 | 10609 | @item -Wno-analyzer-fd-use-without-check |
d77de738 ML |
10610 | This warning requires @option{-fanalyzer}, which enables it; use |
10611 | @option{-Wno-analyzer-fd-use-without-check} | |
10612 | to disable it. | |
10613 | ||
10614 | This diagnostic warns for paths through code in which a | |
10615 | file descriptor is used without being checked for validity. | |
10616 | ||
10617 | This diagnostic also warns for paths through code in which | |
10618 | a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)} | |
10619 | or @code{fd_arg_write (N)} is called with a file descriptor, at referenced | |
10620 | argument @code{N}, without being checked for validity. | |
10621 | ||
d77de738 ML |
10622 | @opindex Wanalyzer-file-leak |
10623 | @opindex Wno-analyzer-file-leak | |
ddf6fe37 | 10624 | @item -Wno-analyzer-file-leak |
d77de738 ML |
10625 | This warning requires @option{-fanalyzer}, which enables it; use |
10626 | @option{-Wno-analyzer-file-leak} | |
10627 | to disable it. | |
10628 | ||
10629 | This diagnostic warns for paths through the code in which a | |
10630 | @code{<stdio.h>} @code{FILE *} stream object is leaked. | |
10631 | ||
10632 | See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}. | |
10633 | ||
d77de738 ML |
10634 | @opindex Wanalyzer-free-of-non-heap |
10635 | @opindex Wno-analyzer-free-of-non-heap | |
ddf6fe37 | 10636 | @item -Wno-analyzer-free-of-non-heap |
d77de738 ML |
10637 | This warning requires @option{-fanalyzer}, which enables it; use |
10638 | @option{-Wno-analyzer-free-of-non-heap} | |
10639 | to disable it. | |
10640 | ||
10641 | This diagnostic warns for paths through the code in which @code{free} | |
10642 | is called on a non-heap pointer (e.g. an on-stack buffer, or a global). | |
10643 | ||
10644 | See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}. | |
10645 | ||
d77de738 ML |
10646 | @opindex Wanalyzer-imprecise-fp-arithmetic |
10647 | @opindex Wno-analyzer-imprecise-fp-arithmetic | |
ddf6fe37 | 10648 | @item -Wno-analyzer-imprecise-fp-arithmetic |
d77de738 ML |
10649 | This warning requires @option{-fanalyzer}, which enables it; use |
10650 | @option{-Wno-analyzer-imprecise-fp-arithmetic} | |
10651 | to disable it. | |
10652 | ||
10653 | This diagnostic warns for paths through the code in which floating-point | |
10654 | arithmetic is used in locations where precise computation is needed. This | |
10655 | diagnostic only warns on use of floating-point operands inside the | |
10656 | calculation of an allocation size at the moment. | |
10657 | ||
ce51e843 ML |
10658 | @opindex Wanalyzer-infinite-recursion |
10659 | @opindex Wno-analyzer-infinite-recursion | |
ddf6fe37 | 10660 | @item -Wno-analyzer-infinite-recursion |
ce51e843 ML |
10661 | This warning requires @option{-fanalyzer}, which enables it; use |
10662 | @option{-Wno-analyzer-infinite-recursion} to disable it. | |
10663 | ||
10664 | This diagnostics warns for paths through the code which appear to | |
10665 | lead to infinite recursion. | |
10666 | ||
10667 | Specifically, when the analyzer "sees" a recursive call, it will compare | |
10668 | the state of memory at the entry to the new frame with that at the entry | |
10669 | to the previous frame of that function on the stack. The warning is | |
10670 | issued if nothing in memory appears to be changing; any changes observed | |
10671 | to parameters or globals are assumed to lead to termination of the | |
10672 | recursion and thus suppress the warning. | |
10673 | ||
10674 | This diagnostic is likely to miss cases of infinite recursion that | |
10675 | are convered to iteration by the optimizer before the analyzer "sees" | |
10676 | them. Hence optimization should be disabled when attempting to trigger | |
10677 | this diagnostic. | |
10678 | ||
10679 | Compare with @option{-Winfinite-recursion}, which provides a similar | |
10680 | diagnostic, but is implemented in a different way. | |
10681 | ||
d77de738 ML |
10682 | @opindex Wanalyzer-jump-through-null |
10683 | @opindex Wno-analyzer-jump-through-null | |
ddf6fe37 | 10684 | @item -Wno-analyzer-jump-through-null |
d77de738 ML |
10685 | This warning requires @option{-fanalyzer}, which enables it; use |
10686 | @option{-Wno-analyzer-jump-through-null} | |
10687 | to disable it. | |
10688 | ||
10689 | This diagnostic warns for paths through the code in which a @code{NULL} | |
10690 | function pointer is called. | |
10691 | ||
d77de738 ML |
10692 | @opindex Wanalyzer-malloc-leak |
10693 | @opindex Wno-analyzer-malloc-leak | |
ddf6fe37 | 10694 | @item -Wno-analyzer-malloc-leak |
d77de738 ML |
10695 | This warning requires @option{-fanalyzer}, which enables it; use |
10696 | @option{-Wno-analyzer-malloc-leak} | |
10697 | to disable it. | |
10698 | ||
10699 | This diagnostic warns for paths through the code in which a | |
10700 | pointer allocated via an allocator is leaked: either @code{malloc}, | |
10701 | or a function marked with attribute @code{malloc}. | |
10702 | ||
10703 | See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}. | |
10704 | ||
d77de738 ML |
10705 | @opindex Wanalyzer-mismatching-deallocation |
10706 | @opindex Wno-analyzer-mismatching-deallocation | |
ddf6fe37 | 10707 | @item -Wno-analyzer-mismatching-deallocation |
d77de738 ML |
10708 | This warning requires @option{-fanalyzer}, which enables it; use |
10709 | @option{-Wno-analyzer-mismatching-deallocation} | |
10710 | to disable it. | |
10711 | ||
10712 | This diagnostic warns for paths through the code in which the | |
10713 | wrong deallocation function is called on a pointer value, based on | |
10714 | which function was used to allocate the pointer value. The diagnostic | |
10715 | will warn about mismatches between @code{free}, scalar @code{delete} | |
10716 | and vector @code{delete[]}, and those marked as allocator/deallocator | |
10717 | pairs using attribute @code{malloc}. | |
10718 | ||
10719 | See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}. | |
10720 | ||
d77de738 ML |
10721 | @opindex Wanalyzer-out-of-bounds |
10722 | @opindex Wno-analyzer-out-of-bounds | |
ddf6fe37 | 10723 | @item -Wno-analyzer-out-of-bounds |
4ace81b6 | 10724 | This warning requires @option{-fanalyzer}, which enables it; use |
d77de738 ML |
10725 | @option{-Wno-analyzer-out-of-bounds} to disable it. |
10726 | ||
4ace81b6 | 10727 | This diagnostic warns for paths through the code in which a buffer is |
d77de738 ML |
10728 | definitely read or written out-of-bounds. The diagnostic applies for |
10729 | cases where the analyzer is able to determine a constant offset and for | |
10730 | accesses past the end of a buffer, also a constant capacity. Further, | |
10731 | the diagnostic does limited checking for accesses past the end when the | |
10732 | offset as well as the capacity is symbolic. | |
10733 | ||
10734 | See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}. | |
10735 | ||
0e466e97 DM |
10736 | For cases where the analyzer is able, it will emit a text art diagram |
10737 | visualizing the spatial relationship between the memory region that the | |
10738 | analyzer predicts would be accessed, versus the range of memory that is | |
10739 | valid to access: whether they overlap, are touching, are close or far | |
10740 | apart; which one is before or after in memory, the relative sizes | |
10741 | involved, the direction of the access (read vs write), and, in some | |
10742 | cases, the values of data involved. This diagram can be suppressed | |
10743 | using @option{-fdiagnostics-text-art-charset=none}. | |
10744 | ||
034d99e8 DM |
10745 | @opindex Wanalyzer-overlapping-buffers |
10746 | @opindex Wno-analyzer-overlapping-buffers | |
10747 | @item -Wno-analyzer-overlapping-buffers | |
10748 | This warning requires @option{-fanalyzer}, which enables it; use | |
10749 | @option{-Wno-analyzer-overlapping-buffers} to disable it. | |
10750 | ||
10751 | This diagnostic warns for paths through the code in which overlapping | |
10752 | buffers are passed to an API for which the behavior on such buffers | |
10753 | is undefined. | |
10754 | ||
10755 | Specifically, the diagnostic occurs on calls to the following functions | |
10756 | @itemize @bullet | |
10757 | @item @code{memcpy} | |
10758 | @item @code{strcat} | |
10759 | @item @code{strcpy} | |
10760 | @end itemize | |
10761 | for cases where the buffers are known to overlap. | |
10762 | ||
d77de738 ML |
10763 | @opindex Wanalyzer-possible-null-argument |
10764 | @opindex Wno-analyzer-possible-null-argument | |
ddf6fe37 | 10765 | @item -Wno-analyzer-possible-null-argument |
d77de738 ML |
10766 | This warning requires @option{-fanalyzer}, which enables it; use |
10767 | @option{-Wno-analyzer-possible-null-argument} to disable it. | |
10768 | ||
10769 | This diagnostic warns for paths through the code in which a | |
10770 | possibly-NULL value 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/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}. | |
10775 | ||
d77de738 ML |
10776 | @opindex Wanalyzer-possible-null-dereference |
10777 | @opindex Wno-analyzer-possible-null-dereference | |
ddf6fe37 | 10778 | @item -Wno-analyzer-possible-null-dereference |
d77de738 ML |
10779 | This warning requires @option{-fanalyzer}, which enables it; use |
10780 | @option{-Wno-analyzer-possible-null-dereference} to disable it. | |
10781 | ||
10782 | This diagnostic warns for paths through the code in which a | |
10783 | possibly-NULL value is dereferenced. | |
10784 | ||
10785 | See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}. | |
10786 | ||
d77de738 ML |
10787 | @opindex Wanalyzer-null-argument |
10788 | @opindex Wno-analyzer-null-argument | |
ddf6fe37 | 10789 | @item -Wno-analyzer-null-argument |
d77de738 ML |
10790 | This warning requires @option{-fanalyzer}, which enables it; use |
10791 | @option{-Wno-analyzer-null-argument} to disable it. | |
10792 | ||
10793 | This diagnostic warns for paths through the code in which a | |
10794 | value known to be NULL is passed to a function argument marked | |
10795 | with @code{__attribute__((nonnull))} as requiring a non-NULL | |
10796 | value. | |
10797 | ||
10798 | See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}. | |
10799 | ||
d77de738 ML |
10800 | @opindex Wanalyzer-null-dereference |
10801 | @opindex Wno-analyzer-null-dereference | |
ddf6fe37 | 10802 | @item -Wno-analyzer-null-dereference |
d77de738 ML |
10803 | This warning requires @option{-fanalyzer}, which enables it; use |
10804 | @option{-Wno-analyzer-null-dereference} to disable it. | |
10805 | ||
10806 | This diagnostic warns for paths through the code in which a | |
10807 | value known to be NULL is dereferenced. | |
10808 | ||
10809 | See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}. | |
10810 | ||
d77de738 ML |
10811 | @opindex Wanalyzer-putenv-of-auto-var |
10812 | @opindex Wno-analyzer-putenv-of-auto-var | |
ddf6fe37 | 10813 | @item -Wno-analyzer-putenv-of-auto-var |
d77de738 ML |
10814 | This warning requires @option{-fanalyzer}, which enables it; use |
10815 | @option{-Wno-analyzer-putenv-of-auto-var} to disable it. | |
10816 | ||
10817 | This diagnostic warns for paths through the code in which a | |
10818 | call to @code{putenv} is passed a pointer to an automatic variable | |
10819 | or an on-stack buffer. | |
10820 | ||
10821 | 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}. | |
10822 | ||
d77de738 ML |
10823 | @opindex Wanalyzer-shift-count-negative |
10824 | @opindex Wno-analyzer-shift-count-negative | |
ddf6fe37 | 10825 | @item -Wno-analyzer-shift-count-negative |
d77de738 ML |
10826 | This warning requires @option{-fanalyzer}, which enables it; use |
10827 | @option{-Wno-analyzer-shift-count-negative} to disable it. | |
10828 | ||
10829 | This diagnostic warns for paths through the code in which a | |
10830 | shift is attempted with a negative count. It is analogous to | |
10831 | the @option{-Wshift-count-negative} diagnostic implemented in | |
10832 | the C/C++ front ends, but is implemented based on analyzing | |
10833 | interprocedural paths, rather than merely parsing the syntax tree. | |
10834 | However, the analyzer does not prioritize detection of such paths, so | |
10835 | false negatives are more likely relative to other warnings. | |
10836 | ||
d77de738 ML |
10837 | @opindex Wanalyzer-shift-count-overflow |
10838 | @opindex Wno-analyzer-shift-count-overflow | |
ddf6fe37 | 10839 | @item -Wno-analyzer-shift-count-overflow |
d77de738 ML |
10840 | This warning requires @option{-fanalyzer}, which enables it; use |
10841 | @option{-Wno-analyzer-shift-count-overflow} to disable it. | |
10842 | ||
10843 | This diagnostic warns for paths through the code in which a | |
10844 | shift is attempted with a count greater than or equal to the | |
10845 | precision of the operand's type. It is analogous to | |
10846 | the @option{-Wshift-count-overflow} diagnostic implemented in | |
10847 | the C/C++ front ends, but is implemented based on analyzing | |
10848 | interprocedural paths, rather than merely parsing the syntax tree. | |
10849 | However, the analyzer does not prioritize detection of such paths, so | |
10850 | false negatives are more likely relative to other warnings. | |
10851 | ||
d77de738 ML |
10852 | @opindex Wanalyzer-stale-setjmp-buffer |
10853 | @opindex Wno-analyzer-stale-setjmp-buffer | |
ddf6fe37 | 10854 | @item -Wno-analyzer-stale-setjmp-buffer |
d77de738 ML |
10855 | This warning requires @option{-fanalyzer}, which enables it; use |
10856 | @option{-Wno-analyzer-stale-setjmp-buffer} to disable it. | |
10857 | ||
10858 | This diagnostic warns for paths through the code in which | |
10859 | @code{longjmp} is called to rewind to a @code{jmp_buf} relating | |
10860 | to a @code{setjmp} call in a function that has returned. | |
10861 | ||
10862 | When @code{setjmp} is called on a @code{jmp_buf} to record a rewind | |
10863 | location, it records the stack frame. The stack frame becomes invalid | |
10864 | when the function containing the @code{setjmp} call returns. Attempting | |
10865 | to rewind to it via @code{longjmp} would reference a stack frame that | |
10866 | no longer exists, and likely lead to a crash (or worse). | |
10867 | ||
d77de738 ML |
10868 | @opindex Wanalyzer-tainted-allocation-size |
10869 | @opindex Wno-analyzer-tainted-allocation-size | |
ddf6fe37 | 10870 | @item -Wno-analyzer-tainted-allocation-size |
d77de738 ML |
10871 | This warning requires both @option{-fanalyzer} and |
10872 | @option{-fanalyzer-checker=taint} to enable it; | |
10873 | use @option{-Wno-analyzer-tainted-allocation-size} to disable it. | |
10874 | ||
10875 | This diagnostic warns for paths through the code in which a value | |
10876 | that could be under an attacker's control is used as the size | |
10877 | of an allocation without being sanitized, so that an attacker could | |
10878 | inject an excessively large allocation and potentially cause a denial | |
10879 | of service attack. | |
10880 | ||
10881 | See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}. | |
10882 | ||
ce51e843 ML |
10883 | @opindex Wanalyzer-tainted-assertion |
10884 | @opindex Wno-analyzer-tainted-assertion | |
ddf6fe37 | 10885 | @item -Wno-analyzer-tainted-assertion |
ce51e843 ML |
10886 | |
10887 | This warning requires both @option{-fanalyzer} and | |
10888 | @option{-fanalyzer-checker=taint} to enable it; | |
10889 | use @option{-Wno-analyzer-tainted-assertion} to disable it. | |
10890 | ||
10891 | This diagnostic warns for paths through the code in which a value | |
10892 | that could be under an attacker's control is used as part of a | |
10893 | condition without being first sanitized, and that condition guards a | |
10894 | call to a function marked with attribute @code{noreturn} | |
10895 | (such as the function @code{__builtin_unreachable}). Such functions | |
10896 | typically indicate abnormal termination of the program, such as for | |
10897 | assertion failure handlers. For example: | |
10898 | ||
10899 | @smallexample | |
10900 | assert (some_tainted_value < SOME_LIMIT); | |
10901 | @end smallexample | |
10902 | ||
10903 | In such cases: | |
10904 | ||
10905 | @itemize | |
10906 | @item | |
10907 | when assertion-checking is enabled: an attacker could trigger | |
10908 | a denial of service by injecting an assertion failure | |
10909 | ||
10910 | @item | |
10911 | when assertion-checking is disabled, such as by defining @code{NDEBUG}, | |
10912 | an attacker could inject data that subverts the process, since it | |
10913 | presumably violates a precondition that is being assumed by the code. | |
10914 | ||
10915 | @end itemize | |
10916 | ||
10917 | Note that when assertion-checking is disabled, the assertions are | |
10918 | typically removed by the preprocessor before the analyzer has a chance | |
10919 | to "see" them, so this diagnostic can only generate warnings on builds | |
10920 | in which assertion-checking is enabled. | |
10921 | ||
10922 | For the purpose of this warning, any function marked with attribute | |
10923 | @code{noreturn} is considered as a possible assertion failure | |
10924 | handler, including @code{__builtin_unreachable}. Note that these functions | |
10925 | are sometimes removed by the optimizer before the analyzer "sees" them. | |
10926 | Hence optimization should be disabled when attempting to trigger this | |
10927 | diagnostic. | |
10928 | ||
10929 | See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}. | |
10930 | ||
10931 | The warning can also report problematic constructions such as | |
10932 | ||
10933 | @smallexample | |
10934 | switch (some_tainted_value) @{ | |
10935 | case 0: | |
10936 | /* [...etc; various valid cases omitted...] */ | |
10937 | break; | |
10938 | ||
10939 | default: | |
10940 | __builtin_unreachable (); /* BUG: attacker can trigger this */ | |
10941 | @} | |
10942 | @end smallexample | |
10943 | ||
10944 | despite the above not being an assertion failure, strictly speaking. | |
10945 | ||
d77de738 ML |
10946 | @opindex Wanalyzer-tainted-array-index |
10947 | @opindex Wno-analyzer-tainted-array-index | |
ddf6fe37 | 10948 | @item -Wno-analyzer-tainted-array-index |
d77de738 ML |
10949 | This warning requires both @option{-fanalyzer} and |
10950 | @option{-fanalyzer-checker=taint} to enable it; | |
10951 | use @option{-Wno-analyzer-tainted-array-index} to disable it. | |
10952 | ||
10953 | This diagnostic warns for paths through the code in which a value | |
10954 | that could be under an attacker's control is used as the index | |
10955 | of an array access without being sanitized, so that an attacker | |
10956 | could inject an out-of-bounds access. | |
10957 | ||
10958 | See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}. | |
10959 | ||
d77de738 ML |
10960 | @opindex Wanalyzer-tainted-divisor |
10961 | @opindex Wno-analyzer-tainted-divisor | |
ddf6fe37 | 10962 | @item -Wno-analyzer-tainted-divisor |
d77de738 ML |
10963 | This warning requires both @option{-fanalyzer} and |
10964 | @option{-fanalyzer-checker=taint} to enable it; | |
10965 | use @option{-Wno-analyzer-tainted-divisor} to disable it. | |
10966 | ||
10967 | This diagnostic warns for paths through the code in which a value | |
10968 | that could be under an attacker's control is used as the divisor | |
10969 | in a division or modulus operation without being sanitized, so that | |
10970 | an attacker could inject a division-by-zero. | |
10971 | ||
10972 | See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}. | |
10973 | ||
d77de738 ML |
10974 | @opindex Wanalyzer-tainted-offset |
10975 | @opindex Wno-analyzer-tainted-offset | |
ddf6fe37 | 10976 | @item -Wno-analyzer-tainted-offset |
d77de738 ML |
10977 | This warning requires both @option{-fanalyzer} and |
10978 | @option{-fanalyzer-checker=taint} to enable it; | |
10979 | use @option{-Wno-analyzer-tainted-offset} to disable it. | |
10980 | ||
10981 | This diagnostic warns for paths through the code in which a value | |
10982 | that could be under an attacker's control is used as a pointer offset | |
10983 | without being sanitized, so that an attacker could inject an out-of-bounds | |
10984 | access. | |
10985 | ||
10986 | See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}. | |
10987 | ||
d77de738 ML |
10988 | @opindex Wanalyzer-tainted-size |
10989 | @opindex Wno-analyzer-tainted-size | |
ddf6fe37 | 10990 | @item -Wno-analyzer-tainted-size |
d77de738 ML |
10991 | This warning requires both @option{-fanalyzer} and |
10992 | @option{-fanalyzer-checker=taint} to enable it; | |
10993 | use @option{-Wno-analyzer-tainted-size} to disable it. | |
10994 | ||
10995 | This diagnostic warns for paths through the code in which a value | |
10996 | that could be under an attacker's control is used as the size of | |
10997 | an operation such as @code{memset} without being sanitized, so that an | |
10998 | attacker could inject an out-of-bounds access. | |
10999 | ||
11000 | See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}. | |
11001 | ||
d77de738 ML |
11002 | @opindex Wanalyzer-unsafe-call-within-signal-handler |
11003 | @opindex Wno-analyzer-unsafe-call-within-signal-handler | |
ddf6fe37 | 11004 | @item -Wno-analyzer-unsafe-call-within-signal-handler |
d77de738 ML |
11005 | This warning requires @option{-fanalyzer}, which enables it; use |
11006 | @option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it. | |
11007 | ||
11008 | This diagnostic warns for paths through the code in which a | |
11009 | function known to be async-signal-unsafe (such as @code{fprintf}) is | |
11010 | called from a signal handler. | |
11011 | ||
11012 | See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}. | |
11013 | ||
d77de738 ML |
11014 | @opindex Wanalyzer-use-after-free |
11015 | @opindex Wno-analyzer-use-after-free | |
ddf6fe37 | 11016 | @item -Wno-analyzer-use-after-free |
d77de738 ML |
11017 | This warning requires @option{-fanalyzer}, which enables it; use |
11018 | @option{-Wno-analyzer-use-after-free} to disable it. | |
11019 | ||
11020 | This diagnostic warns for paths through the code in which a | |
11021 | pointer is used after a deallocator is called on it: either @code{free}, | |
11022 | or a deallocator referenced by attribute @code{malloc}. | |
11023 | ||
11024 | See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}. | |
11025 | ||
d77de738 ML |
11026 | @opindex Wanalyzer-use-of-pointer-in-stale-stack-frame |
11027 | @opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame | |
ddf6fe37 | 11028 | @item -Wno-analyzer-use-of-pointer-in-stale-stack-frame |
d77de738 ML |
11029 | This warning requires @option{-fanalyzer}, which enables it; use |
11030 | @option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame} | |
11031 | to disable it. | |
11032 | ||
11033 | This diagnostic warns for paths through the code in which a pointer | |
11034 | is dereferenced that points to a variable in a stale stack frame. | |
11035 | ||
d77de738 ML |
11036 | @opindex Wanalyzer-va-arg-type-mismatch |
11037 | @opindex Wno-analyzer-va-arg-type-mismatch | |
ddf6fe37 | 11038 | @item -Wno-analyzer-va-arg-type-mismatch |
d77de738 ML |
11039 | This warning requires @option{-fanalyzer}, which enables it; use |
11040 | @option{-Wno-analyzer-va-arg-type-mismatch} | |
11041 | to disable it. | |
11042 | ||
11043 | This diagnostic warns for interprocedural paths through the code for which | |
11044 | the analyzer detects an attempt to use @code{va_arg} to extract a value | |
11045 | passed to a variadic call, but uses a type that does not match that of | |
11046 | the expression passed to the call. | |
11047 | ||
11048 | See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}. | |
11049 | ||
d77de738 ML |
11050 | @opindex Wanalyzer-va-list-exhausted |
11051 | @opindex Wno-analyzer-va-list-exhausted | |
ddf6fe37 | 11052 | @item -Wno-analyzer-va-list-exhausted |
d77de738 ML |
11053 | This warning requires @option{-fanalyzer}, which enables it; use |
11054 | @option{-Wno-analyzer-va-list-exhausted} | |
11055 | to disable it. | |
11056 | ||
11057 | This diagnostic warns for interprocedural paths through the code for which | |
11058 | the analyzer detects an attempt to use @code{va_arg} to access the next | |
11059 | value passed to a variadic call, but all of the values in the | |
11060 | @code{va_list} have already been consumed. | |
11061 | ||
11062 | See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}. | |
11063 | ||
d77de738 ML |
11064 | @opindex Wanalyzer-va-list-leak |
11065 | @opindex Wno-analyzer-va-list-leak | |
ddf6fe37 | 11066 | @item -Wno-analyzer-va-list-leak |
d77de738 ML |
11067 | This warning requires @option{-fanalyzer}, which enables it; use |
11068 | @option{-Wno-analyzer-va-list-leak} | |
11069 | to disable it. | |
11070 | ||
11071 | This diagnostic warns for interprocedural paths through the code for which | |
11072 | the analyzer detects that @code{va_start} or @code{va_copy} has been called | |
11073 | on a @code{va_list} without a corresponding call to @code{va_end}. | |
11074 | ||
d77de738 ML |
11075 | @opindex Wanalyzer-va-list-use-after-va-end |
11076 | @opindex Wno-analyzer-va-list-use-after-va-end | |
ddf6fe37 | 11077 | @item -Wno-analyzer-va-list-use-after-va-end |
d77de738 ML |
11078 | This warning requires @option{-fanalyzer}, which enables it; use |
11079 | @option{-Wno-analyzer-va-list-use-after-va-end} | |
11080 | to disable it. | |
11081 | ||
11082 | This diagnostic warns for interprocedural paths through the code for which | |
11083 | the analyzer detects an attempt to use a @code{va_list} after | |
11084 | @code{va_end} has been called on it. | |
11085 | @code{va_list}. | |
11086 | ||
d77de738 ML |
11087 | @opindex Wanalyzer-write-to-const |
11088 | @opindex Wno-analyzer-write-to-const | |
ddf6fe37 | 11089 | @item -Wno-analyzer-write-to-const |
d77de738 ML |
11090 | This warning requires @option{-fanalyzer}, which enables it; use |
11091 | @option{-Wno-analyzer-write-to-const} | |
11092 | to disable it. | |
11093 | ||
11094 | This diagnostic warns for paths through the code in which the analyzer | |
11095 | detects an attempt to write through a pointer to a @code{const} object. | |
11096 | However, the analyzer does not prioritize detection of such paths, so | |
11097 | false negatives are more likely relative to other warnings. | |
11098 | ||
d77de738 ML |
11099 | @opindex Wanalyzer-write-to-string-literal |
11100 | @opindex Wno-analyzer-write-to-string-literal | |
ddf6fe37 | 11101 | @item -Wno-analyzer-write-to-string-literal |
d77de738 ML |
11102 | This warning requires @option{-fanalyzer}, which enables it; use |
11103 | @option{-Wno-analyzer-write-to-string-literal} | |
11104 | to disable it. | |
11105 | ||
11106 | This diagnostic warns for paths through the code in which the analyzer | |
11107 | detects an attempt to write through a pointer to a string literal. | |
11108 | However, the analyzer does not prioritize detection of such paths, so | |
11109 | false negatives are more likely relative to other warnings. | |
11110 | ||
d77de738 ML |
11111 | @opindex Wanalyzer-use-of-uninitialized-value |
11112 | @opindex Wno-analyzer-use-of-uninitialized-value | |
ddf6fe37 | 11113 | @item -Wno-analyzer-use-of-uninitialized-value |
d77de738 ML |
11114 | This warning requires @option{-fanalyzer}, which enables it; use |
11115 | @option{-Wno-analyzer-use-of-uninitialized-value} to disable it. | |
11116 | ||
11117 | This diagnostic warns for paths through the code in which an uninitialized | |
11118 | value is used. | |
11119 | ||
11120 | See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}. | |
11121 | ||
11122 | @end table | |
11123 | ||
11124 | The analyzer has hardcoded knowledge about the behavior of the following | |
11125 | memory-management functions: | |
11126 | ||
11127 | @itemize @bullet | |
11128 | @item @code{alloca} | |
11129 | @item The built-in functions @code{__builtin_alloc}, | |
11130 | @code{__builtin_alloc_with_align}, @item @code{__builtin_calloc}, | |
11131 | @code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy}, | |
11132 | @code{__builtin_memcpy_chk}, @code{__builtin_memset}, | |
11133 | @code{__builtin_memset_chk}, @code{__builtin_realloc}, | |
11134 | @code{__builtin_stack_restore}, and @code{__builtin_stack_save} | |
11135 | @item @code{calloc} | |
11136 | @item @code{free} | |
11137 | @item @code{malloc} | |
11138 | @item @code{memset} | |
11139 | @item @code{operator delete} | |
11140 | @item @code{operator delete []} | |
11141 | @item @code{operator new} | |
11142 | @item @code{operator new []} | |
11143 | @item @code{realloc} | |
11144 | @item @code{strdup} | |
11145 | @item @code{strndup} | |
11146 | @end itemize | |
11147 | ||
4ace81b6 | 11148 | @noindent |
d77de738 ML |
11149 | of the following functions for working with file descriptors: |
11150 | ||
11151 | @itemize @bullet | |
11152 | @item @code{open} | |
11153 | @item @code{close} | |
11154 | @item @code{creat} | |
11155 | @item @code{dup}, @code{dup2} and @code{dup3} | |
78a17f44 | 11156 | @item @code{isatty} |
d77de738 ML |
11157 | @item @code{pipe}, and @code{pipe2} |
11158 | @item @code{read} | |
11159 | @item @code{write} | |
86a90006 | 11160 | @item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect} |
d77de738 ML |
11161 | @end itemize |
11162 | ||
4ace81b6 | 11163 | @noindent |
d77de738 ML |
11164 | of the following functions for working with @code{<stdio.h>} streams: |
11165 | @itemize @bullet | |
11166 | @item The built-in functions @code{__builtin_fprintf}, | |
11167 | @code{__builtin_fprintf_unlocked}, @code{__builtin_fputc}, | |
11168 | @code{__builtin_fputc_unlocked}, @code{__builtin_fputs}, | |
11169 | @code{__builtin_fputs_unlocked}, @code{__builtin_fwrite}, | |
11170 | @code{__builtin_fwrite_unlocked}, @code{__builtin_printf}, | |
11171 | @code{__builtin_printf_unlocked}, @code{__builtin_putc}, | |
11172 | @code{__builtin_putchar}, @code{__builtin_putchar_unlocked}, | |
11173 | @code{__builtin_putc_unlocked}, @code{__builtin_puts}, | |
11174 | @code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and | |
11175 | @code{__builtin_vprintf} | |
11176 | @item @code{fopen} | |
11177 | @item @code{fclose} | |
78a17f44 | 11178 | @item @code{ferror} |
d77de738 ML |
11179 | @item @code{fgets} |
11180 | @item @code{fgets_unlocked} | |
78a17f44 | 11181 | @item @code{fileno} |
d77de738 | 11182 | @item @code{fread} |
78a17f44 | 11183 | @item @code{getc} |
d77de738 ML |
11184 | @item @code{getchar} |
11185 | @item @code{fprintf} | |
11186 | @item @code{printf} | |
11187 | @item @code{fwrite} | |
11188 | @end itemize | |
11189 | ||
4ace81b6 | 11190 | @noindent |
d77de738 ML |
11191 | and of the following functions: |
11192 | ||
11193 | @itemize @bullet | |
11194 | @item The built-in functions @code{__builtin_expect}, | |
11195 | @code{__builtin_expect_with_probability}, @code{__builtin_strchr}, | |
11196 | @code{__builtin_strcpy}, @code{__builtin_strcpy_chk}, | |
11197 | @code{__builtin_strlen}, @code{__builtin_va_copy}, and | |
11198 | @code{__builtin_va_start} | |
11199 | @item The GNU extensions @code{error} and @code{error_at_line} | |
11200 | @item @code{getpass} | |
11201 | @item @code{longjmp} | |
11202 | @item @code{putenv} | |
11203 | @item @code{setjmp} | |
11204 | @item @code{siglongjmp} | |
11205 | @item @code{signal} | |
11206 | @item @code{sigsetjmp} | |
bbdc0e0d | 11207 | @item @code{strcat} |
d77de738 ML |
11208 | @item @code{strchr} |
11209 | @item @code{strlen} | |
11210 | @end itemize | |
11211 | ||
11212 | In addition, various functions with an @code{__analyzer_} prefix have | |
11213 | special meaning to the analyzer, described in the GCC Internals manual. | |
11214 | ||
11215 | Pertinent parameters for controlling the exploration are: | |
4ace81b6 SL |
11216 | @itemize @bullet |
11217 | @item @option{--param analyzer-bb-explosion-factor=@var{value}} | |
11218 | @item @option{--param analyzer-max-enodes-per-program-point=@var{value}} | |
11219 | @item @option{--param analyzer-max-recursion-depth=@var{value}} | |
11220 | @item @option{--param analyzer-min-snodes-for-call-summary=@var{value}} | |
11221 | @end itemize | |
d77de738 ML |
11222 | |
11223 | The following options control the analyzer. | |
11224 | ||
11225 | @table @gcctabopt | |
11226 | ||
d77de738 ML |
11227 | @opindex fanalyzer-call-summaries |
11228 | @opindex fno-analyzer-call-summaries | |
ddf6fe37 | 11229 | @item -fanalyzer-call-summaries |
d77de738 ML |
11230 | Simplify interprocedural analysis by computing the effect of certain calls, |
11231 | rather than exploring all paths through the function from callsite to each | |
11232 | possible return. | |
11233 | ||
11234 | If enabled, call summaries are only used for functions with more than one | |
11235 | call site, and that are sufficiently complicated (as per | |
11236 | @option{--param analyzer-min-snodes-for-call-summary=@var{value}}). | |
11237 | ||
d77de738 | 11238 | @opindex fanalyzer-checker |
ddf6fe37 | 11239 | @item -fanalyzer-checker=@var{name} |
d77de738 ML |
11240 | Restrict the analyzer to run just the named checker, and enable it. |
11241 | ||
11242 | Some checkers are disabled by default (even with @option{-fanalyzer}), | |
11243 | such as the @code{taint} checker that implements | |
11244 | @option{-Wanalyzer-tainted-array-index}, and this option is required | |
11245 | to enable them. | |
11246 | ||
11247 | @emph{Note:} currently, @option{-fanalyzer-checker=taint} disables the | |
11248 | following warnings from @option{-fanalyzer}: | |
11249 | ||
43b72ede AA |
11250 | @gccoptlist{ |
11251 | -Wanalyzer-deref-before-check | |
11252 | -Wanalyzer-double-fclose | |
11253 | -Wanalyzer-double-free | |
11254 | -Wanalyzer-exposure-through-output-file | |
11255 | -Wanalyzer-fd-access-mode-mismatch | |
11256 | -Wanalyzer-fd-double-close | |
11257 | -Wanalyzer-fd-leak | |
11258 | -Wanalyzer-fd-use-after-close | |
11259 | -Wanalyzer-fd-use-without-check | |
11260 | -Wanalyzer-file-leak | |
11261 | -Wanalyzer-free-of-non-heap | |
11262 | -Wanalyzer-malloc-leak | |
11263 | -Wanalyzer-mismatching-deallocation | |
11264 | -Wanalyzer-null-argument | |
11265 | -Wanalyzer-null-dereference | |
11266 | -Wanalyzer-possible-null-argument | |
11267 | -Wanalyzer-possible-null-dereference | |
11268 | -Wanalyzer-unsafe-call-within-signal-handler | |
11269 | -Wanalyzer-use-after-free | |
11270 | -Wanalyzer-va-list-leak | |
11271 | -Wanalyzer-va-list-use-after-va-end | |
d77de738 ML |
11272 | } |
11273 | ||
0e466e97 DM |
11274 | @opindex fanalyzer-debug-text-art |
11275 | @opindex fno-analyzer-debug-text-art | |
11276 | @item -fanalyzer-debug-text-art-headings | |
11277 | This option is intended for analyzer developers. If enabled, | |
11278 | the analyzer will add extra annotations to any diagrams it generates. | |
11279 | ||
d77de738 ML |
11280 | @opindex fanalyzer-feasibility |
11281 | @opindex fno-analyzer-feasibility | |
ddf6fe37 | 11282 | @item -fno-analyzer-feasibility |
d77de738 ML |
11283 | This option is intended for analyzer developers. |
11284 | ||
11285 | By default the analyzer verifies that there is a feasible control flow path | |
11286 | for each diagnostic it emits: that the conditions that hold are not mutually | |
11287 | exclusive. Diagnostics for which no feasible path can be found are rejected. | |
11288 | This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for | |
11289 | debugging issues in this code. | |
11290 | ||
d77de738 ML |
11291 | @opindex fanalyzer-fine-grained |
11292 | @opindex fno-analyzer-fine-grained | |
ddf6fe37 | 11293 | @item -fanalyzer-fine-grained |
d77de738 ML |
11294 | This option is intended for analyzer developers. |
11295 | ||
11296 | Internally the analyzer builds an ``exploded graph'' that combines | |
11297 | control flow graphs with data flow information. | |
11298 | ||
11299 | By default, an edge in this graph can contain the effects of a run | |
11300 | of multiple statements within a basic block. With | |
11301 | @option{-fanalyzer-fine-grained}, each statement gets its own edge. | |
11302 | ||
d77de738 ML |
11303 | @opindex fanalyzer-show-duplicate-count |
11304 | @opindex fno-analyzer-show-duplicate-count | |
ddf6fe37 | 11305 | @item -fanalyzer-show-duplicate-count |
d77de738 ML |
11306 | This option is intended for analyzer developers: if multiple diagnostics |
11307 | have been detected as being duplicates of each other, it emits a note when | |
11308 | reporting the best diagnostic, giving the number of additional diagnostics | |
11309 | that were suppressed by the deduplication logic. | |
11310 | ||
ce8cdf5b | 11311 | @opindex fanalyzer-show-events-in-system-headers |
11312 | @opindex fno-analyzer-show-events-in-system-headers | |
11313 | @item -fanalyzer-show-events-in-system-headers | |
11314 | By default the analyzer emits simplified diagnostics paths by hiding | |
11315 | events fully located within a system header. | |
11316 | With @option{-fanalyzer-show-events-in-system-headers} such | |
11317 | events are no longer suppressed. | |
11318 | ||
d77de738 ML |
11319 | @opindex fanalyzer-state-merge |
11320 | @opindex fno-analyzer-state-merge | |
ddf6fe37 | 11321 | @item -fno-analyzer-state-merge |
d77de738 ML |
11322 | This option is intended for analyzer developers. |
11323 | ||
11324 | By default the analyzer attempts to simplify analysis by merging | |
11325 | sufficiently similar states at each program point as it builds its | |
11326 | ``exploded graph''. With @option{-fno-analyzer-state-merge} this | |
11327 | merging can be suppressed, for debugging state-handling issues. | |
11328 | ||
d77de738 ML |
11329 | @opindex fanalyzer-state-purge |
11330 | @opindex fno-analyzer-state-purge | |
ddf6fe37 | 11331 | @item -fno-analyzer-state-purge |
d77de738 ML |
11332 | This option is intended for analyzer developers. |
11333 | ||
11334 | By default the analyzer attempts to simplify analysis by purging | |
11335 | aspects of state at a program point that appear to no longer be relevant | |
11336 | e.g. the values of locals that aren't accessed later in the function | |
11337 | and which aren't relevant to leak analysis. | |
11338 | ||
11339 | With @option{-fno-analyzer-state-purge} this purging of state can | |
11340 | be suppressed, for debugging state-handling issues. | |
11341 | ||
8f636915 DM |
11342 | @opindex fanalyzer-suppress-followups |
11343 | @opindex fno-analyzer-suppress-followups | |
f33d7a88 | 11344 | @item -fno-analyzer-suppress-followups |
8f636915 DM |
11345 | This option is intended for analyzer developers. |
11346 | ||
11347 | By default the analyzer will stop exploring an execution path after | |
11348 | encountering certain diagnostics, in order to avoid potentially issuing a | |
11349 | cascade of follow-up diagnostics. | |
11350 | ||
11351 | The diagnostics that terminate analysis along a path are: | |
11352 | ||
11353 | @itemize | |
11354 | @item @option{-Wanalyzer-null-argument} | |
11355 | @item @option{-Wanalyzer-null-dereference} | |
11356 | @item @option{-Wanalyzer-use-after-free} | |
11357 | @item @option{-Wanalyzer-use-of-pointer-in-stale-stack-frame} | |
11358 | @item @option{-Wanalyzer-use-of-uninitialized-value} | |
11359 | @end itemize | |
11360 | ||
11361 | With @option{-fno-analyzer-suppress-followups} the analyzer will | |
11362 | continue to explore such paths even after such diagnostics, which may | |
11363 | be helpful for debugging issues in the analyzer, or for microbenchmarks | |
11364 | for detecting undefined behavior. | |
11365 | ||
d77de738 ML |
11366 | @opindex fanalyzer-transitivity |
11367 | @opindex fno-analyzer-transitivity | |
ddf6fe37 | 11368 | @item -fanalyzer-transitivity |
d77de738 ML |
11369 | This option enables transitivity of constraints within the analyzer. |
11370 | ||
d77de738 ML |
11371 | @opindex fanalyzer-undo-inlining |
11372 | @opindex fno-analyzer-undo-inlining | |
ddf6fe37 | 11373 | @item -fno-analyzer-undo-inlining |
d77de738 ML |
11374 | This option is intended for analyzer developers. |
11375 | ||
11376 | @option{-fanalyzer} runs relatively late compared to other code analysis | |
11377 | tools, and some optimizations have already been applied to the code. In | |
11378 | particular function inlining may have occurred, leading to the | |
11379 | interprocedural execution paths emitted by the analyzer containing | |
11380 | function frames that don't correspond to those in the original source | |
11381 | code. | |
11382 | ||
11383 | By default the analyzer attempts to reconstruct the original function | |
11384 | frames, and to emit events showing the inlined calls. | |
11385 | ||
11386 | With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct | |
11387 | the original frame information can be be disabled, which may be of help | |
11388 | when debugging issues in the analyzer. | |
11389 | ||
11390 | @item -fanalyzer-verbose-edges | |
11391 | This option is intended for analyzer developers. It enables more | |
11392 | verbose, lower-level detail in the descriptions of control flow | |
11393 | within diagnostic paths. | |
11394 | ||
11395 | @item -fanalyzer-verbose-state-changes | |
11396 | This option is intended for analyzer developers. It enables more | |
11397 | verbose, lower-level detail in the descriptions of events relating | |
11398 | to state machines within diagnostic paths. | |
11399 | ||
11400 | @item -fanalyzer-verbosity=@var{level} | |
11401 | This option controls the complexity of the control flow paths that are | |
11402 | emitted for analyzer diagnostics. | |
11403 | ||
11404 | The @var{level} can be one of: | |
11405 | ||
11406 | @table @samp | |
11407 | @item 0 | |
11408 | At this level, interprocedural call and return events are displayed, | |
11409 | along with the most pertinent state-change events relating to | |
11410 | a diagnostic. For example, for a double-@code{free} diagnostic, | |
11411 | both calls to @code{free} will be shown. | |
11412 | ||
11413 | @item 1 | |
11414 | As per the previous level, but also show events for the entry | |
11415 | to each function. | |
11416 | ||
11417 | @item 2 | |
11418 | As per the previous level, but also show events relating to | |
11419 | control flow that are significant to triggering the issue | |
11420 | (e.g. ``true path taken'' at a conditional). | |
11421 | ||
11422 | This level is the default. | |
11423 | ||
11424 | @item 3 | |
11425 | As per the previous level, but show all control flow events, not | |
11426 | just significant ones. | |
11427 | ||
11428 | @item 4 | |
11429 | This level is intended for analyzer developers; it adds various | |
11430 | other events intended for debugging the analyzer. | |
11431 | ||
11432 | @end table | |
11433 | ||
d77de738 | 11434 | @opindex fdump-analyzer |
ddf6fe37 | 11435 | @item -fdump-analyzer |
d77de738 ML |
11436 | Dump internal details about what the analyzer is doing to |
11437 | @file{@var{file}.analyzer.txt}. | |
4ace81b6 | 11438 | @option{-fdump-analyzer-stderr} overrides this option. |
d77de738 | 11439 | |
d77de738 | 11440 | @opindex fdump-analyzer-stderr |
ddf6fe37 | 11441 | @item -fdump-analyzer-stderr |
d77de738 ML |
11442 | Dump internal details about what the analyzer is doing to stderr. |
11443 | This option overrides @option{-fdump-analyzer}. | |
11444 | ||
d77de738 | 11445 | @opindex fdump-analyzer-callgraph |
ddf6fe37 | 11446 | @item -fdump-analyzer-callgraph |
d77de738 ML |
11447 | Dump a representation of the call graph suitable for viewing with |
11448 | GraphViz to @file{@var{file}.callgraph.dot}. | |
11449 | ||
d77de738 | 11450 | @opindex fdump-analyzer-exploded-graph |
ddf6fe37 | 11451 | @item -fdump-analyzer-exploded-graph |
d77de738 ML |
11452 | Dump a representation of the ``exploded graph'' suitable for viewing with |
11453 | GraphViz to @file{@var{file}.eg.dot}. | |
11454 | Nodes are color-coded based on state-machine states to emphasize | |
11455 | state changes. | |
11456 | ||
d77de738 | 11457 | @opindex dump-analyzer-exploded-nodes |
ddf6fe37 | 11458 | @item -fdump-analyzer-exploded-nodes |
d77de738 ML |
11459 | Emit diagnostics showing where nodes in the ``exploded graph'' are |
11460 | in relation to the program source. | |
11461 | ||
d77de738 | 11462 | @opindex dump-analyzer-exploded-nodes-2 |
ddf6fe37 | 11463 | @item -fdump-analyzer-exploded-nodes-2 |
d77de738 ML |
11464 | Dump a textual representation of the ``exploded graph'' to |
11465 | @file{@var{file}.eg.txt}. | |
11466 | ||
d77de738 | 11467 | @opindex dump-analyzer-exploded-nodes-3 |
ddf6fe37 | 11468 | @item -fdump-analyzer-exploded-nodes-3 |
d77de738 ML |
11469 | Dump a textual representation of the ``exploded graph'' to |
11470 | one dump file per node, to @file{@var{file}.eg-@var{id}.txt}. | |
11471 | This is typically a large number of dump files. | |
11472 | ||
d77de738 | 11473 | @opindex fdump-analyzer-exploded-paths |
ddf6fe37 | 11474 | @item -fdump-analyzer-exploded-paths |
d77de738 ML |
11475 | Dump a textual representation of the ``exploded path'' for each |
11476 | diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}. | |
11477 | ||
d77de738 | 11478 | @opindex dump-analyzer-feasibility |
ddf6fe37 | 11479 | @item -fdump-analyzer-feasibility |
d77de738 ML |
11480 | Dump internal details about the analyzer's search for feasible paths. |
11481 | The details are written in a form suitable for viewing with GraphViz | |
11482 | to filenames of the form @file{@var{file}.*.fg.dot}, | |
11483 | @file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}. | |
11484 | ||
d77de738 | 11485 | @opindex fdump-analyzer-json |
ddf6fe37 | 11486 | @item -fdump-analyzer-json |
d77de738 ML |
11487 | Dump a compressed JSON representation of analyzer internals to |
11488 | @file{@var{file}.analyzer.json.gz}. The precise format is subject | |
11489 | to change. | |
11490 | ||
d77de738 | 11491 | @opindex fdump-analyzer-state-purge |
ddf6fe37 | 11492 | @item -fdump-analyzer-state-purge |
d77de738 ML |
11493 | As per @option{-fdump-analyzer-supergraph}, dump a representation of the |
11494 | ``supergraph'' suitable for viewing with GraphViz, but annotate the | |
11495 | graph with information on what state will be purged at each node. | |
11496 | The graph is written to @file{@var{file}.state-purge.dot}. | |
11497 | ||
d77de738 | 11498 | @opindex fdump-analyzer-supergraph |
ddf6fe37 | 11499 | @item -fdump-analyzer-supergraph |
d77de738 ML |
11500 | Dump representations of the ``supergraph'' suitable for viewing with |
11501 | GraphViz to @file{@var{file}.supergraph.dot} and to | |
11502 | @file{@var{file}.supergraph-eg.dot}. These show all of the | |
11503 | control flow graphs in the program, with interprocedural edges for | |
11504 | calls and returns. The second dump contains annotations showing nodes | |
11505 | in the ``exploded graph'' and diagnostics associated with them. | |
11506 | ||
d77de738 | 11507 | @opindex fdump-analyzer-untracked |
ddf6fe37 | 11508 | @item -fdump-analyzer-untracked |
d77de738 ML |
11509 | Emit custom warnings with internal details intended for analyzer developers. |
11510 | ||
11511 | @end table | |
11512 | ||
11513 | @node Debugging Options | |
11514 | @section Options for Debugging Your Program | |
11515 | @cindex options, debugging | |
11516 | @cindex debugging information options | |
11517 | ||
11518 | To tell GCC to emit extra information for use by a debugger, in almost | |
11519 | all cases you need only to add @option{-g} to your other options. Some debug | |
11520 | formats can co-exist (like DWARF with CTF) when each of them is enabled | |
11521 | explicitly by adding the respective command line option to your other options. | |
11522 | ||
11523 | GCC allows you to use @option{-g} with | |
11524 | @option{-O}. The shortcuts taken by optimized code may occasionally | |
11525 | be surprising: some variables you declared may not exist | |
11526 | at all; flow of control may briefly move where you did not expect it; | |
11527 | some statements may not be executed because they compute constant | |
11528 | results or their values are already at hand; some statements may | |
11529 | execute in different places because they have been moved out of loops. | |
11530 | Nevertheless it is possible to debug optimized output. This makes | |
11531 | it reasonable to use the optimizer for programs that might have bugs. | |
11532 | ||
11533 | If you are not using some other optimization option, consider | |
11534 | using @option{-Og} (@pxref{Optimize Options}) with @option{-g}. | |
11535 | With no @option{-O} option at all, some compiler passes that collect | |
11536 | information useful for debugging do not run at all, so that | |
11537 | @option{-Og} may result in a better debugging experience. | |
11538 | ||
11539 | @table @gcctabopt | |
d77de738 | 11540 | @opindex g |
ddf6fe37 | 11541 | @item -g |
d77de738 ML |
11542 | Produce debugging information in the operating system's native format |
11543 | (stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging | |
11544 | information. | |
11545 | ||
11546 | On most systems that use stabs format, @option{-g} enables use of extra | |
11547 | debugging information that only GDB can use; this extra information | |
11548 | makes debugging work better in GDB but probably makes other debuggers | |
11549 | crash or refuse to read the program. If you want to control for certain whether | |
11550 | to generate the extra information, use @option{-gvms} (see below). | |
11551 | ||
d77de738 | 11552 | @opindex ggdb |
ddf6fe37 | 11553 | @item -ggdb |
d77de738 ML |
11554 | Produce debugging information for use by GDB@. This means to use the |
11555 | most expressive format available (DWARF, stabs, or the native format | |
11556 | if neither of those are supported), including GDB extensions if at all | |
11557 | possible. | |
11558 | ||
ddf6fe37 | 11559 | @opindex gdwarf |
d77de738 ML |
11560 | @item -gdwarf |
11561 | @itemx -gdwarf-@var{version} | |
d77de738 ML |
11562 | Produce debugging information in DWARF format (if that is supported). |
11563 | The value of @var{version} may be either 2, 3, 4 or 5; the default | |
11564 | version for most targets is 5 (with the exception of VxWorks, TPF and | |
a335cf24 | 11565 | Darwin / macOS, which default to version 2, and AIX, which defaults |
d77de738 ML |
11566 | to version 4). |
11567 | ||
11568 | Note that with DWARF Version 2, some ports require and always | |
11569 | use some non-conflicting DWARF 3 extensions in the unwind tables. | |
11570 | ||
11571 | Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments} | |
11572 | for maximum benefit. Version 5 requires GDB 8.0 or higher. | |
11573 | ||
11574 | GCC no longer supports DWARF Version 1, which is substantially | |
11575 | different than Version 2 and later. For historical reasons, some | |
11576 | other DWARF-related options such as | |
11577 | @option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2 | |
11578 | in their names, but apply to all currently-supported versions of DWARF. | |
11579 | ||
d77de738 | 11580 | @opindex gbtf |
ddf6fe37 | 11581 | @item -gbtf |
d77de738 ML |
11582 | Request BTF debug information. BTF is the default debugging format for the |
11583 | eBPF target. On other targets, like x86, BTF debug information can be | |
11584 | generated along with DWARF debug information when both of the debug formats are | |
11585 | enabled explicitly via their respective command line options. | |
11586 | ||
ddf6fe37 | 11587 | @opindex gctf |
d77de738 ML |
11588 | @item -gctf |
11589 | @itemx -gctf@var{level} | |
d77de738 ML |
11590 | Request CTF debug information and use level to specify how much CTF debug |
11591 | information should be produced. If @option{-gctf} is specified | |
11592 | without a value for level, the default level of CTF debug information is 2. | |
11593 | ||
11594 | CTF debug information can be generated along with DWARF debug information when | |
11595 | both of the debug formats are enabled explicitly via their respective command | |
11596 | line options. | |
11597 | ||
11598 | Level 0 produces no CTF debug information at all. Thus, @option{-gctf0} | |
11599 | negates @option{-gctf}. | |
11600 | ||
11601 | Level 1 produces CTF information for tracebacks only. This includes callsite | |
11602 | information, but does not include type information. | |
11603 | ||
11604 | Level 2 produces type information for entities (functions, data objects etc.) | |
11605 | at file-scope or global-scope only. | |
11606 | ||
d77de738 | 11607 | @opindex gvms |
ddf6fe37 | 11608 | @item -gvms |
d77de738 ML |
11609 | Produce debugging information in Alpha/VMS debug format (if that is |
11610 | supported). This is the format used by DEBUG on Alpha/VMS systems. | |
11611 | ||
2f7e7bfa MH |
11612 | @item -gcodeview |
11613 | @opindex gcodeview | |
11614 | Produce debugging information in CodeView debug format (if that is | |
11615 | supported). This is the format used by Microsoft Visual C++ on | |
11616 | Windows. | |
11617 | ||
d77de738 ML |
11618 | @item -g@var{level} |
11619 | @itemx -ggdb@var{level} | |
11620 | @itemx -gvms@var{level} | |
11621 | Request debugging information and also use @var{level} to specify how | |
11622 | much information. The default level is 2. | |
11623 | ||
11624 | Level 0 produces no debug information at all. Thus, @option{-g0} negates | |
11625 | @option{-g}. | |
11626 | ||
11627 | Level 1 produces minimal information, enough for making backtraces in | |
11628 | parts of the program that you don't plan to debug. This includes | |
11629 | descriptions of functions and external variables, and line number | |
11630 | tables, but no information about local variables. | |
11631 | ||
11632 | Level 3 includes extra information, such as all the macro definitions | |
11633 | present in the program. Some debuggers support macro expansion when | |
11634 | you use @option{-g3}. | |
11635 | ||
11636 | If you use multiple @option{-g} options, with or without level numbers, | |
11637 | the last such option is the one that is effective. | |
11638 | ||
11639 | @option{-gdwarf} does not accept a concatenated debug level, to avoid | |
11640 | confusion with @option{-gdwarf-@var{level}}. | |
11641 | Instead use an additional @option{-g@var{level}} option to change the | |
11642 | debug level for DWARF. | |
11643 | ||
d77de738 ML |
11644 | @opindex feliminate-unused-debug-symbols |
11645 | @opindex fno-eliminate-unused-debug-symbols | |
ddf6fe37 | 11646 | @item -fno-eliminate-unused-debug-symbols |
d77de738 ML |
11647 | By default, no debug information is produced for symbols that are not actually |
11648 | used. Use this option if you want debug information for all symbols. | |
11649 | ||
d77de738 | 11650 | @opindex femit-class-debug-always |
ddf6fe37 | 11651 | @item -femit-class-debug-always |
d77de738 ML |
11652 | Instead of emitting debugging information for a C++ class in only one |
11653 | object file, emit it in all object files using the class. This option | |
11654 | should be used only with debuggers that are unable to handle the way GCC | |
11655 | normally emits debugging information for classes because using this | |
11656 | option increases the size of debugging information by as much as a | |
11657 | factor of two. | |
11658 | ||
d77de738 ML |
11659 | @opindex fmerge-debug-strings |
11660 | @opindex fno-merge-debug-strings | |
ddf6fe37 | 11661 | @item -fno-merge-debug-strings |
d77de738 ML |
11662 | Direct the linker to not merge together strings in the debugging |
11663 | information that are identical in different object files. Merging is | |
11664 | not supported by all assemblers or linkers. Merging decreases the size | |
11665 | of the debug information in the output file at the cost of increasing | |
11666 | link processing time. Merging is enabled by default. | |
11667 | ||
d77de738 | 11668 | @opindex fdebug-prefix-map |
ddf6fe37 | 11669 | @item -fdebug-prefix-map=@var{old}=@var{new} |
d77de738 ML |
11670 | When compiling files residing in directory @file{@var{old}}, record |
11671 | debugging information describing them as if the files resided in | |
11672 | directory @file{@var{new}} instead. This can be used to replace a | |
11673 | build-time path with an install-time path in the debug info. It can | |
11674 | also be used to change an absolute path to a relative path by using | |
11675 | @file{.} for @var{new}. This can give more reproducible builds, which | |
11676 | are location independent, but may require an extra command to tell GDB | |
2eb0191a JJ |
11677 | where to find the source files. See also @option{-ffile-prefix-map} |
11678 | and @option{-fcanon-prefix-map}. | |
d77de738 | 11679 | |
d77de738 | 11680 | @opindex fvar-tracking |
ddf6fe37 | 11681 | @item -fvar-tracking |
d77de738 ML |
11682 | Run variable tracking pass. It computes where variables are stored at each |
11683 | position in code. Better debugging information is then generated | |
11684 | (if the debugging information format supports this information). | |
11685 | ||
11686 | It is enabled by default when compiling with optimization (@option{-Os}, | |
11687 | @option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and | |
11688 | the debug info format supports it. | |
11689 | ||
d77de738 ML |
11690 | @opindex fvar-tracking-assignments |
11691 | @opindex fno-var-tracking-assignments | |
ddf6fe37 | 11692 | @item -fvar-tracking-assignments |
d77de738 ML |
11693 | Annotate assignments to user variables early in the compilation and |
11694 | attempt to carry the annotations over throughout the compilation all the | |
11695 | way to the end, in an attempt to improve debug information while | |
11696 | optimizing. Use of @option{-gdwarf-4} is recommended along with it. | |
11697 | ||
11698 | It can be enabled even if var-tracking is disabled, in which case | |
11699 | annotations are created and maintained, but discarded at the end. | |
11700 | By default, this flag is enabled together with @option{-fvar-tracking}, | |
11701 | except when selective scheduling is enabled. | |
11702 | ||
d77de738 | 11703 | @opindex gsplit-dwarf |
ddf6fe37 | 11704 | @item -gsplit-dwarf |
d77de738 ML |
11705 | If DWARF debugging information is enabled, separate as much debugging |
11706 | information as possible into a separate output file with the extension | |
11707 | @file{.dwo}. This option allows the build system to avoid linking files with | |
11708 | debug information. To be useful, this option requires a debugger capable of | |
11709 | reading @file{.dwo} files. | |
11710 | ||
d77de738 ML |
11711 | @opindex gdwarf32 |
11712 | @opindex gdwarf64 | |
ddf6fe37 AA |
11713 | @item -gdwarf32 |
11714 | @itemx -gdwarf64 | |
d77de738 ML |
11715 | If DWARF debugging information is enabled, the @option{-gdwarf32} selects |
11716 | the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit | |
11717 | DWARF format. The default is target specific, on most targets it is | |
11718 | @option{-gdwarf32} though. The 32-bit DWARF format is smaller, but | |
11719 | can't support more than 2GiB of debug information in any of the DWARF | |
11720 | debug information sections. The 64-bit DWARF format allows larger debug | |
11721 | information and might not be well supported by all consumers yet. | |
11722 | ||
d77de738 | 11723 | @opindex gdescribe-dies |
ddf6fe37 | 11724 | @item -gdescribe-dies |
d77de738 ML |
11725 | Add description attributes to some DWARF DIEs that have no name attribute, |
11726 | such as artificial variables, external references and call site | |
11727 | parameter DIEs. | |
11728 | ||
d77de738 | 11729 | @opindex gpubnames |
ddf6fe37 | 11730 | @item -gpubnames |
d77de738 ML |
11731 | Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections. |
11732 | ||
d77de738 | 11733 | @opindex ggnu-pubnames |
ddf6fe37 | 11734 | @item -ggnu-pubnames |
d77de738 ML |
11735 | Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format |
11736 | suitable for conversion into a GDB@ index. This option is only useful | |
11737 | with a linker that can produce GDB@ index version 7. | |
11738 | ||
d77de738 ML |
11739 | @opindex fdebug-types-section |
11740 | @opindex fno-debug-types-section | |
ddf6fe37 | 11741 | @item -fdebug-types-section |
d77de738 ML |
11742 | When using DWARF Version 4 or higher, type DIEs can be put into |
11743 | their own @code{.debug_types} section instead of making them part of the | |
11744 | @code{.debug_info} section. It is more efficient to put them in a separate | |
11745 | comdat section since the linker can then remove duplicates. | |
11746 | But not all DWARF consumers support @code{.debug_types} sections yet | |
11747 | and on some objects @code{.debug_types} produces larger instead of smaller | |
11748 | debugging information. | |
11749 | ||
d77de738 ML |
11750 | @opindex grecord-gcc-switches |
11751 | @opindex gno-record-gcc-switches | |
ddf6fe37 AA |
11752 | @item -grecord-gcc-switches |
11753 | @itemx -gno-record-gcc-switches | |
d77de738 ML |
11754 | This switch causes the command-line options used to invoke the |
11755 | compiler that may affect code generation to be appended to the | |
11756 | DW_AT_producer attribute in DWARF debugging information. The options | |
11757 | are concatenated with spaces separating them from each other and from | |
11758 | the compiler version. | |
11759 | It is enabled by default. | |
11760 | See also @option{-frecord-gcc-switches} for another | |
11761 | way of storing compiler options into the object file. | |
11762 | ||
d77de738 | 11763 | @opindex gstrict-dwarf |
ddf6fe37 | 11764 | @item -gstrict-dwarf |
d77de738 ML |
11765 | Disallow using extensions of later DWARF standard version than selected |
11766 | with @option{-gdwarf-@var{version}}. On most targets using non-conflicting | |
11767 | DWARF extensions from later standard versions is allowed. | |
11768 | ||
d77de738 | 11769 | @opindex gno-strict-dwarf |
ddf6fe37 | 11770 | @item -gno-strict-dwarf |
d77de738 ML |
11771 | Allow using extensions of later DWARF standard version than selected with |
11772 | @option{-gdwarf-@var{version}}. | |
11773 | ||
d77de738 | 11774 | @opindex gas-loc-support |
ddf6fe37 | 11775 | @item -gas-loc-support |
d77de738 ML |
11776 | Inform the compiler that the assembler supports @code{.loc} directives. |
11777 | It may then use them for the assembler to generate DWARF2+ line number | |
11778 | tables. | |
11779 | ||
11780 | This is generally desirable, because assembler-generated line-number | |
11781 | tables are a lot more compact than those the compiler can generate | |
11782 | itself. | |
11783 | ||
11784 | This option will be enabled by default if, at GCC configure time, the | |
11785 | assembler was found to support such directives. | |
11786 | ||
d77de738 | 11787 | @opindex gno-as-loc-support |
ddf6fe37 | 11788 | @item -gno-as-loc-support |
d77de738 ML |
11789 | Force GCC to generate DWARF2+ line number tables internally, if DWARF2+ |
11790 | line number tables are to be generated. | |
11791 | ||
d77de738 | 11792 | @opindex gas-locview-support |
ddf6fe37 | 11793 | @item -gas-locview-support |
d77de738 ML |
11794 | Inform the compiler that the assembler supports @code{view} assignment |
11795 | and reset assertion checking in @code{.loc} directives. | |
11796 | ||
11797 | This option will be enabled by default if, at GCC configure time, the | |
11798 | assembler was found to support them. | |
11799 | ||
11800 | @item -gno-as-locview-support | |
11801 | Force GCC to assign view numbers internally, if | |
11802 | @option{-gvariable-location-views} are explicitly requested. | |
11803 | ||
d77de738 ML |
11804 | @opindex gcolumn-info |
11805 | @opindex gno-column-info | |
ddf6fe37 AA |
11806 | @item -gcolumn-info |
11807 | @itemx -gno-column-info | |
d77de738 ML |
11808 | Emit location column information into DWARF debugging information, rather |
11809 | than just file and line. | |
11810 | This option is enabled by default. | |
11811 | ||
d77de738 ML |
11812 | @opindex gstatement-frontiers |
11813 | @opindex gno-statement-frontiers | |
ddf6fe37 AA |
11814 | @item -gstatement-frontiers |
11815 | @itemx -gno-statement-frontiers | |
d77de738 ML |
11816 | This option causes GCC to create markers in the internal representation |
11817 | at the beginning of statements, and to keep them roughly in place | |
11818 | throughout compilation, using them to guide the output of @code{is_stmt} | |
11819 | markers in the line number table. This is enabled by default when | |
11820 | compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2}, | |
11821 | @dots{}), and outputting DWARF 2 debug information at the normal level. | |
11822 | ||
d77de738 ML |
11823 | @opindex gvariable-location-views |
11824 | @opindex gvariable-location-views=incompat5 | |
11825 | @opindex gno-variable-location-views | |
ddf6fe37 AA |
11826 | @item -gvariable-location-views |
11827 | @itemx -gvariable-location-views=incompat5 | |
11828 | @itemx -gno-variable-location-views | |
d77de738 ML |
11829 | Augment variable location lists with progressive view numbers implied |
11830 | from the line number table. This enables debug information consumers to | |
11831 | inspect state at certain points of the program, even if no instructions | |
11832 | associated with the corresponding source locations are present at that | |
11833 | point. If the assembler lacks support for view numbers in line number | |
11834 | tables, this will cause the compiler to emit the line number table, | |
11835 | which generally makes them somewhat less compact. The augmented line | |
11836 | number tables and location lists are fully backward-compatible, so they | |
11837 | can be consumed by debug information consumers that are not aware of | |
11838 | these augmentations, but they won't derive any benefit from them either. | |
11839 | ||
11840 | This is enabled by default when outputting DWARF 2 debug information at | |
11841 | the normal level, as long as there is assembler support, | |
11842 | @option{-fvar-tracking-assignments} is enabled and | |
11843 | @option{-gstrict-dwarf} is not. When assembler support is not | |
11844 | available, this may still be enabled, but it will force GCC to output | |
11845 | internal line number tables, and if | |
11846 | @option{-ginternal-reset-location-views} is not enabled, that will most | |
11847 | certainly lead to silently mismatching location views. | |
11848 | ||
11849 | There is a proposed representation for view numbers that is not backward | |
11850 | compatible with the location list format introduced in DWARF 5, that can | |
11851 | be enabled with @option{-gvariable-location-views=incompat5}. This | |
11852 | option may be removed in the future, is only provided as a reference | |
11853 | implementation of the proposed representation. Debug information | |
11854 | consumers are not expected to support this extended format, and they | |
11855 | would be rendered unable to decode location lists using it. | |
11856 | ||
d77de738 ML |
11857 | @opindex ginternal-reset-location-views |
11858 | @opindex gno-internal-reset-location-views | |
ddf6fe37 AA |
11859 | @item -ginternal-reset-location-views |
11860 | @itemx -gno-internal-reset-location-views | |
d77de738 ML |
11861 | Attempt to determine location views that can be omitted from location |
11862 | view lists. This requires the compiler to have very accurate insn | |
11863 | length estimates, which isn't always the case, and it may cause | |
11864 | incorrect view lists to be generated silently when using an assembler | |
11865 | that does not support location view lists. The GNU assembler will flag | |
11866 | any such error as a @code{view number mismatch}. This is only enabled | |
11867 | on ports that define a reliable estimation function. | |
11868 | ||
d77de738 ML |
11869 | @opindex ginline-points |
11870 | @opindex gno-inline-points | |
ddf6fe37 AA |
11871 | @item -ginline-points |
11872 | @itemx -gno-inline-points | |
d77de738 ML |
11873 | Generate extended debug information for inlined functions. Location |
11874 | view tracking markers are inserted at inlined entry points, so that | |
11875 | address and view numbers can be computed and output in debug | |
11876 | information. This can be enabled independently of location views, in | |
11877 | which case the view numbers won't be output, but it can only be enabled | |
11878 | along with statement frontiers, and it is only enabled by default if | |
11879 | location views are enabled. | |
11880 | ||
d77de738 | 11881 | @opindex gz |
ddf6fe37 | 11882 | @item -gz@r{[}=@var{type}@r{]} |
d77de738 ML |
11883 | Produce compressed debug sections in DWARF format, if that is supported. |
11884 | If @var{type} is not given, the default type depends on the capabilities | |
11885 | of the assembler and linker used. @var{type} may be one of | |
11886 | @samp{none} (don't compress debug sections), or @samp{zlib} (use zlib | |
11887 | compression in ELF gABI format). If the linker doesn't support writing | |
11888 | compressed debug sections, the option is rejected. Otherwise, if the | |
11889 | assembler does not support them, @option{-gz} is silently ignored when | |
11890 | producing object files. | |
11891 | ||
d77de738 | 11892 | @opindex femit-struct-debug-baseonly |
ddf6fe37 | 11893 | @item -femit-struct-debug-baseonly |
d77de738 ML |
11894 | Emit debug information for struct-like types |
11895 | only when the base name of the compilation source file | |
11896 | matches the base name of file in which the struct is defined. | |
11897 | ||
11898 | This option substantially reduces the size of debugging information, | |
11899 | but at significant potential loss in type information to the debugger. | |
11900 | See @option{-femit-struct-debug-reduced} for a less aggressive option. | |
11901 | See @option{-femit-struct-debug-detailed} for more detailed control. | |
11902 | ||
11903 | This option works only with DWARF debug output. | |
11904 | ||
d77de738 | 11905 | @opindex femit-struct-debug-reduced |
ddf6fe37 | 11906 | @item -femit-struct-debug-reduced |
d77de738 ML |
11907 | Emit debug information for struct-like types |
11908 | only when the base name of the compilation source file | |
11909 | matches the base name of file in which the type is defined, | |
11910 | unless the struct is a template or defined in a system header. | |
11911 | ||
11912 | This option significantly reduces the size of debugging information, | |
11913 | with some potential loss in type information to the debugger. | |
11914 | See @option{-femit-struct-debug-baseonly} for a more aggressive option. | |
11915 | See @option{-femit-struct-debug-detailed} for more detailed control. | |
11916 | ||
11917 | This option works only with DWARF debug output. | |
11918 | ||
d77de738 | 11919 | @opindex femit-struct-debug-detailed |
ddf6fe37 | 11920 | @item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]} |
d77de738 ML |
11921 | Specify the struct-like types |
11922 | for which the compiler generates debug information. | |
11923 | The intent is to reduce duplicate struct debug information | |
11924 | between different object files within the same program. | |
11925 | ||
11926 | This option is a detailed version of | |
11927 | @option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly}, | |
11928 | which serves for most needs. | |
11929 | ||
11930 | A specification has the syntax@* | |
11931 | [@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none}) | |
11932 | ||
11933 | The optional first word limits the specification to | |
11934 | structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}). | |
11935 | A struct type is used directly when it is the type of a variable, member. | |
11936 | Indirect uses arise through pointers to structs. | |
11937 | That is, when use of an incomplete struct is valid, the use is indirect. | |
11938 | An example is | |
11939 | @samp{struct one direct; struct two * indirect;}. | |
11940 | ||
11941 | The optional second word limits the specification to | |
11942 | ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}). | |
11943 | Generic structs are a bit complicated to explain. | |
11944 | For C++, these are non-explicit specializations of template classes, | |
11945 | or non-template classes within the above. | |
11946 | Other programming languages have generics, | |
11947 | but @option{-femit-struct-debug-detailed} does not yet implement them. | |
11948 | ||
11949 | The third word specifies the source files for those | |
11950 | structs for which the compiler should emit debug information. | |
11951 | The values @samp{none} and @samp{any} have the normal meaning. | |
11952 | The value @samp{base} means that | |
11953 | the base of name of the file in which the type declaration appears | |
11954 | must match the base of the name of the main compilation file. | |
11955 | In practice, this means that when compiling @file{foo.c}, debug information | |
11956 | is generated for types declared in that file and @file{foo.h}, | |
11957 | but not other header files. | |
11958 | The value @samp{sys} means those types satisfying @samp{base} | |
11959 | or declared in system or compiler headers. | |
11960 | ||
11961 | You may need to experiment to determine the best settings for your application. | |
11962 | ||
11963 | The default is @option{-femit-struct-debug-detailed=all}. | |
11964 | ||
11965 | This option works only with DWARF debug output. | |
11966 | ||
d77de738 ML |
11967 | @opindex fdwarf2-cfi-asm |
11968 | @opindex fno-dwarf2-cfi-asm | |
ddf6fe37 | 11969 | @item -fno-dwarf2-cfi-asm |
d77de738 ML |
11970 | Emit DWARF unwind info as compiler generated @code{.eh_frame} section |
11971 | instead of using GAS @code{.cfi_*} directives. | |
11972 | ||
d77de738 ML |
11973 | @opindex feliminate-unused-debug-types |
11974 | @opindex fno-eliminate-unused-debug-types | |
ddf6fe37 | 11975 | @item -fno-eliminate-unused-debug-types |
d77de738 ML |
11976 | Normally, when producing DWARF output, GCC avoids producing debug symbol |
11977 | output for types that are nowhere used in the source file being compiled. | |
11978 | Sometimes it is useful to have GCC emit debugging | |
11979 | information for all types declared in a compilation | |
11980 | unit, regardless of whether or not they are actually used | |
11981 | in that compilation unit, for example | |
11982 | if, in the debugger, you want to cast a value to a type that is | |
11983 | not actually used in your program (but is declared). More often, | |
11984 | however, this results in a significant amount of wasted space. | |
11985 | @end table | |
11986 | ||
11987 | @node Optimize Options | |
11988 | @section Options That Control Optimization | |
11989 | @cindex optimize options | |
11990 | @cindex options, optimization | |
11991 | ||
11992 | These options control various sorts of optimizations. | |
11993 | ||
11994 | Without any optimization option, the compiler's goal is to reduce the | |
11995 | cost of compilation and to make debugging produce the expected | |
11996 | results. Statements are independent: if you stop the program with a | |
11997 | breakpoint between statements, you can then assign a new value to any | |
11998 | variable or change the program counter to any other statement in the | |
11999 | function and get exactly the results you expect from the source | |
12000 | code. | |
12001 | ||
12002 | Turning on optimization flags makes the compiler attempt to improve | |
12003 | the performance and/or code size at the expense of compilation time | |
12004 | and possibly the ability to debug the program. | |
12005 | ||
12006 | The compiler performs optimization based on the knowledge it has of the | |
12007 | program. Compiling multiple files at once to a single output file mode allows | |
12008 | the compiler to use information gained from all of the files when compiling | |
12009 | each of them. | |
12010 | ||
12011 | Not all optimizations are controlled directly by a flag. Only | |
12012 | optimizations that have a flag are listed in this section. | |
12013 | ||
12014 | Most optimizations are completely disabled at @option{-O0} or if an | |
12015 | @option{-O} level is not set on the command line, even if individual | |
12016 | optimization flags are specified. Similarly, @option{-Og} suppresses | |
12017 | many optimization passes. | |
12018 | ||
12019 | Depending on the target and how GCC was configured, a slightly different | |
12020 | set of optimizations may be enabled at each @option{-O} level than | |
12021 | those listed here. You can invoke GCC with @option{-Q --help=optimizers} | |
12022 | to find out the exact set of optimizations that are enabled at each level. | |
12023 | @xref{Overall Options}, for examples. | |
12024 | ||
12025 | @table @gcctabopt | |
d77de738 ML |
12026 | @opindex O |
12027 | @opindex O1 | |
ddf6fe37 AA |
12028 | @item -O |
12029 | @itemx -O1 | |
d77de738 ML |
12030 | Optimize. Optimizing compilation takes somewhat more time, and a lot |
12031 | more memory for a large function. | |
12032 | ||
12033 | With @option{-O}, the compiler tries to reduce code size and execution | |
12034 | time, without performing any optimizations that take a great deal of | |
12035 | compilation time. | |
12036 | ||
12037 | @c Note that in addition to the default_options_table list in opts.cc, | |
12038 | @c several optimization flags default to true but control optimization | |
12039 | @c passes that are explicitly disabled at -O0. | |
12040 | ||
12041 | @option{-O} turns on the following optimization flags: | |
12042 | ||
12043 | @c Please keep the following list alphabetized. | |
43b72ede AA |
12044 | @gccoptlist{-fauto-inc-dec |
12045 | -fbranch-count-reg | |
12046 | -fcombine-stack-adjustments | |
12047 | -fcompare-elim | |
12048 | -fcprop-registers | |
12049 | -fdce | |
12050 | -fdefer-pop | |
12051 | -fdelayed-branch | |
12052 | -fdse | |
12053 | -fforward-propagate | |
12054 | -fguess-branch-probability | |
12055 | -fif-conversion | |
12056 | -fif-conversion2 | |
12057 | -finline-functions-called-once | |
12058 | -fipa-modref | |
12059 | -fipa-profile | |
12060 | -fipa-pure-const | |
12061 | -fipa-reference | |
12062 | -fipa-reference-addressable | |
12063 | -fmerge-constants | |
12064 | -fmove-loop-invariants | |
12065 | -fmove-loop-stores | |
12066 | -fomit-frame-pointer | |
12067 | -freorder-blocks | |
12068 | -fshrink-wrap | |
12069 | -fshrink-wrap-separate | |
12070 | -fsplit-wide-types | |
12071 | -fssa-backprop | |
12072 | -fssa-phiopt | |
12073 | -ftree-bit-ccp | |
12074 | -ftree-ccp | |
12075 | -ftree-ch | |
12076 | -ftree-coalesce-vars | |
12077 | -ftree-copy-prop | |
12078 | -ftree-dce | |
12079 | -ftree-dominator-opts | |
12080 | -ftree-dse | |
12081 | -ftree-forwprop | |
12082 | -ftree-fre | |
12083 | -ftree-phiprop | |
12084 | -ftree-pta | |
12085 | -ftree-scev-cprop | |
12086 | -ftree-sink | |
12087 | -ftree-slsr | |
12088 | -ftree-sra | |
12089 | -ftree-ter | |
d77de738 ML |
12090 | -funit-at-a-time} |
12091 | ||
d77de738 | 12092 | @opindex O2 |
ddf6fe37 | 12093 | @item -O2 |
d77de738 ML |
12094 | Optimize even more. GCC performs nearly all supported optimizations |
12095 | that do not involve a space-speed tradeoff. | |
12096 | As compared to @option{-O}, this option increases both compilation time | |
12097 | and the performance of the generated code. | |
12098 | ||
12099 | @option{-O2} turns on all optimization flags specified by @option{-O1}. It | |
12100 | also turns on the following optimization flags: | |
12101 | ||
12102 | @c Please keep the following list alphabetized! | |
43b72ede AA |
12103 | @gccoptlist{-falign-functions -falign-jumps |
12104 | -falign-labels -falign-loops | |
12105 | -fcaller-saves | |
12106 | -fcode-hoisting | |
12107 | -fcrossjumping | |
12108 | -fcse-follow-jumps -fcse-skip-blocks | |
12109 | -fdelete-null-pointer-checks | |
12110 | -fdevirtualize -fdevirtualize-speculatively | |
12111 | -fexpensive-optimizations | |
12112 | -ffinite-loops | |
12113 | -fgcse -fgcse-lm | |
12114 | -fhoist-adjacent-loads | |
12115 | -finline-functions | |
12116 | -finline-small-functions | |
12117 | -findirect-inlining | |
12118 | -fipa-bit-cp -fipa-cp -fipa-icf | |
12119 | -fipa-ra -fipa-sra -fipa-vrp | |
12120 | -fisolate-erroneous-paths-dereference | |
12121 | -flra-remat | |
12122 | -foptimize-sibling-calls | |
12123 | -foptimize-strlen | |
12124 | -fpartial-inlining | |
12125 | -fpeephole2 | |
12126 | -freorder-blocks-algorithm=stc | |
12127 | -freorder-blocks-and-partition -freorder-functions | |
12128 | -frerun-cse-after-loop | |
12129 | -fschedule-insns -fschedule-insns2 | |
12130 | -fsched-interblock -fsched-spec | |
12131 | -fstore-merging | |
12132 | -fstrict-aliasing | |
12133 | -fthread-jumps | |
12134 | -ftree-builtin-call-dce | |
12135 | -ftree-loop-vectorize | |
12136 | -ftree-pre | |
12137 | -ftree-slp-vectorize | |
12138 | -ftree-switch-conversion -ftree-tail-merge | |
12139 | -ftree-vrp | |
d77de738 ML |
12140 | -fvect-cost-model=very-cheap} |
12141 | ||
12142 | Please note the warning under @option{-fgcse} about | |
12143 | invoking @option{-O2} on programs that use computed gotos. | |
12144 | ||
d77de738 | 12145 | @opindex O3 |
ddf6fe37 | 12146 | @item -O3 |
d77de738 ML |
12147 | Optimize yet more. @option{-O3} turns on all optimizations specified |
12148 | by @option{-O2} and also turns on the following optimization flags: | |
12149 | ||
12150 | @c Please keep the following list alphabetized! | |
43b72ede | 12151 | @gccoptlist{-fgcse-after-reload |
d77de738 | 12152 | -fipa-cp-clone |
43b72ede AA |
12153 | -floop-interchange |
12154 | -floop-unroll-and-jam | |
12155 | -fpeel-loops | |
12156 | -fpredictive-commoning | |
12157 | -fsplit-loops | |
12158 | -fsplit-paths | |
12159 | -ftree-loop-distribution | |
12160 | -ftree-partial-pre | |
12161 | -funswitch-loops | |
12162 | -fvect-cost-model=dynamic | |
d77de738 ML |
12163 | -fversion-loops-for-strides} |
12164 | ||
d77de738 | 12165 | @opindex O0 |
ddf6fe37 | 12166 | @item -O0 |
d77de738 ML |
12167 | Reduce compilation time and make debugging produce the expected |
12168 | results. This is the default. | |
12169 | ||
d77de738 | 12170 | @opindex Os |
ddf6fe37 | 12171 | @item -Os |
d77de738 ML |
12172 | Optimize for size. @option{-Os} enables all @option{-O2} optimizations |
12173 | except those that often increase code size: | |
12174 | ||
43b72ede AA |
12175 | @gccoptlist{-falign-functions -falign-jumps |
12176 | -falign-labels -falign-loops | |
d77de738 ML |
12177 | -fprefetch-loop-arrays -freorder-blocks-algorithm=stc} |
12178 | ||
12179 | It also enables @option{-finline-functions}, causes the compiler to tune for | |
12180 | code size rather than execution speed, and performs further optimizations | |
12181 | designed to reduce code size. | |
12182 | ||
d77de738 | 12183 | @opindex Ofast |
ddf6fe37 | 12184 | @item -Ofast |
d77de738 ML |
12185 | Disregard strict standards compliance. @option{-Ofast} enables all |
12186 | @option{-O3} optimizations. It also enables optimizations that are not | |
12187 | valid for all standard-compliant programs. | |
12188 | It turns on @option{-ffast-math}, @option{-fallow-store-data-races} | |
12189 | and the Fortran-specific @option{-fstack-arrays}, unless | |
12190 | @option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}. | |
12191 | It turns off @option{-fsemantic-interposition}. | |
12192 | ||
d77de738 | 12193 | @opindex Og |
ddf6fe37 | 12194 | @item -Og |
d77de738 ML |
12195 | Optimize debugging experience. @option{-Og} should be the optimization |
12196 | level of choice for the standard edit-compile-debug cycle, offering | |
12197 | a reasonable level of optimization while maintaining fast compilation | |
12198 | and a good debugging experience. It is a better choice than @option{-O0} | |
12199 | for producing debuggable code because some compiler passes | |
12200 | that collect debug information are disabled at @option{-O0}. | |
12201 | ||
12202 | Like @option{-O0}, @option{-Og} completely disables a number of | |
12203 | optimization passes so that individual options controlling them have | |
12204 | no effect. Otherwise @option{-Og} enables all @option{-O1} | |
12205 | optimization flags except for those that may interfere with debugging: | |
12206 | ||
43b72ede AA |
12207 | @gccoptlist{-fbranch-count-reg -fdelayed-branch |
12208 | -fdse -fif-conversion -fif-conversion2 | |
12209 | -finline-functions-called-once | |
12210 | -fmove-loop-invariants -fmove-loop-stores -fssa-phiopt | |
d77de738 ML |
12211 | -ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra} |
12212 | ||
d77de738 | 12213 | @opindex Oz |
ddf6fe37 | 12214 | @item -Oz |
d77de738 ML |
12215 | Optimize aggressively for size rather than speed. This may increase |
12216 | the number of instructions executed if those instructions require | |
12217 | fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os} | |
12218 | including enabling most @option{-O2} optimizations. | |
12219 | ||
12220 | @end table | |
12221 | ||
12222 | If you use multiple @option{-O} options, with or without level numbers, | |
12223 | the last such option is the one that is effective. | |
12224 | ||
12225 | Options of the form @option{-f@var{flag}} specify machine-independent | |
12226 | flags. Most flags have both positive and negative forms; the negative | |
12227 | form of @option{-ffoo} is @option{-fno-foo}. In the table | |
12228 | below, only one of the forms is listed---the one you typically | |
12229 | use. You can figure out the other form by either removing @samp{no-} | |
12230 | or adding it. | |
12231 | ||
12232 | The following options control specific optimizations. They are either | |
12233 | activated by @option{-O} options or are related to ones that are. You | |
12234 | can use the following flags in the rare cases when ``fine-tuning'' of | |
12235 | optimizations to be performed is desired. | |
12236 | ||
12237 | @table @gcctabopt | |
d77de738 ML |
12238 | @opindex fno-defer-pop |
12239 | @opindex fdefer-pop | |
ddf6fe37 | 12240 | @item -fno-defer-pop |
d77de738 ML |
12241 | For machines that must pop arguments after a function call, always pop |
12242 | the arguments as soon as each function returns. | |
12243 | At levels @option{-O1} and higher, @option{-fdefer-pop} is the default; | |
12244 | this allows the compiler to let arguments accumulate on the stack for several | |
12245 | function calls and pop them all at once. | |
12246 | ||
d77de738 | 12247 | @opindex fforward-propagate |
ddf6fe37 | 12248 | @item -fforward-propagate |
d77de738 ML |
12249 | Perform a forward propagation pass on RTL@. The pass tries to combine two |
12250 | instructions and checks if the result can be simplified. If loop unrolling | |
12251 | is active, two passes are performed and the second is scheduled after | |
12252 | loop unrolling. | |
12253 | ||
12254 | This option is enabled by default at optimization levels @option{-O1}, | |
12255 | @option{-O2}, @option{-O3}, @option{-Os}. | |
12256 | ||
d77de738 | 12257 | @opindex ffp-contract |
ddf6fe37 | 12258 | @item -ffp-contract=@var{style} |
d77de738 ML |
12259 | @option{-ffp-contract=off} disables floating-point expression contraction. |
12260 | @option{-ffp-contract=fast} enables floating-point expression contraction | |
12261 | such as forming of fused multiply-add operations if the target has | |
12262 | native support for them. | |
12263 | @option{-ffp-contract=on} enables floating-point expression contraction | |
1c1dd396 AM |
12264 | if allowed by the language standard. This is implemented for C and C++, |
12265 | where it enables contraction within one expression, but not across | |
12266 | different statements. | |
d77de738 | 12267 | |
1c1dd396 AM |
12268 | The default is @option{-ffp-contract=off} for C in a standards compliant mode |
12269 | (@option{-std=c11} or similar), @option{-ffp-contract=fast} otherwise. | |
d77de738 | 12270 | |
d77de738 | 12271 | @opindex fomit-frame-pointer |
ddf6fe37 | 12272 | @item -fomit-frame-pointer |
d77de738 ML |
12273 | Omit the frame pointer in functions that don't need one. This avoids the |
12274 | instructions to save, set up and restore the frame pointer; on many targets | |
12275 | it also makes an extra register available. | |
12276 | ||
12277 | On some targets this flag has no effect because the standard calling sequence | |
12278 | always uses a frame pointer, so it cannot be omitted. | |
12279 | ||
12280 | Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer | |
12281 | is used in all functions. Several targets always omit the frame pointer in | |
12282 | leaf functions. | |
12283 | ||
12284 | Enabled by default at @option{-O1} and higher. | |
12285 | ||
d77de738 | 12286 | @opindex foptimize-sibling-calls |
ddf6fe37 | 12287 | @item -foptimize-sibling-calls |
d77de738 ML |
12288 | Optimize sibling and tail recursive calls. |
12289 | ||
12290 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12291 | ||
d77de738 | 12292 | @opindex foptimize-strlen |
ddf6fe37 | 12293 | @item -foptimize-strlen |
d77de738 ML |
12294 | Optimize various standard C string functions (e.g.@: @code{strlen}, |
12295 | @code{strchr} or @code{strcpy}) and | |
12296 | their @code{_FORTIFY_SOURCE} counterparts into faster alternatives. | |
12297 | ||
12298 | Enabled at levels @option{-O2}, @option{-O3}. | |
12299 | ||
d77de738 ML |
12300 | @opindex fno-inline |
12301 | @opindex finline | |
ddf6fe37 | 12302 | @item -fno-inline |
d77de738 ML |
12303 | Do not expand any functions inline apart from those marked with |
12304 | the @code{always_inline} attribute. This is the default when not | |
12305 | optimizing. | |
12306 | ||
12307 | Single functions can be exempted from inlining by marking them | |
12308 | with the @code{noinline} attribute. | |
12309 | ||
d77de738 | 12310 | @opindex finline-small-functions |
ddf6fe37 | 12311 | @item -finline-small-functions |
d77de738 ML |
12312 | Integrate functions into their callers when their body is smaller than expected |
12313 | function call code (so overall size of program gets smaller). The compiler | |
12314 | heuristically decides which functions are simple enough to be worth integrating | |
12315 | in this way. This inlining applies to all functions, even those not declared | |
12316 | inline. | |
12317 | ||
12318 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12319 | ||
d77de738 | 12320 | @opindex findirect-inlining |
ddf6fe37 | 12321 | @item -findirect-inlining |
d77de738 ML |
12322 | Inline also indirect calls that are discovered to be known at compile |
12323 | time thanks to previous inlining. This option has any effect only | |
12324 | when inlining itself is turned on by the @option{-finline-functions} | |
12325 | or @option{-finline-small-functions} options. | |
12326 | ||
12327 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12328 | ||
d77de738 | 12329 | @opindex finline-functions |
ddf6fe37 | 12330 | @item -finline-functions |
d77de738 ML |
12331 | Consider all functions for inlining, even if they are not declared inline. |
12332 | The compiler heuristically decides which functions are worth integrating | |
12333 | in this way. | |
12334 | ||
12335 | If all calls to a given function are integrated, and the function is | |
12336 | declared @code{static}, then the function is normally not output as | |
12337 | assembler code in its own right. | |
12338 | ||
12339 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled | |
12340 | by @option{-fprofile-use} and @option{-fauto-profile}. | |
12341 | ||
d77de738 | 12342 | @opindex finline-functions-called-once |
ddf6fe37 | 12343 | @item -finline-functions-called-once |
d77de738 ML |
12344 | Consider all @code{static} functions called once for inlining into their |
12345 | caller even if they are not marked @code{inline}. If a call to a given | |
12346 | function is integrated, then the function is not output as assembler code | |
12347 | in its own right. | |
12348 | ||
12349 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os}, | |
12350 | but not @option{-Og}. | |
12351 | ||
d77de738 | 12352 | @opindex fearly-inlining |
ddf6fe37 | 12353 | @item -fearly-inlining |
d77de738 ML |
12354 | Inline functions marked by @code{always_inline} and functions whose body seems |
12355 | smaller than the function call overhead early before doing | |
12356 | @option{-fprofile-generate} instrumentation and real inlining pass. Doing so | |
12357 | makes profiling significantly cheaper and usually inlining faster on programs | |
12358 | having large chains of nested wrapper functions. | |
12359 | ||
12360 | Enabled by default. | |
12361 | ||
d77de738 | 12362 | @opindex fipa-sra |
ddf6fe37 | 12363 | @item -fipa-sra |
d77de738 ML |
12364 | Perform interprocedural scalar replacement of aggregates, removal of |
12365 | unused parameters and replacement of parameters passed by reference | |
12366 | by parameters passed by value. | |
12367 | ||
12368 | Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}. | |
12369 | ||
d77de738 | 12370 | @opindex finline-limit |
ddf6fe37 | 12371 | @item -finline-limit=@var{n} |
d77de738 ML |
12372 | By default, GCC limits the size of functions that can be inlined. This flag |
12373 | allows coarse control of this limit. @var{n} is the size of functions that | |
12374 | can be inlined in number of pseudo instructions. | |
12375 | ||
12376 | Inlining is actually controlled by a number of parameters, which may be | |
12377 | specified individually by using @option{--param @var{name}=@var{value}}. | |
12378 | The @option{-finline-limit=@var{n}} option sets some of these parameters | |
12379 | as follows: | |
12380 | ||
12381 | @table @gcctabopt | |
12382 | @item max-inline-insns-single | |
12383 | is set to @var{n}/2. | |
12384 | @item max-inline-insns-auto | |
12385 | is set to @var{n}/2. | |
12386 | @end table | |
12387 | ||
12388 | See below for a documentation of the individual | |
12389 | parameters controlling inlining and for the defaults of these parameters. | |
12390 | ||
12391 | @emph{Note:} there may be no value to @option{-finline-limit} that results | |
12392 | in default behavior. | |
12393 | ||
12394 | @emph{Note:} pseudo instruction represents, in this particular context, an | |
12395 | abstract measurement of function's size. In no way does it represent a count | |
12396 | of assembly instructions and as such its exact meaning might change from one | |
12397 | release to an another. | |
12398 | ||
d77de738 ML |
12399 | @opindex fno-keep-inline-dllexport |
12400 | @opindex fkeep-inline-dllexport | |
ddf6fe37 | 12401 | @item -fno-keep-inline-dllexport |
d77de738 ML |
12402 | This is a more fine-grained version of @option{-fkeep-inline-functions}, |
12403 | which applies only to functions that are declared using the @code{dllexport} | |
12404 | attribute or declspec. @xref{Function Attributes,,Declaring Attributes of | |
12405 | Functions}. | |
12406 | ||
d77de738 | 12407 | @opindex fkeep-inline-functions |
ddf6fe37 | 12408 | @item -fkeep-inline-functions |
d77de738 ML |
12409 | In C, emit @code{static} functions that are declared @code{inline} |
12410 | into the object file, even if the function has been inlined into all | |
12411 | of its callers. This switch does not affect functions using the | |
12412 | @code{extern inline} extension in GNU C90@. In C++, emit any and all | |
12413 | inline functions into the object file. | |
12414 | ||
d77de738 | 12415 | @opindex fkeep-static-functions |
ddf6fe37 | 12416 | @item -fkeep-static-functions |
d77de738 ML |
12417 | Emit @code{static} functions into the object file, even if the function |
12418 | is never used. | |
12419 | ||
d77de738 | 12420 | @opindex fkeep-static-consts |
ddf6fe37 | 12421 | @item -fkeep-static-consts |
d77de738 ML |
12422 | Emit variables declared @code{static const} when optimization isn't turned |
12423 | on, even if the variables aren't referenced. | |
12424 | ||
12425 | GCC enables this option by default. If you want to force the compiler to | |
12426 | check if a variable is referenced, regardless of whether or not | |
12427 | optimization is turned on, use the @option{-fno-keep-static-consts} option. | |
12428 | ||
d77de738 | 12429 | @opindex fmerge-constants |
ddf6fe37 | 12430 | @item -fmerge-constants |
d77de738 ML |
12431 | Attempt to merge identical constants (string constants and floating-point |
12432 | constants) across compilation units. | |
12433 | ||
12434 | This option is the default for optimized compilation if the assembler and | |
12435 | linker support it. Use @option{-fno-merge-constants} to inhibit this | |
12436 | behavior. | |
12437 | ||
12438 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
12439 | ||
d77de738 | 12440 | @opindex fmerge-all-constants |
ddf6fe37 | 12441 | @item -fmerge-all-constants |
d77de738 ML |
12442 | Attempt to merge identical constants and identical variables. |
12443 | ||
12444 | This option implies @option{-fmerge-constants}. In addition to | |
12445 | @option{-fmerge-constants} this considers e.g.@: even constant initialized | |
12446 | arrays or initialized constant variables with integral or floating-point | |
12447 | types. Languages like C or C++ require each variable, including multiple | |
12448 | instances of the same variable in recursive calls, to have distinct locations, | |
12449 | so using this option results in non-conforming | |
12450 | behavior. | |
12451 | ||
d77de738 | 12452 | @opindex fmodulo-sched |
ddf6fe37 | 12453 | @item -fmodulo-sched |
d77de738 ML |
12454 | Perform swing modulo scheduling immediately before the first scheduling |
12455 | pass. This pass looks at innermost loops and reorders their | |
12456 | instructions by overlapping different iterations. | |
12457 | ||
d77de738 | 12458 | @opindex fmodulo-sched-allow-regmoves |
ddf6fe37 | 12459 | @item -fmodulo-sched-allow-regmoves |
d77de738 ML |
12460 | Perform more aggressive SMS-based modulo scheduling with register moves |
12461 | allowed. By setting this flag certain anti-dependences edges are | |
12462 | deleted, which triggers the generation of reg-moves based on the | |
12463 | life-range analysis. This option is effective only with | |
12464 | @option{-fmodulo-sched} enabled. | |
12465 | ||
d77de738 ML |
12466 | @opindex fno-branch-count-reg |
12467 | @opindex fbranch-count-reg | |
ddf6fe37 | 12468 | @item -fno-branch-count-reg |
d77de738 ML |
12469 | Disable the optimization pass that scans for opportunities to use |
12470 | ``decrement and branch'' instructions on a count register instead of | |
12471 | instruction sequences that decrement a register, compare it against zero, and | |
12472 | then branch based upon the result. This option is only meaningful on | |
12473 | architectures that support such instructions, which include x86, PowerPC, | |
12474 | IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option | |
12475 | doesn't remove the decrement and branch instructions from the generated | |
12476 | instruction stream introduced by other optimization passes. | |
12477 | ||
12478 | The default is @option{-fbranch-count-reg} at @option{-O1} and higher, | |
12479 | except for @option{-Og}. | |
12480 | ||
d77de738 ML |
12481 | @opindex fno-function-cse |
12482 | @opindex ffunction-cse | |
ddf6fe37 | 12483 | @item -fno-function-cse |
d77de738 ML |
12484 | Do not put function addresses in registers; make each instruction that |
12485 | calls a constant function contain the function's address explicitly. | |
12486 | ||
12487 | This option results in less efficient code, but some strange hacks | |
12488 | that alter the assembler output may be confused by the optimizations | |
12489 | performed when this option is not used. | |
12490 | ||
12491 | The default is @option{-ffunction-cse} | |
12492 | ||
d77de738 ML |
12493 | @opindex fno-zero-initialized-in-bss |
12494 | @opindex fzero-initialized-in-bss | |
ddf6fe37 | 12495 | @item -fno-zero-initialized-in-bss |
d77de738 ML |
12496 | If the target supports a BSS section, GCC by default puts variables that |
12497 | are initialized to zero into BSS@. This can save space in the resulting | |
12498 | code. | |
12499 | ||
12500 | This option turns off this behavior because some programs explicitly | |
12501 | rely on variables going to the data section---e.g., so that the | |
12502 | resulting executable can find the beginning of that section and/or make | |
12503 | assumptions based on that. | |
12504 | ||
12505 | The default is @option{-fzero-initialized-in-bss}. | |
12506 | ||
d77de738 | 12507 | @opindex fthread-jumps |
ddf6fe37 | 12508 | @item -fthread-jumps |
d77de738 ML |
12509 | Perform optimizations that check to see if a jump branches to a |
12510 | location where another comparison subsumed by the first is found. If | |
12511 | so, the first branch is redirected to either the destination of the | |
12512 | second branch or a point immediately following it, depending on whether | |
12513 | the condition is known to be true or false. | |
12514 | ||
12515 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
12516 | ||
d77de738 | 12517 | @opindex fsplit-wide-types |
ddf6fe37 | 12518 | @item -fsplit-wide-types |
d77de738 ML |
12519 | When using a type that occupies multiple registers, such as @code{long |
12520 | long} on a 32-bit system, split the registers apart and allocate them | |
12521 | independently. This normally generates better code for those types, | |
12522 | but may make debugging more difficult. | |
12523 | ||
12524 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, | |
12525 | @option{-Os}. | |
12526 | ||
d77de738 | 12527 | @opindex fsplit-wide-types-early |
ddf6fe37 | 12528 | @item -fsplit-wide-types-early |
d77de738 ML |
12529 | Fully split wide types early, instead of very late. |
12530 | This option has no effect unless @option{-fsplit-wide-types} is turned on. | |
12531 | ||
12532 | This is the default on some targets. | |
12533 | ||
d77de738 | 12534 | @opindex fcse-follow-jumps |
ddf6fe37 | 12535 | @item -fcse-follow-jumps |
d77de738 ML |
12536 | In common subexpression elimination (CSE), scan through jump instructions |
12537 | when the target of the jump is not reached by any other path. For | |
12538 | example, when CSE encounters an @code{if} statement with an | |
12539 | @code{else} clause, CSE follows the jump when the condition | |
12540 | tested is false. | |
12541 | ||
12542 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12543 | ||
d77de738 | 12544 | @opindex fcse-skip-blocks |
ddf6fe37 | 12545 | @item -fcse-skip-blocks |
d77de738 ML |
12546 | This is similar to @option{-fcse-follow-jumps}, but causes CSE to |
12547 | follow jumps that conditionally skip over blocks. When CSE | |
12548 | encounters a simple @code{if} statement with no else clause, | |
12549 | @option{-fcse-skip-blocks} causes CSE to follow the jump around the | |
12550 | body of the @code{if}. | |
12551 | ||
12552 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12553 | ||
d77de738 | 12554 | @opindex frerun-cse-after-loop |
ddf6fe37 | 12555 | @item -frerun-cse-after-loop |
d77de738 ML |
12556 | Re-run common subexpression elimination after loop optimizations are |
12557 | performed. | |
12558 | ||
12559 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12560 | ||
d77de738 | 12561 | @opindex fgcse |
ddf6fe37 | 12562 | @item -fgcse |
d77de738 ML |
12563 | Perform a global common subexpression elimination pass. |
12564 | This pass also performs global constant and copy propagation. | |
12565 | ||
12566 | @emph{Note:} When compiling a program using computed gotos, a GCC | |
12567 | extension, you may get better run-time performance if you disable | |
12568 | the global common subexpression elimination pass by adding | |
12569 | @option{-fno-gcse} to the command line. | |
12570 | ||
12571 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12572 | ||
d77de738 | 12573 | @opindex fgcse-lm |
ddf6fe37 | 12574 | @item -fgcse-lm |
d77de738 ML |
12575 | When @option{-fgcse-lm} is enabled, global common subexpression elimination |
12576 | attempts to move loads that are only killed by stores into themselves. This | |
12577 | allows a loop containing a load/store sequence to be changed to a load outside | |
12578 | the loop, and a copy/store within the loop. | |
12579 | ||
12580 | Enabled by default when @option{-fgcse} is enabled. | |
12581 | ||
d77de738 | 12582 | @opindex fgcse-sm |
ddf6fe37 | 12583 | @item -fgcse-sm |
d77de738 ML |
12584 | When @option{-fgcse-sm} is enabled, a store motion pass is run after |
12585 | global common subexpression elimination. This pass attempts to move | |
12586 | stores out of loops. When used in conjunction with @option{-fgcse-lm}, | |
12587 | loops containing a load/store sequence can be changed to a load before | |
12588 | the loop and a store after the loop. | |
12589 | ||
12590 | Not enabled at any optimization level. | |
12591 | ||
d77de738 | 12592 | @opindex fgcse-las |
ddf6fe37 | 12593 | @item -fgcse-las |
d77de738 ML |
12594 | When @option{-fgcse-las} is enabled, the global common subexpression |
12595 | elimination pass eliminates redundant loads that come after stores to the | |
12596 | same memory location (both partial and full redundancies). | |
12597 | ||
12598 | Not enabled at any optimization level. | |
12599 | ||
d77de738 | 12600 | @opindex fgcse-after-reload |
ddf6fe37 | 12601 | @item -fgcse-after-reload |
d77de738 ML |
12602 | When @option{-fgcse-after-reload} is enabled, a redundant load elimination |
12603 | pass is performed after reload. The purpose of this pass is to clean up | |
12604 | redundant spilling. | |
12605 | ||
12606 | Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}. | |
12607 | ||
d77de738 | 12608 | @opindex faggressive-loop-optimizations |
ddf6fe37 | 12609 | @item -faggressive-loop-optimizations |
d77de738 ML |
12610 | This option tells the loop optimizer to use language constraints to |
12611 | derive bounds for the number of iterations of a loop. This assumes that | |
12612 | loop code does not invoke undefined behavior by for example causing signed | |
12613 | integer overflows or out-of-bound array accesses. The bounds for the | |
12614 | number of iterations of a loop are used to guide loop unrolling and peeling | |
12615 | and loop exit test optimizations. | |
12616 | This option is enabled by default. | |
12617 | ||
d77de738 | 12618 | @opindex funconstrained-commons |
ddf6fe37 | 12619 | @item -funconstrained-commons |
d77de738 ML |
12620 | This option tells the compiler that variables declared in common blocks |
12621 | (e.g.@: Fortran) may later be overridden with longer trailing arrays. This | |
12622 | prevents certain optimizations that depend on knowing the array bounds. | |
12623 | ||
d77de738 | 12624 | @opindex fcrossjumping |
ddf6fe37 | 12625 | @item -fcrossjumping |
d77de738 ML |
12626 | Perform cross-jumping transformation. |
12627 | This transformation unifies equivalent code and saves code size. The | |
12628 | resulting code may or may not perform better than without cross-jumping. | |
12629 | ||
12630 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12631 | ||
d77de738 | 12632 | @opindex fauto-inc-dec |
ddf6fe37 | 12633 | @item -fauto-inc-dec |
d77de738 ML |
12634 | Combine increments or decrements of addresses with memory accesses. |
12635 | This pass is always skipped on architectures that do not have | |
12636 | instructions to support this. Enabled by default at @option{-O1} and | |
12637 | higher on architectures that support this. | |
12638 | ||
d77de738 | 12639 | @opindex fdce |
ddf6fe37 | 12640 | @item -fdce |
d77de738 ML |
12641 | Perform dead code elimination (DCE) on RTL@. |
12642 | Enabled by default at @option{-O1} and higher. | |
12643 | ||
d77de738 | 12644 | @opindex fdse |
ddf6fe37 | 12645 | @item -fdse |
d77de738 ML |
12646 | Perform dead store elimination (DSE) on RTL@. |
12647 | Enabled by default at @option{-O1} and higher. | |
12648 | ||
d77de738 | 12649 | @opindex fif-conversion |
ddf6fe37 | 12650 | @item -fif-conversion |
d77de738 ML |
12651 | Attempt to transform conditional jumps into branch-less equivalents. This |
12652 | includes use of conditional moves, min, max, set flags and abs instructions, and | |
12653 | some tricks doable by standard arithmetics. The use of conditional execution | |
12654 | on chips where it is available is controlled by @option{-fif-conversion2}. | |
12655 | ||
12656 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but | |
12657 | not with @option{-Og}. | |
12658 | ||
d77de738 | 12659 | @opindex fif-conversion2 |
ddf6fe37 | 12660 | @item -fif-conversion2 |
d77de738 ML |
12661 | Use conditional execution (where available) to transform conditional jumps into |
12662 | branch-less equivalents. | |
12663 | ||
12664 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but | |
12665 | not with @option{-Og}. | |
12666 | ||
d77de738 | 12667 | @opindex fdeclone-ctor-dtor |
ddf6fe37 | 12668 | @item -fdeclone-ctor-dtor |
d77de738 ML |
12669 | The C++ ABI requires multiple entry points for constructors and |
12670 | destructors: one for a base subobject, one for a complete object, and | |
12671 | one for a virtual destructor that calls operator delete afterwards. | |
12672 | For a hierarchy with virtual bases, the base and complete variants are | |
12673 | clones, which means two copies of the function. With this option, the | |
12674 | base and complete variants are changed to be thunks that call a common | |
12675 | implementation. | |
12676 | ||
12677 | Enabled by @option{-Os}. | |
12678 | ||
d77de738 | 12679 | @opindex fdelete-null-pointer-checks |
ddf6fe37 | 12680 | @item -fdelete-null-pointer-checks |
d77de738 ML |
12681 | Assume that programs cannot safely dereference null pointers, and that |
12682 | no code or data element resides at address zero. | |
12683 | This option enables simple constant | |
12684 | folding optimizations at all optimization levels. In addition, other | |
12685 | optimization passes in GCC use this flag to control global dataflow | |
12686 | analyses that eliminate useless checks for null pointers; these assume | |
12687 | that a memory access to address zero always results in a trap, so | |
12688 | that if a pointer is checked after it has already been dereferenced, | |
12689 | it cannot be null. | |
12690 | ||
12691 | Note however that in some environments this assumption is not true. | |
12692 | Use @option{-fno-delete-null-pointer-checks} to disable this optimization | |
12693 | for programs that depend on that behavior. | |
12694 | ||
12695 | This option is enabled by default on most targets. On Nios II ELF, it | |
12696 | defaults to off. On AVR and MSP430, this option is completely disabled. | |
12697 | ||
12698 | Passes that use the dataflow information | |
12699 | are enabled independently at different optimization levels. | |
12700 | ||
d77de738 | 12701 | @opindex fdevirtualize |
ddf6fe37 | 12702 | @item -fdevirtualize |
d77de738 ML |
12703 | Attempt to convert calls to virtual functions to direct calls. This |
12704 | is done both within a procedure and interprocedurally as part of | |
12705 | indirect inlining (@option{-findirect-inlining}) and interprocedural constant | |
12706 | propagation (@option{-fipa-cp}). | |
12707 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12708 | ||
d77de738 | 12709 | @opindex fdevirtualize-speculatively |
ddf6fe37 | 12710 | @item -fdevirtualize-speculatively |
d77de738 ML |
12711 | Attempt to convert calls to virtual functions to speculative direct calls. |
12712 | Based on the analysis of the type inheritance graph, determine for a given call | |
12713 | the set of likely targets. If the set is small, preferably of size 1, change | |
12714 | the call into a conditional deciding between direct and indirect calls. The | |
12715 | speculative calls enable more optimizations, such as inlining. When they seem | |
12716 | useless after further optimization, they are converted back into original form. | |
12717 | ||
d77de738 | 12718 | @opindex fdevirtualize-at-ltrans |
ddf6fe37 | 12719 | @item -fdevirtualize-at-ltrans |
d77de738 ML |
12720 | Stream extra information needed for aggressive devirtualization when running |
12721 | the link-time optimizer in local transformation mode. | |
12722 | This option enables more devirtualization but | |
12723 | significantly increases the size of streamed data. For this reason it is | |
12724 | disabled by default. | |
12725 | ||
d77de738 | 12726 | @opindex fexpensive-optimizations |
ddf6fe37 | 12727 | @item -fexpensive-optimizations |
d77de738 ML |
12728 | Perform a number of minor optimizations that are relatively expensive. |
12729 | ||
12730 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12731 | ||
d77de738 | 12732 | @opindex free |
ddf6fe37 | 12733 | @item -free |
d77de738 ML |
12734 | Attempt to remove redundant extension instructions. This is especially |
12735 | helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit | |
12736 | registers after writing to their lower 32-bit half. | |
12737 | ||
88ae53a3 LC |
12738 | Enabled for Alpha, AArch64, LoongArch, PowerPC, RISC-V, SPARC, h83000 and x86 at |
12739 | levels @option{-O2}, @option{-O3}, @option{-Os}. | |
d77de738 | 12740 | |
d77de738 ML |
12741 | @opindex fno-lifetime-dse |
12742 | @opindex flifetime-dse | |
ddf6fe37 | 12743 | @item -fno-lifetime-dse |
d77de738 ML |
12744 | In C++ the value of an object is only affected by changes within its |
12745 | lifetime: when the constructor begins, the object has an indeterminate | |
12746 | value, and any changes during the lifetime of the object are dead when | |
12747 | the object is destroyed. Normally dead store elimination will take | |
12748 | advantage of this; if your code relies on the value of the object | |
12749 | storage persisting beyond the lifetime of the object, you can use this | |
12750 | flag to disable this optimization. To preserve stores before the | |
12751 | constructor starts (e.g.@: because your operator new clears the object | |
12752 | storage) but still treat the object as dead after the destructor, you | |
12753 | can use @option{-flifetime-dse=1}. The default behavior can be | |
12754 | explicitly selected with @option{-flifetime-dse=2}. | |
12755 | @option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}. | |
12756 | ||
d77de738 | 12757 | @opindex flive-range-shrinkage |
ddf6fe37 | 12758 | @item -flive-range-shrinkage |
d77de738 ML |
12759 | Attempt to decrease register pressure through register live range |
12760 | shrinkage. This is helpful for fast processors with small or moderate | |
12761 | size register sets. | |
12762 | ||
d77de738 | 12763 | @opindex fira-algorithm |
ddf6fe37 | 12764 | @item -fira-algorithm=@var{algorithm} |
d77de738 ML |
12765 | Use the specified coloring algorithm for the integrated register |
12766 | allocator. The @var{algorithm} argument can be @samp{priority}, which | |
12767 | specifies Chow's priority coloring, or @samp{CB}, which specifies | |
12768 | Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented | |
12769 | for all architectures, but for those targets that do support it, it is | |
12770 | the default because it generates better code. | |
12771 | ||
d77de738 | 12772 | @opindex fira-region |
ddf6fe37 | 12773 | @item -fira-region=@var{region} |
d77de738 ML |
12774 | Use specified regions for the integrated register allocator. The |
12775 | @var{region} argument should be one of the following: | |
12776 | ||
12777 | @table @samp | |
12778 | ||
12779 | @item all | |
12780 | Use all loops as register allocation regions. | |
12781 | This can give the best results for machines with a small and/or | |
12782 | irregular register set. | |
12783 | ||
12784 | @item mixed | |
12785 | Use all loops except for loops with small register pressure | |
12786 | as the regions. This value usually gives | |
12787 | the best results in most cases and for most architectures, | |
12788 | and is enabled by default when compiling with optimization for speed | |
12789 | (@option{-O}, @option{-O2}, @dots{}). | |
12790 | ||
12791 | @item one | |
12792 | Use all functions as a single region. | |
12793 | This typically results in the smallest code size, and is enabled by default for | |
12794 | @option{-Os} or @option{-O0}. | |
12795 | ||
12796 | @end table | |
12797 | ||
d77de738 | 12798 | @opindex fira-hoist-pressure |
ddf6fe37 | 12799 | @item -fira-hoist-pressure |
d77de738 ML |
12800 | Use IRA to evaluate register pressure in the code hoisting pass for |
12801 | decisions to hoist expressions. This option usually results in smaller | |
12802 | code, but it can slow the compiler down. | |
12803 | ||
12804 | This option is enabled at level @option{-Os} for all targets. | |
12805 | ||
d77de738 | 12806 | @opindex fira-loop-pressure |
ddf6fe37 | 12807 | @item -fira-loop-pressure |
d77de738 ML |
12808 | Use IRA to evaluate register pressure in loops for decisions to move |
12809 | loop invariants. This option usually results in generation | |
12810 | of faster and smaller code on machines with large register files (>= 32 | |
12811 | registers), but it can slow the compiler down. | |
12812 | ||
12813 | This option is enabled at level @option{-O3} for some targets. | |
12814 | ||
d77de738 ML |
12815 | @opindex fno-ira-share-save-slots |
12816 | @opindex fira-share-save-slots | |
ddf6fe37 | 12817 | @item -fno-ira-share-save-slots |
d77de738 ML |
12818 | Disable sharing of stack slots used for saving call-used hard |
12819 | registers living through a call. Each hard register gets a | |
12820 | separate stack slot, and as a result function stack frames are | |
12821 | larger. | |
12822 | ||
d77de738 ML |
12823 | @opindex fno-ira-share-spill-slots |
12824 | @opindex fira-share-spill-slots | |
ddf6fe37 | 12825 | @item -fno-ira-share-spill-slots |
d77de738 ML |
12826 | Disable sharing of stack slots allocated for pseudo-registers. Each |
12827 | pseudo-register that does not get a hard register gets a separate | |
12828 | stack slot, and as a result function stack frames are larger. | |
12829 | ||
d77de738 | 12830 | @opindex flra-remat |
ddf6fe37 | 12831 | @item -flra-remat |
d77de738 ML |
12832 | Enable CFG-sensitive rematerialization in LRA. Instead of loading |
12833 | values of spilled pseudos, LRA tries to rematerialize (recalculate) | |
12834 | values if it is profitable. | |
12835 | ||
12836 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12837 | ||
d77de738 | 12838 | @opindex fdelayed-branch |
ddf6fe37 | 12839 | @item -fdelayed-branch |
d77de738 ML |
12840 | If supported for the target machine, attempt to reorder instructions |
12841 | to exploit instruction slots available after delayed branch | |
12842 | instructions. | |
12843 | ||
12844 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, | |
12845 | but not at @option{-Og}. | |
12846 | ||
d77de738 | 12847 | @opindex fschedule-insns |
ddf6fe37 | 12848 | @item -fschedule-insns |
d77de738 ML |
12849 | If supported for the target machine, attempt to reorder instructions to |
12850 | eliminate execution stalls due to required data being unavailable. This | |
12851 | helps machines that have slow floating point or memory load instructions | |
12852 | by allowing other instructions to be issued until the result of the load | |
12853 | or floating-point instruction is required. | |
12854 | ||
12855 | Enabled at levels @option{-O2}, @option{-O3}. | |
12856 | ||
d77de738 | 12857 | @opindex fschedule-insns2 |
ddf6fe37 | 12858 | @item -fschedule-insns2 |
d77de738 ML |
12859 | Similar to @option{-fschedule-insns}, but requests an additional pass of |
12860 | instruction scheduling after register allocation has been done. This is | |
12861 | especially useful on machines with a relatively small number of | |
12862 | registers and where memory load instructions take more than one cycle. | |
12863 | ||
12864 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12865 | ||
d77de738 ML |
12866 | @opindex fno-sched-interblock |
12867 | @opindex fsched-interblock | |
ddf6fe37 | 12868 | @item -fno-sched-interblock |
d77de738 ML |
12869 | Disable instruction scheduling across basic blocks, which |
12870 | is normally enabled when scheduling before register allocation, i.e.@: | |
12871 | with @option{-fschedule-insns} or at @option{-O2} or higher. | |
12872 | ||
d77de738 ML |
12873 | @opindex fno-sched-spec |
12874 | @opindex fsched-spec | |
ddf6fe37 | 12875 | @item -fno-sched-spec |
d77de738 ML |
12876 | Disable speculative motion of non-load instructions, which |
12877 | is normally enabled when scheduling before register allocation, i.e.@: | |
12878 | with @option{-fschedule-insns} or at @option{-O2} or higher. | |
12879 | ||
d77de738 | 12880 | @opindex fsched-pressure |
ddf6fe37 | 12881 | @item -fsched-pressure |
d77de738 ML |
12882 | Enable register pressure sensitive insn scheduling before register |
12883 | allocation. This only makes sense when scheduling before register | |
12884 | allocation is enabled, i.e.@: with @option{-fschedule-insns} or at | |
12885 | @option{-O2} or higher. Usage of this option can improve the | |
12886 | generated code and decrease its size by preventing register pressure | |
12887 | increase above the number of available hard registers and subsequent | |
12888 | spills in register allocation. | |
12889 | ||
d77de738 | 12890 | @opindex fsched-spec-load |
ddf6fe37 | 12891 | @item -fsched-spec-load |
d77de738 ML |
12892 | Allow speculative motion of some load instructions. This only makes |
12893 | sense when scheduling before register allocation, i.e.@: with | |
12894 | @option{-fschedule-insns} or at @option{-O2} or higher. | |
12895 | ||
d77de738 | 12896 | @opindex fsched-spec-load-dangerous |
ddf6fe37 | 12897 | @item -fsched-spec-load-dangerous |
d77de738 ML |
12898 | Allow speculative motion of more load instructions. This only makes |
12899 | sense when scheduling before register allocation, i.e.@: with | |
12900 | @option{-fschedule-insns} or at @option{-O2} or higher. | |
12901 | ||
ddf6fe37 | 12902 | @opindex fsched-stalled-insns |
d77de738 ML |
12903 | @item -fsched-stalled-insns |
12904 | @itemx -fsched-stalled-insns=@var{n} | |
d77de738 ML |
12905 | Define how many insns (if any) can be moved prematurely from the queue |
12906 | of stalled insns into the ready list during the second scheduling pass. | |
12907 | @option{-fno-sched-stalled-insns} means that no insns are moved | |
12908 | prematurely, @option{-fsched-stalled-insns=0} means there is no limit | |
12909 | on how many queued insns can be moved prematurely. | |
12910 | @option{-fsched-stalled-insns} without a value is equivalent to | |
12911 | @option{-fsched-stalled-insns=1}. | |
12912 | ||
ddf6fe37 | 12913 | @opindex fsched-stalled-insns-dep |
d77de738 ML |
12914 | @item -fsched-stalled-insns-dep |
12915 | @itemx -fsched-stalled-insns-dep=@var{n} | |
d77de738 ML |
12916 | Define how many insn groups (cycles) are examined for a dependency |
12917 | on a stalled insn that is a candidate for premature removal from the queue | |
12918 | of stalled insns. This has an effect only during the second scheduling pass, | |
12919 | and only if @option{-fsched-stalled-insns} is used. | |
12920 | @option{-fno-sched-stalled-insns-dep} is equivalent to | |
12921 | @option{-fsched-stalled-insns-dep=0}. | |
12922 | @option{-fsched-stalled-insns-dep} without a value is equivalent to | |
12923 | @option{-fsched-stalled-insns-dep=1}. | |
12924 | ||
d77de738 | 12925 | @opindex fsched2-use-superblocks |
ddf6fe37 | 12926 | @item -fsched2-use-superblocks |
d77de738 ML |
12927 | When scheduling after register allocation, use superblock scheduling. |
12928 | This allows motion across basic block boundaries, | |
12929 | resulting in faster schedules. This option is experimental, as not all machine | |
12930 | descriptions used by GCC model the CPU closely enough to avoid unreliable | |
12931 | results from the algorithm. | |
12932 | ||
12933 | This only makes sense when scheduling after register allocation, i.e.@: with | |
12934 | @option{-fschedule-insns2} or at @option{-O2} or higher. | |
12935 | ||
d77de738 | 12936 | @opindex fsched-group-heuristic |
ddf6fe37 | 12937 | @item -fsched-group-heuristic |
d77de738 ML |
12938 | Enable the group heuristic in the scheduler. This heuristic favors |
12939 | the instruction that belongs to a schedule group. This is enabled | |
12940 | by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns} | |
12941 | or @option{-fschedule-insns2} or at @option{-O2} or higher. | |
12942 | ||
d77de738 | 12943 | @opindex fsched-critical-path-heuristic |
ddf6fe37 | 12944 | @item -fsched-critical-path-heuristic |
d77de738 ML |
12945 | Enable the critical-path heuristic in the scheduler. This heuristic favors |
12946 | instructions on the critical path. This is enabled by default when | |
12947 | scheduling is enabled, i.e.@: with @option{-fschedule-insns} | |
12948 | or @option{-fschedule-insns2} or at @option{-O2} or higher. | |
12949 | ||
d77de738 | 12950 | @opindex fsched-spec-insn-heuristic |
ddf6fe37 | 12951 | @item -fsched-spec-insn-heuristic |
d77de738 ML |
12952 | Enable the speculative instruction heuristic in the scheduler. This |
12953 | heuristic favors speculative instructions with greater dependency weakness. | |
12954 | This is enabled by default when scheduling is enabled, i.e.@: | |
12955 | with @option{-fschedule-insns} or @option{-fschedule-insns2} | |
12956 | or at @option{-O2} or higher. | |
12957 | ||
d77de738 | 12958 | @opindex fsched-rank-heuristic |
ddf6fe37 | 12959 | @item -fsched-rank-heuristic |
d77de738 ML |
12960 | Enable the rank heuristic in the scheduler. This heuristic favors |
12961 | the instruction belonging to a basic block with greater size or frequency. | |
12962 | This is enabled by default when scheduling is enabled, i.e.@: | |
12963 | with @option{-fschedule-insns} or @option{-fschedule-insns2} or | |
12964 | at @option{-O2} or higher. | |
12965 | ||
d77de738 | 12966 | @opindex fsched-last-insn-heuristic |
ddf6fe37 | 12967 | @item -fsched-last-insn-heuristic |
d77de738 ML |
12968 | Enable the last-instruction heuristic in the scheduler. This heuristic |
12969 | favors the instruction that is less dependent on the last instruction | |
12970 | scheduled. This is enabled by default when scheduling is enabled, | |
12971 | i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or | |
12972 | at @option{-O2} or higher. | |
12973 | ||
d77de738 | 12974 | @opindex fsched-dep-count-heuristic |
ddf6fe37 | 12975 | @item -fsched-dep-count-heuristic |
d77de738 ML |
12976 | Enable the dependent-count heuristic in the scheduler. This heuristic |
12977 | favors the instruction that has more instructions depending on it. | |
12978 | This is enabled by default when scheduling is enabled, i.e.@: | |
12979 | with @option{-fschedule-insns} or @option{-fschedule-insns2} or | |
12980 | at @option{-O2} or higher. | |
12981 | ||
d77de738 | 12982 | @opindex freschedule-modulo-scheduled-loops |
ddf6fe37 | 12983 | @item -freschedule-modulo-scheduled-loops |
d77de738 ML |
12984 | Modulo scheduling is performed before traditional scheduling. If a loop |
12985 | is modulo scheduled, later scheduling passes may change its schedule. | |
12986 | Use this option to control that behavior. | |
12987 | ||
d77de738 | 12988 | @opindex fselective-scheduling |
ddf6fe37 | 12989 | @item -fselective-scheduling |
d77de738 ML |
12990 | Schedule instructions using selective scheduling algorithm. Selective |
12991 | scheduling runs instead of the first scheduler pass. | |
12992 | ||
d77de738 | 12993 | @opindex fselective-scheduling2 |
ddf6fe37 | 12994 | @item -fselective-scheduling2 |
d77de738 ML |
12995 | Schedule instructions using selective scheduling algorithm. Selective |
12996 | scheduling runs instead of the second scheduler pass. | |
12997 | ||
d77de738 | 12998 | @opindex fsel-sched-pipelining |
ddf6fe37 | 12999 | @item -fsel-sched-pipelining |
d77de738 ML |
13000 | Enable software pipelining of innermost loops during selective scheduling. |
13001 | This option has no effect unless one of @option{-fselective-scheduling} or | |
13002 | @option{-fselective-scheduling2} is turned on. | |
13003 | ||
d77de738 | 13004 | @opindex fsel-sched-pipelining-outer-loops |
ddf6fe37 | 13005 | @item -fsel-sched-pipelining-outer-loops |
d77de738 ML |
13006 | When pipelining loops during selective scheduling, also pipeline outer loops. |
13007 | This option has no effect unless @option{-fsel-sched-pipelining} is turned on. | |
13008 | ||
d77de738 | 13009 | @opindex fsemantic-interposition |
ddf6fe37 | 13010 | @item -fsemantic-interposition |
d77de738 ML |
13011 | Some object formats, like ELF, allow interposing of symbols by the |
13012 | dynamic linker. | |
13013 | This means that for symbols exported from the DSO, the compiler cannot perform | |
13014 | interprocedural propagation, inlining and other optimizations in anticipation | |
13015 | that the function or variable in question may change. While this feature is | |
13016 | useful, for example, to rewrite memory allocation functions by a debugging | |
13017 | implementation, it is expensive in the terms of code quality. | |
13018 | With @option{-fno-semantic-interposition} the compiler assumes that | |
13019 | if interposition happens for functions the overwriting function will have | |
13020 | precisely the same semantics (and side effects). | |
13021 | Similarly if interposition happens | |
13022 | for variables, the constructor of the variable will be the same. The flag | |
13023 | has no effect for functions explicitly declared inline | |
13024 | (where it is never allowed for interposition to change semantics) | |
13025 | and for symbols explicitly declared weak. | |
13026 | ||
d77de738 | 13027 | @opindex fshrink-wrap |
ddf6fe37 | 13028 | @item -fshrink-wrap |
d77de738 ML |
13029 | Emit function prologues only before parts of the function that need it, |
13030 | rather than at the top of the function. This flag is enabled by default at | |
13031 | @option{-O} and higher. | |
13032 | ||
d77de738 | 13033 | @opindex fshrink-wrap-separate |
ddf6fe37 | 13034 | @item -fshrink-wrap-separate |
d77de738 ML |
13035 | Shrink-wrap separate parts of the prologue and epilogue separately, so that |
13036 | those parts are only executed when needed. | |
13037 | This option is on by default, but has no effect unless @option{-fshrink-wrap} | |
13038 | is also turned on and the target supports this. | |
13039 | ||
d77de738 | 13040 | @opindex fcaller-saves |
ddf6fe37 | 13041 | @item -fcaller-saves |
d77de738 ML |
13042 | Enable allocation of values to registers that are clobbered by |
13043 | function calls, by emitting extra instructions to save and restore the | |
13044 | registers around such calls. Such allocation is done only when it | |
13045 | seems to result in better code. | |
13046 | ||
13047 | This option is always enabled by default on certain machines, usually | |
13048 | those which have no call-preserved registers to use instead. | |
13049 | ||
13050 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13051 | ||
d77de738 | 13052 | @opindex fcombine-stack-adjustments |
ddf6fe37 | 13053 | @item -fcombine-stack-adjustments |
d77de738 ML |
13054 | Tracks stack adjustments (pushes and pops) and stack memory references |
13055 | and then tries to find ways to combine them. | |
13056 | ||
13057 | Enabled by default at @option{-O1} and higher. | |
13058 | ||
d77de738 | 13059 | @opindex fipa-ra |
ddf6fe37 | 13060 | @item -fipa-ra |
d77de738 ML |
13061 | Use caller save registers for allocation if those registers are not used by |
13062 | any called function. In that case it is not necessary to save and restore | |
13063 | them around calls. This is only possible if called functions are part of | |
13064 | same compilation unit as current function and they are compiled before it. | |
13065 | ||
13066 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option | |
13067 | is disabled if generated code will be instrumented for profiling | |
13068 | (@option{-p}, or @option{-pg}) or if callee's register usage cannot be known | |
13069 | exactly (this happens on targets that do not expose prologues | |
13070 | and epilogues in RTL). | |
13071 | ||
d77de738 | 13072 | @opindex fconserve-stack |
ddf6fe37 | 13073 | @item -fconserve-stack |
d77de738 ML |
13074 | Attempt to minimize stack usage. The compiler attempts to use less |
13075 | stack space, even if that makes the program slower. This option | |
13076 | implies setting the @option{large-stack-frame} parameter to 100 | |
13077 | and the @option{large-stack-frame-growth} parameter to 400. | |
13078 | ||
d77de738 | 13079 | @opindex ftree-reassoc |
ddf6fe37 | 13080 | @item -ftree-reassoc |
d77de738 ML |
13081 | Perform reassociation on trees. This flag is enabled by default |
13082 | at @option{-O1} and higher. | |
13083 | ||
d77de738 | 13084 | @opindex fcode-hoisting |
ddf6fe37 | 13085 | @item -fcode-hoisting |
d77de738 ML |
13086 | Perform code hoisting. Code hoisting tries to move the |
13087 | evaluation of expressions executed on all paths to the function exit | |
13088 | as early as possible. This is especially useful as a code size | |
13089 | optimization, but it often helps for code speed as well. | |
13090 | This flag is enabled by default at @option{-O2} and higher. | |
13091 | ||
d77de738 | 13092 | @opindex ftree-pre |
ddf6fe37 | 13093 | @item -ftree-pre |
d77de738 ML |
13094 | Perform partial redundancy elimination (PRE) on trees. This flag is |
13095 | enabled by default at @option{-O2} and @option{-O3}. | |
13096 | ||
d77de738 | 13097 | @opindex ftree-partial-pre |
ddf6fe37 | 13098 | @item -ftree-partial-pre |
d77de738 ML |
13099 | Make partial redundancy elimination (PRE) more aggressive. This flag is |
13100 | enabled by default at @option{-O3}. | |
13101 | ||
d77de738 | 13102 | @opindex ftree-forwprop |
ddf6fe37 | 13103 | @item -ftree-forwprop |
d77de738 ML |
13104 | Perform forward propagation on trees. This flag is enabled by default |
13105 | at @option{-O1} and higher. | |
13106 | ||
d77de738 | 13107 | @opindex ftree-fre |
ddf6fe37 | 13108 | @item -ftree-fre |
d77de738 ML |
13109 | Perform full redundancy elimination (FRE) on trees. The difference |
13110 | between FRE and PRE is that FRE only considers expressions | |
13111 | that are computed on all paths leading to the redundant computation. | |
13112 | This analysis is faster than PRE, though it exposes fewer redundancies. | |
13113 | This flag is enabled by default at @option{-O1} and higher. | |
13114 | ||
d77de738 | 13115 | @opindex ftree-phiprop |
ddf6fe37 | 13116 | @item -ftree-phiprop |
d77de738 ML |
13117 | Perform hoisting of loads from conditional pointers on trees. This |
13118 | pass is enabled by default at @option{-O1} and higher. | |
13119 | ||
d77de738 | 13120 | @opindex fhoist-adjacent-loads |
ddf6fe37 | 13121 | @item -fhoist-adjacent-loads |
d77de738 ML |
13122 | Speculatively hoist loads from both branches of an if-then-else if the |
13123 | loads are from adjacent locations in the same structure and the target | |
13124 | architecture has a conditional move instruction. This flag is enabled | |
13125 | by default at @option{-O2} and higher. | |
13126 | ||
d77de738 | 13127 | @opindex ftree-copy-prop |
ddf6fe37 | 13128 | @item -ftree-copy-prop |
d77de738 ML |
13129 | Perform copy propagation on trees. This pass eliminates unnecessary |
13130 | copy operations. This flag is enabled by default at @option{-O1} and | |
13131 | higher. | |
13132 | ||
d77de738 | 13133 | @opindex fipa-pure-const |
ddf6fe37 | 13134 | @item -fipa-pure-const |
d77de738 ML |
13135 | Discover which functions are pure or constant. |
13136 | Enabled by default at @option{-O1} and higher. | |
13137 | ||
d77de738 | 13138 | @opindex fipa-reference |
ddf6fe37 | 13139 | @item -fipa-reference |
d77de738 ML |
13140 | Discover which static variables do not escape the |
13141 | compilation unit. | |
13142 | Enabled by default at @option{-O1} and higher. | |
13143 | ||
d77de738 | 13144 | @opindex fipa-reference-addressable |
ddf6fe37 | 13145 | @item -fipa-reference-addressable |
d77de738 ML |
13146 | Discover read-only, write-only and non-addressable static variables. |
13147 | Enabled by default at @option{-O1} and higher. | |
13148 | ||
d77de738 | 13149 | @opindex fipa-stack-alignment |
ddf6fe37 | 13150 | @item -fipa-stack-alignment |
d77de738 ML |
13151 | Reduce stack alignment on call sites if possible. |
13152 | Enabled by default. | |
13153 | ||
d77de738 | 13154 | @opindex fipa-pta |
ddf6fe37 | 13155 | @item -fipa-pta |
d77de738 ML |
13156 | Perform interprocedural pointer analysis and interprocedural modification |
13157 | and reference analysis. This option can cause excessive memory and | |
13158 | compile-time usage on large compilation units. It is not enabled by | |
13159 | default at any optimization level. | |
13160 | ||
d77de738 | 13161 | @opindex fipa-profile |
ddf6fe37 | 13162 | @item -fipa-profile |
d77de738 ML |
13163 | Perform interprocedural profile propagation. The functions called only from |
13164 | cold functions are marked as cold. Also functions executed once (such as | |
13165 | @code{cold}, @code{noreturn}, static constructors or destructors) are | |
13166 | identified. Cold functions and loop less parts of functions executed once are | |
13167 | then optimized for size. | |
13168 | Enabled by default at @option{-O1} and higher. | |
13169 | ||
d77de738 | 13170 | @opindex fipa-modref |
ddf6fe37 | 13171 | @item -fipa-modref |
d77de738 ML |
13172 | Perform interprocedural mod/ref analysis. This optimization analyzes the side |
13173 | effects of functions (memory locations that are modified or referenced) and | |
13174 | enables better optimization across the function call boundary. This flag is | |
13175 | enabled by default at @option{-O1} and higher. | |
13176 | ||
d77de738 | 13177 | @opindex fipa-cp |
ddf6fe37 | 13178 | @item -fipa-cp |
d77de738 ML |
13179 | Perform interprocedural constant propagation. |
13180 | This optimization analyzes the program to determine when values passed | |
13181 | to functions are constants and then optimizes accordingly. | |
13182 | This optimization can substantially increase performance | |
13183 | if the application has constants passed to functions. | |
13184 | This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}. | |
13185 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13186 | ||
d77de738 | 13187 | @opindex fipa-cp-clone |
ddf6fe37 | 13188 | @item -fipa-cp-clone |
d77de738 ML |
13189 | Perform function cloning to make interprocedural constant propagation stronger. |
13190 | When enabled, interprocedural constant propagation performs function cloning | |
13191 | when externally visible function can be called with constant arguments. | |
13192 | Because this optimization can create multiple copies of functions, | |
13193 | it may significantly increase code size | |
13194 | (see @option{--param ipa-cp-unit-growth=@var{value}}). | |
13195 | This flag is enabled by default at @option{-O3}. | |
13196 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13197 | ||
d77de738 | 13198 | @opindex fipa-bit-cp |
ddf6fe37 | 13199 | @item -fipa-bit-cp |
d77de738 ML |
13200 | When enabled, perform interprocedural bitwise constant |
13201 | propagation. This flag is enabled by default at @option{-O2} and | |
13202 | by @option{-fprofile-use} and @option{-fauto-profile}. | |
13203 | It requires that @option{-fipa-cp} is enabled. | |
13204 | ||
d77de738 | 13205 | @opindex fipa-vrp |
ddf6fe37 | 13206 | @item -fipa-vrp |
d77de738 ML |
13207 | When enabled, perform interprocedural propagation of value |
13208 | ranges. This flag is enabled by default at @option{-O2}. It requires | |
13209 | that @option{-fipa-cp} is enabled. | |
13210 | ||
d77de738 | 13211 | @opindex fipa-icf |
ddf6fe37 | 13212 | @item -fipa-icf |
d77de738 ML |
13213 | Perform Identical Code Folding for functions and read-only variables. |
13214 | The optimization reduces code size and may disturb unwind stacks by replacing | |
13215 | a function by equivalent one with a different name. The optimization works | |
13216 | more effectively with link-time optimization enabled. | |
13217 | ||
13218 | Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF | |
13219 | works on different levels and thus the optimizations are not same - there are | |
13220 | equivalences that are found only by GCC and equivalences found only by Gold. | |
13221 | ||
13222 | This flag is enabled by default at @option{-O2} and @option{-Os}. | |
13223 | ||
d77de738 | 13224 | @opindex flive-patching |
ddf6fe37 | 13225 | @item -flive-patching=@var{level} |
d77de738 ML |
13226 | Control GCC's optimizations to produce output suitable for live-patching. |
13227 | ||
13228 | If the compiler's optimization uses a function's body or information extracted | |
13229 | from its body to optimize/change another function, the latter is called an | |
13230 | impacted function of the former. If a function is patched, its impacted | |
13231 | functions should be patched too. | |
13232 | ||
13233 | The impacted functions are determined by the compiler's interprocedural | |
13234 | optimizations. For example, a caller is impacted when inlining a function | |
13235 | into its caller, | |
13236 | cloning a function and changing its caller to call this new clone, | |
13237 | or extracting a function's pureness/constness information to optimize | |
13238 | its direct or indirect callers, etc. | |
13239 | ||
13240 | Usually, the more IPA optimizations enabled, the larger the number of | |
13241 | impacted functions for each function. In order to control the number of | |
13242 | impacted functions and more easily compute the list of impacted function, | |
13243 | IPA optimizations can be partially enabled at two different levels. | |
13244 | ||
13245 | The @var{level} argument should be one of the following: | |
13246 | ||
13247 | @table @samp | |
13248 | ||
13249 | @item inline-clone | |
13250 | ||
13251 | Only enable inlining and cloning optimizations, which includes inlining, | |
13252 | cloning, interprocedural scalar replacement of aggregates and partial inlining. | |
13253 | As a result, when patching a function, all its callers and its clones' | |
13254 | callers are impacted, therefore need to be patched as well. | |
13255 | ||
13256 | @option{-flive-patching=inline-clone} disables the following optimization flags: | |
43b72ede AA |
13257 | @gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra |
13258 | -fipa-icf -fipa-icf-functions -fipa-icf-variables | |
13259 | -fipa-bit-cp -fipa-vrp -fipa-pure-const | |
13260 | -fipa-reference-addressable | |
d77de738 ML |
13261 | -fipa-stack-alignment -fipa-modref} |
13262 | ||
13263 | @item inline-only-static | |
13264 | ||
13265 | Only enable inlining of static functions. | |
13266 | As a result, when patching a static function, all its callers are impacted | |
13267 | and so need to be patched as well. | |
13268 | ||
13269 | In addition to all the flags that @option{-flive-patching=inline-clone} | |
13270 | disables, | |
13271 | @option{-flive-patching=inline-only-static} disables the following additional | |
13272 | optimization flags: | |
13273 | @gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp} | |
13274 | ||
13275 | @end table | |
13276 | ||
13277 | When @option{-flive-patching} is specified without any value, the default value | |
13278 | is @var{inline-clone}. | |
13279 | ||
13280 | This flag is disabled by default. | |
13281 | ||
13282 | Note that @option{-flive-patching} is not supported with link-time optimization | |
13283 | (@option{-flto}). | |
13284 | ||
d77de738 | 13285 | @opindex fisolate-erroneous-paths-dereference |
ddf6fe37 | 13286 | @item -fisolate-erroneous-paths-dereference |
d77de738 ML |
13287 | Detect paths that trigger erroneous or undefined behavior due to |
13288 | dereferencing a null pointer. Isolate those paths from the main control | |
13289 | flow and turn the statement with erroneous or undefined behavior into a trap. | |
13290 | This flag is enabled by default at @option{-O2} and higher and depends on | |
13291 | @option{-fdelete-null-pointer-checks} also being enabled. | |
13292 | ||
d77de738 | 13293 | @opindex fisolate-erroneous-paths-attribute |
ddf6fe37 | 13294 | @item -fisolate-erroneous-paths-attribute |
d77de738 ML |
13295 | Detect paths that trigger erroneous or undefined behavior due to a null value |
13296 | being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull} | |
13297 | attribute. Isolate those paths from the main control flow and turn the | |
13298 | statement with erroneous or undefined behavior into a trap. This is not | |
13299 | currently enabled, but may be enabled by @option{-O2} in the future. | |
13300 | ||
d77de738 | 13301 | @opindex ftree-sink |
ddf6fe37 | 13302 | @item -ftree-sink |
d77de738 ML |
13303 | Perform forward store motion on trees. This flag is |
13304 | enabled by default at @option{-O1} and higher. | |
13305 | ||
d77de738 | 13306 | @opindex ftree-bit-ccp |
ddf6fe37 | 13307 | @item -ftree-bit-ccp |
d77de738 ML |
13308 | Perform sparse conditional bit constant propagation on trees and propagate |
13309 | pointer alignment information. | |
13310 | This pass only operates on local scalar variables and is enabled by default | |
13311 | at @option{-O1} and higher, except for @option{-Og}. | |
13312 | It requires that @option{-ftree-ccp} is enabled. | |
13313 | ||
d77de738 | 13314 | @opindex ftree-ccp |
ddf6fe37 | 13315 | @item -ftree-ccp |
d77de738 ML |
13316 | Perform sparse conditional constant propagation (CCP) on trees. This |
13317 | pass only operates on local scalar variables and is enabled by default | |
13318 | at @option{-O1} and higher. | |
13319 | ||
d77de738 | 13320 | @opindex fssa-backprop |
ddf6fe37 | 13321 | @item -fssa-backprop |
d77de738 ML |
13322 | Propagate information about uses of a value up the definition chain |
13323 | in order to simplify the definitions. For example, this pass strips | |
13324 | sign operations if the sign of a value never matters. The flag is | |
13325 | enabled by default at @option{-O1} and higher. | |
13326 | ||
d77de738 | 13327 | @opindex fssa-phiopt |
ddf6fe37 | 13328 | @item -fssa-phiopt |
d77de738 ML |
13329 | Perform pattern matching on SSA PHI nodes to optimize conditional |
13330 | code. This pass is enabled by default at @option{-O1} and higher, | |
13331 | except for @option{-Og}. | |
13332 | ||
d77de738 | 13333 | @opindex ftree-switch-conversion |
ddf6fe37 | 13334 | @item -ftree-switch-conversion |
d77de738 ML |
13335 | Perform conversion of simple initializations in a switch to |
13336 | initializations from a scalar array. This flag is enabled by default | |
13337 | at @option{-O2} and higher. | |
13338 | ||
d77de738 | 13339 | @opindex ftree-tail-merge |
ddf6fe37 | 13340 | @item -ftree-tail-merge |
d77de738 ML |
13341 | Look for identical code sequences. When found, replace one with a jump to the |
13342 | other. This optimization is known as tail merging or cross jumping. This flag | |
13343 | is enabled by default at @option{-O2} and higher. The compilation time | |
13344 | in this pass can | |
13345 | be limited using @option{max-tail-merge-comparisons} parameter and | |
13346 | @option{max-tail-merge-iterations} parameter. | |
13347 | ||
d77de738 | 13348 | @opindex ftree-dce |
ddf6fe37 | 13349 | @item -ftree-dce |
d77de738 ML |
13350 | Perform dead code elimination (DCE) on trees. This flag is enabled by |
13351 | default at @option{-O1} and higher. | |
13352 | ||
d77de738 | 13353 | @opindex ftree-builtin-call-dce |
ddf6fe37 | 13354 | @item -ftree-builtin-call-dce |
d77de738 ML |
13355 | Perform conditional dead code elimination (DCE) for calls to built-in functions |
13356 | that may set @code{errno} but are otherwise free of side effects. This flag is | |
13357 | enabled by default at @option{-O2} and higher if @option{-Os} is not also | |
13358 | specified. | |
13359 | ||
d77de738 ML |
13360 | @opindex ffinite-loops |
13361 | @opindex fno-finite-loops | |
ddf6fe37 | 13362 | @item -ffinite-loops |
d77de738 ML |
13363 | Assume that a loop with an exit will eventually take the exit and not loop |
13364 | indefinitely. This allows the compiler to remove loops that otherwise have | |
13365 | no side-effects, not considering eventual endless looping as such. | |
13366 | ||
13367 | This option is enabled by default at @option{-O2} for C++ with -std=c++11 | |
13368 | or higher. | |
13369 | ||
d77de738 | 13370 | @opindex ftree-dominator-opts |
ddf6fe37 | 13371 | @item -ftree-dominator-opts |
d77de738 ML |
13372 | Perform a variety of simple scalar cleanups (constant/copy |
13373 | propagation, redundancy elimination, range propagation and expression | |
13374 | simplification) based on a dominator tree traversal. This also | |
13375 | performs jump threading (to reduce jumps to jumps). This flag is | |
13376 | enabled by default at @option{-O1} and higher. | |
13377 | ||
d77de738 | 13378 | @opindex ftree-dse |
ddf6fe37 | 13379 | @item -ftree-dse |
d77de738 ML |
13380 | Perform dead store elimination (DSE) on trees. A dead store is a store into |
13381 | a memory location that is later overwritten by another store without | |
13382 | any intervening loads. In this case the earlier store can be deleted. This | |
13383 | flag is enabled by default at @option{-O1} and higher. | |
13384 | ||
d77de738 | 13385 | @opindex ftree-ch |
ddf6fe37 | 13386 | @item -ftree-ch |
d77de738 ML |
13387 | Perform loop header copying on trees. This is beneficial since it increases |
13388 | effectiveness of code motion optimizations. It also saves one jump. This flag | |
13389 | is enabled by default at @option{-O1} and higher. It is not enabled | |
13390 | for @option{-Os}, since it usually increases code size. | |
13391 | ||
d77de738 | 13392 | @opindex ftree-loop-optimize |
ddf6fe37 | 13393 | @item -ftree-loop-optimize |
d77de738 ML |
13394 | Perform loop optimizations on trees. This flag is enabled by default |
13395 | at @option{-O1} and higher. | |
13396 | ||
d77de738 ML |
13397 | @opindex ftree-loop-linear |
13398 | @opindex floop-strip-mine | |
13399 | @opindex floop-block | |
ddf6fe37 AA |
13400 | @item -ftree-loop-linear |
13401 | @itemx -floop-strip-mine | |
13402 | @itemx -floop-block | |
d77de738 ML |
13403 | Perform loop nest optimizations. Same as |
13404 | @option{-floop-nest-optimize}. To use this code transformation, GCC has | |
13405 | to be configured with @option{--with-isl} to enable the Graphite loop | |
13406 | transformation infrastructure. | |
13407 | ||
d77de738 | 13408 | @opindex fgraphite-identity |
ddf6fe37 | 13409 | @item -fgraphite-identity |
d77de738 ML |
13410 | Enable the identity transformation for graphite. For every SCoP we generate |
13411 | the polyhedral representation and transform it back to gimple. Using | |
13412 | @option{-fgraphite-identity} we can check the costs or benefits of the | |
13413 | GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations | |
13414 | are also performed by the code generator isl, like index splitting and | |
13415 | dead code elimination in loops. | |
13416 | ||
d77de738 | 13417 | @opindex floop-nest-optimize |
ddf6fe37 | 13418 | @item -floop-nest-optimize |
d77de738 ML |
13419 | Enable the isl based loop nest optimizer. This is a generic loop nest |
13420 | optimizer based on the Pluto optimization algorithms. It calculates a loop | |
13421 | structure optimized for data-locality and parallelism. This option | |
13422 | is experimental. | |
13423 | ||
d77de738 | 13424 | @opindex floop-parallelize-all |
ddf6fe37 | 13425 | @item -floop-parallelize-all |
d77de738 ML |
13426 | Use the Graphite data dependence analysis to identify loops that can |
13427 | be parallelized. Parallelize all the loops that can be analyzed to | |
13428 | not contain loop carried dependences without checking that it is | |
13429 | profitable to parallelize the loops. | |
13430 | ||
d77de738 | 13431 | @opindex ftree-coalesce-vars |
ddf6fe37 | 13432 | @item -ftree-coalesce-vars |
d77de738 ML |
13433 | While transforming the program out of the SSA representation, attempt to |
13434 | reduce copying by coalescing versions of different user-defined | |
13435 | variables, instead of just compiler temporaries. This may severely | |
13436 | limit the ability to debug an optimized program compiled with | |
13437 | @option{-fno-var-tracking-assignments}. In the negated form, this flag | |
13438 | prevents SSA coalescing of user variables. This option is enabled by | |
13439 | default if optimization is enabled, and it does very little otherwise. | |
13440 | ||
d77de738 | 13441 | @opindex ftree-loop-if-convert |
ddf6fe37 | 13442 | @item -ftree-loop-if-convert |
d77de738 ML |
13443 | Attempt to transform conditional jumps in the innermost loops to |
13444 | branch-less equivalents. The intent is to remove control-flow from | |
13445 | the innermost loops in order to improve the ability of the | |
13446 | vectorization pass to handle these loops. This is enabled by default | |
13447 | if vectorization is enabled. | |
13448 | ||
d77de738 | 13449 | @opindex ftree-loop-distribution |
ddf6fe37 | 13450 | @item -ftree-loop-distribution |
d77de738 ML |
13451 | Perform loop distribution. This flag can improve cache performance on |
13452 | big loop bodies and allow further loop optimizations, like | |
13453 | parallelization or vectorization, to take place. For example, the loop | |
13454 | @smallexample | |
13455 | DO I = 1, N | |
13456 | A(I) = B(I) + C | |
13457 | D(I) = E(I) * F | |
13458 | ENDDO | |
13459 | @end smallexample | |
13460 | is transformed to | |
13461 | @smallexample | |
13462 | DO I = 1, N | |
13463 | A(I) = B(I) + C | |
13464 | ENDDO | |
13465 | DO I = 1, N | |
13466 | D(I) = E(I) * F | |
13467 | ENDDO | |
13468 | @end smallexample | |
13469 | This flag is enabled by default at @option{-O3}. | |
13470 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13471 | ||
d77de738 | 13472 | @opindex ftree-loop-distribute-patterns |
ddf6fe37 | 13473 | @item -ftree-loop-distribute-patterns |
d77de738 ML |
13474 | Perform loop distribution of patterns that can be code generated with |
13475 | calls to a library. This flag is enabled by default at @option{-O2} and | |
13476 | higher, and by @option{-fprofile-use} and @option{-fauto-profile}. | |
13477 | ||
13478 | This pass distributes the initialization loops and generates a call to | |
13479 | memset zero. For example, the loop | |
13480 | @smallexample | |
13481 | DO I = 1, N | |
13482 | A(I) = 0 | |
13483 | B(I) = A(I) + I | |
13484 | ENDDO | |
13485 | @end smallexample | |
13486 | is transformed to | |
13487 | @smallexample | |
13488 | DO I = 1, N | |
13489 | A(I) = 0 | |
13490 | ENDDO | |
13491 | DO I = 1, N | |
13492 | B(I) = A(I) + I | |
13493 | ENDDO | |
13494 | @end smallexample | |
13495 | and the initialization loop is transformed into a call to memset zero. | |
13496 | This flag is enabled by default at @option{-O3}. | |
13497 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13498 | ||
d77de738 | 13499 | @opindex floop-interchange |
ddf6fe37 | 13500 | @item -floop-interchange |
d77de738 ML |
13501 | Perform loop interchange outside of graphite. This flag can improve cache |
13502 | performance on loop nest and allow further loop optimizations, like | |
13503 | vectorization, to take place. For example, the loop | |
13504 | @smallexample | |
13505 | for (int i = 0; i < N; i++) | |
13506 | for (int j = 0; j < N; j++) | |
13507 | for (int k = 0; k < N; k++) | |
13508 | c[i][j] = c[i][j] + a[i][k]*b[k][j]; | |
13509 | @end smallexample | |
13510 | is transformed to | |
13511 | @smallexample | |
13512 | for (int i = 0; i < N; i++) | |
13513 | for (int k = 0; k < N; k++) | |
13514 | for (int j = 0; j < N; j++) | |
13515 | c[i][j] = c[i][j] + a[i][k]*b[k][j]; | |
13516 | @end smallexample | |
13517 | This flag is enabled by default at @option{-O3}. | |
13518 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13519 | ||
d77de738 | 13520 | @opindex floop-unroll-and-jam |
ddf6fe37 | 13521 | @item -floop-unroll-and-jam |
d77de738 ML |
13522 | Apply unroll and jam transformations on feasible loops. In a loop |
13523 | nest this unrolls the outer loop by some factor and fuses the resulting | |
13524 | multiple inner loops. This flag is enabled by default at @option{-O3}. | |
13525 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13526 | ||
d77de738 | 13527 | @opindex ftree-loop-im |
ddf6fe37 | 13528 | @item -ftree-loop-im |
d77de738 ML |
13529 | Perform loop invariant motion on trees. This pass moves only invariants that |
13530 | are hard to handle at RTL level (function calls, operations that expand to | |
13531 | nontrivial sequences of insns). With @option{-funswitch-loops} it also moves | |
13532 | operands of conditions that are invariant out of the loop, so that we can use | |
13533 | just trivial invariantness analysis in loop unswitching. The pass also includes | |
13534 | store motion. | |
13535 | ||
d77de738 | 13536 | @opindex ftree-loop-ivcanon |
ddf6fe37 | 13537 | @item -ftree-loop-ivcanon |
d77de738 ML |
13538 | Create a canonical counter for number of iterations in loops for which |
13539 | determining number of iterations requires complicated analysis. Later | |
13540 | optimizations then may determine the number easily. Useful especially | |
13541 | in connection with unrolling. | |
13542 | ||
d77de738 | 13543 | @opindex ftree-scev-cprop |
ddf6fe37 | 13544 | @item -ftree-scev-cprop |
d77de738 ML |
13545 | Perform final value replacement. If a variable is modified in a loop |
13546 | in such a way that its value when exiting the loop can be determined using | |
13547 | only its initial value and the number of loop iterations, replace uses of | |
13548 | the final value by such a computation, provided it is sufficiently cheap. | |
13549 | This reduces data dependencies and may allow further simplifications. | |
13550 | Enabled by default at @option{-O1} and higher. | |
13551 | ||
d77de738 | 13552 | @opindex fivopts |
ddf6fe37 | 13553 | @item -fivopts |
d77de738 ML |
13554 | Perform induction variable optimizations (strength reduction, induction |
13555 | variable merging and induction variable elimination) on trees. | |
13556 | ||
d77de738 | 13557 | @opindex ftree-parallelize-loops |
ddf6fe37 | 13558 | @item -ftree-parallelize-loops=n |
d77de738 ML |
13559 | Parallelize loops, i.e., split their iteration space to run in n threads. |
13560 | This is only possible for loops whose iterations are independent | |
13561 | and can be arbitrarily reordered. The optimization is only | |
13562 | profitable on multiprocessor machines, for loops that are CPU-intensive, | |
13563 | rather than constrained e.g.@: by memory bandwidth. This option | |
13564 | implies @option{-pthread}, and thus is only supported on targets | |
13565 | that have support for @option{-pthread}. | |
13566 | ||
d77de738 | 13567 | @opindex ftree-pta |
ddf6fe37 | 13568 | @item -ftree-pta |
d77de738 ML |
13569 | Perform function-local points-to analysis on trees. This flag is |
13570 | enabled by default at @option{-O1} and higher, except for @option{-Og}. | |
13571 | ||
d77de738 | 13572 | @opindex ftree-sra |
ddf6fe37 | 13573 | @item -ftree-sra |
d77de738 ML |
13574 | Perform scalar replacement of aggregates. This pass replaces structure |
13575 | references with scalars to prevent committing structures to memory too | |
13576 | early. This flag is enabled by default at @option{-O1} and higher, | |
13577 | except for @option{-Og}. | |
13578 | ||
d77de738 | 13579 | @opindex fstore-merging |
ddf6fe37 | 13580 | @item -fstore-merging |
d77de738 ML |
13581 | Perform merging of narrow stores to consecutive memory addresses. This pass |
13582 | merges contiguous stores of immediate values narrower than a word into fewer | |
13583 | wider stores to reduce the number of instructions. This is enabled by default | |
13584 | at @option{-O2} and higher as well as @option{-Os}. | |
13585 | ||
d77de738 | 13586 | @opindex ftree-ter |
ddf6fe37 | 13587 | @item -ftree-ter |
d77de738 ML |
13588 | Perform temporary expression replacement during the SSA->normal phase. Single |
13589 | use/single def temporaries are replaced at their use location with their | |
13590 | defining expression. This results in non-GIMPLE code, but gives the expanders | |
13591 | much more complex trees to work on resulting in better RTL generation. This is | |
13592 | enabled by default at @option{-O1} and higher. | |
13593 | ||
d77de738 | 13594 | @opindex ftree-slsr |
ddf6fe37 | 13595 | @item -ftree-slsr |
d77de738 ML |
13596 | Perform straight-line strength reduction on trees. This recognizes related |
13597 | expressions involving multiplications and replaces them by less expensive | |
13598 | calculations when possible. This is enabled by default at @option{-O1} and | |
13599 | higher. | |
13600 | ||
d77de738 | 13601 | @opindex ftree-vectorize |
ddf6fe37 | 13602 | @item -ftree-vectorize |
d77de738 ML |
13603 | Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize} |
13604 | and @option{-ftree-slp-vectorize} if not explicitly specified. | |
13605 | ||
d77de738 | 13606 | @opindex ftree-loop-vectorize |
ddf6fe37 | 13607 | @item -ftree-loop-vectorize |
d77de738 ML |
13608 | Perform loop vectorization on trees. This flag is enabled by default at |
13609 | @option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use}, | |
13610 | and @option{-fauto-profile}. | |
13611 | ||
d77de738 | 13612 | @opindex ftree-slp-vectorize |
ddf6fe37 | 13613 | @item -ftree-slp-vectorize |
d77de738 ML |
13614 | Perform basic block vectorization on trees. This flag is enabled by default at |
13615 | @option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use}, | |
13616 | and @option{-fauto-profile}. | |
13617 | ||
d77de738 | 13618 | @opindex ftrivial-auto-var-init |
ddf6fe37 | 13619 | @item -ftrivial-auto-var-init=@var{choice} |
d77de738 ML |
13620 | Initialize automatic variables with either a pattern or with zeroes to increase |
13621 | the security and predictability of a program by preventing uninitialized memory | |
13622 | disclosure and use. | |
13623 | GCC still considers an automatic variable that doesn't have an explicit | |
13624 | initializer as uninitialized, @option{-Wuninitialized} and | |
13625 | @option{-Wanalyzer-use-of-uninitialized-value} will still report | |
8f4634fb RB |
13626 | warning messages on such automatic variables and the compiler will |
13627 | perform optimization as if the variable were uninitialized. | |
d77de738 ML |
13628 | With this option, GCC will also initialize any padding of automatic variables |
13629 | that have structure or union types to zeroes. | |
13630 | However, the current implementation cannot initialize automatic variables that | |
13631 | are declared between the controlling expression and the first case of a | |
13632 | @code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all | |
13633 | such cases. | |
13634 | ||
13635 | The three values of @var{choice} are: | |
13636 | ||
13637 | @itemize @bullet | |
13638 | @item | |
13639 | @samp{uninitialized} doesn't initialize any automatic variables. | |
13640 | This is C and C++'s default. | |
13641 | ||
13642 | @item | |
13643 | @samp{pattern} Initialize automatic variables with values which will likely | |
13644 | transform logic bugs into crashes down the line, are easily recognized in a | |
13645 | crash dump and without being values that programmers can rely on for useful | |
13646 | program semantics. | |
13647 | The current value is byte-repeatable pattern with byte "0xFE". | |
13648 | The values used for pattern initialization might be changed in the future. | |
13649 | ||
13650 | @item | |
13651 | @samp{zero} Initialize automatic variables with zeroes. | |
13652 | @end itemize | |
13653 | ||
13654 | The default is @samp{uninitialized}. | |
13655 | ||
13656 | You can control this behavior for a specific variable by using the variable | |
13657 | attribute @code{uninitialized} (@pxref{Variable Attributes}). | |
13658 | ||
d77de738 | 13659 | @opindex fvect-cost-model |
ddf6fe37 | 13660 | @item -fvect-cost-model=@var{model} |
d77de738 ML |
13661 | Alter the cost model used for vectorization. The @var{model} argument |
13662 | should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or | |
13663 | @samp{very-cheap}. | |
13664 | With the @samp{unlimited} model the vectorized code-path is assumed | |
13665 | to be profitable while with the @samp{dynamic} model a runtime check | |
13666 | guards the vectorized code-path to enable it only for iteration | |
13667 | counts that will likely execute faster than when executing the original | |
13668 | scalar loop. The @samp{cheap} model disables vectorization of | |
13669 | loops where doing so would be cost prohibitive for example due to | |
13670 | required runtime checks for data dependence or alignment but otherwise | |
13671 | is equal to the @samp{dynamic} model. The @samp{very-cheap} model only | |
13672 | allows vectorization if the vector code would entirely replace the | |
13673 | scalar code that is being vectorized. For example, if each iteration | |
13674 | of a vectorized loop would only be able to handle exactly four iterations | |
13675 | of the scalar loop, the @samp{very-cheap} model would only allow | |
13676 | vectorization if the scalar iteration count is known to be a multiple | |
13677 | of four. | |
13678 | ||
13679 | The default cost model depends on other optimization flags and is | |
13680 | either @samp{dynamic} or @samp{cheap}. | |
13681 | ||
d77de738 | 13682 | @opindex fsimd-cost-model |
ddf6fe37 | 13683 | @item -fsimd-cost-model=@var{model} |
d77de738 ML |
13684 | Alter the cost model used for vectorization of loops marked with the OpenMP |
13685 | simd directive. The @var{model} argument should be one of | |
13686 | @samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model} | |
13687 | have the same meaning as described in @option{-fvect-cost-model} and by | |
13688 | default a cost model defined with @option{-fvect-cost-model} is used. | |
13689 | ||
d77de738 | 13690 | @opindex ftree-vrp |
ddf6fe37 | 13691 | @item -ftree-vrp |
d77de738 ML |
13692 | Perform Value Range Propagation on trees. This is similar to the |
13693 | constant propagation pass, but instead of values, ranges of values are | |
13694 | propagated. This allows the optimizers to remove unnecessary range | |
13695 | checks like array bound checks and null pointer checks. This is | |
13696 | enabled by default at @option{-O2} and higher. Null pointer check | |
13697 | elimination is only done if @option{-fdelete-null-pointer-checks} is | |
13698 | enabled. | |
13699 | ||
d77de738 | 13700 | @opindex fsplit-paths |
ddf6fe37 | 13701 | @item -fsplit-paths |
d77de738 ML |
13702 | Split paths leading to loop backedges. This can improve dead code |
13703 | elimination and common subexpression elimination. This is enabled by | |
13704 | default at @option{-O3} and above. | |
13705 | ||
d77de738 | 13706 | @opindex fsplit-ivs-in-unroller |
ddf6fe37 | 13707 | @item -fsplit-ivs-in-unroller |
d77de738 ML |
13708 | Enables expression of values of induction variables in later iterations |
13709 | of the unrolled loop using the value in the first iteration. This breaks | |
13710 | long dependency chains, thus improving efficiency of the scheduling passes. | |
13711 | ||
13712 | A combination of @option{-fweb} and CSE is often sufficient to obtain the | |
13713 | same effect. However, that is not reliable in cases where the loop body | |
13714 | is more complicated than a single basic block. It also does not work at all | |
13715 | on some architectures due to restrictions in the CSE pass. | |
13716 | ||
13717 | This optimization is enabled by default. | |
13718 | ||
d77de738 | 13719 | @opindex fvariable-expansion-in-unroller |
ddf6fe37 | 13720 | @item -fvariable-expansion-in-unroller |
d77de738 ML |
13721 | With this option, the compiler creates multiple copies of some |
13722 | local variables when unrolling a loop, which can result in superior code. | |
13723 | ||
13724 | This optimization is enabled by default for PowerPC targets, but disabled | |
13725 | by default otherwise. | |
13726 | ||
d77de738 | 13727 | @opindex fpartial-inlining |
ddf6fe37 | 13728 | @item -fpartial-inlining |
d77de738 ML |
13729 | Inline parts of functions. This option has any effect only |
13730 | when inlining itself is turned on by the @option{-finline-functions} | |
13731 | or @option{-finline-small-functions} options. | |
13732 | ||
13733 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13734 | ||
d77de738 | 13735 | @opindex fpredictive-commoning |
ddf6fe37 | 13736 | @item -fpredictive-commoning |
d77de738 ML |
13737 | Perform predictive commoning optimization, i.e., reusing computations |
13738 | (especially memory loads and stores) performed in previous | |
13739 | iterations of loops. | |
13740 | ||
13741 | This option is enabled at level @option{-O3}. | |
13742 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13743 | ||
d77de738 | 13744 | @opindex fprefetch-loop-arrays |
ddf6fe37 | 13745 | @item -fprefetch-loop-arrays |
d77de738 ML |
13746 | If supported by the target machine, generate instructions to prefetch |
13747 | memory to improve the performance of loops that access large arrays. | |
13748 | ||
13749 | This option may generate better or worse code; results are highly | |
13750 | dependent on the structure of loops within the source code. | |
13751 | ||
13752 | Disabled at level @option{-Os}. | |
13753 | ||
d77de738 ML |
13754 | @opindex fno-printf-return-value |
13755 | @opindex fprintf-return-value | |
ddf6fe37 | 13756 | @item -fno-printf-return-value |
d77de738 ML |
13757 | Do not substitute constants for known return value of formatted output |
13758 | functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and | |
13759 | @code{vsnprintf} (but not @code{printf} of @code{fprintf}). This | |
13760 | transformation allows GCC to optimize or even eliminate branches based | |
13761 | on the known return value of these functions called with arguments that | |
13762 | are either constant, or whose values are known to be in a range that | |
13763 | makes determining the exact return value possible. For example, when | |
13764 | @option{-fprintf-return-value} is in effect, both the branch and the | |
13765 | body of the @code{if} statement (but not the call to @code{snprint}) | |
13766 | can be optimized away when @code{i} is a 32-bit or smaller integer | |
13767 | because the return value is guaranteed to be at most 8. | |
13768 | ||
13769 | @smallexample | |
13770 | char buf[9]; | |
13771 | if (snprintf (buf, "%08x", i) >= sizeof buf) | |
13772 | @dots{} | |
13773 | @end smallexample | |
13774 | ||
13775 | The @option{-fprintf-return-value} option relies on other optimizations | |
13776 | and yields best results with @option{-O2} and above. It works in tandem | |
13777 | with the @option{-Wformat-overflow} and @option{-Wformat-truncation} | |
13778 | options. The @option{-fprintf-return-value} option is enabled by default. | |
13779 | ||
d77de738 ML |
13780 | @opindex fno-peephole |
13781 | @opindex fpeephole | |
13782 | @opindex fno-peephole2 | |
13783 | @opindex fpeephole2 | |
ddf6fe37 AA |
13784 | @item -fno-peephole |
13785 | @itemx -fno-peephole2 | |
d77de738 ML |
13786 | Disable any machine-specific peephole optimizations. The difference |
13787 | between @option{-fno-peephole} and @option{-fno-peephole2} is in how they | |
13788 | are implemented in the compiler; some targets use one, some use the | |
13789 | other, a few use both. | |
13790 | ||
13791 | @option{-fpeephole} is enabled by default. | |
13792 | @option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13793 | ||
d77de738 ML |
13794 | @opindex fno-guess-branch-probability |
13795 | @opindex fguess-branch-probability | |
ddf6fe37 | 13796 | @item -fno-guess-branch-probability |
d77de738 ML |
13797 | Do not guess branch probabilities using heuristics. |
13798 | ||
13799 | GCC uses heuristics to guess branch probabilities if they are | |
13800 | not provided by profiling feedback (@option{-fprofile-arcs}). These | |
13801 | heuristics are based on the control flow graph. If some branch probabilities | |
13802 | are specified by @code{__builtin_expect}, then the heuristics are | |
13803 | used to guess branch probabilities for the rest of the control flow graph, | |
13804 | taking the @code{__builtin_expect} info into account. The interactions | |
13805 | between the heuristics and @code{__builtin_expect} can be complex, and in | |
13806 | some cases, it may be useful to disable the heuristics so that the effects | |
13807 | of @code{__builtin_expect} are easier to understand. | |
13808 | ||
13809 | It is also possible to specify expected probability of the expression | |
13810 | with @code{__builtin_expect_with_probability} built-in function. | |
13811 | ||
13812 | The default is @option{-fguess-branch-probability} at levels | |
13813 | @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}. | |
13814 | ||
d77de738 | 13815 | @opindex freorder-blocks |
ddf6fe37 | 13816 | @item -freorder-blocks |
d77de738 ML |
13817 | Reorder basic blocks in the compiled function in order to reduce number of |
13818 | taken branches and improve code locality. | |
13819 | ||
13820 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
13821 | ||
d77de738 | 13822 | @opindex freorder-blocks-algorithm |
ddf6fe37 | 13823 | @item -freorder-blocks-algorithm=@var{algorithm} |
d77de738 ML |
13824 | Use the specified algorithm for basic block reordering. The |
13825 | @var{algorithm} argument can be @samp{simple}, which does not increase | |
13826 | code size (except sometimes due to secondary effects like alignment), | |
13827 | or @samp{stc}, the ``software trace cache'' algorithm, which tries to | |
13828 | put all often executed code together, minimizing the number of branches | |
13829 | executed by making extra copies of code. | |
13830 | ||
13831 | The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and | |
13832 | @samp{stc} at levels @option{-O2}, @option{-O3}. | |
13833 | ||
d77de738 | 13834 | @opindex freorder-blocks-and-partition |
ddf6fe37 | 13835 | @item -freorder-blocks-and-partition |
d77de738 ML |
13836 | In addition to reordering basic blocks in the compiled function, in order |
13837 | to reduce number of taken branches, partitions hot and cold basic blocks | |
13838 | into separate sections of the assembly and @file{.o} files, to improve | |
13839 | paging and cache locality performance. | |
13840 | ||
13841 | This optimization is automatically turned off in the presence of | |
13842 | exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined | |
13843 | section attribute and on any architecture that does not support named | |
13844 | sections. When @option{-fsplit-stack} is used this option is not | |
13845 | enabled by default (to avoid linker errors), but may be enabled | |
13846 | explicitly (if using a working linker). | |
13847 | ||
13848 | Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13849 | ||
d77de738 | 13850 | @opindex freorder-functions |
ddf6fe37 | 13851 | @item -freorder-functions |
d77de738 ML |
13852 | Reorder functions in the object file in order to |
13853 | improve code locality. This is implemented by using special | |
13854 | subsections @code{.text.hot} for most frequently executed functions and | |
13855 | @code{.text.unlikely} for unlikely executed functions. Reordering is done by | |
13856 | the linker so object file format must support named sections and linker must | |
13857 | place them in a reasonable way. | |
13858 | ||
13859 | This option isn't effective unless you either provide profile feedback | |
13860 | (see @option{-fprofile-arcs} for details) or manually annotate functions with | |
13861 | @code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}). | |
13862 | ||
13863 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13864 | ||
d77de738 | 13865 | @opindex fstrict-aliasing |
ddf6fe37 | 13866 | @item -fstrict-aliasing |
d77de738 ML |
13867 | Allow the compiler to assume the strictest aliasing rules applicable to |
13868 | the language being compiled. For C (and C++), this activates | |
13869 | optimizations based on the type of expressions. In particular, an | |
13870 | object of one type is assumed never to reside at the same address as an | |
13871 | object of a different type, unless the types are almost the same. For | |
13872 | example, an @code{unsigned int} can alias an @code{int}, but not a | |
13873 | @code{void*} or a @code{double}. A character type may alias any other | |
13874 | type. | |
13875 | ||
13876 | @anchor{Type-punning}Pay special attention to code like this: | |
13877 | @smallexample | |
13878 | union a_union @{ | |
13879 | int i; | |
13880 | double d; | |
13881 | @}; | |
13882 | ||
13883 | int f() @{ | |
13884 | union a_union t; | |
13885 | t.d = 3.0; | |
13886 | return t.i; | |
13887 | @} | |
13888 | @end smallexample | |
13889 | The practice of reading from a different union member than the one most | |
13890 | recently written to (called ``type-punning'') is common. Even with | |
13891 | @option{-fstrict-aliasing}, type-punning is allowed, provided the memory | |
13892 | is accessed through the union type. So, the code above works as | |
13893 | expected. @xref{Structures unions enumerations and bit-fields | |
13894 | implementation}. However, this code might not: | |
13895 | @smallexample | |
13896 | int f() @{ | |
13897 | union a_union t; | |
13898 | int* ip; | |
13899 | t.d = 3.0; | |
13900 | ip = &t.i; | |
13901 | return *ip; | |
13902 | @} | |
13903 | @end smallexample | |
13904 | ||
13905 | Similarly, access by taking the address, casting the resulting pointer | |
13906 | and dereferencing the result has undefined behavior, even if the cast | |
13907 | uses a union type, e.g.: | |
13908 | @smallexample | |
13909 | int f() @{ | |
13910 | double d = 3.0; | |
13911 | return ((union a_union *) &d)->i; | |
13912 | @} | |
13913 | @end smallexample | |
13914 | ||
13915 | The @option{-fstrict-aliasing} option is enabled at levels | |
13916 | @option{-O2}, @option{-O3}, @option{-Os}. | |
13917 | ||
d77de738 | 13918 | @opindex fipa-strict-aliasing |
ddf6fe37 | 13919 | @item -fipa-strict-aliasing |
d77de738 ML |
13920 | Controls whether rules of @option{-fstrict-aliasing} are applied across |
13921 | function boundaries. Note that if multiple functions gets inlined into a | |
13922 | single function the memory accesses are no longer considered to be crossing a | |
13923 | function boundary. | |
13924 | ||
13925 | The @option{-fipa-strict-aliasing} option is enabled by default and is | |
13926 | effective only in combination with @option{-fstrict-aliasing}. | |
13927 | ||
ddf6fe37 | 13928 | @opindex falign-functions |
d77de738 ML |
13929 | @item -falign-functions |
13930 | @itemx -falign-functions=@var{n} | |
13931 | @itemx -falign-functions=@var{n}:@var{m} | |
13932 | @itemx -falign-functions=@var{n}:@var{m}:@var{n2} | |
13933 | @itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
13934 | Align the start of functions to the next power-of-two greater than or |
13935 | equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at | |
13936 | least the first @var{m} bytes of the function can be fetched by the CPU | |
13937 | without crossing an @var{n}-byte alignment boundary. | |
13938 | ||
13939 | If @var{m} is not specified, it defaults to @var{n}. | |
13940 | ||
13941 | Examples: @option{-falign-functions=32} aligns functions to the next | |
13942 | 32-byte boundary, @option{-falign-functions=24} aligns to the next | |
13943 | 32-byte boundary only if this can be done by skipping 23 bytes or less, | |
13944 | @option{-falign-functions=32:7} aligns to the next | |
13945 | 32-byte boundary only if this can be done by skipping 6 bytes or less. | |
13946 | ||
13947 | The second pair of @var{n2}:@var{m2} values allows you to specify | |
13948 | a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to | |
13949 | the next 64-byte boundary if this can be done by skipping 6 bytes or less, | |
13950 | otherwise aligns to the next 32-byte boundary if this can be done | |
13951 | by skipping 2 bytes or less. | |
13952 | If @var{m2} is not specified, it defaults to @var{n2}. | |
13953 | ||
13954 | Some assemblers only support this flag when @var{n} is a power of two; | |
13955 | in that case, it is rounded up. | |
13956 | ||
13957 | @option{-fno-align-functions} and @option{-falign-functions=1} are | |
13958 | equivalent and mean that functions are not aligned. | |
13959 | ||
13960 | If @var{n} is not specified or is zero, use a machine-dependent default. | |
13961 | The maximum allowed @var{n} option value is 65536. | |
13962 | ||
13963 | Enabled at levels @option{-O2}, @option{-O3}. | |
13964 | ||
13965 | @item -flimit-function-alignment | |
13966 | If this option is enabled, the compiler tries to avoid unnecessarily | |
13967 | overaligning functions. It attempts to instruct the assembler to align | |
13968 | by the amount specified by @option{-falign-functions}, but not to | |
13969 | skip more bytes than the size of the function. | |
13970 | ||
ddf6fe37 | 13971 | @opindex falign-labels |
d77de738 ML |
13972 | @item -falign-labels |
13973 | @itemx -falign-labels=@var{n} | |
13974 | @itemx -falign-labels=@var{n}:@var{m} | |
13975 | @itemx -falign-labels=@var{n}:@var{m}:@var{n2} | |
13976 | @itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
13977 | Align all branch targets to a power-of-two boundary. |
13978 | ||
13979 | Parameters of this option are analogous to the @option{-falign-functions} option. | |
13980 | @option{-fno-align-labels} and @option{-falign-labels=1} are | |
13981 | equivalent and mean that labels are not aligned. | |
13982 | ||
13983 | If @option{-falign-loops} or @option{-falign-jumps} are applicable and | |
13984 | are greater than this value, then their values are used instead. | |
13985 | ||
13986 | If @var{n} is not specified or is zero, use a machine-dependent default | |
13987 | which is very likely to be @samp{1}, meaning no alignment. | |
13988 | The maximum allowed @var{n} option value is 65536. | |
13989 | ||
13990 | Enabled at levels @option{-O2}, @option{-O3}. | |
13991 | ||
ddf6fe37 | 13992 | @opindex falign-loops |
d77de738 ML |
13993 | @item -falign-loops |
13994 | @itemx -falign-loops=@var{n} | |
13995 | @itemx -falign-loops=@var{n}:@var{m} | |
13996 | @itemx -falign-loops=@var{n}:@var{m}:@var{n2} | |
13997 | @itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
13998 | Align loops to a power-of-two boundary. If the loops are executed |
13999 | many times, this makes up for any execution of the dummy padding | |
14000 | instructions. | |
14001 | ||
14002 | If @option{-falign-labels} is greater than this value, then its value | |
14003 | is used instead. | |
14004 | ||
14005 | Parameters of this option are analogous to the @option{-falign-functions} option. | |
14006 | @option{-fno-align-loops} and @option{-falign-loops=1} are | |
14007 | equivalent and mean that loops are not aligned. | |
14008 | The maximum allowed @var{n} option value is 65536. | |
14009 | ||
14010 | If @var{n} is not specified or is zero, use a machine-dependent default. | |
14011 | ||
14012 | Enabled at levels @option{-O2}, @option{-O3}. | |
14013 | ||
ddf6fe37 | 14014 | @opindex falign-jumps |
d77de738 ML |
14015 | @item -falign-jumps |
14016 | @itemx -falign-jumps=@var{n} | |
14017 | @itemx -falign-jumps=@var{n}:@var{m} | |
14018 | @itemx -falign-jumps=@var{n}:@var{m}:@var{n2} | |
14019 | @itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
14020 | Align branch targets to a power-of-two boundary, for branch targets |
14021 | where the targets can only be reached by jumping. In this case, | |
14022 | no dummy operations need be executed. | |
14023 | ||
14024 | If @option{-falign-labels} is greater than this value, then its value | |
14025 | is used instead. | |
14026 | ||
14027 | Parameters of this option are analogous to the @option{-falign-functions} option. | |
14028 | @option{-fno-align-jumps} and @option{-falign-jumps=1} are | |
14029 | equivalent and mean that loops are not aligned. | |
14030 | ||
14031 | If @var{n} is not specified or is zero, use a machine-dependent default. | |
14032 | The maximum allowed @var{n} option value is 65536. | |
14033 | ||
14034 | Enabled at levels @option{-O2}, @option{-O3}. | |
14035 | ||
d77de738 | 14036 | @opindex fno-allocation-dce |
ddf6fe37 | 14037 | @item -fno-allocation-dce |
d77de738 ML |
14038 | Do not remove unused C++ allocations in dead code elimination. |
14039 | ||
d77de738 | 14040 | @opindex fallow-store-data-races |
ddf6fe37 | 14041 | @item -fallow-store-data-races |
d77de738 ML |
14042 | Allow the compiler to perform optimizations that may introduce new data races |
14043 | on stores, without proving that the variable cannot be concurrently accessed | |
14044 | by other threads. Does not affect optimization of local data. It is safe to | |
14045 | use this option if it is known that global data will not be accessed by | |
14046 | multiple threads. | |
14047 | ||
14048 | Examples of optimizations enabled by @option{-fallow-store-data-races} include | |
14049 | hoisting or if-conversions that may cause a value that was already in memory | |
14050 | to be re-written with that same value. Such re-writing is safe in a single | |
14051 | threaded context but may be unsafe in a multi-threaded context. Note that on | |
14052 | some processors, if-conversions may be required in order to enable | |
14053 | vectorization. | |
14054 | ||
14055 | Enabled at level @option{-Ofast}. | |
14056 | ||
d77de738 | 14057 | @opindex funit-at-a-time |
ddf6fe37 | 14058 | @item -funit-at-a-time |
d77de738 ML |
14059 | This option is left for compatibility reasons. @option{-funit-at-a-time} |
14060 | has no effect, while @option{-fno-unit-at-a-time} implies | |
14061 | @option{-fno-toplevel-reorder} and @option{-fno-section-anchors}. | |
14062 | ||
14063 | Enabled by default. | |
14064 | ||
d77de738 ML |
14065 | @opindex fno-toplevel-reorder |
14066 | @opindex ftoplevel-reorder | |
ddf6fe37 | 14067 | @item -fno-toplevel-reorder |
d77de738 ML |
14068 | Do not reorder top-level functions, variables, and @code{asm} |
14069 | statements. Output them in the same order that they appear in the | |
14070 | input file. When this option is used, unreferenced static variables | |
14071 | are not removed. This option is intended to support existing code | |
14072 | that relies on a particular ordering. For new code, it is better to | |
14073 | use attributes when possible. | |
14074 | ||
14075 | @option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and | |
14076 | also at @option{-O0} if @option{-fsection-anchors} is explicitly requested. | |
14077 | Additionally @option{-fno-toplevel-reorder} implies | |
14078 | @option{-fno-section-anchors}. | |
14079 | ||
d77de738 | 14080 | @opindex funreachable-traps |
ddf6fe37 | 14081 | @item -funreachable-traps |
d77de738 ML |
14082 | With this option, the compiler turns calls to |
14083 | @code{__builtin_unreachable} into traps, instead of using them for | |
14084 | optimization. This also affects any such calls implicitly generated | |
14085 | by the compiler. | |
14086 | ||
14087 | This option has the same effect as @option{-fsanitize=unreachable | |
14088 | -fsanitize-trap=unreachable}, but does not affect the values of those | |
14089 | options. If @option{-fsanitize=unreachable} is enabled, that option | |
14090 | takes priority over this one. | |
14091 | ||
14092 | This option is enabled by default at @option{-O0} and @option{-Og}. | |
14093 | ||
d77de738 | 14094 | @opindex fweb |
ddf6fe37 | 14095 | @item -fweb |
d77de738 ML |
14096 | Constructs webs as commonly used for register allocation purposes and assign |
14097 | each web individual pseudo register. This allows the register allocation pass | |
14098 | to operate on pseudos directly, but also strengthens several other optimization | |
14099 | passes, such as CSE, loop optimizer and trivial dead code remover. It can, | |
14100 | however, make debugging impossible, since variables no longer stay in a | |
14101 | ``home register''. | |
14102 | ||
14103 | Enabled by default with @option{-funroll-loops}. | |
14104 | ||
d77de738 | 14105 | @opindex fwhole-program |
ddf6fe37 | 14106 | @item -fwhole-program |
d77de738 ML |
14107 | Assume that the current compilation unit represents the whole program being |
14108 | compiled. All public functions and variables with the exception of @code{main} | |
14109 | and those merged by attribute @code{externally_visible} become static functions | |
14110 | and in effect are optimized more aggressively by interprocedural optimizers. | |
14111 | ||
39ebd3a9 JH |
14112 | With @option{-flto} this option has a limited use. In most cases the |
14113 | precise list of symbols used or exported from the binary is known the | |
14114 | resolution info passed to the link-time optimizer by the linker plugin. It is | |
14115 | still useful if no linker plugin is used or during incremental link step when | |
14116 | final code is produced (with @option{-flto} | |
14117 | @option{-flinker-output=nolto-rel}). | |
d77de738 | 14118 | |
d77de738 | 14119 | @opindex flto |
ddf6fe37 | 14120 | @item -flto[=@var{n}] |
d77de738 ML |
14121 | This option runs the standard link-time optimizer. When invoked |
14122 | with source code, it generates GIMPLE (one of GCC's internal | |
14123 | representations) and writes it to special ELF sections in the object | |
14124 | file. When the object files are linked together, all the function | |
14125 | bodies are read from these ELF sections and instantiated as if they | |
14126 | had been part of the same translation unit. | |
14127 | ||
14128 | To use the link-time optimizer, @option{-flto} and optimization | |
14129 | options should be specified at compile time and during the final link. | |
14130 | It is recommended that you compile all the files participating in the | |
14131 | same link with the same options and also specify those options at | |
14132 | link time. | |
14133 | For example: | |
14134 | ||
14135 | @smallexample | |
14136 | gcc -c -O2 -flto foo.c | |
14137 | gcc -c -O2 -flto bar.c | |
14138 | gcc -o myprog -flto -O2 foo.o bar.o | |
14139 | @end smallexample | |
14140 | ||
14141 | The first two invocations to GCC save a bytecode representation | |
14142 | of GIMPLE into special ELF sections inside @file{foo.o} and | |
14143 | @file{bar.o}. The final invocation reads the GIMPLE bytecode from | |
14144 | @file{foo.o} and @file{bar.o}, merges the two files into a single | |
14145 | internal image, and compiles the result as usual. Since both | |
14146 | @file{foo.o} and @file{bar.o} are merged into a single image, this | |
14147 | causes all the interprocedural analyses and optimizations in GCC to | |
14148 | work across the two files as if they were a single one. This means, | |
14149 | for example, that the inliner is able to inline functions in | |
14150 | @file{bar.o} into functions in @file{foo.o} and vice-versa. | |
14151 | ||
14152 | Another (simpler) way to enable link-time optimization is: | |
14153 | ||
14154 | @smallexample | |
14155 | gcc -o myprog -flto -O2 foo.c bar.c | |
14156 | @end smallexample | |
14157 | ||
14158 | The above generates bytecode for @file{foo.c} and @file{bar.c}, | |
14159 | merges them together into a single GIMPLE representation and optimizes | |
14160 | them as usual to produce @file{myprog}. | |
14161 | ||
14162 | The important thing to keep in mind is that to enable link-time | |
14163 | optimizations you need to use the GCC driver to perform the link step. | |
14164 | GCC automatically performs link-time optimization if any of the | |
14165 | objects involved were compiled with the @option{-flto} command-line option. | |
14166 | You can always override | |
14167 | the automatic decision to do link-time optimization | |
14168 | by passing @option{-fno-lto} to the link command. | |
14169 | ||
14170 | To make whole program optimization effective, it is necessary to make | |
14171 | certain whole program assumptions. The compiler needs to know | |
14172 | what functions and variables can be accessed by libraries and runtime | |
14173 | outside of the link-time optimized unit. When supported by the linker, | |
14174 | the linker plugin (see @option{-fuse-linker-plugin}) passes information | |
14175 | to the compiler about used and externally visible symbols. When | |
14176 | the linker plugin is not available, @option{-fwhole-program} should be | |
14177 | used to allow the compiler to make these assumptions, which leads | |
14178 | to more aggressive optimization decisions. | |
14179 | ||
14180 | When a file is compiled with @option{-flto} without | |
14181 | @option{-fuse-linker-plugin}, the generated object file is larger than | |
14182 | a regular object file because it contains GIMPLE bytecodes and the usual | |
14183 | final code (see @option{-ffat-lto-objects}). This means that | |
14184 | object files with LTO information can be linked as normal object | |
14185 | files; if @option{-fno-lto} is passed to the linker, no | |
14186 | interprocedural optimizations are applied. Note that when | |
14187 | @option{-fno-fat-lto-objects} is enabled the compile stage is faster | |
14188 | but you cannot perform a regular, non-LTO link on them. | |
14189 | ||
14190 | When producing the final binary, GCC only | |
14191 | applies link-time optimizations to those files that contain bytecode. | |
14192 | Therefore, you can mix and match object files and libraries with | |
14193 | GIMPLE bytecodes and final object code. GCC automatically selects | |
14194 | which files to optimize in LTO mode and which files to link without | |
14195 | further processing. | |
14196 | ||
14197 | Generally, options specified at link time override those | |
14198 | specified at compile time, although in some cases GCC attempts to infer | |
14199 | link-time options from the settings used to compile the input files. | |
14200 | ||
14201 | If you do not specify an optimization level option @option{-O} at | |
14202 | link time, then GCC uses the highest optimization level | |
14203 | used when compiling the object files. Note that it is generally | |
14204 | ineffective to specify an optimization level option only at link time and | |
14205 | not at compile time, for two reasons. First, compiling without | |
14206 | optimization suppresses compiler passes that gather information | |
14207 | needed for effective optimization at link time. Second, some early | |
14208 | optimization passes can be performed only at compile time and | |
14209 | not at link time. | |
14210 | ||
14211 | There are some code generation flags preserved by GCC when | |
14212 | generating bytecodes, as they need to be used during the final link. | |
14213 | Currently, the following options and their settings are taken from | |
14214 | the first object file that explicitly specifies them: | |
14215 | @option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions}, | |
14216 | @option{-fgnu-tm} and all the @option{-m} target flags. | |
14217 | ||
14218 | The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and | |
14219 | @option{-fPIE} are combined based on the following scheme: | |
14220 | ||
14221 | @smallexample | |
14222 | @option{-fPIC} + @option{-fpic} = @option{-fpic} | |
14223 | @option{-fPIC} + @option{-fno-pic} = @option{-fno-pic} | |
14224 | @option{-fpic/-fPIC} + (no option) = (no option) | |
14225 | @option{-fPIC} + @option{-fPIE} = @option{-fPIE} | |
14226 | @option{-fpic} + @option{-fPIE} = @option{-fpie} | |
14227 | @option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie} | |
14228 | @end smallexample | |
14229 | ||
14230 | Certain ABI-changing flags are required to match in all compilation units, | |
14231 | and trying to override this at link time with a conflicting value | |
14232 | is ignored. This includes options such as @option{-freg-struct-return} | |
14233 | and @option{-fpcc-struct-return}. | |
14234 | ||
14235 | Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow}, | |
14236 | @option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing} | |
14237 | are passed through to the link stage and merged conservatively for | |
14238 | conflicting translation units. Specifically | |
14239 | @option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take | |
14240 | precedence; and for example @option{-ffp-contract=off} takes precedence | |
14241 | over @option{-ffp-contract=fast}. You can override them at link time. | |
14242 | ||
14243 | Diagnostic options such as @option{-Wstringop-overflow} are passed | |
14244 | through to the link stage and their setting matches that of the | |
14245 | compile-step at function granularity. Note that this matters only | |
14246 | for diagnostics emitted during optimization. Note that code | |
14247 | transforms such as inlining can lead to warnings being enabled | |
14248 | or disabled for regions if code not consistent with the setting | |
14249 | at compile time. | |
14250 | ||
14251 | When you need to pass options to the assembler via @option{-Wa} or | |
14252 | @option{-Xassembler} make sure to either compile such translation | |
14253 | units with @option{-fno-lto} or consistently use the same assembler | |
14254 | options on all translation units. You can alternatively also | |
14255 | specify assembler options at LTO link time. | |
14256 | ||
14257 | To enable debug info generation you need to supply @option{-g} at | |
14258 | compile time. If any of the input files at link time were built | |
14259 | with debug info generation enabled the link will enable debug info | |
14260 | generation as well. Any elaborate debug info settings | |
14261 | like the dwarf level @option{-gdwarf-5} need to be explicitly repeated | |
14262 | at the linker command line and mixing different settings in different | |
14263 | translation units is discouraged. | |
14264 | ||
14265 | If LTO encounters objects with C linkage declared with incompatible | |
14266 | types in separate translation units to be linked together (undefined | |
14267 | behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be | |
14268 | issued. The behavior is still undefined at run time. Similar | |
14269 | diagnostics may be raised for other languages. | |
14270 | ||
14271 | Another feature of LTO is that it is possible to apply interprocedural | |
14272 | optimizations on files written in different languages: | |
14273 | ||
14274 | @smallexample | |
14275 | gcc -c -flto foo.c | |
14276 | g++ -c -flto bar.cc | |
14277 | gfortran -c -flto baz.f90 | |
14278 | g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran | |
14279 | @end smallexample | |
14280 | ||
14281 | Notice that the final link is done with @command{g++} to get the C++ | |
14282 | runtime libraries and @option{-lgfortran} is added to get the Fortran | |
14283 | runtime libraries. In general, when mixing languages in LTO mode, you | |
14284 | should use the same link command options as when mixing languages in a | |
14285 | regular (non-LTO) compilation. | |
14286 | ||
14287 | If object files containing GIMPLE bytecode are stored in a library archive, say | |
14288 | @file{libfoo.a}, it is possible to extract and use them in an LTO link if you | |
14289 | are using a linker with plugin support. To create static libraries suitable | |
14290 | for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar} | |
14291 | and @command{ranlib}; | |
14292 | to show the symbols of object files with GIMPLE bytecode, use | |
14293 | @command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib} | |
14294 | and @command{nm} have been compiled with plugin support. At link time, use the | |
14295 | flag @option{-fuse-linker-plugin} to ensure that the library participates in | |
14296 | the LTO optimization process: | |
14297 | ||
14298 | @smallexample | |
14299 | gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo | |
14300 | @end smallexample | |
14301 | ||
14302 | With the linker plugin enabled, the linker extracts the needed | |
14303 | GIMPLE files from @file{libfoo.a} and passes them on to the running GCC | |
14304 | to make them part of the aggregated GIMPLE image to be optimized. | |
14305 | ||
14306 | If you are not using a linker with plugin support and/or do not | |
14307 | enable the linker plugin, then the objects inside @file{libfoo.a} | |
14308 | are extracted and linked as usual, but they do not participate | |
14309 | in the LTO optimization process. In order to make a static library suitable | |
14310 | for both LTO optimization and usual linkage, compile its object files with | |
14311 | @option{-flto} @option{-ffat-lto-objects}. | |
14312 | ||
14313 | Link-time optimizations do not require the presence of the whole program to | |
14314 | operate. If the program does not require any symbols to be exported, it is | |
14315 | possible to combine @option{-flto} and @option{-fwhole-program} to allow | |
14316 | the interprocedural optimizers to use more aggressive assumptions which may | |
14317 | lead to improved optimization opportunities. | |
14318 | Use of @option{-fwhole-program} is not needed when linker plugin is | |
14319 | active (see @option{-fuse-linker-plugin}). | |
14320 | ||
14321 | The current implementation of LTO makes no | |
14322 | attempt to generate bytecode that is portable between different | |
14323 | types of hosts. The bytecode files are versioned and there is a | |
14324 | strict version check, so bytecode files generated in one version of | |
14325 | GCC do not work with an older or newer version of GCC. | |
14326 | ||
14327 | Link-time optimization does not work well with generation of debugging | |
14328 | information on systems other than those using a combination of ELF and | |
14329 | DWARF. | |
14330 | ||
14331 | If you specify the optional @var{n}, the optimization and code | |
14332 | generation done at link time is executed in parallel using @var{n} | |
14333 | parallel jobs by utilizing an installed @command{make} program. The | |
14334 | environment variable @env{MAKE} may be used to override the program | |
14335 | used. | |
14336 | ||
14337 | You can also specify @option{-flto=jobserver} to use GNU make's | |
14338 | job server mode to determine the number of parallel jobs. This | |
14339 | is useful when the Makefile calling GCC is already executing in parallel. | |
14340 | You must prepend a @samp{+} to the command recipe in the parent Makefile | |
14341 | for this to work. This option likely only works if @env{MAKE} is | |
14342 | GNU make. Even without the option value, GCC tries to automatically | |
14343 | detect a running GNU make's job server. | |
14344 | ||
14345 | Use @option{-flto=auto} to use GNU make's job server, if available, | |
14346 | or otherwise fall back to autodetection of the number of CPU threads | |
14347 | present in your system. | |
14348 | ||
d77de738 | 14349 | @opindex flto-partition |
ddf6fe37 | 14350 | @item -flto-partition=@var{alg} |
d77de738 ML |
14351 | Specify the partitioning algorithm used by the link-time optimizer. |
14352 | The value is either @samp{1to1} to specify a partitioning mirroring | |
14353 | the original source files or @samp{balanced} to specify partitioning | |
14354 | into equally sized chunks (whenever possible) or @samp{max} to create | |
14355 | new partition for every symbol where possible. Specifying @samp{none} | |
14356 | as an algorithm disables partitioning and streaming completely. | |
14357 | The default value is @samp{balanced}. While @samp{1to1} can be used | |
14358 | as an workaround for various code ordering issues, the @samp{max} | |
14359 | partitioning is intended for internal testing only. | |
14360 | The value @samp{one} specifies that exactly one partition should be | |
14361 | used while the value @samp{none} bypasses partitioning and executes | |
14362 | the link-time optimization step directly from the WPA phase. | |
14363 | ||
d77de738 | 14364 | @opindex flto-compression-level |
ddf6fe37 | 14365 | @item -flto-compression-level=@var{n} |
d77de738 ML |
14366 | This option specifies the level of compression used for intermediate |
14367 | language written to LTO object files, and is only meaningful in | |
14368 | conjunction with LTO mode (@option{-flto}). GCC currently supports two | |
14369 | LTO compression algorithms. For zstd, valid values are 0 (no compression) | |
14370 | to 19 (maximum compression), while zlib supports values from 0 to 9. | |
14371 | Values outside this range are clamped to either minimum or maximum | |
14372 | of the supported values. If the option is not given, | |
14373 | a default balanced compression setting is used. | |
14374 | ||
d77de738 | 14375 | @opindex fuse-linker-plugin |
ddf6fe37 | 14376 | @item -fuse-linker-plugin |
d77de738 ML |
14377 | Enables the use of a linker plugin during link-time optimization. This |
14378 | option relies on plugin support in the linker, which is available in gold | |
14379 | or in GNU ld 2.21 or newer. | |
14380 | ||
14381 | This option enables the extraction of object files with GIMPLE bytecode out | |
14382 | of library archives. This improves the quality of optimization by exposing | |
14383 | more code to the link-time optimizer. This information specifies what | |
14384 | symbols can be accessed externally (by non-LTO object or during dynamic | |
14385 | linking). Resulting code quality improvements on binaries (and shared | |
14386 | libraries that use hidden visibility) are similar to @option{-fwhole-program}. | |
14387 | See @option{-flto} for a description of the effect of this flag and how to | |
14388 | use it. | |
14389 | ||
14390 | This option is enabled by default when LTO support in GCC is enabled | |
14391 | and GCC was configured for use with | |
14392 | a linker supporting plugins (GNU ld 2.21 or newer or gold). | |
14393 | ||
d77de738 | 14394 | @opindex ffat-lto-objects |
ddf6fe37 | 14395 | @item -ffat-lto-objects |
d77de738 ML |
14396 | Fat LTO objects are object files that contain both the intermediate language |
14397 | and the object code. This makes them usable for both LTO linking and normal | |
14398 | linking. This option is effective only when compiling with @option{-flto} | |
14399 | and is ignored at link time. | |
14400 | ||
14401 | @option{-fno-fat-lto-objects} improves compilation time over plain LTO, but | |
14402 | requires the complete toolchain to be aware of LTO. It requires a linker with | |
14403 | linker plugin support for basic functionality. Additionally, | |
14404 | @command{nm}, @command{ar} and @command{ranlib} | |
14405 | need to support linker plugins to allow a full-featured build environment | |
14406 | (capable of building static libraries etc). GCC provides the @command{gcc-ar}, | |
14407 | @command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options | |
14408 | to these tools. With non fat LTO makefiles need to be modified to use them. | |
14409 | ||
14410 | Note that modern binutils provide plugin auto-load mechanism. | |
14411 | Installing the linker plugin into @file{$libdir/bfd-plugins} has the same | |
14412 | effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and | |
14413 | @command{gcc-ranlib}). | |
14414 | ||
14415 | The default is @option{-fno-fat-lto-objects} on targets with linker plugin | |
14416 | support. | |
14417 | ||
d77de738 | 14418 | @opindex fcompare-elim |
ddf6fe37 | 14419 | @item -fcompare-elim |
d77de738 ML |
14420 | After register allocation and post-register allocation instruction splitting, |
14421 | identify arithmetic instructions that compute processor flags similar to a | |
14422 | comparison operation based on that arithmetic. If possible, eliminate the | |
14423 | explicit comparison operation. | |
14424 | ||
14425 | This pass only applies to certain targets that cannot explicitly represent | |
14426 | the comparison operation before register allocation is complete. | |
14427 | ||
14428 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
14429 | ||
04c9cf5c MT |
14430 | @opindex ffold-mem-offsets |
14431 | @item -ffold-mem-offsets | |
14432 | @itemx -fno-fold-mem-offsets | |
14433 | Try to eliminate add instructions by folding them in memory loads/stores. | |
14434 | ||
14435 | Enabled at levels @option{-O2}, @option{-O3}. | |
14436 | ||
d77de738 | 14437 | @opindex fcprop-registers |
ddf6fe37 | 14438 | @item -fcprop-registers |
d77de738 ML |
14439 | After register allocation and post-register allocation instruction splitting, |
14440 | perform a copy-propagation pass to try to reduce scheduling dependencies | |
14441 | and occasionally eliminate the copy. | |
14442 | ||
14443 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
14444 | ||
d77de738 | 14445 | @opindex fprofile-correction |
ddf6fe37 | 14446 | @item -fprofile-correction |
d77de738 ML |
14447 | Profiles collected using an instrumented binary for multi-threaded programs may |
14448 | be inconsistent due to missed counter updates. When this option is specified, | |
14449 | GCC uses heuristics to correct or smooth out such inconsistencies. By | |
14450 | default, GCC emits an error message when an inconsistent profile is detected. | |
14451 | ||
14452 | This option is enabled by @option{-fauto-profile}. | |
14453 | ||
d77de738 | 14454 | @opindex fprofile-partial-training |
ddf6fe37 | 14455 | @item -fprofile-partial-training |
d77de738 ML |
14456 | With @code{-fprofile-use} all portions of programs not executed during train |
14457 | run are optimized agressively for size rather than speed. In some cases it is | |
14458 | not practical to train all possible hot paths in the program. (For | |
14459 | example, program may contain functions specific for a given hardware and | |
14460 | trianing may not cover all hardware configurations program is run on.) With | |
14461 | @code{-fprofile-partial-training} profile feedback will be ignored for all | |
14462 | functions not executed during the train run leading them to be optimized as if | |
14463 | they were compiled without profile feedback. This leads to better performance | |
14464 | when train run is not representative but also leads to significantly bigger | |
14465 | code. | |
14466 | ||
ddf6fe37 | 14467 | @opindex fprofile-use |
d77de738 ML |
14468 | @item -fprofile-use |
14469 | @itemx -fprofile-use=@var{path} | |
d77de738 ML |
14470 | Enable profile feedback-directed optimizations, |
14471 | and the following optimizations, many of which | |
14472 | are generally profitable only with profile feedback available: | |
14473 | ||
43b72ede AA |
14474 | @gccoptlist{-fbranch-probabilities -fprofile-values |
14475 | -funroll-loops -fpeel-loops -ftracer -fvpt | |
14476 | -finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp | |
14477 | -fpredictive-commoning -fsplit-loops -funswitch-loops | |
14478 | -fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize | |
14479 | -fvect-cost-model=dynamic -ftree-loop-distribute-patterns | |
d77de738 ML |
14480 | -fprofile-reorder-functions} |
14481 | ||
14482 | Before you can use this option, you must first generate profiling information. | |
14483 | @xref{Instrumentation Options}, for information about the | |
14484 | @option{-fprofile-generate} option. | |
14485 | ||
14486 | By default, GCC emits an error message if the feedback profiles do not | |
14487 | match the source code. This error can be turned into a warning by using | |
14488 | @option{-Wno-error=coverage-mismatch}. Note this may result in poorly | |
14489 | optimized code. Additionally, by default, GCC also emits a warning message if | |
14490 | the feedback profiles do not exist (see @option{-Wmissing-profile}). | |
14491 | ||
14492 | If @var{path} is specified, GCC looks at the @var{path} to find | |
14493 | the profile feedback data files. See @option{-fprofile-dir}. | |
14494 | ||
ddf6fe37 | 14495 | @opindex fauto-profile |
d77de738 ML |
14496 | @item -fauto-profile |
14497 | @itemx -fauto-profile=@var{path} | |
d77de738 ML |
14498 | Enable sampling-based feedback-directed optimizations, |
14499 | and the following optimizations, | |
14500 | many of which are generally profitable only with profile feedback available: | |
14501 | ||
43b72ede AA |
14502 | @gccoptlist{-fbranch-probabilities -fprofile-values |
14503 | -funroll-loops -fpeel-loops -ftracer -fvpt | |
14504 | -finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp | |
14505 | -fpredictive-commoning -fsplit-loops -funswitch-loops | |
14506 | -fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize | |
14507 | -fvect-cost-model=dynamic -ftree-loop-distribute-patterns | |
d77de738 ML |
14508 | -fprofile-correction} |
14509 | ||
14510 | @var{path} is the name of a file containing AutoFDO profile information. | |
14511 | If omitted, it defaults to @file{fbdata.afdo} in the current directory. | |
14512 | ||
14513 | Producing an AutoFDO profile data file requires running your program | |
14514 | with the @command{perf} utility on a supported GNU/Linux target system. | |
14515 | For more information, see @uref{https://perf.wiki.kernel.org/}. | |
14516 | ||
14517 | E.g. | |
14518 | @smallexample | |
14519 | perf record -e br_inst_retired:near_taken -b -o perf.data \ | |
14520 | -- your_program | |
14521 | @end smallexample | |
14522 | ||
14523 | Then use the @command{create_gcov} tool to convert the raw profile data | |
14524 | to a format that can be used by GCC.@ You must also supply the | |
14525 | unstripped binary for your program to this tool. | |
14526 | See @uref{https://github.com/google/autofdo}. | |
14527 | ||
14528 | E.g. | |
14529 | @smallexample | |
14530 | create_gcov --binary=your_program.unstripped --profile=perf.data \ | |
14531 | --gcov=profile.afdo | |
14532 | @end smallexample | |
14533 | @end table | |
14534 | ||
14535 | The following options control compiler behavior regarding floating-point | |
14536 | arithmetic. These options trade off between speed and | |
14537 | correctness. All must be specifically enabled. | |
14538 | ||
14539 | @table @gcctabopt | |
d77de738 | 14540 | @opindex ffloat-store |
ddf6fe37 | 14541 | @item -ffloat-store |
d77de738 ML |
14542 | Do not store floating-point variables in registers, and inhibit other |
14543 | options that might change whether a floating-point value is taken from a | |
14544 | register or memory. | |
14545 | ||
14546 | @cindex floating-point precision | |
14547 | This option prevents undesirable excess precision on machines such as | |
14548 | the 68000 where the floating registers (of the 68881) keep more | |
14549 | precision than a @code{double} is supposed to have. Similarly for the | |
14550 | x86 architecture. For most programs, the excess precision does only | |
14551 | good, but a few programs rely on the precise definition of IEEE floating | |
14552 | point. Use @option{-ffloat-store} for such programs, after modifying | |
14553 | them to store all pertinent intermediate computations into variables. | |
14554 | ||
d77de738 | 14555 | @opindex fexcess-precision |
ddf6fe37 | 14556 | @item -fexcess-precision=@var{style} |
d77de738 ML |
14557 | This option allows further control over excess precision on machines |
14558 | where floating-point operations occur in a format with more precision or | |
14559 | range than the IEEE standard and interchange floating-point types. By | |
14560 | default, @option{-fexcess-precision=fast} is in effect; this means that | |
14561 | operations may be carried out in a wider precision than the types specified | |
14562 | in the source if that would result in faster code, and it is unpredictable | |
14563 | when rounding to the types specified in the source code takes place. | |
14564 | When compiling C or C++, if @option{-fexcess-precision=standard} is specified | |
14565 | then excess precision follows the rules specified in ISO C99 or C++; in particular, | |
14566 | both casts and assignments cause values to be rounded to their | |
14567 | semantic types (whereas @option{-ffloat-store} only affects | |
14568 | assignments). This option is enabled by default for C or C++ if a strict | |
14569 | conformance option such as @option{-std=c99} or @option{-std=c++17} is used. | |
14570 | @option{-ffast-math} enables @option{-fexcess-precision=fast} by default | |
14571 | regardless of whether a strict conformance option is used. | |
14572 | ||
14573 | @opindex mfpmath | |
14574 | @option{-fexcess-precision=standard} is not implemented for languages | |
14575 | other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse} | |
14576 | or @option{-mfpmath=sse+387} is specified; in the former case, IEEE | |
14577 | semantics apply without excess precision, and in the latter, rounding | |
14578 | is unpredictable. | |
14579 | ||
d77de738 | 14580 | @opindex ffast-math |
ddf6fe37 | 14581 | @item -ffast-math |
d77de738 ML |
14582 | Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations}, |
14583 | @option{-ffinite-math-only}, @option{-fno-rounding-math}, | |
14584 | @option{-fno-signaling-nans}, @option{-fcx-limited-range} and | |
14585 | @option{-fexcess-precision=fast}. | |
14586 | ||
14587 | This option causes the preprocessor macro @code{__FAST_MATH__} to be defined. | |
14588 | ||
14589 | This option is not turned on by any @option{-O} option besides | |
14590 | @option{-Ofast} since it can result in incorrect output for programs | |
14591 | that depend on an exact implementation of IEEE or ISO rules/specifications | |
14592 | for math functions. It may, however, yield faster code for programs | |
14593 | that do not require the guarantees of these specifications. | |
14594 | ||
d77de738 ML |
14595 | @opindex fno-math-errno |
14596 | @opindex fmath-errno | |
ddf6fe37 | 14597 | @item -fno-math-errno |
d77de738 ML |
14598 | Do not set @code{errno} after calling math functions that are executed |
14599 | with a single instruction, e.g., @code{sqrt}. A program that relies on | |
14600 | IEEE exceptions for math error handling may want to use this flag | |
14601 | for speed while maintaining IEEE arithmetic compatibility. | |
14602 | ||
14603 | This option is not turned on by any @option{-O} option since | |
14604 | it can result in incorrect output for programs that depend on | |
14605 | an exact implementation of IEEE or ISO rules/specifications for | |
14606 | math functions. It may, however, yield faster code for programs | |
14607 | that do not require the guarantees of these specifications. | |
14608 | ||
14609 | The default is @option{-fmath-errno}. | |
14610 | ||
14611 | On Darwin systems, the math library never sets @code{errno}. There is | |
14612 | therefore no reason for the compiler to consider the possibility that | |
14613 | it might, and @option{-fno-math-errno} is the default. | |
14614 | ||
d77de738 | 14615 | @opindex funsafe-math-optimizations |
ddf6fe37 | 14616 | @item -funsafe-math-optimizations |
d77de738 ML |
14617 | |
14618 | Allow optimizations for floating-point arithmetic that (a) assume | |
14619 | that arguments and results are valid and (b) may violate IEEE or | |
14620 | ANSI standards. When used at link time, it may include libraries | |
14621 | or startup files that change the default FPU control word or other | |
14622 | similar optimizations. | |
14623 | ||
14624 | This option is not turned on by any @option{-O} option since | |
14625 | it can result in incorrect output for programs that depend on | |
14626 | an exact implementation of IEEE or ISO rules/specifications for | |
14627 | math functions. It may, however, yield faster code for programs | |
14628 | that do not require the guarantees of these specifications. | |
14629 | Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math}, | |
14630 | @option{-fassociative-math} and @option{-freciprocal-math}. | |
14631 | ||
14632 | The default is @option{-fno-unsafe-math-optimizations}. | |
14633 | ||
d77de738 | 14634 | @opindex fassociative-math |
ddf6fe37 | 14635 | @item -fassociative-math |
d77de738 ML |
14636 | |
14637 | Allow re-association of operands in series of floating-point operations. | |
14638 | This violates the ISO C and C++ language standard by possibly changing | |
14639 | computation result. NOTE: re-ordering may change the sign of zero as | |
14640 | well as ignore NaNs and inhibit or create underflow or overflow (and | |
14641 | thus cannot be used on code that relies on rounding behavior like | |
14642 | @code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons | |
14643 | and thus may not be used when ordered comparisons are required. | |
14644 | This option requires that both @option{-fno-signed-zeros} and | |
14645 | @option{-fno-trapping-math} be in effect. Moreover, it doesn't make | |
14646 | much sense with @option{-frounding-math}. For Fortran the option | |
14647 | is automatically enabled when both @option{-fno-signed-zeros} and | |
14648 | @option{-fno-trapping-math} are in effect. | |
14649 | ||
14650 | The default is @option{-fno-associative-math}. | |
14651 | ||
d77de738 | 14652 | @opindex freciprocal-math |
ddf6fe37 | 14653 | @item -freciprocal-math |
d77de738 ML |
14654 | |
14655 | Allow the reciprocal of a value to be used instead of dividing by | |
14656 | the value if this enables optimizations. For example @code{x / y} | |
14657 | can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)} | |
14658 | is subject to common subexpression elimination. Note that this loses | |
14659 | precision and increases the number of flops operating on the value. | |
14660 | ||
14661 | The default is @option{-fno-reciprocal-math}. | |
14662 | ||
d77de738 | 14663 | @opindex ffinite-math-only |
ddf6fe37 | 14664 | @item -ffinite-math-only |
d77de738 ML |
14665 | Allow optimizations for floating-point arithmetic that assume |
14666 | that arguments and results are not NaNs or +-Infs. | |
14667 | ||
14668 | This option is not turned on by any @option{-O} option since | |
14669 | it can result in incorrect output for programs that depend on | |
14670 | an exact implementation of IEEE or ISO rules/specifications for | |
14671 | math functions. It may, however, yield faster code for programs | |
14672 | that do not require the guarantees of these specifications. | |
14673 | ||
14674 | The default is @option{-fno-finite-math-only}. | |
14675 | ||
d77de738 ML |
14676 | @opindex fno-signed-zeros |
14677 | @opindex fsigned-zeros | |
ddf6fe37 | 14678 | @item -fno-signed-zeros |
d77de738 ML |
14679 | Allow optimizations for floating-point arithmetic that ignore the |
14680 | signedness of zero. IEEE arithmetic specifies the behavior of | |
14681 | distinct +0.0 and @minus{}0.0 values, which then prohibits simplification | |
14682 | of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}). | |
14683 | This option implies that the sign of a zero result isn't significant. | |
14684 | ||
14685 | The default is @option{-fsigned-zeros}. | |
14686 | ||
d77de738 ML |
14687 | @opindex fno-trapping-math |
14688 | @opindex ftrapping-math | |
ddf6fe37 | 14689 | @item -fno-trapping-math |
d77de738 ML |
14690 | Compile code assuming that floating-point operations cannot generate |
14691 | user-visible traps. These traps include division by zero, overflow, | |
14692 | underflow, inexact result and invalid operation. This option requires | |
14693 | that @option{-fno-signaling-nans} be in effect. Setting this option may | |
14694 | allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example. | |
14695 | ||
14696 | This option should never be turned on by any @option{-O} option since | |
14697 | it can result in incorrect output for programs that depend on | |
14698 | an exact implementation of IEEE or ISO rules/specifications for | |
14699 | math functions. | |
14700 | ||
14701 | The default is @option{-ftrapping-math}. | |
14702 | ||
14703 | Future versions of GCC may provide finer control of this setting | |
14704 | using C99's @code{FENV_ACCESS} pragma. This command-line option | |
14705 | will be used along with @option{-frounding-math} to specify the | |
14706 | default state for @code{FENV_ACCESS}. | |
14707 | ||
d77de738 | 14708 | @opindex frounding-math |
ddf6fe37 | 14709 | @item -frounding-math |
d77de738 ML |
14710 | Disable transformations and optimizations that assume default floating-point |
14711 | rounding behavior. This is round-to-zero for all floating point | |
14712 | to integer conversions, and round-to-nearest for all other arithmetic | |
14713 | truncations. This option should be specified for programs that change | |
14714 | the FP rounding mode dynamically, or that may be executed with a | |
14715 | non-default rounding mode. This option disables constant folding of | |
14716 | floating-point expressions at compile time (which may be affected by | |
14717 | rounding mode) and arithmetic transformations that are unsafe in the | |
14718 | presence of sign-dependent rounding modes. | |
14719 | ||
14720 | The default is @option{-fno-rounding-math}. | |
14721 | ||
14722 | This option is experimental and does not currently guarantee to | |
14723 | disable all GCC optimizations that are affected by rounding mode. | |
14724 | Future versions of GCC may provide finer control of this setting | |
14725 | using C99's @code{FENV_ACCESS} pragma. This command-line option | |
14726 | will be used along with @option{-ftrapping-math} to specify the | |
14727 | default state for @code{FENV_ACCESS}. | |
14728 | ||
d77de738 | 14729 | @opindex fsignaling-nans |
ddf6fe37 | 14730 | @item -fsignaling-nans |
d77de738 ML |
14731 | Compile code assuming that IEEE signaling NaNs may generate user-visible |
14732 | traps during floating-point operations. Setting this option disables | |
14733 | optimizations that may change the number of exceptions visible with | |
14734 | signaling NaNs. This option implies @option{-ftrapping-math}. | |
14735 | ||
14736 | This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to | |
14737 | be defined. | |
14738 | ||
14739 | The default is @option{-fno-signaling-nans}. | |
14740 | ||
14741 | This option is experimental and does not currently guarantee to | |
14742 | disable all GCC optimizations that affect signaling NaN behavior. | |
14743 | ||
d77de738 ML |
14744 | @opindex fno-fp-int-builtin-inexact |
14745 | @opindex ffp-int-builtin-inexact | |
ddf6fe37 | 14746 | @item -fno-fp-int-builtin-inexact |
d77de738 ML |
14747 | Do not allow the built-in functions @code{ceil}, @code{floor}, |
14748 | @code{round} and @code{trunc}, and their @code{float} and @code{long | |
14749 | double} variants, to generate code that raises the ``inexact'' | |
14750 | floating-point exception for noninteger arguments. ISO C99 and C11 | |
14751 | allow these functions to raise the ``inexact'' exception, but ISO/IEC | |
14752 | TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into | |
094a609c | 14753 | ISO C23, does not allow these functions to do so. |
d77de738 ML |
14754 | |
14755 | The default is @option{-ffp-int-builtin-inexact}, allowing the | |
094a609c | 14756 | exception to be raised, unless C23 or a later C standard is selected. |
d77de738 ML |
14757 | This option does nothing unless @option{-ftrapping-math} is in effect. |
14758 | ||
14759 | Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions | |
14760 | generate a call to a library function then the ``inexact'' exception | |
14761 | may be raised if the library implementation does not follow TS 18661. | |
14762 | ||
d77de738 | 14763 | @opindex fsingle-precision-constant |
ddf6fe37 | 14764 | @item -fsingle-precision-constant |
d77de738 ML |
14765 | Treat floating-point constants as single precision instead of |
14766 | implicitly converting them to double-precision constants. | |
14767 | ||
d77de738 | 14768 | @opindex fcx-limited-range |
ddf6fe37 | 14769 | @item -fcx-limited-range |
d77de738 ML |
14770 | When enabled, this option states that a range reduction step is not |
14771 | needed when performing complex division. Also, there is no checking | |
14772 | whether the result of a complex multiplication or division is @code{NaN | |
14773 | + I*NaN}, with an attempt to rescue the situation in that case. The | |
14774 | default is @option{-fno-cx-limited-range}, but is enabled by | |
14775 | @option{-ffast-math}. | |
14776 | ||
14777 | This option controls the default setting of the ISO C99 | |
14778 | @code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to | |
14779 | all languages. | |
14780 | ||
d77de738 | 14781 | @opindex fcx-fortran-rules |
ddf6fe37 | 14782 | @item -fcx-fortran-rules |
d77de738 ML |
14783 | Complex multiplication and division follow Fortran rules. Range |
14784 | reduction is done as part of complex division, but there is no checking | |
14785 | whether the result of a complex multiplication or division is @code{NaN | |
14786 | + I*NaN}, with an attempt to rescue the situation in that case. | |
14787 | ||
14788 | The default is @option{-fno-cx-fortran-rules}. | |
14789 | ||
14790 | @end table | |
14791 | ||
14792 | The following options control optimizations that may improve | |
14793 | performance, but are not enabled by any @option{-O} options. This | |
14794 | section includes experimental options that may produce broken code. | |
14795 | ||
14796 | @table @gcctabopt | |
d77de738 | 14797 | @opindex fbranch-probabilities |
ddf6fe37 | 14798 | @item -fbranch-probabilities |
d77de738 ML |
14799 | After running a program compiled with @option{-fprofile-arcs} |
14800 | (@pxref{Instrumentation Options}), | |
14801 | you can compile it a second time using | |
14802 | @option{-fbranch-probabilities}, to improve optimizations based on | |
14803 | the number of times each branch was taken. When a program | |
14804 | compiled with @option{-fprofile-arcs} exits, it saves arc execution | |
14805 | counts to a file called @file{@var{sourcename}.gcda} for each source | |
14806 | file. The information in this data file is very dependent on the | |
14807 | structure of the generated code, so you must use the same source code | |
14808 | and the same optimization options for both compilations. | |
14809 | See details about the file naming in @option{-fprofile-arcs}. | |
14810 | ||
14811 | With @option{-fbranch-probabilities}, GCC puts a | |
14812 | @samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}. | |
14813 | These can be used to improve optimization. Currently, they are only | |
14814 | used in one place: in @file{reorg.cc}, instead of guessing which path a | |
14815 | branch is most likely to take, the @samp{REG_BR_PROB} values are used to | |
14816 | exactly determine which path is taken more often. | |
14817 | ||
14818 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14819 | ||
d77de738 | 14820 | @opindex fprofile-values |
ddf6fe37 | 14821 | @item -fprofile-values |
d77de738 ML |
14822 | If combined with @option{-fprofile-arcs}, it adds code so that some |
14823 | data about values of expressions in the program is gathered. | |
14824 | ||
14825 | With @option{-fbranch-probabilities}, it reads back the data gathered | |
14826 | from profiling values of expressions for usage in optimizations. | |
14827 | ||
14828 | Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and | |
14829 | @option{-fauto-profile}. | |
14830 | ||
d77de738 | 14831 | @opindex fprofile-reorder-functions |
ddf6fe37 | 14832 | @item -fprofile-reorder-functions |
d77de738 ML |
14833 | Function reordering based on profile instrumentation collects |
14834 | first time of execution of a function and orders these functions | |
14835 | in ascending order. | |
14836 | ||
14837 | Enabled with @option{-fprofile-use}. | |
14838 | ||
d77de738 | 14839 | @opindex fvpt |
ddf6fe37 | 14840 | @item -fvpt |
d77de738 ML |
14841 | If combined with @option{-fprofile-arcs}, this option instructs the compiler |
14842 | to add code to gather information about values of expressions. | |
14843 | ||
14844 | With @option{-fbranch-probabilities}, it reads back the data gathered | |
14845 | and actually performs the optimizations based on them. | |
14846 | Currently the optimizations include specialization of division operations | |
14847 | using the knowledge about the value of the denominator. | |
14848 | ||
14849 | Enabled with @option{-fprofile-use} and @option{-fauto-profile}. | |
14850 | ||
d77de738 | 14851 | @opindex frename-registers |
ddf6fe37 | 14852 | @item -frename-registers |
d77de738 ML |
14853 | Attempt to avoid false dependencies in scheduled code by making use |
14854 | of registers left over after register allocation. This optimization | |
14855 | most benefits processors with lots of registers. Depending on the | |
14856 | debug information format adopted by the target, however, it can | |
14857 | make debugging impossible, since variables no longer stay in | |
14858 | a ``home register''. | |
14859 | ||
14860 | Enabled by default with @option{-funroll-loops}. | |
14861 | ||
d77de738 | 14862 | @opindex fschedule-fusion |
ddf6fe37 | 14863 | @item -fschedule-fusion |
d77de738 ML |
14864 | Performs a target dependent pass over the instruction stream to schedule |
14865 | instructions of same type together because target machine can execute them | |
14866 | more efficiently if they are adjacent to each other in the instruction flow. | |
14867 | ||
14868 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
14869 | ||
d77de738 | 14870 | @opindex ftracer |
ddf6fe37 | 14871 | @item -ftracer |
d77de738 ML |
14872 | Perform tail duplication to enlarge superblock size. This transformation |
14873 | simplifies the control flow of the function allowing other optimizations to do | |
14874 | a better job. | |
14875 | ||
14876 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14877 | ||
d77de738 | 14878 | @opindex funroll-loops |
ddf6fe37 | 14879 | @item -funroll-loops |
d77de738 ML |
14880 | Unroll loops whose number of iterations can be determined at compile time or |
14881 | upon entry to the loop. @option{-funroll-loops} implies | |
14882 | @option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}. | |
14883 | It also turns on complete loop peeling (i.e.@: complete removal of loops with | |
14884 | a small constant number of iterations). This option makes code larger, and may | |
14885 | or may not make it run faster. | |
14886 | ||
14887 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14888 | ||
d77de738 | 14889 | @opindex funroll-all-loops |
ddf6fe37 | 14890 | @item -funroll-all-loops |
d77de738 ML |
14891 | Unroll all loops, even if their number of iterations is uncertain when |
14892 | the loop is entered. This usually makes programs run more slowly. | |
14893 | @option{-funroll-all-loops} implies the same options as | |
14894 | @option{-funroll-loops}. | |
14895 | ||
d77de738 | 14896 | @opindex fpeel-loops |
ddf6fe37 | 14897 | @item -fpeel-loops |
d77de738 ML |
14898 | Peels loops for which there is enough information that they do not |
14899 | roll much (from profile feedback or static analysis). It also turns on | |
14900 | complete loop peeling (i.e.@: complete removal of loops with small constant | |
14901 | number of iterations). | |
14902 | ||
14903 | Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}. | |
14904 | ||
d77de738 | 14905 | @opindex fmove-loop-invariants |
ddf6fe37 | 14906 | @item -fmove-loop-invariants |
d77de738 ML |
14907 | Enables the loop invariant motion pass in the RTL loop optimizer. Enabled |
14908 | at level @option{-O1} and higher, except for @option{-Og}. | |
14909 | ||
d77de738 | 14910 | @opindex fmove-loop-stores |
ddf6fe37 | 14911 | @item -fmove-loop-stores |
d77de738 ML |
14912 | Enables the loop store motion pass in the GIMPLE loop optimizer. This |
14913 | moves invariant stores to after the end of the loop in exchange for | |
14914 | carrying the stored value in a register across the iteration. | |
14915 | Note for this option to have an effect @option{-ftree-loop-im} has to | |
14916 | be enabled as well. Enabled at level @option{-O1} and higher, except | |
14917 | for @option{-Og}. | |
14918 | ||
d77de738 | 14919 | @opindex fsplit-loops |
ddf6fe37 | 14920 | @item -fsplit-loops |
d77de738 ML |
14921 | Split a loop into two if it contains a condition that's always true |
14922 | for one side of the iteration space and false for the other. | |
14923 | ||
14924 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14925 | ||
d77de738 | 14926 | @opindex funswitch-loops |
ddf6fe37 | 14927 | @item -funswitch-loops |
d77de738 ML |
14928 | Move branches with loop invariant conditions out of the loop, with duplicates |
14929 | of the loop on both branches (modified according to result of the condition). | |
14930 | ||
14931 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14932 | ||
d77de738 | 14933 | @opindex fversion-loops-for-strides |
ddf6fe37 | 14934 | @item -fversion-loops-for-strides |
d77de738 ML |
14935 | If a loop iterates over an array with a variable stride, create another |
14936 | version of the loop that assumes the stride is always one. For example: | |
14937 | ||
14938 | @smallexample | |
14939 | for (int i = 0; i < n; ++i) | |
14940 | x[i * stride] = @dots{}; | |
14941 | @end smallexample | |
14942 | ||
14943 | becomes: | |
14944 | ||
14945 | @smallexample | |
14946 | if (stride == 1) | |
14947 | for (int i = 0; i < n; ++i) | |
14948 | x[i] = @dots{}; | |
14949 | else | |
14950 | for (int i = 0; i < n; ++i) | |
14951 | x[i * stride] = @dots{}; | |
14952 | @end smallexample | |
14953 | ||
14954 | This is particularly useful for assumed-shape arrays in Fortran where | |
14955 | (for example) it allows better vectorization assuming contiguous accesses. | |
14956 | This flag is enabled by default at @option{-O3}. | |
14957 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14958 | ||
d77de738 ML |
14959 | @opindex ffunction-sections |
14960 | @opindex fdata-sections | |
ddf6fe37 AA |
14961 | @item -ffunction-sections |
14962 | @itemx -fdata-sections | |
d77de738 ML |
14963 | Place each function or data item into its own section in the output |
14964 | file if the target supports arbitrary sections. The name of the | |
14965 | function or the name of the data item determines the section's name | |
14966 | in the output file. | |
14967 | ||
14968 | Use these options on systems where the linker can perform optimizations to | |
14969 | improve locality of reference in the instruction space. Most systems using the | |
14970 | ELF object format have linkers with such optimizations. On AIX, the linker | |
14971 | rearranges sections (CSECTs) based on the call graph. The performance impact | |
14972 | varies. | |
14973 | ||
14974 | Together with a linker garbage collection (linker @option{--gc-sections} | |
14975 | option) these options may lead to smaller statically-linked executables (after | |
14976 | stripping). | |
14977 | ||
14978 | On ELF/DWARF systems these options do not degenerate the quality of the debug | |
14979 | information. There could be issues with other object files/debug info formats. | |
14980 | ||
14981 | Only use these options when there are significant benefits from doing so. When | |
14982 | you specify these options, the assembler and linker create larger object and | |
14983 | executable files and are also slower. These options affect code generation. | |
14984 | They prevent optimizations by the compiler and assembler using relative | |
14985 | locations inside a translation unit since the locations are unknown until | |
14986 | link time. An example of such an optimization is relaxing calls to short call | |
14987 | instructions. | |
14988 | ||
d77de738 | 14989 | @opindex fstdarg-opt |
ddf6fe37 | 14990 | @item -fstdarg-opt |
d77de738 ML |
14991 | Optimize the prologue of variadic argument functions with respect to usage of |
14992 | those arguments. | |
14993 | ||
d77de738 | 14994 | @opindex fsection-anchors |
ddf6fe37 | 14995 | @item -fsection-anchors |
d77de738 ML |
14996 | Try to reduce the number of symbolic address calculations by using |
14997 | shared ``anchor'' symbols to address nearby objects. This transformation | |
14998 | can help to reduce the number of GOT entries and GOT accesses on some | |
14999 | targets. | |
15000 | ||
15001 | For example, the implementation of the following function @code{foo}: | |
15002 | ||
15003 | @smallexample | |
15004 | static int a, b, c; | |
15005 | int foo (void) @{ return a + b + c; @} | |
15006 | @end smallexample | |
15007 | ||
15008 | @noindent | |
15009 | usually calculates the addresses of all three variables, but if you | |
15010 | compile it with @option{-fsection-anchors}, it accesses the variables | |
15011 | from a common anchor point instead. The effect is similar to the | |
15012 | following pseudocode (which isn't valid C): | |
15013 | ||
15014 | @smallexample | |
15015 | int foo (void) | |
15016 | @{ | |
15017 | register int *xr = &x; | |
15018 | return xr[&a - &x] + xr[&b - &x] + xr[&c - &x]; | |
15019 | @} | |
15020 | @end smallexample | |
15021 | ||
15022 | Not all targets support this option. | |
15023 | ||
d77de738 | 15024 | @opindex fzero-call-used-regs |
ddf6fe37 | 15025 | @item -fzero-call-used-regs=@var{choice} |
d77de738 ML |
15026 | Zero call-used registers at function return to increase program |
15027 | security by either mitigating Return-Oriented Programming (ROP) | |
15028 | attacks or preventing information leakage through registers. | |
15029 | ||
15030 | The possible values of @var{choice} are the same as for the | |
15031 | @code{zero_call_used_regs} attribute (@pxref{Function Attributes}). | |
15032 | The default is @samp{skip}. | |
15033 | ||
15034 | You can control this behavior for a specific function by using the function | |
15035 | attribute @code{zero_call_used_regs} (@pxref{Function Attributes}). | |
15036 | ||
d77de738 | 15037 | @opindex param |
ddf6fe37 | 15038 | @item --param @var{name}=@var{value} |
d77de738 ML |
15039 | In some places, GCC uses various constants to control the amount of |
15040 | optimization that is done. For example, GCC does not inline functions | |
15041 | that contain more than a certain number of instructions. You can | |
15042 | control some of these constants on the command line using the | |
15043 | @option{--param} option. | |
15044 | ||
15045 | The names of specific parameters, and the meaning of the values, are | |
15046 | tied to the internals of the compiler, and are subject to change | |
15047 | without notice in future releases. | |
15048 | ||
c381327d GP |
15049 | In order to get the minimal, maximal and default values of a parameter, |
15050 | use the @option{--help=param -Q} options. | |
d77de738 ML |
15051 | |
15052 | In each case, the @var{value} is an integer. The following choices | |
15053 | of @var{name} are recognized for all targets: | |
15054 | ||
15055 | @table @gcctabopt | |
15056 | @item predictable-branch-outcome | |
15057 | When branch is predicted to be taken with probability lower than this threshold | |
15058 | (in percent), then it is considered well predictable. | |
15059 | ||
15060 | @item max-rtl-if-conversion-insns | |
15061 | RTL if-conversion tries to remove conditional branches around a block and | |
15062 | replace them with conditionally executed instructions. This parameter | |
15063 | gives the maximum number of instructions in a block which should be | |
15064 | considered for if-conversion. The compiler will | |
15065 | also use other heuristics to decide whether if-conversion is likely to be | |
15066 | profitable. | |
15067 | ||
15068 | @item max-rtl-if-conversion-predictable-cost | |
15069 | RTL if-conversion will try to remove conditional branches around a block | |
15070 | and replace them with conditionally executed instructions. These parameters | |
15071 | give the maximum permissible cost for the sequence that would be generated | |
15072 | by if-conversion depending on whether the branch is statically determined | |
15073 | to be predictable or not. The units for this parameter are the same as | |
15074 | those for the GCC internal seq_cost metric. The compiler will try to | |
15075 | provide a reasonable default for this parameter using the BRANCH_COST | |
15076 | target macro. | |
15077 | ||
15078 | @item max-crossjump-edges | |
15079 | The maximum number of incoming edges to consider for cross-jumping. | |
15080 | The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in | |
15081 | the number of edges incoming to each block. Increasing values mean | |
15082 | more aggressive optimization, making the compilation time increase with | |
15083 | probably small improvement in executable size. | |
15084 | ||
15085 | @item min-crossjump-insns | |
15086 | The minimum number of instructions that must be matched at the end | |
15087 | of two blocks before cross-jumping is performed on them. This | |
15088 | value is ignored in the case where all instructions in the block being | |
15089 | cross-jumped from are matched. | |
15090 | ||
15091 | @item max-grow-copy-bb-insns | |
15092 | The maximum code size expansion factor when copying basic blocks | |
15093 | instead of jumping. The expansion is relative to a jump instruction. | |
15094 | ||
15095 | @item max-goto-duplication-insns | |
15096 | The maximum number of instructions to duplicate to a block that jumps | |
15097 | to a computed goto. To avoid @math{O(N^2)} behavior in a number of | |
15098 | passes, GCC factors computed gotos early in the compilation process, | |
15099 | and unfactors them as late as possible. Only computed jumps at the | |
15100 | end of a basic blocks with no more than max-goto-duplication-insns are | |
15101 | unfactored. | |
15102 | ||
15103 | @item max-delay-slot-insn-search | |
15104 | The maximum number of instructions to consider when looking for an | |
15105 | instruction to fill a delay slot. If more than this arbitrary number of | |
15106 | instructions are searched, the time savings from filling the delay slot | |
15107 | are minimal, so stop searching. Increasing values mean more | |
15108 | aggressive optimization, making the compilation time increase with probably | |
15109 | small improvement in execution time. | |
15110 | ||
15111 | @item max-delay-slot-live-search | |
15112 | When trying to fill delay slots, the maximum number of instructions to | |
15113 | consider when searching for a block with valid live register | |
15114 | information. Increasing this arbitrarily chosen value means more | |
15115 | aggressive optimization, increasing the compilation time. This parameter | |
15116 | should be removed when the delay slot code is rewritten to maintain the | |
15117 | control-flow graph. | |
15118 | ||
15119 | @item max-gcse-memory | |
15120 | The approximate maximum amount of memory in @code{kB} that can be allocated in | |
15121 | order to perform the global common subexpression elimination | |
15122 | optimization. If more memory than specified is required, the | |
15123 | optimization is not done. | |
15124 | ||
15125 | @item max-gcse-insertion-ratio | |
15126 | If the ratio of expression insertions to deletions is larger than this value | |
15127 | for any expression, then RTL PRE inserts or removes the expression and thus | |
15128 | leaves partially redundant computations in the instruction stream. | |
15129 | ||
15130 | @item max-pending-list-length | |
15131 | The maximum number of pending dependencies scheduling allows | |
15132 | before flushing the current state and starting over. Large functions | |
15133 | with few branches or calls can create excessively large lists which | |
15134 | needlessly consume memory and resources. | |
15135 | ||
15136 | @item max-modulo-backtrack-attempts | |
15137 | The maximum number of backtrack attempts the scheduler should make | |
15138 | when modulo scheduling a loop. Larger values can exponentially increase | |
15139 | compilation time. | |
15140 | ||
15141 | @item max-inline-functions-called-once-loop-depth | |
15142 | Maximal loop depth of a call considered by inline heuristics that tries to | |
15143 | inline all functions called once. | |
15144 | ||
15145 | @item max-inline-functions-called-once-insns | |
15146 | Maximal estimated size of functions produced while inlining functions called | |
15147 | once. | |
15148 | ||
15149 | @item max-inline-insns-single | |
15150 | Several parameters control the tree inliner used in GCC@. This number sets the | |
15151 | maximum number of instructions (counted in GCC's internal representation) in a | |
15152 | single function that the tree inliner considers for inlining. This only | |
15153 | affects functions declared inline and methods implemented in a class | |
15154 | declaration (C++). | |
15155 | ||
15156 | ||
15157 | @item max-inline-insns-auto | |
15158 | When you use @option{-finline-functions} (included in @option{-O3}), | |
15159 | a lot of functions that would otherwise not be considered for inlining | |
15160 | by the compiler are investigated. To those functions, a different | |
15161 | (more restrictive) limit compared to functions declared inline can | |
15162 | be applied (@option{--param max-inline-insns-auto}). | |
15163 | ||
15164 | @item max-inline-insns-small | |
15165 | This is bound applied to calls which are considered relevant with | |
15166 | @option{-finline-small-functions}. | |
15167 | ||
15168 | @item max-inline-insns-size | |
15169 | This is bound applied to calls which are optimized for size. Small growth | |
15170 | may be desirable to anticipate optimization oppurtunities exposed by inlining. | |
15171 | ||
15172 | @item uninlined-function-insns | |
15173 | Number of instructions accounted by inliner for function overhead such as | |
15174 | function prologue and epilogue. | |
15175 | ||
15176 | @item uninlined-function-time | |
15177 | Extra time accounted by inliner for function overhead such as time needed to | |
15178 | execute function prologue and epilogue. | |
15179 | ||
15180 | @item inline-heuristics-hint-percent | |
15181 | The scale (in percents) applied to @option{inline-insns-single}, | |
15182 | @option{inline-insns-single-O2}, @option{inline-insns-auto} | |
15183 | when inline heuristics hints that inlining is | |
15184 | very profitable (will enable later optimizations). | |
15185 | ||
15186 | @item uninlined-thunk-insns | |
15187 | @item uninlined-thunk-time | |
15188 | Same as @option{--param uninlined-function-insns} and | |
15189 | @option{--param uninlined-function-time} but applied to function thunks. | |
15190 | ||
15191 | @item inline-min-speedup | |
15192 | When estimated performance improvement of caller + callee runtime exceeds this | |
15193 | threshold (in percent), the function can be inlined regardless of the limit on | |
15194 | @option{--param max-inline-insns-single} and @option{--param | |
15195 | max-inline-insns-auto}. | |
15196 | ||
15197 | @item large-function-insns | |
15198 | The limit specifying really large functions. For functions larger than this | |
15199 | limit after inlining, inlining is constrained by | |
15200 | @option{--param large-function-growth}. This parameter is useful primarily | |
15201 | to avoid extreme compilation time caused by non-linear algorithms used by the | |
15202 | back end. | |
15203 | ||
15204 | @item large-function-growth | |
15205 | Specifies maximal growth of large function caused by inlining in percents. | |
15206 | For example, parameter value 100 limits large function growth to 2.0 times | |
15207 | the original size. | |
15208 | ||
15209 | @item large-unit-insns | |
15210 | The limit specifying large translation unit. Growth caused by inlining of | |
15211 | units larger than this limit is limited by @option{--param inline-unit-growth}. | |
15212 | For small units this might be too tight. | |
15213 | For example, consider a unit consisting of function A | |
15214 | that is inline and B that just calls A three times. If B is small relative to | |
15215 | A, the growth of unit is 300\% and yet such inlining is very sane. For very | |
15216 | large units consisting of small inlineable functions, however, the overall unit | |
15217 | growth limit is needed to avoid exponential explosion of code size. Thus for | |
15218 | smaller units, the size is increased to @option{--param large-unit-insns} | |
15219 | before applying @option{--param inline-unit-growth}. | |
15220 | ||
15221 | @item lazy-modules | |
15222 | Maximum number of concurrently open C++ module files when lazy loading. | |
15223 | ||
15224 | @item inline-unit-growth | |
15225 | Specifies maximal overall growth of the compilation unit caused by inlining. | |
15226 | For example, parameter value 20 limits unit growth to 1.2 times the original | |
15227 | size. Cold functions (either marked cold via an attribute or by profile | |
15228 | feedback) are not accounted into the unit size. | |
15229 | ||
15230 | @item ipa-cp-unit-growth | |
15231 | Specifies maximal overall growth of the compilation unit caused by | |
15232 | interprocedural constant propagation. For example, parameter value 10 limits | |
15233 | unit growth to 1.1 times the original size. | |
15234 | ||
15235 | @item ipa-cp-large-unit-insns | |
15236 | The size of translation unit that IPA-CP pass considers large. | |
15237 | ||
15238 | @item large-stack-frame | |
15239 | The limit specifying large stack frames. While inlining the algorithm is trying | |
15240 | to not grow past this limit too much. | |
15241 | ||
15242 | @item large-stack-frame-growth | |
15243 | Specifies maximal growth of large stack frames caused by inlining in percents. | |
15244 | For example, parameter value 1000 limits large stack frame growth to 11 times | |
15245 | the original size. | |
15246 | ||
15247 | @item max-inline-insns-recursive | |
15248 | @itemx max-inline-insns-recursive-auto | |
15249 | Specifies the maximum number of instructions an out-of-line copy of a | |
15250 | self-recursive inline | |
15251 | function can grow into by performing recursive inlining. | |
15252 | ||
15253 | @option{--param max-inline-insns-recursive} applies to functions | |
15254 | declared inline. | |
15255 | For functions not declared inline, recursive inlining | |
15256 | happens only when @option{-finline-functions} (included in @option{-O3}) is | |
15257 | enabled; @option{--param max-inline-insns-recursive-auto} applies instead. | |
15258 | ||
15259 | @item max-inline-recursive-depth | |
15260 | @itemx max-inline-recursive-depth-auto | |
15261 | Specifies the maximum recursion depth used for recursive inlining. | |
15262 | ||
15263 | @option{--param max-inline-recursive-depth} applies to functions | |
15264 | declared inline. For functions not declared inline, recursive inlining | |
15265 | happens only when @option{-finline-functions} (included in @option{-O3}) is | |
15266 | enabled; @option{--param max-inline-recursive-depth-auto} applies instead. | |
15267 | ||
15268 | @item min-inline-recursive-probability | |
15269 | Recursive inlining is profitable only for function having deep recursion | |
15270 | in average and can hurt for function having little recursion depth by | |
15271 | increasing the prologue size or complexity of function body to other | |
15272 | optimizers. | |
15273 | ||
15274 | When profile feedback is available (see @option{-fprofile-generate}) the actual | |
15275 | recursion depth can be guessed from the probability that function recurses | |
15276 | via a given call expression. This parameter limits inlining only to call | |
15277 | expressions whose probability exceeds the given threshold (in percents). | |
15278 | ||
15279 | @item early-inlining-insns | |
15280 | Specify growth that the early inliner can make. In effect it increases | |
15281 | the amount of inlining for code having a large abstraction penalty. | |
15282 | ||
15283 | @item max-early-inliner-iterations | |
15284 | Limit of iterations of the early inliner. This basically bounds | |
15285 | the number of nested indirect calls the early inliner can resolve. | |
15286 | Deeper chains are still handled by late inlining. | |
15287 | ||
15288 | @item comdat-sharing-probability | |
15289 | Probability (in percent) that C++ inline function with comdat visibility | |
15290 | are shared across multiple compilation units. | |
15291 | ||
15292 | @item modref-max-bases | |
15293 | @item modref-max-refs | |
15294 | @item modref-max-accesses | |
15295 | Specifies the maximal number of base pointers, references and accesses stored | |
15296 | for a single function by mod/ref analysis. | |
15297 | ||
15298 | @item modref-max-tests | |
15299 | Specifies the maxmal number of tests alias oracle can perform to disambiguate | |
15300 | memory locations using the mod/ref information. This parameter ought to be | |
15301 | bigger than @option{--param modref-max-bases} and @option{--param | |
15302 | modref-max-refs}. | |
15303 | ||
15304 | @item modref-max-depth | |
15305 | Specifies the maximum depth of DFS walk used by modref escape analysis. | |
15306 | Setting to 0 disables the analysis completely. | |
15307 | ||
15308 | @item modref-max-escape-points | |
15309 | Specifies the maximum number of escape points tracked by modref per SSA-name. | |
15310 | ||
15311 | @item modref-max-adjustments | |
15312 | Specifies the maximum number the access range is enlarged during modref dataflow | |
15313 | analysis. | |
15314 | ||
15315 | @item profile-func-internal-id | |
15316 | A parameter to control whether to use function internal id in profile | |
15317 | database lookup. If the value is 0, the compiler uses an id that | |
15318 | is based on function assembler name and filename, which makes old profile | |
15319 | data more tolerant to source changes such as function reordering etc. | |
15320 | ||
15321 | @item min-vect-loop-bound | |
15322 | The minimum number of iterations under which loops are not vectorized | |
15323 | when @option{-ftree-vectorize} is used. The number of iterations after | |
15324 | vectorization needs to be greater than the value specified by this option | |
15325 | to allow vectorization. | |
15326 | ||
15327 | @item gcse-cost-distance-ratio | |
15328 | Scaling factor in calculation of maximum distance an expression | |
15329 | can be moved by GCSE optimizations. This is currently supported only in the | |
15330 | code hoisting pass. The bigger the ratio, the more aggressive code hoisting | |
15331 | is with simple expressions, i.e., the expressions that have cost | |
15332 | less than @option{gcse-unrestricted-cost}. Specifying 0 disables | |
15333 | hoisting of simple expressions. | |
15334 | ||
15335 | @item gcse-unrestricted-cost | |
15336 | Cost, roughly measured as the cost of a single typical machine | |
15337 | instruction, at which GCSE optimizations do not constrain | |
15338 | the distance an expression can travel. This is currently | |
15339 | supported only in the code hoisting pass. The lesser the cost, | |
15340 | the more aggressive code hoisting is. Specifying 0 | |
15341 | allows all expressions to travel unrestricted distances. | |
15342 | ||
15343 | @item max-hoist-depth | |
15344 | The depth of search in the dominator tree for expressions to hoist. | |
15345 | This is used to avoid quadratic behavior in hoisting algorithm. | |
15346 | The value of 0 does not limit on the search, but may slow down compilation | |
15347 | of huge functions. | |
15348 | ||
15349 | @item max-tail-merge-comparisons | |
15350 | The maximum amount of similar bbs to compare a bb with. This is used to | |
15351 | avoid quadratic behavior in tree tail merging. | |
15352 | ||
15353 | @item max-tail-merge-iterations | |
15354 | The maximum amount of iterations of the pass over the function. This is used to | |
15355 | limit compilation time in tree tail merging. | |
15356 | ||
15357 | @item store-merging-allow-unaligned | |
15358 | Allow the store merging pass to introduce unaligned stores if it is legal to | |
15359 | do so. | |
15360 | ||
15361 | @item max-stores-to-merge | |
15362 | The maximum number of stores to attempt to merge into wider stores in the store | |
15363 | merging pass. | |
15364 | ||
15365 | @item max-store-chains-to-track | |
15366 | The maximum number of store chains to track at the same time in the attempt | |
15367 | to merge them into wider stores in the store merging pass. | |
15368 | ||
15369 | @item max-stores-to-track | |
15370 | The maximum number of stores to track at the same time in the attemt to | |
15371 | to merge them into wider stores in the store merging pass. | |
15372 | ||
15373 | @item max-unrolled-insns | |
15374 | The maximum number of instructions that a loop may have to be unrolled. | |
15375 | If a loop is unrolled, this parameter also determines how many times | |
15376 | the loop code is unrolled. | |
15377 | ||
15378 | @item max-average-unrolled-insns | |
15379 | The maximum number of instructions biased by probabilities of their execution | |
15380 | that a loop may have to be unrolled. If a loop is unrolled, | |
15381 | this parameter also determines how many times the loop code is unrolled. | |
15382 | ||
15383 | @item max-unroll-times | |
15384 | The maximum number of unrollings of a single loop. | |
15385 | ||
15386 | @item max-peeled-insns | |
15387 | The maximum number of instructions that a loop may have to be peeled. | |
15388 | If a loop is peeled, this parameter also determines how many times | |
15389 | the loop code is peeled. | |
15390 | ||
15391 | @item max-peel-times | |
15392 | The maximum number of peelings of a single loop. | |
15393 | ||
15394 | @item max-peel-branches | |
15395 | The maximum number of branches on the hot path through the peeled sequence. | |
15396 | ||
15397 | @item max-completely-peeled-insns | |
15398 | The maximum number of insns of a completely peeled loop. | |
15399 | ||
15400 | @item max-completely-peel-times | |
15401 | The maximum number of iterations of a loop to be suitable for complete peeling. | |
15402 | ||
15403 | @item max-completely-peel-loop-nest-depth | |
15404 | The maximum depth of a loop nest suitable for complete peeling. | |
15405 | ||
15406 | @item max-unswitch-insns | |
15407 | The maximum number of insns of an unswitched loop. | |
15408 | ||
5b50850c RB |
15409 | @item max-unswitch-depth |
15410 | The maximum depth of a loop nest to be unswitched. | |
15411 | ||
d77de738 ML |
15412 | @item lim-expensive |
15413 | The minimum cost of an expensive expression in the loop invariant motion. | |
15414 | ||
15415 | @item min-loop-cond-split-prob | |
15416 | When FDO profile information is available, @option{min-loop-cond-split-prob} | |
15417 | specifies minimum threshold for probability of semi-invariant condition | |
15418 | statement to trigger loop split. | |
15419 | ||
15420 | @item iv-consider-all-candidates-bound | |
15421 | Bound on number of candidates for induction variables, below which | |
15422 | all candidates are considered for each use in induction variable | |
15423 | optimizations. If there are more candidates than this, | |
15424 | only the most relevant ones are considered to avoid quadratic time complexity. | |
15425 | ||
15426 | @item iv-max-considered-uses | |
15427 | The induction variable optimizations give up on loops that contain more | |
15428 | induction variable uses. | |
15429 | ||
15430 | @item iv-always-prune-cand-set-bound | |
15431 | If the number of candidates in the set is smaller than this value, | |
15432 | always try to remove unnecessary ivs from the set | |
15433 | when adding a new one. | |
15434 | ||
15435 | @item avg-loop-niter | |
15436 | Average number of iterations of a loop. | |
15437 | ||
15438 | @item dse-max-object-size | |
15439 | Maximum size (in bytes) of objects tracked bytewise by dead store elimination. | |
15440 | Larger values may result in larger compilation times. | |
15441 | ||
15442 | @item dse-max-alias-queries-per-store | |
15443 | Maximum number of queries into the alias oracle per store. | |
15444 | Larger values result in larger compilation times and may result in more | |
15445 | removed dead stores. | |
15446 | ||
15447 | @item scev-max-expr-size | |
15448 | Bound on size of expressions used in the scalar evolutions analyzer. | |
15449 | Large expressions slow the analyzer. | |
15450 | ||
15451 | @item scev-max-expr-complexity | |
15452 | Bound on the complexity of the expressions in the scalar evolutions analyzer. | |
15453 | Complex expressions slow the analyzer. | |
15454 | ||
15455 | @item max-tree-if-conversion-phi-args | |
15456 | Maximum number of arguments in a PHI supported by TREE if conversion | |
15457 | unless the loop is marked with simd pragma. | |
15458 | ||
15459 | @item vect-max-layout-candidates | |
15460 | The maximum number of possible vector layouts (such as permutations) | |
15461 | to consider when optimizing to-be-vectorized code. | |
15462 | ||
15463 | @item vect-max-version-for-alignment-checks | |
15464 | The maximum number of run-time checks that can be performed when | |
15465 | doing loop versioning for alignment in the vectorizer. | |
15466 | ||
15467 | @item vect-max-version-for-alias-checks | |
15468 | The maximum number of run-time checks that can be performed when | |
15469 | doing loop versioning for alias in the vectorizer. | |
15470 | ||
15471 | @item vect-max-peeling-for-alignment | |
15472 | The maximum number of loop peels to enhance access alignment | |
15473 | for vectorizer. Value -1 means no limit. | |
15474 | ||
15475 | @item max-iterations-to-track | |
15476 | The maximum number of iterations of a loop the brute-force algorithm | |
15477 | for analysis of the number of iterations of the loop tries to evaluate. | |
15478 | ||
15479 | @item hot-bb-count-fraction | |
15480 | The denominator n of fraction 1/n of the maximal execution count of a | |
15481 | basic block in the entire program that a basic block needs to at least | |
15482 | have in order to be considered hot. The default is 10000, which means | |
15483 | that a basic block is considered hot if its execution count is greater | |
15484 | than 1/10000 of the maximal execution count. 0 means that it is never | |
15485 | considered hot. Used in non-LTO mode. | |
15486 | ||
15487 | @item hot-bb-count-ws-permille | |
15488 | The number of most executed permilles, ranging from 0 to 1000, of the | |
15489 | profiled execution of the entire program to which the execution count | |
15490 | of a basic block must be part of in order to be considered hot. The | |
15491 | default is 990, which means that a basic block is considered hot if | |
15492 | its execution count contributes to the upper 990 permilles, or 99.0%, | |
15493 | of the profiled execution of the entire program. 0 means that it is | |
15494 | never considered hot. Used in LTO mode. | |
15495 | ||
15496 | @item hot-bb-frequency-fraction | |
15497 | The denominator n of fraction 1/n of the execution frequency of the | |
15498 | entry block of a function that a basic block of this function needs | |
15499 | to at least have in order to be considered hot. The default is 1000, | |
15500 | which means that a basic block is considered hot in a function if it | |
15501 | is executed more frequently than 1/1000 of the frequency of the entry | |
15502 | block of the function. 0 means that it is never considered hot. | |
15503 | ||
15504 | @item unlikely-bb-count-fraction | |
15505 | The denominator n of fraction 1/n of the number of profiled runs of | |
15506 | the entire program below which the execution count of a basic block | |
15507 | must be in order for the basic block to be considered unlikely executed. | |
15508 | The default is 20, which means that a basic block is considered unlikely | |
15509 | executed if it is executed in fewer than 1/20, or 5%, of the runs of | |
15510 | the program. 0 means that it is always considered unlikely executed. | |
15511 | ||
15512 | @item max-predicted-iterations | |
15513 | The maximum number of loop iterations we predict statically. This is useful | |
15514 | in cases where a function contains a single loop with known bound and | |
15515 | another loop with unknown bound. | |
15516 | The known number of iterations is predicted correctly, while | |
15517 | the unknown number of iterations average to roughly 10. This means that the | |
15518 | loop without bounds appears artificially cold relative to the other one. | |
15519 | ||
15520 | @item builtin-expect-probability | |
15521 | Control the probability of the expression having the specified value. This | |
15522 | parameter takes a percentage (i.e.@: 0 ... 100) as input. | |
15523 | ||
15524 | @item builtin-string-cmp-inline-length | |
15525 | The maximum length of a constant string for a builtin string cmp call | |
15526 | eligible for inlining. | |
15527 | ||
15528 | @item align-threshold | |
15529 | ||
15530 | Select fraction of the maximal frequency of executions of a basic block in | |
15531 | a function to align the basic block. | |
15532 | ||
15533 | @item align-loop-iterations | |
15534 | ||
15535 | A loop expected to iterate at least the selected number of iterations is | |
15536 | aligned. | |
15537 | ||
15538 | @item tracer-dynamic-coverage | |
15539 | @itemx tracer-dynamic-coverage-feedback | |
15540 | ||
15541 | This value is used to limit superblock formation once the given percentage of | |
15542 | executed instructions is covered. This limits unnecessary code size | |
15543 | expansion. | |
15544 | ||
15545 | The @option{tracer-dynamic-coverage-feedback} parameter | |
15546 | is used only when profile | |
15547 | feedback is available. The real profiles (as opposed to statically estimated | |
15548 | ones) are much less balanced allowing the threshold to be larger value. | |
15549 | ||
15550 | @item tracer-max-code-growth | |
15551 | Stop tail duplication once code growth has reached given percentage. This is | |
15552 | a rather artificial limit, as most of the duplicates are eliminated later in | |
15553 | cross jumping, so it may be set to much higher values than is the desired code | |
15554 | growth. | |
15555 | ||
15556 | @item tracer-min-branch-ratio | |
15557 | ||
15558 | Stop reverse growth when the reverse probability of best edge is less than this | |
15559 | threshold (in percent). | |
15560 | ||
15561 | @item tracer-min-branch-probability | |
15562 | @itemx tracer-min-branch-probability-feedback | |
15563 | ||
15564 | Stop forward growth if the best edge has probability lower than this | |
15565 | threshold. | |
15566 | ||
15567 | Similarly to @option{tracer-dynamic-coverage} two parameters are | |
15568 | provided. @option{tracer-min-branch-probability-feedback} is used for | |
15569 | compilation with profile feedback and @option{tracer-min-branch-probability} | |
15570 | compilation without. The value for compilation with profile feedback | |
15571 | needs to be more conservative (higher) in order to make tracer | |
15572 | effective. | |
15573 | ||
15574 | @item stack-clash-protection-guard-size | |
15575 | Specify the size of the operating system provided stack guard as | |
15576 | 2 raised to @var{num} bytes. Higher values may reduce the | |
15577 | number of explicit probes, but a value larger than the operating system | |
15578 | provided guard will leave code vulnerable to stack clash style attacks. | |
15579 | ||
15580 | @item stack-clash-protection-probe-interval | |
15581 | Stack clash protection involves probing stack space as it is allocated. This | |
15582 | param controls the maximum distance between probes into the stack as 2 raised | |
15583 | to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value | |
15584 | larger than the operating system provided guard will leave code vulnerable to | |
15585 | stack clash style attacks. | |
15586 | ||
15587 | @item max-cse-path-length | |
15588 | ||
15589 | The maximum number of basic blocks on path that CSE considers. | |
15590 | ||
15591 | @item max-cse-insns | |
15592 | The maximum number of instructions CSE processes before flushing. | |
15593 | ||
15594 | @item ggc-min-expand | |
15595 | ||
15596 | GCC uses a garbage collector to manage its own memory allocation. This | |
15597 | parameter specifies the minimum percentage by which the garbage | |
15598 | collector's heap should be allowed to expand between collections. | |
15599 | Tuning this may improve compilation speed; it has no effect on code | |
15600 | generation. | |
15601 | ||
15602 | The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when | |
15603 | RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is | |
15604 | the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If | |
15605 | GCC is not able to calculate RAM on a particular platform, the lower | |
15606 | bound of 30% is used. Setting this parameter and | |
15607 | @option{ggc-min-heapsize} to zero causes a full collection to occur at | |
15608 | every opportunity. This is extremely slow, but can be useful for | |
15609 | debugging. | |
15610 | ||
15611 | @item ggc-min-heapsize | |
15612 | ||
15613 | Minimum size of the garbage collector's heap before it begins bothering | |
15614 | to collect garbage. The first collection occurs after the heap expands | |
15615 | by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again, | |
15616 | tuning this may improve compilation speed, and has no effect on code | |
15617 | generation. | |
15618 | ||
15619 | The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that | |
15620 | tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but | |
15621 | with a lower bound of 4096 (four megabytes) and an upper bound of | |
15622 | 131072 (128 megabytes). If GCC is not able to calculate RAM on a | |
15623 | particular platform, the lower bound is used. Setting this parameter | |
15624 | very large effectively disables garbage collection. Setting this | |
15625 | parameter and @option{ggc-min-expand} to zero causes a full collection | |
15626 | to occur at every opportunity. | |
15627 | ||
15628 | @item max-reload-search-insns | |
15629 | The maximum number of instruction reload should look backward for equivalent | |
15630 | register. Increasing values mean more aggressive optimization, making the | |
15631 | compilation time increase with probably slightly better performance. | |
15632 | ||
15633 | @item max-cselib-memory-locations | |
15634 | The maximum number of memory locations cselib should take into account. | |
15635 | Increasing values mean more aggressive optimization, making the compilation time | |
15636 | increase with probably slightly better performance. | |
15637 | ||
15638 | @item max-sched-ready-insns | |
15639 | The maximum number of instructions ready to be issued the scheduler should | |
15640 | consider at any given time during the first scheduling pass. Increasing | |
15641 | values mean more thorough searches, making the compilation time increase | |
15642 | with probably little benefit. | |
15643 | ||
15644 | @item max-sched-region-blocks | |
15645 | The maximum number of blocks in a region to be considered for | |
15646 | interblock scheduling. | |
15647 | ||
15648 | @item max-pipeline-region-blocks | |
15649 | The maximum number of blocks in a region to be considered for | |
15650 | pipelining in the selective scheduler. | |
15651 | ||
15652 | @item max-sched-region-insns | |
15653 | The maximum number of insns in a region to be considered for | |
15654 | interblock scheduling. | |
15655 | ||
15656 | @item max-pipeline-region-insns | |
15657 | The maximum number of insns in a region to be considered for | |
15658 | pipelining in the selective scheduler. | |
15659 | ||
15660 | @item min-spec-prob | |
15661 | The minimum probability (in percents) of reaching a source block | |
15662 | for interblock speculative scheduling. | |
15663 | ||
15664 | @item max-sched-extend-regions-iters | |
15665 | The maximum number of iterations through CFG to extend regions. | |
15666 | A value of 0 disables region extensions. | |
15667 | ||
15668 | @item max-sched-insn-conflict-delay | |
15669 | The maximum conflict delay for an insn to be considered for speculative motion. | |
15670 | ||
15671 | @item sched-spec-prob-cutoff | |
15672 | The minimal probability of speculation success (in percents), so that | |
15673 | speculative insns are scheduled. | |
15674 | ||
15675 | @item sched-state-edge-prob-cutoff | |
15676 | The minimum probability an edge must have for the scheduler to save its | |
15677 | state across it. | |
15678 | ||
15679 | @item sched-mem-true-dep-cost | |
15680 | Minimal distance (in CPU cycles) between store and load targeting same | |
15681 | memory locations. | |
15682 | ||
15683 | @item selsched-max-lookahead | |
15684 | The maximum size of the lookahead window of selective scheduling. It is a | |
15685 | depth of search for available instructions. | |
15686 | ||
15687 | @item selsched-max-sched-times | |
15688 | The maximum number of times that an instruction is scheduled during | |
15689 | selective scheduling. This is the limit on the number of iterations | |
15690 | through which the instruction may be pipelined. | |
15691 | ||
15692 | @item selsched-insns-to-rename | |
15693 | The maximum number of best instructions in the ready list that are considered | |
15694 | for renaming in the selective scheduler. | |
15695 | ||
15696 | @item sms-min-sc | |
15697 | The minimum value of stage count that swing modulo scheduler | |
15698 | generates. | |
15699 | ||
15700 | @item max-last-value-rtl | |
15701 | The maximum size measured as number of RTLs that can be recorded in an expression | |
15702 | in combiner for a pseudo register as last known value of that register. | |
15703 | ||
15704 | @item max-combine-insns | |
15705 | The maximum number of instructions the RTL combiner tries to combine. | |
15706 | ||
15707 | @item integer-share-limit | |
15708 | Small integer constants can use a shared data structure, reducing the | |
15709 | compiler's memory usage and increasing its speed. This sets the maximum | |
15710 | value of a shared integer constant. | |
15711 | ||
15712 | @item ssp-buffer-size | |
15713 | The minimum size of buffers (i.e.@: arrays) that receive stack smashing | |
15714 | protection when @option{-fstack-protector} is used. | |
15715 | ||
15716 | @item min-size-for-stack-sharing | |
15717 | The minimum size of variables taking part in stack slot sharing when not | |
15718 | optimizing. | |
15719 | ||
15720 | @item max-jump-thread-duplication-stmts | |
15721 | Maximum number of statements allowed in a block that needs to be | |
15722 | duplicated when threading jumps. | |
15723 | ||
15724 | @item max-jump-thread-paths | |
15725 | The maximum number of paths to consider when searching for jump threading | |
15726 | opportunities. When arriving at a block, incoming edges are only considered | |
15727 | if the number of paths to be searched so far multiplied by the number of | |
15728 | incoming edges does not exhaust the specified maximum number of paths to | |
15729 | consider. | |
15730 | ||
15731 | @item max-fields-for-field-sensitive | |
15732 | Maximum number of fields in a structure treated in | |
15733 | a field sensitive manner during pointer analysis. | |
15734 | ||
15735 | @item prefetch-latency | |
15736 | Estimate on average number of instructions that are executed before | |
15737 | prefetch finishes. The distance prefetched ahead is proportional | |
15738 | to this constant. Increasing this number may also lead to less | |
15739 | streams being prefetched (see @option{simultaneous-prefetches}). | |
15740 | ||
15741 | @item simultaneous-prefetches | |
15742 | Maximum number of prefetches that can run at the same time. | |
15743 | ||
15744 | @item l1-cache-line-size | |
15745 | The size of cache line in L1 data cache, in bytes. | |
15746 | ||
15747 | @item l1-cache-size | |
15748 | The size of L1 data cache, in kilobytes. | |
15749 | ||
15750 | @item l2-cache-size | |
15751 | The size of L2 data cache, in kilobytes. | |
15752 | ||
15753 | @item prefetch-dynamic-strides | |
15754 | Whether the loop array prefetch pass should issue software prefetch hints | |
15755 | for strides that are non-constant. In some cases this may be | |
15756 | beneficial, though the fact the stride is non-constant may make it | |
15757 | hard to predict when there is clear benefit to issuing these hints. | |
15758 | ||
15759 | Set to 1 if the prefetch hints should be issued for non-constant | |
15760 | strides. Set to 0 if prefetch hints should be issued only for strides that | |
15761 | are known to be constant and below @option{prefetch-minimum-stride}. | |
15762 | ||
15763 | @item prefetch-minimum-stride | |
15764 | Minimum constant stride, in bytes, to start using prefetch hints for. If | |
15765 | the stride is less than this threshold, prefetch hints will not be issued. | |
15766 | ||
15767 | This setting is useful for processors that have hardware prefetchers, in | |
15768 | which case there may be conflicts between the hardware prefetchers and | |
15769 | the software prefetchers. If the hardware prefetchers have a maximum | |
15770 | stride they can handle, it should be used here to improve the use of | |
15771 | software prefetchers. | |
15772 | ||
15773 | A value of -1 means we don't have a threshold and therefore | |
15774 | prefetch hints can be issued for any constant stride. | |
15775 | ||
15776 | This setting is only useful for strides that are known and constant. | |
15777 | ||
15778 | @item destructive-interference-size | |
15779 | @item constructive-interference-size | |
15780 | The values for the C++17 variables | |
15781 | @code{std::hardware_destructive_interference_size} and | |
15782 | @code{std::hardware_constructive_interference_size}. The destructive | |
15783 | interference size is the minimum recommended offset between two | |
15784 | independent concurrently-accessed objects; the constructive | |
15785 | interference size is the maximum recommended size of contiguous memory | |
15786 | accessed together. Typically both will be the size of an L1 cache | |
15787 | line for the target, in bytes. For a generic target covering a range of L1 | |
15788 | cache line sizes, typically the constructive interference size will be | |
15789 | the small end of the range and the destructive size will be the large | |
15790 | end. | |
15791 | ||
15792 | The destructive interference size is intended to be used for layout, | |
15793 | and thus has ABI impact. The default value is not expected to be | |
15794 | stable, and on some targets varies with @option{-mtune}, so use of | |
15795 | this variable in a context where ABI stability is important, such as | |
15796 | the public interface of a library, is strongly discouraged; if it is | |
15797 | used in that context, users can stabilize the value using this | |
15798 | option. | |
15799 | ||
15800 | The constructive interference size is less sensitive, as it is | |
15801 | typically only used in a @samp{static_assert} to make sure that a type | |
15802 | fits within a cache line. | |
15803 | ||
15804 | See also @option{-Winterference-size}. | |
15805 | ||
15806 | @item loop-interchange-max-num-stmts | |
15807 | The maximum number of stmts in a loop to be interchanged. | |
15808 | ||
15809 | @item loop-interchange-stride-ratio | |
15810 | The minimum ratio between stride of two loops for interchange to be profitable. | |
15811 | ||
15812 | @item min-insn-to-prefetch-ratio | |
15813 | The minimum ratio between the number of instructions and the | |
15814 | number of prefetches to enable prefetching in a loop. | |
15815 | ||
15816 | @item prefetch-min-insn-to-mem-ratio | |
15817 | The minimum ratio between the number of instructions and the | |
15818 | number of memory references to enable prefetching in a loop. | |
15819 | ||
15820 | @item use-canonical-types | |
15821 | Whether the compiler should use the ``canonical'' type system. | |
15822 | Should always be 1, which uses a more efficient internal | |
15823 | mechanism for comparing types in C++ and Objective-C++. However, if | |
15824 | bugs in the canonical type system are causing compilation failures, | |
15825 | set this value to 0 to disable canonical types. | |
15826 | ||
15827 | @item switch-conversion-max-branch-ratio | |
15828 | Switch initialization conversion refuses to create arrays that are | |
15829 | bigger than @option{switch-conversion-max-branch-ratio} times the number of | |
15830 | branches in the switch. | |
15831 | ||
15832 | @item max-partial-antic-length | |
15833 | Maximum length of the partial antic set computed during the tree | |
15834 | partial redundancy elimination optimization (@option{-ftree-pre}) when | |
15835 | optimizing at @option{-O3} and above. For some sorts of source code | |
15836 | the enhanced partial redundancy elimination optimization can run away, | |
15837 | consuming all of the memory available on the host machine. This | |
15838 | parameter sets a limit on the length of the sets that are computed, | |
15839 | which prevents the runaway behavior. Setting a value of 0 for | |
15840 | this parameter allows an unlimited set length. | |
15841 | ||
15842 | @item rpo-vn-max-loop-depth | |
15843 | Maximum loop depth that is value-numbered optimistically. | |
15844 | When the limit hits the innermost | |
15845 | @var{rpo-vn-max-loop-depth} loops and the outermost loop in the | |
15846 | loop nest are value-numbered optimistically and the remaining ones not. | |
15847 | ||
15848 | @item sccvn-max-alias-queries-per-access | |
15849 | Maximum number of alias-oracle queries we perform when looking for | |
15850 | redundancies for loads and stores. If this limit is hit the search | |
15851 | is aborted and the load or store is not considered redundant. The | |
15852 | number of queries is algorithmically limited to the number of | |
15853 | stores on all paths from the load to the function entry. | |
15854 | ||
15855 | @item ira-max-loops-num | |
15856 | IRA uses regional register allocation by default. If a function | |
15857 | contains more loops than the number given by this parameter, only at most | |
15858 | the given number of the most frequently-executed loops form regions | |
15859 | for regional register allocation. | |
15860 | ||
15861 | @item ira-max-conflict-table-size | |
15862 | Although IRA uses a sophisticated algorithm to compress the conflict | |
15863 | table, the table can still require excessive amounts of memory for | |
15864 | huge functions. If the conflict table for a function could be more | |
15865 | than the size in MB given by this parameter, the register allocator | |
15866 | instead uses a faster, simpler, and lower-quality | |
15867 | algorithm that does not require building a pseudo-register conflict table. | |
15868 | ||
15869 | @item ira-loop-reserved-regs | |
15870 | IRA can be used to evaluate more accurate register pressure in loops | |
15871 | for decisions to move loop invariants (see @option{-O3}). The number | |
15872 | of available registers reserved for some other purposes is given | |
15873 | by this parameter. Default of the parameter | |
15874 | is the best found from numerous experiments. | |
15875 | ||
15876 | @item ira-consider-dup-in-all-alts | |
15877 | Make IRA to consider matching constraint (duplicated operand number) | |
15878 | heavily in all available alternatives for preferred register class. | |
15879 | If it is set as zero, it means IRA only respects the matching | |
15880 | constraint when it's in the only available alternative with an | |
15881 | appropriate register class. Otherwise, it means IRA will check all | |
15882 | available alternatives for preferred register class even if it has | |
15883 | found some choice with an appropriate register class and respect the | |
15884 | found qualified matching constraint. | |
15885 | ||
9847c753 ML |
15886 | @item ira-simple-lra-insn-threshold |
15887 | Approximate function insn number in 1K units triggering simple local RA. | |
15888 | ||
d77de738 ML |
15889 | @item lra-inheritance-ebb-probability-cutoff |
15890 | LRA tries to reuse values reloaded in registers in subsequent insns. | |
15891 | This optimization is called inheritance. EBB is used as a region to | |
15892 | do this optimization. The parameter defines a minimal fall-through | |
15893 | edge probability in percentage used to add BB to inheritance EBB in | |
15894 | LRA. The default value was chosen | |
15895 | from numerous runs of SPEC2000 on x86-64. | |
15896 | ||
15897 | @item loop-invariant-max-bbs-in-loop | |
15898 | Loop invariant motion can be very expensive, both in compilation time and | |
15899 | in amount of needed compile-time memory, with very large loops. Loops | |
15900 | with more basic blocks than this parameter won't have loop invariant | |
15901 | motion optimization performed on them. | |
15902 | ||
15903 | @item loop-max-datarefs-for-datadeps | |
15904 | Building data dependencies is expensive for very large loops. This | |
15905 | parameter limits the number of data references in loops that are | |
15906 | considered for data dependence analysis. These large loops are no | |
15907 | handled by the optimizations using loop data dependencies. | |
15908 | ||
15909 | @item max-vartrack-size | |
15910 | Sets a maximum number of hash table slots to use during variable | |
15911 | tracking dataflow analysis of any function. If this limit is exceeded | |
15912 | with variable tracking at assignments enabled, analysis for that | |
15913 | function is retried without it, after removing all debug insns from | |
15914 | the function. If the limit is exceeded even without debug insns, var | |
15915 | tracking analysis is completely disabled for the function. Setting | |
15916 | the parameter to zero makes it unlimited. | |
15917 | ||
15918 | @item max-vartrack-expr-depth | |
15919 | Sets a maximum number of recursion levels when attempting to map | |
15920 | variable names or debug temporaries to value expressions. This trades | |
15921 | compilation time for more complete debug information. If this is set too | |
15922 | low, value expressions that are available and could be represented in | |
15923 | debug information may end up not being used; setting this higher may | |
15924 | enable the compiler to find more complex debug expressions, but compile | |
15925 | time and memory use may grow. | |
15926 | ||
15927 | @item max-debug-marker-count | |
15928 | Sets a threshold on the number of debug markers (e.g.@: begin stmt | |
15929 | markers) to avoid complexity explosion at inlining or expanding to RTL. | |
15930 | If a function has more such gimple stmts than the set limit, such stmts | |
15931 | will be dropped from the inlined copy of a function, and from its RTL | |
15932 | expansion. | |
15933 | ||
15934 | @item min-nondebug-insn-uid | |
15935 | Use uids starting at this parameter for nondebug insns. The range below | |
15936 | the parameter is reserved exclusively for debug insns created by | |
15937 | @option{-fvar-tracking-assignments}, but debug insns may get | |
15938 | (non-overlapping) uids above it if the reserved range is exhausted. | |
15939 | ||
10478270 MJ |
15940 | @item ipa-sra-deref-prob-threshold |
15941 | IPA-SRA replaces a pointer which is known not be NULL with one or more | |
15942 | new parameters only when the probability (in percent, relative to | |
15943 | function entry) of it being dereferenced is higher than this parameter. | |
15944 | ||
d77de738 ML |
15945 | @item ipa-sra-ptr-growth-factor |
15946 | IPA-SRA replaces a pointer to an aggregate with one or more new | |
15947 | parameters only when their cumulative size is less or equal to | |
15948 | @option{ipa-sra-ptr-growth-factor} times the size of the original | |
15949 | pointer parameter. | |
15950 | ||
69363825 ML |
15951 | @item ipa-sra-ptrwrap-growth-factor |
15952 | Additional maximum allowed growth of total size of new parameters | |
15953 | that ipa-sra replaces a pointer to an aggregate with, | |
049dccd0 MJ |
15954 | if it points to a local variable that the caller only writes to and |
15955 | passes it as an argument to other functions. | |
69363825 | 15956 | |
d77de738 ML |
15957 | @item ipa-sra-max-replacements |
15958 | Maximum pieces of an aggregate that IPA-SRA tracks. As a | |
15959 | consequence, it is also the maximum number of replacements of a formal | |
15960 | parameter. | |
15961 | ||
15962 | @item sra-max-scalarization-size-Ospeed | |
15963 | @itemx sra-max-scalarization-size-Osize | |
15964 | The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to | |
15965 | replace scalar parts of aggregates with uses of independent scalar | |
15966 | variables. These parameters control the maximum size, in storage units, | |
15967 | of aggregate which is considered for replacement when compiling for | |
15968 | speed | |
15969 | (@option{sra-max-scalarization-size-Ospeed}) or size | |
15970 | (@option{sra-max-scalarization-size-Osize}) respectively. | |
15971 | ||
15972 | @item sra-max-propagations | |
15973 | The maximum number of artificial accesses that Scalar Replacement of | |
15974 | Aggregates (SRA) will track, per one local variable, in order to | |
15975 | facilitate copy propagation. | |
15976 | ||
15977 | @item tm-max-aggregate-size | |
15978 | When making copies of thread-local variables in a transaction, this | |
15979 | parameter specifies the size in bytes after which variables are | |
15980 | saved with the logging functions as opposed to save/restore code | |
15981 | sequence pairs. This option only applies when using | |
15982 | @option{-fgnu-tm}. | |
15983 | ||
15984 | @item graphite-max-nb-scop-params | |
15985 | To avoid exponential effects in the Graphite loop transforms, the | |
15986 | number of parameters in a Static Control Part (SCoP) is bounded. | |
15987 | A value of zero can be used to lift | |
15988 | the bound. A variable whose value is unknown at compilation time and | |
15989 | defined outside a SCoP is a parameter of the SCoP. | |
15990 | ||
551935d1 AO |
15991 | @item hardcfr-max-blocks |
15992 | Disable @option{-fharden-control-flow-redundancy} for functions with a | |
15993 | larger number of blocks than the specified value. Zero removes any | |
15994 | limit. | |
15995 | ||
15996 | @item hardcfr-max-inline-blocks | |
15997 | Force @option{-fharden-control-flow-redundancy} to use out-of-line | |
15998 | checking for functions with a larger number of basic blocks than the | |
15999 | specified value. | |
16000 | ||
d77de738 ML |
16001 | @item loop-block-tile-size |
16002 | Loop blocking or strip mining transforms, enabled with | |
16003 | @option{-floop-block} or @option{-floop-strip-mine}, strip mine each | |
16004 | loop in the loop nest by a given number of iterations. The strip | |
16005 | length can be changed using the @option{loop-block-tile-size} | |
16006 | parameter. | |
16007 | ||
16008 | @item ipa-jump-function-lookups | |
16009 | Specifies number of statements visited during jump function offset discovery. | |
16010 | ||
16011 | @item ipa-cp-value-list-size | |
16012 | IPA-CP attempts to track all possible values and types passed to a function's | |
16013 | parameter in order to propagate them and perform devirtualization. | |
16014 | @option{ipa-cp-value-list-size} is the maximum number of values and types it | |
16015 | stores per one formal parameter of a function. | |
16016 | ||
16017 | @item ipa-cp-eval-threshold | |
16018 | IPA-CP calculates its own score of cloning profitability heuristics | |
16019 | and performs those cloning opportunities with scores that exceed | |
16020 | @option{ipa-cp-eval-threshold}. | |
16021 | ||
16022 | @item ipa-cp-max-recursive-depth | |
16023 | Maximum depth of recursive cloning for self-recursive function. | |
16024 | ||
16025 | @item ipa-cp-min-recursive-probability | |
16026 | Recursive cloning only when the probability of call being executed exceeds | |
16027 | the parameter. | |
16028 | ||
16029 | @item ipa-cp-profile-count-base | |
16030 | When using @option{-fprofile-use} option, IPA-CP will consider the measured | |
16031 | execution count of a call graph edge at this percentage position in their | |
16032 | histogram as the basis for its heuristics calculation. | |
16033 | ||
16034 | @item ipa-cp-recursive-freq-factor | |
16035 | The number of times interprocedural copy propagation expects recursive | |
16036 | functions to call themselves. | |
16037 | ||
16038 | @item ipa-cp-recursion-penalty | |
16039 | Percentage penalty the recursive functions will receive when they | |
16040 | are evaluated for cloning. | |
16041 | ||
16042 | @item ipa-cp-single-call-penalty | |
16043 | Percentage penalty functions containing a single call to another | |
16044 | function will receive when they are evaluated for cloning. | |
16045 | ||
16046 | @item ipa-max-agg-items | |
16047 | IPA-CP is also capable to propagate a number of scalar values passed | |
16048 | in an aggregate. @option{ipa-max-agg-items} controls the maximum | |
16049 | number of such values per one parameter. | |
16050 | ||
16051 | @item ipa-cp-loop-hint-bonus | |
16052 | When IPA-CP determines that a cloning candidate would make the number | |
16053 | of iterations of a loop known, it adds a bonus of | |
16054 | @option{ipa-cp-loop-hint-bonus} to the profitability score of | |
16055 | the candidate. | |
16056 | ||
16057 | @item ipa-max-loop-predicates | |
16058 | The maximum number of different predicates IPA will use to describe when | |
16059 | loops in a function have known properties. | |
16060 | ||
16061 | @item ipa-max-aa-steps | |
16062 | During its analysis of function bodies, IPA-CP employs alias analysis | |
16063 | in order to track values pointed to by function parameters. In order | |
16064 | not spend too much time analyzing huge functions, it gives up and | |
16065 | consider all memory clobbered after examining | |
16066 | @option{ipa-max-aa-steps} statements modifying memory. | |
16067 | ||
16068 | @item ipa-max-switch-predicate-bounds | |
16069 | Maximal number of boundary endpoints of case ranges of switch statement. | |
16070 | For switch exceeding this limit, IPA-CP will not construct cloning cost | |
16071 | predicate, which is used to estimate cloning benefit, for default case | |
16072 | of the switch statement. | |
16073 | ||
16074 | @item ipa-max-param-expr-ops | |
16075 | IPA-CP will analyze conditional statement that references some function | |
16076 | parameter to estimate benefit for cloning upon certain constant value. | |
16077 | But if number of operations in a parameter expression exceeds | |
16078 | @option{ipa-max-param-expr-ops}, the expression is treated as complicated | |
16079 | one, and is not handled by IPA analysis. | |
16080 | ||
16081 | @item lto-partitions | |
16082 | Specify desired number of partitions produced during WHOPR compilation. | |
16083 | The number of partitions should exceed the number of CPUs used for compilation. | |
16084 | ||
16085 | @item lto-min-partition | |
16086 | Size of minimal partition for WHOPR (in estimated instructions). | |
16087 | This prevents expenses of splitting very small programs into too many | |
16088 | partitions. | |
16089 | ||
16090 | @item lto-max-partition | |
16091 | Size of max partition for WHOPR (in estimated instructions). | |
16092 | to provide an upper bound for individual size of partition. | |
16093 | Meant to be used only with balanced partitioning. | |
16094 | ||
16095 | @item lto-max-streaming-parallelism | |
16096 | Maximal number of parallel processes used for LTO streaming. | |
16097 | ||
16098 | @item cxx-max-namespaces-for-diagnostic-help | |
16099 | The maximum number of namespaces to consult for suggestions when C++ | |
16100 | name lookup fails for an identifier. | |
16101 | ||
16102 | @item sink-frequency-threshold | |
16103 | The maximum relative execution frequency (in percents) of the target block | |
16104 | relative to a statement's original block to allow statement sinking of a | |
16105 | statement. Larger numbers result in more aggressive statement sinking. | |
16106 | A small positive adjustment is applied for | |
16107 | statements with memory operands as those are even more profitable so sink. | |
16108 | ||
16109 | @item max-stores-to-sink | |
16110 | The maximum number of conditional store pairs that can be sunk. Set to 0 | |
16111 | if either vectorization (@option{-ftree-vectorize}) or if-conversion | |
16112 | (@option{-ftree-loop-if-convert}) is disabled. | |
16113 | ||
16114 | @item case-values-threshold | |
16115 | The smallest number of different values for which it is best to use a | |
16116 | jump-table instead of a tree of conditional branches. If the value is | |
16117 | 0, use the default for the machine. | |
16118 | ||
16119 | @item jump-table-max-growth-ratio-for-size | |
16120 | The maximum code size growth ratio when expanding | |
16121 | into a jump table (in percent). The parameter is used when | |
16122 | optimizing for size. | |
16123 | ||
16124 | @item jump-table-max-growth-ratio-for-speed | |
16125 | The maximum code size growth ratio when expanding | |
16126 | into a jump table (in percent). The parameter is used when | |
16127 | optimizing for speed. | |
16128 | ||
16129 | @item tree-reassoc-width | |
16130 | Set the maximum number of instructions executed in parallel in | |
16131 | reassociated tree. This parameter overrides target dependent | |
16132 | heuristics used by default if has non zero value. | |
16133 | ||
16134 | @item sched-pressure-algorithm | |
16135 | Choose between the two available implementations of | |
16136 | @option{-fsched-pressure}. Algorithm 1 is the original implementation | |
16137 | and is the more likely to prevent instructions from being reordered. | |
16138 | Algorithm 2 was designed to be a compromise between the relatively | |
16139 | conservative approach taken by algorithm 1 and the rather aggressive | |
16140 | approach taken by the default scheduler. It relies more heavily on | |
16141 | having a regular register file and accurate register pressure classes. | |
16142 | See @file{haifa-sched.cc} in the GCC sources for more details. | |
16143 | ||
16144 | The default choice depends on the target. | |
16145 | ||
16146 | @item max-slsr-cand-scan | |
16147 | Set the maximum number of existing candidates that are considered when | |
16148 | seeking a basis for a new straight-line strength reduction candidate. | |
16149 | ||
16150 | @item asan-globals | |
16151 | Enable buffer overflow detection for global objects. This kind | |
16152 | of protection is enabled by default if you are using | |
16153 | @option{-fsanitize=address} option. | |
16154 | To disable global objects protection use @option{--param asan-globals=0}. | |
16155 | ||
16156 | @item asan-stack | |
16157 | Enable buffer overflow detection for stack objects. This kind of | |
16158 | protection is enabled by default when using @option{-fsanitize=address}. | |
16159 | To disable stack protection use @option{--param asan-stack=0} option. | |
16160 | ||
16161 | @item asan-instrument-reads | |
16162 | Enable buffer overflow detection for memory reads. This kind of | |
16163 | protection is enabled by default when using @option{-fsanitize=address}. | |
16164 | To disable memory reads protection use | |
16165 | @option{--param asan-instrument-reads=0}. | |
16166 | ||
16167 | @item asan-instrument-writes | |
16168 | Enable buffer overflow detection for memory writes. This kind of | |
16169 | protection is enabled by default when using @option{-fsanitize=address}. | |
16170 | To disable memory writes protection use | |
16171 | @option{--param asan-instrument-writes=0} option. | |
16172 | ||
16173 | @item asan-memintrin | |
16174 | Enable detection for built-in functions. This kind of protection | |
16175 | is enabled by default when using @option{-fsanitize=address}. | |
16176 | To disable built-in functions protection use | |
16177 | @option{--param asan-memintrin=0}. | |
16178 | ||
16179 | @item asan-use-after-return | |
16180 | Enable detection of use-after-return. This kind of protection | |
16181 | is enabled by default when using the @option{-fsanitize=address} option. | |
16182 | To disable it use @option{--param asan-use-after-return=0}. | |
16183 | ||
16184 | Note: By default the check is disabled at run time. To enable it, | |
16185 | add @code{detect_stack_use_after_return=1} to the environment variable | |
16186 | @env{ASAN_OPTIONS}. | |
16187 | ||
16188 | @item asan-instrumentation-with-call-threshold | |
16189 | If number of memory accesses in function being instrumented | |
16190 | is greater or equal to this number, use callbacks instead of inline checks. | |
16191 | E.g. to disable inline code use | |
16192 | @option{--param asan-instrumentation-with-call-threshold=0}. | |
16193 | ||
545c9f8b | 16194 | @item asan-kernel-mem-intrinsic-prefix |
f56ed5b3 SL |
16195 | If nonzero, prefix calls to @code{memcpy}, @code{memset} and @code{memmove} |
16196 | with @samp{__asan_} or @samp{__hwasan_} | |
16197 | for @option{-fsanitize=kernel-address} or @samp{-fsanitize=kernel-hwaddress}, | |
16198 | respectively. | |
545c9f8b | 16199 | |
d77de738 ML |
16200 | @item hwasan-instrument-stack |
16201 | Enable hwasan instrumentation of statically sized stack-allocated variables. | |
16202 | This kind of instrumentation is enabled by default when using | |
16203 | @option{-fsanitize=hwaddress} and disabled by default when using | |
16204 | @option{-fsanitize=kernel-hwaddress}. | |
16205 | To disable stack instrumentation use | |
16206 | @option{--param hwasan-instrument-stack=0}, and to enable it use | |
16207 | @option{--param hwasan-instrument-stack=1}. | |
16208 | ||
16209 | @item hwasan-random-frame-tag | |
16210 | When using stack instrumentation, decide tags for stack variables using a | |
16211 | deterministic sequence beginning at a random tag for each frame. With this | |
16212 | parameter unset tags are chosen using the same sequence but beginning from 1. | |
16213 | This is enabled by default for @option{-fsanitize=hwaddress} and unavailable | |
16214 | for @option{-fsanitize=kernel-hwaddress}. | |
16215 | To disable it use @option{--param hwasan-random-frame-tag=0}. | |
16216 | ||
16217 | @item hwasan-instrument-allocas | |
16218 | Enable hwasan instrumentation of dynamically sized stack-allocated variables. | |
16219 | This kind of instrumentation is enabled by default when using | |
16220 | @option{-fsanitize=hwaddress} and disabled by default when using | |
16221 | @option{-fsanitize=kernel-hwaddress}. | |
16222 | To disable instrumentation of such variables use | |
16223 | @option{--param hwasan-instrument-allocas=0}, and to enable it use | |
16224 | @option{--param hwasan-instrument-allocas=1}. | |
16225 | ||
16226 | @item hwasan-instrument-reads | |
16227 | Enable hwasan checks on memory reads. Instrumentation of reads is enabled by | |
16228 | default for both @option{-fsanitize=hwaddress} and | |
16229 | @option{-fsanitize=kernel-hwaddress}. | |
16230 | To disable checking memory reads use | |
16231 | @option{--param hwasan-instrument-reads=0}. | |
16232 | ||
16233 | @item hwasan-instrument-writes | |
16234 | Enable hwasan checks on memory writes. Instrumentation of writes is enabled by | |
16235 | default for both @option{-fsanitize=hwaddress} and | |
16236 | @option{-fsanitize=kernel-hwaddress}. | |
16237 | To disable checking memory writes use | |
16238 | @option{--param hwasan-instrument-writes=0}. | |
16239 | ||
16240 | @item hwasan-instrument-mem-intrinsics | |
16241 | Enable hwasan instrumentation of builtin functions. Instrumentation of these | |
16242 | builtin functions is enabled by default for both @option{-fsanitize=hwaddress} | |
16243 | and @option{-fsanitize=kernel-hwaddress}. | |
16244 | To disable instrumentation of builtin functions use | |
16245 | @option{--param hwasan-instrument-mem-intrinsics=0}. | |
16246 | ||
16247 | @item use-after-scope-direct-emission-threshold | |
16248 | If the size of a local variable in bytes is smaller or equal to this | |
16249 | number, directly poison (or unpoison) shadow memory instead of using | |
16250 | run-time callbacks. | |
16251 | ||
16252 | @item tsan-distinguish-volatile | |
16253 | Emit special instrumentation for accesses to volatiles. | |
16254 | ||
16255 | @item tsan-instrument-func-entry-exit | |
16256 | Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit(). | |
16257 | ||
16258 | @item max-fsm-thread-path-insns | |
16259 | Maximum number of instructions to copy when duplicating blocks on a | |
16260 | finite state automaton jump thread path. | |
16261 | ||
16262 | @item threader-debug | |
16263 | threader-debug=[none|all] Enables verbose dumping of the threader solver. | |
16264 | ||
16265 | @item parloops-chunk-size | |
16266 | Chunk size of omp schedule for loops parallelized by parloops. | |
16267 | ||
16268 | @item parloops-schedule | |
16269 | Schedule type of omp schedule for loops parallelized by parloops (static, | |
16270 | dynamic, guided, auto, runtime). | |
16271 | ||
16272 | @item parloops-min-per-thread | |
16273 | The minimum number of iterations per thread of an innermost parallelized | |
16274 | loop for which the parallelized variant is preferred over the single threaded | |
16275 | one. Note that for a parallelized loop nest the | |
16276 | minimum number of iterations of the outermost loop per thread is two. | |
16277 | ||
16278 | @item max-ssa-name-query-depth | |
16279 | Maximum depth of recursion when querying properties of SSA names in things | |
16280 | like fold routines. One level of recursion corresponds to following a | |
16281 | use-def chain. | |
16282 | ||
16283 | @item max-speculative-devirt-maydefs | |
16284 | The maximum number of may-defs we analyze when looking for a must-def | |
16285 | specifying the dynamic type of an object that invokes a virtual call | |
16286 | we may be able to devirtualize speculatively. | |
16287 | ||
d77de738 ML |
16288 | @item ranger-debug |
16289 | Specifies the type of debug output to be issued for ranges. | |
16290 | ||
d77de738 ML |
16291 | @item unroll-jam-min-percent |
16292 | The minimum percentage of memory references that must be optimized | |
16293 | away for the unroll-and-jam transformation to be considered profitable. | |
16294 | ||
16295 | @item unroll-jam-max-unroll | |
16296 | The maximum number of times the outer loop should be unrolled by | |
16297 | the unroll-and-jam transformation. | |
16298 | ||
16299 | @item max-rtl-if-conversion-unpredictable-cost | |
16300 | Maximum permissible cost for the sequence that would be generated | |
16301 | by the RTL if-conversion pass for a branch that is considered unpredictable. | |
16302 | ||
16303 | @item max-variable-expansions-in-unroller | |
16304 | If @option{-fvariable-expansion-in-unroller} is used, the maximum number | |
16305 | of times that an individual variable will be expanded during loop unrolling. | |
16306 | ||
16307 | @item partial-inlining-entry-probability | |
16308 | Maximum probability of the entry BB of split region | |
16309 | (in percent relative to entry BB of the function) | |
16310 | to make partial inlining happen. | |
16311 | ||
16312 | @item max-tracked-strlens | |
16313 | Maximum number of strings for which strlen optimization pass will | |
16314 | track string lengths. | |
16315 | ||
16316 | @item gcse-after-reload-partial-fraction | |
16317 | The threshold ratio for performing partial redundancy | |
16318 | elimination after reload. | |
16319 | ||
16320 | @item gcse-after-reload-critical-fraction | |
16321 | The threshold ratio of critical edges execution count that | |
16322 | permit performing redundancy elimination after reload. | |
16323 | ||
16324 | @item max-loop-header-insns | |
16325 | The maximum number of insns in loop header duplicated | |
16326 | by the copy loop headers pass. | |
16327 | ||
16328 | @item vect-epilogues-nomask | |
16329 | Enable loop epilogue vectorization using smaller vector size. | |
16330 | ||
16331 | @item vect-partial-vector-usage | |
16332 | Controls when the loop vectorizer considers using partial vector loads | |
16333 | and stores as an alternative to falling back to scalar code. 0 stops | |
16334 | the vectorizer from ever using partial vector loads and stores. 1 allows | |
16335 | partial vector loads and stores if vectorization removes the need for the | |
16336 | code to iterate. 2 allows partial vector loads and stores in all loops. | |
16337 | The parameter only has an effect on targets that support partial | |
16338 | vector loads and stores. | |
16339 | ||
16340 | @item vect-inner-loop-cost-factor | |
16341 | The maximum factor which the loop vectorizer applies to the cost of statements | |
16342 | in an inner loop relative to the loop being vectorized. The factor applied | |
16343 | is the maximum of the estimated number of iterations of the inner loop and | |
16344 | this parameter. The default value of this parameter is 50. | |
16345 | ||
16346 | @item vect-induction-float | |
16347 | Enable loop vectorization of floating point inductions. | |
16348 | ||
cbe32d38 ML |
16349 | @item vrp-sparse-threshold |
16350 | Maximum number of basic blocks before VRP uses a sparse bitmap cache. | |
16351 | ||
16352 | @item vrp-switch-limit | |
16353 | Maximum number of outgoing edges in a switch before VRP will not process it. | |
16354 | ||
16355 | @item vrp-vector-threshold | |
16356 | Maximum number of basic blocks for VRP to use a basic cache vector. | |
16357 | ||
d77de738 ML |
16358 | @item avoid-fma-max-bits |
16359 | Maximum number of bits for which we avoid creating FMAs. | |
16360 | ||
16361 | @item sms-loop-average-count-threshold | |
16362 | A threshold on the average loop count considered by the swing modulo scheduler. | |
16363 | ||
16364 | @item sms-dfa-history | |
16365 | The number of cycles the swing modulo scheduler considers when checking | |
16366 | conflicts using DFA. | |
16367 | ||
16368 | @item graphite-allow-codegen-errors | |
16369 | Whether codegen errors should be ICEs when @option{-fchecking}. | |
16370 | ||
16371 | @item sms-max-ii-factor | |
16372 | A factor for tuning the upper bound that swing modulo scheduler | |
16373 | uses for scheduling a loop. | |
16374 | ||
16375 | @item lra-max-considered-reload-pseudos | |
16376 | The max number of reload pseudos which are considered during | |
16377 | spilling a non-reload pseudo. | |
16378 | ||
16379 | @item max-pow-sqrt-depth | |
16380 | Maximum depth of sqrt chains to use when synthesizing exponentiation | |
16381 | by a real constant. | |
16382 | ||
16383 | @item max-dse-active-local-stores | |
16384 | Maximum number of active local stores in RTL dead store elimination. | |
16385 | ||
16386 | @item asan-instrument-allocas | |
16387 | Enable asan allocas/VLAs protection. | |
16388 | ||
16389 | @item max-iterations-computation-cost | |
16390 | Bound on the cost of an expression to compute the number of iterations. | |
16391 | ||
16392 | @item max-isl-operations | |
16393 | Maximum number of isl operations, 0 means unlimited. | |
16394 | ||
16395 | @item graphite-max-arrays-per-scop | |
16396 | Maximum number of arrays per scop. | |
16397 | ||
16398 | @item max-vartrack-reverse-op-size | |
16399 | Max. size of loc list for which reverse ops should be added. | |
16400 | ||
16401 | @item fsm-scale-path-stmts | |
16402 | Scale factor to apply to the number of statements in a threading path | |
7c9f20fc RB |
16403 | crossing a loop backedge when comparing to |
16404 | @option{--param=max-jump-thread-duplication-stmts}. | |
d77de738 ML |
16405 | |
16406 | @item uninit-control-dep-attempts | |
16407 | Maximum number of nested calls to search for control dependencies | |
16408 | during uninitialized variable analysis. | |
16409 | ||
b8a2a124 RB |
16410 | @item uninit-max-chain-len |
16411 | Maximum number of predicates anded for each predicate ored in the normalized | |
16412 | predicate chain. | |
16413 | ||
16414 | @item uninit-max-num-chains | |
16415 | Maximum number of predicates ored in the normalized predicate chain. | |
16416 | ||
d77de738 ML |
16417 | @item sched-autopref-queue-depth |
16418 | Hardware autoprefetcher scheduler model control flag. | |
16419 | Number of lookahead cycles the model looks into; at ' | |
16420 | ' only enable instruction sorting heuristic. | |
16421 | ||
16422 | @item loop-versioning-max-inner-insns | |
16423 | The maximum number of instructions that an inner loop can have | |
16424 | before the loop versioning pass considers it too big to copy. | |
16425 | ||
16426 | @item loop-versioning-max-outer-insns | |
16427 | The maximum number of instructions that an outer loop can have | |
16428 | before the loop versioning pass considers it too big to copy, | |
16429 | discounting any instructions in inner loops that directly benefit | |
16430 | from versioning. | |
16431 | ||
16432 | @item ssa-name-def-chain-limit | |
16433 | The maximum number of SSA_NAME assignments to follow in determining | |
16434 | a property of a variable such as its value. This limits the number | |
16435 | of iterations or recursive calls GCC performs when optimizing certain | |
16436 | statements or when determining their validity prior to issuing | |
16437 | diagnostics. | |
16438 | ||
16439 | @item store-merging-max-size | |
16440 | Maximum size of a single store merging region in bytes. | |
16441 | ||
16442 | @item hash-table-verification-limit | |
16443 | The number of elements for which hash table verification is done | |
16444 | for each searched element. | |
16445 | ||
16446 | @item max-find-base-term-values | |
16447 | Maximum number of VALUEs handled during a single find_base_term call. | |
16448 | ||
16449 | @item analyzer-max-enodes-per-program-point | |
16450 | The maximum number of exploded nodes per program point within | |
16451 | the analyzer, before terminating analysis of that point. | |
16452 | ||
16453 | @item analyzer-max-constraints | |
16454 | The maximum number of constraints per state. | |
16455 | ||
16456 | @item analyzer-min-snodes-for-call-summary | |
16457 | The minimum number of supernodes within a function for the | |
16458 | analyzer to consider summarizing its effects at call sites. | |
16459 | ||
16460 | @item analyzer-max-enodes-for-full-dump | |
16461 | The maximum depth of exploded nodes that should appear in a dot dump | |
16462 | before switching to a less verbose format. | |
16463 | ||
16464 | @item analyzer-max-recursion-depth | |
16465 | The maximum number of times a callsite can appear in a call stack | |
16466 | within the analyzer, before terminating analysis of a call that would | |
16467 | recurse deeper. | |
16468 | ||
16469 | @item analyzer-max-svalue-depth | |
16470 | The maximum depth of a symbolic value, before approximating | |
16471 | the value as unknown. | |
16472 | ||
16473 | @item analyzer-max-infeasible-edges | |
16474 | The maximum number of infeasible edges to reject before declaring | |
16475 | a diagnostic as infeasible. | |
16476 | ||
16477 | @item gimple-fe-computed-hot-bb-threshold | |
16478 | The number of executions of a basic block which is considered hot. | |
16479 | The parameter is used only in GIMPLE FE. | |
16480 | ||
16481 | @item analyzer-bb-explosion-factor | |
16482 | The maximum number of 'after supernode' exploded nodes within the analyzer | |
16483 | per supernode, before terminating analysis. | |
16484 | ||
c0c5a57b MJ |
16485 | @item analyzer-text-art-string-ellipsis-threshold |
16486 | The number of bytes at which to ellipsize string literals in analyzer text art diagrams. | |
16487 | ||
16488 | @item analyzer-text-art-ideal-canvas-width | |
16489 | The ideal width in characters of text art diagrams generated by the analyzer. | |
16490 | ||
16491 | @item analyzer-text-art-string-ellipsis-head-len | |
16492 | The number of literal bytes to show at the head of a string literal in text art when ellipsizing it. | |
16493 | ||
16494 | @item analyzer-text-art-string-ellipsis-tail-len | |
16495 | The number of literal bytes to show at the tail of a string literal in text art when ellipsizing it. | |
16496 | ||
d77de738 ML |
16497 | @item ranger-logical-depth |
16498 | Maximum depth of logical expression evaluation ranger will look through | |
16499 | when evaluating outgoing edge ranges. | |
16500 | ||
9fd6d83a ML |
16501 | @item ranger-recompute-depth |
16502 | Maximum depth of instruction chains to consider for recomputation | |
16503 | in the outgoing range calculator. | |
16504 | ||
d77de738 ML |
16505 | @item relation-block-limit |
16506 | Maximum number of relations the oracle will register in a basic block. | |
16507 | ||
16508 | @item min-pagesize | |
16509 | Minimum page size for warning purposes. | |
16510 | ||
16511 | @item openacc-kernels | |
16512 | Specify mode of OpenACC `kernels' constructs handling. | |
16513 | With @option{--param=openacc-kernels=decompose}, OpenACC `kernels' | |
16514 | constructs are decomposed into parts, a sequence of compute | |
16515 | constructs, each then handled individually. | |
16516 | This is work in progress. | |
16517 | With @option{--param=openacc-kernels=parloops}, OpenACC `kernels' | |
16518 | constructs are handled by the @samp{parloops} pass, en bloc. | |
16519 | This is the current default. | |
16520 | ||
16521 | @item openacc-privatization | |
4ace81b6 SL |
16522 | Control whether the @option{-fopt-info-omp-note} and applicable |
16523 | @option{-fdump-tree-*-details} options emit OpenACC privatization diagnostics. | |
d77de738 ML |
16524 | With @option{--param=openacc-privatization=quiet}, don't diagnose. |
16525 | This is the current default. | |
16526 | With @option{--param=openacc-privatization=noisy}, do diagnose. | |
16527 | ||
16528 | @end table | |
16529 | ||
16530 | The following choices of @var{name} are available on AArch64 targets: | |
16531 | ||
16532 | @table @gcctabopt | |
16533 | @item aarch64-sve-compare-costs | |
16534 | When vectorizing for SVE, consider using ``unpacked'' vectors for | |
16535 | smaller elements and use the cost model to pick the cheapest approach. | |
16536 | Also use the cost model to choose between SVE and Advanced SIMD vectorization. | |
16537 | ||
16538 | Using unpacked vectors includes storing smaller elements in larger | |
16539 | containers and accessing elements with extending loads and truncating | |
16540 | stores. | |
16541 | ||
16542 | @item aarch64-float-recp-precision | |
16543 | The number of Newton iterations for calculating the reciprocal for float type. | |
16544 | The precision of division is proportional to this param when division | |
16545 | approximation is enabled. The default value is 1. | |
16546 | ||
16547 | @item aarch64-double-recp-precision | |
16548 | The number of Newton iterations for calculating the reciprocal for double type. | |
16549 | The precision of division is propotional to this param when division | |
16550 | approximation is enabled. The default value is 2. | |
16551 | ||
16552 | @item aarch64-autovec-preference | |
16553 | Force an ISA selection strategy for auto-vectorization. Accepts values from | |
16554 | 0 to 4, inclusive. | |
16555 | @table @samp | |
16556 | @item 0 | |
16557 | Use the default heuristics. | |
16558 | @item 1 | |
16559 | Use only Advanced SIMD for auto-vectorization. | |
16560 | @item 2 | |
16561 | Use only SVE for auto-vectorization. | |
16562 | @item 3 | |
16563 | Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are | |
16564 | deemed equal. | |
16565 | @item 4 | |
16566 | Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal. | |
16567 | @end table | |
16568 | The default value is 0. | |
16569 | ||
834fc2bf MA |
16570 | @item aarch64-ldp-policy |
16571 | Fine-grained policy for load pairs. | |
16572 | With @option{--param=aarch64-ldp-policy=default}, use the policy of the | |
16573 | tuning structure. This is the current default. | |
16574 | With @option{--param=aarch64-ldp-policy=always}, emit ldp regardless | |
16575 | of alignment. | |
16576 | With @option{--param=aarch64-ldp-policy=never}, do not emit ldp. | |
16577 | With @option{--param=aarch64-ldp-policy=aligned}, emit ldp only if the | |
16578 | source pointer is aligned to at least double the alignment of the type. | |
16579 | ||
16580 | @item aarch64-stp-policy | |
16581 | Fine-grained policy for store pairs. | |
16582 | With @option{--param=aarch64-stp-policy=default}, use the policy of the | |
16583 | tuning structure. This is the current default. | |
16584 | With @option{--param=aarch64-stp-policy=always}, emit stp regardless | |
16585 | of alignment. | |
16586 | With @option{--param=aarch64-stp-policy=never}, do not emit stp. | |
16587 | With @option{--param=aarch64-stp-policy=aligned}, emit stp only if the | |
16588 | source pointer is aligned to at least double the alignment of the type. | |
16589 | ||
d77de738 ML |
16590 | @item aarch64-loop-vect-issue-rate-niters |
16591 | The tuning for some AArch64 CPUs tries to take both latencies and issue | |
16592 | rates into account when deciding whether a loop should be vectorized | |
16593 | using SVE, vectorized using Advanced SIMD, or not vectorized at all. | |
16594 | If this parameter is set to @var{n}, GCC will not use this heuristic | |
16595 | for loops that are known to execute in fewer than @var{n} Advanced | |
16596 | SIMD iterations. | |
16597 | ||
16598 | @item aarch64-vect-unroll-limit | |
16599 | The vectorizer will use available tuning information to determine whether it | |
16600 | would be beneficial to unroll the main vectorized loop and by how much. This | |
16601 | parameter set's the upper bound of how much the vectorizer will unroll the main | |
16602 | loop. The default value is four. | |
16603 | ||
16604 | @end table | |
16605 | ||
16606 | The following choices of @var{name} are available on i386 and x86_64 targets: | |
16607 | ||
16608 | @table @gcctabopt | |
16609 | @item x86-stlf-window-ninsns | |
16610 | Instructions number above which STFL stall penalty can be compensated. | |
16611 | ||
60101899 RB |
16612 | @item x86-stv-max-visits |
16613 | The maximum number of use and def visits when discovering a STV chain before | |
16614 | the discovery is aborted. | |
16615 | ||
d77de738 ML |
16616 | @end table |
16617 | ||
16618 | @end table | |
16619 | ||
16620 | @node Instrumentation Options | |
16621 | @section Program Instrumentation Options | |
16622 | @cindex instrumentation options | |
16623 | @cindex program instrumentation options | |
16624 | @cindex run-time error checking options | |
16625 | @cindex profiling options | |
16626 | @cindex options, program instrumentation | |
16627 | @cindex options, run-time error checking | |
16628 | @cindex options, profiling | |
16629 | ||
16630 | GCC supports a number of command-line options that control adding | |
16631 | run-time instrumentation to the code it normally generates. | |
16632 | For example, one purpose of instrumentation is collect profiling | |
16633 | statistics for use in finding program hot spots, code coverage | |
16634 | analysis, or profile-guided optimizations. | |
16635 | Another class of program instrumentation is adding run-time checking | |
16636 | to detect programming errors like invalid pointer | |
16637 | dereferences or out-of-bounds array accesses, as well as deliberately | |
16638 | hostile attacks such as stack smashing or C++ vtable hijacking. | |
16639 | There is also a general hook which can be used to implement other | |
16640 | forms of tracing or function-level instrumentation for debug or | |
16641 | program analysis purposes. | |
16642 | ||
16643 | @table @gcctabopt | |
16644 | @cindex @command{prof} | |
16645 | @cindex @command{gprof} | |
d77de738 ML |
16646 | @opindex p |
16647 | @opindex pg | |
ddf6fe37 AA |
16648 | @item -p |
16649 | @itemx -pg | |
d77de738 ML |
16650 | Generate extra code to write profile information suitable for the |
16651 | analysis program @command{prof} (for @option{-p}) or @command{gprof} | |
16652 | (for @option{-pg}). You must use this option when compiling | |
16653 | the source files you want data about, and you must also use it when | |
16654 | linking. | |
16655 | ||
16656 | You can use the function attribute @code{no_instrument_function} to | |
16657 | suppress profiling of individual functions when compiling with these options. | |
16658 | @xref{Common Function Attributes}. | |
16659 | ||
d77de738 | 16660 | @opindex fprofile-arcs |
ddf6fe37 | 16661 | @item -fprofile-arcs |
d77de738 ML |
16662 | Add code so that program flow @dfn{arcs} are instrumented. During |
16663 | execution the program records how many times each branch and call is | |
16664 | executed and how many times it is taken or returns. On targets that support | |
16665 | constructors with priority support, profiling properly handles constructors, | |
16666 | destructors and C++ constructors (and destructors) of classes which are used | |
16667 | as a type of a global variable. | |
16668 | ||
16669 | When the compiled | |
16670 | program exits it saves this data to a file called | |
16671 | @file{@var{auxname}.gcda} for each source file. The data may be used for | |
16672 | profile-directed optimizations (@option{-fbranch-probabilities}), or for | |
16673 | test coverage analysis (@option{-ftest-coverage}). Each object file's | |
16674 | @var{auxname} is generated from the name of the output file, if | |
16675 | explicitly specified and it is not the final executable, otherwise it is | |
16676 | the basename of the source file. In both cases any suffix is removed | |
16677 | (e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or | |
16678 | @file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}). | |
16679 | ||
16680 | Note that if a command line directly links source files, the corresponding | |
16681 | @var{.gcda} files will be prefixed with the unsuffixed name of the output file. | |
16682 | E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and | |
16683 | @file{binary-b.gcda} files. | |
16684 | ||
16685 | @xref{Cross-profiling}. | |
16686 | ||
16687 | @cindex @command{gcov} | |
d77de738 | 16688 | @opindex coverage |
ddf6fe37 | 16689 | @item --coverage |
d77de738 ML |
16690 | |
16691 | This option is used to compile and link code instrumented for coverage | |
16692 | analysis. The option is a synonym for @option{-fprofile-arcs} | |
16693 | @option{-ftest-coverage} (when compiling) and @option{-lgcov} (when | |
16694 | linking). See the documentation for those options for more details. | |
16695 | ||
16696 | @itemize | |
16697 | ||
16698 | @item | |
16699 | Compile the source files with @option{-fprofile-arcs} plus optimization | |
16700 | and code generation options. For test coverage analysis, use the | |
16701 | additional @option{-ftest-coverage} option. You do not need to profile | |
16702 | every source file in a program. | |
16703 | ||
16704 | @item | |
16705 | Compile the source files additionally with @option{-fprofile-abs-path} | |
16706 | to create absolute path names in the @file{.gcno} files. This allows | |
16707 | @command{gcov} to find the correct sources in projects where compilations | |
16708 | occur with different working directories. | |
16709 | ||
16710 | @item | |
16711 | Link your object files with @option{-lgcov} or @option{-fprofile-arcs} | |
16712 | (the latter implies the former). | |
16713 | ||
16714 | @item | |
16715 | Run the program on a representative workload to generate the arc profile | |
16716 | information. This may be repeated any number of times. You can run | |
16717 | concurrent instances of your program, and provided that the file system | |
16718 | supports locking, the data files will be correctly updated. Unless | |
16719 | a strict ISO C dialect option is in effect, @code{fork} calls are | |
16720 | detected and correctly handled without double counting. | |
16721 | ||
16722 | Moreover, an object file can be recompiled multiple times | |
16723 | and the corresponding @file{.gcda} file merges as long as | |
16724 | the source file and the compiler options are unchanged. | |
16725 | ||
16726 | @item | |
16727 | For profile-directed optimizations, compile the source files again with | |
16728 | the same optimization and code generation options plus | |
16729 | @option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that | |
16730 | Control Optimization}). | |
16731 | ||
16732 | @item | |
16733 | For test coverage analysis, use @command{gcov} to produce human readable | |
16734 | information from the @file{.gcno} and @file{.gcda} files. Refer to the | |
16735 | @command{gcov} documentation for further information. | |
16736 | ||
16737 | @end itemize | |
16738 | ||
16739 | With @option{-fprofile-arcs}, for each function of your program GCC | |
16740 | creates a program flow graph, then finds a spanning tree for the graph. | |
16741 | Only arcs that are not on the spanning tree have to be instrumented: the | |
16742 | compiler adds code to count the number of times that these arcs are | |
16743 | executed. When an arc is the only exit or only entrance to a block, the | |
16744 | instrumentation code can be added to the block; otherwise, a new basic | |
16745 | block must be created to hold the instrumentation code. | |
16746 | ||
16747 | @need 2000 | |
d77de738 | 16748 | @opindex ftest-coverage |
ddf6fe37 | 16749 | @item -ftest-coverage |
d77de738 ML |
16750 | Produce a notes file that the @command{gcov} code-coverage utility |
16751 | (@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to | |
16752 | show program coverage. Each source file's note file is called | |
16753 | @file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option | |
16754 | above for a description of @var{auxname} and instructions on how to | |
16755 | generate test coverage data. Coverage data matches the source files | |
16756 | more closely if you do not optimize. | |
16757 | ||
d77de738 | 16758 | @opindex fprofile-abs-path |
ddf6fe37 | 16759 | @item -fprofile-abs-path |
d77de738 ML |
16760 | Automatically convert relative source file names to absolute path names |
16761 | in the @file{.gcno} files. This allows @command{gcov} to find the correct | |
16762 | sources in projects where compilations occur with different working | |
16763 | directories. | |
16764 | ||
d77de738 | 16765 | @opindex fprofile-dir |
ddf6fe37 | 16766 | @item -fprofile-dir=@var{path} |
d77de738 ML |
16767 | |
16768 | Set the directory to search for the profile data files in to @var{path}. | |
16769 | This option affects only the profile data generated by | |
16770 | @option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs} | |
16771 | and used by @option{-fprofile-use} and @option{-fbranch-probabilities} | |
16772 | and its related options. Both absolute and relative paths can be used. | |
16773 | By default, GCC uses the current directory as @var{path}, thus the | |
16774 | profile data file appears in the same directory as the object file. | |
16775 | In order to prevent the file name clashing, if the object file name is | |
16776 | not an absolute path, we mangle the absolute path of the | |
16777 | @file{@var{sourcename}.gcda} file and use it as the file name of a | |
16778 | @file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}. | |
16779 | See similar option @option{-fprofile-note}. | |
16780 | ||
16781 | When an executable is run in a massive parallel environment, it is recommended | |
16782 | to save profile to different folders. That can be done with variables | |
16783 | in @var{path} that are exported during run-time: | |
16784 | ||
16785 | @table @gcctabopt | |
16786 | ||
16787 | @item %p | |
16788 | process ID. | |
16789 | ||
16790 | @item %q@{VAR@} | |
16791 | value of environment variable @var{VAR} | |
16792 | ||
16793 | @end table | |
16794 | ||
ddf6fe37 | 16795 | @opindex fprofile-generate |
d77de738 ML |
16796 | @item -fprofile-generate |
16797 | @itemx -fprofile-generate=@var{path} | |
d77de738 ML |
16798 | |
16799 | Enable options usually used for instrumenting application to produce | |
16800 | profile useful for later recompilation with profile feedback based | |
16801 | optimization. You must use @option{-fprofile-generate} both when | |
16802 | compiling and when linking your program. | |
16803 | ||
16804 | The following options are enabled: | |
16805 | @option{-fprofile-arcs}, @option{-fprofile-values}, | |
16806 | @option{-finline-functions}, and @option{-fipa-bit-cp}. | |
16807 | ||
16808 | If @var{path} is specified, GCC looks at the @var{path} to find | |
16809 | the profile feedback data files. See @option{-fprofile-dir}. | |
16810 | ||
16811 | To optimize the program based on the collected profile information, use | |
16812 | @option{-fprofile-use}. @xref{Optimize Options}, for more information. | |
16813 | ||
ddf6fe37 | 16814 | @opindex fprofile-info-section |
d77de738 ML |
16815 | @item -fprofile-info-section |
16816 | @itemx -fprofile-info-section=@var{name} | |
d77de738 ML |
16817 | |
16818 | Register the profile information in the specified section instead of using a | |
16819 | constructor/destructor. The section name is @var{name} if it is specified, | |
16820 | otherwise the section name defaults to @code{.gcov_info}. A pointer to the | |
16821 | profile information generated by @option{-fprofile-arcs} is placed in the | |
16822 | specified section for each translation unit. This option disables the profile | |
16823 | information registration through a constructor and it disables the profile | |
16824 | information processing through a destructor. This option is not intended to be | |
16825 | used in hosted environments such as GNU/Linux. It targets freestanding | |
16826 | environments (for example embedded systems) with limited resources which do not | |
16827 | support constructors/destructors or the C library file I/O. | |
16828 | ||
16829 | The linker could collect the input sections in a continuous memory block and | |
16830 | define start and end symbols. A GNU linker script example which defines a | |
16831 | linker output section follows: | |
16832 | ||
16833 | @smallexample | |
16834 | .gcov_info : | |
16835 | @{ | |
16836 | PROVIDE (__gcov_info_start = .); | |
16837 | KEEP (*(.gcov_info)) | |
16838 | PROVIDE (__gcov_info_end = .); | |
16839 | @} | |
16840 | @end smallexample | |
16841 | ||
16842 | The program could dump the profiling information registered in this linker set | |
16843 | for example like this: | |
16844 | ||
16845 | @smallexample | |
16846 | #include <gcov.h> | |
16847 | #include <stdio.h> | |
16848 | #include <stdlib.h> | |
16849 | ||
16850 | extern const struct gcov_info *const __gcov_info_start[]; | |
16851 | extern const struct gcov_info *const __gcov_info_end[]; | |
16852 | ||
16853 | static void | |
16854 | dump (const void *d, unsigned n, void *arg) | |
16855 | @{ | |
16856 | const unsigned char *c = d; | |
16857 | ||
16858 | for (unsigned i = 0; i < n; ++i) | |
16859 | printf ("%02x", c[i]); | |
16860 | @} | |
16861 | ||
16862 | static void | |
16863 | filename (const char *f, void *arg) | |
16864 | @{ | |
16865 | __gcov_filename_to_gcfn (f, dump, arg ); | |
16866 | @} | |
16867 | ||
16868 | static void * | |
16869 | allocate (unsigned length, void *arg) | |
16870 | @{ | |
16871 | return malloc (length); | |
16872 | @} | |
16873 | ||
16874 | static void | |
16875 | dump_gcov_info (void) | |
16876 | @{ | |
16877 | const struct gcov_info *const *info = __gcov_info_start; | |
16878 | const struct gcov_info *const *end = __gcov_info_end; | |
16879 | ||
16880 | /* Obfuscate variable to prevent compiler optimizations. */ | |
16881 | __asm__ ("" : "+r" (info)); | |
16882 | ||
16883 | while (info != end) | |
16884 | @{ | |
16885 | void *arg = NULL; | |
16886 | __gcov_info_to_gcda (*info, filename, dump, allocate, arg); | |
16887 | putchar ('\n'); | |
16888 | ++info; | |
16889 | @} | |
16890 | @} | |
16891 | ||
16892 | int | |
16893 | main (void) | |
16894 | @{ | |
16895 | dump_gcov_info (); | |
16896 | return 0; | |
16897 | @} | |
16898 | @end smallexample | |
16899 | ||
16900 | The @command{merge-stream} subcommand of @command{gcov-tool} may be used to | |
16901 | deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and | |
16902 | @code{__gcov_info_to_gcda} functions and merge the profile information into | |
16903 | @file{.gcda} files on the host filesystem. | |
16904 | ||
d77de738 | 16905 | @opindex fprofile-note |
ddf6fe37 | 16906 | @item -fprofile-note=@var{path} |
d77de738 ML |
16907 | |
16908 | If @var{path} is specified, GCC saves @file{.gcno} file into @var{path} | |
16909 | location. If you combine the option with multiple source files, | |
16910 | the @file{.gcno} file will be overwritten. | |
16911 | ||
d77de738 | 16912 | @opindex fprofile-prefix-path |
ddf6fe37 | 16913 | @item -fprofile-prefix-path=@var{path} |
d77de738 ML |
16914 | |
16915 | This option can be used in combination with | |
16916 | @option{profile-generate=}@var{profile_dir} and | |
16917 | @option{profile-use=}@var{profile_dir} to inform GCC where is the base | |
16918 | directory of built source tree. By default @var{profile_dir} will contain | |
16919 | files with mangled absolute paths of all object files in the built project. | |
16920 | This is not desirable when directory used to build the instrumented binary | |
16921 | differs from the directory used to build the binary optimized with profile | |
16922 | feedback because the profile data will not be found during the optimized build. | |
16923 | In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path} | |
16924 | pointing to the base directory of the build can be used to strip the irrelevant | |
16925 | part of the path and keep all file names relative to the main build directory. | |
16926 | ||
d77de738 | 16927 | @opindex fprofile-prefix-map |
ddf6fe37 | 16928 | @item -fprofile-prefix-map=@var{old}=@var{new} |
d77de738 ML |
16929 | When compiling files residing in directory @file{@var{old}}, record |
16930 | profiling information (with @option{--coverage}) | |
16931 | describing them as if the files resided in | |
16932 | directory @file{@var{new}} instead. | |
2eb0191a | 16933 | See also @option{-ffile-prefix-map} and @option{-fcanon-prefix-map}. |
d77de738 | 16934 | |
d77de738 | 16935 | @opindex fprofile-update |
ddf6fe37 | 16936 | @item -fprofile-update=@var{method} |
d77de738 ML |
16937 | |
16938 | Alter the update method for an application instrumented for profile | |
16939 | feedback based optimization. The @var{method} argument should be one of | |
16940 | @samp{single}, @samp{atomic} or @samp{prefer-atomic}. | |
16941 | The first one is useful for single-threaded applications, | |
16942 | while the second one prevents profile corruption by emitting thread-safe code. | |
16943 | ||
16944 | @strong{Warning:} When an application does not properly join all threads | |
16945 | (or creates an detached thread), a profile file can be still corrupted. | |
16946 | ||
16947 | Using @samp{prefer-atomic} would be transformed either to @samp{atomic}, | |
16948 | when supported by a target, or to @samp{single} otherwise. The GCC driver | |
16949 | automatically selects @samp{prefer-atomic} when @option{-pthread} | |
16950 | is present in the command line. | |
16951 | ||
d77de738 | 16952 | @opindex fprofile-filter-files |
ddf6fe37 | 16953 | @item -fprofile-filter-files=@var{regex} |
d77de738 ML |
16954 | |
16955 | Instrument only functions from files whose name matches | |
16956 | any of the regular expressions (separated by semi-colons). | |
16957 | ||
16958 | For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument | |
16959 | only @file{main.c} and all C files starting with 'module'. | |
16960 | ||
d77de738 | 16961 | @opindex fprofile-exclude-files |
ddf6fe37 | 16962 | @item -fprofile-exclude-files=@var{regex} |
d77de738 ML |
16963 | |
16964 | Instrument only functions from files whose name does not match | |
16965 | any of the regular expressions (separated by semi-colons). | |
16966 | ||
16967 | For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation | |
16968 | of all files that are located in the @file{/usr/} folder. | |
16969 | ||
d77de738 | 16970 | @opindex fprofile-reproducible |
ddf6fe37 | 16971 | @item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]} |
d77de738 ML |
16972 | Control level of reproducibility of profile gathered by |
16973 | @code{-fprofile-generate}. This makes it possible to rebuild program | |
16974 | with same outcome which is useful, for example, for distribution | |
16975 | packages. | |
16976 | ||
16977 | With @option{-fprofile-reproducible=serial} the profile gathered by | |
16978 | @option{-fprofile-generate} is reproducible provided the trained program | |
16979 | behaves the same at each invocation of the train run, it is not | |
16980 | multi-threaded and profile data streaming is always done in the same | |
16981 | order. Note that profile streaming happens at the end of program run but | |
16982 | also before @code{fork} function is invoked. | |
16983 | ||
16984 | Note that it is quite common that execution counts of some part of | |
16985 | programs depends, for example, on length of temporary file names or | |
16986 | memory space randomization (that may affect hash-table collision rate). | |
16987 | Such non-reproducible part of programs may be annotated by | |
16988 | @code{no_instrument_function} function attribute. @command{gcov-dump} with | |
16989 | @option{-l} can be used to dump gathered data and verify that they are | |
16990 | indeed reproducible. | |
16991 | ||
16992 | With @option{-fprofile-reproducible=parallel-runs} collected profile | |
16993 | stays reproducible regardless the order of streaming of the data into | |
16994 | gcda files. This setting makes it possible to run multiple instances of | |
16995 | instrumented program in parallel (such as with @code{make -j}). This | |
16996 | reduces quality of gathered data, in particular of indirect call | |
16997 | profiling. | |
16998 | ||
d77de738 | 16999 | @opindex fsanitize=address |
ddf6fe37 | 17000 | @item -fsanitize=address |
d77de738 ML |
17001 | Enable AddressSanitizer, a fast memory error detector. |
17002 | Memory access instructions are instrumented to detect | |
17003 | out-of-bounds and use-after-free bugs. | |
17004 | The option enables @option{-fsanitize-address-use-after-scope}. | |
17005 | See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for | |
17006 | more details. The run-time behavior can be influenced using the | |
17007 | @env{ASAN_OPTIONS} environment variable. When set to @code{help=1}, | |
17008 | the available options are shown at startup of the instrumented program. See | |
17009 | @url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags} | |
17010 | for a list of supported options. | |
17011 | The option cannot be combined with @option{-fsanitize=thread} or | |
17012 | @option{-fsanitize=hwaddress}. Note that the only target | |
17013 | @option{-fsanitize=hwaddress} is currently supported on is AArch64. | |
17014 | ||
6a07798c MP |
17015 | To get more accurate stack traces, it is possible to use options such as |
17016 | @option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent | |
17017 | most function inlining), @option{-fno-optimize-sibling-calls} (which prevents | |
17018 | optimizing sibling and tail recursive calls; this option is implicit for | |
17019 | @option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which | |
17020 | disables Identical Code Folding for functions). Since multiple runs of the | |
17021 | program may yield backtraces with different addresses due to ASLR (Address | |
17022 | Space Layout Randomization), it may be desirable to turn ASLR off. On Linux, | |
17023 | this can be achieved with @samp{setarch `uname -m` -R ./prog}. | |
17024 | ||
d77de738 | 17025 | @opindex fsanitize=kernel-address |
f33d7a88 | 17026 | @item -fsanitize=kernel-address |
d77de738 | 17027 | Enable AddressSanitizer for Linux kernel. |
a0bf71be | 17028 | See @uref{https://github.com/google/kernel-sanitizers} for more details. |
d77de738 | 17029 | |
d77de738 | 17030 | @opindex fsanitize=hwaddress |
f33d7a88 | 17031 | @item -fsanitize=hwaddress |
d77de738 ML |
17032 | Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to |
17033 | ignore the top byte of a pointer to allow the detection of memory errors with | |
17034 | a low memory overhead. | |
17035 | Memory access instructions are instrumented to detect out-of-bounds and | |
17036 | use-after-free bugs. | |
17037 | The option enables @option{-fsanitize-address-use-after-scope}. | |
17038 | See | |
17039 | @uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html} | |
17040 | for more details. The run-time behavior can be influenced using the | |
17041 | @env{HWASAN_OPTIONS} environment variable. When set to @code{help=1}, | |
17042 | the available options are shown at startup of the instrumented program. | |
17043 | The option cannot be combined with @option{-fsanitize=thread} or | |
17044 | @option{-fsanitize=address}, and is currently only available on AArch64. | |
17045 | ||
d77de738 | 17046 | @opindex fsanitize=kernel-hwaddress |
ddf6fe37 | 17047 | @item -fsanitize=kernel-hwaddress |
d77de738 ML |
17048 | Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel. |
17049 | Similar to @option{-fsanitize=kernel-address} but using an alternate | |
17050 | instrumentation method, and similar to @option{-fsanitize=hwaddress} but with | |
17051 | instrumentation differences necessary for compiling the Linux kernel. | |
17052 | These differences are to avoid hwasan library initialization calls and to | |
17053 | account for the stack pointer having a different value in its top byte. | |
17054 | ||
17055 | @emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}. | |
17056 | Instrumenting the stack and alloca calls are not on by default but are still | |
17057 | possible by specifying the command-line options | |
17058 | @option{--param hwasan-instrument-stack=1} and | |
17059 | @option{--param hwasan-instrument-allocas=1} respectively. Using a random frame | |
17060 | tag is not implemented for kernel instrumentation. | |
17061 | ||
d77de738 | 17062 | @opindex fsanitize=pointer-compare |
ddf6fe37 | 17063 | @item -fsanitize=pointer-compare |
d77de738 ML |
17064 | Instrument comparison operation (<, <=, >, >=) with pointer operands. |
17065 | The option must be combined with either @option{-fsanitize=kernel-address} or | |
17066 | @option{-fsanitize=address} | |
17067 | The option cannot be combined with @option{-fsanitize=thread}. | |
17068 | Note: By default the check is disabled at run time. To enable it, | |
17069 | add @code{detect_invalid_pointer_pairs=2} to the environment variable | |
17070 | @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects | |
17071 | invalid operation only when both pointers are non-null. | |
17072 | ||
d77de738 | 17073 | @opindex fsanitize=pointer-subtract |
ddf6fe37 | 17074 | @item -fsanitize=pointer-subtract |
d77de738 ML |
17075 | Instrument subtraction with pointer operands. |
17076 | The option must be combined with either @option{-fsanitize=kernel-address} or | |
17077 | @option{-fsanitize=address} | |
17078 | The option cannot be combined with @option{-fsanitize=thread}. | |
17079 | Note: By default the check is disabled at run time. To enable it, | |
17080 | add @code{detect_invalid_pointer_pairs=2} to the environment variable | |
17081 | @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects | |
17082 | invalid operation only when both pointers are non-null. | |
17083 | ||
d77de738 | 17084 | @opindex fsanitize=shadow-call-stack |
ddf6fe37 | 17085 | @item -fsanitize=shadow-call-stack |
d77de738 ML |
17086 | Enable ShadowCallStack, a security enhancement mechanism used to protect |
17087 | programs against return address overwrites (e.g. stack buffer overflows.) | |
17088 | It works by saving a function's return address to a separately allocated | |
17089 | shadow call stack in the function prologue and restoring the return address | |
17090 | from the shadow call stack in the function epilogue. Instrumentation only | |
17091 | occurs in functions that need to save the return address to the stack. | |
17092 | ||
17093 | Currently it only supports the aarch64 platform. It is specifically | |
17094 | designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option. | |
17095 | For the user space programs, runtime support is not currently provided | |
17096 | in libc and libgcc. Users who want to use this feature in user space need | |
17097 | to provide their own support for the runtime. It should be noted that | |
17098 | this may cause the ABI rules to be broken. | |
17099 | ||
17100 | On aarch64, the instrumentation makes use of the platform register @code{x18}. | |
17101 | This generally means that any code that may run on the same thread as code | |
17102 | compiled with ShadowCallStack must be compiled with the flag | |
17103 | @option{-ffixed-x18}, otherwise functions compiled without | |
17104 | @option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow | |
17105 | stack pointer. | |
17106 | ||
17107 | Also, because there is no userspace runtime support, code compiled with | |
17108 | ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions} | |
17109 | to turn off exceptions. | |
17110 | ||
17111 | See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more | |
17112 | details. | |
17113 | ||
d77de738 | 17114 | @opindex fsanitize=thread |
ddf6fe37 | 17115 | @item -fsanitize=thread |
d77de738 ML |
17116 | Enable ThreadSanitizer, a fast data race detector. |
17117 | Memory access instructions are instrumented to detect | |
17118 | data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more | |
17119 | details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS} | |
17120 | environment variable; see | |
17121 | @url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of | |
17122 | supported options. | |
17123 | The option cannot be combined with @option{-fsanitize=address}, | |
17124 | @option{-fsanitize=leak}. | |
17125 | ||
17126 | Note that sanitized atomic builtins cannot throw exceptions when | |
17127 | operating on invalid memory addresses with non-call exceptions | |
17128 | (@option{-fnon-call-exceptions}). | |
17129 | ||
d77de738 | 17130 | @opindex fsanitize=leak |
ddf6fe37 | 17131 | @item -fsanitize=leak |
d77de738 | 17132 | Enable LeakSanitizer, a memory leak detector. |
c5c4fdac JG |
17133 | This option only matters for linking of executables. |
17134 | The executable is linked against a library that overrides @code{malloc} | |
d77de738 ML |
17135 | and other allocator functions. See |
17136 | @uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more | |
17137 | details. The run-time behavior can be influenced using the | |
17138 | @env{LSAN_OPTIONS} environment variable. | |
17139 | The option cannot be combined with @option{-fsanitize=thread}. | |
17140 | ||
d77de738 | 17141 | @opindex fsanitize=undefined |
ddf6fe37 | 17142 | @item -fsanitize=undefined |
d77de738 ML |
17143 | Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector. |
17144 | Various computations are instrumented to detect undefined behavior | |
17145 | at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the | |
17146 | @env{UBSAN_OPTIONS} environment variable. Current suboptions are: | |
17147 | ||
17148 | @table @gcctabopt | |
17149 | ||
d77de738 | 17150 | @opindex fsanitize=shift |
ddf6fe37 | 17151 | @item -fsanitize=shift |
d77de738 ML |
17152 | This option enables checking that the result of a shift operation is |
17153 | not undefined. Note that what exactly is considered undefined differs | |
17154 | slightly between C and C++, as well as between ISO C90 and C99, etc. | |
17155 | This option has two suboptions, @option{-fsanitize=shift-base} and | |
17156 | @option{-fsanitize=shift-exponent}. | |
17157 | ||
d77de738 | 17158 | @opindex fsanitize=shift-exponent |
ddf6fe37 | 17159 | @item -fsanitize=shift-exponent |
d77de738 ML |
17160 | This option enables checking that the second argument of a shift operation |
17161 | is not negative and is smaller than the precision of the promoted first | |
17162 | argument. | |
17163 | ||
d77de738 | 17164 | @opindex fsanitize=shift-base |
ddf6fe37 | 17165 | @item -fsanitize=shift-base |
d77de738 ML |
17166 | If the second argument of a shift operation is within range, check that the |
17167 | result of a shift operation is not undefined. Note that what exactly is | |
17168 | considered undefined differs slightly between C and C++, as well as between | |
17169 | ISO C90 and C99, etc. | |
17170 | ||
d77de738 | 17171 | @opindex fsanitize=integer-divide-by-zero |
ddf6fe37 | 17172 | @item -fsanitize=integer-divide-by-zero |
d77de738 ML |
17173 | Detect integer division by zero. |
17174 | ||
d77de738 | 17175 | @opindex fsanitize=unreachable |
ddf6fe37 | 17176 | @item -fsanitize=unreachable |
d77de738 ML |
17177 | With this option, the compiler turns the @code{__builtin_unreachable} |
17178 | call into a diagnostics message call instead. When reaching the | |
17179 | @code{__builtin_unreachable} call, the behavior is undefined. | |
17180 | ||
d77de738 | 17181 | @opindex fsanitize=vla-bound |
ddf6fe37 | 17182 | @item -fsanitize=vla-bound |
d77de738 ML |
17183 | This option instructs the compiler to check that the size of a variable |
17184 | length array is positive. | |
17185 | ||
d77de738 | 17186 | @opindex fsanitize=null |
ddf6fe37 | 17187 | @item -fsanitize=null |
d77de738 ML |
17188 | This option enables pointer checking. Particularly, the application |
17189 | built with this option turned on will issue an error message when it | |
17190 | tries to dereference a NULL pointer, or if a reference (possibly an | |
17191 | rvalue reference) is bound to a NULL pointer, or if a method is invoked | |
17192 | on an object pointed by a NULL pointer. | |
17193 | ||
d77de738 | 17194 | @opindex fsanitize=return |
ddf6fe37 | 17195 | @item -fsanitize=return |
d77de738 ML |
17196 | This option enables return statement checking. Programs |
17197 | built with this option turned on will issue an error message | |
17198 | when the end of a non-void function is reached without actually | |
17199 | returning a value. This option works in C++ only. | |
17200 | ||
d77de738 | 17201 | @opindex fsanitize=signed-integer-overflow |
ddf6fe37 | 17202 | @item -fsanitize=signed-integer-overflow |
d77de738 ML |
17203 | This option enables signed integer overflow checking. We check that |
17204 | the result of @code{+}, @code{*}, and both unary and binary @code{-} | |
17205 | does not overflow in the signed arithmetics. This also detects | |
17206 | @code{INT_MIN / -1} signed division. Note, integer promotion | |
17207 | rules must be taken into account. That is, the following is not an | |
17208 | overflow: | |
17209 | @smallexample | |
17210 | signed char a = SCHAR_MAX; | |
17211 | a++; | |
17212 | @end smallexample | |
17213 | ||
d77de738 | 17214 | @opindex fsanitize=bounds |
ddf6fe37 | 17215 | @item -fsanitize=bounds |
d77de738 ML |
17216 | This option enables instrumentation of array bounds. Various out of bounds |
17217 | accesses are detected. Flexible array members, flexible array member-like | |
c7728805 JJ |
17218 | arrays, and initializers of variables with static storage are not |
17219 | instrumented, with the exception of flexible array member-like arrays | |
17220 | for which @code{-fstrict-flex-arrays} or @code{-fstrict-flex-arrays=} | |
17221 | options or @code{strict_flex_array} attributes say they shouldn't be treated | |
17222 | like flexible array member-like arrays. | |
d77de738 | 17223 | |
d77de738 | 17224 | @opindex fsanitize=bounds-strict |
ddf6fe37 | 17225 | @item -fsanitize=bounds-strict |
d77de738 | 17226 | This option enables strict instrumentation of array bounds. Most out of bounds |
c7728805 JJ |
17227 | accesses are detected, including flexible array member-like arrays. |
17228 | Initializers of variables with static storage are not instrumented. | |
d77de738 | 17229 | |
d77de738 | 17230 | @opindex fsanitize=alignment |
ddf6fe37 | 17231 | @item -fsanitize=alignment |
d77de738 ML |
17232 | |
17233 | This option enables checking of alignment of pointers when they are | |
17234 | dereferenced, or when a reference is bound to insufficiently aligned target, | |
17235 | or when a method or constructor is invoked on insufficiently aligned object. | |
17236 | ||
d77de738 | 17237 | @opindex fsanitize=object-size |
ddf6fe37 | 17238 | @item -fsanitize=object-size |
d77de738 | 17239 | This option enables instrumentation of memory references using the |
7283380a SP |
17240 | @code{__builtin_dynamic_object_size} function. Various out of bounds |
17241 | pointer accesses are detected. | |
d77de738 | 17242 | |
d77de738 | 17243 | @opindex fsanitize=float-divide-by-zero |
ddf6fe37 | 17244 | @item -fsanitize=float-divide-by-zero |
d77de738 ML |
17245 | Detect floating-point division by zero. Unlike other similar options, |
17246 | @option{-fsanitize=float-divide-by-zero} is not enabled by | |
17247 | @option{-fsanitize=undefined}, since floating-point division by zero can | |
17248 | be a legitimate way of obtaining infinities and NaNs. | |
17249 | ||
d77de738 | 17250 | @opindex fsanitize=float-cast-overflow |
ddf6fe37 | 17251 | @item -fsanitize=float-cast-overflow |
d77de738 ML |
17252 | This option enables floating-point type to integer conversion checking. |
17253 | We check that the result of the conversion does not overflow. | |
17254 | Unlike other similar options, @option{-fsanitize=float-cast-overflow} is | |
17255 | not enabled by @option{-fsanitize=undefined}. | |
17256 | This option does not work well with @code{FE_INVALID} exceptions enabled. | |
17257 | ||
d77de738 | 17258 | @opindex fsanitize=nonnull-attribute |
ddf6fe37 | 17259 | @item -fsanitize=nonnull-attribute |
d77de738 ML |
17260 | |
17261 | This option enables instrumentation of calls, checking whether null values | |
17262 | are not passed to arguments marked as requiring a non-null value by the | |
17263 | @code{nonnull} function attribute. | |
17264 | ||
d77de738 | 17265 | @opindex fsanitize=returns-nonnull-attribute |
ddf6fe37 | 17266 | @item -fsanitize=returns-nonnull-attribute |
d77de738 ML |
17267 | |
17268 | This option enables instrumentation of return statements in functions | |
17269 | marked with @code{returns_nonnull} function attribute, to detect returning | |
17270 | of null values from such functions. | |
17271 | ||
d77de738 | 17272 | @opindex fsanitize=bool |
ddf6fe37 | 17273 | @item -fsanitize=bool |
d77de738 ML |
17274 | |
17275 | This option enables instrumentation of loads from bool. If a value other | |
17276 | than 0/1 is loaded, a run-time error is issued. | |
17277 | ||
d77de738 | 17278 | @opindex fsanitize=enum |
ddf6fe37 | 17279 | @item -fsanitize=enum |
d77de738 ML |
17280 | |
17281 | This option enables instrumentation of loads from an enum type. If | |
17282 | a value outside the range of values for the enum type is loaded, | |
17283 | a run-time error is issued. | |
17284 | ||
d77de738 | 17285 | @opindex fsanitize=vptr |
ddf6fe37 | 17286 | @item -fsanitize=vptr |
d77de738 ML |
17287 | |
17288 | This option enables instrumentation of C++ member function calls, member | |
17289 | accesses and some conversions between pointers to base and derived classes, | |
17290 | to verify the referenced object has the correct dynamic type. | |
17291 | ||
d77de738 | 17292 | @opindex fsanitize=pointer-overflow |
ddf6fe37 | 17293 | @item -fsanitize=pointer-overflow |
d77de738 ML |
17294 | |
17295 | This option enables instrumentation of pointer arithmetics. If the pointer | |
17296 | arithmetics overflows, a run-time error is issued. | |
17297 | ||
d77de738 | 17298 | @opindex fsanitize=builtin |
ddf6fe37 | 17299 | @item -fsanitize=builtin |
d77de738 ML |
17300 | |
17301 | This option enables instrumentation of arguments to selected builtin | |
17302 | functions. If an invalid value is passed to such arguments, a run-time | |
17303 | error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz} | |
17304 | or @code{__builtin_clz} invokes undefined behavior and is diagnosed | |
17305 | by this option. | |
17306 | ||
17307 | @end table | |
17308 | ||
17309 | Note that sanitizers tend to increase the rate of false positive | |
17310 | warnings, most notably those around @option{-Wmaybe-uninitialized}. | |
17311 | We recommend against combining @option{-Werror} and [the use of] | |
17312 | sanitizers. | |
17313 | ||
17314 | While @option{-ftrapv} causes traps for signed overflows to be emitted, | |
17315 | @option{-fsanitize=undefined} gives a diagnostic message. | |
17316 | This currently works only for the C family of languages. | |
17317 | ||
d77de738 | 17318 | @opindex fno-sanitize=all |
ddf6fe37 | 17319 | @item -fno-sanitize=all |
d77de738 ML |
17320 | |
17321 | This option disables all previously enabled sanitizers. | |
17322 | @option{-fsanitize=all} is not allowed, as some sanitizers cannot be used | |
17323 | together. | |
17324 | ||
d77de738 | 17325 | @opindex fasan-shadow-offset |
ddf6fe37 | 17326 | @item -fasan-shadow-offset=@var{number} |
d77de738 ML |
17327 | This option forces GCC to use custom shadow offset in AddressSanitizer checks. |
17328 | It is useful for experimenting with different shadow memory layouts in | |
17329 | Kernel AddressSanitizer. | |
17330 | ||
d77de738 | 17331 | @opindex fsanitize-sections |
ddf6fe37 | 17332 | @item -fsanitize-sections=@var{s1},@var{s2},... |
d77de738 ML |
17333 | Sanitize global variables in selected user-defined sections. @var{si} may |
17334 | contain wildcards. | |
17335 | ||
d77de738 ML |
17336 | @opindex fsanitize-recover |
17337 | @opindex fno-sanitize-recover | |
ddf6fe37 | 17338 | @item -fsanitize-recover@r{[}=@var{opts}@r{]} |
d77de738 ML |
17339 | @option{-fsanitize-recover=} controls error recovery mode for sanitizers |
17340 | mentioned in comma-separated list of @var{opts}. Enabling this option | |
17341 | for a sanitizer component causes it to attempt to continue | |
17342 | running the program as if no error happened. This means multiple | |
17343 | runtime errors can be reported in a single program run, and the exit | |
17344 | code of the program may indicate success even when errors | |
17345 | have been reported. The @option{-fno-sanitize-recover=} option | |
17346 | can be used to alter | |
17347 | this behavior: only the first detected error is reported | |
17348 | and program then exits with a non-zero exit code. | |
17349 | ||
17350 | Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions | |
17351 | except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}), | |
17352 | @option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero}, | |
17353 | @option{-fsanitize=bounds-strict}, | |
17354 | @option{-fsanitize=kernel-address} and @option{-fsanitize=address}. | |
17355 | For these sanitizers error recovery is turned on by default, | |
17356 | except @option{-fsanitize=address}, for which this feature is experimental. | |
17357 | @option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also | |
17358 | accepted, the former enables recovery for all sanitizers that support it, | |
17359 | the latter disables recovery for all sanitizers that support it. | |
17360 | ||
17361 | Even if a recovery mode is turned on the compiler side, it needs to be also | |
17362 | enabled on the runtime library side, otherwise the failures are still fatal. | |
17363 | The runtime library defaults to @code{halt_on_error=0} for | |
17364 | ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for | |
17365 | AddressSanitizer is @code{halt_on_error=1}. This can be overridden through | |
17366 | setting the @code{halt_on_error} flag in the corresponding environment variable. | |
17367 | ||
17368 | Syntax without an explicit @var{opts} parameter is deprecated. It is | |
17369 | equivalent to specifying an @var{opts} list of: | |
17370 | ||
17371 | @smallexample | |
17372 | undefined,float-cast-overflow,float-divide-by-zero,bounds-strict | |
17373 | @end smallexample | |
17374 | ||
d77de738 | 17375 | @opindex fsanitize-address-use-after-scope |
ddf6fe37 | 17376 | @item -fsanitize-address-use-after-scope |
d77de738 ML |
17377 | Enable sanitization of local variables to detect use-after-scope bugs. |
17378 | The option sets @option{-fstack-reuse} to @samp{none}. | |
17379 | ||
d77de738 ML |
17380 | @opindex fsanitize-trap |
17381 | @opindex fno-sanitize-trap | |
ddf6fe37 | 17382 | @item -fsanitize-trap@r{[}=@var{opts}@r{]} |
d77de738 ML |
17383 | The @option{-fsanitize-trap=} option instructs the compiler to |
17384 | report for sanitizers mentioned in comma-separated list of @var{opts} | |
17385 | undefined behavior using @code{__builtin_trap} rather than a @code{libubsan} | |
17386 | library routine. If this option is enabled for certain sanitizer, | |
17387 | it takes precedence over the @option{-fsanitizer-recover=} for that | |
17388 | sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless | |
17389 | of whether recovery is enabled or disabled using @option{-fsanitize-recover=}. | |
17390 | ||
17391 | The advantage of this is that the @code{libubsan} library is not needed | |
17392 | and is not linked in, so this is usable even in freestanding environments. | |
17393 | ||
17394 | Currently this feature works with @option{-fsanitize=undefined} (and its suboptions | |
17395 | except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow}, | |
17396 | @option{-fsanitize=float-divide-by-zero} and | |
17397 | @option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also | |
17398 | specified, which enables it for @code{undefined} suboptions, | |
17399 | @option{-fsanitize=float-cast-overflow}, | |
17400 | @option{-fsanitize=float-divide-by-zero} and | |
17401 | @option{-fsanitize=bounds-strict}. | |
17402 | If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used | |
17403 | and @code{-fsanitize=vptr} is enabled on the command line, the | |
17404 | instrumentation is silently ignored as the instrumentation always needs | |
17405 | @code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed. | |
17406 | ||
d77de738 | 17407 | @opindex fsanitize-undefined-trap-on-error |
ddf6fe37 | 17408 | @item -fsanitize-undefined-trap-on-error |
d77de738 ML |
17409 | The @option{-fsanitize-undefined-trap-on-error} option is deprecated |
17410 | equivalent of @option{-fsanitize-trap=all}. | |
17411 | ||
d77de738 | 17412 | @opindex fsanitize-coverage=trace-pc |
ddf6fe37 | 17413 | @item -fsanitize-coverage=trace-pc |
d77de738 ML |
17414 | Enable coverage-guided fuzzing code instrumentation. |
17415 | Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block. | |
17416 | ||
d77de738 | 17417 | @opindex fsanitize-coverage=trace-cmp |
ddf6fe37 | 17418 | @item -fsanitize-coverage=trace-cmp |
d77de738 ML |
17419 | Enable dataflow guided fuzzing code instrumentation. |
17420 | Inserts a call to @code{__sanitizer_cov_trace_cmp1}, | |
17421 | @code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or | |
17422 | @code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands | |
17423 | variable or @code{__sanitizer_cov_trace_const_cmp1}, | |
17424 | @code{__sanitizer_cov_trace_const_cmp2}, | |
17425 | @code{__sanitizer_cov_trace_const_cmp4} or | |
17426 | @code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one | |
17427 | operand constant, @code{__sanitizer_cov_trace_cmpf} or | |
17428 | @code{__sanitizer_cov_trace_cmpd} for float or double comparisons and | |
17429 | @code{__sanitizer_cov_trace_switch} for switch statements. | |
17430 | ||
d77de738 | 17431 | @opindex fcf-protection |
ddf6fe37 | 17432 | @item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]} |
d77de738 ML |
17433 | Enable code instrumentation of control-flow transfers to increase |
17434 | program security by checking that target addresses of control-flow | |
17435 | transfer instructions (such as indirect function call, function return, | |
17436 | indirect jump) are valid. This prevents diverting the flow of control | |
17437 | to an unexpected target. This is intended to protect against such | |
17438 | threats as Return-oriented Programming (ROP), and similarly | |
17439 | call/jmp-oriented programming (COP/JOP). | |
17440 | ||
17441 | The value @code{branch} tells the compiler to implement checking of | |
17442 | validity of control-flow transfer at the point of indirect branch | |
17443 | instructions, i.e.@: call/jmp instructions. The value @code{return} | |
17444 | implements checking of validity at the point of returning from a | |
17445 | function. The value @code{full} is an alias for specifying both | |
17446 | @code{branch} and @code{return}. The value @code{none} turns off | |
17447 | instrumentation. | |
17448 | ||
17449 | The value @code{check} is used for the final link with link-time | |
17450 | optimization (LTO). An error is issued if LTO object files are | |
17451 | compiled with different @option{-fcf-protection} values. The | |
17452 | value @code{check} is ignored at the compile time. | |
17453 | ||
17454 | The macro @code{__CET__} is defined when @option{-fcf-protection} is | |
17455 | used. The first bit of @code{__CET__} is set to 1 for the value | |
17456 | @code{branch} and the second bit of @code{__CET__} is set to 1 for | |
17457 | the @code{return}. | |
17458 | ||
17459 | You can also use the @code{nocf_check} attribute to identify | |
17460 | which functions and calls should be skipped from instrumentation | |
17461 | (@pxref{Function Attributes}). | |
17462 | ||
17463 | Currently the x86 GNU/Linux target provides an implementation based | |
17464 | on Intel Control-flow Enforcement Technology (CET) which works for | |
17465 | i686 processor or newer. | |
17466 | ||
d77de738 | 17467 | @opindex fharden-compares |
ddf6fe37 | 17468 | @item -fharden-compares |
d77de738 ML |
17469 | For every logical test that survives gimple optimizations and is |
17470 | @emph{not} the condition in a conditional branch (for example, | |
17471 | conditions tested for conditional moves, or to store in boolean | |
17472 | variables), emit extra code to compute and verify the reversed | |
17473 | condition, and to call @code{__builtin_trap} if the results do not | |
17474 | match. Use with @samp{-fharden-conditional-branches} to cover all | |
17475 | conditionals. | |
17476 | ||
d77de738 | 17477 | @opindex fharden-conditional-branches |
ddf6fe37 | 17478 | @item -fharden-conditional-branches |
d77de738 ML |
17479 | For every non-vectorized conditional branch that survives gimple |
17480 | optimizations, emit extra code to compute and verify the reversed | |
17481 | condition, and to call @code{__builtin_trap} if the result is | |
17482 | unexpected. Use with @samp{-fharden-compares} to cover all | |
17483 | conditionals. | |
17484 | ||
551935d1 AO |
17485 | @opindex fharden-control-flow-redundancy |
17486 | @item -fharden-control-flow-redundancy | |
17487 | Emit extra code to set booleans when entering basic blocks, and to | |
17488 | verify and trap, at function exits, when the booleans do not form an | |
17489 | execution path that is compatible with the control flow graph. | |
17490 | ||
17491 | Verification takes place before returns, before mandatory tail calls | |
17492 | (see below) and, optionally, before escaping exceptions with | |
17493 | @option{-fhardcfr-check-exceptions}, before returning calls with | |
17494 | @option{-fhardcfr-check-returning-calls}, and before noreturn calls with | |
17495 | @option{-fhardcfr-check-noreturn-calls}). Tuning options | |
17496 | @option{--param hardcfr-max-blocks} and @option{--param | |
17497 | hardcfr-max-inline-blocks} are available. | |
17498 | ||
17499 | Tail call optimization takes place too late to affect control flow | |
17500 | redundancy, but calls annotated as mandatory tail calls by language | |
17501 | front-ends, and any calls marked early enough as potential tail calls | |
17502 | would also have verification issued before the call, but these | |
17503 | possibilities are merely theoretical, as these conditions can only be | |
17504 | met when using custom compiler plugins. | |
17505 | ||
17506 | @opindex fhardcfr-skip-leaf | |
17507 | @item -fhardcfr-skip-leaf | |
17508 | Disable @option{-fharden-control-flow-redundancy} in leaf functions. | |
17509 | ||
17510 | @opindex fhardcfr-check-exceptions | |
17511 | @opindex fno-hardcfr-check-exceptions | |
17512 | @item -fhardcfr-check-exceptions | |
17513 | When @option{-fharden-control-flow-redundancy} is active, check the | |
17514 | recorded execution path against the control flow graph at exception | |
17515 | escape points, as if the function body was wrapped with a cleanup | |
17516 | handler that performed the check and reraised. This option is enabled | |
17517 | by default; use @option{-fno-hardcfr-check-exceptions} to disable it. | |
17518 | ||
17519 | @opindex fhardcfr-check-returning-calls | |
17520 | @opindex fno-hardcfr-check-returning-calls | |
17521 | @item -fhardcfr-check-returning-calls | |
17522 | When @option{-fharden-control-flow-redundancy} is active, check the | |
17523 | recorded execution path against the control flow graph before any | |
17524 | function call immediately followed by a return of its result, if any, so | |
17525 | as to not prevent tail-call optimization, whether or not it is | |
17526 | ultimately optimized to a tail call. | |
17527 | ||
17528 | This option is enabled by default whenever sibling call optimizations | |
17529 | are enabled (see @option{-foptimize-sibling-calls}), but it can be | |
17530 | enabled (or disabled, using its negated form) explicitly, regardless of | |
17531 | the optimizations. | |
17532 | ||
17533 | @opindex fhardcfr-check-noreturn-calls | |
17534 | @item -fhardcfr-check-noreturn-calls=@r{[}always@r{|}no-xthrow@r{|}nothrow@r{|}never@r{]} | |
17535 | When @option{-fharden-control-flow-redundancy} is active, check the | |
17536 | recorded execution path against the control flow graph before | |
17537 | @code{noreturn} calls, either all of them (@option{always}), those that | |
17538 | aren't expected to return control to the caller through an exception | |
17539 | (@option{no-xthrow}, the default), those that may not return control to | |
17540 | the caller through an exception either (@option{nothrow}), or none of | |
17541 | them (@option{never}). | |
17542 | ||
17543 | Checking before a @code{noreturn} function that may return control to | |
17544 | the caller through an exception may cause checking to be performed more | |
17545 | than once, if the exception is caught in the caller, whether by a | |
17546 | handler or a cleanup. When @option{-fhardcfr-check-exceptions} is also | |
17547 | enabled, the compiler will avoid associating a @code{noreturn} call with | |
17548 | the implicitly-added cleanup handler, since it would be redundant with | |
17549 | the check performed before the call, but other handlers or cleanups in | |
17550 | the function, if activated, will modify the recorded execution path and | |
17551 | check it again when another checkpoint is hit. The checkpoint may even | |
17552 | be another @code{noreturn} call, so checking may end up performed | |
17553 | multiple times. | |
17554 | ||
17555 | Various optimizers may cause calls to be marked as @code{noreturn} | |
17556 | and/or @code{nothrow}, even in the absence of the corresponding | |
17557 | attributes, which may affect the placement of checks before calls, as | |
17558 | well as the addition of implicit cleanup handlers for them. This | |
17559 | unpredictability, and the fact that raising and reraising exceptions | |
17560 | frequently amounts to implicitly calling @code{noreturn} functions, have | |
17561 | made @option{no-xthrow} the default setting for this option: it excludes | |
17562 | from the @code{noreturn} treatment only internal functions used to | |
17563 | (re)raise exceptions, that are not affected by these optimizations. | |
17564 | ||
d77de738 | 17565 | @opindex fstack-protector |
ddf6fe37 | 17566 | @item -fstack-protector |
d77de738 ML |
17567 | Emit extra code to check for buffer overflows, such as stack smashing |
17568 | attacks. This is done by adding a guard variable to functions with | |
17569 | vulnerable objects. This includes functions that call @code{alloca}, and | |
17570 | functions with buffers larger than or equal to 8 bytes. The guards are | |
17571 | initialized when a function is entered and then checked when the function | |
17572 | exits. If a guard check fails, an error message is printed and the program | |
17573 | exits. Only variables that are actually allocated on the stack are | |
17574 | considered, optimized away variables or variables allocated in registers | |
17575 | don't count. | |
17576 | ||
d77de738 | 17577 | @opindex fstack-protector-all |
ddf6fe37 | 17578 | @item -fstack-protector-all |
d77de738 ML |
17579 | Like @option{-fstack-protector} except that all functions are protected. |
17580 | ||
d77de738 | 17581 | @opindex fstack-protector-strong |
ddf6fe37 | 17582 | @item -fstack-protector-strong |
d77de738 ML |
17583 | Like @option{-fstack-protector} but includes additional functions to |
17584 | be protected --- those that have local array definitions, or have | |
17585 | references to local frame addresses. Only variables that are actually | |
17586 | allocated on the stack are considered, optimized away variables or variables | |
17587 | allocated in registers don't count. | |
17588 | ||
d77de738 | 17589 | @opindex fstack-protector-explicit |
ddf6fe37 | 17590 | @item -fstack-protector-explicit |
d77de738 ML |
17591 | Like @option{-fstack-protector} but only protects those functions which |
17592 | have the @code{stack_protect} attribute. | |
17593 | ||
d77de738 | 17594 | @opindex fstack-check |
ddf6fe37 | 17595 | @item -fstack-check |
d77de738 ML |
17596 | Generate code to verify that you do not go beyond the boundary of the |
17597 | stack. You should specify this flag if you are running in an | |
17598 | environment with multiple threads, but you only rarely need to specify it in | |
17599 | a single-threaded environment since stack overflow is automatically | |
17600 | detected on nearly all systems if there is only one stack. | |
17601 | ||
17602 | Note that this switch does not actually cause checking to be done; the | |
17603 | operating system or the language runtime must do that. The switch causes | |
17604 | generation of code to ensure that they see the stack being extended. | |
17605 | ||
17606 | You can additionally specify a string parameter: @samp{no} means no | |
17607 | checking, @samp{generic} means force the use of old-style checking, | |
17608 | @samp{specific} means use the best checking method and is equivalent | |
17609 | to bare @option{-fstack-check}. | |
17610 | ||
17611 | Old-style checking is a generic mechanism that requires no specific | |
17612 | target support in the compiler but comes with the following drawbacks: | |
17613 | ||
17614 | @enumerate | |
17615 | @item | |
17616 | Modified allocation strategy for large objects: they are always | |
17617 | allocated dynamically if their size exceeds a fixed threshold. Note this | |
17618 | may change the semantics of some code. | |
17619 | ||
17620 | @item | |
17621 | Fixed limit on the size of the static frame of functions: when it is | |
17622 | topped by a particular function, stack checking is not reliable and | |
17623 | a warning is issued by the compiler. | |
17624 | ||
17625 | @item | |
17626 | Inefficiency: because of both the modified allocation strategy and the | |
17627 | generic implementation, code performance is hampered. | |
17628 | @end enumerate | |
17629 | ||
17630 | Note that old-style stack checking is also the fallback method for | |
17631 | @samp{specific} if no target support has been added in the compiler. | |
17632 | ||
17633 | @samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion | |
17634 | and stack overflows. @samp{specific} is an excellent choice when compiling | |
17635 | Ada code. It is not generally sufficient to protect against stack-clash | |
17636 | attacks. To protect against those you want @samp{-fstack-clash-protection}. | |
17637 | ||
d77de738 | 17638 | @opindex fstack-clash-protection |
ddf6fe37 | 17639 | @item -fstack-clash-protection |
d77de738 ML |
17640 | Generate code to prevent stack clash style attacks. When this option is |
17641 | enabled, the compiler will only allocate one page of stack space at a time | |
17642 | and each page is accessed immediately after allocation. Thus, it prevents | |
17643 | allocations from jumping over any stack guard page provided by the | |
17644 | operating system. | |
17645 | ||
17646 | Most targets do not fully support stack clash protection. However, on | |
17647 | those targets @option{-fstack-clash-protection} will protect dynamic stack | |
17648 | allocations. @option{-fstack-clash-protection} may also provide limited | |
17649 | protection for static stack allocations if the target supports | |
17650 | @option{-fstack-check=specific}. | |
17651 | ||
d77de738 ML |
17652 | @opindex fstack-limit-register |
17653 | @opindex fstack-limit-symbol | |
17654 | @opindex fno-stack-limit | |
ddf6fe37 AA |
17655 | @item -fstack-limit-register=@var{reg} |
17656 | @itemx -fstack-limit-symbol=@var{sym} | |
17657 | @itemx -fno-stack-limit | |
d77de738 ML |
17658 | Generate code to ensure that the stack does not grow beyond a certain value, |
17659 | either the value of a register or the address of a symbol. If a larger | |
17660 | stack is required, a signal is raised at run time. For most targets, | |
17661 | the signal is raised before the stack overruns the boundary, so | |
17662 | it is possible to catch the signal without taking special precautions. | |
17663 | ||
17664 | For instance, if the stack starts at absolute address @samp{0x80000000} | |
17665 | and grows downwards, you can use the flags | |
17666 | @option{-fstack-limit-symbol=__stack_limit} and | |
17667 | @option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit | |
17668 | of 128KB@. Note that this may only work with the GNU linker. | |
17669 | ||
17670 | You can locally override stack limit checking by using the | |
17671 | @code{no_stack_limit} function attribute (@pxref{Function Attributes}). | |
17672 | ||
d77de738 | 17673 | @opindex fsplit-stack |
ddf6fe37 | 17674 | @item -fsplit-stack |
d77de738 ML |
17675 | Generate code to automatically split the stack before it overflows. |
17676 | The resulting program has a discontiguous stack which can only | |
17677 | overflow if the program is unable to allocate any more memory. This | |
17678 | is most useful when running threaded programs, as it is no longer | |
17679 | necessary to calculate a good stack size to use for each thread. This | |
17680 | is currently only implemented for the x86 targets running | |
17681 | GNU/Linux. | |
17682 | ||
17683 | When code compiled with @option{-fsplit-stack} calls code compiled | |
17684 | without @option{-fsplit-stack}, there may not be much stack space | |
17685 | available for the latter code to run. If compiling all code, | |
17686 | including library code, with @option{-fsplit-stack} is not an option, | |
17687 | then the linker can fix up these calls so that the code compiled | |
17688 | without @option{-fsplit-stack} always has a large stack. Support for | |
17689 | this is implemented in the gold linker in GNU binutils release 2.21 | |
17690 | and later. | |
17691 | ||
d77de738 | 17692 | @opindex fvtable-verify |
ddf6fe37 | 17693 | @item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} |
d77de738 ML |
17694 | This option is only available when compiling C++ code. |
17695 | It turns on (or off, if using @option{-fvtable-verify=none}) the security | |
17696 | feature that verifies at run time, for every virtual call, that | |
17697 | the vtable pointer through which the call is made is valid for the type of | |
17698 | the object, and has not been corrupted or overwritten. If an invalid vtable | |
17699 | pointer is detected at run time, an error is reported and execution of the | |
17700 | program is immediately halted. | |
17701 | ||
17702 | This option causes run-time data structures to be built at program startup, | |
17703 | which are used for verifying the vtable pointers. | |
17704 | The options @samp{std} and @samp{preinit} | |
17705 | control the timing of when these data structures are built. In both cases the | |
17706 | data structures are built before execution reaches @code{main}. Using | |
17707 | @option{-fvtable-verify=std} causes the data structures to be built after | |
17708 | shared libraries have been loaded and initialized. | |
17709 | @option{-fvtable-verify=preinit} causes them to be built before shared | |
17710 | libraries have been loaded and initialized. | |
17711 | ||
17712 | If this option appears multiple times in the command line with different | |
17713 | values specified, @samp{none} takes highest priority over both @samp{std} and | |
17714 | @samp{preinit}; @samp{preinit} takes priority over @samp{std}. | |
17715 | ||
d77de738 | 17716 | @opindex fvtv-debug |
ddf6fe37 | 17717 | @item -fvtv-debug |
d77de738 ML |
17718 | When used in conjunction with @option{-fvtable-verify=std} or |
17719 | @option{-fvtable-verify=preinit}, causes debug versions of the | |
17720 | runtime functions for the vtable verification feature to be called. | |
17721 | This flag also causes the compiler to log information about which | |
17722 | vtable pointers it finds for each class. | |
17723 | This information is written to a file named @file{vtv_set_ptr_data.log} | |
17724 | in the directory named by the environment variable @env{VTV_LOGS_DIR} | |
17725 | if that is defined or the current working directory otherwise. | |
17726 | ||
17727 | Note: This feature @emph{appends} data to the log file. If you want a fresh log | |
17728 | file, be sure to delete any existing one. | |
17729 | ||
d77de738 | 17730 | @opindex fvtv-counts |
ddf6fe37 | 17731 | @item -fvtv-counts |
d77de738 ML |
17732 | This is a debugging flag. When used in conjunction with |
17733 | @option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this | |
17734 | causes the compiler to keep track of the total number of virtual calls | |
17735 | it encounters and the number of verifications it inserts. It also | |
17736 | counts the number of calls to certain run-time library functions | |
17737 | that it inserts and logs this information for each compilation unit. | |
17738 | The compiler writes this information to a file named | |
17739 | @file{vtv_count_data.log} in the directory named by the environment | |
17740 | variable @env{VTV_LOGS_DIR} if that is defined or the current working | |
17741 | directory otherwise. It also counts the size of the vtable pointer sets | |
17742 | for each class, and writes this information to @file{vtv_class_set_sizes.log} | |
17743 | in the same directory. | |
17744 | ||
17745 | Note: This feature @emph{appends} data to the log files. To get fresh log | |
17746 | files, be sure to delete any existing ones. | |
17747 | ||
d77de738 | 17748 | @opindex finstrument-functions |
ddf6fe37 | 17749 | @item -finstrument-functions |
d77de738 ML |
17750 | Generate instrumentation calls for entry and exit to functions. Just |
17751 | after function entry and just before function exit, the following | |
17752 | profiling functions are called with the address of the current | |
17753 | function and its call site. (On some platforms, | |
17754 | @code{__builtin_return_address} does not work beyond the current | |
17755 | function, so the call site information may not be available to the | |
17756 | profiling functions otherwise.) | |
17757 | ||
17758 | @smallexample | |
17759 | void __cyg_profile_func_enter (void *this_fn, | |
17760 | void *call_site); | |
17761 | void __cyg_profile_func_exit (void *this_fn, | |
17762 | void *call_site); | |
17763 | @end smallexample | |
17764 | ||
17765 | The first argument is the address of the start of the current function, | |
17766 | which may be looked up exactly in the symbol table. | |
17767 | ||
17768 | This instrumentation is also done for functions expanded inline in other | |
17769 | functions. The profiling calls indicate where, conceptually, the | |
17770 | inline function is entered and exited. This means that addressable | |
17771 | versions of such functions must be available. If all your uses of a | |
17772 | function are expanded inline, this may mean an additional expansion of | |
17773 | code size. If you use @code{extern inline} in your C code, an | |
17774 | addressable version of such functions must be provided. (This is | |
17775 | normally the case anyway, but if you get lucky and the optimizer always | |
17776 | expands the functions inline, you might have gotten away without | |
17777 | providing static copies.) | |
17778 | ||
17779 | A function may be given the attribute @code{no_instrument_function}, in | |
17780 | which case this instrumentation is not done. This can be used, for | |
17781 | example, for the profiling functions listed above, high-priority | |
17782 | interrupt routines, and any functions from which the profiling functions | |
17783 | cannot safely be called (perhaps signal handlers, if the profiling | |
17784 | routines generate output or allocate memory). | |
17785 | @xref{Common Function Attributes}. | |
17786 | ||
9c19597c | 17787 | @opindex finstrument-functions-once |
ddf6fe37 | 17788 | @item -finstrument-functions-once |
d77de738 ML |
17789 | This is similar to @option{-finstrument-functions}, but the profiling |
17790 | functions are called only once per instrumented function, i.e. the first | |
17791 | profiling function is called after the first entry into the instrumented | |
17792 | function and the second profiling function is called before the exit | |
17793 | corresponding to this first entry. | |
17794 | ||
17795 | The definition of @code{once} for the purpose of this option is a little | |
17796 | vague because the implementation is not protected against data races. | |
17797 | As a result, the implementation only guarantees that the profiling | |
17798 | functions are called at @emph{least} once per process and at @emph{most} | |
17799 | once per thread, but the calls are always paired, that is to say, if a | |
17800 | thread calls the first function, then it will call the second function, | |
17801 | unless it never reaches the exit of the instrumented function. | |
17802 | ||
d77de738 | 17803 | @opindex finstrument-functions-exclude-file-list |
ddf6fe37 | 17804 | @item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{} |
d77de738 ML |
17805 | |
17806 | Set the list of functions that are excluded from instrumentation (see | |
17807 | the description of @option{-finstrument-functions}). If the file that | |
17808 | contains a function definition matches with one of @var{file}, then | |
17809 | that function is not instrumented. The match is done on substrings: | |
17810 | if the @var{file} parameter is a substring of the file name, it is | |
17811 | considered to be a match. | |
17812 | ||
17813 | For example: | |
17814 | ||
17815 | @smallexample | |
17816 | -finstrument-functions-exclude-file-list=/bits/stl,include/sys | |
17817 | @end smallexample | |
17818 | ||
17819 | @noindent | |
17820 | excludes any inline function defined in files whose pathnames | |
17821 | contain @file{/bits/stl} or @file{include/sys}. | |
17822 | ||
17823 | If, for some reason, you want to include letter @samp{,} in one of | |
17824 | @var{sym}, write @samp{\,}. For example, | |
17825 | @option{-finstrument-functions-exclude-file-list='\,\,tmp'} | |
17826 | (note the single quote surrounding the option). | |
17827 | ||
d77de738 | 17828 | @opindex finstrument-functions-exclude-function-list |
ddf6fe37 | 17829 | @item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} |
d77de738 ML |
17830 | |
17831 | This is similar to @option{-finstrument-functions-exclude-file-list}, | |
17832 | but this option sets the list of function names to be excluded from | |
17833 | instrumentation. The function name to be matched is its user-visible | |
17834 | name, such as @code{vector<int> blah(const vector<int> &)}, not the | |
17835 | internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The | |
17836 | match is done on substrings: if the @var{sym} parameter is a substring | |
17837 | of the function name, it is considered to be a match. For C99 and C++ | |
17838 | extended identifiers, the function name must be given in UTF-8, not | |
17839 | using universal character names. | |
17840 | ||
d77de738 | 17841 | @opindex fpatchable-function-entry |
ddf6fe37 | 17842 | @item -fpatchable-function-entry=@var{N}[,@var{M}] |
d77de738 ML |
17843 | Generate @var{N} NOPs right at the beginning |
17844 | of each function, with the function entry point before the @var{M}th NOP. | |
17845 | If @var{M} is omitted, it defaults to @code{0} so the | |
17846 | function entry points to the address just at the first NOP. | |
17847 | The NOP instructions reserve extra space which can be used to patch in | |
17848 | any desired instrumentation at run time, provided that the code segment | |
17849 | is writable. The amount of space is controllable indirectly via | |
17850 | the number of NOPs; the NOP instruction used corresponds to the instruction | |
17851 | emitted by the internal GCC back-end interface @code{gen_nop}. This behavior | |
17852 | is target-specific and may also depend on the architecture variant and/or | |
17853 | other compilation options. | |
17854 | ||
17855 | For run-time identification, the starting addresses of these areas, | |
17856 | which correspond to their respective function entries minus @var{M}, | |
17857 | are additionally collected in the @code{__patchable_function_entries} | |
17858 | section of the resulting binary. | |
17859 | ||
17860 | Note that the value of @code{__attribute__ ((patchable_function_entry | |
17861 | (N,M)))} takes precedence over command-line option | |
17862 | @option{-fpatchable-function-entry=N,M}. This can be used to increase | |
17863 | the area size or to remove it completely on a single function. | |
17864 | If @code{N=0}, no pad location is recorded. | |
17865 | ||
17866 | The NOP instructions are inserted at---and maybe before, depending on | |
17867 | @var{M}---the function entry address, even before the prologue. On | |
17868 | PowerPC with the ELFv2 ABI, for a function with dual entry points, | |
17869 | the local entry point is this function entry address. | |
17870 | ||
17871 | The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the | |
17872 | ELFv2 ABI, for a function with dual entry points, the supported values | |
17873 | for @var{M} are 0, 2, 6 and 14. | |
17874 | @end table | |
17875 | ||
17876 | ||
17877 | @node Preprocessor Options | |
17878 | @section Options Controlling the Preprocessor | |
17879 | @cindex preprocessor options | |
17880 | @cindex options, preprocessor | |
17881 | ||
17882 | These options control the C preprocessor, which is run on each C source | |
17883 | file before actual compilation. | |
17884 | ||
17885 | If you use the @option{-E} option, nothing is done except preprocessing. | |
17886 | Some of these options make sense only together with @option{-E} because | |
17887 | they cause the preprocessor output to be unsuitable for actual | |
17888 | compilation. | |
17889 | ||
17890 | In addition to the options listed here, there are a number of options | |
17891 | to control search paths for include files documented in | |
17892 | @ref{Directory Options}. | |
17893 | Options to control preprocessor diagnostics are listed in | |
17894 | @ref{Warning Options}. | |
17895 | ||
17896 | @table @gcctabopt | |
17897 | @include cppopts.texi | |
17898 | ||
d77de738 | 17899 | @opindex Wp |
ddf6fe37 | 17900 | @item -Wp,@var{option} |
d77de738 ML |
17901 | You can use @option{-Wp,@var{option}} to bypass the compiler driver |
17902 | and pass @var{option} directly through to the preprocessor. If | |
17903 | @var{option} contains commas, it is split into multiple options at the | |
17904 | commas. However, many options are modified, translated or interpreted | |
17905 | by the compiler driver before being passed to the preprocessor, and | |
17906 | @option{-Wp} forcibly bypasses this phase. The preprocessor's direct | |
17907 | interface is undocumented and subject to change, so whenever possible | |
17908 | you should avoid using @option{-Wp} and let the driver handle the | |
17909 | options instead. | |
17910 | ||
d77de738 | 17911 | @opindex Xpreprocessor |
ddf6fe37 | 17912 | @item -Xpreprocessor @var{option} |
d77de738 ML |
17913 | Pass @var{option} as an option to the preprocessor. You can use this to |
17914 | supply system-specific preprocessor options that GCC does not | |
17915 | recognize. | |
17916 | ||
17917 | If you want to pass an option that takes an argument, you must use | |
17918 | @option{-Xpreprocessor} twice, once for the option and once for the argument. | |
17919 | ||
d77de738 | 17920 | @opindex no-integrated-cpp |
ddf6fe37 | 17921 | @item -no-integrated-cpp |
d77de738 ML |
17922 | Perform preprocessing as a separate pass before compilation. |
17923 | By default, GCC performs preprocessing as an integrated part of | |
17924 | input tokenization and parsing. | |
17925 | If this option is provided, the appropriate language front end | |
17926 | (@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++, | |
17927 | and Objective-C, respectively) is instead invoked twice, | |
17928 | once for preprocessing only and once for actual compilation | |
17929 | of the preprocessed input. | |
17930 | This option may be useful in conjunction with the @option{-B} or | |
17931 | @option{-wrapper} options to specify an alternate preprocessor or | |
17932 | perform additional processing of the program source between | |
17933 | normal preprocessing and compilation. | |
17934 | ||
d77de738 | 17935 | @opindex flarge-source-files |
ddf6fe37 | 17936 | @item -flarge-source-files |
d77de738 ML |
17937 | Adjust GCC to expect large source files, at the expense of slower |
17938 | compilation and higher memory usage. | |
17939 | ||
17940 | Specifically, GCC normally tracks both column numbers and line numbers | |
17941 | within source files and it normally prints both of these numbers in | |
17942 | diagnostics. However, once it has processed a certain number of source | |
17943 | lines, it stops tracking column numbers and only tracks line numbers. | |
17944 | This means that diagnostics for later lines do not include column numbers. | |
17945 | It also means that options like @option{-Wmisleading-indentation} cease to work | |
17946 | at that point, although the compiler prints a note if this happens. | |
17947 | Passing @option{-flarge-source-files} significantly increases the number | |
17948 | of source lines that GCC can process before it stops tracking columns. | |
17949 | ||
17950 | @end table | |
17951 | ||
17952 | @node Assembler Options | |
17953 | @section Passing Options to the Assembler | |
17954 | ||
17955 | @c prevent bad page break with this line | |
17956 | You can pass options to the assembler. | |
17957 | ||
17958 | @table @gcctabopt | |
d77de738 | 17959 | @opindex Wa |
ddf6fe37 | 17960 | @item -Wa,@var{option} |
d77de738 ML |
17961 | Pass @var{option} as an option to the assembler. If @var{option} |
17962 | contains commas, it is split into multiple options at the commas. | |
17963 | ||
d77de738 | 17964 | @opindex Xassembler |
ddf6fe37 | 17965 | @item -Xassembler @var{option} |
d77de738 ML |
17966 | Pass @var{option} as an option to the assembler. You can use this to |
17967 | supply system-specific assembler options that GCC does not | |
17968 | recognize. | |
17969 | ||
17970 | If you want to pass an option that takes an argument, you must use | |
17971 | @option{-Xassembler} twice, once for the option and once for the argument. | |
17972 | ||
17973 | @end table | |
17974 | ||
17975 | @node Link Options | |
17976 | @section Options for Linking | |
17977 | @cindex link options | |
17978 | @cindex options, linking | |
17979 | ||
17980 | These options come into play when the compiler links object files into | |
17981 | an executable output file. They are meaningless if the compiler is | |
17982 | not doing a link step. | |
17983 | ||
17984 | @table @gcctabopt | |
17985 | @cindex file names | |
17986 | @item @var{object-file-name} | |
17987 | A file name that does not end in a special recognized suffix is | |
17988 | considered to name an object file or library. (Object files are | |
17989 | distinguished from libraries by the linker according to the file | |
17990 | contents.) If linking is done, these object files are used as input | |
17991 | to the linker. | |
17992 | ||
d77de738 ML |
17993 | @opindex c |
17994 | @opindex S | |
17995 | @opindex E | |
ddf6fe37 AA |
17996 | @item -c |
17997 | @itemx -S | |
17998 | @itemx -E | |
d77de738 ML |
17999 | If any of these options is used, then the linker is not run, and |
18000 | object file names should not be used as arguments. @xref{Overall | |
18001 | Options}. | |
18002 | ||
d77de738 | 18003 | @opindex flinker-output |
ddf6fe37 | 18004 | @item -flinker-output=@var{type} |
d77de738 ML |
18005 | This option controls code generation of the link-time optimizer. By |
18006 | default the linker output is automatically determined by the linker | |
18007 | plugin. For debugging the compiler and if incremental linking with a | |
18008 | non-LTO object file is desired, it may be useful to control the type | |
18009 | manually. | |
18010 | ||
18011 | If @var{type} is @samp{exec}, code generation produces a static | |
18012 | binary. In this case @option{-fpic} and @option{-fpie} are both | |
18013 | disabled. | |
18014 | ||
18015 | If @var{type} is @samp{dyn}, code generation produces a shared | |
18016 | library. In this case @option{-fpic} or @option{-fPIC} is preserved, | |
18017 | but not enabled automatically. This allows to build shared libraries | |
18018 | without position-independent code on architectures where this is | |
18019 | possible, i.e.@: on x86. | |
18020 | ||
18021 | If @var{type} is @samp{pie}, code generation produces an @option{-fpie} | |
18022 | executable. This results in similar optimizations as @samp{exec} | |
18023 | except that @option{-fpie} is not disabled if specified at compilation | |
18024 | time. | |
18025 | ||
18026 | If @var{type} is @samp{rel}, the compiler assumes that incremental linking is | |
18027 | done. The sections containing intermediate code for link-time optimization are | |
18028 | merged, pre-optimized, and output to the resulting object file. In addition, if | |
18029 | @option{-ffat-lto-objects} is specified, binary code is produced for future | |
18030 | non-LTO linking. The object file produced by incremental linking is smaller | |
18031 | than a static library produced from the same object files. At link time the | |
18032 | result of incremental linking also loads faster than a static | |
18033 | library assuming that the majority of objects in the library are used. | |
18034 | ||
18035 | Finally @samp{nolto-rel} configures the compiler for incremental linking where | |
18036 | code generation is forced, a final binary is produced, and the intermediate | |
18037 | code for later link-time optimization is stripped. When multiple object files | |
18038 | are linked together the resulting code is better optimized than with | |
18039 | link-time optimizations disabled (for example, cross-module inlining | |
18040 | happens), but most of benefits of whole program optimizations are lost. | |
18041 | ||
18042 | During the incremental link (by @option{-r}) the linker plugin defaults to | |
18043 | @option{rel}. With current interfaces to GNU Binutils it is however not | |
18044 | possible to incrementally link LTO objects and non-LTO objects into a single | |
18045 | mixed object file. If any of object files in incremental link cannot | |
18046 | be used for link-time optimization, the linker plugin issues a warning and | |
18047 | uses @samp{nolto-rel}. To maintain whole program optimization, it is | |
18048 | recommended to link such objects into static library instead. Alternatively it | |
18049 | is possible to use H.J. Lu's binutils with support for mixed objects. | |
18050 | ||
d77de738 | 18051 | @opindex fuse-ld=bfd |
ddf6fe37 | 18052 | @item -fuse-ld=bfd |
d77de738 ML |
18053 | Use the @command{bfd} linker instead of the default linker. |
18054 | ||
d77de738 | 18055 | @opindex fuse-ld=gold |
ddf6fe37 | 18056 | @item -fuse-ld=gold |
d77de738 ML |
18057 | Use the @command{gold} linker instead of the default linker. |
18058 | ||
d77de738 | 18059 | @opindex fuse-ld=lld |
ddf6fe37 | 18060 | @item -fuse-ld=lld |
d77de738 ML |
18061 | Use the LLVM @command{lld} linker instead of the default linker. |
18062 | ||
d77de738 | 18063 | @opindex fuse-ld=mold |
ddf6fe37 | 18064 | @item -fuse-ld=mold |
d77de738 ML |
18065 | Use the Modern Linker (@command{mold}) instead of the default linker. |
18066 | ||
18067 | @cindex Libraries | |
ddf6fe37 | 18068 | @opindex l |
d77de738 ML |
18069 | @item -l@var{library} |
18070 | @itemx -l @var{library} | |
d77de738 ML |
18071 | Search the library named @var{library} when linking. (The second |
18072 | alternative with the library as a separate argument is only for | |
18073 | POSIX compliance and is not recommended.) | |
18074 | ||
18075 | The @option{-l} option is passed directly to the linker by GCC. Refer | |
18076 | to your linker documentation for exact details. The general | |
18077 | description below applies to the GNU linker. | |
18078 | ||
18079 | The linker searches a standard list of directories for the library. | |
18080 | The directories searched include several standard system directories | |
18081 | plus any that you specify with @option{-L}. | |
18082 | ||
18083 | Static libraries are archives of object files, and have file names | |
18084 | like @file{lib@var{library}.a}. Some targets also support shared | |
18085 | libraries, which typically have names like @file{lib@var{library}.so}. | |
18086 | If both static and shared libraries are found, the linker gives | |
18087 | preference to linking with the shared library unless the | |
18088 | @option{-static} option is used. | |
18089 | ||
18090 | It makes a difference where in the command you write this option; the | |
18091 | linker searches and processes libraries and object files in the order they | |
18092 | are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z} | |
18093 | after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers | |
18094 | to functions in @samp{z}, those functions may not be loaded. | |
18095 | ||
d77de738 | 18096 | @opindex lobjc |
ddf6fe37 | 18097 | @item -lobjc |
d77de738 ML |
18098 | You need this special case of the @option{-l} option in order to |
18099 | link an Objective-C or Objective-C++ program. | |
18100 | ||
d77de738 | 18101 | @opindex nostartfiles |
ddf6fe37 | 18102 | @item -nostartfiles |
d77de738 ML |
18103 | Do not use the standard system startup files when linking. |
18104 | The standard system libraries are used normally, unless @option{-nostdlib}, | |
18105 | @option{-nolibc}, or @option{-nodefaultlibs} is used. | |
18106 | ||
d77de738 | 18107 | @opindex nodefaultlibs |
ddf6fe37 | 18108 | @item -nodefaultlibs |
d77de738 ML |
18109 | Do not use the standard system libraries when linking. |
18110 | Only the libraries you specify are passed to the linker, and options | |
18111 | specifying linkage of the system libraries, such as @option{-static-libgcc} | |
18112 | or @option{-shared-libgcc}, are ignored. | |
18113 | The standard startup files are used normally, unless @option{-nostartfiles} | |
18114 | is used. | |
18115 | ||
18116 | The compiler may generate calls to @code{memcmp}, | |
18117 | @code{memset}, @code{memcpy} and @code{memmove}. | |
18118 | These entries are usually resolved by entries in | |
18119 | libc. These entry points should be supplied through some other | |
18120 | mechanism when this option is specified. | |
18121 | ||
d77de738 | 18122 | @opindex nolibc |
ddf6fe37 | 18123 | @item -nolibc |
d77de738 ML |
18124 | Do not use the C library or system libraries tightly coupled with it when |
18125 | linking. Still link with the startup files, @file{libgcc} or toolchain | |
18126 | provided language support libraries such as @file{libgnat}, @file{libgfortran} | |
18127 | or @file{libstdc++} unless options preventing their inclusion are used as | |
18128 | well. This typically removes @option{-lc} from the link command line, as well | |
18129 | as system libraries that normally go with it and become meaningless when | |
18130 | absence of a C library is assumed, for example @option{-lpthread} or | |
18131 | @option{-lm} in some configurations. This is intended for bare-board | |
18132 | targets when there is indeed no C library available. | |
18133 | ||
d77de738 | 18134 | @opindex nostdlib |
ddf6fe37 | 18135 | @item -nostdlib |
d77de738 ML |
18136 | Do not use the standard system startup files or libraries when linking. |
18137 | No startup files and only the libraries you specify are passed to | |
18138 | the linker, and options specifying linkage of the system libraries, such as | |
18139 | @option{-static-libgcc} or @option{-shared-libgcc}, are ignored. | |
18140 | ||
18141 | The compiler may generate calls to @code{memcmp}, @code{memset}, | |
18142 | @code{memcpy} and @code{memmove}. | |
18143 | These entries are usually resolved by entries in | |
18144 | libc. These entry points should be supplied through some other | |
18145 | mechanism when this option is specified. | |
18146 | ||
18147 | @cindex @option{-lgcc}, use with @option{-nostdlib} | |
18148 | @cindex @option{-nostdlib} and unresolved references | |
18149 | @cindex unresolved references and @option{-nostdlib} | |
18150 | @cindex @option{-lgcc}, use with @option{-nodefaultlibs} | |
18151 | @cindex @option{-nodefaultlibs} and unresolved references | |
18152 | @cindex unresolved references and @option{-nodefaultlibs} | |
18153 | One of the standard libraries bypassed by @option{-nostdlib} and | |
18154 | @option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines | |
18155 | which GCC uses to overcome shortcomings of particular machines, or special | |
18156 | needs for some languages. | |
18157 | (@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler | |
18158 | Collection (GCC) Internals}, | |
18159 | for more discussion of @file{libgcc.a}.) | |
18160 | In most cases, you need @file{libgcc.a} even when you want to avoid | |
18161 | other standard libraries. In other words, when you specify @option{-nostdlib} | |
18162 | or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well. | |
18163 | This ensures that you have no unresolved references to internal GCC | |
18164 | library subroutines. | |
18165 | (An example of such an internal subroutine is @code{__main}, used to ensure C++ | |
18166 | constructors are called; @pxref{Collect2,,@code{collect2}, gccint, | |
18167 | GNU Compiler Collection (GCC) Internals}.) | |
18168 | ||
d77de738 | 18169 | @opindex nostdlib++ |
ddf6fe37 | 18170 | @item -nostdlib++ |
d77de738 ML |
18171 | Do not implicitly link with standard C++ libraries. |
18172 | ||
d77de738 ML |
18173 | @opindex e |
18174 | @opindex entry | |
ddf6fe37 AA |
18175 | @item -e @var{entry} |
18176 | @itemx --entry=@var{entry} | |
d77de738 ML |
18177 | |
18178 | Specify that the program entry point is @var{entry}. The argument is | |
18179 | interpreted by the linker; the GNU linker accepts either a symbol name | |
18180 | or an address. | |
18181 | ||
d77de738 | 18182 | @opindex pie |
ddf6fe37 | 18183 | @item -pie |
d77de738 ML |
18184 | Produce a dynamically linked position independent executable on targets |
18185 | that support it. For predictable results, you must also specify the same | |
18186 | set of options used for compilation (@option{-fpie}, @option{-fPIE}, | |
18187 | or model suboptions) when you specify this linker option. | |
18188 | ||
d77de738 | 18189 | @opindex no-pie |
ddf6fe37 | 18190 | @item -no-pie |
d77de738 ML |
18191 | Don't produce a dynamically linked position independent executable. |
18192 | ||
d77de738 | 18193 | @opindex static-pie |
ddf6fe37 | 18194 | @item -static-pie |
d77de738 ML |
18195 | Produce a static position independent executable on targets that support |
18196 | it. A static position independent executable is similar to a static | |
18197 | executable, but can be loaded at any address without a dynamic linker. | |
18198 | For predictable results, you must also specify the same set of options | |
18199 | used for compilation (@option{-fpie}, @option{-fPIE}, or model | |
18200 | suboptions) when you specify this linker option. | |
18201 | ||
d77de738 | 18202 | @opindex pthread |
ddf6fe37 | 18203 | @item -pthread |
d77de738 ML |
18204 | Link with the POSIX threads library. This option is supported on |
18205 | GNU/Linux targets, most other Unix derivatives, and also on | |
18206 | x86 Cygwin and MinGW targets. On some targets this option also sets | |
18207 | flags for the preprocessor, so it should be used consistently for both | |
18208 | compilation and linking. | |
18209 | ||
d77de738 | 18210 | @opindex r |
ddf6fe37 | 18211 | @item -r |
d77de738 ML |
18212 | Produce a relocatable object as output. This is also known as partial |
18213 | linking. | |
18214 | ||
d77de738 | 18215 | @opindex rdynamic |
ddf6fe37 | 18216 | @item -rdynamic |
d77de738 ML |
18217 | Pass the flag @option{-export-dynamic} to the ELF linker, on targets |
18218 | that support it. This instructs the linker to add all symbols, not | |
18219 | only used ones, to the dynamic symbol table. This option is needed | |
18220 | for some uses of @code{dlopen} or to allow obtaining backtraces | |
18221 | from within a program. | |
18222 | ||
d77de738 | 18223 | @opindex s |
ddf6fe37 | 18224 | @item -s |
d77de738 ML |
18225 | Remove all symbol table and relocation information from the executable. |
18226 | ||
d77de738 | 18227 | @opindex static |
ddf6fe37 | 18228 | @item -static |
d77de738 ML |
18229 | On systems that support dynamic linking, this overrides @option{-pie} |
18230 | and prevents linking with the shared libraries. On other systems, this | |
18231 | option has no effect. | |
18232 | ||
d77de738 | 18233 | @opindex shared |
ddf6fe37 | 18234 | @item -shared |
d77de738 ML |
18235 | Produce a shared object which can then be linked with other objects to |
18236 | form an executable. Not all systems support this option. For predictable | |
18237 | results, you must also specify the same set of options used for compilation | |
18238 | (@option{-fpic}, @option{-fPIC}, or model suboptions) when | |
18239 | you specify this linker option.@footnote{On some systems, @samp{gcc -shared} | |
18240 | needs to build supplementary stub code for constructors to work. On | |
18241 | multi-libbed systems, @samp{gcc -shared} must select the correct support | |
18242 | libraries to link against. Failing to supply the correct flags may lead | |
18243 | to subtle defects. Supplying them in cases where they are not necessary | |
b799acef RB |
18244 | is innocuous. @option{-shared} suppresses the addition of startup code |
18245 | to alter the floating-point environment as done with @option{-ffast-math}, | |
18246 | @option{-Ofast} or @option{-funsafe-math-optimizations} on some targets.} | |
d77de738 | 18247 | |
d77de738 ML |
18248 | @opindex shared-libgcc |
18249 | @opindex static-libgcc | |
ddf6fe37 AA |
18250 | @item -shared-libgcc |
18251 | @itemx -static-libgcc | |
d77de738 ML |
18252 | On systems that provide @file{libgcc} as a shared library, these options |
18253 | force the use of either the shared or static version, respectively. | |
18254 | If no shared version of @file{libgcc} was built when the compiler was | |
18255 | configured, these options have no effect. | |
18256 | ||
18257 | There are several situations in which an application should use the | |
18258 | shared @file{libgcc} instead of the static version. The most common | |
18259 | of these is when the application wishes to throw and catch exceptions | |
18260 | across different shared libraries. In that case, each of the libraries | |
18261 | as well as the application itself should use the shared @file{libgcc}. | |
18262 | ||
18263 | Therefore, the G++ driver automatically adds @option{-shared-libgcc} | |
18264 | whenever you build a shared library or a main executable, because C++ | |
18265 | programs typically use exceptions, so this is the right thing to do. | |
18266 | ||
18267 | If, instead, you use the GCC driver to create shared libraries, you may | |
18268 | find that they are not always linked with the shared @file{libgcc}. | |
18269 | If GCC finds, at its configuration time, that you have a non-GNU linker | |
18270 | or a GNU linker that does not support option @option{--eh-frame-hdr}, | |
18271 | it links the shared version of @file{libgcc} into shared libraries | |
18272 | by default. Otherwise, it takes advantage of the linker and optimizes | |
18273 | away the linking with the shared version of @file{libgcc}, linking with | |
18274 | the static version of libgcc by default. This allows exceptions to | |
18275 | propagate through such shared libraries, without incurring relocation | |
18276 | costs at library load time. | |
18277 | ||
18278 | However, if a library or main executable is supposed to throw or catch | |
18279 | exceptions, you must link it using the G++ driver, or using the option | |
18280 | @option{-shared-libgcc}, such that it is linked with the shared | |
18281 | @file{libgcc}. | |
18282 | ||
d77de738 | 18283 | @opindex static-libasan |
ddf6fe37 | 18284 | @item -static-libasan |
d77de738 ML |
18285 | When the @option{-fsanitize=address} option is used to link a program, |
18286 | the GCC driver automatically links against @option{libasan}. If | |
18287 | @file{libasan} is available as a shared library, and the @option{-static} | |
18288 | option is not used, then this links against the shared version of | |
18289 | @file{libasan}. The @option{-static-libasan} option directs the GCC | |
18290 | driver to link @file{libasan} statically, without necessarily linking | |
18291 | other libraries statically. | |
18292 | ||
d77de738 | 18293 | @opindex static-libtsan |
ddf6fe37 | 18294 | @item -static-libtsan |
d77de738 ML |
18295 | When the @option{-fsanitize=thread} option is used to link a program, |
18296 | the GCC driver automatically links against @option{libtsan}. If | |
18297 | @file{libtsan} is available as a shared library, and the @option{-static} | |
18298 | option is not used, then this links against the shared version of | |
18299 | @file{libtsan}. The @option{-static-libtsan} option directs the GCC | |
18300 | driver to link @file{libtsan} statically, without necessarily linking | |
18301 | other libraries statically. | |
18302 | ||
d77de738 | 18303 | @opindex static-liblsan |
ddf6fe37 | 18304 | @item -static-liblsan |
d77de738 ML |
18305 | When the @option{-fsanitize=leak} option is used to link a program, |
18306 | the GCC driver automatically links against @option{liblsan}. If | |
18307 | @file{liblsan} is available as a shared library, and the @option{-static} | |
18308 | option is not used, then this links against the shared version of | |
18309 | @file{liblsan}. The @option{-static-liblsan} option directs the GCC | |
18310 | driver to link @file{liblsan} statically, without necessarily linking | |
18311 | other libraries statically. | |
18312 | ||
d77de738 | 18313 | @opindex static-libubsan |
ddf6fe37 | 18314 | @item -static-libubsan |
d77de738 ML |
18315 | When the @option{-fsanitize=undefined} option is used to link a program, |
18316 | the GCC driver automatically links against @option{libubsan}. If | |
18317 | @file{libubsan} is available as a shared library, and the @option{-static} | |
18318 | option is not used, then this links against the shared version of | |
18319 | @file{libubsan}. The @option{-static-libubsan} option directs the GCC | |
18320 | driver to link @file{libubsan} statically, without necessarily linking | |
18321 | other libraries statically. | |
18322 | ||
d77de738 | 18323 | @opindex static-libstdc++ |
ddf6fe37 | 18324 | @item -static-libstdc++ |
d77de738 ML |
18325 | When the @command{g++} program is used to link a C++ program, it |
18326 | normally automatically links against @option{libstdc++}. If | |
18327 | @file{libstdc++} is available as a shared library, and the | |
18328 | @option{-static} option is not used, then this links against the | |
18329 | shared version of @file{libstdc++}. That is normally fine. However, it | |
18330 | is sometimes useful to freeze the version of @file{libstdc++} used by | |
18331 | the program without going all the way to a fully static link. The | |
18332 | @option{-static-libstdc++} option directs the @command{g++} driver to | |
18333 | link @file{libstdc++} statically, without necessarily linking other | |
18334 | libraries statically. | |
18335 | ||
d77de738 | 18336 | @opindex symbolic |
ddf6fe37 | 18337 | @item -symbolic |
d77de738 ML |
18338 | Bind references to global symbols when building a shared object. Warn |
18339 | about any unresolved references (unless overridden by the link editor | |
18340 | option @option{-Xlinker -z -Xlinker defs}). Only a few systems support | |
18341 | this option. | |
18342 | ||
d77de738 ML |
18343 | @opindex T |
18344 | @cindex linker script | |
f33d7a88 | 18345 | @item -T @var{script} |
d77de738 ML |
18346 | Use @var{script} as the linker script. This option is supported by most |
18347 | systems using the GNU linker. On some targets, such as bare-board | |
18348 | targets without an operating system, the @option{-T} option may be required | |
18349 | when linking to avoid references to undefined symbols. | |
18350 | ||
d77de738 | 18351 | @opindex Xlinker |
ddf6fe37 | 18352 | @item -Xlinker @var{option} |
d77de738 ML |
18353 | Pass @var{option} as an option to the linker. You can use this to |
18354 | supply system-specific linker options that GCC does not recognize. | |
18355 | ||
18356 | If you want to pass an option that takes a separate argument, you must use | |
18357 | @option{-Xlinker} twice, once for the option and once for the argument. | |
18358 | For example, to pass @option{-assert definitions}, you must write | |
18359 | @option{-Xlinker -assert -Xlinker definitions}. It does not work to write | |
18360 | @option{-Xlinker "-assert definitions"}, because this passes the entire | |
18361 | string as a single argument, which is not what the linker expects. | |
18362 | ||
18363 | When using the GNU linker, it is usually more convenient to pass | |
18364 | arguments to linker options using the @option{@var{option}=@var{value}} | |
18365 | syntax than as separate arguments. For example, you can specify | |
18366 | @option{-Xlinker -Map=output.map} rather than | |
18367 | @option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support | |
18368 | this syntax for command-line options. | |
18369 | ||
d77de738 | 18370 | @opindex Wl |
ddf6fe37 | 18371 | @item -Wl,@var{option} |
d77de738 ML |
18372 | Pass @var{option} as an option to the linker. If @var{option} contains |
18373 | commas, it is split into multiple options at the commas. You can use this | |
18374 | syntax to pass an argument to the option. | |
18375 | For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the | |
18376 | linker. When using the GNU linker, you can also get the same effect with | |
18377 | @option{-Wl,-Map=output.map}. | |
18378 | ||
d77de738 | 18379 | @opindex u |
ddf6fe37 | 18380 | @item -u @var{symbol} |
d77de738 ML |
18381 | Pretend the symbol @var{symbol} is undefined, to force linking of |
18382 | library modules to define it. You can use @option{-u} multiple times with | |
18383 | different symbols to force loading of additional library modules. | |
18384 | ||
d77de738 | 18385 | @opindex z |
ddf6fe37 | 18386 | @item -z @var{keyword} |
d77de738 ML |
18387 | @option{-z} is passed directly on to the linker along with the keyword |
18388 | @var{keyword}. See the section in the documentation of your linker for | |
18389 | permitted values and their meanings. | |
18390 | @end table | |
18391 | ||
18392 | @node Directory Options | |
18393 | @section Options for Directory Search | |
18394 | @cindex directory options | |
18395 | @cindex options, directory search | |
18396 | @cindex search path | |
18397 | ||
18398 | These options specify directories to search for header files, for | |
18399 | libraries and for parts of the compiler: | |
18400 | ||
18401 | @table @gcctabopt | |
18402 | @include cppdiropts.texi | |
18403 | ||
d77de738 | 18404 | @opindex iplugindir= |
ddf6fe37 | 18405 | @item -iplugindir=@var{dir} |
d77de738 ML |
18406 | Set the directory to search for plugins that are passed |
18407 | by @option{-fplugin=@var{name}} instead of | |
18408 | @option{-fplugin=@var{path}/@var{name}.so}. This option is not meant | |
18409 | to be used by the user, but only passed by the driver. | |
18410 | ||
d77de738 | 18411 | @opindex L |
ddf6fe37 | 18412 | @item -L@var{dir} |
d77de738 ML |
18413 | Add directory @var{dir} to the list of directories to be searched |
18414 | for @option{-l}. | |
18415 | ||
d77de738 | 18416 | @opindex B |
ddf6fe37 | 18417 | @item -B@var{prefix} |
d77de738 ML |
18418 | This option specifies where to find the executables, libraries, |
18419 | include files, and data files of the compiler itself. | |
18420 | ||
18421 | The compiler driver program runs one or more of the subprograms | |
18422 | @command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries | |
18423 | @var{prefix} as a prefix for each program it tries to run, both with and | |
18424 | without @samp{@var{machine}/@var{version}/} for the corresponding target | |
18425 | machine and compiler version. | |
18426 | ||
18427 | For each subprogram to be run, the compiler driver first tries the | |
18428 | @option{-B} prefix, if any. If that name is not found, or if @option{-B} | |
18429 | is not specified, the driver tries two standard prefixes, | |
18430 | @file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of | |
18431 | those results in a file name that is found, the unmodified program | |
18432 | name is searched for using the directories specified in your | |
18433 | @env{PATH} environment variable. | |
18434 | ||
18435 | The compiler checks to see if the path provided by @option{-B} | |
18436 | refers to a directory, and if necessary it adds a directory | |
18437 | separator character at the end of the path. | |
18438 | ||
18439 | @option{-B} prefixes that effectively specify directory names also apply | |
18440 | to libraries in the linker, because the compiler translates these | |
18441 | options into @option{-L} options for the linker. They also apply to | |
18442 | include files in the preprocessor, because the compiler translates these | |
18443 | options into @option{-isystem} options for the preprocessor. In this case, | |
18444 | the compiler appends @samp{include} to the prefix. | |
18445 | ||
18446 | The runtime support file @file{libgcc.a} can also be searched for using | |
18447 | the @option{-B} prefix, if needed. If it is not found there, the two | |
18448 | standard prefixes above are tried, and that is all. The file is left | |
18449 | out of the link if it is not found by those means. | |
18450 | ||
18451 | Another way to specify a prefix much like the @option{-B} prefix is to use | |
18452 | the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment | |
18453 | Variables}. | |
18454 | ||
18455 | As a special kludge, if the path provided by @option{-B} is | |
18456 | @file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to | |
18457 | 9, then it is replaced by @file{[dir/]include}. This is to help | |
18458 | with boot-strapping the compiler. | |
18459 | ||
d77de738 | 18460 | @opindex no-canonical-prefixes |
ddf6fe37 | 18461 | @item -no-canonical-prefixes |
d77de738 ML |
18462 | Do not expand any symbolic links, resolve references to @samp{/../} |
18463 | or @samp{/./}, or make the path absolute when generating a relative | |
18464 | prefix. | |
18465 | ||
d77de738 | 18466 | @opindex sysroot |
ddf6fe37 | 18467 | @item --sysroot=@var{dir} |
d77de738 ML |
18468 | Use @var{dir} as the logical root directory for headers and libraries. |
18469 | For example, if the compiler normally searches for headers in | |
18470 | @file{/usr/include} and libraries in @file{/usr/lib}, it instead | |
18471 | searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}. | |
18472 | ||
18473 | If you use both this option and the @option{-isysroot} option, then | |
18474 | the @option{--sysroot} option applies to libraries, but the | |
18475 | @option{-isysroot} option applies to header files. | |
18476 | ||
18477 | The GNU linker (beginning with version 2.16) has the necessary support | |
18478 | for this option. If your linker does not support this option, the | |
18479 | header file aspect of @option{--sysroot} still works, but the | |
18480 | library aspect does not. | |
18481 | ||
d77de738 | 18482 | @opindex no-sysroot-suffix |
ddf6fe37 | 18483 | @item --no-sysroot-suffix |
d77de738 ML |
18484 | For some targets, a suffix is added to the root directory specified |
18485 | with @option{--sysroot}, depending on the other options used, so that | |
18486 | headers may for example be found in | |
18487 | @file{@var{dir}/@var{suffix}/usr/include} instead of | |
18488 | @file{@var{dir}/usr/include}. This option disables the addition of | |
18489 | such a suffix. | |
18490 | ||
18491 | @end table | |
18492 | ||
18493 | @node Code Gen Options | |
18494 | @section Options for Code Generation Conventions | |
18495 | @cindex code generation conventions | |
18496 | @cindex options, code generation | |
18497 | @cindex run-time options | |
18498 | ||
18499 | These machine-independent options control the interface conventions | |
18500 | used in code generation. | |
18501 | ||
18502 | Most of them have both positive and negative forms; the negative form | |
18503 | of @option{-ffoo} is @option{-fno-foo}. In the table below, only | |
18504 | one of the forms is listed---the one that is not the default. You | |
18505 | can figure out the other form by either removing @samp{no-} or adding | |
18506 | it. | |
18507 | ||
18508 | @table @gcctabopt | |
d77de738 | 18509 | @opindex fstack_reuse |
ddf6fe37 | 18510 | @item -fstack-reuse=@var{reuse-level} |
d77de738 ML |
18511 | This option controls stack space reuse for user declared local/auto variables |
18512 | and compiler generated temporaries. @var{reuse_level} can be @samp{all}, | |
18513 | @samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all | |
18514 | local variables and temporaries, @samp{named_vars} enables the reuse only for | |
18515 | user defined local variables with names, and @samp{none} disables stack reuse | |
18516 | completely. The default value is @samp{all}. The option is needed when the | |
18517 | program extends the lifetime of a scoped local variable or a compiler generated | |
18518 | temporary beyond the end point defined by the language. When a lifetime of | |
18519 | a variable ends, and if the variable lives in memory, the optimizing compiler | |
18520 | has the freedom to reuse its stack space with other temporaries or scoped | |
18521 | local variables whose live range does not overlap with it. Legacy code extending | |
18522 | local lifetime is likely to break with the stack reuse optimization. | |
18523 | ||
18524 | For example, | |
18525 | ||
18526 | @smallexample | |
18527 | int *p; | |
18528 | @{ | |
18529 | int local1; | |
18530 | ||
18531 | p = &local1; | |
18532 | local1 = 10; | |
18533 | .... | |
18534 | @} | |
18535 | @{ | |
18536 | int local2; | |
18537 | local2 = 20; | |
18538 | ... | |
18539 | @} | |
18540 | ||
18541 | if (*p == 10) // out of scope use of local1 | |
18542 | @{ | |
18543 | ||
18544 | @} | |
18545 | @end smallexample | |
18546 | ||
18547 | Another example: | |
18548 | @smallexample | |
18549 | ||
18550 | struct A | |
18551 | @{ | |
18552 | A(int k) : i(k), j(k) @{ @} | |
18553 | int i; | |
18554 | int j; | |
18555 | @}; | |
18556 | ||
18557 | A *ap; | |
18558 | ||
18559 | void foo(const A& ar) | |
18560 | @{ | |
18561 | ap = &ar; | |
18562 | @} | |
18563 | ||
18564 | void bar() | |
18565 | @{ | |
18566 | foo(A(10)); // temp object's lifetime ends when foo returns | |
18567 | ||
18568 | @{ | |
18569 | A a(20); | |
18570 | .... | |
18571 | @} | |
18572 | ap->i+= 10; // ap references out of scope temp whose space | |
18573 | // is reused with a. What is the value of ap->i? | |
18574 | @} | |
18575 | ||
18576 | @end smallexample | |
18577 | ||
18578 | The lifetime of a compiler generated temporary is well defined by the C++ | |
18579 | standard. When a lifetime of a temporary ends, and if the temporary lives | |
18580 | in memory, the optimizing compiler has the freedom to reuse its stack | |
18581 | space with other temporaries or scoped local variables whose live range | |
18582 | does not overlap with it. However some of the legacy code relies on | |
18583 | the behavior of older compilers in which temporaries' stack space is | |
18584 | not reused, the aggressive stack reuse can lead to runtime errors. This | |
18585 | option is used to control the temporary stack reuse optimization. | |
18586 | ||
d77de738 | 18587 | @opindex ftrapv |
ddf6fe37 | 18588 | @item -ftrapv |
d77de738 ML |
18589 | This option generates traps for signed overflow on addition, subtraction, |
18590 | multiplication operations. | |
18591 | The options @option{-ftrapv} and @option{-fwrapv} override each other, so using | |
18592 | @option{-ftrapv} @option{-fwrapv} on the command-line results in | |
18593 | @option{-fwrapv} being effective. Note that only active options override, so | |
18594 | using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line | |
18595 | results in @option{-ftrapv} being effective. | |
18596 | ||
d77de738 | 18597 | @opindex fwrapv |
ddf6fe37 | 18598 | @item -fwrapv |
d77de738 ML |
18599 | This option instructs the compiler to assume that signed arithmetic |
18600 | overflow of addition, subtraction and multiplication wraps around | |
18601 | using twos-complement representation. This flag enables some optimizations | |
18602 | and disables others. | |
18603 | The options @option{-ftrapv} and @option{-fwrapv} override each other, so using | |
18604 | @option{-ftrapv} @option{-fwrapv} on the command-line results in | |
18605 | @option{-fwrapv} being effective. Note that only active options override, so | |
18606 | using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line | |
18607 | results in @option{-ftrapv} being effective. | |
18608 | ||
d77de738 | 18609 | @opindex fwrapv-pointer |
ddf6fe37 | 18610 | @item -fwrapv-pointer |
d77de738 ML |
18611 | This option instructs the compiler to assume that pointer arithmetic |
18612 | overflow on addition and subtraction wraps around using twos-complement | |
18613 | representation. This flag disables some optimizations which assume | |
18614 | pointer overflow is invalid. | |
18615 | ||
d77de738 | 18616 | @opindex fstrict-overflow |
ddf6fe37 | 18617 | @item -fstrict-overflow |
d77de738 ML |
18618 | This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when |
18619 | negated implies @option{-fwrapv} @option{-fwrapv-pointer}. | |
18620 | ||
d77de738 | 18621 | @opindex fexceptions |
ddf6fe37 | 18622 | @item -fexceptions |
d77de738 ML |
18623 | Enable exception handling. Generates extra code needed to propagate |
18624 | exceptions. For some targets, this implies GCC generates frame | |
18625 | unwind information for all functions, which can produce significant data | |
18626 | size overhead, although it does not affect execution. If you do not | |
18627 | specify this option, GCC enables it by default for languages like | |
18628 | C++ that normally require exception handling, and disables it for | |
18629 | languages like C that do not normally require it. However, you may need | |
18630 | to enable this option when compiling C code that needs to interoperate | |
18631 | properly with exception handlers written in C++. You may also wish to | |
18632 | disable this option if you are compiling older C++ programs that don't | |
18633 | use exception handling. | |
18634 | ||
d77de738 | 18635 | @opindex fnon-call-exceptions |
ddf6fe37 | 18636 | @item -fnon-call-exceptions |
d77de738 ML |
18637 | Generate code that allows trapping instructions to throw exceptions. |
18638 | Note that this requires platform-specific runtime support that does | |
18639 | not exist everywhere. Moreover, it only allows @emph{trapping} | |
18640 | instructions to throw exceptions, i.e.@: memory references or floating-point | |
18641 | instructions. It does not allow exceptions to be thrown from | |
18642 | arbitrary signal handlers such as @code{SIGALRM}. This enables | |
18643 | @option{-fexceptions}. | |
18644 | ||
d77de738 | 18645 | @opindex fdelete-dead-exceptions |
ddf6fe37 | 18646 | @item -fdelete-dead-exceptions |
d77de738 ML |
18647 | Consider that instructions that may throw exceptions but don't otherwise |
18648 | contribute to the execution of the program can be optimized away. | |
18649 | This does not affect calls to functions except those with the | |
18650 | @code{pure} or @code{const} attributes. | |
18651 | This option is enabled by default for the Ada and C++ compilers, as permitted by | |
18652 | the language specifications. | |
18653 | Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels. | |
18654 | ||
d77de738 | 18655 | @opindex funwind-tables |
ddf6fe37 | 18656 | @item -funwind-tables |
d77de738 ML |
18657 | Similar to @option{-fexceptions}, except that it just generates any needed |
18658 | static data, but does not affect the generated code in any other way. | |
18659 | You normally do not need to enable this option; instead, a language processor | |
18660 | that needs this handling enables it on your behalf. | |
18661 | ||
d77de738 | 18662 | @opindex fasynchronous-unwind-tables |
ddf6fe37 | 18663 | @item -fasynchronous-unwind-tables |
d77de738 ML |
18664 | Generate unwind table in DWARF format, if supported by target machine. The |
18665 | table is exact at each instruction boundary, so it can be used for stack | |
18666 | unwinding from asynchronous events (such as debugger or garbage collector). | |
18667 | ||
d77de738 ML |
18668 | @opindex fno-gnu-unique |
18669 | @opindex fgnu-unique | |
ddf6fe37 | 18670 | @item -fno-gnu-unique |
d77de738 ML |
18671 | On systems with recent GNU assembler and C library, the C++ compiler |
18672 | uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions | |
18673 | of template static data members and static local variables in inline | |
18674 | functions are unique even in the presence of @code{RTLD_LOCAL}; this | |
18675 | is necessary to avoid problems with a library used by two different | |
18676 | @code{RTLD_LOCAL} plugins depending on a definition in one of them and | |
18677 | therefore disagreeing with the other one about the binding of the | |
18678 | symbol. But this causes @code{dlclose} to be ignored for affected | |
18679 | DSOs; if your program relies on reinitialization of a DSO via | |
18680 | @code{dlclose} and @code{dlopen}, you can use | |
18681 | @option{-fno-gnu-unique}. | |
18682 | ||
d77de738 | 18683 | @opindex fpcc-struct-return |
ddf6fe37 | 18684 | @item -fpcc-struct-return |
d77de738 ML |
18685 | Return ``short'' @code{struct} and @code{union} values in memory like |
18686 | longer ones, rather than in registers. This convention is less | |
18687 | efficient, but it has the advantage of allowing intercallability between | |
18688 | GCC-compiled files and files compiled with other compilers, particularly | |
18689 | the Portable C Compiler (pcc). | |
18690 | ||
18691 | The precise convention for returning structures in memory depends | |
18692 | on the target configuration macros. | |
18693 | ||
18694 | Short structures and unions are those whose size and alignment match | |
18695 | that of some integer type. | |
18696 | ||
18697 | @strong{Warning:} code compiled with the @option{-fpcc-struct-return} | |
18698 | switch is not binary compatible with code compiled with the | |
18699 | @option{-freg-struct-return} switch. | |
18700 | Use it to conform to a non-default application binary interface. | |
18701 | ||
d77de738 | 18702 | @opindex freg-struct-return |
ddf6fe37 | 18703 | @item -freg-struct-return |
d77de738 ML |
18704 | Return @code{struct} and @code{union} values in registers when possible. |
18705 | This is more efficient for small structures than | |
18706 | @option{-fpcc-struct-return}. | |
18707 | ||
18708 | If you specify neither @option{-fpcc-struct-return} nor | |
18709 | @option{-freg-struct-return}, GCC defaults to whichever convention is | |
18710 | standard for the target. If there is no standard convention, GCC | |
18711 | defaults to @option{-fpcc-struct-return}, except on targets where GCC is | |
18712 | the principal compiler. In those cases, we can choose the standard, and | |
18713 | we chose the more efficient register return alternative. | |
18714 | ||
18715 | @strong{Warning:} code compiled with the @option{-freg-struct-return} | |
18716 | switch is not binary compatible with code compiled with the | |
18717 | @option{-fpcc-struct-return} switch. | |
18718 | Use it to conform to a non-default application binary interface. | |
18719 | ||
d77de738 | 18720 | @opindex fshort-enums |
ddf6fe37 | 18721 | @item -fshort-enums |
d77de738 ML |
18722 | Allocate to an @code{enum} type only as many bytes as it needs for the |
18723 | declared range of possible values. Specifically, the @code{enum} type | |
18724 | is equivalent to the smallest integer type that has enough room. | |
d8a656d5 JW |
18725 | This option has no effect for an enumeration type with a fixed underlying |
18726 | type. | |
d77de738 ML |
18727 | |
18728 | @strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate | |
18729 | code that is not binary compatible with code generated without that switch. | |
18730 | Use it to conform to a non-default application binary interface. | |
18731 | ||
d77de738 | 18732 | @opindex fshort-wchar |
ddf6fe37 | 18733 | @item -fshort-wchar |
d77de738 ML |
18734 | Override the underlying type for @code{wchar_t} to be @code{short |
18735 | unsigned int} instead of the default for the target. This option is | |
18736 | useful for building programs to run under WINE@. | |
18737 | ||
18738 | @strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate | |
18739 | code that is not binary compatible with code generated without that switch. | |
18740 | Use it to conform to a non-default application binary interface. | |
18741 | ||
d77de738 ML |
18742 | @opindex fcommon |
18743 | @opindex fno-common | |
18744 | @cindex tentative definitions | |
f33d7a88 | 18745 | @item -fcommon |
d77de738 ML |
18746 | In C code, this option controls the placement of global variables |
18747 | defined without an initializer, known as @dfn{tentative definitions} | |
18748 | in the C standard. Tentative definitions are distinct from declarations | |
18749 | of a variable with the @code{extern} keyword, which do not allocate storage. | |
18750 | ||
18751 | The default is @option{-fno-common}, which specifies that the compiler places | |
18752 | uninitialized global variables in the BSS section of the object file. | |
18753 | This inhibits the merging of tentative definitions by the linker so you get a | |
18754 | multiple-definition error if the same variable is accidentally defined in more | |
18755 | than one compilation unit. | |
18756 | ||
18757 | The @option{-fcommon} places uninitialized global variables in a common block. | |
18758 | This allows the linker to resolve all tentative definitions of the same variable | |
18759 | in different compilation units to the same object, or to a non-tentative | |
18760 | definition. This behavior is inconsistent with C++, and on many targets implies | |
18761 | a speed and code size penalty on global variable references. It is mainly | |
18762 | useful to enable legacy code to link without errors. | |
18763 | ||
d77de738 ML |
18764 | @opindex fno-ident |
18765 | @opindex fident | |
ddf6fe37 | 18766 | @item -fno-ident |
d77de738 ML |
18767 | Ignore the @code{#ident} directive. |
18768 | ||
d77de738 | 18769 | @opindex finhibit-size-directive |
ddf6fe37 | 18770 | @item -finhibit-size-directive |
d77de738 ML |
18771 | Don't output a @code{.size} assembler directive, or anything else that |
18772 | would cause trouble if the function is split in the middle, and the | |
18773 | two halves are placed at locations far apart in memory. This option is | |
18774 | used when compiling @file{crtstuff.c}; you should not need to use it | |
18775 | for anything else. | |
18776 | ||
d77de738 | 18777 | @opindex fverbose-asm |
ddf6fe37 | 18778 | @item -fverbose-asm |
d77de738 ML |
18779 | Put extra commentary information in the generated assembly code to |
18780 | make it more readable. This option is generally only of use to those | |
18781 | who actually need to read the generated assembly code (perhaps while | |
18782 | debugging the compiler itself). | |
18783 | ||
18784 | @option{-fno-verbose-asm}, the default, causes the | |
18785 | extra information to be omitted and is useful when comparing two assembler | |
18786 | files. | |
18787 | ||
18788 | The added comments include: | |
18789 | ||
18790 | @itemize @bullet | |
18791 | ||
18792 | @item | |
18793 | information on the compiler version and command-line options, | |
18794 | ||
18795 | @item | |
18796 | the source code lines associated with the assembly instructions, | |
18797 | in the form FILENAME:LINENUMBER:CONTENT OF LINE, | |
18798 | ||
18799 | @item | |
18800 | hints on which high-level expressions correspond to | |
18801 | the various assembly instruction operands. | |
18802 | ||
18803 | @end itemize | |
18804 | ||
18805 | For example, given this C source file: | |
18806 | ||
18807 | @smallexample | |
18808 | int test (int n) | |
18809 | @{ | |
18810 | int i; | |
18811 | int total = 0; | |
18812 | ||
18813 | for (i = 0; i < n; i++) | |
18814 | total += i * i; | |
18815 | ||
18816 | return total; | |
18817 | @} | |
18818 | @end smallexample | |
18819 | ||
18820 | compiling to (x86_64) assembly via @option{-S} and emitting the result | |
18821 | direct to stdout via @option{-o} @option{-} | |
18822 | ||
18823 | @smallexample | |
18824 | gcc -S test.c -fverbose-asm -Os -o - | |
18825 | @end smallexample | |
18826 | ||
18827 | gives output similar to this: | |
18828 | ||
18829 | @smallexample | |
18830 | .file "test.c" | |
18831 | # GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu) | |
18832 | [...snip...] | |
18833 | # options passed: | |
18834 | [...snip...] | |
18835 | ||
18836 | .text | |
18837 | .globl test | |
18838 | .type test, @@function | |
18839 | test: | |
18840 | .LFB0: | |
18841 | .cfi_startproc | |
18842 | # test.c:4: int total = 0; | |
18843 | xorl %eax, %eax # <retval> | |
18844 | # test.c:6: for (i = 0; i < n; i++) | |
18845 | xorl %edx, %edx # i | |
18846 | .L2: | |
18847 | # test.c:6: for (i = 0; i < n; i++) | |
18848 | cmpl %edi, %edx # n, i | |
18849 | jge .L5 #, | |
18850 | # test.c:7: total += i * i; | |
18851 | movl %edx, %ecx # i, tmp92 | |
18852 | imull %edx, %ecx # i, tmp92 | |
18853 | # test.c:6: for (i = 0; i < n; i++) | |
18854 | incl %edx # i | |
18855 | # test.c:7: total += i * i; | |
18856 | addl %ecx, %eax # tmp92, <retval> | |
18857 | jmp .L2 # | |
18858 | .L5: | |
18859 | # test.c:10: @} | |
18860 | ret | |
18861 | .cfi_endproc | |
18862 | .LFE0: | |
18863 | .size test, .-test | |
18864 | .ident "GCC: (GNU) 7.0.0 20160809 (experimental)" | |
18865 | .section .note.GNU-stack,"",@@progbits | |
18866 | @end smallexample | |
18867 | ||
18868 | The comments are intended for humans rather than machines and hence the | |
18869 | precise format of the comments is subject to change. | |
18870 | ||
d77de738 | 18871 | @opindex frecord-gcc-switches |
ddf6fe37 | 18872 | @item -frecord-gcc-switches |
d77de738 ML |
18873 | This switch causes the command line used to invoke the |
18874 | compiler to be recorded into the object file that is being created. | |
18875 | This switch is only implemented on some targets and the exact format | |
18876 | of the recording is target and binary file format dependent, but it | |
18877 | usually takes the form of a section containing ASCII text. This | |
18878 | switch is related to the @option{-fverbose-asm} switch, but that | |
18879 | switch only records information in the assembler output file as | |
18880 | comments, so it never reaches the object file. | |
18881 | See also @option{-grecord-gcc-switches} for another | |
18882 | way of storing compiler options into the object file. | |
18883 | ||
d77de738 ML |
18884 | @opindex fpic |
18885 | @cindex global offset table | |
18886 | @cindex PIC | |
f33d7a88 | 18887 | @item -fpic |
d77de738 ML |
18888 | Generate position-independent code (PIC) suitable for use in a shared |
18889 | library, if supported for the target machine. Such code accesses all | |
18890 | constant addresses through a global offset table (GOT)@. The dynamic | |
18891 | loader resolves the GOT entries when the program starts (the dynamic | |
18892 | loader is not part of GCC; it is part of the operating system). If | |
18893 | the GOT size for the linked executable exceeds a machine-specific | |
18894 | maximum size, you get an error message from the linker indicating that | |
18895 | @option{-fpic} does not work; in that case, recompile with @option{-fPIC} | |
18896 | instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k | |
18897 | on the m68k and RS/6000. The x86 has no such limit.) | |
18898 | ||
18899 | Position-independent code requires special support, and therefore works | |
18900 | only on certain machines. For the x86, GCC supports PIC for System V | |
18901 | but not for the Sun 386i. Code generated for the IBM RS/6000 is always | |
18902 | position-independent. | |
18903 | ||
18904 | When this flag is set, the macros @code{__pic__} and @code{__PIC__} | |
18905 | are defined to 1. | |
18906 | ||
d77de738 | 18907 | @opindex fPIC |
ddf6fe37 | 18908 | @item -fPIC |
d77de738 ML |
18909 | If supported for the target machine, emit position-independent code, |
18910 | suitable for dynamic linking and avoiding any limit on the size of the | |
18911 | global offset table. This option makes a difference on AArch64, m68k, | |
18912 | PowerPC and SPARC@. | |
18913 | ||
18914 | Position-independent code requires special support, and therefore works | |
18915 | only on certain machines. | |
18916 | ||
18917 | When this flag is set, the macros @code{__pic__} and @code{__PIC__} | |
18918 | are defined to 2. | |
18919 | ||
d77de738 ML |
18920 | @opindex fpie |
18921 | @opindex fPIE | |
ddf6fe37 AA |
18922 | @item -fpie |
18923 | @itemx -fPIE | |
d77de738 ML |
18924 | These options are similar to @option{-fpic} and @option{-fPIC}, but the |
18925 | generated position-independent code can be only linked into executables. | |
18926 | Usually these options are used to compile code that will be linked using | |
18927 | the @option{-pie} GCC option. | |
18928 | ||
18929 | @option{-fpie} and @option{-fPIE} both define the macros | |
18930 | @code{__pie__} and @code{__PIE__}. The macros have the value 1 | |
18931 | for @option{-fpie} and 2 for @option{-fPIE}. | |
18932 | ||
d77de738 ML |
18933 | @opindex fno-plt |
18934 | @opindex fplt | |
ddf6fe37 | 18935 | @item -fno-plt |
d77de738 ML |
18936 | Do not use the PLT for external function calls in position-independent code. |
18937 | Instead, load the callee address at call sites from the GOT and branch to it. | |
18938 | This leads to more efficient code by eliminating PLT stubs and exposing | |
18939 | GOT loads to optimizations. On architectures such as 32-bit x86 where | |
18940 | PLT stubs expect the GOT pointer in a specific register, this gives more | |
18941 | register allocation freedom to the compiler. | |
18942 | Lazy binding requires use of the PLT; | |
18943 | with @option{-fno-plt} all external symbols are resolved at load time. | |
18944 | ||
18945 | Alternatively, the function attribute @code{noplt} can be used to avoid calls | |
18946 | through the PLT for specific external functions. | |
18947 | ||
18948 | In position-dependent code, a few targets also convert calls to | |
18949 | functions that are marked to not use the PLT to use the GOT instead. | |
18950 | ||
d77de738 ML |
18951 | @opindex fno-jump-tables |
18952 | @opindex fjump-tables | |
ddf6fe37 | 18953 | @item -fno-jump-tables |
d77de738 ML |
18954 | Do not use jump tables for switch statements even where it would be |
18955 | more efficient than other code generation strategies. This option is | |
18956 | of use in conjunction with @option{-fpic} or @option{-fPIC} for | |
18957 | building code that forms part of a dynamic linker and cannot | |
18958 | reference the address of a jump table. On some targets, jump tables | |
18959 | do not require a GOT and this option is not needed. | |
18960 | ||
d77de738 ML |
18961 | @opindex fno-bit-tests |
18962 | @opindex fbit-tests | |
ddf6fe37 | 18963 | @item -fno-bit-tests |
d77de738 ML |
18964 | Do not use bit tests for switch statements even where it would be |
18965 | more efficient than other code generation strategies. | |
18966 | ||
d77de738 | 18967 | @opindex ffixed |
ddf6fe37 | 18968 | @item -ffixed-@var{reg} |
d77de738 ML |
18969 | Treat the register named @var{reg} as a fixed register; generated code |
18970 | should never refer to it (except perhaps as a stack pointer, frame | |
18971 | pointer or in some other fixed role). | |
18972 | ||
18973 | @var{reg} must be the name of a register. The register names accepted | |
18974 | are machine-specific and are defined in the @code{REGISTER_NAMES} | |
18975 | macro in the machine description macro file. | |
18976 | ||
18977 | This flag does not have a negative form, because it specifies a | |
18978 | three-way choice. | |
18979 | ||
d77de738 | 18980 | @opindex fcall-used |
ddf6fe37 | 18981 | @item -fcall-used-@var{reg} |
d77de738 ML |
18982 | Treat the register named @var{reg} as an allocable register that is |
18983 | clobbered by function calls. It may be allocated for temporaries or | |
18984 | variables that do not live across a call. Functions compiled this way | |
18985 | do not save and restore the register @var{reg}. | |
18986 | ||
18987 | It is an error to use this flag with the frame pointer or stack pointer. | |
18988 | Use of this flag for other registers that have fixed pervasive roles in | |
18989 | the machine's execution model produces disastrous results. | |
18990 | ||
18991 | This flag does not have a negative form, because it specifies a | |
18992 | three-way choice. | |
18993 | ||
d77de738 | 18994 | @opindex fcall-saved |
ddf6fe37 | 18995 | @item -fcall-saved-@var{reg} |
d77de738 ML |
18996 | Treat the register named @var{reg} as an allocable register saved by |
18997 | functions. It may be allocated even for temporaries or variables that | |
18998 | live across a call. Functions compiled this way save and restore | |
18999 | the register @var{reg} if they use it. | |
19000 | ||
19001 | It is an error to use this flag with the frame pointer or stack pointer. | |
19002 | Use of this flag for other registers that have fixed pervasive roles in | |
19003 | the machine's execution model produces disastrous results. | |
19004 | ||
19005 | A different sort of disaster results from the use of this flag for | |
19006 | a register in which function values may be returned. | |
19007 | ||
19008 | This flag does not have a negative form, because it specifies a | |
19009 | three-way choice. | |
19010 | ||
d77de738 | 19011 | @opindex fpack-struct |
ddf6fe37 | 19012 | @item -fpack-struct[=@var{n}] |
d77de738 ML |
19013 | Without a value specified, pack all structure members together without |
19014 | holes. When a value is specified (which must be a small power of two), pack | |
19015 | structure members according to this value, representing the maximum | |
19016 | alignment (that is, objects with default alignment requirements larger than | |
19017 | this are output potentially unaligned at the next fitting location. | |
19018 | ||
19019 | @strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate | |
19020 | code that is not binary compatible with code generated without that switch. | |
19021 | Additionally, it makes the code suboptimal. | |
19022 | Use it to conform to a non-default application binary interface. | |
19023 | ||
d77de738 | 19024 | @opindex fleading-underscore |
ddf6fe37 | 19025 | @item -fleading-underscore |
d77de738 ML |
19026 | This option and its counterpart, @option{-fno-leading-underscore}, forcibly |
19027 | change the way C symbols are represented in the object file. One use | |
19028 | is to help link with legacy assembly code. | |
19029 | ||
19030 | @strong{Warning:} the @option{-fleading-underscore} switch causes GCC to | |
19031 | generate code that is not binary compatible with code generated without that | |
19032 | switch. Use it to conform to a non-default application binary interface. | |
19033 | Not all targets provide complete support for this switch. | |
19034 | ||
d77de738 | 19035 | @opindex ftls-model |
ddf6fe37 | 19036 | @item -ftls-model=@var{model} |
d77de738 ML |
19037 | Alter the thread-local storage model to be used (@pxref{Thread-Local}). |
19038 | The @var{model} argument should be one of @samp{global-dynamic}, | |
19039 | @samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}. | |
19040 | Note that the choice is subject to optimization: the compiler may use | |
19041 | a more efficient model for symbols not visible outside of the translation | |
19042 | unit, or if @option{-fpic} is not given on the command line. | |
19043 | ||
19044 | The default without @option{-fpic} is @samp{initial-exec}; with | |
19045 | @option{-fpic} the default is @samp{global-dynamic}. | |
19046 | ||
d77de738 | 19047 | @opindex ftrampolines |
ddf6fe37 | 19048 | @item -ftrampolines |
d77de738 ML |
19049 | For targets that normally need trampolines for nested functions, always |
19050 | generate them instead of using descriptors. Otherwise, for targets that | |
19051 | do not need them, like for example HP-PA or IA-64, do nothing. | |
19052 | ||
19053 | A trampoline is a small piece of code that is created at run time on the | |
19054 | stack when the address of a nested function is taken, and is used to call | |
19055 | the nested function indirectly. Therefore, it requires the stack to be | |
19056 | made executable in order for the program to work properly. | |
19057 | ||
19058 | @option{-fno-trampolines} is enabled by default on a language by language | |
19059 | basis to let the compiler avoid generating them, if it computes that this | |
19060 | is safe, and replace them with descriptors. Descriptors are made up of data | |
19061 | only, but the generated code must be prepared to deal with them. As of this | |
19062 | writing, @option{-fno-trampolines} is enabled by default only for Ada. | |
19063 | ||
19064 | Moreover, code compiled with @option{-ftrampolines} and code compiled with | |
19065 | @option{-fno-trampolines} are not binary compatible if nested functions are | |
19066 | present. This option must therefore be used on a program-wide basis and be | |
19067 | manipulated with extreme care. | |
19068 | ||
19069 | For languages other than Ada, the @code{-ftrampolines} and | |
19070 | @code{-fno-trampolines} options currently have no effect, and | |
19071 | trampolines are always generated on platforms that need them | |
19072 | for nested functions. | |
19073 | ||
28d8c680 AB |
19074 | @opindex ftrampoline-impl |
19075 | @item -ftrampoline-impl=@r{[}stack@r{|}heap@r{]} | |
19076 | By default, trampolines are generated on stack. However, certain platforms | |
19077 | (such as the Apple M1) do not permit an executable stack. Compiling with | |
19078 | @option{-ftrampoline-impl=heap} generate calls to | |
19079 | @code{__builtin_nested_func_ptr_created} and | |
19080 | @code{__builtin_nested_func_ptr_deleted} in order to allocate and | |
19081 | deallocate trampoline space on the executable heap. These functions are | |
19082 | implemented in libgcc, and will only be provided on specific targets: | |
19083 | x86_64 Darwin, x86_64 and aarch64 Linux. @emph{PLEASE NOTE}: Heap | |
19084 | trampolines are @emph{not} guaranteed to be correctly deallocated if you | |
19085 | @code{setjmp}, instantiate nested functions, and then @code{longjmp} back | |
19086 | to a state prior to having allocated those nested functions. | |
19087 | ||
d77de738 | 19088 | @opindex fvisibility |
ddf6fe37 | 19089 | @item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} |
d77de738 ML |
19090 | Set the default ELF image symbol visibility to the specified option---all |
19091 | symbols are marked with this unless overridden within the code. | |
19092 | Using this feature can very substantially improve linking and | |
19093 | load times of shared object libraries, produce more optimized | |
19094 | code, provide near-perfect API export and prevent symbol clashes. | |
19095 | It is @strong{strongly} recommended that you use this in any shared objects | |
19096 | you distribute. | |
19097 | ||
19098 | Despite the nomenclature, @samp{default} always means public; i.e., | |
19099 | available to be linked against from outside the shared object. | |
19100 | @samp{protected} and @samp{internal} are pretty useless in real-world | |
19101 | usage so the only other commonly used option is @samp{hidden}. | |
19102 | The default if @option{-fvisibility} isn't specified is | |
19103 | @samp{default}, i.e., make every symbol public. | |
19104 | ||
19105 | A good explanation of the benefits offered by ensuring ELF | |
19106 | symbols have the correct visibility is given by ``How To Write | |
19107 | Shared Libraries'' by Ulrich Drepper (which can be found at | |
19108 | @w{@uref{https://www.akkadia.org/drepper/}})---however a superior | |
19109 | solution made possible by this option to marking things hidden when | |
19110 | the default is public is to make the default hidden and mark things | |
19111 | public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden} | |
19112 | and @code{__attribute__ ((visibility("default")))} instead of | |
19113 | @code{__declspec(dllexport)} you get almost identical semantics with | |
19114 | identical syntax. This is a great boon to those working with | |
19115 | cross-platform projects. | |
19116 | ||
19117 | For those adding visibility support to existing code, you may find | |
19118 | @code{#pragma GCC visibility} of use. This works by you enclosing | |
19119 | the declarations you wish to set visibility for with (for example) | |
19120 | @code{#pragma GCC visibility push(hidden)} and | |
19121 | @code{#pragma GCC visibility pop}. | |
19122 | Bear in mind that symbol visibility should be viewed @strong{as | |
19123 | part of the API interface contract} and thus all new code should | |
19124 | always specify visibility when it is not the default; i.e., declarations | |
19125 | only for use within the local DSO should @strong{always} be marked explicitly | |
19126 | as hidden as so to avoid PLT indirection overheads---making this | |
19127 | abundantly clear also aids readability and self-documentation of the code. | |
19128 | Note that due to ISO C++ specification requirements, @code{operator new} and | |
19129 | @code{operator delete} must always be of default visibility. | |
19130 | ||
19131 | Be aware that headers from outside your project, in particular system | |
19132 | headers and headers from any other library you use, may not be | |
19133 | expecting to be compiled with visibility other than the default. You | |
19134 | may need to explicitly say @code{#pragma GCC visibility push(default)} | |
19135 | before including any such headers. | |
19136 | ||
19137 | @code{extern} declarations are not affected by @option{-fvisibility}, so | |
19138 | a lot of code can be recompiled with @option{-fvisibility=hidden} with | |
19139 | no modifications. However, this means that calls to @code{extern} | |
19140 | functions with no explicit visibility use the PLT, so it is more | |
19141 | effective to use @code{__attribute ((visibility))} and/or | |
19142 | @code{#pragma GCC visibility} to tell the compiler which @code{extern} | |
19143 | declarations should be treated as hidden. | |
19144 | ||
19145 | Note that @option{-fvisibility} does affect C++ vague linkage | |
19146 | entities. This means that, for instance, an exception class that is | |
19147 | be thrown between DSOs must be explicitly marked with default | |
19148 | visibility so that the @samp{type_info} nodes are unified between | |
19149 | the DSOs. | |
19150 | ||
19151 | An overview of these techniques, their benefits and how to use them | |
19152 | is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}. | |
19153 | ||
d77de738 | 19154 | @opindex fstrict-volatile-bitfields |
ddf6fe37 | 19155 | @item -fstrict-volatile-bitfields |
d77de738 ML |
19156 | This option should be used if accesses to volatile bit-fields (or other |
19157 | structure fields, although the compiler usually honors those types | |
19158 | anyway) should use a single access of the width of the | |
19159 | field's type, aligned to a natural alignment if possible. For | |
19160 | example, targets with memory-mapped peripheral registers might require | |
19161 | all such accesses to be 16 bits wide; with this flag you can | |
19162 | declare all peripheral bit-fields as @code{unsigned short} (assuming short | |
19163 | is 16 bits on these targets) to force GCC to use 16-bit accesses | |
19164 | instead of, perhaps, a more efficient 32-bit access. | |
19165 | ||
19166 | If this option is disabled, the compiler uses the most efficient | |
19167 | instruction. In the previous example, that might be a 32-bit load | |
19168 | instruction, even though that accesses bytes that do not contain | |
19169 | any portion of the bit-field, or memory-mapped registers unrelated to | |
19170 | the one being updated. | |
19171 | ||
19172 | In some cases, such as when the @code{packed} attribute is applied to a | |
19173 | structure field, it may not be possible to access the field with a single | |
19174 | read or write that is correctly aligned for the target machine. In this | |
19175 | case GCC falls back to generating multiple accesses rather than code that | |
19176 | will fault or truncate the result at run time. | |
19177 | ||
19178 | Note: Due to restrictions of the C/C++11 memory model, write accesses are | |
19179 | not allowed to touch non bit-field members. It is therefore recommended | |
19180 | to define all bits of the field's type as bit-field members. | |
19181 | ||
19182 | The default value of this option is determined by the application binary | |
19183 | interface for the target processor. | |
19184 | ||
d77de738 | 19185 | @opindex fsync-libcalls |
ddf6fe37 | 19186 | @item -fsync-libcalls |
d77de738 ML |
19187 | This option controls whether any out-of-line instance of the @code{__sync} |
19188 | family of functions may be used to implement the C++11 @code{__atomic} | |
19189 | family of functions. | |
19190 | ||
19191 | The default value of this option is enabled, thus the only useful form | |
19192 | of the option is @option{-fno-sync-libcalls}. This option is used in | |
19193 | the implementation of the @file{libatomic} runtime library. | |
19194 | ||
19195 | @end table | |
19196 | ||
19197 | @node Developer Options | |
19198 | @section GCC Developer Options | |
19199 | @cindex developer options | |
19200 | @cindex debugging GCC | |
19201 | @cindex debug dump options | |
19202 | @cindex dump options | |
19203 | @cindex compilation statistics | |
19204 | ||
19205 | This section describes command-line options that are primarily of | |
19206 | interest to GCC developers, including options to support compiler | |
19207 | testing and investigation of compiler bugs and compile-time | |
19208 | performance problems. This includes options that produce debug dumps | |
19209 | at various points in the compilation; that print statistics such as | |
19210 | memory use and execution time; and that print information about GCC's | |
19211 | configuration, such as where it searches for libraries. You should | |
19212 | rarely need to use any of these options for ordinary compilation and | |
19213 | linking tasks. | |
19214 | ||
19215 | Many developer options that cause GCC to dump output to a file take an | |
19216 | optional @samp{=@var{filename}} suffix. You can specify @samp{stdout} | |
19217 | or @samp{-} to dump to standard output, and @samp{stderr} for standard | |
19218 | error. | |
19219 | ||
19220 | If @samp{=@var{filename}} is omitted, a default dump file name is | |
19221 | constructed by concatenating the base dump file name, a pass number, | |
19222 | phase letter, and pass name. The base dump file name is the name of | |
19223 | output file produced by the compiler if explicitly specified and not | |
19224 | an executable; otherwise it is the source file name. | |
19225 | The pass number is determined by the order passes are registered with | |
19226 | the compiler's pass manager. | |
19227 | This is generally the same as the order of execution, but passes | |
19228 | registered by plugins, target-specific passes, or passes that are | |
19229 | otherwise registered late are numbered higher than the pass named | |
19230 | @samp{final}, even if they are executed earlier. The phase letter is | |
19231 | one of @samp{i} (inter-procedural analysis), @samp{l} | |
19232 | (language-specific), @samp{r} (RTL), or @samp{t} (tree). | |
19233 | The files are created in the directory of the output file. | |
19234 | ||
19235 | @table @gcctabopt | |
19236 | ||
ddf6fe37 | 19237 | @opindex fcallgraph-info |
d77de738 ML |
19238 | @item -fcallgraph-info |
19239 | @itemx -fcallgraph-info=@var{MARKERS} | |
d77de738 ML |
19240 | Makes the compiler output callgraph information for the program, on a |
19241 | per-object-file basis. The information is generated in the common VCG | |
19242 | format. It can be decorated with additional, per-node and/or per-edge | |
19243 | information, if a list of comma-separated markers is additionally | |
19244 | specified. When the @code{su} marker is specified, the callgraph is | |
19245 | decorated with stack usage information; it is equivalent to | |
19246 | @option{-fstack-usage}. When the @code{da} marker is specified, the | |
19247 | callgraph is decorated with information about dynamically allocated | |
19248 | objects. | |
19249 | ||
19250 | When compiling with @option{-flto}, no callgraph information is output | |
19251 | along with the object file. At LTO link time, @option{-fcallgraph-info} | |
19252 | may generate multiple callgraph information files next to intermediate | |
19253 | LTO output files. | |
19254 | ||
ddf6fe37 AA |
19255 | @opindex d |
19256 | @opindex fdump-rtl-@var{pass} | |
d77de738 ML |
19257 | @item -d@var{letters} |
19258 | @itemx -fdump-rtl-@var{pass} | |
19259 | @itemx -fdump-rtl-@var{pass}=@var{filename} | |
d77de738 ML |
19260 | Says to make debugging dumps during compilation at times specified by |
19261 | @var{letters}. This is used for debugging the RTL-based passes of the | |
19262 | compiler. | |
19263 | ||
19264 | Some @option{-d@var{letters}} switches have different meaning when | |
19265 | @option{-E} is used for preprocessing. @xref{Preprocessor Options}, | |
19266 | for information about preprocessor-specific dump options. | |
19267 | ||
19268 | Debug dumps can be enabled with a @option{-fdump-rtl} switch or some | |
19269 | @option{-d} option @var{letters}. Here are the possible | |
19270 | letters for use in @var{pass} and @var{letters}, and their meanings: | |
19271 | ||
19272 | @table @gcctabopt | |
19273 | ||
d77de738 | 19274 | @opindex fdump-rtl-alignments |
ddf6fe37 | 19275 | @item -fdump-rtl-alignments |
d77de738 ML |
19276 | Dump after branch alignments have been computed. |
19277 | ||
d77de738 | 19278 | @opindex fdump-rtl-asmcons |
ddf6fe37 | 19279 | @item -fdump-rtl-asmcons |
d77de738 ML |
19280 | Dump after fixing rtl statements that have unsatisfied in/out constraints. |
19281 | ||
d77de738 | 19282 | @opindex fdump-rtl-auto_inc_dec |
ddf6fe37 | 19283 | @item -fdump-rtl-auto_inc_dec |
d77de738 ML |
19284 | Dump after auto-inc-dec discovery. This pass is only run on |
19285 | architectures that have auto inc or auto dec instructions. | |
19286 | ||
d77de738 | 19287 | @opindex fdump-rtl-barriers |
ddf6fe37 | 19288 | @item -fdump-rtl-barriers |
d77de738 ML |
19289 | Dump after cleaning up the barrier instructions. |
19290 | ||
d77de738 | 19291 | @opindex fdump-rtl-bbpart |
ddf6fe37 | 19292 | @item -fdump-rtl-bbpart |
d77de738 ML |
19293 | Dump after partitioning hot and cold basic blocks. |
19294 | ||
d77de738 | 19295 | @opindex fdump-rtl-bbro |
ddf6fe37 | 19296 | @item -fdump-rtl-bbro |
d77de738 ML |
19297 | Dump after block reordering. |
19298 | ||
d77de738 ML |
19299 | @opindex fdump-rtl-btl2 |
19300 | @opindex fdump-rtl-btl2 | |
ddf6fe37 AA |
19301 | @item -fdump-rtl-btl1 |
19302 | @itemx -fdump-rtl-btl2 | |
d77de738 ML |
19303 | @option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping |
19304 | after the two branch | |
19305 | target load optimization passes. | |
19306 | ||
d77de738 | 19307 | @opindex fdump-rtl-bypass |
ddf6fe37 | 19308 | @item -fdump-rtl-bypass |
d77de738 ML |
19309 | Dump after jump bypassing and control flow optimizations. |
19310 | ||
d77de738 | 19311 | @opindex fdump-rtl-combine |
ddf6fe37 | 19312 | @item -fdump-rtl-combine |
d77de738 ML |
19313 | Dump after the RTL instruction combination pass. |
19314 | ||
d77de738 | 19315 | @opindex fdump-rtl-compgotos |
ddf6fe37 | 19316 | @item -fdump-rtl-compgotos |
d77de738 ML |
19317 | Dump after duplicating the computed gotos. |
19318 | ||
d77de738 ML |
19319 | @opindex fdump-rtl-ce1 |
19320 | @opindex fdump-rtl-ce2 | |
19321 | @opindex fdump-rtl-ce3 | |
ddf6fe37 AA |
19322 | @item -fdump-rtl-ce1 |
19323 | @itemx -fdump-rtl-ce2 | |
19324 | @itemx -fdump-rtl-ce3 | |
d77de738 ML |
19325 | @option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and |
19326 | @option{-fdump-rtl-ce3} enable dumping after the three | |
19327 | if conversion passes. | |
19328 | ||
d77de738 | 19329 | @opindex fdump-rtl-cprop_hardreg |
ddf6fe37 | 19330 | @item -fdump-rtl-cprop_hardreg |
d77de738 ML |
19331 | Dump after hard register copy propagation. |
19332 | ||
d77de738 | 19333 | @opindex fdump-rtl-csa |
ddf6fe37 | 19334 | @item -fdump-rtl-csa |
d77de738 ML |
19335 | Dump after combining stack adjustments. |
19336 | ||
d77de738 ML |
19337 | @opindex fdump-rtl-cse1 |
19338 | @opindex fdump-rtl-cse2 | |
ddf6fe37 AA |
19339 | @item -fdump-rtl-cse1 |
19340 | @itemx -fdump-rtl-cse2 | |
d77de738 ML |
19341 | @option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after |
19342 | the two common subexpression elimination passes. | |
19343 | ||
d77de738 | 19344 | @opindex fdump-rtl-dce |
ddf6fe37 | 19345 | @item -fdump-rtl-dce |
d77de738 ML |
19346 | Dump after the standalone dead code elimination passes. |
19347 | ||
d77de738 | 19348 | @opindex fdump-rtl-dbr |
ddf6fe37 | 19349 | @item -fdump-rtl-dbr |
d77de738 ML |
19350 | Dump after delayed branch scheduling. |
19351 | ||
d77de738 ML |
19352 | @opindex fdump-rtl-dce1 |
19353 | @opindex fdump-rtl-dce2 | |
ddf6fe37 AA |
19354 | @item -fdump-rtl-dce1 |
19355 | @itemx -fdump-rtl-dce2 | |
d77de738 ML |
19356 | @option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after |
19357 | the two dead store elimination passes. | |
19358 | ||
d77de738 | 19359 | @opindex fdump-rtl-eh |
ddf6fe37 | 19360 | @item -fdump-rtl-eh |
d77de738 ML |
19361 | Dump after finalization of EH handling code. |
19362 | ||
d77de738 | 19363 | @opindex fdump-rtl-eh_ranges |
ddf6fe37 | 19364 | @item -fdump-rtl-eh_ranges |
d77de738 ML |
19365 | Dump after conversion of EH handling range regions. |
19366 | ||
d77de738 | 19367 | @opindex fdump-rtl-expand |
ddf6fe37 | 19368 | @item -fdump-rtl-expand |
d77de738 ML |
19369 | Dump after RTL generation. |
19370 | ||
d77de738 ML |
19371 | @opindex fdump-rtl-fwprop1 |
19372 | @opindex fdump-rtl-fwprop2 | |
ddf6fe37 AA |
19373 | @item -fdump-rtl-fwprop1 |
19374 | @itemx -fdump-rtl-fwprop2 | |
d77de738 ML |
19375 | @option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable |
19376 | dumping after the two forward propagation passes. | |
19377 | ||
d77de738 ML |
19378 | @opindex fdump-rtl-gcse1 |
19379 | @opindex fdump-rtl-gcse2 | |
ddf6fe37 AA |
19380 | @item -fdump-rtl-gcse1 |
19381 | @itemx -fdump-rtl-gcse2 | |
d77de738 ML |
19382 | @option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping |
19383 | after global common subexpression elimination. | |
19384 | ||
d77de738 | 19385 | @opindex fdump-rtl-init-regs |
ddf6fe37 | 19386 | @item -fdump-rtl-init-regs |
d77de738 ML |
19387 | Dump after the initialization of the registers. |
19388 | ||
d77de738 | 19389 | @opindex fdump-rtl-initvals |
ddf6fe37 | 19390 | @item -fdump-rtl-initvals |
d77de738 ML |
19391 | Dump after the computation of the initial value sets. |
19392 | ||
d77de738 | 19393 | @opindex fdump-rtl-into_cfglayout |
ddf6fe37 | 19394 | @item -fdump-rtl-into_cfglayout |
d77de738 ML |
19395 | Dump after converting to cfglayout mode. |
19396 | ||
d77de738 | 19397 | @opindex fdump-rtl-ira |
ddf6fe37 | 19398 | @item -fdump-rtl-ira |
d77de738 ML |
19399 | Dump after iterated register allocation. |
19400 | ||
d77de738 | 19401 | @opindex fdump-rtl-jump |
ddf6fe37 | 19402 | @item -fdump-rtl-jump |
d77de738 ML |
19403 | Dump after the second jump optimization. |
19404 | ||
d77de738 | 19405 | @opindex fdump-rtl-loop2 |
ddf6fe37 | 19406 | @item -fdump-rtl-loop2 |
d77de738 ML |
19407 | @option{-fdump-rtl-loop2} enables dumping after the rtl |
19408 | loop optimization passes. | |
19409 | ||
d77de738 | 19410 | @opindex fdump-rtl-mach |
ddf6fe37 | 19411 | @item -fdump-rtl-mach |
d77de738 ML |
19412 | Dump after performing the machine dependent reorganization pass, if that |
19413 | pass exists. | |
19414 | ||
d77de738 | 19415 | @opindex fdump-rtl-mode_sw |
ddf6fe37 | 19416 | @item -fdump-rtl-mode_sw |
d77de738 ML |
19417 | Dump after removing redundant mode switches. |
19418 | ||
d77de738 | 19419 | @opindex fdump-rtl-rnreg |
ddf6fe37 | 19420 | @item -fdump-rtl-rnreg |
d77de738 ML |
19421 | Dump after register renumbering. |
19422 | ||
d77de738 | 19423 | @opindex fdump-rtl-outof_cfglayout |
ddf6fe37 | 19424 | @item -fdump-rtl-outof_cfglayout |
d77de738 ML |
19425 | Dump after converting from cfglayout mode. |
19426 | ||
d77de738 | 19427 | @opindex fdump-rtl-peephole2 |
ddf6fe37 | 19428 | @item -fdump-rtl-peephole2 |
d77de738 ML |
19429 | Dump after the peephole pass. |
19430 | ||
d77de738 | 19431 | @opindex fdump-rtl-postreload |
ddf6fe37 | 19432 | @item -fdump-rtl-postreload |
d77de738 ML |
19433 | Dump after post-reload optimizations. |
19434 | ||
d77de738 | 19435 | @opindex fdump-rtl-pro_and_epilogue |
ddf6fe37 | 19436 | @item -fdump-rtl-pro_and_epilogue |
d77de738 ML |
19437 | Dump after generating the function prologues and epilogues. |
19438 | ||
d77de738 ML |
19439 | @opindex fdump-rtl-sched1 |
19440 | @opindex fdump-rtl-sched2 | |
ddf6fe37 AA |
19441 | @item -fdump-rtl-sched1 |
19442 | @itemx -fdump-rtl-sched2 | |
d77de738 ML |
19443 | @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping |
19444 | after the basic block scheduling passes. | |
19445 | ||
d77de738 | 19446 | @opindex fdump-rtl-ree |
ddf6fe37 | 19447 | @item -fdump-rtl-ree |
d77de738 ML |
19448 | Dump after sign/zero extension elimination. |
19449 | ||
d77de738 | 19450 | @opindex fdump-rtl-seqabstr |
ddf6fe37 | 19451 | @item -fdump-rtl-seqabstr |
d77de738 ML |
19452 | Dump after common sequence discovery. |
19453 | ||
d77de738 | 19454 | @opindex fdump-rtl-shorten |
ddf6fe37 | 19455 | @item -fdump-rtl-shorten |
d77de738 ML |
19456 | Dump after shortening branches. |
19457 | ||
d77de738 | 19458 | @opindex fdump-rtl-sibling |
ddf6fe37 | 19459 | @item -fdump-rtl-sibling |
d77de738 ML |
19460 | Dump after sibling call optimizations. |
19461 | ||
d77de738 ML |
19462 | @opindex fdump-rtl-split1 |
19463 | @opindex fdump-rtl-split2 | |
19464 | @opindex fdump-rtl-split3 | |
19465 | @opindex fdump-rtl-split4 | |
19466 | @opindex fdump-rtl-split5 | |
ddf6fe37 AA |
19467 | @item -fdump-rtl-split1 |
19468 | @itemx -fdump-rtl-split2 | |
19469 | @itemx -fdump-rtl-split3 | |
19470 | @itemx -fdump-rtl-split4 | |
19471 | @itemx -fdump-rtl-split5 | |
d77de738 ML |
19472 | These options enable dumping after five rounds of |
19473 | instruction splitting. | |
19474 | ||
d77de738 | 19475 | @opindex fdump-rtl-sms |
ddf6fe37 | 19476 | @item -fdump-rtl-sms |
d77de738 ML |
19477 | Dump after modulo scheduling. This pass is only run on some |
19478 | architectures. | |
19479 | ||
d77de738 | 19480 | @opindex fdump-rtl-stack |
ddf6fe37 | 19481 | @item -fdump-rtl-stack |
d77de738 ML |
19482 | Dump after conversion from GCC's ``flat register file'' registers to the |
19483 | x87's stack-like registers. This pass is only run on x86 variants. | |
19484 | ||
d77de738 ML |
19485 | @opindex fdump-rtl-subreg1 |
19486 | @opindex fdump-rtl-subreg2 | |
ddf6fe37 AA |
19487 | @item -fdump-rtl-subreg1 |
19488 | @itemx -fdump-rtl-subreg2 | |
d77de738 ML |
19489 | @option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after |
19490 | the two subreg expansion passes. | |
19491 | ||
d77de738 | 19492 | @opindex fdump-rtl-unshare |
ddf6fe37 | 19493 | @item -fdump-rtl-unshare |
d77de738 ML |
19494 | Dump after all rtl has been unshared. |
19495 | ||
d77de738 | 19496 | @opindex fdump-rtl-vartrack |
ddf6fe37 | 19497 | @item -fdump-rtl-vartrack |
d77de738 ML |
19498 | Dump after variable tracking. |
19499 | ||
d77de738 | 19500 | @opindex fdump-rtl-vregs |
ddf6fe37 | 19501 | @item -fdump-rtl-vregs |
d77de738 ML |
19502 | Dump after converting virtual registers to hard registers. |
19503 | ||
d77de738 | 19504 | @opindex fdump-rtl-web |
ddf6fe37 | 19505 | @item -fdump-rtl-web |
d77de738 ML |
19506 | Dump after live range splitting. |
19507 | ||
d77de738 ML |
19508 | @opindex fdump-rtl-regclass |
19509 | @opindex fdump-rtl-subregs_of_mode_init | |
19510 | @opindex fdump-rtl-subregs_of_mode_finish | |
19511 | @opindex fdump-rtl-dfinit | |
19512 | @opindex fdump-rtl-dfinish | |
ddf6fe37 AA |
19513 | @item -fdump-rtl-regclass |
19514 | @itemx -fdump-rtl-subregs_of_mode_init | |
19515 | @itemx -fdump-rtl-subregs_of_mode_finish | |
19516 | @itemx -fdump-rtl-dfinit | |
19517 | @itemx -fdump-rtl-dfinish | |
d77de738 ML |
19518 | These dumps are defined but always produce empty files. |
19519 | ||
d77de738 ML |
19520 | @opindex da |
19521 | @opindex fdump-rtl-all | |
ddf6fe37 AA |
19522 | @item -da |
19523 | @itemx -fdump-rtl-all | |
d77de738 ML |
19524 | Produce all the dumps listed above. |
19525 | ||
d77de738 | 19526 | @opindex dA |
ddf6fe37 | 19527 | @item -dA |
d77de738 ML |
19528 | Annotate the assembler output with miscellaneous debugging information. |
19529 | ||
d77de738 | 19530 | @opindex dD |
ddf6fe37 | 19531 | @item -dD |
d77de738 ML |
19532 | Dump all macro definitions, at the end of preprocessing, in addition to |
19533 | normal output. | |
19534 | ||
d77de738 | 19535 | @opindex dH |
ddf6fe37 | 19536 | @item -dH |
d77de738 ML |
19537 | Produce a core dump whenever an error occurs. |
19538 | ||
d77de738 | 19539 | @opindex dp |
ddf6fe37 | 19540 | @item -dp |
d77de738 ML |
19541 | Annotate the assembler output with a comment indicating which |
19542 | pattern and alternative is used. The length and cost of each instruction are | |
19543 | also printed. | |
19544 | ||
d77de738 | 19545 | @opindex dP |
ddf6fe37 | 19546 | @item -dP |
d77de738 ML |
19547 | Dump the RTL in the assembler output as a comment before each instruction. |
19548 | Also turns on @option{-dp} annotation. | |
19549 | ||
d77de738 | 19550 | @opindex dx |
ddf6fe37 | 19551 | @item -dx |
d77de738 ML |
19552 | Just generate RTL for a function instead of compiling it. Usually used |
19553 | with @option{-fdump-rtl-expand}. | |
19554 | @end table | |
19555 | ||
d77de738 | 19556 | @opindex fdump-debug |
ddf6fe37 | 19557 | @item -fdump-debug |
d77de738 ML |
19558 | Dump debugging information generated during the debug |
19559 | generation phase. | |
19560 | ||
d77de738 | 19561 | @opindex fdump-earlydebug |
ddf6fe37 | 19562 | @item -fdump-earlydebug |
d77de738 ML |
19563 | Dump debugging information generated during the early debug |
19564 | generation phase. | |
19565 | ||
d77de738 | 19566 | @opindex fdump-noaddr |
ddf6fe37 | 19567 | @item -fdump-noaddr |
d77de738 ML |
19568 | When doing debugging dumps, suppress address output. This makes it more |
19569 | feasible to use diff on debugging dumps for compiler invocations with | |
19570 | different compiler binaries and/or different | |
19571 | text / bss / data / heap / stack / dso start locations. | |
19572 | ||
d77de738 | 19573 | @opindex freport-bug |
ddf6fe37 | 19574 | @item -freport-bug |
d77de738 ML |
19575 | Collect and dump debug information into a temporary file if an |
19576 | internal compiler error (ICE) occurs. | |
19577 | ||
d77de738 | 19578 | @opindex fdump-unnumbered |
ddf6fe37 | 19579 | @item -fdump-unnumbered |
d77de738 ML |
19580 | When doing debugging dumps, suppress instruction numbers and address output. |
19581 | This makes it more feasible to use diff on debugging dumps for compiler | |
19582 | invocations with different options, in particular with and without | |
19583 | @option{-g}. | |
19584 | ||
d77de738 | 19585 | @opindex fdump-unnumbered-links |
ddf6fe37 | 19586 | @item -fdump-unnumbered-links |
d77de738 ML |
19587 | When doing debugging dumps (see @option{-d} option above), suppress |
19588 | instruction numbers for the links to the previous and next instructions | |
19589 | in a sequence. | |
19590 | ||
ddf6fe37 | 19591 | @opindex fdump-ipa |
d77de738 ML |
19592 | @item -fdump-ipa-@var{switch} |
19593 | @itemx -fdump-ipa-@var{switch}-@var{options} | |
d77de738 ML |
19594 | Control the dumping at various stages of inter-procedural analysis |
19595 | language tree to a file. The file name is generated by appending a | |
19596 | switch specific suffix to the source file name, and the file is created | |
19597 | in the same directory as the output file. The following dumps are | |
19598 | possible: | |
19599 | ||
19600 | @table @samp | |
19601 | @item all | |
19602 | Enables all inter-procedural analysis dumps. | |
19603 | ||
19604 | @item cgraph | |
19605 | Dumps information about call-graph optimization, unused function removal, | |
19606 | and inlining decisions. | |
19607 | ||
19608 | @item inline | |
19609 | Dump after function inlining. | |
19610 | ||
19611 | @end table | |
19612 | ||
19613 | Additionally, the options @option{-optimized}, @option{-missed}, | |
19614 | @option{-note}, and @option{-all} can be provided, with the same meaning | |
19615 | as for @option{-fopt-info}, defaulting to @option{-optimized}. | |
19616 | ||
19617 | For example, @option{-fdump-ipa-inline-optimized-missed} will emit | |
19618 | information on callsites that were inlined, along with callsites | |
19619 | that were not inlined. | |
19620 | ||
19621 | By default, the dump will contain messages about successful | |
19622 | optimizations (equivalent to @option{-optimized}) together with | |
19623 | low-level details about the analysis. | |
19624 | ||
d77de738 | 19625 | @opindex fdump-lang |
ddf6fe37 | 19626 | @item -fdump-lang |
d77de738 ML |
19627 | Dump language-specific information. The file name is made by appending |
19628 | @file{.lang} to the source file name. | |
19629 | ||
ddf6fe37 AA |
19630 | @opindex fdump-lang-all |
19631 | @opindex fdump-lang | |
d77de738 ML |
19632 | @item -fdump-lang-all |
19633 | @itemx -fdump-lang-@var{switch} | |
19634 | @itemx -fdump-lang-@var{switch}-@var{options} | |
19635 | @itemx -fdump-lang-@var{switch}-@var{options}=@var{filename} | |
d77de738 ML |
19636 | Control the dumping of language-specific information. The @var{options} |
19637 | and @var{filename} portions behave as described in the | |
19638 | @option{-fdump-tree} option. The following @var{switch} values are | |
19639 | accepted: | |
19640 | ||
19641 | @table @samp | |
19642 | @item all | |
19643 | ||
19644 | Enable all language-specific dumps. | |
19645 | ||
19646 | @item class | |
19647 | Dump class hierarchy information. Virtual table information is emitted | |
19648 | unless '@option{slim}' is specified. This option is applicable to C++ only. | |
19649 | ||
19650 | @item module | |
19651 | Dump module information. Options @option{lineno} (locations), | |
19652 | @option{graph} (reachability), @option{blocks} (clusters), | |
19653 | @option{uid} (serialization), @option{alias} (mergeable), | |
19654 | @option{asmname} (Elrond), @option{eh} (mapper) & @option{vops} | |
19655 | (macros) may provide additional information. This option is | |
19656 | applicable to C++ only. | |
19657 | ||
19658 | @item raw | |
19659 | Dump the raw internal tree data. This option is applicable to C++ only. | |
19660 | ||
19661 | @end table | |
19662 | ||
d77de738 | 19663 | @opindex fdump-passes |
ddf6fe37 | 19664 | @item -fdump-passes |
d77de738 ML |
19665 | Print on @file{stderr} the list of optimization passes that are turned |
19666 | on and off by the current command-line options. | |
19667 | ||
d77de738 | 19668 | @opindex fdump-statistics |
ddf6fe37 | 19669 | @item -fdump-statistics-@var{option} |
d77de738 ML |
19670 | Enable and control dumping of pass statistics in a separate file. The |
19671 | file name is generated by appending a suffix ending in | |
19672 | @samp{.statistics} to the source file name, and the file is created in | |
19673 | the same directory as the output file. If the @samp{-@var{option}} | |
19674 | form is used, @samp{-stats} causes counters to be summed over the | |
19675 | whole compilation unit while @samp{-details} dumps every event as | |
19676 | the passes generate them. The default with no option is to sum | |
19677 | counters for each function compiled. | |
19678 | ||
ddf6fe37 AA |
19679 | @opindex fdump-tree-all |
19680 | @opindex fdump-tree | |
d77de738 ML |
19681 | @item -fdump-tree-all |
19682 | @itemx -fdump-tree-@var{switch} | |
19683 | @itemx -fdump-tree-@var{switch}-@var{options} | |
19684 | @itemx -fdump-tree-@var{switch}-@var{options}=@var{filename} | |
d77de738 ML |
19685 | Control the dumping at various stages of processing the intermediate |
19686 | language tree to a file. If the @samp{-@var{options}} | |
19687 | form is used, @var{options} is a list of @samp{-} separated options | |
19688 | which control the details of the dump. Not all options are applicable | |
19689 | to all dumps; those that are not meaningful are ignored. The | |
19690 | following options are available | |
19691 | ||
19692 | @table @samp | |
19693 | @item address | |
19694 | Print the address of each node. Usually this is not meaningful as it | |
19695 | changes according to the environment and source file. Its primary use | |
19696 | is for tying up a dump file with a debug environment. | |
19697 | @item asmname | |
19698 | If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that | |
19699 | in the dump instead of @code{DECL_NAME}. Its primary use is ease of | |
19700 | use working backward from mangled names in the assembly file. | |
19701 | @item slim | |
19702 | When dumping front-end intermediate representations, inhibit dumping | |
19703 | of members of a scope or body of a function merely because that scope | |
19704 | has been reached. Only dump such items when they are directly reachable | |
19705 | by some other path. | |
19706 | ||
19707 | When dumping pretty-printed trees, this option inhibits dumping the | |
19708 | bodies of control structures. | |
19709 | ||
19710 | When dumping RTL, print the RTL in slim (condensed) form instead of | |
19711 | the default LISP-like representation. | |
19712 | @item raw | |
19713 | Print a raw representation of the tree. By default, trees are | |
19714 | pretty-printed into a C-like representation. | |
19715 | @item details | |
19716 | Enable more detailed dumps (not honored by every dump option). Also | |
19717 | include information from the optimization passes. | |
19718 | @item stats | |
19719 | Enable dumping various statistics about the pass (not honored by every dump | |
19720 | option). | |
19721 | @item blocks | |
19722 | Enable showing basic block boundaries (disabled in raw dumps). | |
19723 | @item graph | |
19724 | For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}), | |
19725 | dump a representation of the control flow graph suitable for viewing with | |
19726 | GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in | |
19727 | the file is pretty-printed as a subgraph, so that GraphViz can render them | |
19728 | all in a single plot. | |
19729 | ||
19730 | This option currently only works for RTL dumps, and the RTL is always | |
19731 | dumped in slim form. | |
19732 | @item vops | |
19733 | Enable showing virtual operands for every statement. | |
19734 | @item lineno | |
19735 | Enable showing line numbers for statements. | |
19736 | @item uid | |
19737 | Enable showing the unique ID (@code{DECL_UID}) for each variable. | |
19738 | @item verbose | |
19739 | Enable showing the tree dump for each statement. | |
19740 | @item eh | |
19741 | Enable showing the EH region number holding each statement. | |
19742 | @item scev | |
19743 | Enable showing scalar evolution analysis details. | |
19744 | @item optimized | |
19745 | Enable showing optimization information (only available in certain | |
19746 | passes). | |
19747 | @item missed | |
19748 | Enable showing missed optimization information (only available in certain | |
19749 | passes). | |
19750 | @item note | |
19751 | Enable other detailed optimization information (only available in | |
19752 | certain passes). | |
19753 | @item all | |
19754 | Turn on all options, except @option{raw}, @option{slim}, @option{verbose} | |
19755 | and @option{lineno}. | |
19756 | @item optall | |
19757 | Turn on all optimization options, i.e., @option{optimized}, | |
19758 | @option{missed}, and @option{note}. | |
19759 | @end table | |
19760 | ||
19761 | To determine what tree dumps are available or find the dump for a pass | |
19762 | of interest follow the steps below. | |
19763 | ||
19764 | @enumerate | |
19765 | @item | |
19766 | Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output | |
19767 | look for a code that corresponds to the pass you are interested in. | |
19768 | For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and | |
19769 | @code{tree-vrp2} correspond to the three Value Range Propagation passes. | |
19770 | The number at the end distinguishes distinct invocations of the same pass. | |
19771 | @item | |
19772 | To enable the creation of the dump file, append the pass code to | |
19773 | the @option{-fdump-} option prefix and invoke GCC with it. For example, | |
19774 | to enable the dump from the Early Value Range Propagation pass, invoke | |
19775 | GCC with the @option{-fdump-tree-evrp} option. Optionally, you may | |
19776 | specify the name of the dump file. If you don't specify one, GCC | |
19777 | creates as described below. | |
19778 | @item | |
19779 | Find the pass dump in a file whose name is composed of three components | |
19780 | separated by a period: the name of the source file GCC was invoked to | |
19781 | compile, a numeric suffix indicating the pass number followed by the | |
19782 | letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes), | |
19783 | and finally the pass code. For example, the Early VRP pass dump might | |
19784 | be in a file named @file{myfile.c.038t.evrp} in the current working | |
19785 | directory. Note that the numeric codes are not stable and may change | |
19786 | from one version of GCC to another. | |
19787 | @end enumerate | |
19788 | ||
ddf6fe37 | 19789 | @opindex fopt-info |
d77de738 ML |
19790 | @item -fopt-info |
19791 | @itemx -fopt-info-@var{options} | |
19792 | @itemx -fopt-info-@var{options}=@var{filename} | |
d77de738 ML |
19793 | Controls optimization dumps from various optimization passes. If the |
19794 | @samp{-@var{options}} form is used, @var{options} is a list of | |
19795 | @samp{-} separated option keywords to select the dump details and | |
19796 | optimizations. | |
19797 | ||
19798 | The @var{options} can be divided into three groups: | |
19799 | @enumerate | |
19800 | @item | |
19801 | options describing what kinds of messages should be emitted, | |
19802 | @item | |
19803 | options describing the verbosity of the dump, and | |
19804 | @item | |
19805 | options describing which optimizations should be included. | |
19806 | @end enumerate | |
19807 | The options from each group can be freely mixed as they are | |
19808 | non-overlapping. However, in case of any conflicts, | |
19809 | the later options override the earlier options on the command | |
19810 | line. | |
19811 | ||
19812 | The following options control which kinds of messages should be emitted: | |
19813 | ||
19814 | @table @samp | |
19815 | @item optimized | |
19816 | Print information when an optimization is successfully applied. It is | |
19817 | up to a pass to decide which information is relevant. For example, the | |
19818 | vectorizer passes print the source location of loops which are | |
19819 | successfully vectorized. | |
19820 | @item missed | |
19821 | Print information about missed optimizations. Individual passes | |
19822 | control which information to include in the output. | |
19823 | @item note | |
19824 | Print verbose information about optimizations, such as certain | |
19825 | transformations, more detailed messages about decisions etc. | |
19826 | @item all | |
19827 | Print detailed optimization information. This includes | |
19828 | @samp{optimized}, @samp{missed}, and @samp{note}. | |
19829 | @end table | |
19830 | ||
19831 | The following option controls the dump verbosity: | |
19832 | ||
19833 | @table @samp | |
19834 | @item internals | |
19835 | By default, only ``high-level'' messages are emitted. This option enables | |
19836 | additional, more detailed, messages, which are likely to only be of interest | |
19837 | to GCC developers. | |
19838 | @end table | |
19839 | ||
19840 | One or more of the following option keywords can be used to describe a | |
19841 | group of optimizations: | |
19842 | ||
19843 | @table @samp | |
19844 | @item ipa | |
19845 | Enable dumps from all interprocedural optimizations. | |
19846 | @item loop | |
19847 | Enable dumps from all loop optimizations. | |
19848 | @item inline | |
19849 | Enable dumps from all inlining optimizations. | |
19850 | @item omp | |
19851 | Enable dumps from all OMP (Offloading and Multi Processing) optimizations. | |
19852 | @item vec | |
19853 | Enable dumps from all vectorization optimizations. | |
19854 | @item optall | |
19855 | Enable dumps from all optimizations. This is a superset of | |
19856 | the optimization groups listed above. | |
19857 | @end table | |
19858 | ||
19859 | If @var{options} is | |
19860 | omitted, it defaults to @samp{optimized-optall}, which means to dump messages | |
19861 | about successful optimizations from all the passes, omitting messages | |
19862 | that are treated as ``internals''. | |
19863 | ||
19864 | If the @var{filename} is provided, then the dumps from all the | |
19865 | applicable optimizations are concatenated into the @var{filename}. | |
19866 | Otherwise the dump is output onto @file{stderr}. Though multiple | |
19867 | @option{-fopt-info} options are accepted, only one of them can include | |
19868 | a @var{filename}. If other filenames are provided then all but the | |
19869 | first such option are ignored. | |
19870 | ||
19871 | Note that the output @var{filename} is overwritten | |
19872 | in case of multiple translation units. If a combined output from | |
19873 | multiple translation units is desired, @file{stderr} should be used | |
19874 | instead. | |
19875 | ||
19876 | In the following example, the optimization info is output to | |
19877 | @file{stderr}: | |
19878 | ||
19879 | @smallexample | |
19880 | gcc -O3 -fopt-info | |
19881 | @end smallexample | |
19882 | ||
19883 | This example: | |
19884 | @smallexample | |
19885 | gcc -O3 -fopt-info-missed=missed.all | |
19886 | @end smallexample | |
19887 | ||
19888 | @noindent | |
19889 | outputs missed optimization report from all the passes into | |
19890 | @file{missed.all}, and this one: | |
19891 | ||
19892 | @smallexample | |
19893 | gcc -O2 -ftree-vectorize -fopt-info-vec-missed | |
19894 | @end smallexample | |
19895 | ||
19896 | @noindent | |
19897 | prints information about missed optimization opportunities from | |
19898 | vectorization passes on @file{stderr}. | |
19899 | Note that @option{-fopt-info-vec-missed} is equivalent to | |
19900 | @option{-fopt-info-missed-vec}. The order of the optimization group | |
19901 | names and message types listed after @option{-fopt-info} does not matter. | |
19902 | ||
19903 | As another example, | |
19904 | @smallexample | |
19905 | gcc -O3 -fopt-info-inline-optimized-missed=inline.txt | |
19906 | @end smallexample | |
19907 | ||
19908 | @noindent | |
19909 | outputs information about missed optimizations as well as | |
19910 | optimized locations from all the inlining passes into | |
19911 | @file{inline.txt}. | |
19912 | ||
19913 | Finally, consider: | |
19914 | ||
19915 | @smallexample | |
19916 | gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt | |
19917 | @end smallexample | |
19918 | ||
19919 | @noindent | |
19920 | Here the two output filenames @file{vec.miss} and @file{loop.opt} are | |
19921 | in conflict since only one output file is allowed. In this case, only | |
19922 | the first option takes effect and the subsequent options are | |
19923 | ignored. Thus only @file{vec.miss} is produced which contains | |
19924 | dumps from the vectorizer about missed opportunities. | |
19925 | ||
d77de738 | 19926 | @opindex fsave-optimization-record |
ddf6fe37 | 19927 | @item -fsave-optimization-record |
d77de738 ML |
19928 | Write a SRCFILE.opt-record.json.gz file detailing what optimizations |
19929 | were performed, for those optimizations that support @option{-fopt-info}. | |
19930 | ||
19931 | This option is experimental and the format of the data within the | |
19932 | compressed JSON file is subject to change. | |
19933 | ||
19934 | It is roughly equivalent to a machine-readable version of | |
19935 | @option{-fopt-info-all}, as a collection of messages with source file, | |
19936 | line number and column number, with the following additional data for | |
19937 | each message: | |
19938 | ||
19939 | @itemize @bullet | |
19940 | ||
19941 | @item | |
19942 | the execution count of the code being optimized, along with metadata about | |
19943 | whether this was from actual profile data, or just an estimate, allowing | |
19944 | consumers to prioritize messages by code hotness, | |
19945 | ||
19946 | @item | |
19947 | the function name of the code being optimized, where applicable, | |
19948 | ||
19949 | @item | |
19950 | the ``inlining chain'' for the code being optimized, so that when | |
19951 | a function is inlined into several different places (which might | |
19952 | themselves be inlined), the reader can distinguish between the copies, | |
19953 | ||
19954 | @item | |
19955 | objects identifying those parts of the message that refer to expressions, | |
19956 | statements or symbol-table nodes, which of these categories they are, and, | |
19957 | when available, their source code location, | |
19958 | ||
19959 | @item | |
19960 | the GCC pass that emitted the message, and | |
19961 | ||
19962 | @item | |
19963 | the location in GCC's own code from which the message was emitted | |
19964 | ||
19965 | @end itemize | |
19966 | ||
19967 | Additionally, some messages are logically nested within other | |
19968 | messages, reflecting implementation details of the optimization | |
19969 | passes. | |
19970 | ||
d77de738 | 19971 | @opindex fsched-verbose |
ddf6fe37 | 19972 | @item -fsched-verbose=@var{n} |
d77de738 ML |
19973 | On targets that use instruction scheduling, this option controls the |
19974 | amount of debugging output the scheduler prints to the dump files. | |
19975 | ||
19976 | For @var{n} greater than zero, @option{-fsched-verbose} outputs the | |
19977 | same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}. | |
19978 | For @var{n} greater than one, it also output basic block probabilities, | |
19979 | detailed ready list information and unit/insn info. For @var{n} greater | |
19980 | than two, it includes RTL at abort point, control-flow and regions info. | |
19981 | And for @var{n} over four, @option{-fsched-verbose} also includes | |
19982 | dependence info. | |
19983 | ||
19984 | ||
19985 | ||
d77de738 ML |
19986 | @opindex fdisable- |
19987 | @opindex fenable- | |
ddf6fe37 AA |
19988 | @item -fenable-@var{kind}-@var{pass} |
19989 | @itemx -fdisable-@var{kind}-@var{pass}=@var{range-list} | |
d77de738 ML |
19990 | |
19991 | This is a set of options that are used to explicitly disable/enable | |
19992 | optimization passes. These options are intended for use for debugging GCC. | |
19993 | Compiler users should use regular options for enabling/disabling | |
19994 | passes instead. | |
19995 | ||
19996 | @table @gcctabopt | |
19997 | ||
19998 | @item -fdisable-ipa-@var{pass} | |
19999 | Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is | |
20000 | statically invoked in the compiler multiple times, the pass name should be | |
20001 | appended with a sequential number starting from 1. | |
20002 | ||
20003 | @item -fdisable-rtl-@var{pass} | |
20004 | @itemx -fdisable-rtl-@var{pass}=@var{range-list} | |
20005 | Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is | |
20006 | statically invoked in the compiler multiple times, the pass name should be | |
20007 | appended with a sequential number starting from 1. @var{range-list} is a | |
20008 | comma-separated list of function ranges or assembler names. Each range is a number | |
20009 | pair separated by a colon. The range is inclusive in both ends. If the range | |
20010 | is trivial, the number pair can be simplified as a single number. If the | |
20011 | function's call graph node's @var{uid} falls within one of the specified ranges, | |
20012 | the @var{pass} is disabled for that function. The @var{uid} is shown in the | |
20013 | function header of a dump file, and the pass names can be dumped by using | |
20014 | option @option{-fdump-passes}. | |
20015 | ||
20016 | @item -fdisable-tree-@var{pass} | |
20017 | @itemx -fdisable-tree-@var{pass}=@var{range-list} | |
20018 | Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of | |
20019 | option arguments. | |
20020 | ||
20021 | @item -fenable-ipa-@var{pass} | |
20022 | Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is | |
20023 | statically invoked in the compiler multiple times, the pass name should be | |
20024 | appended with a sequential number starting from 1. | |
20025 | ||
20026 | @item -fenable-rtl-@var{pass} | |
20027 | @itemx -fenable-rtl-@var{pass}=@var{range-list} | |
20028 | Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument | |
20029 | description and examples. | |
20030 | ||
20031 | @item -fenable-tree-@var{pass} | |
20032 | @itemx -fenable-tree-@var{pass}=@var{range-list} | |
20033 | Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description | |
20034 | of option arguments. | |
20035 | ||
20036 | @end table | |
20037 | ||
20038 | Here are some examples showing uses of these options. | |
20039 | ||
20040 | @smallexample | |
20041 | ||
20042 | # disable ccp1 for all functions | |
20043 | -fdisable-tree-ccp1 | |
20044 | # disable complete unroll for function whose cgraph node uid is 1 | |
20045 | -fenable-tree-cunroll=1 | |
20046 | # disable gcse2 for functions at the following ranges [1,1], | |
20047 | # [300,400], and [400,1000] | |
20048 | # disable gcse2 for functions foo and foo2 | |
20049 | -fdisable-rtl-gcse2=foo,foo2 | |
20050 | # disable early inlining | |
20051 | -fdisable-tree-einline | |
20052 | # disable ipa inlining | |
20053 | -fdisable-ipa-inline | |
20054 | # enable tree full unroll | |
20055 | -fenable-tree-unroll | |
20056 | ||
20057 | @end smallexample | |
20058 | ||
d77de738 ML |
20059 | @opindex fchecking |
20060 | @opindex fno-checking | |
ddf6fe37 AA |
20061 | @item -fchecking |
20062 | @itemx -fchecking=@var{n} | |
d77de738 ML |
20063 | Enable internal consistency checking. The default depends on |
20064 | the compiler configuration. @option{-fchecking=2} enables further | |
20065 | internal consistency checking that might affect code generation. | |
20066 | ||
d77de738 | 20067 | @opindex frandom-seed |
ddf6fe37 | 20068 | @item -frandom-seed=@var{string} |
d77de738 ML |
20069 | This option provides a seed that GCC uses in place of |
20070 | random numbers in generating certain symbol names | |
20071 | that have to be different in every compiled file. It is also used to | |
20072 | place unique stamps in coverage data files and the object files that | |
20073 | produce them. You can use the @option{-frandom-seed} option to produce | |
20074 | reproducibly identical object files. | |
20075 | ||
20076 | The @var{string} can either be a number (decimal, octal or hex) or an | |
20077 | arbitrary string (in which case it's converted to a number by | |
20078 | computing CRC32). | |
20079 | ||
20080 | The @var{string} should be different for every file you compile. | |
20081 | ||
d77de738 | 20082 | @opindex save-temps |
ddf6fe37 | 20083 | @item -save-temps |
d77de738 ML |
20084 | Store the usual ``temporary'' intermediate files permanently; name them |
20085 | as auxiliary output files, as specified described under | |
20086 | @option{-dumpbase} and @option{-dumpdir}. | |
20087 | ||
20088 | When used in combination with the @option{-x} command-line option, | |
20089 | @option{-save-temps} is sensible enough to avoid overwriting an | |
20090 | input source file with the same extension as an intermediate file. | |
20091 | The corresponding intermediate file may be obtained by renaming the | |
20092 | source file before using @option{-save-temps}. | |
20093 | ||
d77de738 | 20094 | @opindex save-temps=cwd |
ddf6fe37 | 20095 | @item -save-temps=cwd |
d77de738 ML |
20096 | Equivalent to @option{-save-temps -dumpdir ./}. |
20097 | ||
d77de738 | 20098 | @opindex save-temps=obj |
ddf6fe37 | 20099 | @item -save-temps=obj |
d77de738 ML |
20100 | Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where |
20101 | @file{outdir/} is the directory of the output file specified after the | |
20102 | @option{-o} option, including any directory separators. If the | |
20103 | @option{-o} option is not used, the @option{-save-temps=obj} switch | |
20104 | behaves like @option{-save-temps=cwd}. | |
20105 | ||
d77de738 | 20106 | @opindex time |
ddf6fe37 | 20107 | @item -time@r{[}=@var{file}@r{]} |
d77de738 ML |
20108 | Report the CPU time taken by each subprocess in the compilation |
20109 | sequence. For C source files, this is the compiler proper and assembler | |
20110 | (plus the linker if linking is done). | |
20111 | ||
20112 | Without the specification of an output file, the output looks like this: | |
20113 | ||
20114 | @smallexample | |
20115 | # cc1 0.12 0.01 | |
20116 | # as 0.00 0.01 | |
20117 | @end smallexample | |
20118 | ||
20119 | The first number on each line is the ``user time'', that is time spent | |
20120 | executing the program itself. The second number is ``system time'', | |
20121 | time spent executing operating system routines on behalf of the program. | |
20122 | Both numbers are in seconds. | |
20123 | ||
20124 | With the specification of an output file, the output is appended to the | |
20125 | named file, and it looks like this: | |
20126 | ||
20127 | @smallexample | |
20128 | 0.12 0.01 cc1 @var{options} | |
20129 | 0.00 0.01 as @var{options} | |
20130 | @end smallexample | |
20131 | ||
20132 | The ``user time'' and the ``system time'' are moved before the program | |
20133 | name, and the options passed to the program are displayed, so that one | |
20134 | can later tell what file was being compiled, and with which options. | |
20135 | ||
d77de738 | 20136 | @opindex fdump-final-insns |
ddf6fe37 | 20137 | @item -fdump-final-insns@r{[}=@var{file}@r{]} |
d77de738 ML |
20138 | Dump the final internal representation (RTL) to @var{file}. If the |
20139 | optional argument is omitted (or if @var{file} is @code{.}), the name | |
20140 | of the dump file is determined by appending @code{.gkd} to the | |
20141 | dump base name, see @option{-dumpbase}. | |
20142 | ||
d77de738 ML |
20143 | @opindex fcompare-debug |
20144 | @opindex fno-compare-debug | |
ddf6fe37 | 20145 | @item -fcompare-debug@r{[}=@var{opts}@r{]} |
d77de738 ML |
20146 | If no error occurs during compilation, run the compiler a second time, |
20147 | adding @var{opts} and @option{-fcompare-debug-second} to the arguments | |
20148 | passed to the second compilation. Dump the final internal | |
20149 | representation in both compilations, and print an error if they differ. | |
20150 | ||
20151 | If the equal sign is omitted, the default @option{-gtoggle} is used. | |
20152 | ||
20153 | The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty | |
20154 | and nonzero, implicitly enables @option{-fcompare-debug}. If | |
20155 | @env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash, | |
20156 | then it is used for @var{opts}, otherwise the default @option{-gtoggle} | |
20157 | is used. | |
20158 | ||
20159 | @option{-fcompare-debug=}, with the equal sign but without @var{opts}, | |
20160 | is equivalent to @option{-fno-compare-debug}, which disables the dumping | |
20161 | of the final representation and the second compilation, preventing even | |
20162 | @env{GCC_COMPARE_DEBUG} from taking effect. | |
20163 | ||
20164 | To verify full coverage during @option{-fcompare-debug} testing, set | |
20165 | @env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden}, | |
20166 | which GCC rejects as an invalid option in any actual compilation | |
20167 | (rather than preprocessing, assembly or linking). To get just a | |
20168 | warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug | |
20169 | not overridden} will do. | |
20170 | ||
d77de738 | 20171 | @opindex fcompare-debug-second |
ddf6fe37 | 20172 | @item -fcompare-debug-second |
d77de738 ML |
20173 | This option is implicitly passed to the compiler for the second |
20174 | compilation requested by @option{-fcompare-debug}, along with options to | |
20175 | silence warnings, and omitting other options that would cause the compiler | |
20176 | to produce output to files or to standard output as a side effect. Dump | |
20177 | files and preserved temporary files are renamed so as to contain the | |
20178 | @code{.gk} additional extension during the second compilation, to avoid | |
20179 | overwriting those generated by the first. | |
20180 | ||
20181 | When this option is passed to the compiler driver, it causes the | |
20182 | @emph{first} compilation to be skipped, which makes it useful for little | |
20183 | other than debugging the compiler proper. | |
20184 | ||
d77de738 | 20185 | @opindex gtoggle |
ddf6fe37 | 20186 | @item -gtoggle |
d77de738 ML |
20187 | Turn off generation of debug info, if leaving out this option |
20188 | generates it, or turn it on at level 2 otherwise. The position of this | |
20189 | argument in the command line does not matter; it takes effect after all | |
20190 | other options are processed, and it does so only once, no matter how | |
20191 | many times it is given. This is mainly intended to be used with | |
20192 | @option{-fcompare-debug}. | |
20193 | ||
d77de738 ML |
20194 | @opindex fvar-tracking-assignments-toggle |
20195 | @opindex fno-var-tracking-assignments-toggle | |
ddf6fe37 | 20196 | @item -fvar-tracking-assignments-toggle |
d77de738 ML |
20197 | Toggle @option{-fvar-tracking-assignments}, in the same way that |
20198 | @option{-gtoggle} toggles @option{-g}. | |
20199 | ||
d77de738 | 20200 | @opindex Q |
ddf6fe37 | 20201 | @item -Q |
d77de738 ML |
20202 | Makes the compiler print out each function name as it is compiled, and |
20203 | print some statistics about each pass when it finishes. | |
20204 | ||
d77de738 | 20205 | @opindex ftime-report |
ddf6fe37 | 20206 | @item -ftime-report |
75d62394 DM |
20207 | Makes the compiler print some statistics to stderr about the time consumed |
20208 | by each pass when it finishes. | |
20209 | ||
20210 | If SARIF output of diagnostics was requested via | |
20211 | @option{-fdiagnostics-format=sarif-file} or | |
20212 | @option{-fdiagnostics-format=sarif-stderr} then the @option{-ftime-report} | |
20213 | information is instead emitted in JSON form as part of SARIF output. The | |
20214 | precise format of this JSON data is subject to change, and the values may | |
20215 | not exactly match those emitted to stderr due to being written out at a | |
20216 | slightly different place within the compiler. | |
d77de738 | 20217 | |
d77de738 | 20218 | @opindex ftime-report-details |
ddf6fe37 | 20219 | @item -ftime-report-details |
d77de738 ML |
20220 | Record the time consumed by infrastructure parts separately for each pass. |
20221 | ||
d77de738 | 20222 | @opindex fira-verbose |
ddf6fe37 | 20223 | @item -fira-verbose=@var{n} |
d77de738 ML |
20224 | Control the verbosity of the dump file for the integrated register allocator. |
20225 | The default value is 5. If the value @var{n} is greater or equal to 10, | |
20226 | the dump output is sent to stderr using the same format as @var{n} minus 10. | |
20227 | ||
d77de738 | 20228 | @opindex flto-report |
ddf6fe37 | 20229 | @item -flto-report |
d77de738 ML |
20230 | Prints a report with internal details on the workings of the link-time |
20231 | optimizer. The contents of this report vary from version to version. | |
20232 | It is meant to be useful to GCC developers when processing object | |
20233 | files in LTO mode (via @option{-flto}). | |
20234 | ||
20235 | Disabled by default. | |
20236 | ||
d77de738 | 20237 | @opindex flto-report-wpa |
ddf6fe37 | 20238 | @item -flto-report-wpa |
d77de738 ML |
20239 | Like @option{-flto-report}, but only print for the WPA phase of link-time |
20240 | optimization. | |
20241 | ||
d77de738 | 20242 | @opindex fmem-report |
ddf6fe37 | 20243 | @item -fmem-report |
d77de738 ML |
20244 | Makes the compiler print some statistics about permanent memory |
20245 | allocation when it finishes. | |
20246 | ||
d77de738 | 20247 | @opindex fmem-report-wpa |
ddf6fe37 | 20248 | @item -fmem-report-wpa |
d77de738 ML |
20249 | Makes the compiler print some statistics about permanent memory |
20250 | allocation for the WPA phase only. | |
20251 | ||
d77de738 | 20252 | @opindex fpre-ipa-mem-report |
d77de738 | 20253 | @opindex fpost-ipa-mem-report |
ddf6fe37 AA |
20254 | @item -fpre-ipa-mem-report |
20255 | @item -fpost-ipa-mem-report | |
d77de738 ML |
20256 | Makes the compiler print some statistics about permanent memory |
20257 | allocation before or after interprocedural optimization. | |
20258 | ||
d77de738 | 20259 | @opindex fmultiflags |
ddf6fe37 | 20260 | @item -fmultiflags |
d77de738 ML |
20261 | This option enables multilib-aware @code{TFLAGS} to be used to build |
20262 | target libraries with options different from those the compiler is | |
20263 | configured to use by default, through the use of specs (@xref{Spec | |
20264 | Files}) set up by compiler internals, by the target, or by builders at | |
20265 | configure time. | |
20266 | ||
20267 | Like @code{TFLAGS}, this allows the target libraries to be built for | |
20268 | portable baseline environments, while the compiler defaults to more | |
20269 | demanding ones. That's useful because users can easily override the | |
20270 | defaults the compiler is configured to use to build their own programs, | |
20271 | if the defaults are not ideal for their target environment, whereas | |
20272 | rebuilding the runtime libraries is usually not as easy or desirable. | |
20273 | ||
20274 | Unlike @code{TFLAGS}, the use of specs enables different flags to be | |
20275 | selected for different multilibs. The way to accomplish that is to | |
20276 | build with @samp{make TFLAGS=-fmultiflags}, after configuring | |
20277 | @samp{--with-specs=%@{fmultiflags:...@}}. | |
20278 | ||
20279 | This option is discarded by the driver once it's done processing driver | |
20280 | self spec. | |
20281 | ||
20282 | It is also useful to check that @code{TFLAGS} are being used to build | |
20283 | all target libraries, by configuring a non-bootstrap compiler | |
20284 | @samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building | |
20285 | the compiler and target libraries. | |
20286 | ||
d77de738 | 20287 | @opindex fprofile-report |
ddf6fe37 | 20288 | @item -fprofile-report |
d77de738 ML |
20289 | Makes the compiler print some statistics about consistency of the |
20290 | (estimated) profile and effect of individual passes. | |
20291 | ||
d77de738 | 20292 | @opindex fstack-usage |
ddf6fe37 | 20293 | @item -fstack-usage |
d77de738 ML |
20294 | Makes the compiler output stack usage information for the program, on a |
20295 | per-function basis. The filename for the dump is made by appending | |
20296 | @file{.su} to the @var{auxname}. @var{auxname} is generated from the name of | |
20297 | the output file, if explicitly specified and it is not an executable, | |
20298 | otherwise it is the basename of the source file. An entry is made up | |
20299 | of three fields: | |
20300 | ||
20301 | @itemize | |
20302 | @item | |
20303 | The name of the function. | |
20304 | @item | |
20305 | A number of bytes. | |
20306 | @item | |
20307 | One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}. | |
20308 | @end itemize | |
20309 | ||
20310 | The qualifier @code{static} means that the function manipulates the stack | |
20311 | statically: a fixed number of bytes are allocated for the frame on function | |
20312 | entry and released on function exit; no stack adjustments are otherwise made | |
20313 | in the function. The second field is this fixed number of bytes. | |
20314 | ||
20315 | The qualifier @code{dynamic} means that the function manipulates the stack | |
20316 | dynamically: in addition to the static allocation described above, stack | |
20317 | adjustments are made in the body of the function, for example to push/pop | |
20318 | arguments around function calls. If the qualifier @code{bounded} is also | |
20319 | present, the amount of these adjustments is bounded at compile time and | |
20320 | the second field is an upper bound of the total amount of stack used by | |
20321 | the function. If it is not present, the amount of these adjustments is | |
20322 | not bounded at compile time and the second field only represents the | |
20323 | bounded part. | |
20324 | ||
d77de738 | 20325 | @opindex fstats |
ddf6fe37 | 20326 | @item -fstats |
d77de738 ML |
20327 | Emit statistics about front-end processing at the end of the compilation. |
20328 | This option is supported only by the C++ front end, and | |
20329 | the information is generally only useful to the G++ development team. | |
20330 | ||
d77de738 | 20331 | @opindex fdbg-cnt-list |
ddf6fe37 | 20332 | @item -fdbg-cnt-list |
d77de738 ML |
20333 | Print the name and the counter upper bound for all debug counters. |
20334 | ||
20335 | ||
d77de738 | 20336 | @opindex fdbg-cnt |
ddf6fe37 | 20337 | @item -fdbg-cnt=@var{counter-value-list} |
d77de738 ML |
20338 | Set the internal debug counter lower and upper bound. @var{counter-value-list} |
20339 | is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1} | |
20340 | [:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets | |
20341 | the name of the counter and list of closed intervals. | |
20342 | The @var{lower_bound} is optional and is zero | |
20343 | initialized if not set. | |
20344 | For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10}, | |
20345 | @code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and | |
20346 | eleventh invocation. | |
20347 | For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations. | |
20348 | ||
d77de738 | 20349 | @opindex print-file-name |
ddf6fe37 | 20350 | @item -print-file-name=@var{library} |
d77de738 ML |
20351 | Print the full absolute name of the library file @var{library} that |
20352 | would be used when linking---and don't do anything else. With this | |
20353 | option, GCC does not compile or link anything; it just prints the | |
20354 | file name. | |
20355 | ||
d77de738 | 20356 | @opindex print-multi-directory |
ddf6fe37 | 20357 | @item -print-multi-directory |
d77de738 ML |
20358 | Print the directory name corresponding to the multilib selected by any |
20359 | other switches present in the command line. This directory is supposed | |
20360 | to exist in @env{GCC_EXEC_PREFIX}. | |
20361 | ||
d77de738 | 20362 | @opindex print-multi-lib |
ddf6fe37 | 20363 | @item -print-multi-lib |
d77de738 ML |
20364 | Print the mapping from multilib directory names to compiler switches |
20365 | that enable them. The directory name is separated from the switches by | |
20366 | @samp{;}, and each switch starts with an @samp{@@} instead of the | |
20367 | @samp{-}, without spaces between multiple switches. This is supposed to | |
20368 | ease shell processing. | |
20369 | ||
d77de738 | 20370 | @opindex print-multi-os-directory |
ddf6fe37 | 20371 | @item -print-multi-os-directory |
d77de738 ML |
20372 | Print the path to OS libraries for the selected |
20373 | multilib, relative to some @file{lib} subdirectory. If OS libraries are | |
20374 | present in the @file{lib} subdirectory and no multilibs are used, this is | |
20375 | usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}} | |
20376 | sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or | |
20377 | @file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}} | |
20378 | subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}. | |
20379 | ||
d77de738 | 20380 | @opindex print-multiarch |
ddf6fe37 | 20381 | @item -print-multiarch |
d77de738 ML |
20382 | Print the path to OS libraries for the selected multiarch, |
20383 | relative to some @file{lib} subdirectory. | |
20384 | ||
d77de738 | 20385 | @opindex print-prog-name |
ddf6fe37 | 20386 | @item -print-prog-name=@var{program} |
d77de738 ML |
20387 | Like @option{-print-file-name}, but searches for a program such as @command{cpp}. |
20388 | ||
d77de738 | 20389 | @opindex print-libgcc-file-name |
ddf6fe37 | 20390 | @item -print-libgcc-file-name |
d77de738 ML |
20391 | Same as @option{-print-file-name=libgcc.a}. |
20392 | ||
20393 | This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs} | |
20394 | but you do want to link with @file{libgcc.a}. You can do: | |
20395 | ||
20396 | @smallexample | |
20397 | gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name` | |
20398 | @end smallexample | |
20399 | ||
d77de738 | 20400 | @opindex print-search-dirs |
ddf6fe37 | 20401 | @item -print-search-dirs |
d77de738 ML |
20402 | Print the name of the configured installation directory and a list of |
20403 | program and library directories @command{gcc} searches---and don't do anything else. | |
20404 | ||
20405 | This is useful when @command{gcc} prints the error message | |
20406 | @samp{installation problem, cannot exec cpp0: No such file or directory}. | |
20407 | To resolve this you either need to put @file{cpp0} and the other compiler | |
20408 | components where @command{gcc} expects to find them, or you can set the environment | |
20409 | variable @env{GCC_EXEC_PREFIX} to the directory where you installed them. | |
20410 | Don't forget the trailing @samp{/}. | |
20411 | @xref{Environment Variables}. | |
20412 | ||
d77de738 | 20413 | @opindex print-sysroot |
ddf6fe37 | 20414 | @item -print-sysroot |
d77de738 ML |
20415 | Print the target sysroot directory that is used during |
20416 | compilation. This is the target sysroot specified either at configure | |
20417 | time or using the @option{--sysroot} option, possibly with an extra | |
20418 | suffix that depends on compilation options. If no target sysroot is | |
20419 | specified, the option prints nothing. | |
20420 | ||
d77de738 | 20421 | @opindex print-sysroot-headers-suffix |
ddf6fe37 | 20422 | @item -print-sysroot-headers-suffix |
d77de738 ML |
20423 | Print the suffix added to the target sysroot when searching for |
20424 | headers, or give an error if the compiler is not configured with such | |
20425 | a suffix---and don't do anything else. | |
20426 | ||
d77de738 | 20427 | @opindex dumpmachine |
ddf6fe37 | 20428 | @item -dumpmachine |
d77de738 ML |
20429 | Print the compiler's target machine (for example, |
20430 | @samp{i686-pc-linux-gnu})---and don't do anything else. | |
20431 | ||
d77de738 | 20432 | @opindex dumpversion |
ddf6fe37 | 20433 | @item -dumpversion |
d77de738 ML |
20434 | Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do |
20435 | anything else. This is the compiler version used in filesystem paths and | |
20436 | specs. Depending on how the compiler has been configured it can be just | |
20437 | a single number (major version), two numbers separated by a dot (major and | |
20438 | minor version) or three numbers separated by dots (major, minor and patchlevel | |
20439 | version). | |
20440 | ||
d77de738 | 20441 | @opindex dumpfullversion |
ddf6fe37 | 20442 | @item -dumpfullversion |
d77de738 ML |
20443 | Print the full compiler version---and don't do anything else. The output is |
20444 | always three numbers separated by dots, major, minor and patchlevel version. | |
20445 | ||
d77de738 | 20446 | @opindex dumpspecs |
ddf6fe37 | 20447 | @item -dumpspecs |
d77de738 ML |
20448 | Print the compiler's built-in specs---and don't do anything else. (This |
20449 | is used when GCC itself is being built.) @xref{Spec Files}. | |
20450 | @end table | |
20451 | ||
20452 | @node Submodel Options | |
20453 | @section Machine-Dependent Options | |
20454 | @cindex submodel options | |
20455 | @cindex specifying hardware config | |
20456 | @cindex hardware models and configurations, specifying | |
20457 | @cindex target-dependent options | |
20458 | @cindex machine-dependent options | |
20459 | ||
20460 | Each target machine supported by GCC can have its own options---for | |
20461 | example, to allow you to compile for a particular processor variant or | |
20462 | ABI, or to control optimizations specific to that machine. By | |
20463 | convention, the names of machine-specific options start with | |
20464 | @samp{-m}. | |
20465 | ||
20466 | Some configurations of the compiler also support additional target-specific | |
20467 | options, usually for compatibility with other compilers on the same | |
20468 | platform. | |
20469 | ||
20470 | @c This list is ordered alphanumerically by subsection name. | |
20471 | @c It should be the same order and spelling as these options are listed | |
20472 | @c in Machine Dependent Options | |
20473 | ||
20474 | @menu | |
20475 | * AArch64 Options:: | |
20476 | * Adapteva Epiphany Options:: | |
20477 | * AMD GCN Options:: | |
20478 | * ARC Options:: | |
20479 | * ARM Options:: | |
20480 | * AVR Options:: | |
20481 | * Blackfin Options:: | |
20482 | * C6X Options:: | |
20483 | * CRIS Options:: | |
20484 | * C-SKY Options:: | |
20485 | * Darwin Options:: | |
20486 | * DEC Alpha Options:: | |
20487 | * eBPF Options:: | |
20488 | * FR30 Options:: | |
20489 | * FT32 Options:: | |
20490 | * FRV Options:: | |
20491 | * GNU/Linux Options:: | |
20492 | * H8/300 Options:: | |
20493 | * HPPA Options:: | |
20494 | * IA-64 Options:: | |
20495 | * LM32 Options:: | |
20496 | * LoongArch Options:: | |
20497 | * M32C Options:: | |
20498 | * M32R/D Options:: | |
20499 | * M680x0 Options:: | |
20500 | * MCore Options:: | |
d77de738 ML |
20501 | * MicroBlaze Options:: |
20502 | * MIPS Options:: | |
20503 | * MMIX Options:: | |
20504 | * MN10300 Options:: | |
20505 | * Moxie Options:: | |
20506 | * MSP430 Options:: | |
20507 | * NDS32 Options:: | |
20508 | * Nios II Options:: | |
20509 | * Nvidia PTX Options:: | |
20510 | * OpenRISC Options:: | |
20511 | * PDP-11 Options:: | |
d77de738 ML |
20512 | * PowerPC Options:: |
20513 | * PRU Options:: | |
20514 | * RISC-V Options:: | |
20515 | * RL78 Options:: | |
20516 | * RS/6000 and PowerPC Options:: | |
20517 | * RX Options:: | |
20518 | * S/390 and zSeries Options:: | |
d77de738 ML |
20519 | * SH Options:: |
20520 | * Solaris 2 Options:: | |
20521 | * SPARC Options:: | |
20522 | * System V Options:: | |
20523 | * V850 Options:: | |
20524 | * VAX Options:: | |
20525 | * Visium Options:: | |
20526 | * VMS Options:: | |
20527 | * VxWorks Options:: | |
20528 | * x86 Options:: | |
20529 | * x86 Windows Options:: | |
20530 | * Xstormy16 Options:: | |
20531 | * Xtensa Options:: | |
20532 | * zSeries Options:: | |
20533 | @end menu | |
20534 | ||
20535 | @node AArch64 Options | |
20536 | @subsection AArch64 Options | |
20537 | @cindex AArch64 Options | |
20538 | ||
20539 | These options are defined for AArch64 implementations: | |
20540 | ||
20541 | @table @gcctabopt | |
20542 | ||
d77de738 | 20543 | @opindex mabi |
ddf6fe37 | 20544 | @item -mabi=@var{name} |
d77de738 ML |
20545 | Generate code for the specified data model. Permissible values |
20546 | are @samp{ilp32} for SysV-like data model where int, long int and pointers | |
20547 | are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits, | |
20548 | but long int and pointers are 64 bits. | |
20549 | ||
20550 | The default depends on the specific target configuration. Note that | |
20551 | the LP64 and ILP32 ABIs are not link-compatible; you must compile your | |
20552 | entire program with the same ABI, and link with a compatible set of libraries. | |
20553 | ||
d77de738 | 20554 | @opindex mbig-endian |
ddf6fe37 | 20555 | @item -mbig-endian |
d77de738 ML |
20556 | Generate big-endian code. This is the default when GCC is configured for an |
20557 | @samp{aarch64_be-*-*} target. | |
20558 | ||
d77de738 | 20559 | @opindex mgeneral-regs-only |
ddf6fe37 | 20560 | @item -mgeneral-regs-only |
d77de738 ML |
20561 | Generate code which uses only the general-purpose registers. This will prevent |
20562 | the compiler from using floating-point and Advanced SIMD registers but will not | |
20563 | impose any restrictions on the assembler. | |
20564 | ||
d77de738 | 20565 | @opindex mlittle-endian |
ddf6fe37 | 20566 | @item -mlittle-endian |
d77de738 ML |
20567 | Generate little-endian code. This is the default when GCC is configured for an |
20568 | @samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target. | |
20569 | ||
d77de738 | 20570 | @opindex mcmodel=tiny |
ddf6fe37 | 20571 | @item -mcmodel=tiny |
d77de738 ML |
20572 | Generate code for the tiny code model. The program and its statically defined |
20573 | symbols must be within 1MB of each other. Programs can be statically or | |
20574 | dynamically linked. | |
20575 | ||
d77de738 | 20576 | @opindex mcmodel=small |
ddf6fe37 | 20577 | @item -mcmodel=small |
d77de738 ML |
20578 | Generate code for the small code model. The program and its statically defined |
20579 | symbols must be within 4GB of each other. Programs can be statically or | |
20580 | dynamically linked. This is the default code model. | |
20581 | ||
d77de738 | 20582 | @opindex mcmodel=large |
ddf6fe37 | 20583 | @item -mcmodel=large |
d77de738 ML |
20584 | Generate code for the large code model. This makes no assumptions about |
20585 | addresses and sizes of sections. Programs can be statically linked only. The | |
20586 | @option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32}, | |
20587 | @option{-fpic} and @option{-fPIC}. | |
20588 | ||
573624ec KT |
20589 | @item -mtp=@var{name} |
20590 | @opindex mtp | |
20591 | Specify the system register to use as a thread pointer. The valid values | |
4389a2d2 KT |
20592 | are @samp{tpidr_el0}, @samp{tpidrro_el0}, @samp{tpidr_el1}, @samp{tpidr_el2}, |
20593 | @samp{tpidr_el3}. For backwards compatibility the aliases @samp{el0}, | |
20594 | @samp{el1}, @samp{el2}, @samp{el3} are also accepted. | |
20595 | The default setting is @samp{tpidr_el0}. It is recommended to compile all | |
20596 | code intended to interoperate with the same value of this option to avoid | |
20597 | accessing a different thread pointer from the wrong exception level. | |
573624ec | 20598 | |
d77de738 ML |
20599 | @opindex mstrict-align |
20600 | @opindex mno-strict-align | |
ddf6fe37 AA |
20601 | @item -mstrict-align |
20602 | @itemx -mno-strict-align | |
d77de738 ML |
20603 | Avoid or allow generating memory accesses that may not be aligned on a natural |
20604 | object boundary as described in the architecture specification. | |
20605 | ||
d77de738 ML |
20606 | @opindex momit-leaf-frame-pointer |
20607 | @opindex mno-omit-leaf-frame-pointer | |
ddf6fe37 AA |
20608 | @item -momit-leaf-frame-pointer |
20609 | @itemx -mno-omit-leaf-frame-pointer | |
d77de738 ML |
20610 | Omit or keep the frame pointer in leaf functions. The former behavior is the |
20611 | default. | |
20612 | ||
d77de738 ML |
20613 | @opindex mstack-protector-guard |
20614 | @opindex mstack-protector-guard-reg | |
20615 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
20616 | @item -mstack-protector-guard=@var{guard} |
20617 | @itemx -mstack-protector-guard-reg=@var{reg} | |
20618 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
20619 | Generate stack protection code using canary at @var{guard}. Supported |
20620 | locations are @samp{global} for a global canary or @samp{sysreg} for a | |
20621 | canary in an appropriate system register. | |
20622 | ||
20623 | With the latter choice the options | |
20624 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
20625 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
20626 | which system register to use as base register for reading the canary, | |
20627 | and from what offset from that base register. There is no default | |
20628 | register or offset as this is entirely for use within the Linux | |
20629 | kernel. | |
20630 | ||
d77de738 | 20631 | @opindex mtls-dialect=desc |
ddf6fe37 | 20632 | @item -mtls-dialect=desc |
d77de738 ML |
20633 | Use TLS descriptors as the thread-local storage mechanism for dynamic accesses |
20634 | of TLS variables. This is the default. | |
20635 | ||
d77de738 | 20636 | @opindex mtls-dialect=traditional |
ddf6fe37 | 20637 | @item -mtls-dialect=traditional |
d77de738 ML |
20638 | Use traditional TLS as the thread-local storage mechanism for dynamic accesses |
20639 | of TLS variables. | |
20640 | ||
d77de738 | 20641 | @opindex mtls-size |
ddf6fe37 | 20642 | @item -mtls-size=@var{size} |
d77de738 ML |
20643 | Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48. |
20644 | This option requires binutils 2.26 or newer. | |
20645 | ||
d77de738 ML |
20646 | @opindex mfix-cortex-a53-835769 |
20647 | @opindex mno-fix-cortex-a53-835769 | |
ddf6fe37 AA |
20648 | @item -mfix-cortex-a53-835769 |
20649 | @itemx -mno-fix-cortex-a53-835769 | |
d77de738 ML |
20650 | Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769. |
20651 | This involves inserting a NOP instruction between memory instructions and | |
20652 | 64-bit integer multiply-accumulate instructions. | |
20653 | ||
d77de738 ML |
20654 | @opindex mfix-cortex-a53-843419 |
20655 | @opindex mno-fix-cortex-a53-843419 | |
ddf6fe37 AA |
20656 | @item -mfix-cortex-a53-843419 |
20657 | @itemx -mno-fix-cortex-a53-843419 | |
d77de738 ML |
20658 | Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419. |
20659 | This erratum workaround is made at link time and this will only pass the | |
20660 | corresponding flag to the linker. | |
20661 | ||
d77de738 ML |
20662 | @opindex mlow-precision-recip-sqrt |
20663 | @opindex mno-low-precision-recip-sqrt | |
ddf6fe37 AA |
20664 | @item -mlow-precision-recip-sqrt |
20665 | @itemx -mno-low-precision-recip-sqrt | |
d77de738 ML |
20666 | Enable or disable the reciprocal square root approximation. |
20667 | This option only has an effect if @option{-ffast-math} or | |
20668 | @option{-funsafe-math-optimizations} is used as well. Enabling this reduces | |
20669 | precision of reciprocal square root results to about 16 bits for | |
20670 | single precision and to 32 bits for double precision. | |
20671 | ||
d77de738 ML |
20672 | @opindex mlow-precision-sqrt |
20673 | @opindex mno-low-precision-sqrt | |
ddf6fe37 AA |
20674 | @item -mlow-precision-sqrt |
20675 | @itemx -mno-low-precision-sqrt | |
d77de738 ML |
20676 | Enable or disable the square root approximation. |
20677 | This option only has an effect if @option{-ffast-math} or | |
20678 | @option{-funsafe-math-optimizations} is used as well. Enabling this reduces | |
20679 | precision of square root results to about 16 bits for | |
20680 | single precision and to 32 bits for double precision. | |
20681 | If enabled, it implies @option{-mlow-precision-recip-sqrt}. | |
20682 | ||
d77de738 ML |
20683 | @opindex mlow-precision-div |
20684 | @opindex mno-low-precision-div | |
ddf6fe37 AA |
20685 | @item -mlow-precision-div |
20686 | @itemx -mno-low-precision-div | |
d77de738 ML |
20687 | Enable or disable the division approximation. |
20688 | This option only has an effect if @option{-ffast-math} or | |
20689 | @option{-funsafe-math-optimizations} is used as well. Enabling this reduces | |
20690 | precision of division results to about 16 bits for | |
20691 | single precision and to 32 bits for double precision. | |
20692 | ||
20693 | @item -mtrack-speculation | |
20694 | @itemx -mno-track-speculation | |
20695 | Enable or disable generation of additional code to track speculative | |
20696 | execution through conditional branches. The tracking state can then | |
20697 | be used by the compiler when expanding calls to | |
20698 | @code{__builtin_speculation_safe_copy} to permit a more efficient code | |
20699 | sequence to be generated. | |
20700 | ||
20701 | @item -moutline-atomics | |
20702 | @itemx -mno-outline-atomics | |
20703 | Enable or disable calls to out-of-line helpers to implement atomic operations. | |
20704 | These helpers will, at runtime, determine if the LSE instructions from | |
20705 | ARMv8.1-A can be used; if not, they will use the load/store-exclusive | |
20706 | instructions that are present in the base ARMv8.0 ISA. | |
20707 | ||
20708 | This option is only applicable when compiling for the base ARMv8.0 | |
20709 | instruction set. If using a later revision, e.g. @option{-march=armv8.1-a} | |
20710 | or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be | |
20711 | used directly. The same applies when using @option{-mcpu=} when the | |
20712 | selected cpu supports the @samp{lse} feature. | |
20713 | This option is on by default. | |
20714 | ||
d77de738 | 20715 | @opindex march |
ddf6fe37 | 20716 | @item -march=@var{name} |
d77de738 ML |
20717 | Specify the name of the target architecture and, optionally, one or |
20718 | more feature modifiers. This option has the form | |
20719 | @option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}. | |
20720 | ||
20721 | The table below summarizes the permissible values for @var{arch} | |
20722 | and the features that they enable by default: | |
20723 | ||
20724 | @multitable @columnfractions 0.20 0.20 0.60 | |
20725 | @headitem @var{arch} value @tab Architecture @tab Includes by default | |
20726 | @item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd} | |
20727 | @item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma} | |
20728 | @item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a} | |
20729 | @item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth} | |
20730 | @item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod} | |
20731 | @item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres} | |
20732 | @item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm} | |
20733 | @item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+ls64} | |
20734 | @item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops} | |
20735 | @item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2} | |
20736 | @item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm} | |
20737 | @item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+ls64} | |
20738 | @item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops} | |
20739 | @item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r} | |
20740 | @end multitable | |
20741 | ||
20742 | The value @samp{native} is available on native AArch64 GNU/Linux and | |
20743 | causes the compiler to pick the architecture of the host system. This | |
20744 | option has no effect if the compiler is unable to recognize the | |
20745 | architecture of the host system, | |
20746 | ||
20747 | The permissible values for @var{feature} are listed in the sub-section | |
20748 | on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu} | |
20749 | Feature Modifiers}. Where conflicting feature modifiers are | |
20750 | specified, the right-most feature is used. | |
20751 | ||
20752 | GCC uses @var{name} to determine what kind of instructions it can emit | |
20753 | when generating assembly code. If @option{-march} is specified | |
20754 | without either of @option{-mtune} or @option{-mcpu} also being | |
20755 | specified, the code is tuned to perform well across a range of target | |
20756 | processors implementing the target architecture. | |
20757 | ||
d77de738 | 20758 | @opindex mtune |
ddf6fe37 | 20759 | @item -mtune=@var{name} |
d77de738 ML |
20760 | Specify the name of the target processor for which GCC should tune the |
20761 | performance of the code. Permissible values for this option are: | |
20762 | @samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, | |
20763 | @samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, | |
20764 | @samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77}, | |
20765 | @samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34}, | |
20766 | @samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, | |
20767 | @samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor}, | |
20768 | @samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1}, | |
20769 | @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{qdf24xx}, | |
20770 | @samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan}, | |
20771 | @samp{octeontx}, @samp{octeontx81}, @samp{octeontx83}, | |
20772 | @samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96} | |
20773 | @samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n}, | |
20774 | @samp{octeontx2f95mm}, | |
20775 | @samp{a64fx}, | |
20776 | @samp{thunderx}, @samp{thunderxt88}, | |
20777 | @samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110}, | |
20778 | @samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus}, | |
20779 | @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
20780 | @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53}, | |
20781 | @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}, | |
ce51e843 | 20782 | @samp{cortex-r82}, @samp{cortex-x1}, @samp{cortex-x1c}, @samp{cortex-x2}, |
3bfde22c SJ |
20783 | @samp{cortex-x3}, @samp{cortex-x4}, @samp{cortex-a510}, @samp{cortex-a520}, |
20784 | @samp{cortex-a710}, @samp{cortex-a715}, @samp{cortex-a720}, @samp{ampere1}, | |
20785 | @samp{ampere1a}, and @samp{native}. | |
d77de738 ML |
20786 | |
20787 | The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
20788 | @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53}, | |
20789 | @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55} specify that GCC | |
20790 | should tune for a big.LITTLE system. | |
20791 | ||
20792 | The value @samp{neoverse-512tvb} specifies that GCC should tune | |
20793 | for Neoverse cores that (a) implement SVE and (b) have a total vector | |
20794 | bandwidth of 512 bits per cycle. In other words, the option tells GCC to | |
20795 | tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic | |
20796 | instructions a cycle and that can execute an equivalent number of SVE | |
20797 | arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE). | |
20798 | This is more general than tuning for a specific core like Neoverse V1 | |
20799 | but is more specific than the default tuning described below. | |
20800 | ||
20801 | Additionally on native AArch64 GNU/Linux systems the value | |
20802 | @samp{native} tunes performance to the host system. This option has no effect | |
20803 | if the compiler is unable to recognize the processor of the host system. | |
20804 | ||
20805 | Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=} | |
20806 | are specified, the code is tuned to perform well across a range | |
20807 | of target processors. | |
20808 | ||
20809 | This option cannot be suffixed by feature modifiers. | |
20810 | ||
d77de738 | 20811 | @opindex mcpu |
ddf6fe37 | 20812 | @item -mcpu=@var{name} |
d77de738 ML |
20813 | Specify the name of the target processor, optionally suffixed by one |
20814 | or more feature modifiers. This option has the form | |
20815 | @option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where | |
20816 | the permissible values for @var{cpu} are the same as those available | |
20817 | for @option{-mtune}. The permissible values for @var{feature} are | |
20818 | documented in the sub-section on | |
20819 | @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu} | |
20820 | Feature Modifiers}. Where conflicting feature modifiers are | |
20821 | specified, the right-most feature is used. | |
20822 | ||
20823 | GCC uses @var{name} to determine what kind of instructions it can emit when | |
20824 | generating assembly code (as if by @option{-march}) and to determine | |
20825 | the target processor for which to tune for performance (as if | |
20826 | by @option{-mtune}). Where this option is used in conjunction | |
20827 | with @option{-march} or @option{-mtune}, those options take precedence | |
20828 | over the appropriate part of this option. | |
20829 | ||
20830 | @option{-mcpu=neoverse-512tvb} is special in that it does not refer | |
20831 | to a specific core, but instead refers to all Neoverse cores that | |
20832 | (a) implement SVE and (b) have a total vector bandwidth of 512 bits | |
20833 | a cycle. Unless overridden by @option{-march}, | |
20834 | @option{-mcpu=neoverse-512tvb} generates code that can run on a | |
20835 | Neoverse V1 core, since Neoverse V1 is the first Neoverse core with | |
20836 | these properties. Unless overridden by @option{-mtune}, | |
20837 | @option{-mcpu=neoverse-512tvb} tunes code in the same way as for | |
20838 | @option{-mtune=neoverse-512tvb}. | |
20839 | ||
d77de738 | 20840 | @opindex moverride |
ddf6fe37 | 20841 | @item -moverride=@var{string} |
d77de738 ML |
20842 | Override tuning decisions made by the back-end in response to a |
20843 | @option{-mtune=} switch. The syntax, semantics, and accepted values | |
20844 | for @var{string} in this option are not guaranteed to be consistent | |
20845 | across releases. | |
20846 | ||
20847 | This option is only intended to be useful when developing GCC. | |
20848 | ||
d77de738 | 20849 | @opindex mverbose-cost-dump |
ddf6fe37 | 20850 | @item -mverbose-cost-dump |
d77de738 ML |
20851 | Enable verbose cost model dumping in the debug dump files. This option is |
20852 | provided for use in debugging the compiler. | |
20853 | ||
d77de738 ML |
20854 | @opindex mpc-relative-literal-loads |
20855 | @opindex mno-pc-relative-literal-loads | |
ddf6fe37 AA |
20856 | @item -mpc-relative-literal-loads |
20857 | @itemx -mno-pc-relative-literal-loads | |
d77de738 ML |
20858 | Enable or disable PC-relative literal loads. With this option literal pools are |
20859 | accessed using a single instruction and emitted after each function. This | |
20860 | limits the maximum size of functions to 1MB. This is enabled by default for | |
20861 | @option{-mcmodel=tiny}. | |
20862 | ||
d77de738 | 20863 | @opindex msign-return-address |
ddf6fe37 | 20864 | @item -msign-return-address=@var{scope} |
d77de738 ML |
20865 | Select the function scope on which return address signing will be applied. |
20866 | Permissible values are @samp{none}, which disables return address signing, | |
20867 | @samp{non-leaf}, which enables pointer signing for functions which are not leaf | |
20868 | functions, and @samp{all}, which enables pointer signing for all functions. The | |
20869 | default value is @samp{none}. This option has been deprecated by | |
20870 | -mbranch-protection. | |
20871 | ||
d77de738 | 20872 | @opindex mbranch-protection |
ddf6fe37 | 20873 | @item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti} |
d77de738 ML |
20874 | Select the branch protection features to use. |
20875 | @samp{none} is the default and turns off all types of branch protection. | |
20876 | @samp{standard} turns on all types of branch protection features. If a feature | |
20877 | has additional tuning options, then @samp{standard} sets it to its standard | |
20878 | level. | |
20879 | @samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard | |
20880 | level: signing functions that save the return address to memory (non-leaf | |
20881 | functions will practically always do this) using the a-key. The optional | |
20882 | argument @samp{leaf} can be used to extend the signing to include leaf | |
20883 | functions. The optional argument @samp{b-key} can be used to sign the functions | |
20884 | with the B-key instead of the A-key. | |
20885 | @samp{bti} turns on branch target identification mechanism. | |
20886 | ||
d77de738 | 20887 | @opindex mharden-sls |
ddf6fe37 | 20888 | @item -mharden-sls=@var{opts} |
d77de738 ML |
20889 | Enable compiler hardening against straight line speculation (SLS). |
20890 | @var{opts} is a comma-separated list of the following options: | |
20891 | @table @samp | |
20892 | @item retbr | |
20893 | @item blr | |
20894 | @end table | |
20895 | In addition, @samp{-mharden-sls=all} enables all SLS hardening while | |
20896 | @samp{-mharden-sls=none} disables all SLS hardening. | |
20897 | ||
d77de738 | 20898 | @opindex msve-vector-bits |
ddf6fe37 | 20899 | @item -msve-vector-bits=@var{bits} |
d77de738 ML |
20900 | Specify the number of bits in an SVE vector register. This option only has |
20901 | an effect when SVE is enabled. | |
20902 | ||
20903 | GCC supports two forms of SVE code generation: ``vector-length | |
20904 | agnostic'' output that works with any size of vector register and | |
20905 | ``vector-length specific'' output that allows GCC to make assumptions | |
20906 | about the vector length when it is useful for optimization reasons. | |
20907 | The possible values of @samp{bits} are: @samp{scalable}, @samp{128}, | |
20908 | @samp{256}, @samp{512}, @samp{1024} and @samp{2048}. | |
20909 | Specifying @samp{scalable} selects vector-length agnostic | |
20910 | output. At present @samp{-msve-vector-bits=128} also generates vector-length | |
20911 | agnostic output for big-endian targets. All other values generate | |
20912 | vector-length specific code. The behavior of these values may change | |
20913 | in future releases and no value except @samp{scalable} should be | |
20914 | relied on for producing code that is portable across different | |
20915 | hardware SVE vector lengths. | |
20916 | ||
20917 | The default is @samp{-msve-vector-bits=scalable}, which produces | |
20918 | vector-length agnostic code. | |
20919 | @end table | |
20920 | ||
20921 | @subsubsection @option{-march} and @option{-mcpu} Feature Modifiers | |
20922 | @anchor{aarch64-feature-modifiers} | |
20923 | @cindex @option{-march} feature modifiers | |
20924 | @cindex @option{-mcpu} feature modifiers | |
20925 | Feature modifiers used with @option{-march} and @option{-mcpu} can be any of | |
20926 | the following and their inverses @option{no@var{feature}}: | |
20927 | ||
20928 | @table @samp | |
20929 | @item crc | |
20930 | Enable CRC extension. This is on by default for | |
20931 | @option{-march=armv8.1-a}. | |
20932 | @item crypto | |
20933 | Enable Crypto extension. This also enables Advanced SIMD and floating-point | |
20934 | instructions. | |
20935 | @item fp | |
20936 | Enable floating-point instructions. This is on by default for all possible | |
20937 | values for options @option{-march} and @option{-mcpu}. | |
20938 | @item simd | |
20939 | Enable Advanced SIMD instructions. This also enables floating-point | |
20940 | instructions. This is on by default for all possible values for options | |
20941 | @option{-march} and @option{-mcpu}. | |
20942 | @item sve | |
20943 | Enable Scalable Vector Extension instructions. This also enables Advanced | |
20944 | SIMD and floating-point instructions. | |
20945 | @item lse | |
20946 | Enable Large System Extension instructions. This is on by default for | |
20947 | @option{-march=armv8.1-a}. | |
20948 | @item rdma | |
20949 | Enable Round Double Multiply Accumulate instructions. This is on by default | |
20950 | for @option{-march=armv8.1-a}. | |
20951 | @item fp16 | |
20952 | Enable FP16 extension. This also enables floating-point instructions. | |
20953 | @item fp16fml | |
20954 | Enable FP16 fmla extension. This also enables FP16 extensions and | |
20955 | 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. | |
20956 | ||
20957 | @item rcpc | |
0431e8ae AV |
20958 | Enable the RCpc extension. This enables the use of the LDAPR instructions for |
20959 | load-acquire atomic semantics, and passes it on to the assembler, enabling | |
20960 | inline asm statements to use instructions from the RCpc extension. | |
d77de738 ML |
20961 | @item dotprod |
20962 | Enable the Dot Product extension. This also enables Advanced SIMD instructions. | |
20963 | @item aes | |
20964 | Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced | |
20965 | SIMD instructions. | |
20966 | @item sha2 | |
20967 | Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions. | |
20968 | @item sha3 | |
20969 | Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD | |
20970 | instructions. Use of this option with architectures prior to Armv8.2-A is not supported. | |
20971 | @item sm4 | |
20972 | Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions. | |
20973 | Use of this option with architectures prior to Armv8.2-A is not supported. | |
20974 | @item profile | |
20975 | Enable the Statistical Profiling extension. This option is only to enable the | |
20976 | extension at the assembler level and does not affect code generation. | |
20977 | @item rng | |
20978 | Enable the Armv8.5-a Random Number instructions. This option is only to | |
20979 | enable the extension at the assembler level and does not affect code | |
20980 | generation. | |
20981 | @item memtag | |
20982 | Enable the Armv8.5-a Memory Tagging Extensions. | |
20983 | Use of this option with architectures prior to Armv8.5-A is not supported. | |
20984 | @item sb | |
20985 | Enable the Armv8-a Speculation Barrier instruction. This option is only to | |
20986 | enable the extension at the assembler level and does not affect code | |
20987 | generation. This option is enabled by default for @option{-march=armv8.5-a}. | |
20988 | @item ssbs | |
20989 | Enable the Armv8-a Speculative Store Bypass Safe instruction. This option | |
20990 | is only to enable the extension at the assembler level and does not affect code | |
20991 | generation. This option is enabled by default for @option{-march=armv8.5-a}. | |
20992 | @item predres | |
20993 | Enable the Armv8-a Execution and Data Prediction Restriction instructions. | |
20994 | This option is only to enable the extension at the assembler level and does | |
20995 | not affect code generation. This option is enabled by default for | |
20996 | @option{-march=armv8.5-a}. | |
20997 | @item sve2 | |
20998 | Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE | |
20999 | instructions. | |
21000 | @item sve2-bitperm | |
21001 | Enable SVE2 bitperm instructions. This also enables SVE2 instructions. | |
21002 | @item sve2-sm4 | |
21003 | Enable SVE2 sm4 instructions. This also enables SVE2 instructions. | |
21004 | @item sve2-aes | |
21005 | Enable SVE2 aes instructions. This also enables SVE2 instructions. | |
21006 | @item sve2-sha3 | |
21007 | Enable SVE2 sha3 instructions. This also enables SVE2 instructions. | |
21008 | @item tme | |
21009 | Enable the Transactional Memory Extension. | |
21010 | @item i8mm | |
21011 | Enable 8-bit Integer Matrix Multiply instructions. This also enables | |
21012 | Advanced SIMD and floating-point instructions. This option is enabled by | |
21013 | default for @option{-march=armv8.6-a}. Use of this option with architectures | |
21014 | prior to Armv8.2-A is not supported. | |
21015 | @item f32mm | |
21016 | Enable 32-bit Floating point Matrix Multiply instructions. This also enables | |
21017 | SVE instructions. Use of this option with architectures prior to Armv8.2-A is | |
21018 | not supported. | |
21019 | @item f64mm | |
21020 | Enable 64-bit Floating point Matrix Multiply instructions. This also enables | |
21021 | SVE instructions. Use of this option with architectures prior to Armv8.2-A is | |
21022 | not supported. | |
21023 | @item bf16 | |
21024 | Enable brain half-precision floating-point instructions. This also enables | |
21025 | Advanced SIMD and floating-point instructions. This option is enabled by | |
21026 | default for @option{-march=armv8.6-a}. Use of this option with architectures | |
21027 | prior to Armv8.2-A is not supported. | |
21028 | @item ls64 | |
21029 | Enable the 64-byte atomic load and store instructions for accelerators. | |
21030 | This option is enabled by default for @option{-march=armv8.7-a}. | |
21031 | @item mops | |
21032 | Enable the instructions to accelerate memory operations like @code{memcpy}, | |
21033 | @code{memmove}, @code{memset}. This option is enabled by default for | |
21034 | @option{-march=armv8.8-a} | |
21035 | @item flagm | |
21036 | Enable the Flag Manipulation instructions Extension. | |
21037 | @item pauth | |
21038 | Enable the Pointer Authentication Extension. | |
d758d190 KT |
21039 | @item cssc |
21040 | Enable the Common Short Sequence Compression instructions. | |
d77de738 ML |
21041 | |
21042 | @end table | |
21043 | ||
21044 | Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd}, | |
21045 | which implies @option{fp}. | |
21046 | Conversely, @option{nofp} implies @option{nosimd}, which implies | |
21047 | @option{nocrypto}, @option{noaes} and @option{nosha2}. | |
21048 | ||
21049 | @node Adapteva Epiphany Options | |
21050 | @subsection Adapteva Epiphany Options | |
21051 | ||
21052 | These @samp{-m} options are defined for Adapteva Epiphany: | |
21053 | ||
21054 | @table @gcctabopt | |
d77de738 | 21055 | @opindex mhalf-reg-file |
ddf6fe37 | 21056 | @item -mhalf-reg-file |
d77de738 ML |
21057 | Don't allocate any register in the range @code{r32}@dots{}@code{r63}. |
21058 | That allows code to run on hardware variants that lack these registers. | |
21059 | ||
d77de738 | 21060 | @opindex mprefer-short-insn-regs |
ddf6fe37 | 21061 | @item -mprefer-short-insn-regs |
d77de738 ML |
21062 | Preferentially allocate registers that allow short instruction generation. |
21063 | This can result in increased instruction count, so this may either reduce or | |
21064 | increase overall code size. | |
21065 | ||
d77de738 | 21066 | @opindex mbranch-cost |
ddf6fe37 | 21067 | @item -mbranch-cost=@var{num} |
d77de738 ML |
21068 | Set the cost of branches to roughly @var{num} ``simple'' instructions. |
21069 | This cost is only a heuristic and is not guaranteed to produce | |
21070 | consistent results across releases. | |
21071 | ||
d77de738 | 21072 | @opindex mcmove |
ddf6fe37 | 21073 | @item -mcmove |
d77de738 ML |
21074 | Enable the generation of conditional moves. |
21075 | ||
d77de738 | 21076 | @opindex mnops |
ddf6fe37 | 21077 | @item -mnops=@var{num} |
d77de738 ML |
21078 | Emit @var{num} NOPs before every other generated instruction. |
21079 | ||
d77de738 ML |
21080 | @opindex mno-soft-cmpsf |
21081 | @opindex msoft-cmpsf | |
ddf6fe37 | 21082 | @item -mno-soft-cmpsf |
d77de738 ML |
21083 | For single-precision floating-point comparisons, emit an @code{fsub} instruction |
21084 | and test the flags. This is faster than a software comparison, but can | |
21085 | get incorrect results in the presence of NaNs, or when two different small | |
21086 | numbers are compared such that their difference is calculated as zero. | |
21087 | The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant, | |
21088 | software comparisons. | |
21089 | ||
d77de738 | 21090 | @opindex mstack-offset |
ddf6fe37 | 21091 | @item -mstack-offset=@var{num} |
d77de738 ML |
21092 | Set the offset between the top of the stack and the stack pointer. |
21093 | E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7} | |
21094 | can be used by leaf functions without stack allocation. | |
21095 | Values other than @samp{8} or @samp{16} are untested and unlikely to work. | |
21096 | Note also that this option changes the ABI; compiling a program with a | |
21097 | different stack offset than the libraries have been compiled with | |
21098 | generally does not work. | |
21099 | This option can be useful if you want to evaluate if a different stack | |
21100 | offset would give you better code, but to actually use a different stack | |
21101 | offset to build working programs, it is recommended to configure the | |
21102 | toolchain with the appropriate @option{--with-stack-offset=@var{num}} option. | |
21103 | ||
d77de738 ML |
21104 | @opindex mno-round-nearest |
21105 | @opindex mround-nearest | |
ddf6fe37 | 21106 | @item -mno-round-nearest |
d77de738 ML |
21107 | Make the scheduler assume that the rounding mode has been set to |
21108 | truncating. The default is @option{-mround-nearest}. | |
21109 | ||
d77de738 | 21110 | @opindex mlong-calls |
ddf6fe37 | 21111 | @item -mlong-calls |
d77de738 ML |
21112 | If not otherwise specified by an attribute, assume all calls might be beyond |
21113 | the offset range of the @code{b} / @code{bl} instructions, and therefore load the | |
21114 | function address into a register before performing a (otherwise direct) call. | |
21115 | This is the default. | |
21116 | ||
d77de738 | 21117 | @opindex short-calls |
ddf6fe37 | 21118 | @item -mshort-calls |
d77de738 ML |
21119 | If not otherwise specified by an attribute, assume all direct calls are |
21120 | in the range of the @code{b} / @code{bl} instructions, so use these instructions | |
21121 | for direct calls. The default is @option{-mlong-calls}. | |
21122 | ||
d77de738 | 21123 | @opindex msmall16 |
ddf6fe37 | 21124 | @item -msmall16 |
d77de738 ML |
21125 | Assume addresses can be loaded as 16-bit unsigned values. This does not |
21126 | apply to function addresses for which @option{-mlong-calls} semantics | |
21127 | are in effect. | |
21128 | ||
d77de738 | 21129 | @opindex mfp-mode |
ddf6fe37 | 21130 | @item -mfp-mode=@var{mode} |
d77de738 ML |
21131 | Set the prevailing mode of the floating-point unit. |
21132 | This determines the floating-point mode that is provided and expected | |
21133 | at function call and return time. Making this mode match the mode you | |
21134 | predominantly need at function start can make your programs smaller and | |
21135 | faster by avoiding unnecessary mode switches. | |
21136 | ||
21137 | @var{mode} can be set to one the following values: | |
21138 | ||
21139 | @table @samp | |
21140 | @item caller | |
21141 | Any mode at function entry is valid, and retained or restored when | |
21142 | the function returns, and when it calls other functions. | |
21143 | This mode is useful for compiling libraries or other compilation units | |
21144 | you might want to incorporate into different programs with different | |
21145 | prevailing FPU modes, and the convenience of being able to use a single | |
21146 | object file outweighs the size and speed overhead for any extra | |
21147 | mode switching that might be needed, compared with what would be needed | |
21148 | with a more specific choice of prevailing FPU mode. | |
21149 | ||
21150 | @item truncate | |
21151 | This is the mode used for floating-point calculations with | |
21152 | truncating (i.e.@: round towards zero) rounding mode. That includes | |
21153 | conversion from floating point to integer. | |
21154 | ||
21155 | @item round-nearest | |
21156 | This is the mode used for floating-point calculations with | |
21157 | round-to-nearest-or-even rounding mode. | |
21158 | ||
21159 | @item int | |
21160 | This is the mode used to perform integer calculations in the FPU, e.g.@: | |
21161 | integer multiply, or integer multiply-and-accumulate. | |
21162 | @end table | |
21163 | ||
21164 | The default is @option{-mfp-mode=caller} | |
21165 | ||
d77de738 ML |
21166 | @opindex mno-split-lohi |
21167 | @opindex msplit-lohi | |
21168 | @opindex mno-postinc | |
21169 | @opindex mpostinc | |
21170 | @opindex mno-postmodify | |
21171 | @opindex mpostmodify | |
ddf6fe37 AA |
21172 | @item -mno-split-lohi |
21173 | @itemx -mno-postinc | |
21174 | @itemx -mno-postmodify | |
d77de738 ML |
21175 | Code generation tweaks that disable, respectively, splitting of 32-bit |
21176 | loads, generation of post-increment addresses, and generation of | |
21177 | post-modify addresses. The defaults are @option{msplit-lohi}, | |
21178 | @option{-mpost-inc}, and @option{-mpost-modify}. | |
21179 | ||
d77de738 ML |
21180 | @opindex mno-vect-double |
21181 | @opindex mvect-double | |
ddf6fe37 | 21182 | @item -mnovect-double |
d77de738 ML |
21183 | Change the preferred SIMD mode to SImode. The default is |
21184 | @option{-mvect-double}, which uses DImode as preferred SIMD mode. | |
21185 | ||
d77de738 | 21186 | @opindex max-vect-align |
ddf6fe37 | 21187 | @item -max-vect-align=@var{num} |
d77de738 ML |
21188 | The maximum alignment for SIMD vector mode types. |
21189 | @var{num} may be 4 or 8. The default is 8. | |
21190 | Note that this is an ABI change, even though many library function | |
21191 | interfaces are unaffected if they don't use SIMD vector modes | |
21192 | in places that affect size and/or alignment of relevant types. | |
21193 | ||
d77de738 | 21194 | @opindex msplit-vecmove-early |
ddf6fe37 | 21195 | @item -msplit-vecmove-early |
d77de738 ML |
21196 | Split vector moves into single word moves before reload. In theory this |
21197 | can give better register allocation, but so far the reverse seems to be | |
21198 | generally the case. | |
21199 | ||
d77de738 | 21200 | @opindex m1reg- |
ddf6fe37 | 21201 | @item -m1reg-@var{reg} |
d77de738 ML |
21202 | Specify a register to hold the constant @minus{}1, which makes loading small negative |
21203 | constants and certain bitmasks faster. | |
21204 | Allowable values for @var{reg} are @samp{r43} and @samp{r63}, | |
21205 | which specify use of that register as a fixed register, | |
21206 | and @samp{none}, which means that no register is used for this | |
21207 | purpose. The default is @option{-m1reg-none}. | |
21208 | ||
21209 | @end table | |
21210 | ||
21211 | @node AMD GCN Options | |
21212 | @subsection AMD GCN Options | |
21213 | @cindex AMD GCN Options | |
21214 | ||
21215 | These options are defined specifically for the AMD GCN port. | |
21216 | ||
21217 | @table @gcctabopt | |
21218 | ||
d77de738 | 21219 | @opindex march |
d77de738 | 21220 | @opindex mtune |
ddf6fe37 AA |
21221 | @item -march=@var{gpu} |
21222 | @itemx -mtune=@var{gpu} | |
d77de738 ML |
21223 | Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu} |
21224 | are | |
21225 | ||
21226 | @table @samp | |
21227 | @item fiji | |
56ed1055 AS |
21228 | Compile for GCN3 Fiji devices (gfx803). Support deprecated; availablility |
21229 | depends on how GCC has been configured, see @option{--with-arch} and | |
21230 | @option{--with-multilib-list}. | |
d77de738 ML |
21231 | |
21232 | @item gfx900 | |
21233 | Compile for GCN5 Vega 10 devices (gfx900). | |
21234 | ||
21235 | @item gfx906 | |
21236 | Compile for GCN5 Vega 20 devices (gfx906). | |
21237 | ||
21238 | @item gfx908 | |
21239 | Compile for CDNA1 Instinct MI100 series devices (gfx908). | |
21240 | ||
21241 | @item gfx90a | |
21242 | Compile for CDNA2 Instinct MI200 series devices (gfx90a). | |
21243 | ||
21244 | @end table | |
21245 | ||
ddf6fe37 | 21246 | @opindex msram-ecc |
d77de738 ML |
21247 | @item -msram-ecc=on |
21248 | @itemx -msram-ecc=off | |
21249 | @itemx -msram-ecc=any | |
d77de738 ML |
21250 | Compile binaries suitable for devices with the SRAM-ECC feature enabled, |
21251 | disabled, or either mode. This feature can be enabled per-process on some | |
21252 | devices. The compiled code must match the device mode. The default is | |
21253 | @samp{any}, for devices that support it. | |
21254 | ||
d77de738 | 21255 | @opindex mstack-size |
ddf6fe37 | 21256 | @item -mstack-size=@var{bytes} |
d77de738 ML |
21257 | Specify how many @var{bytes} of stack space will be requested for each GPU |
21258 | thread (wave-front). Beware that there may be many threads and limited memory | |
21259 | available. The size of the stack allocation may also have an impact on | |
21260 | run-time performance. The default is 32KB when using OpenACC or OpenMP, and | |
21261 | 1MB otherwise. | |
21262 | ||
d77de738 | 21263 | @opindex mxnack |
366e3d30 TB |
21264 | @item -mxnack=on |
21265 | @itemx -mxnack=off | |
21266 | @itemx -mxnack=any | |
21267 | Compile binaries suitable for devices with the XNACK feature enabled, disabled, | |
21268 | or either mode. Some devices always require XNACK and some allow the user to | |
21269 | configure XNACK. The compiled code must match the device mode. | |
21270 | @c The default is @samp{-mxnack=any}. | |
21271 | At present this option is a placeholder for support that is not yet implemented. | |
d77de738 ML |
21272 | |
21273 | @end table | |
21274 | ||
21275 | @node ARC Options | |
21276 | @subsection ARC Options | |
21277 | @cindex ARC options | |
21278 | ||
21279 | The following options control the architecture variant for which code | |
21280 | is being compiled: | |
21281 | ||
21282 | @c architecture variants | |
21283 | @table @gcctabopt | |
21284 | ||
d77de738 | 21285 | @opindex mbarrel-shifter |
ddf6fe37 | 21286 | @item -mbarrel-shifter |
d77de738 ML |
21287 | Generate instructions supported by barrel shifter. This is the default |
21288 | unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect. | |
21289 | ||
d77de738 | 21290 | @opindex mjli-always |
ddf6fe37 | 21291 | @item -mjli-always |
d77de738 ML |
21292 | Force to call a function using jli_s instruction. This option is |
21293 | valid only for ARCv2 architecture. | |
21294 | ||
d77de738 | 21295 | @opindex mcpu |
ddf6fe37 | 21296 | @item -mcpu=@var{cpu} |
d77de738 ML |
21297 | Set architecture type, register usage, and instruction scheduling |
21298 | parameters for @var{cpu}. There are also shortcut alias options | |
21299 | available for backward compatibility and convenience. Supported | |
21300 | values for @var{cpu} are | |
21301 | ||
21302 | @table @samp | |
21303 | @opindex mA6 | |
21304 | @opindex mARC600 | |
21305 | @item arc600 | |
21306 | Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}. | |
21307 | ||
d77de738 | 21308 | @opindex mARC601 |
ddf6fe37 | 21309 | @item arc601 |
d77de738 ML |
21310 | Compile for ARC601. Alias: @option{-mARC601}. |
21311 | ||
d77de738 ML |
21312 | @opindex mA7 |
21313 | @opindex mARC700 | |
ddf6fe37 | 21314 | @item arc700 |
d77de738 ML |
21315 | Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}. |
21316 | This is the default when configured with @option{--with-cpu=arc700}@. | |
21317 | ||
21318 | @item arcem | |
21319 | Compile for ARC EM. | |
21320 | ||
21321 | @item archs | |
21322 | Compile for ARC HS. | |
21323 | ||
21324 | @item em | |
21325 | Compile for ARC EM CPU with no hardware extensions. | |
21326 | ||
21327 | @item em4 | |
21328 | Compile for ARC EM4 CPU. | |
21329 | ||
21330 | @item em4_dmips | |
21331 | Compile for ARC EM4 DMIPS CPU. | |
21332 | ||
21333 | @item em4_fpus | |
21334 | Compile for ARC EM4 DMIPS CPU with the single-precision floating-point | |
21335 | extension. | |
21336 | ||
21337 | @item em4_fpuda | |
21338 | Compile for ARC EM4 DMIPS CPU with single-precision floating-point and | |
21339 | double assist instructions. | |
21340 | ||
21341 | @item hs | |
21342 | Compile for ARC HS CPU with no hardware extensions except the atomic | |
21343 | instructions. | |
21344 | ||
21345 | @item hs34 | |
21346 | Compile for ARC HS34 CPU. | |
21347 | ||
21348 | @item hs38 | |
21349 | Compile for ARC HS38 CPU. | |
21350 | ||
21351 | @item hs38_linux | |
21352 | Compile for ARC HS38 CPU with all hardware extensions on. | |
21353 | ||
21354 | @item hs4x | |
21355 | Compile for ARC HS4x CPU. | |
21356 | ||
21357 | @item hs4xd | |
21358 | Compile for ARC HS4xD CPU. | |
21359 | ||
21360 | @item hs4x_rel31 | |
21361 | Compile for ARC HS4x CPU release 3.10a. | |
21362 | ||
21363 | @item arc600_norm | |
21364 | Compile for ARC 600 CPU with @code{norm} instructions enabled. | |
21365 | ||
21366 | @item arc600_mul32x16 | |
21367 | Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply | |
21368 | instructions enabled. | |
21369 | ||
21370 | @item arc600_mul64 | |
21371 | Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family | |
21372 | instructions enabled. | |
21373 | ||
21374 | @item arc601_norm | |
21375 | Compile for ARC 601 CPU with @code{norm} instructions enabled. | |
21376 | ||
21377 | @item arc601_mul32x16 | |
21378 | Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply | |
21379 | instructions enabled. | |
21380 | ||
21381 | @item arc601_mul64 | |
21382 | Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family | |
21383 | instructions enabled. | |
21384 | ||
21385 | @item nps400 | |
21386 | Compile for ARC 700 on NPS400 chip. | |
21387 | ||
21388 | @item em_mini | |
21389 | Compile for ARC EM minimalist configuration featuring reduced register | |
21390 | set. | |
21391 | ||
21392 | @end table | |
21393 | ||
d77de738 | 21394 | @opindex mdpfp |
d77de738 | 21395 | @opindex mdpfp-compact |
ddf6fe37 AA |
21396 | @item -mdpfp |
21397 | @itemx -mdpfp-compact | |
d77de738 ML |
21398 | Generate double-precision FPX instructions, tuned for the compact |
21399 | implementation. | |
21400 | ||
d77de738 | 21401 | @opindex mdpfp-fast |
ddf6fe37 | 21402 | @item -mdpfp-fast |
d77de738 ML |
21403 | Generate double-precision FPX instructions, tuned for the fast |
21404 | implementation. | |
21405 | ||
d77de738 | 21406 | @opindex mno-dpfp-lrsr |
ddf6fe37 | 21407 | @item -mno-dpfp-lrsr |
d77de738 ML |
21408 | Disable @code{lr} and @code{sr} instructions from using FPX extension |
21409 | aux registers. | |
21410 | ||
d77de738 | 21411 | @opindex mea |
ddf6fe37 | 21412 | @item -mea |
d77de738 ML |
21413 | Generate extended arithmetic instructions. Currently only |
21414 | @code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are | |
21415 | supported. Only valid for @option{-mcpu=ARC700}. | |
21416 | ||
d77de738 ML |
21417 | @opindex mno-mpy |
21418 | @opindex mmpy | |
ddf6fe37 | 21419 | @item -mno-mpy |
d77de738 ML |
21420 | Do not generate @code{mpy}-family instructions for ARC700. This option is |
21421 | deprecated. | |
21422 | ||
d77de738 | 21423 | @opindex mmul32x16 |
ddf6fe37 | 21424 | @item -mmul32x16 |
d77de738 ML |
21425 | Generate 32x16-bit multiply and multiply-accumulate instructions. |
21426 | ||
d77de738 | 21427 | @opindex mmul64 |
ddf6fe37 | 21428 | @item -mmul64 |
d77de738 ML |
21429 | Generate @code{mul64} and @code{mulu64} instructions. |
21430 | Only valid for @option{-mcpu=ARC600}. | |
21431 | ||
d77de738 | 21432 | @opindex mnorm |
ddf6fe37 | 21433 | @item -mnorm |
d77de738 ML |
21434 | Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700} |
21435 | is in effect. | |
21436 | ||
d77de738 | 21437 | @opindex mspfp |
d77de738 | 21438 | @opindex mspfp-compact |
ddf6fe37 AA |
21439 | @item -mspfp |
21440 | @itemx -mspfp-compact | |
d77de738 ML |
21441 | Generate single-precision FPX instructions, tuned for the compact |
21442 | implementation. | |
21443 | ||
d77de738 | 21444 | @opindex mspfp-fast |
ddf6fe37 | 21445 | @item -mspfp-fast |
d77de738 ML |
21446 | Generate single-precision FPX instructions, tuned for the fast |
21447 | implementation. | |
21448 | ||
d77de738 | 21449 | @opindex msimd |
ddf6fe37 | 21450 | @item -msimd |
d77de738 ML |
21451 | Enable generation of ARC SIMD instructions via target-specific |
21452 | builtins. Only valid for @option{-mcpu=ARC700}. | |
21453 | ||
d77de738 | 21454 | @opindex msoft-float |
ddf6fe37 | 21455 | @item -msoft-float |
d77de738 ML |
21456 | This option ignored; it is provided for compatibility purposes only. |
21457 | Software floating-point code is emitted by default, and this default | |
21458 | can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or | |
21459 | @option{-mspfp-fast} for single precision, and @option{-mdpfp}, | |
21460 | @option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision. | |
21461 | ||
d77de738 | 21462 | @opindex mswap |
ddf6fe37 | 21463 | @item -mswap |
d77de738 ML |
21464 | Generate @code{swap} instructions. |
21465 | ||
d77de738 | 21466 | @opindex matomic |
ddf6fe37 | 21467 | @item -matomic |
d77de738 ML |
21468 | This enables use of the locked load/store conditional extension to implement |
21469 | atomic memory built-in functions. Not available for ARC 6xx or ARC | |
21470 | EM cores. | |
21471 | ||
d77de738 | 21472 | @opindex mdiv-rem |
ddf6fe37 | 21473 | @item -mdiv-rem |
d77de738 ML |
21474 | Enable @code{div} and @code{rem} instructions for ARCv2 cores. |
21475 | ||
d77de738 | 21476 | @opindex mcode-density |
ddf6fe37 | 21477 | @item -mcode-density |
d77de738 ML |
21478 | Enable code density instructions for ARC EM. |
21479 | This option is on by default for ARC HS. | |
21480 | ||
d77de738 | 21481 | @opindex mll64 |
ddf6fe37 | 21482 | @item -mll64 |
d77de738 ML |
21483 | Enable double load/store operations for ARC HS cores. |
21484 | ||
d77de738 | 21485 | @opindex mtp-regno |
ddf6fe37 | 21486 | @item -mtp-regno=@var{regno} |
d77de738 ML |
21487 | Specify thread pointer register number. |
21488 | ||
d77de738 | 21489 | @opindex mmpy-option |
ddf6fe37 | 21490 | @item -mmpy-option=@var{multo} |
d77de738 ML |
21491 | Compile ARCv2 code with a multiplier design option. You can specify |
21492 | the option using either a string or numeric value for @var{multo}. | |
21493 | @samp{wlh1} is the default value. The recognized values are: | |
21494 | ||
21495 | @table @samp | |
21496 | @item 0 | |
21497 | @itemx none | |
21498 | No multiplier available. | |
21499 | ||
21500 | @item 1 | |
21501 | @itemx w | |
21502 | 16x16 multiplier, fully pipelined. | |
21503 | The following instructions are enabled: @code{mpyw} and @code{mpyuw}. | |
21504 | ||
21505 | @item 2 | |
21506 | @itemx wlh1 | |
21507 | 32x32 multiplier, fully | |
21508 | pipelined (1 stage). The following instructions are additionally | |
21509 | enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21510 | ||
21511 | @item 3 | |
21512 | @itemx wlh2 | |
21513 | 32x32 multiplier, fully pipelined | |
21514 | (2 stages). The following instructions are additionally enabled: @code{mpy}, | |
21515 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21516 | ||
21517 | @item 4 | |
21518 | @itemx wlh3 | |
21519 | Two 16x16 multipliers, blocking, | |
21520 | sequential. The following instructions are additionally enabled: @code{mpy}, | |
21521 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21522 | ||
21523 | @item 5 | |
21524 | @itemx wlh4 | |
21525 | One 16x16 multiplier, blocking, | |
21526 | sequential. The following instructions are additionally enabled: @code{mpy}, | |
21527 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21528 | ||
21529 | @item 6 | |
21530 | @itemx wlh5 | |
21531 | One 32x4 multiplier, blocking, | |
21532 | sequential. The following instructions are additionally enabled: @code{mpy}, | |
21533 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21534 | ||
21535 | @item 7 | |
21536 | @itemx plus_dmpy | |
21537 | ARC HS SIMD support. | |
21538 | ||
21539 | @item 8 | |
21540 | @itemx plus_macd | |
21541 | ARC HS SIMD support. | |
21542 | ||
21543 | @item 9 | |
21544 | @itemx plus_qmacw | |
21545 | ARC HS SIMD support. | |
21546 | ||
21547 | @end table | |
21548 | ||
21549 | This option is only available for ARCv2 cores@. | |
21550 | ||
d77de738 | 21551 | @opindex mfpu |
ddf6fe37 | 21552 | @item -mfpu=@var{fpu} |
d77de738 ML |
21553 | Enables support for specific floating-point hardware extensions for ARCv2 |
21554 | cores. Supported values for @var{fpu} are: | |
21555 | ||
21556 | @table @samp | |
21557 | ||
21558 | @item fpus | |
21559 | Enables support for single-precision floating-point hardware | |
21560 | extensions@. | |
21561 | ||
21562 | @item fpud | |
21563 | Enables support for double-precision floating-point hardware | |
21564 | extensions. The single-precision floating-point extension is also | |
21565 | enabled. Not available for ARC EM@. | |
21566 | ||
21567 | @item fpuda | |
21568 | Enables support for double-precision floating-point hardware | |
21569 | extensions using double-precision assist instructions. The single-precision | |
21570 | floating-point extension is also enabled. This option is | |
21571 | only available for ARC EM@. | |
21572 | ||
21573 | @item fpuda_div | |
21574 | Enables support for double-precision floating-point hardware | |
21575 | extensions using double-precision assist instructions. | |
21576 | The single-precision floating-point, square-root, and divide | |
21577 | extensions are also enabled. This option is | |
21578 | only available for ARC EM@. | |
21579 | ||
21580 | @item fpuda_fma | |
21581 | Enables support for double-precision floating-point hardware | |
21582 | extensions using double-precision assist instructions. | |
21583 | The single-precision floating-point and fused multiply and add | |
21584 | hardware extensions are also enabled. This option is | |
21585 | only available for ARC EM@. | |
21586 | ||
21587 | @item fpuda_all | |
21588 | Enables support for double-precision floating-point hardware | |
21589 | extensions using double-precision assist instructions. | |
21590 | All single-precision floating-point hardware extensions are also | |
21591 | enabled. This option is only available for ARC EM@. | |
21592 | ||
21593 | @item fpus_div | |
21594 | Enables support for single-precision floating-point, square-root and divide | |
21595 | hardware extensions@. | |
21596 | ||
21597 | @item fpud_div | |
21598 | Enables support for double-precision floating-point, square-root and divide | |
21599 | hardware extensions. This option | |
21600 | includes option @samp{fpus_div}. Not available for ARC EM@. | |
21601 | ||
21602 | @item fpus_fma | |
21603 | Enables support for single-precision floating-point and | |
21604 | fused multiply and add hardware extensions@. | |
21605 | ||
21606 | @item fpud_fma | |
21607 | Enables support for double-precision floating-point and | |
21608 | fused multiply and add hardware extensions. This option | |
21609 | includes option @samp{fpus_fma}. Not available for ARC EM@. | |
21610 | ||
21611 | @item fpus_all | |
21612 | Enables support for all single-precision floating-point hardware | |
21613 | extensions@. | |
21614 | ||
21615 | @item fpud_all | |
21616 | Enables support for all single- and double-precision floating-point | |
21617 | hardware extensions. Not available for ARC EM@. | |
21618 | ||
21619 | @end table | |
21620 | ||
d77de738 | 21621 | @opindex mirq-ctrl-saved |
ddf6fe37 | 21622 | @item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count} |
d77de738 ML |
21623 | Specifies general-purposes registers that the processor automatically |
21624 | saves/restores on interrupt entry and exit. @var{register-range} is | |
21625 | specified as two registers separated by a dash. The register range | |
21626 | always starts with @code{r0}, the upper limit is @code{fp} register. | |
21627 | @var{blink} and @var{lp_count} are optional. This option is only | |
21628 | valid for ARC EM and ARC HS cores. | |
21629 | ||
d77de738 | 21630 | @opindex mrgf-banked-regs |
ddf6fe37 | 21631 | @item -mrgf-banked-regs=@var{number} |
d77de738 ML |
21632 | Specifies the number of registers replicated in second register bank |
21633 | on entry to fast interrupt. Fast interrupts are interrupts with the | |
21634 | highest priority level P0. These interrupts save only PC and STATUS32 | |
21635 | registers to avoid memory transactions during interrupt entry and exit | |
21636 | sequences. Use this option when you are using fast interrupts in an | |
21637 | ARC V2 family processor. Permitted values are 4, 8, 16, and 32. | |
21638 | ||
d77de738 | 21639 | @opindex mlpc-width |
ddf6fe37 | 21640 | @item -mlpc-width=@var{width} |
d77de738 ML |
21641 | Specify the width of the @code{lp_count} register. Valid values for |
21642 | @var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is | |
21643 | fixed to 32 bits. If the width is less than 32, the compiler does not | |
21644 | attempt to transform loops in your program to use the zero-delay loop | |
21645 | mechanism unless it is known that the @code{lp_count} register can | |
21646 | hold the required loop-counter value. Depending on the width | |
21647 | specified, the compiler and run-time library might continue to use the | |
21648 | loop mechanism for various needs. This option defines macro | |
21649 | @code{__ARC_LPC_WIDTH__} with the value of @var{width}. | |
21650 | ||
d77de738 | 21651 | @opindex mrf16 |
ddf6fe37 | 21652 | @item -mrf16 |
d77de738 ML |
21653 | This option instructs the compiler to generate code for a 16-entry |
21654 | register file. This option defines the @code{__ARC_RF16__} | |
21655 | preprocessor macro. | |
21656 | ||
d77de738 | 21657 | @opindex mbranch-index |
ddf6fe37 | 21658 | @item -mbranch-index |
d77de738 ML |
21659 | Enable use of @code{bi} or @code{bih} instructions to implement jump |
21660 | tables. | |
21661 | ||
21662 | @end table | |
21663 | ||
21664 | The following options are passed through to the assembler, and also | |
21665 | define preprocessor macro symbols. | |
21666 | ||
21667 | @c Flags used by the assembler, but for which we define preprocessor | |
21668 | @c macro symbols as well. | |
21669 | @table @gcctabopt | |
d77de738 | 21670 | @opindex mdsp-packa |
ddf6fe37 | 21671 | @item -mdsp-packa |
d77de738 ML |
21672 | Passed down to the assembler to enable the DSP Pack A extensions. |
21673 | Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is | |
21674 | deprecated. | |
21675 | ||
d77de738 | 21676 | @opindex mdvbf |
ddf6fe37 | 21677 | @item -mdvbf |
d77de738 ML |
21678 | Passed down to the assembler to enable the dual Viterbi butterfly |
21679 | extension. Also sets the preprocessor symbol @code{__Xdvbf}. This | |
21680 | option is deprecated. | |
21681 | ||
21682 | @c ARC700 4.10 extension instruction | |
d77de738 | 21683 | @opindex mlock |
ddf6fe37 | 21684 | @item -mlock |
d77de738 ML |
21685 | Passed down to the assembler to enable the locked load/store |
21686 | conditional extension. Also sets the preprocessor symbol | |
21687 | @code{__Xlock}. | |
21688 | ||
d77de738 | 21689 | @opindex mmac-d16 |
ddf6fe37 | 21690 | @item -mmac-d16 |
d77de738 ML |
21691 | Passed down to the assembler. Also sets the preprocessor symbol |
21692 | @code{__Xxmac_d16}. This option is deprecated. | |
21693 | ||
d77de738 | 21694 | @opindex mmac-24 |
ddf6fe37 | 21695 | @item -mmac-24 |
d77de738 ML |
21696 | Passed down to the assembler. Also sets the preprocessor symbol |
21697 | @code{__Xxmac_24}. This option is deprecated. | |
21698 | ||
21699 | @c ARC700 4.10 extension instruction | |
d77de738 | 21700 | @opindex mrtsc |
ddf6fe37 | 21701 | @item -mrtsc |
d77de738 ML |
21702 | Passed down to the assembler to enable the 64-bit time-stamp counter |
21703 | extension instruction. Also sets the preprocessor symbol | |
21704 | @code{__Xrtsc}. This option is deprecated. | |
21705 | ||
21706 | @c ARC700 4.10 extension instruction | |
d77de738 | 21707 | @opindex mswape |
ddf6fe37 | 21708 | @item -mswape |
d77de738 ML |
21709 | Passed down to the assembler to enable the swap byte ordering |
21710 | extension instruction. Also sets the preprocessor symbol | |
21711 | @code{__Xswape}. | |
21712 | ||
d77de738 | 21713 | @opindex mtelephony |
ddf6fe37 | 21714 | @item -mtelephony |
d77de738 ML |
21715 | Passed down to the assembler to enable dual- and single-operand |
21716 | instructions for telephony. Also sets the preprocessor symbol | |
21717 | @code{__Xtelephony}. This option is deprecated. | |
21718 | ||
d77de738 | 21719 | @opindex mxy |
ddf6fe37 | 21720 | @item -mxy |
d77de738 ML |
21721 | Passed down to the assembler to enable the XY memory extension. Also |
21722 | sets the preprocessor symbol @code{__Xxy}. | |
21723 | ||
21724 | @end table | |
21725 | ||
21726 | The following options control how the assembly code is annotated: | |
21727 | ||
21728 | @c Assembly annotation options | |
21729 | @table @gcctabopt | |
d77de738 | 21730 | @opindex misize |
ddf6fe37 | 21731 | @item -misize |
d77de738 ML |
21732 | Annotate assembler instructions with estimated addresses. |
21733 | ||
d77de738 | 21734 | @opindex mannotate-align |
ddf6fe37 | 21735 | @item -mannotate-align |
e4b19406 | 21736 | Does nothing. Preserved for backward compatibility. |
d77de738 ML |
21737 | |
21738 | @end table | |
21739 | ||
21740 | The following options are passed through to the linker: | |
21741 | ||
21742 | @c options passed through to the linker | |
21743 | @table @gcctabopt | |
d77de738 | 21744 | @opindex marclinux |
ddf6fe37 | 21745 | @item -marclinux |
d77de738 ML |
21746 | Passed through to the linker, to specify use of the @code{arclinux} emulation. |
21747 | This option is enabled by default in tool chains built for | |
21748 | @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets | |
21749 | when profiling is not requested. | |
21750 | ||
d77de738 | 21751 | @opindex marclinux_prof |
ddf6fe37 | 21752 | @item -marclinux_prof |
d77de738 ML |
21753 | Passed through to the linker, to specify use of the |
21754 | @code{arclinux_prof} emulation. This option is enabled by default in | |
21755 | tool chains built for @w{@code{arc-linux-uclibc}} and | |
21756 | @w{@code{arceb-linux-uclibc}} targets when profiling is requested. | |
21757 | ||
21758 | @end table | |
21759 | ||
21760 | The following options control the semantics of generated code: | |
21761 | ||
21762 | @c semantically relevant code generation options | |
21763 | @table @gcctabopt | |
d77de738 | 21764 | @opindex mlong-calls |
ddf6fe37 | 21765 | @item -mlong-calls |
d77de738 ML |
21766 | Generate calls as register indirect calls, thus providing access |
21767 | to the full 32-bit address range. | |
21768 | ||
d77de738 | 21769 | @opindex mmedium-calls |
ddf6fe37 | 21770 | @item -mmedium-calls |
d77de738 ML |
21771 | Don't use less than 25-bit addressing range for calls, which is the |
21772 | offset available for an unconditional branch-and-link | |
21773 | instruction. Conditional execution of function calls is suppressed, to | |
21774 | allow use of the 25-bit range, rather than the 21-bit range with | |
21775 | conditional branch-and-link. This is the default for tool chains built | |
21776 | for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets. | |
21777 | ||
d77de738 | 21778 | @opindex G |
ddf6fe37 | 21779 | @item -G @var{num} |
d77de738 ML |
21780 | Put definitions of externally-visible data in a small data section if |
21781 | that data is no bigger than @var{num} bytes. The default value of | |
21782 | @var{num} is 4 for any ARC configuration, or 8 when we have double | |
21783 | load/store operations. | |
21784 | ||
d77de738 ML |
21785 | @opindex mno-sdata |
21786 | @opindex msdata | |
ddf6fe37 | 21787 | @item -mno-sdata |
d77de738 ML |
21788 | Do not generate sdata references. This is the default for tool chains |
21789 | built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} | |
21790 | targets. | |
21791 | ||
d77de738 | 21792 | @opindex mvolatile-cache |
ddf6fe37 | 21793 | @item -mvolatile-cache |
d77de738 ML |
21794 | Use ordinarily cached memory accesses for volatile references. This is the |
21795 | default. | |
21796 | ||
d77de738 ML |
21797 | @opindex mno-volatile-cache |
21798 | @opindex mvolatile-cache | |
ddf6fe37 | 21799 | @item -mno-volatile-cache |
d77de738 ML |
21800 | Enable cache bypass for volatile references. |
21801 | ||
21802 | @end table | |
21803 | ||
21804 | The following options fine tune code generation: | |
21805 | @c code generation tuning options | |
21806 | @table @gcctabopt | |
d77de738 | 21807 | @opindex malign-call |
ddf6fe37 | 21808 | @item -malign-call |
d77de738 ML |
21809 | Does nothing. Preserved for backward compatibility. |
21810 | ||
d77de738 | 21811 | @opindex mauto-modify-reg |
ddf6fe37 | 21812 | @item -mauto-modify-reg |
d77de738 ML |
21813 | Enable the use of pre/post modify with register displacement. |
21814 | ||
d77de738 | 21815 | @opindex mbbit-peephole |
ddf6fe37 | 21816 | @item -mbbit-peephole |
07f7615c | 21817 | Does nothing. Preserved for backward compatibility. |
d77de738 | 21818 | |
d77de738 | 21819 | @opindex mno-brcc |
ddf6fe37 | 21820 | @item -mno-brcc |
d77de738 ML |
21821 | This option disables a target-specific pass in @file{arc_reorg} to |
21822 | generate compare-and-branch (@code{br@var{cc}}) instructions. | |
21823 | It has no effect on | |
21824 | generation of these instructions driven by the combiner pass. | |
21825 | ||
d77de738 | 21826 | @opindex mcase-vector-pcrel |
ddf6fe37 | 21827 | @item -mcase-vector-pcrel |
d77de738 ML |
21828 | Use PC-relative switch case tables to enable case table shortening. |
21829 | This is the default for @option{-Os}. | |
21830 | ||
d77de738 | 21831 | @opindex mcompact-casesi |
ddf6fe37 | 21832 | @item -mcompact-casesi |
d77de738 ML |
21833 | Enable compact @code{casesi} pattern. This is the default for @option{-Os}, |
21834 | and only available for ARCv1 cores. This option is deprecated. | |
21835 | ||
d77de738 | 21836 | @opindex mno-cond-exec |
ddf6fe37 | 21837 | @item -mno-cond-exec |
d77de738 ML |
21838 | Disable the ARCompact-specific pass to generate conditional |
21839 | execution instructions. | |
21840 | ||
21841 | Due to delay slot scheduling and interactions between operand numbers, | |
21842 | literal sizes, instruction lengths, and the support for conditional execution, | |
21843 | the target-independent pass to generate conditional execution is often lacking, | |
21844 | so the ARC port has kept a special pass around that tries to find more | |
21845 | conditional execution generation opportunities after register allocation, | |
21846 | branch shortening, and delay slot scheduling have been done. This pass | |
21847 | generally, but not always, improves performance and code size, at the cost of | |
21848 | extra compilation time, which is why there is an option to switch it off. | |
21849 | If you have a problem with call instructions exceeding their allowable | |
21850 | offset range because they are conditionalized, you should consider using | |
21851 | @option{-mmedium-calls} instead. | |
21852 | ||
d77de738 | 21853 | @opindex mearly-cbranchsi |
ddf6fe37 | 21854 | @item -mearly-cbranchsi |
d77de738 ML |
21855 | Enable pre-reload use of the @code{cbranchsi} pattern. |
21856 | ||
d77de738 | 21857 | @opindex mexpand-adddi |
ddf6fe37 | 21858 | @item -mexpand-adddi |
d77de738 ML |
21859 | Expand @code{adddi3} and @code{subdi3} at RTL generation time into |
21860 | @code{add.f}, @code{adc} etc. This option is deprecated. | |
21861 | ||
d77de738 | 21862 | @opindex mindexed-loads |
ddf6fe37 | 21863 | @item -mindexed-loads |
d77de738 ML |
21864 | Enable the use of indexed loads. This can be problematic because some |
21865 | optimizers then assume that indexed stores exist, which is not | |
21866 | the case. | |
21867 | ||
d77de738 | 21868 | @opindex mlra |
ddf6fe37 | 21869 | @item -mlra |
d77de738 ML |
21870 | Enable Local Register Allocation. This is still experimental for ARC, |
21871 | so by default the compiler uses standard reload | |
21872 | (i.e.@: @option{-mno-lra}). | |
21873 | ||
d77de738 | 21874 | @opindex mlra-priority-none |
ddf6fe37 | 21875 | @item -mlra-priority-none |
d77de738 ML |
21876 | Don't indicate any priority for target registers. |
21877 | ||
d77de738 | 21878 | @opindex mlra-priority-compact |
ddf6fe37 | 21879 | @item -mlra-priority-compact |
d77de738 ML |
21880 | Indicate target register priority for r0..r3 / r12..r15. |
21881 | ||
d77de738 | 21882 | @opindex mlra-priority-noncompact |
ddf6fe37 | 21883 | @item -mlra-priority-noncompact |
d77de738 ML |
21884 | Reduce target register priority for r0..r3 / r12..r15. |
21885 | ||
d77de738 | 21886 | @opindex mmillicode |
ddf6fe37 | 21887 | @item -mmillicode |
d77de738 ML |
21888 | When optimizing for size (using @option{-Os}), prologues and epilogues |
21889 | that have to save or restore a large number of registers are often | |
21890 | shortened by using call to a special function in libgcc; this is | |
21891 | referred to as a @emph{millicode} call. As these calls can pose | |
21892 | performance issues, and/or cause linking issues when linking in a | |
21893 | nonstandard way, this option is provided to turn on or off millicode | |
21894 | call generation. | |
21895 | ||
d77de738 | 21896 | @opindex mcode-density-frame |
ddf6fe37 | 21897 | @item -mcode-density-frame |
d77de738 ML |
21898 | This option enable the compiler to emit @code{enter} and @code{leave} |
21899 | instructions. These instructions are only valid for CPUs with | |
21900 | code-density feature. | |
21901 | ||
d77de738 | 21902 | @opindex mmixed-code |
ddf6fe37 | 21903 | @item -mmixed-code |
d77de738 ML |
21904 | Does nothing. Preserved for backward compatibility. |
21905 | ||
d77de738 | 21906 | @opindex mq-class |
ddf6fe37 | 21907 | @item -mq-class |
d77de738 ML |
21908 | Ths option is deprecated. Enable @samp{q} instruction alternatives. |
21909 | This is the default for @option{-Os}. | |
21910 | ||
d77de738 | 21911 | @opindex mRcq |
ddf6fe37 | 21912 | @item -mRcq |
d77de738 ML |
21913 | Does nothing. Preserved for backward compatibility. |
21914 | ||
d77de738 | 21915 | @opindex mRcw |
ddf6fe37 | 21916 | @item -mRcw |
d77de738 ML |
21917 | Does nothing. Preserved for backward compatibility. |
21918 | ||
d77de738 | 21919 | @opindex msize-level |
ddf6fe37 | 21920 | @item -msize-level=@var{level} |
d77de738 ML |
21921 | Fine-tune size optimization with regards to instruction lengths and alignment. |
21922 | The recognized values for @var{level} are: | |
21923 | @table @samp | |
21924 | @item 0 | |
21925 | No size optimization. This level is deprecated and treated like @samp{1}. | |
21926 | ||
21927 | @item 1 | |
21928 | Short instructions are used opportunistically. | |
21929 | ||
21930 | @item 2 | |
21931 | In addition, alignment of loops and of code after barriers are dropped. | |
21932 | ||
21933 | @item 3 | |
21934 | In addition, optional data alignment is dropped, and the option @option{Os} is enabled. | |
21935 | ||
21936 | @end table | |
21937 | ||
21938 | This defaults to @samp{3} when @option{-Os} is in effect. Otherwise, | |
21939 | the behavior when this is not set is equivalent to level @samp{1}. | |
21940 | ||
d77de738 | 21941 | @opindex mtune |
ddf6fe37 | 21942 | @item -mtune=@var{cpu} |
d77de738 ML |
21943 | Set instruction scheduling parameters for @var{cpu}, overriding any implied |
21944 | by @option{-mcpu=}. | |
21945 | ||
21946 | Supported values for @var{cpu} are | |
21947 | ||
21948 | @table @samp | |
21949 | @item ARC600 | |
21950 | Tune for ARC600 CPU. | |
21951 | ||
21952 | @item ARC601 | |
21953 | Tune for ARC601 CPU. | |
21954 | ||
21955 | @item ARC700 | |
21956 | Tune for ARC700 CPU with standard multiplier block. | |
21957 | ||
21958 | @item ARC700-xmac | |
21959 | Tune for ARC700 CPU with XMAC block. | |
21960 | ||
21961 | @item ARC725D | |
21962 | Tune for ARC725D CPU. | |
21963 | ||
21964 | @item ARC750D | |
21965 | Tune for ARC750D CPU. | |
21966 | ||
21967 | @item core3 | |
21968 | Tune for ARCv2 core3 type CPU. This option enable usage of | |
21969 | @code{dbnz} instruction. | |
21970 | ||
21971 | @item release31a | |
21972 | Tune for ARC4x release 3.10a. | |
21973 | ||
21974 | @end table | |
21975 | ||
d77de738 | 21976 | @opindex mmultcost |
ddf6fe37 | 21977 | @item -mmultcost=@var{num} |
d77de738 ML |
21978 | Cost to assume for a multiply instruction, with @samp{4} being equal to a |
21979 | normal instruction. | |
21980 | ||
d77de738 | 21981 | @opindex munalign-prob-threshold |
ddf6fe37 | 21982 | @item -munalign-prob-threshold=@var{probability} |
d77de738 ML |
21983 | Does nothing. Preserved for backward compatibility. |
21984 | ||
21985 | @end table | |
21986 | ||
21987 | The following options are maintained for backward compatibility, but | |
21988 | are now deprecated and will be removed in a future release: | |
21989 | ||
21990 | @c Deprecated options | |
21991 | @table @gcctabopt | |
21992 | ||
d77de738 | 21993 | @opindex margonaut |
ddf6fe37 | 21994 | @item -margonaut |
d77de738 ML |
21995 | Obsolete FPX. |
21996 | ||
d77de738 | 21997 | @opindex mbig-endian |
d77de738 | 21998 | @opindex EB |
ddf6fe37 AA |
21999 | @item -mbig-endian |
22000 | @itemx -EB | |
d77de738 ML |
22001 | Compile code for big-endian targets. Use of these options is now |
22002 | deprecated. Big-endian code is supported by configuring GCC to build | |
22003 | @w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets, | |
22004 | for which big endian is the default. | |
22005 | ||
d77de738 | 22006 | @opindex mlittle-endian |
d77de738 | 22007 | @opindex EL |
ddf6fe37 AA |
22008 | @item -mlittle-endian |
22009 | @itemx -EL | |
d77de738 ML |
22010 | Compile code for little-endian targets. Use of these options is now |
22011 | deprecated. Little-endian code is supported by configuring GCC to build | |
22012 | @w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets, | |
22013 | for which little endian is the default. | |
22014 | ||
d77de738 | 22015 | @opindex mbarrel_shifter |
ddf6fe37 | 22016 | @item -mbarrel_shifter |
d77de738 ML |
22017 | Replaced by @option{-mbarrel-shifter}. |
22018 | ||
d77de738 | 22019 | @opindex mdpfp_compact |
ddf6fe37 | 22020 | @item -mdpfp_compact |
d77de738 ML |
22021 | Replaced by @option{-mdpfp-compact}. |
22022 | ||
d77de738 | 22023 | @opindex mdpfp_fast |
ddf6fe37 | 22024 | @item -mdpfp_fast |
d77de738 ML |
22025 | Replaced by @option{-mdpfp-fast}. |
22026 | ||
d77de738 | 22027 | @opindex mdsp_packa |
ddf6fe37 | 22028 | @item -mdsp_packa |
d77de738 ML |
22029 | Replaced by @option{-mdsp-packa}. |
22030 | ||
d77de738 | 22031 | @opindex mEA |
ddf6fe37 | 22032 | @item -mEA |
d77de738 ML |
22033 | Replaced by @option{-mea}. |
22034 | ||
d77de738 | 22035 | @opindex mmac_24 |
ddf6fe37 | 22036 | @item -mmac_24 |
d77de738 ML |
22037 | Replaced by @option{-mmac-24}. |
22038 | ||
d77de738 | 22039 | @opindex mmac_d16 |
ddf6fe37 | 22040 | @item -mmac_d16 |
d77de738 ML |
22041 | Replaced by @option{-mmac-d16}. |
22042 | ||
d77de738 | 22043 | @opindex mspfp_compact |
ddf6fe37 | 22044 | @item -mspfp_compact |
d77de738 ML |
22045 | Replaced by @option{-mspfp-compact}. |
22046 | ||
d77de738 | 22047 | @opindex mspfp_fast |
ddf6fe37 | 22048 | @item -mspfp_fast |
d77de738 ML |
22049 | Replaced by @option{-mspfp-fast}. |
22050 | ||
d77de738 | 22051 | @opindex mtune |
ddf6fe37 | 22052 | @item -mtune=@var{cpu} |
d77de738 ML |
22053 | Values @samp{arc600}, @samp{arc601}, @samp{arc700} and |
22054 | @samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600}, | |
22055 | @samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively. | |
22056 | ||
d77de738 | 22057 | @opindex multcost |
ddf6fe37 | 22058 | @item -multcost=@var{num} |
d77de738 ML |
22059 | Replaced by @option{-mmultcost}. |
22060 | ||
22061 | @end table | |
22062 | ||
22063 | @node ARM Options | |
22064 | @subsection ARM Options | |
22065 | @cindex ARM options | |
22066 | ||
22067 | These @samp{-m} options are defined for the ARM port: | |
22068 | ||
22069 | @table @gcctabopt | |
d77de738 | 22070 | @opindex mabi |
ddf6fe37 | 22071 | @item -mabi=@var{name} |
d77de738 ML |
22072 | Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu}, |
22073 | @samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}. | |
22074 | ||
d77de738 | 22075 | @opindex mapcs-frame |
ddf6fe37 | 22076 | @item -mapcs-frame |
d77de738 ML |
22077 | Generate a stack frame that is compliant with the ARM Procedure Call |
22078 | Standard for all functions, even if this is not strictly necessary for | |
22079 | correct execution of the code. Specifying @option{-fomit-frame-pointer} | |
22080 | with this option causes the stack frames not to be generated for | |
22081 | leaf functions. The default is @option{-mno-apcs-frame}. | |
22082 | This option is deprecated. | |
22083 | ||
d77de738 | 22084 | @opindex mapcs |
ddf6fe37 | 22085 | @item -mapcs |
d77de738 ML |
22086 | This is a synonym for @option{-mapcs-frame} and is deprecated. |
22087 | ||
22088 | @ignore | |
22089 | @c not currently implemented | |
d77de738 | 22090 | @opindex mapcs-stack-check |
ddf6fe37 | 22091 | @item -mapcs-stack-check |
d77de738 ML |
22092 | Generate code to check the amount of stack space available upon entry to |
22093 | every function (that actually uses some stack space). If there is | |
22094 | insufficient space available then either the function | |
22095 | @code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is | |
22096 | called, depending upon the amount of stack space required. The runtime | |
22097 | system is required to provide these functions. The default is | |
22098 | @option{-mno-apcs-stack-check}, since this produces smaller code. | |
22099 | ||
22100 | @c not currently implemented | |
d77de738 | 22101 | @opindex mapcs-reentrant |
ddf6fe37 | 22102 | @item -mapcs-reentrant |
d77de738 ML |
22103 | Generate reentrant, position-independent code. The default is |
22104 | @option{-mno-apcs-reentrant}. | |
22105 | @end ignore | |
22106 | ||
d77de738 | 22107 | @opindex mthumb-interwork |
ddf6fe37 | 22108 | @item -mthumb-interwork |
d77de738 ML |
22109 | Generate code that supports calling between the ARM and Thumb |
22110 | instruction sets. Without this option, on pre-v5 architectures, the | |
22111 | two instruction sets cannot be reliably used inside one program. The | |
22112 | default is @option{-mno-thumb-interwork}, since slightly larger code | |
22113 | is generated when @option{-mthumb-interwork} is specified. In AAPCS | |
22114 | configurations this option is meaningless. | |
22115 | ||
d77de738 ML |
22116 | @opindex mno-sched-prolog |
22117 | @opindex msched-prolog | |
ddf6fe37 | 22118 | @item -mno-sched-prolog |
d77de738 ML |
22119 | Prevent the reordering of instructions in the function prologue, or the |
22120 | merging of those instruction with the instructions in the function's | |
22121 | body. This means that all functions start with a recognizable set | |
22122 | of instructions (or in fact one of a choice from a small set of | |
22123 | different function prologues), and this information can be used to | |
22124 | locate the start of functions inside an executable piece of code. The | |
22125 | default is @option{-msched-prolog}. | |
22126 | ||
d77de738 | 22127 | @opindex mfloat-abi |
ddf6fe37 | 22128 | @item -mfloat-abi=@var{name} |
d77de738 ML |
22129 | Specifies which floating-point ABI to use. Permissible values |
22130 | are: @samp{soft}, @samp{softfp} and @samp{hard}. | |
22131 | ||
22132 | Specifying @samp{soft} causes GCC to generate output containing | |
22133 | library calls for floating-point operations. | |
22134 | @samp{softfp} allows the generation of code using hardware floating-point | |
22135 | instructions, but still uses the soft-float calling conventions. | |
22136 | @samp{hard} allows generation of floating-point instructions | |
22137 | and uses FPU-specific calling conventions. | |
22138 | ||
22139 | The default depends on the specific target configuration. Note that | |
22140 | the hard-float and soft-float ABIs are not link-compatible; you must | |
22141 | compile your entire program with the same ABI, and link with a | |
22142 | compatible set of libraries. | |
22143 | ||
d77de738 | 22144 | @opindex mgeneral-regs-only |
ddf6fe37 | 22145 | @item -mgeneral-regs-only |
d77de738 ML |
22146 | Generate code which uses only the general-purpose registers. This will prevent |
22147 | the compiler from using floating-point and Advanced SIMD registers but will not | |
22148 | impose any restrictions on the assembler. | |
22149 | ||
d77de738 | 22150 | @opindex mlittle-endian |
ddf6fe37 | 22151 | @item -mlittle-endian |
d77de738 ML |
22152 | Generate code for a processor running in little-endian mode. This is |
22153 | the default for all standard configurations. | |
22154 | ||
d77de738 | 22155 | @opindex mbig-endian |
ddf6fe37 | 22156 | @item -mbig-endian |
d77de738 ML |
22157 | Generate code for a processor running in big-endian mode; the default is |
22158 | to compile code for a little-endian processor. | |
22159 | ||
ddf6fe37 | 22160 | @opindex mbe8 |
d77de738 ML |
22161 | @item -mbe8 |
22162 | @itemx -mbe32 | |
d77de738 ML |
22163 | When linking a big-endian image select between BE8 and BE32 formats. |
22164 | The option has no effect for little-endian images and is ignored. The | |
22165 | default is dependent on the selected target architecture. For ARMv6 | |
22166 | and later architectures the default is BE8, for older architectures | |
22167 | the default is BE32. BE32 format has been deprecated by ARM. | |
22168 | ||
d77de738 | 22169 | @opindex march |
ddf6fe37 | 22170 | @item -march=@var{name}@r{[}+extension@dots{}@r{]} |
d77de738 ML |
22171 | This specifies the name of the target ARM architecture. GCC uses this |
22172 | name to determine what kind of instructions it can emit when generating | |
22173 | assembly code. This option can be used in conjunction with or instead | |
22174 | of the @option{-mcpu=} option. | |
22175 | ||
22176 | Permissible names are: | |
22177 | @samp{armv4t}, | |
22178 | @samp{armv5t}, @samp{armv5te}, | |
22179 | @samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2}, | |
22180 | @samp{armv6z}, @samp{armv6zk}, | |
22181 | @samp{armv7}, @samp{armv7-a}, @samp{armv7ve}, | |
22182 | @samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a}, | |
22183 | @samp{armv8.4-a}, | |
22184 | @samp{armv8.5-a}, | |
22185 | @samp{armv8.6-a}, | |
22186 | @samp{armv9-a}, | |
22187 | @samp{armv7-r}, | |
22188 | @samp{armv8-r}, | |
22189 | @samp{armv6-m}, @samp{armv6s-m}, | |
22190 | @samp{armv7-m}, @samp{armv7e-m}, | |
22191 | @samp{armv8-m.base}, @samp{armv8-m.main}, | |
22192 | @samp{armv8.1-m.main}, | |
22193 | @samp{armv9-a}, | |
22194 | @samp{iwmmxt} and @samp{iwmmxt2}. | |
22195 | ||
22196 | Additionally, the following architectures, which lack support for the | |
22197 | Thumb execution state, are recognized but support is deprecated: @samp{armv4}. | |
22198 | ||
22199 | Many of the architectures support extensions. These can be added by | |
22200 | appending @samp{+@var{extension}} to the architecture name. Extension | |
22201 | options are processed in order and capabilities accumulate. An extension | |
22202 | will also enable any necessary base extensions | |
22203 | upon which it depends. For example, the @samp{+crypto} extension | |
22204 | will always enable the @samp{+simd} extension. The exception to the | |
22205 | additive construction is for extensions that are prefixed with | |
22206 | @samp{+no@dots{}}: these extensions disable the specified option and | |
22207 | any other extensions that may depend on the presence of that | |
22208 | extension. | |
22209 | ||
22210 | For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to | |
22211 | writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is | |
22212 | entirely disabled by the @samp{+nofp} option that follows it. | |
22213 | ||
22214 | Most extension names are generically named, but have an effect that is | |
22215 | dependent upon the architecture to which it is applied. For example, | |
22216 | the @samp{+simd} option can be applied to both @samp{armv7-a} and | |
22217 | @samp{armv8-a} architectures, but will enable the original ARMv7-A | |
22218 | Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A | |
22219 | variant for @samp{armv8-a}. | |
22220 | ||
22221 | The table below lists the supported extensions for each architecture. | |
22222 | Architectures not mentioned do not support any extensions. | |
22223 | ||
22224 | @table @samp | |
22225 | @item armv5te | |
22226 | @itemx armv6 | |
22227 | @itemx armv6j | |
22228 | @itemx armv6k | |
22229 | @itemx armv6kz | |
22230 | @itemx armv6t2 | |
22231 | @itemx armv6z | |
22232 | @itemx armv6zk | |
22233 | @table @samp | |
22234 | @item +fp | |
22235 | The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be | |
22236 | used as an alias for this extension. | |
22237 | ||
22238 | @item +nofp | |
22239 | Disable the floating-point instructions. | |
22240 | @end table | |
22241 | ||
22242 | @item armv7 | |
22243 | The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures. | |
22244 | @table @samp | |
22245 | @item +fp | |
22246 | The VFPv3 floating-point instructions, with 16 double-precision | |
22247 | registers. The extension @samp{+vfpv3-d16} can be used as an alias | |
22248 | for this extension. Note that floating-point is not supported by the | |
22249 | base ARMv7-M architecture, but is compatible with both the ARMv7-A and | |
22250 | ARMv7-R architectures. | |
22251 | ||
22252 | @item +nofp | |
22253 | Disable the floating-point instructions. | |
22254 | @end table | |
22255 | ||
22256 | @item armv7-a | |
22257 | @table @samp | |
22258 | @item +mp | |
22259 | The multiprocessing extension. | |
22260 | ||
22261 | @item +sec | |
22262 | The security extension. | |
22263 | ||
22264 | @item +fp | |
22265 | The VFPv3 floating-point instructions, with 16 double-precision | |
22266 | registers. The extension @samp{+vfpv3-d16} can be used as an alias | |
22267 | for this extension. | |
22268 | ||
22269 | @item +simd | |
22270 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions. | |
22271 | The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases | |
22272 | for this extension. | |
22273 | ||
22274 | @item +vfpv3 | |
22275 | The VFPv3 floating-point instructions, with 32 double-precision | |
22276 | registers. | |
22277 | ||
22278 | @item +vfpv3-d16-fp16 | |
22279 | The VFPv3 floating-point instructions, with 16 double-precision | |
22280 | registers and the half-precision floating-point conversion operations. | |
22281 | ||
22282 | @item +vfpv3-fp16 | |
22283 | The VFPv3 floating-point instructions, with 32 double-precision | |
22284 | registers and the half-precision floating-point conversion operations. | |
22285 | ||
22286 | @item +vfpv4-d16 | |
22287 | The VFPv4 floating-point instructions, with 16 double-precision | |
22288 | registers. | |
22289 | ||
22290 | @item +vfpv4 | |
22291 | The VFPv4 floating-point instructions, with 32 double-precision | |
22292 | registers. | |
22293 | ||
22294 | @item +neon-fp16 | |
22295 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with | |
22296 | the half-precision floating-point conversion operations. | |
22297 | ||
22298 | @item +neon-vfpv4 | |
22299 | The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. | |
22300 | ||
22301 | @item +nosimd | |
22302 | Disable the Advanced SIMD instructions (does not disable floating point). | |
22303 | ||
22304 | @item +nofp | |
22305 | Disable the floating-point and Advanced SIMD instructions. | |
22306 | @end table | |
22307 | ||
22308 | @item armv7ve | |
22309 | The extended version of the ARMv7-A architecture with support for | |
22310 | virtualization. | |
22311 | @table @samp | |
22312 | @item +fp | |
22313 | The VFPv4 floating-point instructions, with 16 double-precision registers. | |
22314 | The extension @samp{+vfpv4-d16} can be used as an alias for this extension. | |
22315 | ||
22316 | @item +simd | |
22317 | The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The | |
22318 | extension @samp{+neon-vfpv4} can be used as an alias for this extension. | |
22319 | ||
22320 | @item +vfpv3-d16 | |
22321 | The VFPv3 floating-point instructions, with 16 double-precision | |
22322 | registers. | |
22323 | ||
22324 | @item +vfpv3 | |
22325 | The VFPv3 floating-point instructions, with 32 double-precision | |
22326 | registers. | |
22327 | ||
22328 | @item +vfpv3-d16-fp16 | |
22329 | The VFPv3 floating-point instructions, with 16 double-precision | |
22330 | registers and the half-precision floating-point conversion operations. | |
22331 | ||
22332 | @item +vfpv3-fp16 | |
22333 | The VFPv3 floating-point instructions, with 32 double-precision | |
22334 | registers and the half-precision floating-point conversion operations. | |
22335 | ||
22336 | @item +vfpv4-d16 | |
22337 | The VFPv4 floating-point instructions, with 16 double-precision | |
22338 | registers. | |
22339 | ||
22340 | @item +vfpv4 | |
22341 | The VFPv4 floating-point instructions, with 32 double-precision | |
22342 | registers. | |
22343 | ||
22344 | @item +neon | |
22345 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions. | |
22346 | The extension @samp{+neon-vfpv3} can be used as an alias for this extension. | |
22347 | ||
22348 | @item +neon-fp16 | |
22349 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with | |
22350 | the half-precision floating-point conversion operations. | |
22351 | ||
22352 | @item +nosimd | |
22353 | Disable the Advanced SIMD instructions (does not disable floating point). | |
22354 | ||
22355 | @item +nofp | |
22356 | Disable the floating-point and Advanced SIMD instructions. | |
22357 | @end table | |
22358 | ||
22359 | @item armv8-a | |
22360 | @table @samp | |
22361 | @item +crc | |
22362 | The Cyclic Redundancy Check (CRC) instructions. | |
22363 | @item +simd | |
22364 | The ARMv8-A Advanced SIMD and floating-point instructions. | |
22365 | @item +crypto | |
22366 | The cryptographic instructions. | |
22367 | @item +nocrypto | |
22368 | Disable the cryptographic instructions. | |
22369 | @item +nofp | |
22370 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22371 | @item +sb | |
22372 | Speculation Barrier Instruction. | |
22373 | @item +predres | |
22374 | Execution and Data Prediction Restriction Instructions. | |
22375 | @end table | |
22376 | ||
22377 | @item armv8.1-a | |
22378 | @table @samp | |
22379 | @item +simd | |
22380 | The ARMv8.1-A Advanced SIMD and floating-point instructions. | |
22381 | ||
22382 | @item +crypto | |
22383 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22384 | floating-point instructions. | |
22385 | ||
22386 | @item +nocrypto | |
22387 | Disable the cryptographic instructions. | |
22388 | ||
22389 | @item +nofp | |
22390 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22391 | ||
22392 | @item +sb | |
22393 | Speculation Barrier Instruction. | |
22394 | ||
22395 | @item +predres | |
22396 | Execution and Data Prediction Restriction Instructions. | |
22397 | @end table | |
22398 | ||
22399 | @item armv8.2-a | |
22400 | @itemx armv8.3-a | |
22401 | @table @samp | |
22402 | @item +fp16 | |
22403 | The half-precision floating-point data processing instructions. | |
22404 | This also enables the Advanced SIMD and floating-point instructions. | |
22405 | ||
22406 | @item +fp16fml | |
22407 | The half-precision floating-point fmla extension. This also enables | |
22408 | the half-precision floating-point extension and Advanced SIMD and | |
22409 | floating-point instructions. | |
22410 | ||
22411 | @item +simd | |
22412 | The ARMv8.1-A Advanced SIMD and floating-point instructions. | |
22413 | ||
22414 | @item +crypto | |
22415 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22416 | floating-point instructions. | |
22417 | ||
22418 | @item +dotprod | |
22419 | Enable the Dot Product extension. This also enables Advanced SIMD instructions. | |
22420 | ||
22421 | @item +nocrypto | |
22422 | Disable the cryptographic extension. | |
22423 | ||
22424 | @item +nofp | |
22425 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22426 | ||
22427 | @item +sb | |
22428 | Speculation Barrier Instruction. | |
22429 | ||
22430 | @item +predres | |
22431 | Execution and Data Prediction Restriction Instructions. | |
22432 | ||
22433 | @item +i8mm | |
22434 | 8-bit Integer Matrix Multiply instructions. | |
22435 | This also enables Advanced SIMD and floating-point instructions. | |
22436 | ||
22437 | @item +bf16 | |
22438 | Brain half-precision floating-point instructions. | |
22439 | This also enables Advanced SIMD and floating-point instructions. | |
22440 | @end table | |
22441 | ||
22442 | @item armv8.4-a | |
22443 | @table @samp | |
22444 | @item +fp16 | |
22445 | The half-precision floating-point data processing instructions. | |
22446 | This also enables the Advanced SIMD and floating-point instructions as well | |
22447 | as the Dot Product extension and the half-precision floating-point fmla | |
22448 | extension. | |
22449 | ||
22450 | @item +simd | |
22451 | The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the | |
22452 | Dot Product extension. | |
22453 | ||
22454 | @item +crypto | |
22455 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22456 | floating-point instructions as well as the Dot Product extension. | |
22457 | ||
22458 | @item +nocrypto | |
22459 | Disable the cryptographic extension. | |
22460 | ||
22461 | @item +nofp | |
22462 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22463 | ||
22464 | @item +sb | |
22465 | Speculation Barrier Instruction. | |
22466 | ||
22467 | @item +predres | |
22468 | Execution and Data Prediction Restriction Instructions. | |
22469 | ||
22470 | @item +i8mm | |
22471 | 8-bit Integer Matrix Multiply instructions. | |
22472 | This also enables Advanced SIMD and floating-point instructions. | |
22473 | ||
22474 | @item +bf16 | |
22475 | Brain half-precision floating-point instructions. | |
22476 | This also enables Advanced SIMD and floating-point instructions. | |
22477 | @end table | |
22478 | ||
22479 | @item armv8.5-a | |
22480 | @table @samp | |
22481 | @item +fp16 | |
22482 | The half-precision floating-point data processing instructions. | |
22483 | This also enables the Advanced SIMD and floating-point instructions as well | |
22484 | as the Dot Product extension and the half-precision floating-point fmla | |
22485 | extension. | |
22486 | ||
22487 | @item +simd | |
22488 | The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the | |
22489 | Dot Product extension. | |
22490 | ||
22491 | @item +crypto | |
22492 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22493 | floating-point instructions as well as the Dot Product extension. | |
22494 | ||
22495 | @item +nocrypto | |
22496 | Disable the cryptographic extension. | |
22497 | ||
22498 | @item +nofp | |
22499 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22500 | ||
22501 | @item +i8mm | |
22502 | 8-bit Integer Matrix Multiply instructions. | |
22503 | This also enables Advanced SIMD and floating-point instructions. | |
22504 | ||
22505 | @item +bf16 | |
22506 | Brain half-precision floating-point instructions. | |
22507 | This also enables Advanced SIMD and floating-point instructions. | |
22508 | @end table | |
22509 | ||
22510 | @item armv8.6-a | |
22511 | @table @samp | |
22512 | @item +fp16 | |
22513 | The half-precision floating-point data processing instructions. | |
22514 | This also enables the Advanced SIMD and floating-point instructions as well | |
22515 | as the Dot Product extension and the half-precision floating-point fmla | |
22516 | extension. | |
22517 | ||
22518 | @item +simd | |
22519 | The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the | |
22520 | Dot Product extension. | |
22521 | ||
22522 | @item +crypto | |
22523 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22524 | floating-point instructions as well as the Dot Product extension. | |
22525 | ||
22526 | @item +nocrypto | |
22527 | Disable the cryptographic extension. | |
22528 | ||
22529 | @item +nofp | |
22530 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22531 | ||
22532 | @item +i8mm | |
22533 | 8-bit Integer Matrix Multiply instructions. | |
22534 | This also enables Advanced SIMD and floating-point instructions. | |
22535 | ||
22536 | @item +bf16 | |
22537 | Brain half-precision floating-point instructions. | |
22538 | This also enables Advanced SIMD and floating-point instructions. | |
22539 | @end table | |
22540 | ||
22541 | @item armv7-r | |
22542 | @table @samp | |
22543 | @item +fp.sp | |
22544 | The single-precision VFPv3 floating-point instructions. The extension | |
22545 | @samp{+vfpv3xd} can be used as an alias for this extension. | |
22546 | ||
22547 | @item +fp | |
22548 | The VFPv3 floating-point instructions with 16 double-precision registers. | |
22549 | The extension +vfpv3-d16 can be used as an alias for this extension. | |
22550 | ||
22551 | @item +vfpv3xd-d16-fp16 | |
22552 | The single-precision VFPv3 floating-point instructions with 16 double-precision | |
22553 | registers and the half-precision floating-point conversion operations. | |
22554 | ||
22555 | @item +vfpv3-d16-fp16 | |
22556 | The VFPv3 floating-point instructions with 16 double-precision | |
22557 | registers and the half-precision floating-point conversion operations. | |
22558 | ||
22559 | @item +nofp | |
22560 | Disable the floating-point extension. | |
22561 | ||
22562 | @item +idiv | |
22563 | The ARM-state integer division instructions. | |
22564 | ||
22565 | @item +noidiv | |
22566 | Disable the ARM-state integer division extension. | |
22567 | @end table | |
22568 | ||
22569 | @item armv7e-m | |
22570 | @table @samp | |
22571 | @item +fp | |
22572 | The single-precision VFPv4 floating-point instructions. | |
22573 | ||
22574 | @item +fpv5 | |
22575 | The single-precision FPv5 floating-point instructions. | |
22576 | ||
22577 | @item +fp.dp | |
22578 | The single- and double-precision FPv5 floating-point instructions. | |
22579 | ||
22580 | @item +nofp | |
22581 | Disable the floating-point extensions. | |
22582 | @end table | |
22583 | ||
22584 | @item armv8.1-m.main | |
22585 | @table @samp | |
22586 | ||
22587 | @item +dsp | |
22588 | The DSP instructions. | |
22589 | ||
22590 | @item +mve | |
22591 | The M-Profile Vector Extension (MVE) integer instructions. | |
22592 | ||
22593 | @item +mve.fp | |
22594 | The M-Profile Vector Extension (MVE) integer and single precision | |
22595 | floating-point instructions. | |
22596 | ||
22597 | @item +fp | |
22598 | The single-precision floating-point instructions. | |
22599 | ||
22600 | @item +fp.dp | |
22601 | The single- and double-precision floating-point instructions. | |
22602 | ||
22603 | @item +nofp | |
22604 | Disable the floating-point extension. | |
22605 | ||
22606 | @item +cdecp0, +cdecp1, ... , +cdecp7 | |
22607 | Enable the Custom Datapath Extension (CDE) on selected coprocessors according | |
22608 | to the numbers given in the options in the range 0 to 7. | |
c91bb7b9 AC |
22609 | |
22610 | @item +pacbti | |
22611 | Enable the Pointer Authentication and Branch Target Identification Extension. | |
d77de738 ML |
22612 | @end table |
22613 | ||
22614 | @item armv8-m.main | |
22615 | @table @samp | |
22616 | @item +dsp | |
22617 | The DSP instructions. | |
22618 | ||
22619 | @item +nodsp | |
22620 | Disable the DSP extension. | |
22621 | ||
22622 | @item +fp | |
22623 | The single-precision floating-point instructions. | |
22624 | ||
22625 | @item +fp.dp | |
22626 | The single- and double-precision floating-point instructions. | |
22627 | ||
22628 | @item +nofp | |
22629 | Disable the floating-point extension. | |
22630 | ||
22631 | @item +cdecp0, +cdecp1, ... , +cdecp7 | |
22632 | Enable the Custom Datapath Extension (CDE) on selected coprocessors according | |
22633 | to the numbers given in the options in the range 0 to 7. | |
22634 | @end table | |
22635 | ||
22636 | @item armv8-r | |
22637 | @table @samp | |
22638 | @item +crc | |
22639 | The Cyclic Redundancy Check (CRC) instructions. | |
22640 | @item +fp.sp | |
22641 | The single-precision FPv5 floating-point instructions. | |
22642 | @item +simd | |
22643 | The ARMv8-A Advanced SIMD and floating-point instructions. | |
22644 | @item +crypto | |
22645 | The cryptographic instructions. | |
22646 | @item +nocrypto | |
22647 | Disable the cryptographic instructions. | |
22648 | @item +nofp | |
22649 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22650 | @end table | |
22651 | ||
22652 | @end table | |
22653 | ||
22654 | @option{-march=native} causes the compiler to auto-detect the architecture | |
22655 | of the build computer. At present, this feature is only supported on | |
22656 | GNU/Linux, and not all architectures are recognized. If the auto-detect | |
22657 | is unsuccessful the option has no effect. | |
22658 | ||
d77de738 | 22659 | @opindex mtune |
ddf6fe37 | 22660 | @item -mtune=@var{name} |
d77de738 ML |
22661 | This option specifies the name of the target ARM processor for |
22662 | which GCC should tune the performance of the code. | |
22663 | For some ARM implementations better performance can be obtained by using | |
22664 | this option. | |
22665 | Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t}, | |
22666 | @samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110}, | |
22667 | @samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810}, | |
22668 | @samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t}, | |
22669 | @samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s}, | |
22670 | @samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t}, | |
22671 | @samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e}, | |
22672 | @samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp}, | |
22673 | @samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s}, | |
22674 | @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8}, | |
22675 | @samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17}, | |
22676 | @samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, | |
22677 | @samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, | |
22678 | @samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77}, | |
22679 | @samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710}, | |
22680 | @samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5}, | |
22681 | @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus}, | |
22682 | @samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3}, | |
22683 | @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33}, | |
ccfd1e7f SP |
22684 | @samp{cortex-m35p}, @samp{cortex-m55}, @samp{cortex-m85}, @samp{cortex-x1}, |
22685 | @samp{cortex-x1c}, @samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply}, | |
d77de738 ML |
22686 | @samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4}, |
22687 | @samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale}, | |
22688 | @samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626}, | |
22689 | @samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1}, | |
22690 | @samp{xgene1}. | |
22691 | ||
22692 | Additionally, this option can specify that GCC should tune the performance | |
22693 | of the code for a big.LITTLE system. Permissible names are: | |
22694 | @samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7}, | |
22695 | @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
22696 | @samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53}, | |
22697 | @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}. | |
22698 | ||
22699 | @option{-mtune=generic-@var{arch}} specifies that GCC should tune the | |
22700 | performance for a blend of processors within architecture @var{arch}. | |
22701 | The aim is to generate code that run well on the current most popular | |
22702 | processors, balancing between optimizations that benefit some CPUs in the | |
22703 | range, and avoiding performance pitfalls of other CPUs. The effects of | |
22704 | this option may change in future GCC versions as CPU models come and go. | |
22705 | ||
22706 | @option{-mtune} permits the same extension options as @option{-mcpu}, but | |
22707 | the extension options do not affect the tuning of the generated code. | |
22708 | ||
22709 | @option{-mtune=native} causes the compiler to auto-detect the CPU | |
22710 | of the build computer. At present, this feature is only supported on | |
22711 | GNU/Linux, and not all architectures are recognized. If the auto-detect is | |
22712 | unsuccessful the option has no effect. | |
22713 | ||
d77de738 | 22714 | @opindex mcpu |
ddf6fe37 | 22715 | @item -mcpu=@var{name}@r{[}+extension@dots{}@r{]} |
d77de738 ML |
22716 | This specifies the name of the target ARM processor. GCC uses this name |
22717 | to derive the name of the target ARM architecture (as if specified | |
22718 | by @option{-march}) and the ARM processor type for which to tune for | |
22719 | performance (as if specified by @option{-mtune}). Where this option | |
22720 | is used in conjunction with @option{-march} or @option{-mtune}, | |
22721 | those options take precedence over the appropriate part of this option. | |
22722 | ||
22723 | Many of the supported CPUs implement optional architectural | |
22724 | extensions. Where this is so the architectural extensions are | |
22725 | normally enabled by default. If implementations that lack the | |
22726 | extension exist, then the extension syntax can be used to disable | |
22727 | those extensions that have been omitted. For floating-point and | |
22728 | Advanced SIMD (Neon) instructions, the settings of the options | |
22729 | @option{-mfloat-abi} and @option{-mfpu} must also be considered: | |
22730 | floating-point and Advanced SIMD instructions will only be used if | |
22731 | @option{-mfloat-abi} is not set to @samp{soft}; and any setting of | |
22732 | @option{-mfpu} other than @samp{auto} will override the available | |
22733 | floating-point and SIMD extension instructions. | |
22734 | ||
22735 | For example, @samp{cortex-a9} can be found in three major | |
22736 | configurations: integer only, with just a floating-point unit or with | |
22737 | floating-point and Advanced SIMD. The default is to enable all the | |
22738 | instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can | |
22739 | be used to disable just the SIMD or both the SIMD and floating-point | |
22740 | instructions respectively. | |
22741 | ||
22742 | Permissible names for this option are the same as those for | |
22743 | @option{-mtune}. | |
22744 | ||
22745 | The following extension options are common to the listed CPUs: | |
22746 | ||
22747 | @table @samp | |
22748 | @item +nodsp | |
ccfd1e7f SP |
22749 | Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p}, |
22750 | @samp{cortex-m55} and @samp{cortex-m85}. Also disable the M-Profile Vector | |
22751 | Extension (MVE) integer and single precision floating-point instructions on | |
22752 | @samp{cortex-m55} and @samp{cortex-m85}. | |
22753 | ||
22754 | @item +nopacbti | |
22755 | Disable the Pointer Authentication and Branch Target Identification Extension | |
22756 | on @samp{cortex-m85}. | |
d77de738 ML |
22757 | |
22758 | @item +nomve | |
22759 | Disable the M-Profile Vector Extension (MVE) integer and single precision | |
ccfd1e7f | 22760 | floating-point instructions on @samp{cortex-m55} and @samp{cortex-m85}. |
d77de738 ML |
22761 | |
22762 | @item +nomve.fp | |
22763 | Disable the M-Profile Vector Extension (MVE) single precision floating-point | |
ccfd1e7f | 22764 | instructions on @samp{cortex-m55} and @samp{cortex-m85}. |
d77de738 | 22765 | |
798a0d05 SP |
22766 | @item +cdecp0, +cdecp1, ... , +cdecp7 |
22767 | Enable the Custom Datapath Extension (CDE) on selected coprocessors according | |
22768 | to the numbers given in the options in the range 0 to 7 on @samp{cortex-m55}. | |
22769 | ||
d77de738 ML |
22770 | @item +nofp |
22771 | Disables the floating-point instructions on @samp{arm9e}, | |
22772 | @samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e}, | |
22773 | @samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s}, | |
22774 | @samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, | |
22775 | @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p} | |
ccfd1e7f SP |
22776 | @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p}, |
22777 | @samp{cortex-m55} and @samp{cortex-m85}. | |
d77de738 ML |
22778 | Disables the floating-point and SIMD instructions on |
22779 | @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, | |
22780 | @samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12}, | |
22781 | @samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7}, | |
22782 | @samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35}, | |
22783 | @samp{cortex-a53} and @samp{cortex-a55}. | |
22784 | ||
22785 | @item +nofp.dp | |
22786 | Disables the double-precision component of the floating-point instructions | |
22787 | on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, | |
22788 | @samp{cortex-r52plus} and @samp{cortex-m7}. | |
22789 | ||
22790 | @item +nosimd | |
22791 | Disables the SIMD (but not floating-point) instructions on | |
22792 | @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7} | |
22793 | and @samp{cortex-a9}. | |
22794 | ||
22795 | @item +crypto | |
22796 | Enables the cryptographic instructions on @samp{cortex-a32}, | |
22797 | @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57}, | |
22798 | @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1}, | |
22799 | @samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
22800 | @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and | |
22801 | @samp{cortex-a75.cortex-a55}. | |
22802 | @end table | |
22803 | ||
22804 | Additionally the @samp{generic-armv7-a} pseudo target defaults to | |
22805 | VFPv3 with 16 double-precision registers. It supports the following | |
22806 | extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16}, | |
22807 | @samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16}, | |
22808 | @samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3}, | |
22809 | @samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for | |
22810 | the extensions to @option{-march=armv7-a}. | |
22811 | ||
22812 | @option{-mcpu=generic-@var{arch}} is also permissible, and is | |
22813 | equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}. | |
22814 | See @option{-mtune} for more information. | |
22815 | ||
22816 | @option{-mcpu=native} causes the compiler to auto-detect the CPU | |
22817 | of the build computer. At present, this feature is only supported on | |
22818 | GNU/Linux, and not all architectures are recognized. If the auto-detect | |
22819 | is unsuccessful the option has no effect. | |
22820 | ||
d77de738 | 22821 | @opindex mfpu |
ddf6fe37 | 22822 | @item -mfpu=@var{name} |
d77de738 ML |
22823 | This specifies what floating-point hardware (or hardware emulation) is |
22824 | available on the target. Permissible names are: @samp{auto}, @samp{vfpv2}, | |
22825 | @samp{vfpv3}, | |
22826 | @samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd}, | |
22827 | @samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4}, | |
22828 | @samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4}, | |
22829 | @samp{fpv5-d16}, @samp{fpv5-sp-d16}, | |
22830 | @samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}. | |
22831 | Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp} | |
22832 | is an alias for @samp{vfpv2}. | |
22833 | ||
22834 | The setting @samp{auto} is the default and is special. It causes the | |
22835 | compiler to select the floating-point and Advanced SIMD instructions | |
22836 | based on the settings of @option{-mcpu} and @option{-march}. | |
22837 | ||
22838 | If the selected floating-point hardware includes the NEON extension | |
22839 | (e.g.@: @option{-mfpu=neon}), note that floating-point | |
22840 | operations are not generated by GCC's auto-vectorization pass unless | |
22841 | @option{-funsafe-math-optimizations} is also specified. This is | |
22842 | because NEON hardware does not fully implement the IEEE 754 standard for | |
22843 | floating-point arithmetic (in particular denormal values are treated as | |
22844 | zero), so the use of NEON instructions may lead to a loss of precision. | |
22845 | ||
22846 | 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}). | |
22847 | ||
d77de738 | 22848 | @opindex mfp16-format |
ddf6fe37 | 22849 | @item -mfp16-format=@var{name} |
d77de738 ML |
22850 | Specify the format of the @code{__fp16} half-precision floating-point type. |
22851 | Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative}; | |
22852 | the default is @samp{none}, in which case the @code{__fp16} type is not | |
22853 | defined. @xref{Half-Precision}, for more information. | |
22854 | ||
d77de738 | 22855 | @opindex mstructure-size-boundary |
ddf6fe37 | 22856 | @item -mstructure-size-boundary=@var{n} |
d77de738 ML |
22857 | The sizes of all structures and unions are rounded up to a multiple |
22858 | of the number of bits set by this option. Permissible values are 8, 32 | |
22859 | and 64. The default value varies for different toolchains. For the COFF | |
22860 | targeted toolchain the default value is 8. A value of 64 is only allowed | |
22861 | if the underlying ABI supports it. | |
22862 | ||
22863 | Specifying a larger number can produce faster, more efficient code, but | |
22864 | can also increase the size of the program. Different values are potentially | |
22865 | incompatible. Code compiled with one value cannot necessarily expect to | |
22866 | work with code or libraries compiled with another value, if they exchange | |
22867 | information using structures or unions. | |
22868 | ||
22869 | This option is deprecated. | |
22870 | ||
d77de738 | 22871 | @opindex mabort-on-noreturn |
ddf6fe37 | 22872 | @item -mabort-on-noreturn |
d77de738 ML |
22873 | Generate a call to the function @code{abort} at the end of a |
22874 | @code{noreturn} function. It is executed if the function tries to | |
22875 | return. | |
22876 | ||
d77de738 ML |
22877 | @opindex mlong-calls |
22878 | @opindex mno-long-calls | |
ddf6fe37 AA |
22879 | @item -mlong-calls |
22880 | @itemx -mno-long-calls | |
d77de738 ML |
22881 | Tells the compiler to perform function calls by first loading the |
22882 | address of the function into a register and then performing a subroutine | |
22883 | call on this register. This switch is needed if the target function | |
22884 | lies outside of the 64-megabyte addressing range of the offset-based | |
22885 | version of subroutine call instruction. | |
22886 | ||
22887 | Even if this switch is enabled, not all function calls are turned | |
22888 | into long calls. The heuristic is that static functions, functions | |
22889 | that have the @code{short_call} attribute, functions that are inside | |
22890 | the scope of a @code{#pragma no_long_calls} directive, and functions whose | |
22891 | definitions have already been compiled within the current compilation | |
22892 | unit are not turned into long calls. The exceptions to this rule are | |
22893 | that weak function definitions, functions with the @code{long_call} | |
22894 | attribute or the @code{section} attribute, and functions that are within | |
22895 | the scope of a @code{#pragma long_calls} directive are always | |
22896 | turned into long calls. | |
22897 | ||
22898 | This feature is not enabled by default. Specifying | |
22899 | @option{-mno-long-calls} restores the default behavior, as does | |
22900 | placing the function calls within the scope of a @code{#pragma | |
22901 | long_calls_off} directive. Note these switches have no effect on how | |
22902 | the compiler generates code to handle function calls via function | |
22903 | pointers. | |
22904 | ||
d77de738 | 22905 | @opindex msingle-pic-base |
ddf6fe37 | 22906 | @item -msingle-pic-base |
d77de738 ML |
22907 | Treat the register used for PIC addressing as read-only, rather than |
22908 | loading it in the prologue for each function. The runtime system is | |
22909 | responsible for initializing this register with an appropriate value | |
22910 | before execution begins. | |
22911 | ||
d77de738 | 22912 | @opindex mpic-register |
ddf6fe37 | 22913 | @item -mpic-register=@var{reg} |
d77de738 ML |
22914 | Specify the register to be used for PIC addressing. |
22915 | For standard PIC base case, the default is any suitable register | |
22916 | determined by compiler. For single PIC base case, the default is | |
22917 | @samp{R9} if target is EABI based or stack-checking is enabled, | |
22918 | otherwise the default is @samp{R10}. | |
22919 | ||
d77de738 | 22920 | @opindex mpic-data-is-text-relative |
ddf6fe37 | 22921 | @item -mpic-data-is-text-relative |
d77de738 ML |
22922 | Assume that the displacement between the text and data segments is fixed |
22923 | at static link time. This permits using PC-relative addressing | |
22924 | operations to access data known to be in the data segment. For | |
22925 | non-VxWorks RTP targets, this option is enabled by default. When | |
22926 | disabled on such targets, it will enable @option{-msingle-pic-base} by | |
22927 | default. | |
22928 | ||
d77de738 | 22929 | @opindex mpoke-function-name |
ddf6fe37 | 22930 | @item -mpoke-function-name |
d77de738 ML |
22931 | Write the name of each function into the text section, directly |
22932 | preceding the function prologue. The generated code is similar to this: | |
22933 | ||
22934 | @smallexample | |
22935 | t0 | |
22936 | .ascii "arm_poke_function_name", 0 | |
22937 | .align | |
22938 | t1 | |
22939 | .word 0xff000000 + (t1 - t0) | |
22940 | arm_poke_function_name | |
22941 | mov ip, sp | |
22942 | stmfd sp!, @{fp, ip, lr, pc@} | |
22943 | sub fp, ip, #4 | |
22944 | @end smallexample | |
22945 | ||
22946 | When performing a stack backtrace, code can inspect the value of | |
22947 | @code{pc} stored at @code{fp + 0}. If the trace function then looks at | |
22948 | location @code{pc - 12} and the top 8 bits are set, then we know that | |
22949 | there is a function name embedded immediately preceding this location | |
22950 | and has length @code{((pc[-3]) & 0xff000000)}. | |
22951 | ||
d77de738 ML |
22952 | @opindex marm |
22953 | @opindex mthumb | |
ddf6fe37 AA |
22954 | @item -mthumb |
22955 | @itemx -marm | |
d77de738 ML |
22956 | |
22957 | Select between generating code that executes in ARM and Thumb | |
22958 | states. The default for most configurations is to generate code | |
22959 | that executes in ARM state, but the default can be changed by | |
22960 | configuring GCC with the @option{--with-mode=}@var{state} | |
22961 | configure option. | |
22962 | ||
22963 | You can also override the ARM and Thumb mode for each function | |
22964 | by using the @code{target("thumb")} and @code{target("arm")} function attributes | |
22965 | (@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}). | |
22966 | ||
d77de738 | 22967 | @opindex mflip-thumb |
ddf6fe37 | 22968 | @item -mflip-thumb |
d77de738 ML |
22969 | Switch ARM/Thumb modes on alternating functions. |
22970 | This option is provided for regression testing of mixed Thumb/ARM code | |
22971 | generation, and is not intended for ordinary use in compiling code. | |
22972 | ||
d77de738 | 22973 | @opindex mtpcs-frame |
ddf6fe37 | 22974 | @item -mtpcs-frame |
d77de738 ML |
22975 | Generate a stack frame that is compliant with the Thumb Procedure Call |
22976 | Standard for all non-leaf functions. (A leaf function is one that does | |
22977 | not call any other functions.) The default is @option{-mno-tpcs-frame}. | |
22978 | ||
d77de738 | 22979 | @opindex mtpcs-leaf-frame |
ddf6fe37 | 22980 | @item -mtpcs-leaf-frame |
d77de738 ML |
22981 | Generate a stack frame that is compliant with the Thumb Procedure Call |
22982 | Standard for all leaf functions. (A leaf function is one that does | |
22983 | not call any other functions.) The default is @option{-mno-apcs-leaf-frame}. | |
22984 | ||
d77de738 | 22985 | @opindex mcallee-super-interworking |
ddf6fe37 | 22986 | @item -mcallee-super-interworking |
d77de738 ML |
22987 | Gives all externally visible functions in the file being compiled an ARM |
22988 | instruction set header which switches to Thumb mode before executing the | |
22989 | rest of the function. This allows these functions to be called from | |
22990 | non-interworking code. This option is not valid in AAPCS configurations | |
22991 | because interworking is enabled by default. | |
22992 | ||
d77de738 | 22993 | @opindex mcaller-super-interworking |
ddf6fe37 | 22994 | @item -mcaller-super-interworking |
d77de738 ML |
22995 | Allows calls via function pointers (including virtual functions) to |
22996 | execute correctly regardless of whether the target code has been | |
22997 | compiled for interworking or not. There is a small overhead in the cost | |
22998 | of executing a function pointer if this option is enabled. This option | |
22999 | is not valid in AAPCS configurations because interworking is enabled | |
23000 | by default. | |
23001 | ||
d77de738 | 23002 | @opindex mtp |
ddf6fe37 | 23003 | @item -mtp=@var{name} |
cca8d9e5 KT |
23004 | Specify the access model for the thread local storage pointer. The model |
23005 | @samp{soft} generates calls to @code{__aeabi_read_tp}. Other accepted | |
23006 | models are @samp{tpidrurw}, @samp{tpidruro} and @samp{tpidrprw} which fetch | |
23007 | the thread pointer from the corresponding system register directly | |
23008 | (supported from the arm6k architecture and later). These system registers | |
23009 | are accessed through the CP15 co-processor interface and the argument | |
23010 | @samp{cp15} is also accepted as a convenience alias of @samp{tpidruro}. | |
23011 | The argument @samp{auto} uses the best available method for the selected | |
23012 | processor. The default setting is @samp{auto}. | |
d77de738 | 23013 | |
d77de738 | 23014 | @opindex mtls-dialect |
ddf6fe37 | 23015 | @item -mtls-dialect=@var{dialect} |
d77de738 ML |
23016 | Specify the dialect to use for accessing thread local storage. Two |
23017 | @var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The | |
23018 | @samp{gnu} dialect selects the original GNU scheme for supporting | |
23019 | local and global dynamic TLS models. The @samp{gnu2} dialect | |
23020 | selects the GNU descriptor scheme, which provides better performance | |
23021 | for shared libraries. The GNU descriptor scheme is compatible with | |
23022 | the original scheme, but does require new assembler, linker and | |
23023 | library support. Initial and local exec TLS models are unaffected by | |
23024 | this option and always use the original scheme. | |
23025 | ||
d77de738 | 23026 | @opindex mword-relocations |
ddf6fe37 | 23027 | @item -mword-relocations |
d77de738 ML |
23028 | Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32). |
23029 | This is enabled by default on targets (uClinux, SymbianOS) where the runtime | |
23030 | loader imposes this restriction, and when @option{-fpic} or @option{-fPIC} | |
23031 | is specified. This option conflicts with @option{-mslow-flash-data}. | |
23032 | ||
d77de738 | 23033 | @opindex mfix-cortex-m3-ldrd |
ddf6fe37 | 23034 | @item -mfix-cortex-m3-ldrd |
d77de738 ML |
23035 | Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions |
23036 | with overlapping destination and base registers are used. This option avoids | |
23037 | generating these instructions. This option is enabled by default when | |
23038 | @option{-mcpu=cortex-m3} is specified. | |
23039 | ||
23040 | @item -mfix-cortex-a57-aes-1742098 | |
23041 | @itemx -mno-fix-cortex-a57-aes-1742098 | |
23042 | @itemx -mfix-cortex-a72-aes-1655431 | |
23043 | @itemx -mno-fix-cortex-a72-aes-1655431 | |
23044 | Enable (disable) mitigation for an erratum on Cortex-A57 and | |
23045 | Cortex-A72 that affects the AES cryptographic instructions. This | |
23046 | option is enabled by default when either @option{-mcpu=cortex-a57} or | |
23047 | @option{-mcpu=cortex-a72} is specified. | |
23048 | ||
d77de738 ML |
23049 | @opindex munaligned-access |
23050 | @opindex mno-unaligned-access | |
ddf6fe37 AA |
23051 | @item -munaligned-access |
23052 | @itemx -mno-unaligned-access | |
d77de738 ML |
23053 | Enables (or disables) reading and writing of 16- and 32- bit values |
23054 | from addresses that are not 16- or 32- bit aligned. By default | |
23055 | unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for | |
23056 | ARMv8-M Baseline architectures, and enabled for all other | |
23057 | architectures. If unaligned access is not enabled then words in packed | |
23058 | data structures are accessed a byte at a time. | |
23059 | ||
23060 | The ARM attribute @code{Tag_CPU_unaligned_access} is set in the | |
23061 | generated object file to either true or false, depending upon the | |
23062 | setting of this option. If unaligned access is enabled then the | |
23063 | preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also | |
23064 | defined. | |
23065 | ||
d77de738 | 23066 | @opindex mneon-for-64bits |
ddf6fe37 | 23067 | @item -mneon-for-64bits |
d77de738 ML |
23068 | This option is deprecated and has no effect. |
23069 | ||
d77de738 | 23070 | @opindex mslow-flash-data |
ddf6fe37 | 23071 | @item -mslow-flash-data |
d77de738 ML |
23072 | Assume loading data from flash is slower than fetching instruction. |
23073 | Therefore literal load is minimized for better performance. | |
23074 | This option is only supported when compiling for ARMv7 M-profile and | |
23075 | off by default. It conflicts with @option{-mword-relocations}. | |
23076 | ||
d77de738 | 23077 | @opindex masm-syntax-unified |
ddf6fe37 | 23078 | @item -masm-syntax-unified |
d77de738 ML |
23079 | Assume inline assembler is using unified asm syntax. The default is |
23080 | currently off which implies divided syntax. This option has no impact | |
23081 | on Thumb2. However, this may change in future releases of GCC. | |
23082 | Divided syntax should be considered deprecated. | |
23083 | ||
d77de738 | 23084 | @opindex mrestrict-it |
ddf6fe37 | 23085 | @item -mrestrict-it |
d77de738 ML |
23086 | Restricts generation of IT blocks to conform to the rules of ARMv8-A. |
23087 | IT blocks can only contain a single 16-bit instruction from a select | |
23088 | set of instructions. This option is on by default for ARMv8-A Thumb mode. | |
23089 | ||
d77de738 | 23090 | @opindex mprint-tune-info |
ddf6fe37 | 23091 | @item -mprint-tune-info |
d77de738 ML |
23092 | Print CPU tuning information as comment in assembler file. This is |
23093 | an option used only for regression testing of the compiler and not | |
23094 | intended for ordinary use in compiling code. This option is disabled | |
23095 | by default. | |
23096 | ||
d77de738 | 23097 | @opindex mverbose-cost-dump |
ddf6fe37 | 23098 | @item -mverbose-cost-dump |
d77de738 ML |
23099 | Enable verbose cost model dumping in the debug dump files. This option is |
23100 | provided for use in debugging the compiler. | |
23101 | ||
d77de738 | 23102 | @opindex mpure-code |
ddf6fe37 | 23103 | @item -mpure-code |
d77de738 ML |
23104 | Do not allow constant data to be placed in code sections. |
23105 | Additionally, when compiling for ELF object format give all text sections the | |
23106 | ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option | |
23107 | is only available when generating non-pic code for M-profile targets. | |
23108 | ||
d77de738 | 23109 | @opindex mcmse |
ddf6fe37 | 23110 | @item -mcmse |
d77de738 ML |
23111 | Generate secure code as per the "ARMv8-M Security Extensions: Requirements on |
23112 | Development Tools Engineering Specification", which can be found on | |
23113 | @url{https://developer.arm.com/documentation/ecm0359818/latest/}. | |
23114 | ||
d77de738 | 23115 | @opindex mfix-cmse-cve-2021-35465 |
ddf6fe37 | 23116 | @item -mfix-cmse-cve-2021-35465 |
d77de738 ML |
23117 | Mitigate against a potential security issue with the @code{VLLDM} instruction |
23118 | in some M-profile devices when using CMSE (CVE-2021-365465). This option is | |
23119 | enabled by default when the option @option{-mcpu=} is used with | |
ccfd1e7f SP |
23120 | @code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m55}, @code{cortex-m85} |
23121 | or @code{star-mc1}. The option @option{-mno-fix-cmse-cve-2021-35465} can be used | |
23122 | to disable the mitigation. | |
d77de738 | 23123 | |
d77de738 ML |
23124 | @opindex mstack-protector-guard |
23125 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
23126 | @item -mstack-protector-guard=@var{guard} |
23127 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
23128 | Generate stack protection code using canary at @var{guard}. Supported |
23129 | locations are @samp{global} for a global canary or @samp{tls} for a | |
23130 | canary accessible via the TLS register. The option | |
23131 | @option{-mstack-protector-guard-offset=} is for use with | |
23132 | @option{-fstack-protector-guard=tls} and not for use in user-land code. | |
23133 | ||
d77de738 ML |
23134 | @opindex mfdpic |
23135 | @opindex mno-fdpic | |
ddf6fe37 AA |
23136 | @item -mfdpic |
23137 | @itemx -mno-fdpic | |
d77de738 ML |
23138 | Select the FDPIC ABI, which uses 64-bit function descriptors to |
23139 | represent pointers to functions. When the compiler is configured for | |
23140 | @code{arm-*-uclinuxfdpiceabi} targets, this option is on by default | |
23141 | and implies @option{-fPIE} if none of the PIC/PIE-related options is | |
23142 | provided. On other targets, it only enables the FDPIC-specific code | |
23143 | generation features, and the user should explicitly provide the | |
23144 | PIC/PIE-related options as needed. | |
23145 | ||
23146 | Note that static linking is not supported because it would still | |
23147 | involve the dynamic linker when the program self-relocates. If such | |
23148 | behavior is acceptable, use -static and -Wl,-dynamic-linker options. | |
23149 | ||
23150 | The opposite @option{-mno-fdpic} option is useful (and required) to | |
23151 | build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi}) | |
23152 | toolchain as the one used to build the userland programs. | |
23153 | ||
14fab5fb | 23154 | @opindex mbranch-protection |
ddf6fe37 | 23155 | @item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]] |
14fab5fb AC |
23156 | Enable branch protection features (armv8.1-m.main only). |
23157 | @samp{none} generate code without branch protection or return address | |
23158 | signing. | |
23159 | @samp{standard[+@var{leaf}]} generate code with all branch protection | |
23160 | features enabled at their standard level. | |
23161 | @samp{pac-ret[+@var{leaf}]} generate code with return address signing | |
23162 | set to its standard level, which is to sign all functions that save | |
23163 | the return address to memory. | |
23164 | @samp{leaf} When return address signing is enabled, also sign leaf | |
23165 | functions even if they do not write the return address to memory. | |
23166 | +@samp{bti} Add landing-pad instructions at the permitted targets of | |
23167 | indirect branch instructions. | |
23168 | ||
23169 | If the @samp{+pacbti} architecture extension is not enabled, then all | |
23170 | branch protection and return address signing operations are | |
23171 | constrained to use only the instructions defined in the | |
23172 | architectural-NOP space. The generated code will remain | |
23173 | backwards-compatible with earlier versions of the architecture, but | |
23174 | the additional security can be enabled at run time on processors that | |
23175 | support the @samp{PACBTI} extension. | |
23176 | ||
23177 | Branch target enforcement using BTI can only be enabled at runtime if | |
23178 | all code in the application has been compiled with at least | |
23179 | @samp{-mbranch-protection=bti}. | |
23180 | ||
23181 | Any setting other than @samp{none} is supported only on armv8-m.main | |
23182 | or later. | |
23183 | ||
23184 | The default is to generate code without branch protection or return | |
23185 | address signing. | |
23186 | ||
d77de738 ML |
23187 | @end table |
23188 | ||
23189 | @node AVR Options | |
23190 | @subsection AVR Options | |
23191 | @cindex AVR Options | |
23192 | ||
23193 | These options are defined for AVR implementations: | |
23194 | ||
23195 | @table @gcctabopt | |
d77de738 | 23196 | @opindex mmcu |
ddf6fe37 | 23197 | @item -mmcu=@var{mcu} |
d77de738 ML |
23198 | Specify Atmel AVR instruction set architectures (ISA) or MCU type. |
23199 | ||
23200 | The default for this option is@tie{}@samp{avr2}. | |
23201 | ||
23202 | GCC supports the following AVR devices and ISAs: | |
23203 | ||
23204 | @include avr-mmcu.texi | |
23205 | ||
d77de738 | 23206 | @opindex mabsdata |
ddf6fe37 | 23207 | @item -mabsdata |
d77de738 ML |
23208 | |
23209 | Assume that all data in static storage can be accessed by LDS / STS | |
23210 | instructions. This option has only an effect on reduced Tiny devices like | |
23211 | ATtiny40. See also the @code{absdata} | |
23212 | @ref{AVR Variable Attributes,variable attribute}. | |
23213 | ||
d77de738 | 23214 | @opindex maccumulate-args |
ddf6fe37 | 23215 | @item -maccumulate-args |
d77de738 ML |
23216 | Accumulate outgoing function arguments and acquire/release the needed |
23217 | stack space for outgoing function arguments once in function | |
23218 | prologue/epilogue. Without this option, outgoing arguments are pushed | |
23219 | before calling a function and popped afterwards. | |
23220 | ||
23221 | Popping the arguments after the function call can be expensive on | |
23222 | AVR so that accumulating the stack space might lead to smaller | |
23223 | executables because arguments need not be removed from the | |
23224 | stack after such a function call. | |
23225 | ||
23226 | This option can lead to reduced code size for functions that perform | |
23227 | several calls to functions that get their arguments on the stack like | |
23228 | calls to printf-like functions. | |
23229 | ||
d77de738 | 23230 | @opindex mbranch-cost |
ddf6fe37 | 23231 | @item -mbranch-cost=@var{cost} |
d77de738 ML |
23232 | Set the branch costs for conditional branch instructions to |
23233 | @var{cost}. Reasonable values for @var{cost} are small, non-negative | |
23234 | integers. The default branch cost is 0. | |
23235 | ||
d77de738 | 23236 | @opindex mcall-prologues |
ddf6fe37 | 23237 | @item -mcall-prologues |
d77de738 ML |
23238 | Functions prologues/epilogues are expanded as calls to appropriate |
23239 | subroutines. Code size is smaller. | |
23240 | ||
d77de738 ML |
23241 | @opindex mdouble |
23242 | @opindex mlong-double | |
ddf6fe37 AA |
23243 | @item -mdouble=@var{bits} |
23244 | @itemx -mlong-double=@var{bits} | |
d77de738 ML |
23245 | Set the size (in bits) of the @code{double} or @code{long double} type, |
23246 | respectively. Possible values for @var{bits} are 32 and 64. | |
23247 | Whether or not a specific value for @var{bits} is allowed depends on | |
23248 | the @code{--with-double=} and @code{--with-long-double=} | |
23249 | @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}}, | |
23250 | and the same applies for the default values of the options. | |
23251 | ||
d77de738 | 23252 | @opindex mgas-isr-prologues |
ddf6fe37 | 23253 | @item -mgas-isr-prologues |
d77de738 ML |
23254 | Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo |
23255 | instruction supported by GNU Binutils. | |
23256 | If this option is on, the feature can still be disabled for individual | |
23257 | ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}} | |
23258 | function attribute. This feature is activated per default | |
23259 | if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}), | |
23260 | and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}. | |
23261 | ||
d77de738 | 23262 | @opindex mint8 |
ddf6fe37 | 23263 | @item -mint8 |
d77de738 ML |
23264 | Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a |
23265 | @code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes, | |
23266 | and @code{long long} is 4 bytes. Please note that this option does not | |
23267 | conform to the C standards, but it results in smaller code | |
23268 | size. | |
23269 | ||
d77de738 | 23270 | @opindex mmain-is-OS_task |
ddf6fe37 | 23271 | @item -mmain-is-OS_task |
d77de738 ML |
23272 | Do not save registers in @code{main}. The effect is the same like |
23273 | attaching attribute @ref{AVR Function Attributes,,@code{OS_task}} | |
23274 | to @code{main}. It is activated per default if optimization is on. | |
23275 | ||
d77de738 | 23276 | @opindex mn-flash |
ddf6fe37 | 23277 | @item -mn-flash=@var{num} |
d77de738 ML |
23278 | Assume that the flash memory has a size of |
23279 | @var{num} times 64@tie{}KiB. | |
23280 | ||
d77de738 | 23281 | @opindex mno-interrupts |
ddf6fe37 | 23282 | @item -mno-interrupts |
d77de738 ML |
23283 | Generated code is not compatible with hardware interrupts. |
23284 | Code size is smaller. | |
23285 | ||
d77de738 | 23286 | @opindex mrelax |
ddf6fe37 | 23287 | @item -mrelax |
d77de738 ML |
23288 | Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter |
23289 | @code{RCALL} resp.@: @code{RJMP} instruction if applicable. | |
23290 | Setting @option{-mrelax} just adds the @option{--mlink-relax} option to | |
23291 | the assembler's command line and the @option{--relax} option to the | |
23292 | linker's command line. | |
23293 | ||
23294 | Jump relaxing is performed by the linker because jump offsets are not | |
23295 | known before code is located. Therefore, the assembler code generated by the | |
23296 | compiler is the same, but the instructions in the executable may | |
23297 | differ from instructions in the assembler code. | |
23298 | ||
23299 | Relaxing must be turned on if linker stubs are needed, see the | |
23300 | section on @code{EIND} and linker stubs below. | |
23301 | ||
d77de738 | 23302 | @opindex mrmw |
ddf6fe37 | 23303 | @item -mrmw |
d77de738 ML |
23304 | Assume that the device supports the Read-Modify-Write |
23305 | instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}. | |
23306 | ||
d77de738 | 23307 | @opindex mshort-calls |
ddf6fe37 | 23308 | @item -mshort-calls |
d77de738 ML |
23309 | |
23310 | Assume that @code{RJMP} and @code{RCALL} can target the whole | |
23311 | program memory. | |
23312 | ||
23313 | This option is used internally for multilib selection. It is | |
23314 | not an optimization option, and you don't need to set it by hand. | |
23315 | ||
d77de738 | 23316 | @opindex msp8 |
ddf6fe37 | 23317 | @item -msp8 |
d77de738 ML |
23318 | Treat the stack pointer register as an 8-bit register, |
23319 | i.e.@: assume the high byte of the stack pointer is zero. | |
23320 | In general, you don't need to set this option by hand. | |
23321 | ||
23322 | This option is used internally by the compiler to select and | |
23323 | build multilibs for architectures @code{avr2} and @code{avr25}. | |
23324 | These architectures mix devices with and without @code{SPH}. | |
23325 | For any setting other than @option{-mmcu=avr2} or @option{-mmcu=avr25} | |
23326 | the compiler driver adds or removes this option from the compiler | |
23327 | proper's command line, because the compiler then knows if the device | |
23328 | or architecture has an 8-bit stack pointer and thus no @code{SPH} | |
23329 | register or not. | |
23330 | ||
d77de738 | 23331 | @opindex mstrict-X |
ddf6fe37 | 23332 | @item -mstrict-X |
d77de738 ML |
23333 | Use address register @code{X} in a way proposed by the hardware. This means |
23334 | that @code{X} is only used in indirect, post-increment or | |
23335 | pre-decrement addressing. | |
23336 | ||
23337 | Without this option, the @code{X} register may be used in the same way | |
23338 | as @code{Y} or @code{Z} which then is emulated by additional | |
23339 | instructions. | |
23340 | For example, loading a value with @code{X+const} addressing with a | |
23341 | small non-negative @code{const < 64} to a register @var{Rn} is | |
23342 | performed as | |
23343 | ||
23344 | @example | |
23345 | adiw r26, const ; X += const | |
23346 | ld @var{Rn}, X ; @var{Rn} = *X | |
23347 | sbiw r26, const ; X -= const | |
23348 | @end example | |
23349 | ||
d77de738 | 23350 | @opindex mtiny-stack |
ddf6fe37 | 23351 | @item -mtiny-stack |
d77de738 ML |
23352 | Only change the lower 8@tie{}bits of the stack pointer. |
23353 | ||
d77de738 | 23354 | @opindex mfract-convert-truncate |
ddf6fe37 | 23355 | @item -mfract-convert-truncate |
d77de738 ML |
23356 | Allow to use truncation instead of rounding towards zero for fractional fixed-point types. |
23357 | ||
d77de738 | 23358 | @opindex nodevicelib |
ddf6fe37 | 23359 | @item -nodevicelib |
d77de738 ML |
23360 | Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}. |
23361 | ||
d77de738 | 23362 | @opindex nodevicespecs |
ddf6fe37 | 23363 | @item -nodevicespecs |
d77de738 ML |
23364 | Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's |
23365 | command line. The user takes responsibility for supplying the sub-processes | |
23366 | like compiler proper, assembler and linker with appropriate command line | |
23367 | options. This means that the user has to supply her private device specs | |
23368 | file by means of @option{-specs=@var{path-to-specs-file}}. There is no | |
23369 | more need for option @option{-mmcu=@var{mcu}}. | |
23370 | ||
23371 | This option can also serve as a replacement for the older way of | |
23372 | specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory | |
23373 | which contains a folder named @code{device-specs} which contains a specs file named | |
23374 | @code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}. | |
23375 | ||
d77de738 ML |
23376 | @opindex Waddr-space-convert |
23377 | @opindex Wno-addr-space-convert | |
ddf6fe37 | 23378 | @item -Waddr-space-convert |
d77de738 ML |
23379 | Warn about conversions between address spaces in the case where the |
23380 | resulting address space is not contained in the incoming address space. | |
23381 | ||
d77de738 ML |
23382 | @opindex Wmisspelled-isr |
23383 | @opindex Wno-misspelled-isr | |
ddf6fe37 | 23384 | @item -Wmisspelled-isr |
d77de738 ML |
23385 | Warn if the ISR is misspelled, i.e.@: without __vector prefix. |
23386 | Enabled by default. | |
23387 | @end table | |
23388 | ||
23389 | @subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash | |
23390 | @cindex @code{EIND} | |
23391 | Pointers in the implementation are 16@tie{}bits wide. | |
23392 | The address of a function or label is represented as word address so | |
23393 | that indirect jumps and calls can target any code address in the | |
23394 | range of 64@tie{}Ki words. | |
23395 | ||
23396 | In order to facilitate indirect jump on devices with more than 128@tie{}Ki | |
23397 | bytes of program memory space, there is a special function register called | |
23398 | @code{EIND} that serves as most significant part of the target address | |
23399 | when @code{EICALL} or @code{EIJMP} instructions are used. | |
23400 | ||
23401 | Indirect jumps and calls on these devices are handled as follows by | |
23402 | the compiler and are subject to some limitations: | |
23403 | ||
23404 | @itemize @bullet | |
23405 | ||
23406 | @item | |
23407 | The compiler never sets @code{EIND}. | |
23408 | ||
23409 | @item | |
23410 | The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP} | |
23411 | instructions or might read @code{EIND} directly in order to emulate an | |
23412 | indirect call/jump by means of a @code{RET} instruction. | |
23413 | ||
23414 | @item | |
23415 | The compiler assumes that @code{EIND} never changes during the startup | |
23416 | code or during the application. In particular, @code{EIND} is not | |
23417 | saved/restored in function or interrupt service routine | |
23418 | prologue/epilogue. | |
23419 | ||
23420 | @item | |
23421 | For indirect calls to functions and computed goto, the linker | |
23422 | generates @emph{stubs}. Stubs are jump pads sometimes also called | |
23423 | @emph{trampolines}. Thus, the indirect call/jump jumps to such a stub. | |
23424 | The stub contains a direct jump to the desired address. | |
23425 | ||
23426 | @item | |
23427 | Linker relaxation must be turned on so that the linker generates | |
23428 | the stubs correctly in all situations. See the compiler option | |
23429 | @option{-mrelax} and the linker option @option{--relax}. | |
23430 | There are corner cases where the linker is supposed to generate stubs | |
23431 | but aborts without relaxation and without a helpful error message. | |
23432 | ||
23433 | @item | |
23434 | The default linker script is arranged for code with @code{EIND = 0}. | |
23435 | If code is supposed to work for a setup with @code{EIND != 0}, a custom | |
23436 | linker script has to be used in order to place the sections whose | |
23437 | name start with @code{.trampolines} into the segment where @code{EIND} | |
23438 | points to. | |
23439 | ||
23440 | @item | |
23441 | The startup code from libgcc never sets @code{EIND}. | |
23442 | Notice that startup code is a blend of code from libgcc and AVR-LibC. | |
23443 | For the impact of AVR-LibC on @code{EIND}, see the | |
a65da9be | 23444 | @w{@uref{https://www.nongnu.org/avr-libc/user-manual/,AVR-LibC user manual}}. |
d77de738 ML |
23445 | |
23446 | @item | |
23447 | It is legitimate for user-specific startup code to set up @code{EIND} | |
23448 | early, for example by means of initialization code located in | |
23449 | section @code{.init3}. Such code runs prior to general startup code | |
23450 | that initializes RAM and calls constructors, but after the bit | |
23451 | of startup code from AVR-LibC that sets @code{EIND} to the segment | |
23452 | where the vector table is located. | |
23453 | @example | |
23454 | #include <avr/io.h> | |
23455 | ||
23456 | static void | |
23457 | __attribute__((section(".init3"),naked,used,no_instrument_function)) | |
23458 | init3_set_eind (void) | |
23459 | @{ | |
23460 | __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t" | |
23461 | "out %i0,r24" :: "n" (&EIND) : "r24","memory"); | |
23462 | @} | |
23463 | @end example | |
23464 | ||
23465 | @noindent | |
23466 | The @code{__trampolines_start} symbol is defined in the linker script. | |
23467 | ||
23468 | @item | |
23469 | Stubs are generated automatically by the linker if | |
23470 | the following two conditions are met: | |
23471 | @itemize @minus | |
23472 | ||
23473 | @item The address of a label is taken by means of the @code{gs} modifier | |
23474 | (short for @emph{generate stubs}) like so: | |
23475 | @example | |
23476 | LDI r24, lo8(gs(@var{func})) | |
23477 | LDI r25, hi8(gs(@var{func})) | |
23478 | @end example | |
23479 | @item The final location of that label is in a code segment | |
23480 | @emph{outside} the segment where the stubs are located. | |
23481 | @end itemize | |
23482 | ||
23483 | @item | |
23484 | The compiler emits such @code{gs} modifiers for code labels in the | |
23485 | following situations: | |
23486 | @itemize @minus | |
23487 | @item Taking address of a function or code label. | |
23488 | @item Computed goto. | |
23489 | @item If prologue-save function is used, see @option{-mcall-prologues} | |
23490 | command-line option. | |
23491 | @item Switch/case dispatch tables. If you do not want such dispatch | |
23492 | tables you can specify the @option{-fno-jump-tables} command-line option. | |
23493 | @item C and C++ constructors/destructors called during startup/shutdown. | |
23494 | @item If the tools hit a @code{gs()} modifier explained above. | |
23495 | @end itemize | |
23496 | ||
23497 | @item | |
23498 | Jumping to non-symbolic addresses like so is @emph{not} supported: | |
23499 | ||
23500 | @example | |
23501 | int main (void) | |
23502 | @{ | |
23503 | /* Call function at word address 0x2 */ | |
23504 | return ((int(*)(void)) 0x2)(); | |
23505 | @} | |
23506 | @end example | |
23507 | ||
23508 | Instead, a stub has to be set up, i.e.@: the function has to be called | |
23509 | through a symbol (@code{func_4} in the example): | |
23510 | ||
23511 | @example | |
23512 | int main (void) | |
23513 | @{ | |
23514 | extern int func_4 (void); | |
23515 | ||
23516 | /* Call function at byte address 0x4 */ | |
23517 | return func_4(); | |
23518 | @} | |
23519 | @end example | |
23520 | ||
23521 | and the application be linked with @option{-Wl,--defsym,func_4=0x4}. | |
23522 | Alternatively, @code{func_4} can be defined in the linker script. | |
23523 | @end itemize | |
23524 | ||
23525 | @subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers | |
23526 | @cindex @code{RAMPD} | |
23527 | @cindex @code{RAMPX} | |
23528 | @cindex @code{RAMPY} | |
23529 | @cindex @code{RAMPZ} | |
23530 | Some AVR devices support memories larger than the 64@tie{}KiB range | |
23531 | that can be accessed with 16-bit pointers. To access memory locations | |
23532 | outside this 64@tie{}KiB range, the content of a @code{RAMP} | |
23533 | register is used as high part of the address: | |
23534 | The @code{X}, @code{Y}, @code{Z} address register is concatenated | |
23535 | with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function | |
23536 | register, respectively, to get a wide address. Similarly, | |
23537 | @code{RAMPD} is used together with direct addressing. | |
23538 | ||
23539 | @itemize | |
23540 | @item | |
23541 | The startup code initializes the @code{RAMP} special function | |
23542 | registers with zero. | |
23543 | ||
23544 | @item | |
23545 | If a @ref{AVR Named Address Spaces,named address space} other than | |
23546 | generic or @code{__flash} is used, then @code{RAMPZ} is set | |
23547 | as needed before the operation. | |
23548 | ||
23549 | @item | |
23550 | If the device supports RAM larger than 64@tie{}KiB and the compiler | |
23551 | needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ} | |
23552 | is reset to zero after the operation. | |
23553 | ||
23554 | @item | |
23555 | If the device comes with a specific @code{RAMP} register, the ISR | |
23556 | prologue/epilogue saves/restores that SFR and initializes it with | |
23557 | zero in case the ISR code might (implicitly) use it. | |
23558 | ||
23559 | @item | |
23560 | RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets. | |
23561 | If you use inline assembler to read from locations outside the | |
23562 | 16-bit address range and change one of the @code{RAMP} registers, | |
23563 | you must reset it to zero after the access. | |
23564 | ||
23565 | @end itemize | |
23566 | ||
23567 | @subsubsection AVR Built-in Macros | |
23568 | ||
23569 | GCC defines several built-in macros so that the user code can test | |
23570 | for the presence or absence of features. Almost any of the following | |
23571 | built-in macros are deduced from device capabilities and thus | |
23572 | triggered by the @option{-mmcu=} command-line option. | |
23573 | ||
23574 | For even more AVR-specific built-in macros see | |
23575 | @ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}. | |
23576 | ||
23577 | @table @code | |
23578 | ||
23579 | @item __AVR_ARCH__ | |
23580 | Build-in macro that resolves to a decimal number that identifies the | |
23581 | architecture and depends on the @option{-mmcu=@var{mcu}} option. | |
23582 | Possible values are: | |
23583 | ||
23584 | @code{2}, @code{25}, @code{3}, @code{31}, @code{35}, | |
23585 | @code{4}, @code{5}, @code{51}, @code{6} | |
23586 | ||
23587 | for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31}, | |
23588 | @code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6}, | |
23589 | ||
23590 | respectively and | |
23591 | ||
23592 | @code{100}, | |
23593 | @code{102}, @code{103}, @code{104}, | |
23594 | @code{105}, @code{106}, @code{107} | |
23595 | ||
23596 | for @var{mcu}=@code{avrtiny}, | |
23597 | @code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4}, | |
23598 | @code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively. | |
23599 | If @var{mcu} specifies a device, this built-in macro is set | |
23600 | accordingly. For example, with @option{-mmcu=atmega8} the macro is | |
23601 | defined to @code{4}. | |
23602 | ||
23603 | @item __AVR_@var{Device}__ | |
23604 | Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects | |
23605 | the device's name. For example, @option{-mmcu=atmega8} defines the | |
23606 | built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines | |
23607 | @code{__AVR_ATtiny261A__}, etc. | |
23608 | ||
23609 | The built-in macros' names follow | |
23610 | the scheme @code{__AVR_@var{Device}__} where @var{Device} is | |
23611 | the device name as from the AVR user manual. The difference between | |
23612 | @var{Device} in the built-in macro and @var{device} in | |
23613 | @option{-mmcu=@var{device}} is that the latter is always lowercase. | |
23614 | ||
23615 | If @var{device} is not a device but only a core architecture like | |
23616 | @samp{avr51}, this macro is not defined. | |
23617 | ||
23618 | @item __AVR_DEVICE_NAME__ | |
23619 | Setting @option{-mmcu=@var{device}} defines this built-in macro to | |
23620 | the device's name. For example, with @option{-mmcu=atmega8} the macro | |
23621 | is defined to @code{atmega8}. | |
23622 | ||
23623 | If @var{device} is not a device but only a core architecture like | |
23624 | @samp{avr51}, this macro is not defined. | |
23625 | ||
23626 | @item __AVR_XMEGA__ | |
23627 | The device / architecture belongs to the XMEGA family of devices. | |
23628 | ||
23629 | @item __AVR_HAVE_ELPM__ | |
23630 | The device has the @code{ELPM} instruction. | |
23631 | ||
23632 | @item __AVR_HAVE_ELPMX__ | |
23633 | The device has the @code{ELPM R@var{n},Z} and @code{ELPM | |
23634 | R@var{n},Z+} instructions. | |
23635 | ||
23636 | @item __AVR_HAVE_MOVW__ | |
23637 | The device has the @code{MOVW} instruction to perform 16-bit | |
23638 | register-register moves. | |
23639 | ||
23640 | @item __AVR_HAVE_LPMX__ | |
23641 | The device has the @code{LPM R@var{n},Z} and | |
23642 | @code{LPM R@var{n},Z+} instructions. | |
23643 | ||
23644 | @item __AVR_HAVE_MUL__ | |
23645 | The device has a hardware multiplier. | |
23646 | ||
23647 | @item __AVR_HAVE_JMP_CALL__ | |
23648 | The device has the @code{JMP} and @code{CALL} instructions. | |
23649 | This is the case for devices with more than 8@tie{}KiB of program | |
23650 | memory. | |
23651 | ||
23652 | @item __AVR_HAVE_EIJMP_EICALL__ | |
23653 | @itemx __AVR_3_BYTE_PC__ | |
23654 | The device has the @code{EIJMP} and @code{EICALL} instructions. | |
23655 | This is the case for devices with more than 128@tie{}KiB of program memory. | |
23656 | This also means that the program counter | |
23657 | (PC) is 3@tie{}bytes wide. | |
23658 | ||
23659 | @item __AVR_2_BYTE_PC__ | |
23660 | The program counter (PC) is 2@tie{}bytes wide. This is the case for devices | |
23661 | with up to 128@tie{}KiB of program memory. | |
23662 | ||
23663 | @item __AVR_HAVE_8BIT_SP__ | |
23664 | @itemx __AVR_HAVE_16BIT_SP__ | |
23665 | The stack pointer (SP) register is treated as 8-bit respectively | |
23666 | 16-bit register by the compiler. | |
23667 | The definition of these macros is affected by @option{-mtiny-stack}. | |
23668 | ||
23669 | @item __AVR_HAVE_SPH__ | |
23670 | @itemx __AVR_SP8__ | |
23671 | The device has the SPH (high part of stack pointer) special function | |
23672 | register or has an 8-bit stack pointer, respectively. | |
23673 | The definition of these macros is affected by @option{-mmcu=} and | |
23674 | in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also | |
23675 | by @option{-msp8}. | |
23676 | ||
23677 | @item __AVR_HAVE_RAMPD__ | |
23678 | @itemx __AVR_HAVE_RAMPX__ | |
23679 | @itemx __AVR_HAVE_RAMPY__ | |
23680 | @itemx __AVR_HAVE_RAMPZ__ | |
23681 | The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY}, | |
23682 | @code{RAMPZ} special function register, respectively. | |
23683 | ||
23684 | @item __NO_INTERRUPTS__ | |
23685 | This macro reflects the @option{-mno-interrupts} command-line option. | |
23686 | ||
23687 | @item __AVR_ERRATA_SKIP__ | |
23688 | @itemx __AVR_ERRATA_SKIP_JMP_CALL__ | |
23689 | Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit | |
23690 | instructions because of a hardware erratum. Skip instructions are | |
23691 | @code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}. | |
23692 | The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also | |
23693 | set. | |
23694 | ||
23695 | @item __AVR_ISA_RMW__ | |
23696 | The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT). | |
23697 | ||
23698 | @item __AVR_SFR_OFFSET__=@var{offset} | |
23699 | Instructions that can address I/O special function registers directly | |
23700 | like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different | |
23701 | address as if addressed by an instruction to access RAM like @code{LD} | |
23702 | or @code{STS}. This offset depends on the device architecture and has | |
23703 | to be subtracted from the RAM address in order to get the | |
23704 | respective I/O@tie{}address. | |
23705 | ||
23706 | @item __AVR_SHORT_CALLS__ | |
23707 | The @option{-mshort-calls} command line option is set. | |
23708 | ||
23709 | @item __AVR_PM_BASE_ADDRESS__=@var{addr} | |
23710 | Some devices support reading from flash memory by means of @code{LD*} | |
23711 | instructions. The flash memory is seen in the data address space | |
23712 | at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro | |
23713 | is not defined, this feature is not available. If defined, | |
23714 | the address space is linear and there is no need to put | |
23715 | @code{.rodata} into RAM. This is handled by the default linker | |
23716 | description file, and is currently available for | |
23717 | @code{avrtiny} and @code{avrxmega3}. Even more convenient, | |
23718 | there is no need to use address spaces like @code{__flash} or | |
23719 | features like attribute @code{progmem} and @code{pgm_read_*}. | |
23720 | ||
23721 | @item __WITH_AVRLIBC__ | |
23722 | The compiler is configured to be used together with AVR-Libc. | |
23723 | See the @option{--with-avrlibc} configure option. | |
23724 | ||
23725 | @item __HAVE_DOUBLE_MULTILIB__ | |
23726 | Defined if @option{-mdouble=} acts as a multilib option. | |
23727 | ||
23728 | @item __HAVE_DOUBLE32__ | |
23729 | @itemx __HAVE_DOUBLE64__ | |
23730 | Defined if the compiler supports 32-bit double resp. 64-bit double. | |
23731 | The actual layout is specified by option @option{-mdouble=}. | |
23732 | ||
23733 | @item __DEFAULT_DOUBLE__ | |
23734 | The size in bits of @code{double} if @option{-mdouble=} is not set. | |
23735 | To test the layout of @code{double} in a program, use the built-in | |
23736 | macro @code{__SIZEOF_DOUBLE__}. | |
23737 | ||
23738 | @item __HAVE_LONG_DOUBLE32__ | |
23739 | @itemx __HAVE_LONG_DOUBLE64__ | |
23740 | @itemx __HAVE_LONG_DOUBLE_MULTILIB__ | |
23741 | @itemx __DEFAULT_LONG_DOUBLE__ | |
23742 | Same as above, but for @code{long double} instead of @code{double}. | |
23743 | ||
23744 | @item __WITH_DOUBLE_COMPARISON__ | |
23745 | Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}} | |
23746 | @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}} | |
23747 | and is defined to @code{2} or @code{3}. | |
23748 | ||
23749 | @item __WITH_LIBF7_LIBGCC__ | |
23750 | @itemx __WITH_LIBF7_MATH__ | |
23751 | @itemx __WITH_LIBF7_MATH_SYMBOLS__ | |
23752 | Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}} | |
23753 | @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}. | |
23754 | ||
23755 | @end table | |
23756 | ||
23757 | @node Blackfin Options | |
23758 | @subsection Blackfin Options | |
23759 | @cindex Blackfin Options | |
23760 | ||
23761 | @table @gcctabopt | |
d77de738 | 23762 | @opindex mcpu= |
ddf6fe37 | 23763 | @item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} |
d77de738 ML |
23764 | Specifies the name of the target Blackfin processor. Currently, @var{cpu} |
23765 | can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518}, | |
23766 | @samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526}, | |
23767 | @samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533}, | |
23768 | @samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539}, | |
23769 | @samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549}, | |
23770 | @samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m}, | |
23771 | @samp{bf561}, @samp{bf592}. | |
23772 | ||
23773 | The optional @var{sirevision} specifies the silicon revision of the target | |
23774 | Blackfin processor. Any workarounds available for the targeted silicon revision | |
23775 | are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled. | |
23776 | If @var{sirevision} is @samp{any}, all workarounds for the targeted processor | |
23777 | are enabled. The @code{__SILICON_REVISION__} macro is defined to two | |
23778 | hexadecimal digits representing the major and minor numbers in the silicon | |
23779 | revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__} | |
23780 | is not defined. If @var{sirevision} is @samp{any}, the | |
23781 | @code{__SILICON_REVISION__} is defined to be @code{0xffff}. | |
23782 | If this optional @var{sirevision} is not used, GCC assumes the latest known | |
23783 | silicon revision of the targeted Blackfin processor. | |
23784 | ||
23785 | GCC defines a preprocessor macro for the specified @var{cpu}. | |
23786 | For the @samp{bfin-elf} toolchain, this option causes the hardware BSP | |
23787 | provided by libgloss to be linked in if @option{-msim} is not given. | |
23788 | ||
23789 | Without this option, @samp{bf532} is used as the processor by default. | |
23790 | ||
23791 | Note that support for @samp{bf561} is incomplete. For @samp{bf561}, | |
23792 | only the preprocessor macro is defined. | |
23793 | ||
d77de738 | 23794 | @opindex msim |
ddf6fe37 | 23795 | @item -msim |
d77de738 ML |
23796 | Specifies that the program will be run on the simulator. This causes |
23797 | the simulator BSP provided by libgloss to be linked in. This option | |
23798 | has effect only for @samp{bfin-elf} toolchain. | |
23799 | Certain other options, such as @option{-mid-shared-library} and | |
23800 | @option{-mfdpic}, imply @option{-msim}. | |
23801 | ||
d77de738 | 23802 | @opindex momit-leaf-frame-pointer |
ddf6fe37 | 23803 | @item -momit-leaf-frame-pointer |
d77de738 ML |
23804 | Don't keep the frame pointer in a register for leaf functions. This |
23805 | avoids the instructions to save, set up and restore frame pointers and | |
23806 | makes an extra register available in leaf functions. | |
23807 | ||
d77de738 | 23808 | @opindex mspecld-anomaly |
ddf6fe37 | 23809 | @item -mspecld-anomaly |
d77de738 ML |
23810 | When enabled, the compiler ensures that the generated code does not |
23811 | contain speculative loads after jump instructions. If this option is used, | |
23812 | @code{__WORKAROUND_SPECULATIVE_LOADS} is defined. | |
23813 | ||
d77de738 ML |
23814 | @opindex mno-specld-anomaly |
23815 | @opindex mspecld-anomaly | |
ddf6fe37 | 23816 | @item -mno-specld-anomaly |
d77de738 ML |
23817 | Don't generate extra code to prevent speculative loads from occurring. |
23818 | ||
d77de738 | 23819 | @opindex mcsync-anomaly |
ddf6fe37 | 23820 | @item -mcsync-anomaly |
d77de738 ML |
23821 | When enabled, the compiler ensures that the generated code does not |
23822 | contain CSYNC or SSYNC instructions too soon after conditional branches. | |
23823 | If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined. | |
23824 | ||
d77de738 ML |
23825 | @opindex mno-csync-anomaly |
23826 | @opindex mcsync-anomaly | |
ddf6fe37 | 23827 | @item -mno-csync-anomaly |
d77de738 ML |
23828 | Don't generate extra code to prevent CSYNC or SSYNC instructions from |
23829 | occurring too soon after a conditional branch. | |
23830 | ||
d77de738 | 23831 | @opindex mlow64k |
ddf6fe37 | 23832 | @item -mlow64k |
d77de738 ML |
23833 | When enabled, the compiler is free to take advantage of the knowledge that |
23834 | the entire program fits into the low 64k of memory. | |
23835 | ||
d77de738 | 23836 | @opindex mno-low64k |
ddf6fe37 | 23837 | @item -mno-low64k |
d77de738 ML |
23838 | Assume that the program is arbitrarily large. This is the default. |
23839 | ||
d77de738 | 23840 | @opindex mstack-check-l1 |
ddf6fe37 | 23841 | @item -mstack-check-l1 |
d77de738 ML |
23842 | Do stack checking using information placed into L1 scratchpad memory by the |
23843 | uClinux kernel. | |
23844 | ||
d77de738 | 23845 | @opindex mid-shared-library |
ddf6fe37 | 23846 | @item -mid-shared-library |
d77de738 ML |
23847 | Generate code that supports shared libraries via the library ID method. |
23848 | This allows for execute in place and shared libraries in an environment | |
23849 | without virtual memory management. This option implies @option{-fPIC}. | |
23850 | With a @samp{bfin-elf} target, this option implies @option{-msim}. | |
23851 | ||
d77de738 ML |
23852 | @opindex mno-id-shared-library |
23853 | @opindex mid-shared-library | |
ddf6fe37 | 23854 | @item -mno-id-shared-library |
d77de738 ML |
23855 | Generate code that doesn't assume ID-based shared libraries are being used. |
23856 | This is the default. | |
23857 | ||
d77de738 | 23858 | @opindex mleaf-id-shared-library |
ddf6fe37 | 23859 | @item -mleaf-id-shared-library |
d77de738 ML |
23860 | Generate code that supports shared libraries via the library ID method, |
23861 | but assumes that this library or executable won't link against any other | |
23862 | ID shared libraries. That allows the compiler to use faster code for jumps | |
23863 | and calls. | |
23864 | ||
d77de738 ML |
23865 | @opindex mno-leaf-id-shared-library |
23866 | @opindex mleaf-id-shared-library | |
ddf6fe37 | 23867 | @item -mno-leaf-id-shared-library |
d77de738 ML |
23868 | Do not assume that the code being compiled won't link against any ID shared |
23869 | libraries. Slower code is generated for jump and call insns. | |
23870 | ||
d77de738 | 23871 | @opindex mshared-library-id |
ddf6fe37 | 23872 | @item -mshared-library-id=n |
d77de738 ML |
23873 | Specifies the identification number of the ID-based shared library being |
23874 | compiled. Specifying a value of 0 generates more compact code; specifying | |
23875 | other values forces the allocation of that number to the current | |
23876 | library but is no more space- or time-efficient than omitting this option. | |
23877 | ||
d77de738 | 23878 | @opindex msep-data |
ddf6fe37 | 23879 | @item -msep-data |
d77de738 ML |
23880 | Generate code that allows the data segment to be located in a different |
23881 | area of memory from the text segment. This allows for execute in place in | |
23882 | an environment without virtual memory management by eliminating relocations | |
23883 | against the text section. | |
23884 | ||
d77de738 ML |
23885 | @opindex mno-sep-data |
23886 | @opindex msep-data | |
ddf6fe37 | 23887 | @item -mno-sep-data |
d77de738 ML |
23888 | Generate code that assumes that the data segment follows the text segment. |
23889 | This is the default. | |
23890 | ||
d77de738 ML |
23891 | @opindex mlong-calls |
23892 | @opindex mno-long-calls | |
ddf6fe37 AA |
23893 | @item -mlong-calls |
23894 | @itemx -mno-long-calls | |
d77de738 ML |
23895 | Tells the compiler to perform function calls by first loading the |
23896 | address of the function into a register and then performing a subroutine | |
23897 | call on this register. This switch is needed if the target function | |
23898 | lies outside of the 24-bit addressing range of the offset-based | |
23899 | version of subroutine call instruction. | |
23900 | ||
23901 | This feature is not enabled by default. Specifying | |
23902 | @option{-mno-long-calls} restores the default behavior. Note these | |
23903 | switches have no effect on how the compiler generates code to handle | |
23904 | function calls via function pointers. | |
23905 | ||
d77de738 | 23906 | @opindex mfast-fp |
ddf6fe37 | 23907 | @item -mfast-fp |
d77de738 ML |
23908 | Link with the fast floating-point library. This library relaxes some of |
23909 | the IEEE floating-point standard's rules for checking inputs against | |
23910 | Not-a-Number (NAN), in the interest of performance. | |
23911 | ||
d77de738 | 23912 | @opindex minline-plt |
ddf6fe37 | 23913 | @item -minline-plt |
d77de738 ML |
23914 | Enable inlining of PLT entries in function calls to functions that are |
23915 | not known to bind locally. It has no effect without @option{-mfdpic}. | |
23916 | ||
d77de738 | 23917 | @opindex mmulticore |
ddf6fe37 | 23918 | @item -mmulticore |
d77de738 ML |
23919 | Build a standalone application for multicore Blackfin processors. |
23920 | This option causes proper start files and link scripts supporting | |
23921 | multicore to be used, and defines the macro @code{__BFIN_MULTICORE}. | |
23922 | It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}. | |
23923 | ||
23924 | This option can be used with @option{-mcorea} or @option{-mcoreb}, which | |
23925 | selects the one-application-per-core programming model. Without | |
23926 | @option{-mcorea} or @option{-mcoreb}, the single-application/dual-core | |
23927 | programming model is used. In this model, the main function of Core B | |
23928 | should be named as @code{coreb_main}. | |
23929 | ||
23930 | If this option is not used, the single-core application programming | |
23931 | model is used. | |
23932 | ||
d77de738 | 23933 | @opindex mcorea |
ddf6fe37 | 23934 | @item -mcorea |
d77de738 ML |
23935 | Build a standalone application for Core A of BF561 when using |
23936 | the one-application-per-core programming model. Proper start files | |
23937 | and link scripts are used to support Core A, and the macro | |
23938 | @code{__BFIN_COREA} is defined. | |
23939 | This option can only be used in conjunction with @option{-mmulticore}. | |
23940 | ||
d77de738 | 23941 | @opindex mcoreb |
ddf6fe37 | 23942 | @item -mcoreb |
d77de738 ML |
23943 | Build a standalone application for Core B of BF561 when using |
23944 | the one-application-per-core programming model. Proper start files | |
23945 | and link scripts are used to support Core B, and the macro | |
23946 | @code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main} | |
23947 | should be used instead of @code{main}. | |
23948 | This option can only be used in conjunction with @option{-mmulticore}. | |
23949 | ||
d77de738 | 23950 | @opindex msdram |
ddf6fe37 | 23951 | @item -msdram |
d77de738 ML |
23952 | Build a standalone application for SDRAM. Proper start files and |
23953 | link scripts are used to put the application into SDRAM, and the macro | |
23954 | @code{__BFIN_SDRAM} is defined. | |
23955 | The loader should initialize SDRAM before loading the application. | |
23956 | ||
d77de738 | 23957 | @opindex micplb |
ddf6fe37 | 23958 | @item -micplb |
d77de738 ML |
23959 | Assume that ICPLBs are enabled at run time. This has an effect on certain |
23960 | anomaly workarounds. For Linux targets, the default is to assume ICPLBs | |
23961 | are enabled; for standalone applications the default is off. | |
23962 | @end table | |
23963 | ||
23964 | @node C6X Options | |
23965 | @subsection C6X Options | |
23966 | @cindex C6X Options | |
23967 | ||
23968 | @table @gcctabopt | |
d77de738 | 23969 | @opindex march |
ddf6fe37 | 23970 | @item -march=@var{name} |
d77de738 ML |
23971 | This specifies the name of the target architecture. GCC uses this |
23972 | name to determine what kind of instructions it can emit when generating | |
23973 | assembly code. Permissible names are: @samp{c62x}, | |
23974 | @samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}. | |
23975 | ||
d77de738 | 23976 | @opindex mbig-endian |
ddf6fe37 | 23977 | @item -mbig-endian |
d77de738 ML |
23978 | Generate code for a big-endian target. |
23979 | ||
d77de738 | 23980 | @opindex mlittle-endian |
ddf6fe37 | 23981 | @item -mlittle-endian |
d77de738 ML |
23982 | Generate code for a little-endian target. This is the default. |
23983 | ||
d77de738 | 23984 | @opindex msim |
ddf6fe37 | 23985 | @item -msim |
d77de738 ML |
23986 | Choose startup files and linker script suitable for the simulator. |
23987 | ||
d77de738 | 23988 | @opindex msdata=default |
ddf6fe37 | 23989 | @item -msdata=default |
d77de738 ML |
23990 | Put small global and static data in the @code{.neardata} section, |
23991 | which is pointed to by register @code{B14}. Put small uninitialized | |
23992 | global and static data in the @code{.bss} section, which is adjacent | |
23993 | to the @code{.neardata} section. Put small read-only data into the | |
23994 | @code{.rodata} section. The corresponding sections used for large | |
23995 | pieces of data are @code{.fardata}, @code{.far} and @code{.const}. | |
23996 | ||
d77de738 | 23997 | @opindex msdata=all |
ddf6fe37 | 23998 | @item -msdata=all |
d77de738 ML |
23999 | Put all data, not just small objects, into the sections reserved for |
24000 | small data, and use addressing relative to the @code{B14} register to | |
24001 | access them. | |
24002 | ||
d77de738 | 24003 | @opindex msdata=none |
ddf6fe37 | 24004 | @item -msdata=none |
d77de738 ML |
24005 | Make no use of the sections reserved for small data, and use absolute |
24006 | addresses to access all data. Put all initialized global and static | |
24007 | data in the @code{.fardata} section, and all uninitialized data in the | |
24008 | @code{.far} section. Put all constant data into the @code{.const} | |
24009 | section. | |
24010 | @end table | |
24011 | ||
24012 | @node CRIS Options | |
24013 | @subsection CRIS Options | |
24014 | @cindex CRIS Options | |
24015 | ||
24016 | These options are defined specifically for the CRIS ports. | |
24017 | ||
24018 | @table @gcctabopt | |
d77de738 ML |
24019 | @opindex march |
24020 | @opindex mcpu | |
ddf6fe37 AA |
24021 | @item -march=@var{architecture-type} |
24022 | @itemx -mcpu=@var{architecture-type} | |
d77de738 ML |
24023 | Generate code for the specified architecture. The choices for |
24024 | @var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for | |
24025 | respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@. | |
24026 | Default is @samp{v0}. | |
24027 | ||
d77de738 | 24028 | @opindex mtune |
ddf6fe37 | 24029 | @item -mtune=@var{architecture-type} |
d77de738 ML |
24030 | Tune to @var{architecture-type} everything applicable about the generated |
24031 | code, except for the ABI and the set of available instructions. The | |
24032 | choices for @var{architecture-type} are the same as for | |
24033 | @option{-march=@var{architecture-type}}. | |
24034 | ||
d77de738 | 24035 | @opindex mmax-stack-frame |
ddf6fe37 | 24036 | @item -mmax-stack-frame=@var{n} |
d77de738 ML |
24037 | Warn when the stack frame of a function exceeds @var{n} bytes. |
24038 | ||
d77de738 ML |
24039 | @opindex metrax4 |
24040 | @opindex metrax100 | |
ddf6fe37 AA |
24041 | @item -metrax4 |
24042 | @itemx -metrax100 | |
d77de738 ML |
24043 | The options @option{-metrax4} and @option{-metrax100} are synonyms for |
24044 | @option{-march=v3} and @option{-march=v8} respectively. | |
24045 | ||
d77de738 ML |
24046 | @opindex mmul-bug-workaround |
24047 | @opindex mno-mul-bug-workaround | |
ddf6fe37 AA |
24048 | @item -mmul-bug-workaround |
24049 | @itemx -mno-mul-bug-workaround | |
d77de738 ML |
24050 | Work around a bug in the @code{muls} and @code{mulu} instructions for CPU |
24051 | models where it applies. This option is disabled by default. | |
24052 | ||
d77de738 | 24053 | @opindex mpdebug |
ddf6fe37 | 24054 | @item -mpdebug |
d77de738 ML |
24055 | Enable CRIS-specific verbose debug-related information in the assembly |
24056 | code. This option also has the effect of turning off the @samp{#NO_APP} | |
24057 | formatted-code indicator to the assembler at the beginning of the | |
24058 | assembly file. | |
24059 | ||
d77de738 | 24060 | @opindex mcc-init |
ddf6fe37 | 24061 | @item -mcc-init |
d77de738 ML |
24062 | Do not use condition-code results from previous instruction; always emit |
24063 | compare and test instructions before use of condition codes. | |
24064 | ||
d77de738 ML |
24065 | @opindex mno-side-effects |
24066 | @opindex mside-effects | |
ddf6fe37 | 24067 | @item -mno-side-effects |
d77de738 ML |
24068 | Do not emit instructions with side effects in addressing modes other than |
24069 | post-increment. | |
24070 | ||
d77de738 ML |
24071 | @opindex mstack-align |
24072 | @opindex mno-stack-align | |
24073 | @opindex mdata-align | |
24074 | @opindex mno-data-align | |
24075 | @opindex mconst-align | |
24076 | @opindex mno-const-align | |
ddf6fe37 AA |
24077 | @item -mstack-align |
24078 | @itemx -mno-stack-align | |
24079 | @itemx -mdata-align | |
24080 | @itemx -mno-data-align | |
24081 | @itemx -mconst-align | |
24082 | @itemx -mno-const-align | |
d77de738 ML |
24083 | These options (@samp{no-} options) arrange (eliminate arrangements) for the |
24084 | stack frame, individual data and constants to be aligned for the maximum | |
24085 | single data access size for the chosen CPU model. The default is to | |
24086 | arrange for 32-bit alignment. ABI details such as structure layout are | |
24087 | not affected by these options. | |
24088 | ||
d77de738 ML |
24089 | @opindex m32-bit |
24090 | @opindex m16-bit | |
24091 | @opindex m8-bit | |
ddf6fe37 AA |
24092 | @item -m32-bit |
24093 | @itemx -m16-bit | |
24094 | @itemx -m8-bit | |
d77de738 ML |
24095 | Similar to the stack- data- and const-align options above, these options |
24096 | arrange for stack frame, writable data and constants to all be 32-bit, | |
24097 | 16-bit or 8-bit aligned. The default is 32-bit alignment. | |
24098 | ||
d77de738 ML |
24099 | @opindex mno-prologue-epilogue |
24100 | @opindex mprologue-epilogue | |
ddf6fe37 AA |
24101 | @item -mno-prologue-epilogue |
24102 | @itemx -mprologue-epilogue | |
d77de738 ML |
24103 | With @option{-mno-prologue-epilogue}, the normal function prologue and |
24104 | epilogue which set up the stack frame are omitted and no return | |
24105 | instructions or return sequences are generated in the code. Use this | |
24106 | option only together with visual inspection of the compiled code: no | |
24107 | warnings or errors are generated when call-saved registers must be saved, | |
24108 | or storage for local variables needs to be allocated. | |
24109 | ||
d77de738 | 24110 | @opindex melf |
ddf6fe37 | 24111 | @item -melf |
d77de738 ML |
24112 | Legacy no-op option. |
24113 | ||
d77de738 | 24114 | @opindex sim |
ddf6fe37 | 24115 | @item -sim |
d77de738 ML |
24116 | This option arranges |
24117 | to link with input-output functions from a simulator library. Code, | |
24118 | initialized data and zero-initialized data are allocated consecutively. | |
24119 | ||
d77de738 | 24120 | @opindex sim2 |
ddf6fe37 | 24121 | @item -sim2 |
d77de738 ML |
24122 | Like @option{-sim}, but pass linker options to locate initialized data at |
24123 | 0x40000000 and zero-initialized data at 0x80000000. | |
24124 | @end table | |
24125 | ||
24126 | @node C-SKY Options | |
24127 | @subsection C-SKY Options | |
24128 | @cindex C-SKY Options | |
24129 | ||
24130 | GCC supports these options when compiling for C-SKY V2 processors. | |
24131 | ||
24132 | @table @gcctabopt | |
24133 | ||
d77de738 | 24134 | @opindex march= |
ddf6fe37 | 24135 | @item -march=@var{arch} |
d77de738 ML |
24136 | Specify the C-SKY target architecture. Valid values for @var{arch} are: |
24137 | @samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}. | |
24138 | The default is @samp{ck810}. | |
24139 | ||
d77de738 | 24140 | @opindex mcpu= |
ddf6fe37 | 24141 | @item -mcpu=@var{cpu} |
d77de738 ML |
24142 | Specify the C-SKY target processor. Valid values for @var{cpu} are: |
24143 | @samp{ck801}, @samp{ck801t}, | |
24144 | @samp{ck802}, @samp{ck802t}, @samp{ck802j}, | |
24145 | @samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht}, | |
24146 | @samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh}, | |
24147 | @samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh}, | |
24148 | @samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1}, | |
24149 | @samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1}, | |
24150 | @samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1}, | |
24151 | @samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1}, | |
24152 | @samp{ck803eftr1}, @samp{ck803efhtr1}, | |
24153 | @samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf}, | |
24154 | @samp{ck803sef}, @samp{ck803seft}, | |
24155 | @samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f}, | |
24156 | @samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft}, | |
24157 | @samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv}, | |
24158 | @samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}. | |
24159 | ||
d77de738 | 24160 | @opindex mbig-endian |
d77de738 | 24161 | @opindex EB |
d77de738 | 24162 | @opindex mlittle-endian |
d77de738 | 24163 | @opindex EL |
ddf6fe37 AA |
24164 | @item -mbig-endian |
24165 | @itemx -EB | |
24166 | @itemx -mlittle-endian | |
24167 | @itemx -EL | |
d77de738 ML |
24168 | |
24169 | Select big- or little-endian code. The default is little-endian. | |
24170 | ||
d77de738 | 24171 | @opindex mfloat-abi |
ddf6fe37 | 24172 | @item -mfloat-abi=@var{name} |
d77de738 ML |
24173 | Specifies which floating-point ABI to use. Permissible values |
24174 | are: @samp{soft}, @samp{softfp} and @samp{hard}. | |
24175 | ||
24176 | Specifying @samp{soft} causes GCC to generate output containing | |
24177 | library calls for floating-point operations. | |
24178 | @samp{softfp} allows the generation of code using hardware floating-point | |
24179 | instructions, but still uses the soft-float calling conventions. | |
24180 | @samp{hard} allows generation of floating-point instructions | |
24181 | and uses FPU-specific calling conventions. | |
24182 | ||
24183 | The default depends on the specific target configuration. Note that | |
24184 | the hard-float and soft-float ABIs are not link-compatible; you must | |
24185 | compile your entire program with the same ABI, and link with a | |
24186 | compatible set of libraries. | |
24187 | ||
d77de738 | 24188 | @opindex mhard-float |
d77de738 | 24189 | @opindex msoft-float |
ddf6fe37 AA |
24190 | @item -mhard-float |
24191 | @itemx -msoft-float | |
d77de738 ML |
24192 | |
24193 | Select hardware or software floating-point implementations. | |
24194 | The default is soft float. | |
24195 | ||
ddf6fe37 | 24196 | @opindex mdouble-float |
d77de738 ML |
24197 | @item -mdouble-float |
24198 | @itemx -mno-double-float | |
d77de738 ML |
24199 | When @option{-mhard-float} is in effect, enable generation of |
24200 | double-precision float instructions. This is the default except | |
24201 | when compiling for CK803. | |
24202 | ||
ddf6fe37 | 24203 | @opindex mfdivdu |
d77de738 ML |
24204 | @item -mfdivdu |
24205 | @itemx -mno-fdivdu | |
d77de738 ML |
24206 | When @option{-mhard-float} is in effect, enable generation of |
24207 | @code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions. | |
24208 | This is the default except when compiling for CK803. | |
24209 | ||
d77de738 | 24210 | @opindex mfpu= |
ddf6fe37 | 24211 | @item -mfpu=@var{fpu} |
d77de738 ML |
24212 | Select the floating-point processor. This option can only be used with |
24213 | @option{-mhard-float}. | |
24214 | Values for @var{fpu} are | |
24215 | @samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}), | |
24216 | @samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and | |
24217 | @samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}). | |
24218 | ||
ddf6fe37 | 24219 | @opindex melrw |
d77de738 ML |
24220 | @item -melrw |
24221 | @itemx -mno-elrw | |
d77de738 ML |
24222 | Enable the extended @code{lrw} instruction. This option defaults to on |
24223 | for CK801 and off otherwise. | |
24224 | ||
ddf6fe37 | 24225 | @opindex mistack |
d77de738 ML |
24226 | @item -mistack |
24227 | @itemx -mno-istack | |
d77de738 ML |
24228 | Enable interrupt stack instructions; the default is off. |
24229 | ||
24230 | The @option{-mistack} option is required to handle the | |
24231 | @code{interrupt} and @code{isr} function attributes | |
24232 | (@pxref{C-SKY Function Attributes}). | |
24233 | ||
d77de738 | 24234 | @opindex mmp |
ddf6fe37 | 24235 | @item -mmp |
d77de738 ML |
24236 | Enable multiprocessor instructions; the default is off. |
24237 | ||
d77de738 | 24238 | @opindex mcp |
ddf6fe37 | 24239 | @item -mcp |
d77de738 ML |
24240 | Enable coprocessor instructions; the default is off. |
24241 | ||
d77de738 | 24242 | @opindex mcache |
ddf6fe37 | 24243 | @item -mcache |
d77de738 ML |
24244 | Enable coprocessor instructions; the default is off. |
24245 | ||
d77de738 | 24246 | @opindex msecurity |
ddf6fe37 | 24247 | @item -msecurity |
d77de738 ML |
24248 | Enable C-SKY security instructions; the default is off. |
24249 | ||
d77de738 | 24250 | @opindex mtrust |
ddf6fe37 | 24251 | @item -mtrust |
d77de738 ML |
24252 | Enable C-SKY trust instructions; the default is off. |
24253 | ||
d77de738 | 24254 | @opindex mdsp |
d77de738 | 24255 | @opindex medsp |
d77de738 | 24256 | @opindex mvdsp |
ddf6fe37 AA |
24257 | @item -mdsp |
24258 | @itemx -medsp | |
24259 | @itemx -mvdsp | |
d77de738 ML |
24260 | Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively. |
24261 | All of these options default to off. | |
24262 | ||
ddf6fe37 | 24263 | @opindex mdiv |
d77de738 ML |
24264 | @item -mdiv |
24265 | @itemx -mno-div | |
d77de738 ML |
24266 | Generate divide instructions. Default is off. |
24267 | ||
ddf6fe37 | 24268 | @opindex msmart |
d77de738 ML |
24269 | @item -msmart |
24270 | @itemx -mno-smart | |
d77de738 ML |
24271 | Generate code for Smart Mode, using only registers numbered 0-7 to allow |
24272 | use of 16-bit instructions. This option is ignored for CK801 where this | |
24273 | is the required behavior, and it defaults to on for CK802. | |
24274 | For other targets, the default is off. | |
24275 | ||
ddf6fe37 | 24276 | @opindex mhigh-registers |
d77de738 ML |
24277 | @item -mhigh-registers |
24278 | @itemx -mno-high-registers | |
d77de738 ML |
24279 | Generate code using the high registers numbered 16-31. This option |
24280 | is not supported on CK801, CK802, or CK803, and is enabled by default | |
24281 | for other processors. | |
24282 | ||
ddf6fe37 | 24283 | @opindex manchor |
d77de738 ML |
24284 | @item -manchor |
24285 | @itemx -mno-anchor | |
d77de738 ML |
24286 | Generate code using global anchor symbol addresses. |
24287 | ||
ddf6fe37 | 24288 | @opindex mpushpop |
d77de738 ML |
24289 | @item -mpushpop |
24290 | @itemx -mno-pushpop | |
d77de738 ML |
24291 | Generate code using @code{push} and @code{pop} instructions. This option |
24292 | defaults to on. | |
24293 | ||
ddf6fe37 | 24294 | @opindex mmultiple-stld |
d77de738 ML |
24295 | @item -mmultiple-stld |
24296 | @itemx -mstm | |
24297 | @itemx -mno-multiple-stld | |
24298 | @itemx -mno-stm | |
d77de738 ML |
24299 | Generate code using @code{stm} and @code{ldm} instructions. This option |
24300 | isn't supported on CK801 but is enabled by default on other processors. | |
24301 | ||
ddf6fe37 | 24302 | @opindex mconstpool |
d77de738 ML |
24303 | @item -mconstpool |
24304 | @itemx -mno-constpool | |
d77de738 ML |
24305 | Create constant pools in the compiler instead of deferring it to the |
24306 | assembler. This option is the default and required for correct code | |
24307 | generation on CK801 and CK802, and is optional on other processors. | |
24308 | ||
ddf6fe37 | 24309 | @opindex mstack-size |
d77de738 ML |
24310 | @item -mstack-size |
24311 | @item -mno-stack-size | |
d77de738 ML |
24312 | Emit @code{.stack_size} directives for each function in the assembly |
24313 | output. This option defaults to off. | |
24314 | ||
ddf6fe37 | 24315 | @opindex mccrt |
d77de738 ML |
24316 | @item -mccrt |
24317 | @itemx -mno-ccrt | |
d77de738 ML |
24318 | Generate code for the C-SKY compiler runtime instead of libgcc. This |
24319 | option defaults to off. | |
24320 | ||
d77de738 | 24321 | @opindex mbranch-cost= |
ddf6fe37 | 24322 | @item -mbranch-cost=@var{n} |
d77de738 ML |
24323 | Set the branch costs to roughly @code{n} instructions. The default is 1. |
24324 | ||
ddf6fe37 | 24325 | @opindex msched-prolog |
d77de738 ML |
24326 | @item -msched-prolog |
24327 | @itemx -mno-sched-prolog | |
d77de738 ML |
24328 | Permit scheduling of function prologue and epilogue sequences. Using |
24329 | this option can result in code that is not compliant with the C-SKY V2 ABI | |
24330 | prologue requirements and that cannot be debugged or backtraced. | |
24331 | It is disabled by default. | |
24332 | ||
d77de738 | 24333 | @opindex msim |
ddf6fe37 | 24334 | @item -msim |
d77de738 ML |
24335 | Links the library libsemi.a which is in compatible with simulator. Applicable |
24336 | to ELF compiler only. | |
24337 | ||
24338 | @end table | |
24339 | ||
24340 | @node Darwin Options | |
24341 | @subsection Darwin Options | |
24342 | @cindex Darwin options | |
24343 | ||
24344 | These options are defined for all architectures running the Darwin operating | |
24345 | system. | |
24346 | ||
24347 | FSF GCC on Darwin does not create ``fat'' object files; it creates | |
24348 | an object file for the single architecture that GCC was built to | |
24349 | target. Apple's GCC on Darwin does create ``fat'' files if multiple | |
24350 | @option{-arch} options are used; it does so by running the compiler or | |
24351 | linker multiple times and joining the results together with | |
24352 | @file{lipo}. | |
24353 | ||
24354 | The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or | |
24355 | @samp{i686}) is determined by the flags that specify the ISA | |
24356 | that GCC is targeting, like @option{-mcpu} or @option{-march}. The | |
24357 | @option{-force_cpusubtype_ALL} option can be used to override this. | |
24358 | ||
24359 | The Darwin tools vary in their behavior when presented with an ISA | |
24360 | mismatch. The assembler, @file{as}, only permits instructions to | |
24361 | be used that are valid for the subtype of the file it is generating, | |
24362 | so you cannot put 64-bit instructions in a @samp{ppc750} object file. | |
24363 | The linker for shared libraries, @file{/usr/bin/libtool}, fails | |
24364 | and prints an error if asked to create a shared library with a less | |
24365 | restrictive subtype than its input files (for instance, trying to put | |
24366 | a @samp{ppc970} object file in a @samp{ppc7400} library). The linker | |
24367 | for executables, @command{ld}, quietly gives the executable the most | |
24368 | restrictive subtype of any of its input files. | |
24369 | ||
24370 | @table @gcctabopt | |
d77de738 | 24371 | @opindex F |
ddf6fe37 | 24372 | @item -F@var{dir} |
d77de738 ML |
24373 | Add the framework directory @var{dir} to the head of the list of |
24374 | directories to be searched for header files. These directories are | |
24375 | interleaved with those specified by @option{-I} options and are | |
24376 | scanned in a left-to-right order. | |
24377 | ||
24378 | A framework directory is a directory with frameworks in it. A | |
24379 | framework is a directory with a @file{Headers} and/or | |
24380 | @file{PrivateHeaders} directory contained directly in it that ends | |
24381 | in @file{.framework}. The name of a framework is the name of this | |
24382 | directory excluding the @file{.framework}. Headers associated with | |
24383 | the framework are found in one of those two directories, with | |
24384 | @file{Headers} being searched first. A subframework is a framework | |
24385 | directory that is in a framework's @file{Frameworks} directory. | |
24386 | Includes of subframework headers can only appear in a header of a | |
24387 | framework that contains the subframework, or in a sibling subframework | |
24388 | header. Two subframeworks are siblings if they occur in the same | |
24389 | framework. A subframework should not have the same name as a | |
24390 | framework; a warning is issued if this is violated. Currently a | |
24391 | subframework cannot have subframeworks; in the future, the mechanism | |
24392 | may be extended to support this. The standard frameworks can be found | |
24393 | in @file{/System/Library/Frameworks} and | |
24394 | @file{/Library/Frameworks}. An example include looks like | |
24395 | @code{#include <Framework/header.h>}, where @file{Framework} denotes | |
24396 | the name of the framework and @file{header.h} is found in the | |
24397 | @file{PrivateHeaders} or @file{Headers} directory. | |
24398 | ||
d77de738 | 24399 | @opindex iframework |
ddf6fe37 | 24400 | @item -iframework@var{dir} |
d77de738 ML |
24401 | Like @option{-F} except the directory is a treated as a system |
24402 | directory. The main difference between this @option{-iframework} and | |
24403 | @option{-F} is that with @option{-iframework} the compiler does not | |
24404 | warn about constructs contained within header files found via | |
24405 | @var{dir}. This option is valid only for the C family of languages. | |
24406 | ||
d77de738 | 24407 | @opindex gused |
ddf6fe37 | 24408 | @item -gused |
d77de738 ML |
24409 | Emit debugging information for symbols that are used. For stabs |
24410 | debugging format, this enables @option{-feliminate-unused-debug-symbols}. | |
24411 | This is by default ON@. | |
24412 | ||
d77de738 | 24413 | @opindex gfull |
ddf6fe37 | 24414 | @item -gfull |
d77de738 ML |
24415 | Emit debugging information for all symbols and types. |
24416 | ||
cdd4b3c0 IS |
24417 | @opindex fconstant-cfstrings |
24418 | @item -fconstant-cfstrings | |
24419 | The @option{-fconstant-cfstrings} is an alias for @option{-mconstant-cfstrings}. | |
24420 | ||
24421 | @opindex mconstant-cfstrings | |
24422 | @item -mconstant-cfstrings | |
24423 | When the NeXT runtime is being used (the default on these systems), override | |
24424 | any @option{-fconstant-string-class} setting and cause @code{@@"@dots{}"} | |
24425 | literals to be laid out as constant CoreFoundation strings. | |
24426 | ||
24427 | @opindex mmacosx-version-min | |
d77de738 | 24428 | @item -mmacosx-version-min=@var{version} |
cdd4b3c0 IS |
24429 | The earliest version of MacOS X that this executable will run on is |
24430 | @var{version}. Typical values supported for @var{version} include @code{12}, | |
24431 | @code{10.12}, and @code{10.5.8}. | |
d77de738 ML |
24432 | |
24433 | If the compiler was built to use the system's headers by default, | |
24434 | then the default for this option is the system version on which the | |
24435 | compiler is running, otherwise the default is to make choices that | |
24436 | are compatible with as many systems and code bases as possible. | |
24437 | ||
d77de738 | 24438 | @opindex mkernel |
ddf6fe37 | 24439 | @item -mkernel |
d77de738 ML |
24440 | Enable kernel development mode. The @option{-mkernel} option sets |
24441 | @option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit}, | |
24442 | @option{-fno-exceptions}, @option{-fno-non-call-exceptions}, | |
24443 | @option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where | |
24444 | applicable. This mode also sets @option{-mno-altivec}, | |
24445 | @option{-msoft-float}, @option{-fno-builtin} and | |
24446 | @option{-mlong-branch} for PowerPC targets. | |
24447 | ||
d77de738 | 24448 | @opindex mone-byte-bool |
ddf6fe37 | 24449 | @item -mone-byte-bool |
d77de738 ML |
24450 | Override the defaults for @code{bool} so that @code{sizeof(bool)==1}. |
24451 | By default @code{sizeof(bool)} is @code{4} when compiling for | |
24452 | Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this | |
24453 | option has no effect on x86. | |
24454 | ||
24455 | @strong{Warning:} The @option{-mone-byte-bool} switch causes GCC | |
24456 | to generate code that is not binary compatible with code generated | |
24457 | without that switch. Using this switch may require recompiling all | |
24458 | other modules in a program, including system libraries. Use this | |
24459 | switch to conform to a non-default data model. | |
24460 | ||
d77de738 ML |
24461 | @opindex mfix-and-continue |
24462 | @opindex ffix-and-continue | |
24463 | @opindex findirect-data | |
ddf6fe37 AA |
24464 | @item -mfix-and-continue |
24465 | @itemx -ffix-and-continue | |
24466 | @itemx -findirect-data | |
d77de738 ML |
24467 | Generate code suitable for fast turnaround development, such as to |
24468 | allow GDB to dynamically load @file{.o} files into already-running | |
24469 | programs. @option{-findirect-data} and @option{-ffix-and-continue} | |
24470 | are provided for backwards compatibility. | |
24471 | ||
d77de738 | 24472 | @opindex all_load |
ddf6fe37 | 24473 | @item -all_load |
d77de738 ML |
24474 | Loads all members of static archive libraries. |
24475 | See man ld(1) for more information. | |
24476 | ||
d77de738 | 24477 | @opindex arch_errors_fatal |
ddf6fe37 | 24478 | @item -arch_errors_fatal |
d77de738 ML |
24479 | Cause the errors having to do with files that have the wrong architecture |
24480 | to be fatal. | |
24481 | ||
d77de738 | 24482 | @opindex bind_at_load |
ddf6fe37 | 24483 | @item -bind_at_load |
d77de738 ML |
24484 | Causes the output file to be marked such that the dynamic linker will |
24485 | bind all undefined references when the file is loaded or launched. | |
24486 | ||
d77de738 | 24487 | @opindex bundle |
ddf6fe37 | 24488 | @item -bundle |
d77de738 ML |
24489 | Produce a Mach-o bundle format file. |
24490 | See man ld(1) for more information. | |
24491 | ||
d77de738 | 24492 | @opindex bundle_loader |
ddf6fe37 | 24493 | @item -bundle_loader @var{executable} |
d77de738 ML |
24494 | This option specifies the @var{executable} that will load the build |
24495 | output file being linked. See man ld(1) for more information. | |
24496 | ||
d77de738 | 24497 | @opindex dynamiclib |
ddf6fe37 | 24498 | @item -dynamiclib |
d77de738 ML |
24499 | When passed this option, GCC produces a dynamic library instead of |
24500 | an executable when linking, using the Darwin @file{libtool} command. | |
24501 | ||
d77de738 | 24502 | @opindex force_cpusubtype_ALL |
ddf6fe37 | 24503 | @item -force_cpusubtype_ALL |
d77de738 ML |
24504 | This causes GCC's output file to have the @samp{ALL} subtype, instead of |
24505 | one controlled by the @option{-mcpu} or @option{-march} option. | |
24506 | ||
47b634a3 FXC |
24507 | @opindex nodefaultrpaths |
24508 | @item -nodefaultrpaths | |
24509 | Do not add default run paths for the compiler library directories to | |
24510 | executables, modules or dynamic libraries. On macOS 10.5 and later, | |
24511 | the embedded runpath is added by default unless the user adds | |
24512 | @option{-nodefaultrpaths} to the link line. Run paths are needed | |
24513 | (and therefore enforced) to build on macOS version 10.11 or later. | |
24514 | ||
d77de738 ML |
24515 | @item -allowable_client @var{client_name} |
24516 | @itemx -client_name | |
24517 | @itemx -compatibility_version | |
24518 | @itemx -current_version | |
24519 | @itemx -dead_strip | |
24520 | @itemx -dependency-file | |
24521 | @itemx -dylib_file | |
24522 | @itemx -dylinker_install_name | |
24523 | @itemx -dynamic | |
24524 | @itemx -exported_symbols_list | |
24525 | @itemx -filelist | |
24526 | @need 800 | |
24527 | @itemx -flat_namespace | |
24528 | @itemx -force_flat_namespace | |
24529 | @itemx -headerpad_max_install_names | |
24530 | @itemx -image_base | |
24531 | @itemx -init | |
24532 | @itemx -install_name | |
24533 | @itemx -keep_private_externs | |
24534 | @itemx -multi_module | |
24535 | @itemx -multiply_defined | |
24536 | @itemx -multiply_defined_unused | |
24537 | @need 800 | |
24538 | @itemx -noall_load | |
24539 | @itemx -no_dead_strip_inits_and_terms | |
24540 | @itemx -nofixprebinding | |
24541 | @itemx -nomultidefs | |
24542 | @itemx -noprebind | |
24543 | @itemx -noseglinkedit | |
24544 | @itemx -pagezero_size | |
24545 | @itemx -prebind | |
24546 | @itemx -prebind_all_twolevel_modules | |
24547 | @itemx -private_bundle | |
24548 | @need 800 | |
24549 | @itemx -read_only_relocs | |
24550 | @itemx -sectalign | |
24551 | @itemx -sectobjectsymbols | |
24552 | @itemx -whyload | |
24553 | @itemx -seg1addr | |
24554 | @itemx -sectcreate | |
24555 | @itemx -sectobjectsymbols | |
24556 | @itemx -sectorder | |
24557 | @itemx -segaddr | |
24558 | @itemx -segs_read_only_addr | |
24559 | @need 800 | |
24560 | @itemx -segs_read_write_addr | |
24561 | @itemx -seg_addr_table | |
24562 | @itemx -seg_addr_table_filename | |
24563 | @itemx -seglinkedit | |
24564 | @itemx -segprot | |
24565 | @itemx -segs_read_only_addr | |
24566 | @itemx -segs_read_write_addr | |
24567 | @itemx -single_module | |
24568 | @itemx -static | |
24569 | @itemx -sub_library | |
24570 | @need 800 | |
d77de738 ML |
24571 | @opindex allowable_client |
24572 | @opindex client_name | |
24573 | @opindex compatibility_version | |
24574 | @opindex current_version | |
24575 | @opindex dead_strip | |
24576 | @opindex dependency-file | |
24577 | @opindex dylib_file | |
24578 | @opindex dylinker_install_name | |
24579 | @opindex dynamic | |
24580 | @opindex exported_symbols_list | |
24581 | @opindex filelist | |
24582 | @opindex flat_namespace | |
24583 | @opindex force_flat_namespace | |
24584 | @opindex headerpad_max_install_names | |
24585 | @opindex image_base | |
24586 | @opindex init | |
24587 | @opindex install_name | |
24588 | @opindex keep_private_externs | |
24589 | @opindex multi_module | |
24590 | @opindex multiply_defined | |
24591 | @opindex multiply_defined_unused | |
24592 | @opindex noall_load | |
24593 | @opindex no_dead_strip_inits_and_terms | |
24594 | @opindex nofixprebinding | |
24595 | @opindex nomultidefs | |
24596 | @opindex noprebind | |
24597 | @opindex noseglinkedit | |
24598 | @opindex pagezero_size | |
24599 | @opindex prebind | |
24600 | @opindex prebind_all_twolevel_modules | |
24601 | @opindex private_bundle | |
24602 | @opindex read_only_relocs | |
24603 | @opindex sectalign | |
24604 | @opindex sectobjectsymbols | |
24605 | @opindex whyload | |
24606 | @opindex seg1addr | |
24607 | @opindex sectcreate | |
24608 | @opindex sectobjectsymbols | |
24609 | @opindex sectorder | |
24610 | @opindex segaddr | |
24611 | @opindex segs_read_only_addr | |
24612 | @opindex segs_read_write_addr | |
24613 | @opindex seg_addr_table | |
24614 | @opindex seg_addr_table_filename | |
24615 | @opindex seglinkedit | |
24616 | @opindex segprot | |
24617 | @opindex segs_read_only_addr | |
24618 | @opindex segs_read_write_addr | |
24619 | @opindex single_module | |
24620 | @opindex static | |
24621 | @opindex sub_library | |
24622 | @opindex sub_umbrella | |
24623 | @opindex twolevel_namespace | |
24624 | @opindex umbrella | |
24625 | @opindex undefined | |
24626 | @opindex unexported_symbols_list | |
24627 | @opindex weak_reference_mismatches | |
24628 | @opindex whatsloaded | |
ddf6fe37 AA |
24629 | @itemx -sub_umbrella |
24630 | @itemx -twolevel_namespace | |
24631 | @itemx -umbrella | |
24632 | @itemx -undefined | |
24633 | @itemx -unexported_symbols_list | |
24634 | @itemx -weak_reference_mismatches | |
24635 | @itemx -whatsloaded | |
d77de738 ML |
24636 | These options are passed to the Darwin linker. The Darwin linker man page |
24637 | describes them in detail. | |
24638 | @end table | |
24639 | ||
24640 | @node DEC Alpha Options | |
24641 | @subsection DEC Alpha Options | |
24642 | ||
24643 | These @samp{-m} options are defined for the DEC Alpha implementations: | |
24644 | ||
24645 | @table @gcctabopt | |
d77de738 ML |
24646 | @opindex mno-soft-float |
24647 | @opindex msoft-float | |
ddf6fe37 AA |
24648 | @item -mno-soft-float |
24649 | @itemx -msoft-float | |
d77de738 ML |
24650 | Use (do not use) the hardware floating-point instructions for |
24651 | floating-point operations. When @option{-msoft-float} is specified, | |
24652 | functions in @file{libgcc.a} are used to perform floating-point | |
24653 | operations. Unless they are replaced by routines that emulate the | |
24654 | floating-point operations, or compiled in such a way as to call such | |
24655 | emulations routines, these routines issue floating-point | |
24656 | operations. If you are compiling for an Alpha without floating-point | |
24657 | operations, you must ensure that the library is built so as not to call | |
24658 | them. | |
24659 | ||
24660 | Note that Alpha implementations without floating-point operations are | |
24661 | required to have floating-point registers. | |
24662 | ||
d77de738 ML |
24663 | @opindex mfp-reg |
24664 | @opindex mno-fp-regs | |
ddf6fe37 AA |
24665 | @item -mfp-reg |
24666 | @itemx -mno-fp-regs | |
d77de738 ML |
24667 | Generate code that uses (does not use) the floating-point register set. |
24668 | @option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point | |
24669 | register set is not used, floating-point operands are passed in integer | |
24670 | registers as if they were integers and floating-point results are passed | |
24671 | in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence, | |
24672 | so any function with a floating-point argument or return value called by code | |
24673 | compiled with @option{-mno-fp-regs} must also be compiled with that | |
24674 | option. | |
24675 | ||
24676 | A typical use of this option is building a kernel that does not use, | |
24677 | and hence need not save and restore, any floating-point registers. | |
24678 | ||
d77de738 | 24679 | @opindex mieee |
ddf6fe37 | 24680 | @item -mieee |
d77de738 ML |
24681 | The Alpha architecture implements floating-point hardware optimized for |
24682 | maximum performance. It is mostly compliant with the IEEE floating-point | |
24683 | standard. However, for full compliance, software assistance is | |
24684 | required. This option generates code fully IEEE-compliant code | |
24685 | @emph{except} that the @var{inexact-flag} is not maintained (see below). | |
24686 | If this option is turned on, the preprocessor macro @code{_IEEE_FP} is | |
24687 | defined during compilation. The resulting code is less efficient but is | |
24688 | able to correctly support denormalized numbers and exceptional IEEE | |
24689 | values such as not-a-number and plus/minus infinity. Other Alpha | |
24690 | compilers call this option @option{-ieee_with_no_inexact}. | |
24691 | ||
d77de738 | 24692 | @opindex mieee-with-inexact |
ddf6fe37 | 24693 | @item -mieee-with-inexact |
d77de738 ML |
24694 | This is like @option{-mieee} except the generated code also maintains |
24695 | the IEEE @var{inexact-flag}. Turning on this option causes the | |
24696 | generated code to implement fully-compliant IEEE math. In addition to | |
24697 | @code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor | |
24698 | macro. On some Alpha implementations the resulting code may execute | |
24699 | significantly slower than the code generated by default. Since there is | |
24700 | very little code that depends on the @var{inexact-flag}, you should | |
24701 | normally not specify this option. Other Alpha compilers call this | |
24702 | option @option{-ieee_with_inexact}. | |
24703 | ||
d77de738 | 24704 | @opindex mfp-trap-mode |
ddf6fe37 | 24705 | @item -mfp-trap-mode=@var{trap-mode} |
d77de738 ML |
24706 | This option controls what floating-point related traps are enabled. |
24707 | Other Alpha compilers call this option @option{-fptm @var{trap-mode}}. | |
24708 | The trap mode can be set to one of four values: | |
24709 | ||
24710 | @table @samp | |
24711 | @item n | |
24712 | This is the default (normal) setting. The only traps that are enabled | |
24713 | are the ones that cannot be disabled in software (e.g., division by zero | |
24714 | trap). | |
24715 | ||
24716 | @item u | |
24717 | In addition to the traps enabled by @samp{n}, underflow traps are enabled | |
24718 | as well. | |
24719 | ||
24720 | @item su | |
24721 | Like @samp{u}, but the instructions are marked to be safe for software | |
24722 | completion (see Alpha architecture manual for details). | |
24723 | ||
24724 | @item sui | |
24725 | Like @samp{su}, but inexact traps are enabled as well. | |
24726 | @end table | |
24727 | ||
d77de738 | 24728 | @opindex mfp-rounding-mode |
ddf6fe37 | 24729 | @item -mfp-rounding-mode=@var{rounding-mode} |
d77de738 ML |
24730 | Selects the IEEE rounding mode. Other Alpha compilers call this option |
24731 | @option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one | |
24732 | of: | |
24733 | ||
24734 | @table @samp | |
24735 | @item n | |
24736 | Normal IEEE rounding mode. Floating-point numbers are rounded towards | |
24737 | the nearest machine number or towards the even machine number in case | |
24738 | of a tie. | |
24739 | ||
24740 | @item m | |
24741 | Round towards minus infinity. | |
24742 | ||
24743 | @item c | |
24744 | Chopped rounding mode. Floating-point numbers are rounded towards zero. | |
24745 | ||
24746 | @item d | |
24747 | Dynamic rounding mode. A field in the floating-point control register | |
24748 | (@var{fpcr}, see Alpha architecture reference manual) controls the | |
24749 | rounding mode in effect. The C library initializes this register for | |
24750 | rounding towards plus infinity. Thus, unless your program modifies the | |
24751 | @var{fpcr}, @samp{d} corresponds to round towards plus infinity. | |
24752 | @end table | |
24753 | ||
d77de738 | 24754 | @opindex mtrap-precision |
ddf6fe37 | 24755 | @item -mtrap-precision=@var{trap-precision} |
d77de738 ML |
24756 | In the Alpha architecture, floating-point traps are imprecise. This |
24757 | means without software assistance it is impossible to recover from a | |
24758 | floating trap and program execution normally needs to be terminated. | |
24759 | GCC can generate code that can assist operating system trap handlers | |
24760 | in determining the exact location that caused a floating-point trap. | |
24761 | Depending on the requirements of an application, different levels of | |
24762 | precisions can be selected: | |
24763 | ||
24764 | @table @samp | |
24765 | @item p | |
24766 | Program precision. This option is the default and means a trap handler | |
24767 | can only identify which program caused a floating-point exception. | |
24768 | ||
24769 | @item f | |
24770 | Function precision. The trap handler can determine the function that | |
24771 | caused a floating-point exception. | |
24772 | ||
24773 | @item i | |
24774 | Instruction precision. The trap handler can determine the exact | |
24775 | instruction that caused a floating-point exception. | |
24776 | @end table | |
24777 | ||
24778 | Other Alpha compilers provide the equivalent options called | |
24779 | @option{-scope_safe} and @option{-resumption_safe}. | |
24780 | ||
d77de738 | 24781 | @opindex mieee-conformant |
ddf6fe37 | 24782 | @item -mieee-conformant |
d77de738 ML |
24783 | This option marks the generated code as IEEE conformant. You must not |
24784 | use this option unless you also specify @option{-mtrap-precision=i} and either | |
24785 | @option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect | |
24786 | is to emit the line @samp{.eflag 48} in the function prologue of the | |
24787 | generated assembly file. | |
24788 | ||
d77de738 | 24789 | @opindex mbuild-constants |
ddf6fe37 | 24790 | @item -mbuild-constants |
d77de738 ML |
24791 | Normally GCC examines a 32- or 64-bit integer constant to |
24792 | see if it can construct it from smaller constants in two or three | |
24793 | instructions. If it cannot, it outputs the constant as a literal and | |
24794 | generates code to load it from the data segment at run time. | |
24795 | ||
24796 | Use this option to require GCC to construct @emph{all} integer constants | |
24797 | using code, even if it takes more instructions (the maximum is six). | |
24798 | ||
24799 | You typically use this option to build a shared library dynamic | |
24800 | loader. Itself a shared library, it must relocate itself in memory | |
24801 | before it can find the variables and constants in its own data segment. | |
24802 | ||
d77de738 ML |
24803 | @opindex mbwx |
24804 | @opindex mno-bwx | |
24805 | @opindex mcix | |
24806 | @opindex mno-cix | |
24807 | @opindex mfix | |
24808 | @opindex mno-fix | |
24809 | @opindex mmax | |
24810 | @opindex mno-max | |
ddf6fe37 AA |
24811 | @item -mbwx |
24812 | @itemx -mno-bwx | |
24813 | @itemx -mcix | |
24814 | @itemx -mno-cix | |
24815 | @itemx -mfix | |
24816 | @itemx -mno-fix | |
24817 | @itemx -mmax | |
24818 | @itemx -mno-max | |
d77de738 ML |
24819 | Indicate whether GCC should generate code to use the optional BWX, |
24820 | CIX, FIX and MAX instruction sets. The default is to use the instruction | |
24821 | sets supported by the CPU type specified via @option{-mcpu=} option or that | |
24822 | of the CPU on which GCC was built if none is specified. | |
24823 | ||
d77de738 ML |
24824 | @opindex mfloat-vax |
24825 | @opindex mfloat-ieee | |
ddf6fe37 AA |
24826 | @item -mfloat-vax |
24827 | @itemx -mfloat-ieee | |
d77de738 ML |
24828 | Generate code that uses (does not use) VAX F and G floating-point |
24829 | arithmetic instead of IEEE single and double precision. | |
24830 | ||
d77de738 ML |
24831 | @opindex mexplicit-relocs |
24832 | @opindex mno-explicit-relocs | |
ddf6fe37 AA |
24833 | @item -mexplicit-relocs |
24834 | @itemx -mno-explicit-relocs | |
d77de738 ML |
24835 | Older Alpha assemblers provided no way to generate symbol relocations |
24836 | except via assembler macros. Use of these macros does not allow | |
24837 | optimal instruction scheduling. GNU binutils as of version 2.12 | |
24838 | supports a new syntax that allows the compiler to explicitly mark | |
24839 | which relocations should apply to which instructions. This option | |
24840 | is mostly useful for debugging, as GCC detects the capabilities of | |
24841 | the assembler when it is built and sets the default accordingly. | |
24842 | ||
d77de738 ML |
24843 | @opindex msmall-data |
24844 | @opindex mlarge-data | |
ddf6fe37 AA |
24845 | @item -msmall-data |
24846 | @itemx -mlarge-data | |
d77de738 ML |
24847 | When @option{-mexplicit-relocs} is in effect, static data is |
24848 | accessed via @dfn{gp-relative} relocations. When @option{-msmall-data} | |
24849 | is used, objects 8 bytes long or smaller are placed in a @dfn{small data area} | |
24850 | (the @code{.sdata} and @code{.sbss} sections) and are accessed via | |
24851 | 16-bit relocations off of the @code{$gp} register. This limits the | |
24852 | size of the small data area to 64KB, but allows the variables to be | |
24853 | directly accessed via a single instruction. | |
24854 | ||
24855 | The default is @option{-mlarge-data}. With this option the data area | |
24856 | is limited to just below 2GB@. Programs that require more than 2GB of | |
24857 | data must use @code{malloc} or @code{mmap} to allocate the data in the | |
24858 | heap instead of in the program's data segment. | |
24859 | ||
24860 | When generating code for shared libraries, @option{-fpic} implies | |
24861 | @option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}. | |
24862 | ||
d77de738 ML |
24863 | @opindex msmall-text |
24864 | @opindex mlarge-text | |
ddf6fe37 AA |
24865 | @item -msmall-text |
24866 | @itemx -mlarge-text | |
d77de738 ML |
24867 | When @option{-msmall-text} is used, the compiler assumes that the |
24868 | code of the entire program (or shared library) fits in 4MB, and is | |
24869 | thus reachable with a branch instruction. When @option{-msmall-data} | |
24870 | is used, the compiler can assume that all local symbols share the | |
24871 | same @code{$gp} value, and thus reduce the number of instructions | |
24872 | required for a function call from 4 to 1. | |
24873 | ||
24874 | The default is @option{-mlarge-text}. | |
24875 | ||
d77de738 | 24876 | @opindex mcpu |
ddf6fe37 | 24877 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
24878 | Set the instruction set and instruction scheduling parameters for |
24879 | machine type @var{cpu_type}. You can specify either the @samp{EV} | |
24880 | style name or the corresponding chip number. GCC supports scheduling | |
24881 | parameters for the EV4, EV5 and EV6 family of processors and | |
24882 | chooses the default values for the instruction set from the processor | |
24883 | you specify. If you do not specify a processor type, GCC defaults | |
24884 | to the processor on which the compiler was built. | |
24885 | ||
24886 | Supported values for @var{cpu_type} are | |
24887 | ||
24888 | @table @samp | |
24889 | @item ev4 | |
24890 | @itemx ev45 | |
24891 | @itemx 21064 | |
24892 | Schedules as an EV4 and has no instruction set extensions. | |
24893 | ||
24894 | @item ev5 | |
24895 | @itemx 21164 | |
24896 | Schedules as an EV5 and has no instruction set extensions. | |
24897 | ||
24898 | @item ev56 | |
24899 | @itemx 21164a | |
24900 | Schedules as an EV5 and supports the BWX extension. | |
24901 | ||
24902 | @item pca56 | |
24903 | @itemx 21164pc | |
24904 | @itemx 21164PC | |
24905 | Schedules as an EV5 and supports the BWX and MAX extensions. | |
24906 | ||
24907 | @item ev6 | |
24908 | @itemx 21264 | |
24909 | Schedules as an EV6 and supports the BWX, FIX, and MAX extensions. | |
24910 | ||
24911 | @item ev67 | |
24912 | @itemx 21264a | |
24913 | Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions. | |
24914 | @end table | |
24915 | ||
24916 | Native toolchains also support the value @samp{native}, | |
24917 | which selects the best architecture option for the host processor. | |
24918 | @option{-mcpu=native} has no effect if GCC does not recognize | |
24919 | the processor. | |
24920 | ||
d77de738 | 24921 | @opindex mtune |
ddf6fe37 | 24922 | @item -mtune=@var{cpu_type} |
d77de738 ML |
24923 | Set only the instruction scheduling parameters for machine type |
24924 | @var{cpu_type}. The instruction set is not changed. | |
24925 | ||
24926 | Native toolchains also support the value @samp{native}, | |
24927 | which selects the best architecture option for the host processor. | |
24928 | @option{-mtune=native} has no effect if GCC does not recognize | |
24929 | the processor. | |
24930 | ||
d77de738 | 24931 | @opindex mmemory-latency |
ddf6fe37 | 24932 | @item -mmemory-latency=@var{time} |
d77de738 ML |
24933 | Sets the latency the scheduler should assume for typical memory |
24934 | references as seen by the application. This number is highly | |
24935 | dependent on the memory access patterns used by the application | |
24936 | and the size of the external cache on the machine. | |
24937 | ||
24938 | Valid options for @var{time} are | |
24939 | ||
24940 | @table @samp | |
24941 | @item @var{number} | |
24942 | A decimal number representing clock cycles. | |
24943 | ||
24944 | @item L1 | |
24945 | @itemx L2 | |
24946 | @itemx L3 | |
24947 | @itemx main | |
24948 | The compiler contains estimates of the number of clock cycles for | |
24949 | ``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches | |
24950 | (also called Dcache, Scache, and Bcache), as well as to main memory. | |
24951 | Note that L3 is only valid for EV5. | |
24952 | ||
24953 | @end table | |
24954 | @end table | |
24955 | ||
24956 | @node eBPF Options | |
24957 | @subsection eBPF Options | |
24958 | @cindex eBPF Options | |
24959 | ||
24960 | @table @gcctabopt | |
24961 | @item -mframe-limit=@var{bytes} | |
24962 | This specifies the hard limit for frame sizes, in bytes. Currently, | |
24963 | the value that can be specified should be less than or equal to | |
24964 | @samp{32767}. Defaults to whatever limit is imposed by the version of | |
24965 | the Linux kernel targeted. | |
24966 | ||
d77de738 | 24967 | @opindex mbig-endian |
ddf6fe37 | 24968 | @item -mbig-endian |
d77de738 ML |
24969 | Generate code for a big-endian target. |
24970 | ||
d77de738 | 24971 | @opindex mlittle-endian |
ddf6fe37 | 24972 | @item -mlittle-endian |
d77de738 ML |
24973 | Generate code for a little-endian target. This is the default. |
24974 | ||
d77de738 | 24975 | @opindex mjmpext |
ddf6fe37 | 24976 | @item -mjmpext |
9cbf4286 DF |
24977 | @itemx -mno-jmpext |
24978 | Enable or disable generation of extra conditional-branch instructions. | |
d77de738 ML |
24979 | Enabled for CPU v2 and above. |
24980 | ||
d77de738 | 24981 | @opindex mjmp32 |
ddf6fe37 | 24982 | @item -mjmp32 |
9cbf4286 DF |
24983 | @itemx -mno-jmp32 |
24984 | Enable or disable generation of 32-bit jump instructions. | |
24985 | Enabled for CPU v3 and above. | |
d77de738 | 24986 | |
d77de738 | 24987 | @opindex malu32 |
ddf6fe37 | 24988 | @item -malu32 |
9cbf4286 DF |
24989 | @itemx -mno-alu32 |
24990 | Enable or disable generation of 32-bit ALU instructions. | |
24991 | Enabled for CPU v3 and above. | |
24992 | ||
24993 | @opindex mv3-atomics | |
24994 | @item -mv3-atomics | |
24995 | @itemx -mno-v3-atomics | |
24996 | Enable or disable instructions for general atomic operations introduced | |
24997 | in CPU v3. Enabled for CPU v3 and above. | |
d77de738 | 24998 | |
f1e34551 JM |
24999 | @opindex mbswap |
25000 | @item -mbswap | |
9cbf4286 DF |
25001 | @itemx -mno-bswap |
25002 | Enable or disable byte swap instructions. Enabled for CPU v4 and above. | |
f1e34551 | 25003 | |
4be3919f JM |
25004 | @opindex msdiv |
25005 | @item -msdiv | |
9cbf4286 DF |
25006 | @itemx -mno-sdiv |
25007 | Enable or disable signed division and modulus instructions. Enabled for | |
25008 | CPU v4 and above. | |
db189d02 | 25009 | |
14dab1a1 DF |
25010 | @opindex msmov |
25011 | @item -msmov | |
25012 | @itemx -mno-smov | |
25013 | Enable or disable sign-extending move and memory load instructions. | |
25014 | Enabled for CPU v4 and above. | |
25015 | ||
d77de738 | 25016 | @opindex mcpu |
ddf6fe37 | 25017 | @item -mcpu=@var{version} |
d77de738 | 25018 | This specifies which version of the eBPF ISA to target. Newer versions |
f1e34551 | 25019 | may not be supported by all kernels. The default is @samp{v4}. |
d77de738 ML |
25020 | |
25021 | Supported values for @var{version} are: | |
25022 | ||
25023 | @table @samp | |
25024 | @item v1 | |
25025 | The first stable eBPF ISA with no special features or extensions. | |
25026 | ||
25027 | @item v2 | |
25028 | Supports the jump extensions, as in @option{-mjmpext}. | |
25029 | ||
25030 | @item v3 | |
25031 | All features of v2, plus: | |
25032 | @itemize @minus | |
25033 | @item 32-bit jump operations, as in @option{-mjmp32} | |
25034 | @item 32-bit ALU operations, as in @option{-malu32} | |
db189d02 | 25035 | @item general atomic operations, as in @option{-mv3-atomics} |
d77de738 ML |
25036 | @end itemize |
25037 | ||
f1e34551 JM |
25038 | @item v4 |
25039 | All features of v3, plus: | |
25040 | @itemize @minus | |
25041 | @item Byte swap instructions, as in @option{-mbswap} | |
9cbf4286 | 25042 | @item Signed division and modulus instructions, as in @option{-msdiv} |
14dab1a1 | 25043 | @item Sign-extending move and memory load instructions, as in @option{-msmov} |
f1e34551 | 25044 | @end itemize |
d77de738 ML |
25045 | @end table |
25046 | ||
d77de738 | 25047 | @opindex mco-re |
ddf6fe37 | 25048 | @item -mco-re |
d77de738 ML |
25049 | Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and |
25050 | is implied by @option{-gbtf}. | |
25051 | ||
d77de738 | 25052 | @opindex mno-co-re |
ddf6fe37 | 25053 | @item -mno-co-re |
d77de738 ML |
25054 | Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE |
25055 | support is enabled by default when generating BTF debug information for | |
25056 | the BPF target. | |
25057 | ||
25058 | @item -mxbpf | |
25059 | Generate code for an expanded version of BPF, which relaxes some of | |
25060 | the restrictions imposed by the BPF architecture: | |
25061 | @itemize @minus | |
25062 | @item Save and restore callee-saved registers at function entry and | |
25063 | exit, respectively. | |
25064 | @end itemize | |
77d0f9ec CM |
25065 | |
25066 | @opindex masm=@var{dialect} | |
25067 | @item -masm=@var{dialect} | |
25068 | Outputs assembly instructions using eBPF selected @var{dialect}. The default | |
25069 | is @samp{normal}. | |
25070 | ||
25071 | Supported values for @var{dialect} are: | |
25072 | ||
25073 | @table @samp | |
25074 | @item normal | |
25075 | Outputs normal assembly dialect. | |
25076 | ||
25077 | @item pseudoc | |
25078 | Outputs pseudo-c assembly dialect. | |
25079 | ||
25080 | @end table | |
25081 | ||
d77de738 ML |
25082 | @end table |
25083 | ||
25084 | @node FR30 Options | |
25085 | @subsection FR30 Options | |
25086 | @cindex FR30 Options | |
25087 | ||
25088 | These options are defined specifically for the FR30 port. | |
25089 | ||
25090 | @table @gcctabopt | |
25091 | ||
d77de738 | 25092 | @opindex msmall-model |
ddf6fe37 | 25093 | @item -msmall-model |
d77de738 ML |
25094 | Use the small address space model. This can produce smaller code, but |
25095 | it does assume that all symbolic values and addresses fit into a | |
25096 | 20-bit range. | |
25097 | ||
d77de738 | 25098 | @opindex mno-lsim |
ddf6fe37 | 25099 | @item -mno-lsim |
d77de738 ML |
25100 | Assume that runtime support has been provided and so there is no need |
25101 | to include the simulator library (@file{libsim.a}) on the linker | |
25102 | command line. | |
25103 | ||
25104 | @end table | |
25105 | ||
25106 | @node FT32 Options | |
25107 | @subsection FT32 Options | |
25108 | @cindex FT32 Options | |
25109 | ||
25110 | These options are defined specifically for the FT32 port. | |
25111 | ||
25112 | @table @gcctabopt | |
25113 | ||
d77de738 | 25114 | @opindex msim |
ddf6fe37 | 25115 | @item -msim |
d77de738 ML |
25116 | Specifies that the program will be run on the simulator. This causes |
25117 | an alternate runtime startup and library to be linked. | |
25118 | You must not use this option when generating programs that will run on | |
25119 | real hardware; you must provide your own runtime library for whatever | |
25120 | I/O functions are needed. | |
25121 | ||
d77de738 | 25122 | @opindex mlra |
ddf6fe37 | 25123 | @item -mlra |
d77de738 ML |
25124 | Enable Local Register Allocation. This is still experimental for FT32, |
25125 | so by default the compiler uses standard reload. | |
25126 | ||
d77de738 | 25127 | @opindex mnodiv |
ddf6fe37 | 25128 | @item -mnodiv |
d77de738 ML |
25129 | Do not use div and mod instructions. |
25130 | ||
d77de738 | 25131 | @opindex mft32b |
ddf6fe37 | 25132 | @item -mft32b |
d77de738 ML |
25133 | Enable use of the extended instructions of the FT32B processor. |
25134 | ||
d77de738 | 25135 | @opindex mcompress |
ddf6fe37 | 25136 | @item -mcompress |
d77de738 ML |
25137 | Compress all code using the Ft32B code compression scheme. |
25138 | ||
d77de738 | 25139 | @opindex mnopm |
ddf6fe37 | 25140 | @item -mnopm |
d77de738 ML |
25141 | Do not generate code that reads program memory. |
25142 | ||
25143 | @end table | |
25144 | ||
25145 | @node FRV Options | |
25146 | @subsection FRV Options | |
25147 | @cindex FRV Options | |
25148 | ||
25149 | @table @gcctabopt | |
d77de738 | 25150 | @opindex mgpr-32 |
ddf6fe37 | 25151 | @item -mgpr-32 |
d77de738 ML |
25152 | |
25153 | Only use the first 32 general-purpose registers. | |
25154 | ||
d77de738 | 25155 | @opindex mgpr-64 |
ddf6fe37 | 25156 | @item -mgpr-64 |
d77de738 ML |
25157 | |
25158 | Use all 64 general-purpose registers. | |
25159 | ||
d77de738 | 25160 | @opindex mfpr-32 |
ddf6fe37 | 25161 | @item -mfpr-32 |
d77de738 ML |
25162 | |
25163 | Use only the first 32 floating-point registers. | |
25164 | ||
d77de738 | 25165 | @opindex mfpr-64 |
ddf6fe37 | 25166 | @item -mfpr-64 |
d77de738 ML |
25167 | |
25168 | Use all 64 floating-point registers. | |
25169 | ||
d77de738 | 25170 | @opindex mhard-float |
ddf6fe37 | 25171 | @item -mhard-float |
d77de738 ML |
25172 | |
25173 | Use hardware instructions for floating-point operations. | |
25174 | ||
d77de738 | 25175 | @opindex msoft-float |
ddf6fe37 | 25176 | @item -msoft-float |
d77de738 ML |
25177 | |
25178 | Use library routines for floating-point operations. | |
25179 | ||
d77de738 | 25180 | @opindex malloc-cc |
ddf6fe37 | 25181 | @item -malloc-cc |
d77de738 ML |
25182 | |
25183 | Dynamically allocate condition code registers. | |
25184 | ||
d77de738 | 25185 | @opindex mfixed-cc |
ddf6fe37 | 25186 | @item -mfixed-cc |
d77de738 ML |
25187 | |
25188 | Do not try to dynamically allocate condition code registers, only | |
25189 | use @code{icc0} and @code{fcc0}. | |
25190 | ||
d77de738 | 25191 | @opindex mdword |
ddf6fe37 | 25192 | @item -mdword |
d77de738 ML |
25193 | |
25194 | Change ABI to use double word insns. | |
25195 | ||
d77de738 ML |
25196 | @opindex mno-dword |
25197 | @opindex mdword | |
ddf6fe37 | 25198 | @item -mno-dword |
d77de738 ML |
25199 | |
25200 | Do not use double word instructions. | |
25201 | ||
d77de738 | 25202 | @opindex mdouble |
ddf6fe37 | 25203 | @item -mdouble |
d77de738 ML |
25204 | |
25205 | Use floating-point double instructions. | |
25206 | ||
d77de738 | 25207 | @opindex mno-double |
ddf6fe37 | 25208 | @item -mno-double |
d77de738 ML |
25209 | |
25210 | Do not use floating-point double instructions. | |
25211 | ||
d77de738 | 25212 | @opindex mmedia |
ddf6fe37 | 25213 | @item -mmedia |
d77de738 ML |
25214 | |
25215 | Use media instructions. | |
25216 | ||
d77de738 | 25217 | @opindex mno-media |
ddf6fe37 | 25218 | @item -mno-media |
d77de738 ML |
25219 | |
25220 | Do not use media instructions. | |
25221 | ||
d77de738 | 25222 | @opindex mmuladd |
ddf6fe37 | 25223 | @item -mmuladd |
d77de738 ML |
25224 | |
25225 | Use multiply and add/subtract instructions. | |
25226 | ||
d77de738 | 25227 | @opindex mno-muladd |
ddf6fe37 | 25228 | @item -mno-muladd |
d77de738 ML |
25229 | |
25230 | Do not use multiply and add/subtract instructions. | |
25231 | ||
d77de738 | 25232 | @opindex mfdpic |
ddf6fe37 | 25233 | @item -mfdpic |
d77de738 ML |
25234 | |
25235 | Select the FDPIC ABI, which uses function descriptors to represent | |
25236 | pointers to functions. Without any PIC/PIE-related options, it | |
25237 | implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it | |
25238 | assumes GOT entries and small data are within a 12-bit range from the | |
25239 | GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets | |
25240 | are computed with 32 bits. | |
25241 | With a @samp{bfin-elf} target, this option implies @option{-msim}. | |
25242 | ||
d77de738 | 25243 | @opindex minline-plt |
ddf6fe37 | 25244 | @item -minline-plt |
d77de738 ML |
25245 | |
25246 | Enable inlining of PLT entries in function calls to functions that are | |
25247 | not known to bind locally. It has no effect without @option{-mfdpic}. | |
25248 | It's enabled by default if optimizing for speed and compiling for | |
25249 | shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an | |
25250 | optimization option such as @option{-O3} or above is present in the | |
25251 | command line. | |
25252 | ||
d77de738 | 25253 | @opindex mTLS |
ddf6fe37 | 25254 | @item -mTLS |
d77de738 ML |
25255 | |
25256 | Assume a large TLS segment when generating thread-local code. | |
25257 | ||
d77de738 | 25258 | @opindex mtls |
ddf6fe37 | 25259 | @item -mtls |
d77de738 ML |
25260 | |
25261 | Do not assume a large TLS segment when generating thread-local code. | |
25262 | ||
d77de738 | 25263 | @opindex mgprel-ro |
ddf6fe37 | 25264 | @item -mgprel-ro |
d77de738 ML |
25265 | |
25266 | Enable the use of @code{GPREL} relocations in the FDPIC ABI for data | |
25267 | that is known to be in read-only sections. It's enabled by default, | |
25268 | except for @option{-fpic} or @option{-fpie}: even though it may help | |
25269 | make the global offset table smaller, it trades 1 instruction for 4. | |
25270 | With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4, | |
25271 | one of which may be shared by multiple symbols, and it avoids the need | |
25272 | for a GOT entry for the referenced symbol, so it's more likely to be a | |
25273 | win. If it is not, @option{-mno-gprel-ro} can be used to disable it. | |
25274 | ||
d77de738 | 25275 | @opindex multilib-library-pic |
ddf6fe37 | 25276 | @item -multilib-library-pic |
d77de738 ML |
25277 | |
25278 | Link with the (library, not FD) pic libraries. It's implied by | |
25279 | @option{-mlibrary-pic}, as well as by @option{-fPIC} and | |
25280 | @option{-fpic} without @option{-mfdpic}. You should never have to use | |
25281 | it explicitly. | |
25282 | ||
d77de738 | 25283 | @opindex mlinked-fp |
ddf6fe37 | 25284 | @item -mlinked-fp |
d77de738 ML |
25285 | |
25286 | Follow the EABI requirement of always creating a frame pointer whenever | |
25287 | a stack frame is allocated. This option is enabled by default and can | |
25288 | be disabled with @option{-mno-linked-fp}. | |
25289 | ||
d77de738 | 25290 | @opindex mlong-calls |
ddf6fe37 | 25291 | @item -mlong-calls |
d77de738 ML |
25292 | |
25293 | Use indirect addressing to call functions outside the current | |
25294 | compilation unit. This allows the functions to be placed anywhere | |
25295 | within the 32-bit address space. | |
25296 | ||
d77de738 | 25297 | @opindex malign-labels |
ddf6fe37 | 25298 | @item -malign-labels |
d77de738 ML |
25299 | |
25300 | Try to align labels to an 8-byte boundary by inserting NOPs into the | |
25301 | previous packet. This option only has an effect when VLIW packing | |
25302 | is enabled. It doesn't create new packets; it merely adds NOPs to | |
25303 | existing ones. | |
25304 | ||
d77de738 | 25305 | @opindex mlibrary-pic |
ddf6fe37 | 25306 | @item -mlibrary-pic |
d77de738 ML |
25307 | |
25308 | Generate position-independent EABI code. | |
25309 | ||
d77de738 | 25310 | @opindex macc-4 |
ddf6fe37 | 25311 | @item -macc-4 |
d77de738 ML |
25312 | |
25313 | Use only the first four media accumulator registers. | |
25314 | ||
d77de738 | 25315 | @opindex macc-8 |
ddf6fe37 | 25316 | @item -macc-8 |
d77de738 ML |
25317 | |
25318 | Use all eight media accumulator registers. | |
25319 | ||
d77de738 | 25320 | @opindex mpack |
ddf6fe37 | 25321 | @item -mpack |
d77de738 ML |
25322 | |
25323 | Pack VLIW instructions. | |
25324 | ||
d77de738 | 25325 | @opindex mno-pack |
ddf6fe37 | 25326 | @item -mno-pack |
d77de738 ML |
25327 | |
25328 | Do not pack VLIW instructions. | |
25329 | ||
d77de738 | 25330 | @opindex mno-eflags |
ddf6fe37 | 25331 | @item -mno-eflags |
d77de738 ML |
25332 | |
25333 | Do not mark ABI switches in e_flags. | |
25334 | ||
d77de738 | 25335 | @opindex mcond-move |
ddf6fe37 | 25336 | @item -mcond-move |
d77de738 ML |
25337 | |
25338 | Enable the use of conditional-move instructions (default). | |
25339 | ||
25340 | This switch is mainly for debugging the compiler and will likely be removed | |
25341 | in a future version. | |
25342 | ||
d77de738 | 25343 | @opindex mno-cond-move |
ddf6fe37 | 25344 | @item -mno-cond-move |
d77de738 ML |
25345 | |
25346 | Disable the use of conditional-move instructions. | |
25347 | ||
25348 | This switch is mainly for debugging the compiler and will likely be removed | |
25349 | in a future version. | |
25350 | ||
d77de738 | 25351 | @opindex mscc |
ddf6fe37 | 25352 | @item -mscc |
d77de738 ML |
25353 | |
25354 | Enable the use of conditional set instructions (default). | |
25355 | ||
25356 | This switch is mainly for debugging the compiler and will likely be removed | |
25357 | in a future version. | |
25358 | ||
d77de738 | 25359 | @opindex mno-scc |
ddf6fe37 | 25360 | @item -mno-scc |
d77de738 ML |
25361 | |
25362 | Disable the use of conditional set instructions. | |
25363 | ||
25364 | This switch is mainly for debugging the compiler and will likely be removed | |
25365 | in a future version. | |
25366 | ||
d77de738 | 25367 | @opindex mcond-exec |
ddf6fe37 | 25368 | @item -mcond-exec |
d77de738 ML |
25369 | |
25370 | Enable the use of conditional execution (default). | |
25371 | ||
25372 | This switch is mainly for debugging the compiler and will likely be removed | |
25373 | in a future version. | |
25374 | ||
d77de738 | 25375 | @opindex mno-cond-exec |
ddf6fe37 | 25376 | @item -mno-cond-exec |
d77de738 ML |
25377 | |
25378 | Disable the use of conditional execution. | |
25379 | ||
25380 | This switch is mainly for debugging the compiler and will likely be removed | |
25381 | in a future version. | |
25382 | ||
d77de738 | 25383 | @opindex mvliw-branch |
ddf6fe37 | 25384 | @item -mvliw-branch |
d77de738 ML |
25385 | |
25386 | Run a pass to pack branches into VLIW instructions (default). | |
25387 | ||
25388 | This switch is mainly for debugging the compiler and will likely be removed | |
25389 | in a future version. | |
25390 | ||
d77de738 | 25391 | @opindex mno-vliw-branch |
ddf6fe37 | 25392 | @item -mno-vliw-branch |
d77de738 ML |
25393 | |
25394 | Do not run a pass to pack branches into VLIW instructions. | |
25395 | ||
25396 | This switch is mainly for debugging the compiler and will likely be removed | |
25397 | in a future version. | |
25398 | ||
d77de738 | 25399 | @opindex mmulti-cond-exec |
ddf6fe37 | 25400 | @item -mmulti-cond-exec |
d77de738 ML |
25401 | |
25402 | Enable optimization of @code{&&} and @code{||} in conditional execution | |
25403 | (default). | |
25404 | ||
25405 | This switch is mainly for debugging the compiler and will likely be removed | |
25406 | in a future version. | |
25407 | ||
d77de738 | 25408 | @opindex mno-multi-cond-exec |
ddf6fe37 | 25409 | @item -mno-multi-cond-exec |
d77de738 ML |
25410 | |
25411 | Disable optimization of @code{&&} and @code{||} in conditional execution. | |
25412 | ||
25413 | This switch is mainly for debugging the compiler and will likely be removed | |
25414 | in a future version. | |
25415 | ||
d77de738 | 25416 | @opindex mnested-cond-exec |
ddf6fe37 | 25417 | @item -mnested-cond-exec |
d77de738 ML |
25418 | |
25419 | Enable nested conditional execution optimizations (default). | |
25420 | ||
25421 | This switch is mainly for debugging the compiler and will likely be removed | |
25422 | in a future version. | |
25423 | ||
d77de738 | 25424 | @opindex mno-nested-cond-exec |
ddf6fe37 | 25425 | @item -mno-nested-cond-exec |
d77de738 ML |
25426 | |
25427 | Disable nested conditional execution optimizations. | |
25428 | ||
25429 | This switch is mainly for debugging the compiler and will likely be removed | |
25430 | in a future version. | |
25431 | ||
d77de738 | 25432 | @opindex moptimize-membar |
ddf6fe37 | 25433 | @item -moptimize-membar |
d77de738 ML |
25434 | |
25435 | This switch removes redundant @code{membar} instructions from the | |
25436 | compiler-generated code. It is enabled by default. | |
25437 | ||
d77de738 ML |
25438 | @opindex mno-optimize-membar |
25439 | @opindex moptimize-membar | |
ddf6fe37 | 25440 | @item -mno-optimize-membar |
d77de738 ML |
25441 | |
25442 | This switch disables the automatic removal of redundant @code{membar} | |
25443 | instructions from the generated code. | |
25444 | ||
d77de738 | 25445 | @opindex mtomcat-stats |
ddf6fe37 | 25446 | @item -mtomcat-stats |
d77de738 ML |
25447 | |
25448 | Cause gas to print out tomcat statistics. | |
25449 | ||
d77de738 | 25450 | @opindex mcpu |
ddf6fe37 | 25451 | @item -mcpu=@var{cpu} |
d77de738 ML |
25452 | |
25453 | Select the processor type for which to generate code. Possible values are | |
25454 | @samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450}, | |
25455 | @samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}. | |
25456 | ||
25457 | @end table | |
25458 | ||
25459 | @node GNU/Linux Options | |
25460 | @subsection GNU/Linux Options | |
25461 | ||
25462 | These @samp{-m} options are defined for GNU/Linux targets: | |
25463 | ||
25464 | @table @gcctabopt | |
d77de738 | 25465 | @opindex mglibc |
ddf6fe37 | 25466 | @item -mglibc |
d77de738 ML |
25467 | Use the GNU C library. This is the default except |
25468 | on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and | |
25469 | @samp{*-*-linux-*android*} targets. | |
25470 | ||
d77de738 | 25471 | @opindex muclibc |
ddf6fe37 | 25472 | @item -muclibc |
d77de738 ML |
25473 | Use uClibc C library. This is the default on |
25474 | @samp{*-*-linux-*uclibc*} targets. | |
25475 | ||
d77de738 | 25476 | @opindex mmusl |
ddf6fe37 | 25477 | @item -mmusl |
d77de738 ML |
25478 | Use the musl C library. This is the default on |
25479 | @samp{*-*-linux-*musl*} targets. | |
25480 | ||
d77de738 | 25481 | @opindex mbionic |
ddf6fe37 | 25482 | @item -mbionic |
d77de738 ML |
25483 | Use Bionic C library. This is the default on |
25484 | @samp{*-*-linux-*android*} targets. | |
25485 | ||
d77de738 | 25486 | @opindex mandroid |
ddf6fe37 | 25487 | @item -mandroid |
d77de738 ML |
25488 | Compile code compatible with Android platform. This is the default on |
25489 | @samp{*-*-linux-*android*} targets. | |
25490 | ||
25491 | When compiling, this option enables @option{-mbionic}, @option{-fPIC}, | |
25492 | @option{-fno-exceptions} and @option{-fno-rtti} by default. When linking, | |
25493 | this option makes the GCC driver pass Android-specific options to the linker. | |
25494 | Finally, this option causes the preprocessor macro @code{__ANDROID__} | |
25495 | to be defined. | |
25496 | ||
d77de738 | 25497 | @opindex tno-android-cc |
ddf6fe37 | 25498 | @item -tno-android-cc |
d77de738 ML |
25499 | Disable compilation effects of @option{-mandroid}, i.e., do not enable |
25500 | @option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and | |
25501 | @option{-fno-rtti} by default. | |
25502 | ||
d77de738 | 25503 | @opindex tno-android-ld |
ddf6fe37 | 25504 | @item -tno-android-ld |
d77de738 ML |
25505 | Disable linking effects of @option{-mandroid}, i.e., pass standard Linux |
25506 | linking options to the linker. | |
25507 | ||
25508 | @end table | |
25509 | ||
25510 | @node H8/300 Options | |
25511 | @subsection H8/300 Options | |
25512 | ||
25513 | These @samp{-m} options are defined for the H8/300 implementations: | |
25514 | ||
25515 | @table @gcctabopt | |
d77de738 | 25516 | @opindex mrelax |
ddf6fe37 | 25517 | @item -mrelax |
d77de738 ML |
25518 | Shorten some address references at link time, when possible; uses the |
25519 | linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300, | |
25520 | ld, Using ld}, for a fuller description. | |
25521 | ||
d77de738 | 25522 | @opindex mh |
ddf6fe37 | 25523 | @item -mh |
d77de738 ML |
25524 | Generate code for the H8/300H@. |
25525 | ||
d77de738 | 25526 | @opindex ms |
ddf6fe37 | 25527 | @item -ms |
d77de738 ML |
25528 | Generate code for the H8S@. |
25529 | ||
d77de738 | 25530 | @opindex mn |
ddf6fe37 | 25531 | @item -mn |
d77de738 ML |
25532 | Generate code for the H8S and H8/300H in the normal mode. This switch |
25533 | must be used either with @option{-mh} or @option{-ms}. | |
25534 | ||
d77de738 | 25535 | @opindex ms2600 |
ddf6fe37 | 25536 | @item -ms2600 |
d77de738 ML |
25537 | Generate code for the H8S/2600. This switch must be used with @option{-ms}. |
25538 | ||
d77de738 | 25539 | @opindex mexr |
ddf6fe37 | 25540 | @item -mexr |
d77de738 ML |
25541 | Extended registers are stored on stack before execution of function |
25542 | with monitor attribute. Default option is @option{-mexr}. | |
25543 | This option is valid only for H8S targets. | |
25544 | ||
d77de738 ML |
25545 | @opindex mno-exr |
25546 | @opindex mexr | |
ddf6fe37 | 25547 | @item -mno-exr |
d77de738 ML |
25548 | Extended registers are not stored on stack before execution of function |
25549 | with monitor attribute. Default option is @option{-mno-exr}. | |
25550 | This option is valid only for H8S targets. | |
25551 | ||
d77de738 | 25552 | @opindex mint32 |
ddf6fe37 | 25553 | @item -mint32 |
d77de738 ML |
25554 | Make @code{int} data 32 bits by default. |
25555 | ||
d77de738 | 25556 | @opindex malign-300 |
ddf6fe37 | 25557 | @item -malign-300 |
d77de738 ML |
25558 | On the H8/300H and H8S, use the same alignment rules as for the H8/300. |
25559 | The default for the H8/300H and H8S is to align longs and floats on | |
25560 | 4-byte boundaries. | |
25561 | @option{-malign-300} causes them to be aligned on 2-byte boundaries. | |
25562 | This option has no effect on the H8/300. | |
25563 | @end table | |
25564 | ||
25565 | @node HPPA Options | |
25566 | @subsection HPPA Options | |
25567 | @cindex HPPA Options | |
25568 | ||
25569 | These @samp{-m} options are defined for the HPPA family of computers: | |
25570 | ||
25571 | @table @gcctabopt | |
d77de738 | 25572 | @opindex march |
ddf6fe37 | 25573 | @item -march=@var{architecture-type} |
d77de738 ML |
25574 | Generate code for the specified architecture. The choices for |
25575 | @var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA | |
25576 | 1.1, and @samp{2.0} for PA 2.0 processors. Refer to | |
25577 | @file{/usr/lib/sched.models} on an HP-UX system to determine the proper | |
25578 | architecture option for your machine. Code compiled for lower numbered | |
25579 | architectures runs on higher numbered architectures, but not the | |
25580 | other way around. | |
25581 | ||
d77de738 ML |
25582 | @opindex mpa-risc-1-0 |
25583 | @opindex mpa-risc-1-1 | |
25584 | @opindex mpa-risc-2-0 | |
ddf6fe37 AA |
25585 | @item -mpa-risc-1-0 |
25586 | @itemx -mpa-risc-1-1 | |
25587 | @itemx -mpa-risc-2-0 | |
d77de738 ML |
25588 | Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively. |
25589 | ||
cf467fb9 JDA |
25590 | @opindex matomic-libcalls |
25591 | @opindex mno-atomic-libcalls | |
ddf6fe37 | 25592 | @item -matomic-libcalls |
cf467fb9 JDA |
25593 | Generate libcalls for atomic loads and stores when sync libcalls are disabled. |
25594 | This option is enabled by default. It only affects the generation of | |
25595 | atomic libcalls by the HPPA backend. | |
25596 | ||
25597 | Both the sync and @file{libatomic} libcall implementations use locking. | |
25598 | As a result, processor stores are not atomic with respect to other | |
25599 | atomic operations. Processor loads up to DImode are atomic with | |
25600 | respect to other atomic operations provided they are implemented as | |
25601 | a single access. | |
25602 | ||
25603 | The PA-RISC architecture does not support any atomic operations in | |
25604 | hardware except for the @code{ldcw} instruction. Thus, all atomic | |
25605 | support is implemented using sync and atomic libcalls. Sync libcall | |
25606 | support is in @file{libgcc.a}. Atomic libcall support is in | |
25607 | @file{libatomic}. | |
25608 | ||
25609 | This option generates @code{__atomic_exchange} calls for atomic stores. | |
25610 | It also provides special handling for atomic DImode accesses on 32-bit | |
25611 | targets. | |
25612 | ||
cf467fb9 | 25613 | @opindex mbig-switch |
ddf6fe37 | 25614 | @item -mbig-switch |
cf467fb9 JDA |
25615 | Does nothing. Preserved for backward compatibility. |
25616 | ||
d77de738 | 25617 | @opindex mcaller-copies |
ddf6fe37 | 25618 | @item -mcaller-copies |
d77de738 ML |
25619 | The caller copies function arguments passed by hidden reference. This |
25620 | option should be used with care as it is not compatible with the default | |
25621 | 32-bit runtime. However, only aggregates larger than eight bytes are | |
25622 | passed by hidden reference and the option provides better compatibility | |
25623 | with OpenMP. | |
25624 | ||
cf467fb9 | 25625 | @opindex mcoherent-ldcw |
ddf6fe37 | 25626 | @item -mcoherent-ldcw |
cf467fb9 | 25627 | Use ldcw/ldcd coherent cache-control hint. |
d77de738 | 25628 | |
d77de738 | 25629 | @opindex mdisable-fpregs |
ddf6fe37 | 25630 | @item -mdisable-fpregs |
cf467fb9 | 25631 | Disable floating-point registers. Equivalent to @code{-msoft-float}. |
d77de738 | 25632 | |
d77de738 | 25633 | @opindex mdisable-indexing |
ddf6fe37 | 25634 | @item -mdisable-indexing |
d77de738 ML |
25635 | Prevent the compiler from using indexing address modes. This avoids some |
25636 | rather obscure problems when compiling MIG generated code under MACH@. | |
25637 | ||
d77de738 | 25638 | @opindex mfast-indirect-calls |
ddf6fe37 | 25639 | @item -mfast-indirect-calls |
d77de738 ML |
25640 | Generate code that assumes calls never cross space boundaries. This |
25641 | allows GCC to emit code that performs faster indirect calls. | |
25642 | ||
25643 | This option does not work in the presence of shared libraries or nested | |
25644 | functions. | |
25645 | ||
d77de738 | 25646 | @opindex mfixed-range |
ddf6fe37 | 25647 | @item -mfixed-range=@var{register-range} |
d77de738 ML |
25648 | Generate code treating the given register range as fixed registers. |
25649 | A fixed register is one that the register allocator cannot use. This is | |
25650 | useful when compiling kernel code. A register range is specified as | |
25651 | two registers separated by a dash. Multiple register ranges can be | |
25652 | specified separated by a comma. | |
25653 | ||
d77de738 | 25654 | @opindex mgas |
ddf6fe37 | 25655 | @item -mgas |
d77de738 ML |
25656 | Enable the use of assembler directives only GAS understands. |
25657 | ||
d77de738 | 25658 | @opindex mgnu-ld |
ddf6fe37 | 25659 | @item -mgnu-ld |
d77de738 ML |
25660 | Use options specific to GNU @command{ld}. |
25661 | This passes @option{-shared} to @command{ld} when | |
25662 | building a shared library. It is the default when GCC is configured, | |
25663 | explicitly or implicitly, with the GNU linker. This option does not | |
25664 | affect which @command{ld} is called; it only changes what parameters | |
25665 | are passed to that @command{ld}. | |
25666 | The @command{ld} that is called is determined by the | |
25667 | @option{--with-ld} configure option, GCC's program search path, and | |
25668 | finally by the user's @env{PATH}. The linker used by GCC can be printed | |
25669 | using @samp{which `gcc -print-prog-name=ld`}. This option is only available | |
25670 | on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}. | |
25671 | ||
d77de738 | 25672 | @opindex mhp-ld |
ddf6fe37 | 25673 | @item -mhp-ld |
d77de738 ML |
25674 | Use options specific to HP @command{ld}. |
25675 | This passes @option{-b} to @command{ld} when building | |
25676 | a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all | |
25677 | links. It is the default when GCC is configured, explicitly or | |
25678 | implicitly, with the HP linker. This option does not affect | |
25679 | which @command{ld} is called; it only changes what parameters are passed to that | |
25680 | @command{ld}. | |
25681 | The @command{ld} that is called is determined by the @option{--with-ld} | |
25682 | configure option, GCC's program search path, and finally by the user's | |
25683 | @env{PATH}. The linker used by GCC can be printed using @samp{which | |
25684 | `gcc -print-prog-name=ld`}. This option is only available on the 64-bit | |
25685 | HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}. | |
25686 | ||
cf467fb9 | 25687 | @opindex mlinker-opt |
ddf6fe37 | 25688 | @item -mlinker-opt |
cf467fb9 JDA |
25689 | Enable the optimization pass in the HP-UX linker. Note this makes symbolic |
25690 | debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9 | |
25691 | linkers in which they give bogus error messages when linking some programs. | |
25692 | ||
d77de738 ML |
25693 | @opindex mno-long-calls |
25694 | @opindex mlong-calls | |
ddf6fe37 | 25695 | @item -mlong-calls |
d77de738 ML |
25696 | Generate code that uses long call sequences. This ensures that a call |
25697 | is always able to reach linker generated stubs. The default is to generate | |
25698 | long calls only when the distance from the call site to the beginning | |
25699 | of the function or translation unit, as the case may be, exceeds a | |
25700 | predefined limit set by the branch type being used. The limits for | |
25701 | normal calls are 7,600,000 and 240,000 bytes, respectively for the | |
25702 | PA 2.0 and PA 1.X architectures. Sibcalls are always limited at | |
25703 | 240,000 bytes. | |
25704 | ||
25705 | Distances are measured from the beginning of functions when using the | |
25706 | @option{-ffunction-sections} option, or when using the @option{-mgas} | |
25707 | and @option{-mno-portable-runtime} options together under HP-UX with | |
25708 | the SOM linker. | |
25709 | ||
25710 | It is normally not desirable to use this option as it degrades | |
25711 | performance. However, it may be useful in large applications, | |
25712 | particularly when partial linking is used to build the application. | |
25713 | ||
25714 | The types of long calls used depends on the capabilities of the | |
25715 | assembler and linker, and the type of code being generated. The | |
25716 | impact on systems that support long absolute calls, and long pic | |
25717 | symbol-difference or pc-relative calls should be relatively small. | |
25718 | However, an indirect call is used on 32-bit ELF systems in pic code | |
25719 | and it is quite long. | |
25720 | ||
cf467fb9 | 25721 | @opindex mlong-load-store |
ddf6fe37 | 25722 | @item -mlong-load-store |
cf467fb9 JDA |
25723 | Generate 3-instruction load and store sequences as sometimes required by |
25724 | the HP-UX 10 linker. This is equivalent to the @samp{+k} option to | |
25725 | the HP compilers. | |
25726 | ||
cf467fb9 | 25727 | @opindex mjump-in-delay |
ddf6fe37 | 25728 | @item -mjump-in-delay |
cf467fb9 JDA |
25729 | This option is ignored and provided for compatibility purposes only. |
25730 | ||
cf467fb9 JDA |
25731 | @opindex mno-space-regs |
25732 | @opindex mspace-regs | |
ddf6fe37 | 25733 | @item -mno-space-regs |
cf467fb9 JDA |
25734 | Generate code that assumes the target has no space registers. This allows |
25735 | GCC to generate faster indirect calls and use unscaled index address modes. | |
25736 | ||
25737 | Such code is suitable for level 0 PA systems and kernels. | |
25738 | ||
cf467fb9 | 25739 | @opindex mordered |
ddf6fe37 | 25740 | @item -mordered |
cf467fb9 JDA |
25741 | Assume memory references are ordered and barriers are not needed. |
25742 | ||
cf467fb9 | 25743 | @opindex mportable-runtime |
ddf6fe37 | 25744 | @item -mportable-runtime |
cf467fb9 JDA |
25745 | Use the portable calling conventions proposed by HP for ELF systems. |
25746 | ||
cf467fb9 | 25747 | @opindex mschedule |
ddf6fe37 | 25748 | @item -mschedule=@var{cpu-type} |
cf467fb9 JDA |
25749 | Schedule code according to the constraints for the machine type |
25750 | @var{cpu-type}. The choices for @var{cpu-type} are @samp{700} | |
25751 | @samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer | |
25752 | to @file{/usr/lib/sched.models} on an HP-UX system to determine the | |
25753 | proper scheduling option for your machine. The default scheduling is | |
25754 | @samp{8000}. | |
25755 | ||
cf467fb9 | 25756 | @opindex msio |
ddf6fe37 | 25757 | @item -msio |
cf467fb9 JDA |
25758 | Generate the predefine, @code{_SIO}, for server IO@. The default is |
25759 | @option{-mwsio}. This generates the predefines, @code{__hp9000s700}, | |
25760 | @code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These | |
25761 | options are available under HP-UX and HI-UX@. | |
25762 | ||
cf467fb9 | 25763 | @opindex msoft-float |
ddf6fe37 | 25764 | @item -msoft-float |
cf467fb9 JDA |
25765 | Generate output containing library calls for floating point. |
25766 | @strong{Warning:} the requisite libraries are not available for all HPPA | |
25767 | targets. Normally the facilities of the machine's usual C compiler are | |
25768 | used, but this cannot be done directly in cross-compilation. You must make | |
25769 | your own arrangements to provide suitable library functions for | |
25770 | cross-compilation. | |
25771 | ||
25772 | @option{-msoft-float} changes the calling convention in the output file; | |
25773 | therefore, it is only useful if you compile @emph{all} of a program with | |
25774 | this option. In particular, you need to compile @file{libgcc.a}, the | |
25775 | library that comes with GCC, with @option{-msoft-float} in order for | |
25776 | this to work. | |
25777 | ||
cf467fb9 | 25778 | @opindex msoft-mult |
ddf6fe37 | 25779 | @item -msoft-mult |
cf467fb9 JDA |
25780 | Use software integer multiplication. |
25781 | ||
25782 | This disables the use of the @code{xmpyu} instruction. | |
25783 | ||
d77de738 | 25784 | @opindex march |
ddf6fe37 | 25785 | @item -munix=@var{unix-std} |
d77de738 ML |
25786 | Generate compiler predefines and select a startfile for the specified |
25787 | UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95} | |
25788 | and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95} | |
25789 | is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX | |
25790 | 11.11 and later. The default values are @samp{93} for HP-UX 10.00, | |
25791 | @samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11 | |
25792 | and later. | |
25793 | ||
25794 | @option{-munix=93} provides the same predefines as GCC 3.3 and 3.4. | |
25795 | @option{-munix=95} provides additional predefines for @code{XOPEN_UNIX} | |
25796 | and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}. | |
25797 | @option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX}, | |
25798 | @code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and | |
25799 | @code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}. | |
25800 | ||
25801 | It is @emph{important} to note that this option changes the interfaces | |
25802 | for various library routines. It also affects the operational behavior | |
25803 | of the C library. Thus, @emph{extreme} care is needed in using this | |
25804 | option. | |
25805 | ||
25806 | Library code that is intended to operate with more than one UNIX | |
25807 | standard must test, set and restore the variable @code{__xpg4_extended_mask} | |
25808 | as appropriate. Most GNU software doesn't provide this capability. | |
25809 | ||
d77de738 | 25810 | @opindex nolibdld |
ddf6fe37 | 25811 | @item -nolibdld |
d77de738 ML |
25812 | Suppress the generation of link options to search libdld.sl when the |
25813 | @option{-static} option is specified on HP-UX 10 and later. | |
25814 | ||
d77de738 | 25815 | @opindex static |
ddf6fe37 | 25816 | @item -static |
d77de738 ML |
25817 | The HP-UX implementation of setlocale in libc has a dependency on |
25818 | libdld.sl. There isn't an archive version of libdld.sl. Thus, | |
25819 | when the @option{-static} option is specified, special link options | |
25820 | are needed to resolve this dependency. | |
25821 | ||
25822 | On HP-UX 10 and later, the GCC driver adds the necessary options to | |
25823 | link with libdld.sl when the @option{-static} option is specified. | |
25824 | This causes the resulting binary to be dynamic. On the 64-bit port, | |
25825 | the linkers generate dynamic binaries by default in any case. The | |
25826 | @option{-nolibdld} option can be used to prevent the GCC driver from | |
25827 | adding these link options. | |
25828 | ||
d77de738 | 25829 | @opindex threads |
ddf6fe37 | 25830 | @item -threads |
d77de738 ML |
25831 | Add support for multithreading with the @dfn{dce thread} library |
25832 | under HP-UX@. This option sets flags for both the preprocessor and | |
25833 | linker. | |
25834 | @end table | |
25835 | ||
25836 | @node IA-64 Options | |
25837 | @subsection IA-64 Options | |
25838 | @cindex IA-64 Options | |
25839 | ||
25840 | These are the @samp{-m} options defined for the Intel IA-64 architecture. | |
25841 | ||
25842 | @table @gcctabopt | |
d77de738 | 25843 | @opindex mbig-endian |
ddf6fe37 | 25844 | @item -mbig-endian |
d77de738 ML |
25845 | Generate code for a big-endian target. This is the default for HP-UX@. |
25846 | ||
d77de738 | 25847 | @opindex mlittle-endian |
ddf6fe37 | 25848 | @item -mlittle-endian |
d77de738 ML |
25849 | Generate code for a little-endian target. This is the default for AIX5 |
25850 | and GNU/Linux. | |
25851 | ||
d77de738 ML |
25852 | @opindex mgnu-as |
25853 | @opindex mno-gnu-as | |
ddf6fe37 AA |
25854 | @item -mgnu-as |
25855 | @itemx -mno-gnu-as | |
d77de738 ML |
25856 | Generate (or don't) code for the GNU assembler. This is the default. |
25857 | @c Also, this is the default if the configure option @option{--with-gnu-as} | |
25858 | @c is used. | |
25859 | ||
d77de738 ML |
25860 | @opindex mgnu-ld |
25861 | @opindex mno-gnu-ld | |
ddf6fe37 AA |
25862 | @item -mgnu-ld |
25863 | @itemx -mno-gnu-ld | |
d77de738 ML |
25864 | Generate (or don't) code for the GNU linker. This is the default. |
25865 | @c Also, this is the default if the configure option @option{--with-gnu-ld} | |
25866 | @c is used. | |
25867 | ||
d77de738 | 25868 | @opindex mno-pic |
ddf6fe37 | 25869 | @item -mno-pic |
d77de738 ML |
25870 | Generate code that does not use a global pointer register. The result |
25871 | is not position independent code, and violates the IA-64 ABI@. | |
25872 | ||
d77de738 ML |
25873 | @opindex mvolatile-asm-stop |
25874 | @opindex mno-volatile-asm-stop | |
ddf6fe37 AA |
25875 | @item -mvolatile-asm-stop |
25876 | @itemx -mno-volatile-asm-stop | |
d77de738 ML |
25877 | Generate (or don't) a stop bit immediately before and after volatile asm |
25878 | statements. | |
25879 | ||
d77de738 ML |
25880 | @opindex mregister-names |
25881 | @opindex mno-register-names | |
ddf6fe37 AA |
25882 | @item -mregister-names |
25883 | @itemx -mno-register-names | |
d77de738 ML |
25884 | Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for |
25885 | the stacked registers. This may make assembler output more readable. | |
25886 | ||
d77de738 ML |
25887 | @opindex mno-sdata |
25888 | @opindex msdata | |
ddf6fe37 AA |
25889 | @item -mno-sdata |
25890 | @itemx -msdata | |
d77de738 ML |
25891 | Disable (or enable) optimizations that use the small data section. This may |
25892 | be useful for working around optimizer bugs. | |
25893 | ||
d77de738 | 25894 | @opindex mconstant-gp |
ddf6fe37 | 25895 | @item -mconstant-gp |
d77de738 ML |
25896 | Generate code that uses a single constant global pointer value. This is |
25897 | useful when compiling kernel code. | |
25898 | ||
d77de738 | 25899 | @opindex mauto-pic |
ddf6fe37 | 25900 | @item -mauto-pic |
d77de738 ML |
25901 | Generate code that is self-relocatable. This implies @option{-mconstant-gp}. |
25902 | This is useful when compiling firmware code. | |
25903 | ||
d77de738 | 25904 | @opindex minline-float-divide-min-latency |
ddf6fe37 | 25905 | @item -minline-float-divide-min-latency |
d77de738 ML |
25906 | Generate code for inline divides of floating-point values |
25907 | using the minimum latency algorithm. | |
25908 | ||
d77de738 | 25909 | @opindex minline-float-divide-max-throughput |
ddf6fe37 | 25910 | @item -minline-float-divide-max-throughput |
d77de738 ML |
25911 | Generate code for inline divides of floating-point values |
25912 | using the maximum throughput algorithm. | |
25913 | ||
d77de738 | 25914 | @opindex mno-inline-float-divide |
ddf6fe37 | 25915 | @item -mno-inline-float-divide |
d77de738 ML |
25916 | Do not generate inline code for divides of floating-point values. |
25917 | ||
d77de738 | 25918 | @opindex minline-int-divide-min-latency |
ddf6fe37 | 25919 | @item -minline-int-divide-min-latency |
d77de738 ML |
25920 | Generate code for inline divides of integer values |
25921 | using the minimum latency algorithm. | |
25922 | ||
d77de738 | 25923 | @opindex minline-int-divide-max-throughput |
ddf6fe37 | 25924 | @item -minline-int-divide-max-throughput |
d77de738 ML |
25925 | Generate code for inline divides of integer values |
25926 | using the maximum throughput algorithm. | |
25927 | ||
d77de738 ML |
25928 | @opindex mno-inline-int-divide |
25929 | @opindex minline-int-divide | |
ddf6fe37 | 25930 | @item -mno-inline-int-divide |
d77de738 ML |
25931 | Do not generate inline code for divides of integer values. |
25932 | ||
d77de738 | 25933 | @opindex minline-sqrt-min-latency |
ddf6fe37 | 25934 | @item -minline-sqrt-min-latency |
d77de738 ML |
25935 | Generate code for inline square roots |
25936 | using the minimum latency algorithm. | |
25937 | ||
d77de738 | 25938 | @opindex minline-sqrt-max-throughput |
ddf6fe37 | 25939 | @item -minline-sqrt-max-throughput |
d77de738 ML |
25940 | Generate code for inline square roots |
25941 | using the maximum throughput algorithm. | |
25942 | ||
d77de738 | 25943 | @opindex mno-inline-sqrt |
ddf6fe37 | 25944 | @item -mno-inline-sqrt |
d77de738 ML |
25945 | Do not generate inline code for @code{sqrt}. |
25946 | ||
d77de738 ML |
25947 | @opindex mfused-madd |
25948 | @opindex mno-fused-madd | |
ddf6fe37 AA |
25949 | @item -mfused-madd |
25950 | @itemx -mno-fused-madd | |
d77de738 ML |
25951 | Do (don't) generate code that uses the fused multiply/add or multiply/subtract |
25952 | instructions. The default is to use these instructions. | |
25953 | ||
d77de738 ML |
25954 | @opindex mno-dwarf2-asm |
25955 | @opindex mdwarf2-asm | |
ddf6fe37 AA |
25956 | @item -mno-dwarf2-asm |
25957 | @itemx -mdwarf2-asm | |
d77de738 ML |
25958 | Don't (or do) generate assembler code for the DWARF line number debugging |
25959 | info. This may be useful when not using the GNU assembler. | |
25960 | ||
d77de738 ML |
25961 | @opindex mearly-stop-bits |
25962 | @opindex mno-early-stop-bits | |
ddf6fe37 AA |
25963 | @item -mearly-stop-bits |
25964 | @itemx -mno-early-stop-bits | |
d77de738 ML |
25965 | Allow stop bits to be placed earlier than immediately preceding the |
25966 | instruction that triggered the stop bit. This can improve instruction | |
25967 | scheduling, but does not always do so. | |
25968 | ||
d77de738 | 25969 | @opindex mfixed-range |
ddf6fe37 | 25970 | @item -mfixed-range=@var{register-range} |
d77de738 ML |
25971 | Generate code treating the given register range as fixed registers. |
25972 | A fixed register is one that the register allocator cannot use. This is | |
25973 | useful when compiling kernel code. A register range is specified as | |
25974 | two registers separated by a dash. Multiple register ranges can be | |
25975 | specified separated by a comma. | |
25976 | ||
d77de738 | 25977 | @opindex mtls-size |
ddf6fe37 | 25978 | @item -mtls-size=@var{tls-size} |
d77de738 ML |
25979 | Specify bit size of immediate TLS offsets. Valid values are 14, 22, and |
25980 | 64. | |
25981 | ||
d77de738 | 25982 | @opindex mtune |
ddf6fe37 | 25983 | @item -mtune=@var{cpu-type} |
d77de738 ML |
25984 | Tune the instruction scheduling for a particular CPU, Valid values are |
25985 | @samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2}, | |
25986 | and @samp{mckinley}. | |
25987 | ||
d77de738 ML |
25988 | @opindex milp32 |
25989 | @opindex mlp64 | |
ddf6fe37 AA |
25990 | @item -milp32 |
25991 | @itemx -mlp64 | |
d77de738 ML |
25992 | Generate code for a 32-bit or 64-bit environment. |
25993 | The 32-bit environment sets int, long and pointer to 32 bits. | |
25994 | The 64-bit environment sets int to 32 bits and long and pointer | |
25995 | to 64 bits. These are HP-UX specific flags. | |
25996 | ||
d77de738 ML |
25997 | @opindex mno-sched-br-data-spec |
25998 | @opindex msched-br-data-spec | |
ddf6fe37 AA |
25999 | @item -mno-sched-br-data-spec |
26000 | @itemx -msched-br-data-spec | |
d77de738 ML |
26001 | (Dis/En)able data speculative scheduling before reload. |
26002 | This results in generation of @code{ld.a} instructions and | |
26003 | the corresponding check instructions (@code{ld.c} / @code{chk.a}). | |
26004 | The default setting is disabled. | |
26005 | ||
d77de738 ML |
26006 | @opindex msched-ar-data-spec |
26007 | @opindex mno-sched-ar-data-spec | |
ddf6fe37 AA |
26008 | @item -msched-ar-data-spec |
26009 | @itemx -mno-sched-ar-data-spec | |
d77de738 ML |
26010 | (En/Dis)able data speculative scheduling after reload. |
26011 | This results in generation of @code{ld.a} instructions and | |
26012 | the corresponding check instructions (@code{ld.c} / @code{chk.a}). | |
26013 | The default setting is enabled. | |
26014 | ||
d77de738 ML |
26015 | @opindex mno-sched-control-spec |
26016 | @opindex msched-control-spec | |
ddf6fe37 AA |
26017 | @item -mno-sched-control-spec |
26018 | @itemx -msched-control-spec | |
d77de738 ML |
26019 | (Dis/En)able control speculative scheduling. This feature is |
26020 | available only during region scheduling (i.e.@: before reload). | |
26021 | This results in generation of the @code{ld.s} instructions and | |
26022 | the corresponding check instructions @code{chk.s}. | |
26023 | The default setting is disabled. | |
26024 | ||
d77de738 ML |
26025 | @opindex msched-br-in-data-spec |
26026 | @opindex mno-sched-br-in-data-spec | |
ddf6fe37 AA |
26027 | @item -msched-br-in-data-spec |
26028 | @itemx -mno-sched-br-in-data-spec | |
d77de738 ML |
26029 | (En/Dis)able speculative scheduling of the instructions that |
26030 | are dependent on the data speculative loads before reload. | |
26031 | This is effective only with @option{-msched-br-data-spec} enabled. | |
26032 | The default setting is enabled. | |
26033 | ||
d77de738 ML |
26034 | @opindex msched-ar-in-data-spec |
26035 | @opindex mno-sched-ar-in-data-spec | |
ddf6fe37 AA |
26036 | @item -msched-ar-in-data-spec |
26037 | @itemx -mno-sched-ar-in-data-spec | |
d77de738 ML |
26038 | (En/Dis)able speculative scheduling of the instructions that |
26039 | are dependent on the data speculative loads after reload. | |
26040 | This is effective only with @option{-msched-ar-data-spec} enabled. | |
26041 | The default setting is enabled. | |
26042 | ||
d77de738 ML |
26043 | @opindex msched-in-control-spec |
26044 | @opindex mno-sched-in-control-spec | |
ddf6fe37 AA |
26045 | @item -msched-in-control-spec |
26046 | @itemx -mno-sched-in-control-spec | |
d77de738 ML |
26047 | (En/Dis)able speculative scheduling of the instructions that |
26048 | are dependent on the control speculative loads. | |
26049 | This is effective only with @option{-msched-control-spec} enabled. | |
26050 | The default setting is enabled. | |
26051 | ||
d77de738 ML |
26052 | @opindex mno-sched-prefer-non-data-spec-insns |
26053 | @opindex msched-prefer-non-data-spec-insns | |
ddf6fe37 AA |
26054 | @item -mno-sched-prefer-non-data-spec-insns |
26055 | @itemx -msched-prefer-non-data-spec-insns | |
d77de738 ML |
26056 | If enabled, data-speculative instructions are chosen for schedule |
26057 | only if there are no other choices at the moment. This makes | |
26058 | the use of the data speculation much more conservative. | |
26059 | The default setting is disabled. | |
26060 | ||
d77de738 ML |
26061 | @opindex mno-sched-prefer-non-control-spec-insns |
26062 | @opindex msched-prefer-non-control-spec-insns | |
ddf6fe37 AA |
26063 | @item -mno-sched-prefer-non-control-spec-insns |
26064 | @itemx -msched-prefer-non-control-spec-insns | |
d77de738 ML |
26065 | If enabled, control-speculative instructions are chosen for schedule |
26066 | only if there are no other choices at the moment. This makes | |
26067 | the use of the control speculation much more conservative. | |
26068 | The default setting is disabled. | |
26069 | ||
d77de738 ML |
26070 | @opindex mno-sched-count-spec-in-critical-path |
26071 | @opindex msched-count-spec-in-critical-path | |
ddf6fe37 AA |
26072 | @item -mno-sched-count-spec-in-critical-path |
26073 | @itemx -msched-count-spec-in-critical-path | |
d77de738 ML |
26074 | If enabled, speculative dependencies are considered during |
26075 | computation of the instructions priorities. This makes the use of the | |
26076 | speculation a bit more conservative. | |
26077 | The default setting is disabled. | |
26078 | ||
d77de738 | 26079 | @opindex msched-spec-ldc |
ddf6fe37 | 26080 | @item -msched-spec-ldc |
d77de738 ML |
26081 | Use a simple data speculation check. This option is on by default. |
26082 | ||
d77de738 | 26083 | @opindex msched-spec-ldc |
ddf6fe37 | 26084 | @item -msched-control-spec-ldc |
d77de738 ML |
26085 | Use a simple check for control speculation. This option is on by default. |
26086 | ||
d77de738 | 26087 | @opindex msched-stop-bits-after-every-cycle |
ddf6fe37 | 26088 | @item -msched-stop-bits-after-every-cycle |
d77de738 ML |
26089 | Place a stop bit after every cycle when scheduling. This option is on |
26090 | by default. | |
26091 | ||
d77de738 | 26092 | @opindex msched-fp-mem-deps-zero-cost |
ddf6fe37 | 26093 | @item -msched-fp-mem-deps-zero-cost |
d77de738 ML |
26094 | Assume that floating-point stores and loads are not likely to cause a conflict |
26095 | when placed into the same instruction group. This option is disabled by | |
26096 | default. | |
26097 | ||
d77de738 | 26098 | @opindex msel-sched-dont-check-control-spec |
ddf6fe37 | 26099 | @item -msel-sched-dont-check-control-spec |
d77de738 ML |
26100 | Generate checks for control speculation in selective scheduling. |
26101 | This flag is disabled by default. | |
26102 | ||
d77de738 | 26103 | @opindex msched-max-memory-insns |
ddf6fe37 | 26104 | @item -msched-max-memory-insns=@var{max-insns} |
d77de738 ML |
26105 | Limit on the number of memory insns per instruction group, giving lower |
26106 | priority to subsequent memory insns attempting to schedule in the same | |
26107 | instruction group. Frequently useful to prevent cache bank conflicts. | |
26108 | The default value is 1. | |
26109 | ||
d77de738 | 26110 | @opindex msched-max-memory-insns-hard-limit |
ddf6fe37 | 26111 | @item -msched-max-memory-insns-hard-limit |
d77de738 ML |
26112 | Makes the limit specified by @option{msched-max-memory-insns} a hard limit, |
26113 | disallowing more than that number in an instruction group. | |
26114 | Otherwise, the limit is ``soft'', meaning that non-memory operations | |
26115 | are preferred when the limit is reached, but memory operations may still | |
26116 | be scheduled. | |
26117 | ||
26118 | @end table | |
26119 | ||
26120 | @node LM32 Options | |
26121 | @subsection LM32 Options | |
26122 | @cindex LM32 options | |
26123 | ||
26124 | These @option{-m} options are defined for the LatticeMico32 architecture: | |
26125 | ||
26126 | @table @gcctabopt | |
d77de738 | 26127 | @opindex mbarrel-shift-enabled |
ddf6fe37 | 26128 | @item -mbarrel-shift-enabled |
d77de738 ML |
26129 | Enable barrel-shift instructions. |
26130 | ||
d77de738 | 26131 | @opindex mdivide-enabled |
ddf6fe37 | 26132 | @item -mdivide-enabled |
d77de738 ML |
26133 | Enable divide and modulus instructions. |
26134 | ||
d77de738 | 26135 | @opindex multiply-enabled |
ddf6fe37 | 26136 | @item -mmultiply-enabled |
d77de738 ML |
26137 | Enable multiply instructions. |
26138 | ||
d77de738 | 26139 | @opindex msign-extend-enabled |
ddf6fe37 | 26140 | @item -msign-extend-enabled |
d77de738 ML |
26141 | Enable sign extend instructions. |
26142 | ||
d77de738 | 26143 | @opindex muser-enabled |
ddf6fe37 | 26144 | @item -muser-enabled |
d77de738 ML |
26145 | Enable user-defined instructions. |
26146 | ||
26147 | @end table | |
26148 | ||
26149 | @node LoongArch Options | |
26150 | @subsection LoongArch Options | |
26151 | @cindex LoongArch Options | |
26152 | ||
26153 | These command-line options are defined for LoongArch targets: | |
26154 | ||
26155 | @table @gcctabopt | |
9c19597c | 26156 | @opindex march |
ddf6fe37 | 26157 | @item -march=@var{cpu-type} |
d77de738 ML |
26158 | Generate instructions for the machine type @var{cpu-type}. In contrast to |
26159 | @option{-mtune=@var{cpu-type}}, which merely tunes the generated code | |
26160 | for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC | |
26161 | to generate code that may not run at all on processors other than the one | |
26162 | indicated. Specifying @option{-march=@var{cpu-type}} implies | |
26163 | @option{-mtune=@var{cpu-type}}, except where noted otherwise. | |
26164 | ||
26165 | The choices for @var{cpu-type} are: | |
26166 | ||
26167 | @table @samp | |
26168 | @item native | |
26169 | This selects the CPU to generate code for at compilation time by determining | |
26170 | the processor type of the compiling machine. Using @option{-march=native} | |
26171 | enables all instruction subsets supported by the local machine (hence | |
26172 | the result might not run on different machines). Using @option{-mtune=native} | |
26173 | produces code optimized for the local machine under the constraints | |
26174 | of the selected instruction set. | |
26175 | @item loongarch64 | |
26176 | A generic CPU with 64-bit extensions. | |
26177 | @item la464 | |
26178 | LoongArch LA464 CPU with LBT, LSX, LASX, LVZ. | |
26179 | @end table | |
26180 | ||
d77de738 | 26181 | @opindex mtune |
ddf6fe37 | 26182 | @item -mtune=@var{cpu-type} |
d77de738 ML |
26183 | Optimize the output for the given processor, specified by microarchitecture |
26184 | name. | |
26185 | ||
d77de738 | 26186 | @opindex mabi |
ddf6fe37 | 26187 | @item -mabi=@var{base-abi-type} |
d77de738 ML |
26188 | Generate code for the specified calling convention. |
26189 | @var{base-abi-type} can be one of: | |
26190 | @table @samp | |
26191 | @item lp64d | |
26192 | Uses 64-bit general purpose registers and 32/64-bit floating-point | |
26193 | registers for parameter passing. Data model is LP64, where @samp{int} | |
26194 | is 32 bits, while @samp{long int} and pointers are 64 bits. | |
26195 | @item lp64f | |
26196 | Uses 64-bit general purpose registers and 32-bit floating-point | |
26197 | registers for parameter passing. Data model is LP64, where @samp{int} | |
26198 | is 32 bits, while @samp{long int} and pointers are 64 bits. | |
26199 | @item lp64s | |
26200 | Uses 64-bit general purpose registers and no floating-point | |
26201 | registers for parameter passing. Data model is LP64, where @samp{int} | |
26202 | is 32 bits, while @samp{long int} and pointers are 64 bits. | |
26203 | @end table | |
26204 | ||
d77de738 | 26205 | @opindex mfpu |
ddf6fe37 | 26206 | @item -mfpu=@var{fpu-type} |
d77de738 ML |
26207 | Generate code for the specified FPU type, which can be one of: |
26208 | @table @samp | |
26209 | @item 64 | |
26210 | Allow the use of hardware floating-point instructions for 32-bit | |
26211 | and 64-bit operations. | |
26212 | @item 32 | |
26213 | Allow the use of hardware floating-point instructions for 32-bit | |
26214 | operations. | |
26215 | @item none | |
26216 | @item 0 | |
26217 | Prevent the use of hardware floating-point instructions. | |
26218 | @end table | |
26219 | ||
bb4a8198 YY |
26220 | @opindex msimd |
26221 | @item -msimd=@var{simd-type} | |
26222 | Enable generation of LoongArch SIMD instructions for vectorization | |
26223 | and via builtin functions. The value can be one of: | |
26224 | @table @samp | |
26225 | @item lasx | |
26226 | Enable generating instructions from the 256-bit LoongArch Advanced | |
26227 | SIMD Extension (LASX) and the 128-bit LoongArch SIMD Extension (LSX). | |
26228 | @item lsx | |
26229 | Enable generating instructions from the 128-bit LoongArch SIMD | |
26230 | Extension (LSX). | |
26231 | @item none | |
26232 | No LoongArch SIMD instruction may be generated. | |
26233 | @end table | |
26234 | ||
d77de738 | 26235 | @opindex msoft-float |
ddf6fe37 | 26236 | @item -msoft-float |
d77de738 ML |
26237 | Force @option{-mfpu=none} and prevents the use of floating-point |
26238 | registers for parameter passing. This option may change the target | |
26239 | ABI. | |
26240 | ||
9c19597c | 26241 | @opindex msingle-float |
ddf6fe37 | 26242 | @item -msingle-float |
d77de738 ML |
26243 | Force @option{-mfpu=32} and allow the use of 32-bit floating-point |
26244 | registers for parameter passing. This option may change the target | |
26245 | ABI. | |
26246 | ||
9c19597c | 26247 | @opindex mdouble-float |
ddf6fe37 | 26248 | @item -mdouble-float |
d77de738 ML |
26249 | Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point |
26250 | registers for parameter passing. This option may change the target | |
26251 | ABI. | |
26252 | ||
bb4a8198 YY |
26253 | @opindex ml[a]sx |
26254 | @item -mlasx | |
26255 | @itemx -mno-lasx | |
26256 | @item -mlsx | |
26257 | @itemx -mno-lsx | |
26258 | Incrementally adjust the scope of the SIMD extensions (none / LSX / LASX) | |
26259 | that can be used by the compiler for code generation. Enabling LASX with | |
26260 | @option{mlasx} automatically enables LSX, and diabling LSX with @option{mno-lsx} | |
26261 | automatically disables LASX. These driver-only options act upon the final | |
26262 | @option{msimd} configuration state and make incremental chagnes in the order | |
26263 | they appear on the GCC driver's command line, deriving the final / canonicalized | |
26264 | @option{msimd} option that is passed to the compiler proper. | |
26265 | ||
9c19597c | 26266 | @opindex mbranch-cost |
ddf6fe37 | 26267 | @item -mbranch-cost=@var{n} |
d77de738 ML |
26268 | Set the cost of branches to roughly @var{n} instructions. |
26269 | ||
ddf6fe37 | 26270 | @opindex mcheck-zero-division |
d77de738 ML |
26271 | @item -mcheck-zero-division |
26272 | @itemx -mno-check-zero-divison | |
d77de738 ML |
26273 | Trap (do not trap) on integer division by zero. The default is |
26274 | @option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and | |
26275 | @option{-mno-check-zero-division} for other optimization levels. | |
26276 | ||
ddf6fe37 | 26277 | @opindex mcond-move-int |
d77de738 ML |
26278 | @item -mcond-move-int |
26279 | @itemx -mno-cond-move-int | |
d77de738 ML |
26280 | Conditional moves for integral data in general-purpose registers |
26281 | are enabled (disabled). The default is @option{-mcond-move-int}. | |
26282 | ||
ddf6fe37 | 26283 | @opindex mcond-move-float |
d77de738 ML |
26284 | @item -mcond-move-float |
26285 | @itemx -mno-cond-move-float | |
d77de738 ML |
26286 | Conditional moves for floating-point registers are enabled (disabled). |
26287 | The default is @option{-mcond-move-float}. | |
26288 | ||
ddf6fe37 | 26289 | @opindex mmemcpy |
d77de738 ML |
26290 | @item -mmemcpy |
26291 | @itemx -mno-memcpy | |
d77de738 ML |
26292 | Force (do not force) the use of @code{memcpy} for non-trivial block moves. |
26293 | The default is @option{-mno-memcpy}, which allows GCC to inline most | |
26294 | constant-sized copies. Setting optimization level to @option{-Os} also | |
26295 | forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this | |
26296 | behavior if explicitly specified, regardless of the order these options on | |
26297 | the command line. | |
26298 | ||
ddf6fe37 | 26299 | @opindex mstrict-align |
d77de738 ML |
26300 | @item -mstrict-align |
26301 | @itemx -mno-strict-align | |
d77de738 ML |
26302 | Avoid or allow generating memory accesses that may not be aligned on a natural |
26303 | object boundary as described in the architecture specification. The default is | |
26304 | @option{-mno-strict-align}. | |
26305 | ||
9c19597c | 26306 | @opindex msmall-data-limit |
ddf6fe37 | 26307 | @item -msmall-data-limit=@var{number} |
d77de738 ML |
26308 | Put global and static data smaller than @var{number} bytes into a special |
26309 | section (on some targets). The default value is 0. | |
26310 | ||
9c19597c | 26311 | @opindex mmax-inline-memcpy-size |
ddf6fe37 | 26312 | @item -mmax-inline-memcpy-size=@var{n} |
d77de738 ML |
26313 | Inline all block moves (such as calls to @code{memcpy} or structure copies) |
26314 | less than or equal to @var{n} bytes. The default value of @var{n} is 1024. | |
26315 | ||
26316 | @item -mcmodel=@var{code-model} | |
26317 | Set the code model to one of: | |
26318 | @table @samp | |
26319 | @item tiny-static (Not implemented yet) | |
26320 | @item tiny (Not implemented yet) | |
26321 | ||
26322 | @item normal | |
26323 | The text segment must be within 128MB addressing space. The data segment must | |
26324 | be within 2GB addressing space. | |
26325 | ||
26326 | @item medium | |
26327 | The text segment and data segment must be within 2GB addressing space. | |
26328 | ||
26329 | @item large (Not implemented yet) | |
26330 | ||
26331 | @item extreme | |
26332 | This mode does not limit the size of the code segment and data segment. | |
e1b1cba1 XR |
26333 | The @option{-mcmodel=extreme} option is incompatible with @option{-fplt}, |
26334 | and it requires @option{-mexplicit-relocs=always}. | |
d77de738 ML |
26335 | @end table |
26336 | The default code model is @code{normal}. | |
26337 | ||
e1b1cba1 XR |
26338 | @item -mexplicit-relocs=@var{style} |
26339 | Set when to use assembler relocation operators when dealing with symbolic | |
d77de738 | 26340 | addresses. The alternative is to use assembler macros instead, which may |
e1b1cba1 XR |
26341 | limit instruction scheduling but allow linker relaxation. |
26342 | with @option{-mexplicit-relocs=none} the assembler macros are always used, | |
26343 | with @option{-mexplicit-relocs=always} the assembler relocation operators | |
26344 | are always used, with @option{-mexplicit-relocs=auto} the compiler will | |
26345 | use the relocation operators where the linker relaxation is impossible to | |
26346 | improve the code quality, and macros elsewhere. The default | |
c25d6f15 XR |
26347 | value for the option is determined during GCC build-time by detecting |
26348 | corresponding assembler support: | |
e1b1cba1 XR |
26349 | @option{-mexplicit-relocs=none} if the assembler does not support |
26350 | relocation operators at all, | |
26351 | @option{-mexplicit-relocs=always} if the assembler supports relocation | |
26352 | operators but does not support relaxation, | |
26353 | @option{-mexplicit-relocs=auto} if the assembler supports both relocation | |
26354 | operators and relaxation. This option is mostly useful for | |
d77de738 ML |
26355 | debugging, or interoperation with assemblers different from the build-time |
26356 | one. | |
26357 | ||
e1b1cba1 XR |
26358 | @opindex mexplicit-relocs |
26359 | @item -mexplicit-relocs | |
26360 | An alias of @option{-mexplicit-relocs=always} for backward compatibility. | |
26361 | ||
26362 | @opindex mno-explicit-relocs | |
26363 | @item -mno-explicit-relocs | |
26364 | An alias of @option{-mexplicit-relocs=none} for backward compatibility. | |
26365 | ||
ddf6fe37 | 26366 | @opindex mdirect-extern-access |
d77de738 ML |
26367 | @item -mdirect-extern-access |
26368 | @itemx -mno-direct-extern-access | |
d77de738 ML |
26369 | Do not use or use GOT to access external symbols. The default is |
26370 | @option{-mno-direct-extern-access}: GOT is used for external symbols with | |
26371 | default visibility, but not used for other external symbols. | |
26372 | ||
26373 | With @option{-mdirect-extern-access}, GOT is not used and all external | |
26374 | symbols are PC-relatively addressed. It is @strong{only} suitable for | |
26375 | environments where no dynamic link is performed, like firmwares, OS | |
26376 | kernels, executables linked with @option{-static} or @option{-static-pie}. | |
26377 | @option{-mdirect-extern-access} is not compatible with @option{-fPIC} or | |
26378 | @option{-fpic}. | |
8f4bbdc2 JX |
26379 | |
26380 | @item loongarch-vect-unroll-limit | |
26381 | The vectorizer will use available tuning information to determine whether it | |
26382 | would be beneficial to unroll the main vectorized loop and by how much. This | |
26383 | parameter set's the upper bound of how much the vectorizer will unroll the main | |
26384 | loop. The default value is six. | |
26385 | ||
d77de738 ML |
26386 | @end table |
26387 | ||
bb4a8198 | 26388 | |
d77de738 ML |
26389 | @node M32C Options |
26390 | @subsection M32C Options | |
26391 | @cindex M32C options | |
26392 | ||
26393 | @table @gcctabopt | |
d77de738 | 26394 | @opindex mcpu= |
ddf6fe37 | 26395 | @item -mcpu=@var{name} |
d77de738 ML |
26396 | Select the CPU for which code is generated. @var{name} may be one of |
26397 | @samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to | |
26398 | /60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for | |
26399 | the M32C/80 series. | |
26400 | ||
d77de738 | 26401 | @opindex msim |
ddf6fe37 | 26402 | @item -msim |
d77de738 ML |
26403 | Specifies that the program will be run on the simulator. This causes |
26404 | an alternate runtime library to be linked in which supports, for | |
26405 | example, file I/O@. You must not use this option when generating | |
26406 | programs that will run on real hardware; you must provide your own | |
26407 | runtime library for whatever I/O functions are needed. | |
26408 | ||
d77de738 | 26409 | @opindex memregs= |
ddf6fe37 | 26410 | @item -memregs=@var{number} |
d77de738 ML |
26411 | Specifies the number of memory-based pseudo-registers GCC uses |
26412 | during code generation. These pseudo-registers are used like real | |
26413 | registers, so there is a tradeoff between GCC's ability to fit the | |
26414 | code into available registers, and the performance penalty of using | |
26415 | memory instead of registers. Note that all modules in a program must | |
26416 | be compiled with the same value for this option. Because of that, you | |
26417 | must not use this option with GCC's default runtime libraries. | |
26418 | ||
26419 | @end table | |
26420 | ||
26421 | @node M32R/D Options | |
26422 | @subsection M32R/D Options | |
26423 | @cindex M32R/D options | |
26424 | ||
26425 | These @option{-m} options are defined for Renesas M32R/D architectures: | |
26426 | ||
26427 | @table @gcctabopt | |
d77de738 | 26428 | @opindex m32r2 |
ddf6fe37 | 26429 | @item -m32r2 |
d77de738 ML |
26430 | Generate code for the M32R/2@. |
26431 | ||
d77de738 | 26432 | @opindex m32rx |
ddf6fe37 | 26433 | @item -m32rx |
d77de738 ML |
26434 | Generate code for the M32R/X@. |
26435 | ||
d77de738 | 26436 | @opindex m32r |
ddf6fe37 | 26437 | @item -m32r |
d77de738 ML |
26438 | Generate code for the M32R@. This is the default. |
26439 | ||
d77de738 | 26440 | @opindex mmodel=small |
ddf6fe37 | 26441 | @item -mmodel=small |
d77de738 ML |
26442 | Assume all objects live in the lower 16MB of memory (so that their addresses |
26443 | can be loaded with the @code{ld24} instruction), and assume all subroutines | |
26444 | are reachable with the @code{bl} instruction. | |
26445 | This is the default. | |
26446 | ||
26447 | The addressability of a particular object can be set with the | |
26448 | @code{model} attribute. | |
26449 | ||
d77de738 | 26450 | @opindex mmodel=medium |
ddf6fe37 | 26451 | @item -mmodel=medium |
d77de738 ML |
26452 | Assume objects may be anywhere in the 32-bit address space (the compiler |
26453 | generates @code{seth/add3} instructions to load their addresses), and | |
26454 | assume all subroutines are reachable with the @code{bl} instruction. | |
26455 | ||
d77de738 | 26456 | @opindex mmodel=large |
ddf6fe37 | 26457 | @item -mmodel=large |
d77de738 ML |
26458 | Assume objects may be anywhere in the 32-bit address space (the compiler |
26459 | generates @code{seth/add3} instructions to load their addresses), and | |
26460 | assume subroutines may not be reachable with the @code{bl} instruction | |
26461 | (the compiler generates the much slower @code{seth/add3/jl} | |
26462 | instruction sequence). | |
26463 | ||
d77de738 | 26464 | @opindex msdata=none |
ddf6fe37 | 26465 | @item -msdata=none |
d77de738 ML |
26466 | Disable use of the small data area. Variables are put into |
26467 | one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the | |
26468 | @code{section} attribute has been specified). | |
26469 | This is the default. | |
26470 | ||
26471 | The small data area consists of sections @code{.sdata} and @code{.sbss}. | |
26472 | Objects may be explicitly put in the small data area with the | |
26473 | @code{section} attribute using one of these sections. | |
26474 | ||
d77de738 | 26475 | @opindex msdata=sdata |
ddf6fe37 | 26476 | @item -msdata=sdata |
d77de738 ML |
26477 | Put small global and static data in the small data area, but do not |
26478 | generate special code to reference them. | |
26479 | ||
d77de738 | 26480 | @opindex msdata=use |
ddf6fe37 | 26481 | @item -msdata=use |
d77de738 ML |
26482 | Put small global and static data in the small data area, and generate |
26483 | special instructions to reference them. | |
26484 | ||
d77de738 ML |
26485 | @opindex G |
26486 | @cindex smaller data references | |
f33d7a88 | 26487 | @item -G @var{num} |
d77de738 ML |
26488 | Put global and static objects less than or equal to @var{num} bytes |
26489 | into the small data or BSS sections instead of the normal data or BSS | |
26490 | sections. The default value of @var{num} is 8. | |
26491 | The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use} | |
26492 | for this option to have any effect. | |
26493 | ||
26494 | All modules should be compiled with the same @option{-G @var{num}} value. | |
26495 | Compiling with different values of @var{num} may or may not work; if it | |
26496 | doesn't the linker gives an error message---incorrect code is not | |
26497 | generated. | |
26498 | ||
d77de738 | 26499 | @opindex mdebug |
ddf6fe37 | 26500 | @item -mdebug |
d77de738 ML |
26501 | Makes the M32R-specific code in the compiler display some statistics |
26502 | that might help in debugging programs. | |
26503 | ||
d77de738 | 26504 | @opindex malign-loops |
ddf6fe37 | 26505 | @item -malign-loops |
d77de738 ML |
26506 | Align all loops to a 32-byte boundary. |
26507 | ||
d77de738 | 26508 | @opindex mno-align-loops |
ddf6fe37 | 26509 | @item -mno-align-loops |
d77de738 ML |
26510 | Do not enforce a 32-byte alignment for loops. This is the default. |
26511 | ||
d77de738 | 26512 | @opindex missue-rate=@var{number} |
ddf6fe37 | 26513 | @item -missue-rate=@var{number} |
d77de738 ML |
26514 | Issue @var{number} instructions per cycle. @var{number} can only be 1 |
26515 | or 2. | |
26516 | ||
d77de738 | 26517 | @opindex mbranch-cost=@var{number} |
ddf6fe37 | 26518 | @item -mbranch-cost=@var{number} |
d77de738 ML |
26519 | @var{number} can only be 1 or 2. If it is 1 then branches are |
26520 | preferred over conditional code, if it is 2, then the opposite applies. | |
26521 | ||
d77de738 | 26522 | @opindex mflush-trap=@var{number} |
ddf6fe37 | 26523 | @item -mflush-trap=@var{number} |
d77de738 ML |
26524 | Specifies the trap number to use to flush the cache. The default is |
26525 | 12. Valid numbers are between 0 and 15 inclusive. | |
26526 | ||
d77de738 | 26527 | @opindex mno-flush-trap |
ddf6fe37 | 26528 | @item -mno-flush-trap |
d77de738 ML |
26529 | Specifies that the cache cannot be flushed by using a trap. |
26530 | ||
d77de738 | 26531 | @opindex mflush-func=@var{name} |
ddf6fe37 | 26532 | @item -mflush-func=@var{name} |
d77de738 ML |
26533 | Specifies the name of the operating system function to call to flush |
26534 | the cache. The default is @samp{_flush_cache}, but a function call | |
26535 | is only used if a trap is not available. | |
26536 | ||
d77de738 | 26537 | @opindex mno-flush-func |
ddf6fe37 | 26538 | @item -mno-flush-func |
d77de738 ML |
26539 | Indicates that there is no OS function for flushing the cache. |
26540 | ||
26541 | @end table | |
26542 | ||
26543 | @node M680x0 Options | |
26544 | @subsection M680x0 Options | |
26545 | @cindex M680x0 options | |
26546 | ||
26547 | These are the @samp{-m} options defined for M680x0 and ColdFire processors. | |
26548 | The default settings depend on which architecture was selected when | |
26549 | the compiler was configured; the defaults for the most common choices | |
26550 | are given below. | |
26551 | ||
26552 | @table @gcctabopt | |
d77de738 | 26553 | @opindex march |
ddf6fe37 | 26554 | @item -march=@var{arch} |
d77de738 ML |
26555 | Generate code for a specific M680x0 or ColdFire instruction set |
26556 | architecture. Permissible values of @var{arch} for M680x0 | |
26557 | architectures are: @samp{68000}, @samp{68010}, @samp{68020}, | |
26558 | @samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire | |
26559 | architectures are selected according to Freescale's ISA classification | |
26560 | and the permissible values are: @samp{isaa}, @samp{isaaplus}, | |
26561 | @samp{isab} and @samp{isac}. | |
26562 | ||
26563 | GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating | |
26564 | code for a ColdFire target. The @var{arch} in this macro is one of the | |
26565 | @option{-march} arguments given above. | |
26566 | ||
26567 | When used together, @option{-march} and @option{-mtune} select code | |
26568 | that runs on a family of similar processors but that is optimized | |
26569 | for a particular microarchitecture. | |
26570 | ||
d77de738 | 26571 | @opindex mcpu |
ddf6fe37 | 26572 | @item -mcpu=@var{cpu} |
d77de738 ML |
26573 | Generate code for a specific M680x0 or ColdFire processor. |
26574 | The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020}, | |
26575 | @samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332} | |
26576 | and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table | |
26577 | below, which also classifies the CPUs into families: | |
26578 | ||
26579 | @multitable @columnfractions 0.20 0.80 | |
26580 | @headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments} | |
26581 | @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} | |
26582 | @item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206} | |
26583 | @item @samp{5206e} @tab @samp{5206e} | |
26584 | @item @samp{5208} @tab @samp{5207} @samp{5208} | |
26585 | @item @samp{5211a} @tab @samp{5210a} @samp{5211a} | |
26586 | @item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213} | |
26587 | @item @samp{5216} @tab @samp{5214} @samp{5216} | |
26588 | @item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235} | |
26589 | @item @samp{5225} @tab @samp{5224} @samp{5225} | |
26590 | @item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259} | |
26591 | @item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x} | |
26592 | @item @samp{5249} @tab @samp{5249} | |
26593 | @item @samp{5250} @tab @samp{5250} | |
26594 | @item @samp{5271} @tab @samp{5270} @samp{5271} | |
26595 | @item @samp{5272} @tab @samp{5272} | |
26596 | @item @samp{5275} @tab @samp{5274} @samp{5275} | |
26597 | @item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x} | |
26598 | @item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017} | |
26599 | @item @samp{5307} @tab @samp{5307} | |
26600 | @item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x} | |
26601 | @item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x} | |
26602 | @item @samp{5407} @tab @samp{5407} | |
26603 | @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} | |
26604 | @end multitable | |
26605 | ||
26606 | @option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if | |
26607 | @var{arch} is compatible with @var{cpu}. Other combinations of | |
26608 | @option{-mcpu} and @option{-march} are rejected. | |
26609 | ||
26610 | GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target | |
26611 | @var{cpu} is selected. It also defines @code{__mcf_family_@var{family}}, | |
26612 | where the value of @var{family} is given by the table above. | |
26613 | ||
d77de738 | 26614 | @opindex mtune |
ddf6fe37 | 26615 | @item -mtune=@var{tune} |
d77de738 ML |
26616 | Tune the code for a particular microarchitecture within the |
26617 | constraints set by @option{-march} and @option{-mcpu}. | |
26618 | The M680x0 microarchitectures are: @samp{68000}, @samp{68010}, | |
26619 | @samp{68020}, @samp{68030}, @samp{68040}, @samp{68060} | |
26620 | and @samp{cpu32}. The ColdFire microarchitectures | |
26621 | are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}. | |
26622 | ||
26623 | You can also use @option{-mtune=68020-40} for code that needs | |
26624 | to run relatively well on 68020, 68030 and 68040 targets. | |
26625 | @option{-mtune=68020-60} is similar but includes 68060 targets | |
26626 | as well. These two options select the same tuning decisions as | |
26627 | @option{-m68020-40} and @option{-m68020-60} respectively. | |
26628 | ||
26629 | GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__} | |
26630 | when tuning for 680x0 architecture @var{arch}. It also defines | |
26631 | @code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std} | |
26632 | option is used. If GCC is tuning for a range of architectures, | |
26633 | as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60}, | |
26634 | it defines the macros for every architecture in the range. | |
26635 | ||
26636 | GCC also defines the macro @code{__m@var{uarch}__} when tuning for | |
26637 | ColdFire microarchitecture @var{uarch}, where @var{uarch} is one | |
26638 | of the arguments given above. | |
26639 | ||
d77de738 ML |
26640 | @opindex m68000 |
26641 | @opindex mc68000 | |
ddf6fe37 AA |
26642 | @item -m68000 |
26643 | @itemx -mc68000 | |
d77de738 ML |
26644 | Generate output for a 68000. This is the default |
26645 | when the compiler is configured for 68000-based systems. | |
26646 | It is equivalent to @option{-march=68000}. | |
26647 | ||
26648 | Use this option for microcontrollers with a 68000 or EC000 core, | |
26649 | including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356. | |
26650 | ||
d77de738 | 26651 | @opindex m68010 |
ddf6fe37 | 26652 | @item -m68010 |
d77de738 ML |
26653 | Generate output for a 68010. This is the default |
26654 | when the compiler is configured for 68010-based systems. | |
26655 | It is equivalent to @option{-march=68010}. | |
26656 | ||
d77de738 ML |
26657 | @opindex m68020 |
26658 | @opindex mc68020 | |
ddf6fe37 AA |
26659 | @item -m68020 |
26660 | @itemx -mc68020 | |
d77de738 ML |
26661 | Generate output for a 68020. This is the default |
26662 | when the compiler is configured for 68020-based systems. | |
26663 | It is equivalent to @option{-march=68020}. | |
26664 | ||
d77de738 | 26665 | @opindex m68030 |
ddf6fe37 | 26666 | @item -m68030 |
d77de738 ML |
26667 | Generate output for a 68030. This is the default when the compiler is |
26668 | configured for 68030-based systems. It is equivalent to | |
26669 | @option{-march=68030}. | |
26670 | ||
d77de738 | 26671 | @opindex m68040 |
ddf6fe37 | 26672 | @item -m68040 |
d77de738 ML |
26673 | Generate output for a 68040. This is the default when the compiler is |
26674 | configured for 68040-based systems. It is equivalent to | |
26675 | @option{-march=68040}. | |
26676 | ||
26677 | This option inhibits the use of 68881/68882 instructions that have to be | |
26678 | emulated by software on the 68040. Use this option if your 68040 does not | |
26679 | have code to emulate those instructions. | |
26680 | ||
d77de738 | 26681 | @opindex m68060 |
ddf6fe37 | 26682 | @item -m68060 |
d77de738 ML |
26683 | Generate output for a 68060. This is the default when the compiler is |
26684 | configured for 68060-based systems. It is equivalent to | |
26685 | @option{-march=68060}. | |
26686 | ||
26687 | This option inhibits the use of 68020 and 68881/68882 instructions that | |
26688 | have to be emulated by software on the 68060. Use this option if your 68060 | |
26689 | does not have code to emulate those instructions. | |
26690 | ||
d77de738 | 26691 | @opindex mcpu32 |
ddf6fe37 | 26692 | @item -mcpu32 |
d77de738 ML |
26693 | Generate output for a CPU32. This is the default |
26694 | when the compiler is configured for CPU32-based systems. | |
26695 | It is equivalent to @option{-march=cpu32}. | |
26696 | ||
26697 | Use this option for microcontrollers with a | |
26698 | CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334, | |
26699 | 68336, 68340, 68341, 68349 and 68360. | |
26700 | ||
d77de738 | 26701 | @opindex m5200 |
ddf6fe37 | 26702 | @item -m5200 |
d77de738 ML |
26703 | Generate output for a 520X ColdFire CPU@. This is the default |
26704 | when the compiler is configured for 520X-based systems. | |
26705 | It is equivalent to @option{-mcpu=5206}, and is now deprecated | |
26706 | in favor of that option. | |
26707 | ||
26708 | Use this option for microcontroller with a 5200 core, including | |
26709 | the MCF5202, MCF5203, MCF5204 and MCF5206. | |
26710 | ||
d77de738 | 26711 | @opindex m5206e |
ddf6fe37 | 26712 | @item -m5206e |
d77de738 ML |
26713 | Generate output for a 5206e ColdFire CPU@. The option is now |
26714 | deprecated in favor of the equivalent @option{-mcpu=5206e}. | |
26715 | ||
d77de738 | 26716 | @opindex m528x |
ddf6fe37 | 26717 | @item -m528x |
d77de738 ML |
26718 | Generate output for a member of the ColdFire 528X family. |
26719 | The option is now deprecated in favor of the equivalent | |
26720 | @option{-mcpu=528x}. | |
26721 | ||
d77de738 | 26722 | @opindex m5307 |
ddf6fe37 | 26723 | @item -m5307 |
d77de738 ML |
26724 | Generate output for a ColdFire 5307 CPU@. The option is now deprecated |
26725 | in favor of the equivalent @option{-mcpu=5307}. | |
26726 | ||
d77de738 | 26727 | @opindex m5407 |
ddf6fe37 | 26728 | @item -m5407 |
d77de738 ML |
26729 | Generate output for a ColdFire 5407 CPU@. The option is now deprecated |
26730 | in favor of the equivalent @option{-mcpu=5407}. | |
26731 | ||
d77de738 | 26732 | @opindex mcfv4e |
ddf6fe37 | 26733 | @item -mcfv4e |
d77de738 ML |
26734 | Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x). |
26735 | This includes use of hardware floating-point instructions. | |
26736 | The option is equivalent to @option{-mcpu=547x}, and is now | |
26737 | deprecated in favor of that option. | |
26738 | ||
d77de738 | 26739 | @opindex m68020-40 |
ddf6fe37 | 26740 | @item -m68020-40 |
d77de738 ML |
26741 | Generate output for a 68040, without using any of the new instructions. |
26742 | This results in code that can run relatively efficiently on either a | |
26743 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
26744 | 68881 instructions that are emulated on the 68040. | |
26745 | ||
26746 | The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}. | |
26747 | ||
d77de738 | 26748 | @opindex m68020-60 |
ddf6fe37 | 26749 | @item -m68020-60 |
d77de738 ML |
26750 | Generate output for a 68060, without using any of the new instructions. |
26751 | This results in code that can run relatively efficiently on either a | |
26752 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
26753 | 68881 instructions that are emulated on the 68060. | |
26754 | ||
26755 | The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}. | |
26756 | ||
d77de738 ML |
26757 | @opindex mhard-float |
26758 | @opindex m68881 | |
ddf6fe37 AA |
26759 | @item -mhard-float |
26760 | @itemx -m68881 | |
d77de738 ML |
26761 | Generate floating-point instructions. This is the default for 68020 |
26762 | and above, and for ColdFire devices that have an FPU@. It defines the | |
26763 | macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__} | |
26764 | on ColdFire targets. | |
26765 | ||
d77de738 | 26766 | @opindex msoft-float |
ddf6fe37 | 26767 | @item -msoft-float |
d77de738 ML |
26768 | Do not generate floating-point instructions; use library calls instead. |
26769 | This is the default for 68000, 68010, and 68832 targets. It is also | |
26770 | the default for ColdFire devices that have no FPU. | |
26771 | ||
d77de738 ML |
26772 | @opindex mdiv |
26773 | @opindex mno-div | |
ddf6fe37 AA |
26774 | @item -mdiv |
26775 | @itemx -mno-div | |
d77de738 ML |
26776 | Generate (do not generate) ColdFire hardware divide and remainder |
26777 | instructions. If @option{-march} is used without @option{-mcpu}, | |
26778 | the default is ``on'' for ColdFire architectures and ``off'' for M680x0 | |
26779 | architectures. Otherwise, the default is taken from the target CPU | |
26780 | (either the default CPU, or the one specified by @option{-mcpu}). For | |
26781 | example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for | |
26782 | @option{-mcpu=5206e}. | |
26783 | ||
26784 | GCC defines the macro @code{__mcfhwdiv__} when this option is enabled. | |
26785 | ||
d77de738 | 26786 | @opindex mshort |
ddf6fe37 | 26787 | @item -mshort |
d77de738 ML |
26788 | Consider type @code{int} to be 16 bits wide, like @code{short int}. |
26789 | Additionally, parameters passed on the stack are also aligned to a | |
26790 | 16-bit boundary even on targets whose API mandates promotion to 32-bit. | |
26791 | ||
d77de738 | 26792 | @opindex mno-short |
ddf6fe37 | 26793 | @item -mno-short |
d77de738 ML |
26794 | Do not consider type @code{int} to be 16 bits wide. This is the default. |
26795 | ||
d77de738 ML |
26796 | @opindex mnobitfield |
26797 | @opindex mno-bitfield | |
ddf6fe37 AA |
26798 | @item -mnobitfield |
26799 | @itemx -mno-bitfield | |
d77de738 ML |
26800 | Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32} |
26801 | and @option{-m5200} options imply @w{@option{-mnobitfield}}. | |
26802 | ||
d77de738 | 26803 | @opindex mbitfield |
ddf6fe37 | 26804 | @item -mbitfield |
d77de738 ML |
26805 | Do use the bit-field instructions. The @option{-m68020} option implies |
26806 | @option{-mbitfield}. This is the default if you use a configuration | |
26807 | designed for a 68020. | |
26808 | ||
d77de738 | 26809 | @opindex mrtd |
ddf6fe37 | 26810 | @item -mrtd |
d77de738 ML |
26811 | Use a different function-calling convention, in which functions |
26812 | that take a fixed number of arguments return with the @code{rtd} | |
26813 | instruction, which pops their arguments while returning. This | |
26814 | saves one instruction in the caller since there is no need to pop | |
26815 | the arguments there. | |
26816 | ||
26817 | This calling convention is incompatible with the one normally | |
26818 | used on Unix, so you cannot use it if you need to call libraries | |
26819 | compiled with the Unix compiler. | |
26820 | ||
26821 | Also, you must provide function prototypes for all functions that | |
26822 | take variable numbers of arguments (including @code{printf}); | |
26823 | otherwise incorrect code is generated for calls to those | |
26824 | functions. | |
26825 | ||
26826 | In addition, seriously incorrect code results if you call a | |
26827 | function with too many arguments. (Normally, extra arguments are | |
26828 | harmlessly ignored.) | |
26829 | ||
26830 | The @code{rtd} instruction is supported by the 68010, 68020, 68030, | |
26831 | 68040, 68060 and CPU32 processors, but not by the 68000 or 5200. | |
26832 | ||
26833 | The default is @option{-mno-rtd}. | |
26834 | ||
d77de738 ML |
26835 | @opindex malign-int |
26836 | @opindex mno-align-int | |
ddf6fe37 AA |
26837 | @item -malign-int |
26838 | @itemx -mno-align-int | |
d77de738 ML |
26839 | Control whether GCC aligns @code{int}, @code{long}, @code{long long}, |
26840 | @code{float}, @code{double}, and @code{long double} variables on a 32-bit | |
26841 | boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}). | |
26842 | Aligning variables on 32-bit boundaries produces code that runs somewhat | |
26843 | faster on processors with 32-bit busses at the expense of more memory. | |
26844 | ||
26845 | @strong{Warning:} if you use the @option{-malign-int} switch, GCC | |
26846 | aligns structures containing the above types differently than | |
26847 | most published application binary interface specifications for the m68k. | |
26848 | ||
26849 | @opindex mpcrel | |
26850 | Use the pc-relative addressing mode of the 68000 directly, instead of | |
26851 | using a global offset table. At present, this option implies @option{-fpic}, | |
26852 | allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is | |
26853 | not presently supported with @option{-mpcrel}, though this could be supported for | |
26854 | 68020 and higher processors. | |
26855 | ||
d77de738 ML |
26856 | @opindex mno-strict-align |
26857 | @opindex mstrict-align | |
ddf6fe37 AA |
26858 | @item -mno-strict-align |
26859 | @itemx -mstrict-align | |
d77de738 ML |
26860 | Do not (do) assume that unaligned memory references are handled by |
26861 | the system. | |
26862 | ||
26863 | @item -msep-data | |
26864 | Generate code that allows the data segment to be located in a different | |
26865 | area of memory from the text segment. This allows for execute-in-place in | |
26866 | an environment without virtual memory management. This option implies | |
26867 | @option{-fPIC}. | |
26868 | ||
26869 | @item -mno-sep-data | |
26870 | Generate code that assumes that the data segment follows the text segment. | |
26871 | This is the default. | |
26872 | ||
26873 | @item -mid-shared-library | |
26874 | Generate code that supports shared libraries via the library ID method. | |
26875 | This allows for execute-in-place and shared libraries in an environment | |
26876 | without virtual memory management. This option implies @option{-fPIC}. | |
26877 | ||
26878 | @item -mno-id-shared-library | |
26879 | Generate code that doesn't assume ID-based shared libraries are being used. | |
26880 | This is the default. | |
26881 | ||
26882 | @item -mshared-library-id=n | |
26883 | Specifies the identification number of the ID-based shared library being | |
26884 | compiled. Specifying a value of 0 generates more compact code; specifying | |
26885 | other values forces the allocation of that number to the current | |
26886 | library, but is no more space- or time-efficient than omitting this option. | |
26887 | ||
d77de738 ML |
26888 | @opindex mxgot |
26889 | @opindex mno-xgot | |
ddf6fe37 AA |
26890 | @item -mxgot |
26891 | @itemx -mno-xgot | |
d77de738 ML |
26892 | When generating position-independent code for ColdFire, generate code |
26893 | that works if the GOT has more than 8192 entries. This code is | |
26894 | larger and slower than code generated without this option. On M680x0 | |
26895 | processors, this option is not needed; @option{-fPIC} suffices. | |
26896 | ||
26897 | GCC normally uses a single instruction to load values from the GOT@. | |
26898 | While this is relatively efficient, it only works if the GOT | |
26899 | is smaller than about 64k. Anything larger causes the linker | |
26900 | to report an error such as: | |
26901 | ||
26902 | @cindex relocation truncated to fit (ColdFire) | |
26903 | @smallexample | |
26904 | relocation truncated to fit: R_68K_GOT16O foobar | |
26905 | @end smallexample | |
26906 | ||
26907 | If this happens, you should recompile your code with @option{-mxgot}. | |
26908 | It should then work with very large GOTs. However, code generated with | |
26909 | @option{-mxgot} is less efficient, since it takes 4 instructions to fetch | |
26910 | the value of a global symbol. | |
26911 | ||
26912 | Note that some linkers, including newer versions of the GNU linker, | |
26913 | can create multiple GOTs and sort GOT entries. If you have such a linker, | |
26914 | you should only need to use @option{-mxgot} when compiling a single | |
26915 | object file that accesses more than 8192 GOT entries. Very few do. | |
26916 | ||
26917 | These options have no effect unless GCC is generating | |
26918 | position-independent code. | |
26919 | ||
d77de738 | 26920 | @opindex mlong-jump-table-offsets |
ddf6fe37 | 26921 | @item -mlong-jump-table-offsets |
d77de738 ML |
26922 | Use 32-bit offsets in @code{switch} tables. The default is to use |
26923 | 16-bit offsets. | |
26924 | ||
26925 | @end table | |
26926 | ||
26927 | @node MCore Options | |
26928 | @subsection MCore Options | |
26929 | @cindex MCore options | |
26930 | ||
26931 | These are the @samp{-m} options defined for the Motorola M*Core | |
26932 | processors. | |
26933 | ||
26934 | @table @gcctabopt | |
26935 | ||
d77de738 ML |
26936 | @opindex mhardlit |
26937 | @opindex mno-hardlit | |
ddf6fe37 AA |
26938 | @item -mhardlit |
26939 | @itemx -mno-hardlit | |
d77de738 ML |
26940 | Inline constants into the code stream if it can be done in two |
26941 | instructions or less. | |
26942 | ||
d77de738 ML |
26943 | @opindex mdiv |
26944 | @opindex mno-div | |
ddf6fe37 AA |
26945 | @item -mdiv |
26946 | @itemx -mno-div | |
d77de738 ML |
26947 | Use the divide instruction. (Enabled by default). |
26948 | ||
d77de738 ML |
26949 | @opindex mrelax-immediate |
26950 | @opindex mno-relax-immediate | |
ddf6fe37 AA |
26951 | @item -mrelax-immediate |
26952 | @itemx -mno-relax-immediate | |
d77de738 ML |
26953 | Allow arbitrary-sized immediates in bit operations. |
26954 | ||
d77de738 ML |
26955 | @opindex mwide-bitfields |
26956 | @opindex mno-wide-bitfields | |
ddf6fe37 AA |
26957 | @item -mwide-bitfields |
26958 | @itemx -mno-wide-bitfields | |
d77de738 ML |
26959 | Always treat bit-fields as @code{int}-sized. |
26960 | ||
d77de738 ML |
26961 | @opindex m4byte-functions |
26962 | @opindex mno-4byte-functions | |
ddf6fe37 AA |
26963 | @item -m4byte-functions |
26964 | @itemx -mno-4byte-functions | |
d77de738 ML |
26965 | Force all functions to be aligned to a 4-byte boundary. |
26966 | ||
d77de738 ML |
26967 | @opindex mcallgraph-data |
26968 | @opindex mno-callgraph-data | |
ddf6fe37 AA |
26969 | @item -mcallgraph-data |
26970 | @itemx -mno-callgraph-data | |
d77de738 ML |
26971 | Emit callgraph information. |
26972 | ||
d77de738 ML |
26973 | @opindex mslow-bytes |
26974 | @opindex mno-slow-bytes | |
ddf6fe37 AA |
26975 | @item -mslow-bytes |
26976 | @itemx -mno-slow-bytes | |
d77de738 ML |
26977 | Prefer word access when reading byte quantities. |
26978 | ||
d77de738 ML |
26979 | @opindex mlittle-endian |
26980 | @opindex mbig-endian | |
ddf6fe37 AA |
26981 | @item -mlittle-endian |
26982 | @itemx -mbig-endian | |
d77de738 ML |
26983 | Generate code for a little-endian target. |
26984 | ||
d77de738 ML |
26985 | @opindex m210 |
26986 | @opindex m340 | |
ddf6fe37 AA |
26987 | @item -m210 |
26988 | @itemx -m340 | |
d77de738 ML |
26989 | Generate code for the 210 processor. |
26990 | ||
d77de738 | 26991 | @opindex mno-lsim |
ddf6fe37 | 26992 | @item -mno-lsim |
d77de738 ML |
26993 | Assume that runtime support has been provided and so omit the |
26994 | simulator library (@file{libsim.a)} from the linker command line. | |
26995 | ||
d77de738 | 26996 | @opindex mstack-increment |
ddf6fe37 | 26997 | @item -mstack-increment=@var{size} |
d77de738 ML |
26998 | Set the maximum amount for a single stack increment operation. Large |
26999 | values can increase the speed of programs that contain functions | |
27000 | that need a large amount of stack space, but they can also trigger a | |
27001 | segmentation fault if the stack is extended too much. The default | |
27002 | value is 0x1000. | |
27003 | ||
27004 | @end table | |
27005 | ||
d77de738 ML |
27006 | @node MicroBlaze Options |
27007 | @subsection MicroBlaze Options | |
27008 | @cindex MicroBlaze Options | |
27009 | ||
27010 | @table @gcctabopt | |
27011 | ||
d77de738 | 27012 | @opindex msoft-float |
ddf6fe37 | 27013 | @item -msoft-float |
d77de738 ML |
27014 | Use software emulation for floating point (default). |
27015 | ||
d77de738 | 27016 | @opindex mhard-float |
ddf6fe37 | 27017 | @item -mhard-float |
d77de738 ML |
27018 | Use hardware floating-point instructions. |
27019 | ||
d77de738 | 27020 | @opindex mmemcpy |
ddf6fe37 | 27021 | @item -mmemcpy |
d77de738 ML |
27022 | Do not optimize block moves, use @code{memcpy}. |
27023 | ||
d77de738 | 27024 | @opindex mno-clearbss |
ddf6fe37 | 27025 | @item -mno-clearbss |
d77de738 ML |
27026 | This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead. |
27027 | ||
d77de738 | 27028 | @opindex mcpu= |
ddf6fe37 | 27029 | @item -mcpu=@var{cpu-type} |
d77de738 ML |
27030 | Use features of, and schedule code for, the given CPU. |
27031 | Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}}, | |
27032 | where @var{X} is a major version, @var{YY} is the minor version, and | |
27033 | @var{Z} is compatibility code. Example values are @samp{v3.00.a}, | |
27034 | @samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}. | |
27035 | ||
d77de738 | 27036 | @opindex mxl-soft-mul |
ddf6fe37 | 27037 | @item -mxl-soft-mul |
d77de738 ML |
27038 | Use software multiply emulation (default). |
27039 | ||
d77de738 | 27040 | @opindex mxl-soft-div |
ddf6fe37 | 27041 | @item -mxl-soft-div |
d77de738 ML |
27042 | Use software emulation for divides (default). |
27043 | ||
d77de738 | 27044 | @opindex mxl-barrel-shift |
ddf6fe37 | 27045 | @item -mxl-barrel-shift |
d77de738 ML |
27046 | Use the hardware barrel shifter. |
27047 | ||
d77de738 | 27048 | @opindex mxl-pattern-compare |
ddf6fe37 | 27049 | @item -mxl-pattern-compare |
d77de738 ML |
27050 | Use pattern compare instructions. |
27051 | ||
d77de738 | 27052 | @opindex msmall-divides |
ddf6fe37 | 27053 | @item -msmall-divides |
d77de738 ML |
27054 | Use table lookup optimization for small signed integer divisions. |
27055 | ||
d77de738 | 27056 | @opindex mxl-stack-check |
ddf6fe37 | 27057 | @item -mxl-stack-check |
d77de738 ML |
27058 | This option is deprecated. Use @option{-fstack-check} instead. |
27059 | ||
d77de738 | 27060 | @opindex mxl-gp-opt |
ddf6fe37 | 27061 | @item -mxl-gp-opt |
d77de738 ML |
27062 | Use GP-relative @code{.sdata}/@code{.sbss} sections. |
27063 | ||
d77de738 | 27064 | @opindex mxl-multiply-high |
ddf6fe37 | 27065 | @item -mxl-multiply-high |
d77de738 ML |
27066 | Use multiply high instructions for high part of 32x32 multiply. |
27067 | ||
d77de738 | 27068 | @opindex mxl-float-convert |
ddf6fe37 | 27069 | @item -mxl-float-convert |
d77de738 ML |
27070 | Use hardware floating-point conversion instructions. |
27071 | ||
d77de738 | 27072 | @opindex mxl-float-sqrt |
ddf6fe37 | 27073 | @item -mxl-float-sqrt |
d77de738 ML |
27074 | Use hardware floating-point square root instruction. |
27075 | ||
d77de738 | 27076 | @opindex mbig-endian |
ddf6fe37 | 27077 | @item -mbig-endian |
d77de738 ML |
27078 | Generate code for a big-endian target. |
27079 | ||
d77de738 | 27080 | @opindex mlittle-endian |
ddf6fe37 | 27081 | @item -mlittle-endian |
d77de738 ML |
27082 | Generate code for a little-endian target. |
27083 | ||
d77de738 | 27084 | @opindex mxl-reorder |
ddf6fe37 | 27085 | @item -mxl-reorder |
d77de738 ML |
27086 | Use reorder instructions (swap and byte reversed load/store). |
27087 | ||
27088 | @item -mxl-mode-@var{app-model} | |
27089 | Select application model @var{app-model}. Valid models are | |
27090 | @table @samp | |
27091 | @item executable | |
27092 | normal executable (default), uses startup code @file{crt0.o}. | |
27093 | ||
27094 | @item xmdstub | |
27095 | for use with Xilinx Microprocessor Debugger (XMD) based | |
27096 | software intrusive debug agent called xmdstub. This uses startup file | |
27097 | @file{crt1.o} and sets the start address of the program to 0x800. | |
27098 | ||
27099 | @item bootstrap | |
27100 | for applications that are loaded using a bootloader. | |
27101 | This model uses startup file @file{crt2.o} which does not contain a processor | |
27102 | reset vector handler. This is suitable for transferring control on a | |
27103 | processor reset to the bootloader rather than the application. | |
27104 | ||
27105 | @item novectors | |
27106 | for applications that do not require any of the | |
27107 | MicroBlaze vectors. This option may be useful for applications running | |
27108 | within a monitoring application. This model uses @file{crt3.o} as a startup file. | |
27109 | @end table | |
27110 | ||
27111 | Option @option{-xl-mode-@var{app-model}} is a deprecated alias for | |
27112 | @option{-mxl-mode-@var{app-model}}. | |
27113 | ||
d77de738 | 27114 | @opindex mpic-data-is-text-relative |
ddf6fe37 | 27115 | @item -mpic-data-is-text-relative |
d77de738 ML |
27116 | Assume that the displacement between the text and data segments is fixed |
27117 | at static link time. This allows data to be referenced by offset from start of | |
27118 | text address instead of GOT since PC-relative addressing is not supported. | |
27119 | ||
27120 | @end table | |
27121 | ||
27122 | @node MIPS Options | |
27123 | @subsection MIPS Options | |
27124 | @cindex MIPS options | |
27125 | ||
27126 | @table @gcctabopt | |
27127 | ||
d77de738 | 27128 | @opindex EB |
ddf6fe37 | 27129 | @item -EB |
d77de738 ML |
27130 | Generate big-endian code. |
27131 | ||
d77de738 | 27132 | @opindex EL |
ddf6fe37 | 27133 | @item -EL |
d77de738 ML |
27134 | Generate little-endian code. This is the default for @samp{mips*el-*-*} |
27135 | configurations. | |
27136 | ||
d77de738 | 27137 | @opindex march |
ddf6fe37 | 27138 | @item -march=@var{arch} |
d77de738 ML |
27139 | Generate code that runs on @var{arch}, which can be the name of a |
27140 | generic MIPS ISA, or the name of a particular processor. | |
27141 | The ISA names are: | |
27142 | @samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4}, | |
27143 | @samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5}, | |
27144 | @samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3}, | |
27145 | @samp{mips64r5} and @samp{mips64r6}. | |
27146 | The processor names are: | |
27147 | @samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc}, | |
27148 | @samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd}, | |
27149 | @samp{5kc}, @samp{5kf}, | |
27150 | @samp{20kc}, | |
27151 | @samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1}, | |
27152 | @samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1}, | |
27153 | @samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn}, | |
27154 | @samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2}, | |
27155 | @samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1}, | |
27156 | @samp{i6400}, @samp{i6500}, | |
27157 | @samp{interaptiv}, | |
27158 | @samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464}, | |
27159 | @samp{gs464e}, @samp{gs264e}, | |
27160 | @samp{m4k}, | |
27161 | @samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec}, | |
27162 | @samp{m5100}, @samp{m5101}, | |
27163 | @samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3}, | |
27164 | @samp{orion}, | |
27165 | @samp{p5600}, @samp{p6600}, | |
27166 | @samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400}, | |
27167 | @samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900}, | |
27168 | @samp{r6000}, @samp{r8000}, | |
27169 | @samp{rm7000}, @samp{rm9000}, | |
27170 | @samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000}, | |
27171 | @samp{sb1}, | |
27172 | @samp{sr71000}, | |
27173 | @samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300}, | |
27174 | @samp{vr5000}, @samp{vr5400}, @samp{vr5500}, | |
27175 | @samp{xlr} and @samp{xlp}. | |
27176 | The special value @samp{from-abi} selects the | |
27177 | most compatible architecture for the selected ABI (that is, | |
27178 | @samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@. | |
27179 | ||
27180 | The native Linux/GNU toolchain also supports the value @samp{native}, | |
27181 | which selects the best architecture option for the host processor. | |
27182 | @option{-march=native} has no effect if GCC does not recognize | |
27183 | the processor. | |
27184 | ||
27185 | In processor names, a final @samp{000} can be abbreviated as @samp{k} | |
27186 | (for example, @option{-march=r2k}). Prefixes are optional, and | |
27187 | @samp{vr} may be written @samp{r}. | |
27188 | ||
27189 | Names of the form @samp{@var{n}f2_1} refer to processors with | |
27190 | FPUs clocked at half the rate of the core, names of the form | |
27191 | @samp{@var{n}f1_1} refer to processors with FPUs clocked at the same | |
27192 | rate as the core, and names of the form @samp{@var{n}f3_2} refer to | |
27193 | processors with FPUs clocked a ratio of 3:2 with respect to the core. | |
27194 | For compatibility reasons, @samp{@var{n}f} is accepted as a synonym | |
27195 | for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are | |
27196 | accepted as synonyms for @samp{@var{n}f1_1}. | |
27197 | ||
27198 | GCC defines two macros based on the value of this option. The first | |
27199 | is @code{_MIPS_ARCH}, which gives the name of target architecture, as | |
27200 | a string. The second has the form @code{_MIPS_ARCH_@var{foo}}, | |
27201 | where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@. | |
27202 | For example, @option{-march=r2000} sets @code{_MIPS_ARCH} | |
27203 | to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}. | |
27204 | ||
27205 | Note that the @code{_MIPS_ARCH} macro uses the processor names given | |
27206 | above. In other words, it has the full prefix and does not | |
27207 | abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi}, | |
27208 | the macro names the resolved architecture (either @code{"mips1"} or | |
27209 | @code{"mips3"}). It names the default architecture when no | |
27210 | @option{-march} option is given. | |
27211 | ||
d77de738 | 27212 | @opindex mtune |
ddf6fe37 | 27213 | @item -mtune=@var{arch} |
d77de738 ML |
27214 | Optimize for @var{arch}. Among other things, this option controls |
27215 | the way instructions are scheduled, and the perceived cost of arithmetic | |
27216 | operations. The list of @var{arch} values is the same as for | |
27217 | @option{-march}. | |
27218 | ||
27219 | When this option is not used, GCC optimizes for the processor | |
27220 | specified by @option{-march}. By using @option{-march} and | |
27221 | @option{-mtune} together, it is possible to generate code that | |
27222 | runs on a family of processors, but optimize the code for one | |
27223 | particular member of that family. | |
27224 | ||
27225 | @option{-mtune} defines the macros @code{_MIPS_TUNE} and | |
27226 | @code{_MIPS_TUNE_@var{foo}}, which work in the same way as the | |
27227 | @option{-march} ones described above. | |
27228 | ||
d77de738 | 27229 | @opindex mips1 |
ddf6fe37 | 27230 | @item -mips1 |
d77de738 ML |
27231 | Equivalent to @option{-march=mips1}. |
27232 | ||
d77de738 | 27233 | @opindex mips2 |
ddf6fe37 | 27234 | @item -mips2 |
d77de738 ML |
27235 | Equivalent to @option{-march=mips2}. |
27236 | ||
d77de738 | 27237 | @opindex mips3 |
ddf6fe37 | 27238 | @item -mips3 |
d77de738 ML |
27239 | Equivalent to @option{-march=mips3}. |
27240 | ||
d77de738 | 27241 | @opindex mips4 |
ddf6fe37 | 27242 | @item -mips4 |
d77de738 ML |
27243 | Equivalent to @option{-march=mips4}. |
27244 | ||
d77de738 | 27245 | @opindex mips32 |
ddf6fe37 | 27246 | @item -mips32 |
d77de738 ML |
27247 | Equivalent to @option{-march=mips32}. |
27248 | ||
d77de738 | 27249 | @opindex mips32r3 |
ddf6fe37 | 27250 | @item -mips32r3 |
d77de738 ML |
27251 | Equivalent to @option{-march=mips32r3}. |
27252 | ||
d77de738 | 27253 | @opindex mips32r5 |
ddf6fe37 | 27254 | @item -mips32r5 |
d77de738 ML |
27255 | Equivalent to @option{-march=mips32r5}. |
27256 | ||
d77de738 | 27257 | @opindex mips32r6 |
ddf6fe37 | 27258 | @item -mips32r6 |
d77de738 ML |
27259 | Equivalent to @option{-march=mips32r6}. |
27260 | ||
d77de738 | 27261 | @opindex mips64 |
ddf6fe37 | 27262 | @item -mips64 |
d77de738 ML |
27263 | Equivalent to @option{-march=mips64}. |
27264 | ||
d77de738 | 27265 | @opindex mips64r2 |
ddf6fe37 | 27266 | @item -mips64r2 |
d77de738 ML |
27267 | Equivalent to @option{-march=mips64r2}. |
27268 | ||
d77de738 | 27269 | @opindex mips64r3 |
ddf6fe37 | 27270 | @item -mips64r3 |
d77de738 ML |
27271 | Equivalent to @option{-march=mips64r3}. |
27272 | ||
d77de738 | 27273 | @opindex mips64r5 |
ddf6fe37 | 27274 | @item -mips64r5 |
d77de738 ML |
27275 | Equivalent to @option{-march=mips64r5}. |
27276 | ||
d77de738 | 27277 | @opindex mips64r6 |
ddf6fe37 | 27278 | @item -mips64r6 |
d77de738 ML |
27279 | Equivalent to @option{-march=mips64r6}. |
27280 | ||
d77de738 ML |
27281 | @opindex mips16 |
27282 | @opindex mno-mips16 | |
ddf6fe37 AA |
27283 | @item -mips16 |
27284 | @itemx -mno-mips16 | |
d77de738 ML |
27285 | Generate (do not generate) MIPS16 code. If GCC is targeting a |
27286 | MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@. | |
27287 | ||
27288 | MIPS16 code generation can also be controlled on a per-function basis | |
27289 | by means of @code{mips16} and @code{nomips16} attributes. | |
27290 | @xref{Function Attributes}, for more information. | |
27291 | ||
926f2d09 JM |
27292 | @opindex mmips16e2 |
27293 | @opindex mno-mips16e2 | |
27294 | @item -mmips16e2 | |
27295 | @itemx -mno-mips16e2 | |
27296 | Use (do not use) the MIPS16e2 ASE. This option modifies the behavior | |
27297 | of the @option{-mips16} option such that it targets the MIPS16e2 ASE@. | |
27298 | ||
d77de738 | 27299 | @opindex mflip-mips16 |
ddf6fe37 | 27300 | @item -mflip-mips16 |
d77de738 ML |
27301 | Generate MIPS16 code on alternating functions. This option is provided |
27302 | for regression testing of mixed MIPS16/non-MIPS16 code generation, and is | |
27303 | not intended for ordinary use in compiling user code. | |
27304 | ||
d77de738 ML |
27305 | @opindex minterlink-compressed |
27306 | @opindex mno-interlink-compressed | |
ddf6fe37 AA |
27307 | @item -minterlink-compressed |
27308 | @itemx -mno-interlink-compressed | |
d77de738 ML |
27309 | Require (do not require) that code using the standard (uncompressed) MIPS ISA |
27310 | be link-compatible with MIPS16 and microMIPS code, and vice versa. | |
27311 | ||
27312 | For example, code using the standard ISA encoding cannot jump directly | |
27313 | to MIPS16 or microMIPS code; it must either use a call or an indirect jump. | |
27314 | @option{-minterlink-compressed} therefore disables direct jumps unless GCC | |
27315 | knows that the target of the jump is not compressed. | |
27316 | ||
d77de738 ML |
27317 | @opindex minterlink-mips16 |
27318 | @opindex mno-interlink-mips16 | |
ddf6fe37 AA |
27319 | @item -minterlink-mips16 |
27320 | @itemx -mno-interlink-mips16 | |
d77de738 ML |
27321 | Aliases of @option{-minterlink-compressed} and |
27322 | @option{-mno-interlink-compressed}. These options predate the microMIPS ASE | |
27323 | and are retained for backwards compatibility. | |
27324 | ||
d77de738 ML |
27325 | @opindex mabi=32 |
27326 | @opindex mabi=o64 | |
27327 | @opindex mabi=n32 | |
27328 | @opindex mabi=64 | |
27329 | @opindex mabi=eabi | |
ddf6fe37 AA |
27330 | @item -mabi=32 |
27331 | @itemx -mabi=o64 | |
27332 | @itemx -mabi=n32 | |
27333 | @itemx -mabi=64 | |
27334 | @itemx -mabi=eabi | |
d77de738 ML |
27335 | Generate code for the given ABI@. |
27336 | ||
27337 | Note that the EABI has a 32-bit and a 64-bit variant. GCC normally | |
27338 | generates 64-bit code when you select a 64-bit architecture, but you | |
27339 | can use @option{-mgp32} to get 32-bit code instead. | |
27340 | ||
27341 | For information about the O64 ABI, see | |
27342 | @uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}. | |
27343 | ||
27344 | GCC supports a variant of the o32 ABI in which floating-point registers | |
27345 | are 64 rather than 32 bits wide. You can select this combination with | |
27346 | @option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1} | |
27347 | and @code{mfhc1} instructions and is therefore only supported for | |
27348 | MIPS32R2, MIPS32R3 and MIPS32R5 processors. | |
27349 | ||
27350 | The register assignments for arguments and return values remain the | |
27351 | same, but each scalar value is passed in a single 64-bit register | |
27352 | rather than a pair of 32-bit registers. For example, scalar | |
27353 | floating-point values are returned in @samp{$f0} only, not a | |
27354 | @samp{$f0}/@samp{$f1} pair. The set of call-saved registers also | |
27355 | remains the same in that the even-numbered double-precision registers | |
27356 | are saved. | |
27357 | ||
27358 | Two additional variants of the o32 ABI are supported to enable | |
27359 | a transition from 32-bit to 64-bit registers. These are FPXX | |
27360 | (@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}). | |
27361 | The FPXX extension mandates that all code must execute correctly | |
27362 | when run using 32-bit or 64-bit registers. The code can be interlinked | |
27363 | with either FP32 or FP64, but not both. | |
27364 | The FP64A extension is similar to the FP64 extension but forbids the | |
27365 | use of odd-numbered single-precision registers. This can be used | |
27366 | in conjunction with the @code{FRE} mode of FPUs in MIPS32R5 | |
27367 | processors and allows both FP32 and FP64A code to interlink and | |
27368 | run in the same process without changing FPU modes. | |
27369 | ||
d77de738 ML |
27370 | @opindex mabicalls |
27371 | @opindex mno-abicalls | |
ddf6fe37 AA |
27372 | @item -mabicalls |
27373 | @itemx -mno-abicalls | |
d77de738 ML |
27374 | Generate (do not generate) code that is suitable for SVR4-style |
27375 | dynamic objects. @option{-mabicalls} is the default for SVR4-based | |
27376 | systems. | |
27377 | ||
27378 | @item -mshared | |
27379 | @itemx -mno-shared | |
27380 | Generate (do not generate) code that is fully position-independent, | |
27381 | and that can therefore be linked into shared libraries. This option | |
27382 | only affects @option{-mabicalls}. | |
27383 | ||
27384 | All @option{-mabicalls} code has traditionally been position-independent, | |
27385 | regardless of options like @option{-fPIC} and @option{-fpic}. However, | |
27386 | as an extension, the GNU toolchain allows executables to use absolute | |
27387 | accesses for locally-binding symbols. It can also use shorter GP | |
27388 | initialization sequences and generate direct calls to locally-defined | |
27389 | functions. This mode is selected by @option{-mno-shared}. | |
27390 | ||
27391 | @option{-mno-shared} depends on binutils 2.16 or higher and generates | |
27392 | objects that can only be linked by the GNU linker. However, the option | |
27393 | does not affect the ABI of the final executable; it only affects the ABI | |
27394 | of relocatable objects. Using @option{-mno-shared} generally makes | |
27395 | executables both smaller and quicker. | |
27396 | ||
27397 | @option{-mshared} is the default. | |
27398 | ||
d77de738 ML |
27399 | @opindex mplt |
27400 | @opindex mno-plt | |
ddf6fe37 AA |
27401 | @item -mplt |
27402 | @itemx -mno-plt | |
d77de738 ML |
27403 | Assume (do not assume) that the static and dynamic linkers |
27404 | support PLTs and copy relocations. This option only affects | |
27405 | @option{-mno-shared -mabicalls}. For the n64 ABI, this option | |
27406 | has no effect without @option{-msym32}. | |
27407 | ||
27408 | You can make @option{-mplt} the default by configuring | |
27409 | GCC with @option{--with-mips-plt}. The default is | |
27410 | @option{-mno-plt} otherwise. | |
27411 | ||
d77de738 ML |
27412 | @opindex mxgot |
27413 | @opindex mno-xgot | |
ddf6fe37 AA |
27414 | @item -mxgot |
27415 | @itemx -mno-xgot | |
d77de738 ML |
27416 | Lift (do not lift) the usual restrictions on the size of the global |
27417 | offset table. | |
27418 | ||
27419 | GCC normally uses a single instruction to load values from the GOT@. | |
27420 | While this is relatively efficient, it only works if the GOT | |
27421 | is smaller than about 64k. Anything larger causes the linker | |
27422 | to report an error such as: | |
27423 | ||
27424 | @cindex relocation truncated to fit (MIPS) | |
27425 | @smallexample | |
27426 | relocation truncated to fit: R_MIPS_GOT16 foobar | |
27427 | @end smallexample | |
27428 | ||
27429 | If this happens, you should recompile your code with @option{-mxgot}. | |
27430 | This works with very large GOTs, although the code is also | |
27431 | less efficient, since it takes three instructions to fetch the | |
27432 | value of a global symbol. | |
27433 | ||
27434 | Note that some linkers can create multiple GOTs. If you have such a | |
27435 | linker, you should only need to use @option{-mxgot} when a single object | |
27436 | file accesses more than 64k's worth of GOT entries. Very few do. | |
27437 | ||
27438 | These options have no effect unless GCC is generating position | |
27439 | independent code. | |
27440 | ||
d77de738 | 27441 | @opindex mgp32 |
ddf6fe37 | 27442 | @item -mgp32 |
d77de738 ML |
27443 | Assume that general-purpose registers are 32 bits wide. |
27444 | ||
d77de738 | 27445 | @opindex mgp64 |
ddf6fe37 | 27446 | @item -mgp64 |
d77de738 ML |
27447 | Assume that general-purpose registers are 64 bits wide. |
27448 | ||
d77de738 | 27449 | @opindex mfp32 |
ddf6fe37 | 27450 | @item -mfp32 |
d77de738 ML |
27451 | Assume that floating-point registers are 32 bits wide. |
27452 | ||
d77de738 | 27453 | @opindex mfp64 |
ddf6fe37 | 27454 | @item -mfp64 |
d77de738 ML |
27455 | Assume that floating-point registers are 64 bits wide. |
27456 | ||
d77de738 | 27457 | @opindex mfpxx |
ddf6fe37 | 27458 | @item -mfpxx |
d77de738 ML |
27459 | Do not assume the width of floating-point registers. |
27460 | ||
d77de738 | 27461 | @opindex mhard-float |
ddf6fe37 | 27462 | @item -mhard-float |
d77de738 ML |
27463 | Use floating-point coprocessor instructions. |
27464 | ||
d77de738 | 27465 | @opindex msoft-float |
ddf6fe37 | 27466 | @item -msoft-float |
d77de738 ML |
27467 | Do not use floating-point coprocessor instructions. Implement |
27468 | floating-point calculations using library calls instead. | |
27469 | ||
d77de738 | 27470 | @opindex mno-float |
ddf6fe37 | 27471 | @item -mno-float |
d77de738 ML |
27472 | Equivalent to @option{-msoft-float}, but additionally asserts that the |
27473 | program being compiled does not perform any floating-point operations. | |
27474 | This option is presently supported only by some bare-metal MIPS | |
27475 | configurations, where it may select a special set of libraries | |
27476 | that lack all floating-point support (including, for example, the | |
27477 | floating-point @code{printf} formats). | |
27478 | If code compiled with @option{-mno-float} accidentally contains | |
27479 | floating-point operations, it is likely to suffer a link-time | |
27480 | or run-time failure. | |
27481 | ||
d77de738 | 27482 | @opindex msingle-float |
ddf6fe37 | 27483 | @item -msingle-float |
d77de738 ML |
27484 | Assume that the floating-point coprocessor only supports single-precision |
27485 | operations. | |
27486 | ||
d77de738 | 27487 | @opindex mdouble-float |
ddf6fe37 | 27488 | @item -mdouble-float |
d77de738 ML |
27489 | Assume that the floating-point coprocessor supports double-precision |
27490 | operations. This is the default. | |
27491 | ||
d77de738 ML |
27492 | @opindex modd-spreg |
27493 | @opindex mno-odd-spreg | |
ddf6fe37 AA |
27494 | @item -modd-spreg |
27495 | @itemx -mno-odd-spreg | |
d77de738 ML |
27496 | Enable the use of odd-numbered single-precision floating-point registers |
27497 | for the o32 ABI. This is the default for processors that are known to | |
27498 | support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg} | |
27499 | is set by default. | |
27500 | ||
d77de738 ML |
27501 | @opindex mabs=2008 |
27502 | @opindex mabs=legacy | |
ddf6fe37 AA |
27503 | @item -mabs=2008 |
27504 | @itemx -mabs=legacy | |
d77de738 ML |
27505 | These options control the treatment of the special not-a-number (NaN) |
27506 | IEEE 754 floating-point data with the @code{abs.@i{fmt}} and | |
27507 | @code{neg.@i{fmt}} machine instructions. | |
27508 | ||
27509 | By default or when @option{-mabs=legacy} is used the legacy | |
27510 | treatment is selected. In this case these instructions are considered | |
27511 | arithmetic and avoided where correct operation is required and the | |
27512 | input operand might be a NaN. A longer sequence of instructions that | |
27513 | manipulate the sign bit of floating-point datum manually is used | |
27514 | instead unless the @option{-ffinite-math-only} option has also been | |
27515 | specified. | |
27516 | ||
27517 | The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In | |
27518 | this case these instructions are considered non-arithmetic and therefore | |
27519 | operating correctly in all cases, including in particular where the | |
27520 | input operand is a NaN. These instructions are therefore always used | |
27521 | for the respective operations. | |
27522 | ||
d77de738 ML |
27523 | @opindex mnan=2008 |
27524 | @opindex mnan=legacy | |
ddf6fe37 AA |
27525 | @item -mnan=2008 |
27526 | @itemx -mnan=legacy | |
d77de738 ML |
27527 | These options control the encoding of the special not-a-number (NaN) |
27528 | IEEE 754 floating-point data. | |
27529 | ||
27530 | The @option{-mnan=legacy} option selects the legacy encoding. In this | |
27531 | case quiet NaNs (qNaNs) are denoted by the first bit of their trailing | |
27532 | significand field being 0, whereas signaling NaNs (sNaNs) are denoted | |
27533 | by the first bit of their trailing significand field being 1. | |
27534 | ||
27535 | The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In | |
27536 | this case qNaNs are denoted by the first bit of their trailing | |
27537 | significand field being 1, whereas sNaNs are denoted by the first bit of | |
27538 | their trailing significand field being 0. | |
27539 | ||
27540 | The default is @option{-mnan=legacy} unless GCC has been configured with | |
27541 | @option{--with-nan=2008}. | |
27542 | ||
d77de738 ML |
27543 | @opindex mllsc |
27544 | @opindex mno-llsc | |
ddf6fe37 AA |
27545 | @item -mllsc |
27546 | @itemx -mno-llsc | |
d77de738 ML |
27547 | Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to |
27548 | implement atomic memory built-in functions. When neither option is | |
27549 | specified, GCC uses the instructions if the target architecture | |
27550 | supports them. | |
27551 | ||
27552 | @option{-mllsc} is useful if the runtime environment can emulate the | |
27553 | instructions and @option{-mno-llsc} can be useful when compiling for | |
27554 | nonstandard ISAs. You can make either option the default by | |
27555 | configuring GCC with @option{--with-llsc} and @option{--without-llsc} | |
27556 | respectively. @option{--with-llsc} is the default for some | |
27557 | configurations; see the installation documentation for details. | |
27558 | ||
d77de738 ML |
27559 | @opindex mdsp |
27560 | @opindex mno-dsp | |
ddf6fe37 AA |
27561 | @item -mdsp |
27562 | @itemx -mno-dsp | |
d77de738 ML |
27563 | Use (do not use) revision 1 of the MIPS DSP ASE@. |
27564 | @xref{MIPS DSP Built-in Functions}. This option defines the | |
27565 | preprocessor macro @code{__mips_dsp}. It also defines | |
27566 | @code{__mips_dsp_rev} to 1. | |
27567 | ||
d77de738 ML |
27568 | @opindex mdspr2 |
27569 | @opindex mno-dspr2 | |
ddf6fe37 AA |
27570 | @item -mdspr2 |
27571 | @itemx -mno-dspr2 | |
d77de738 ML |
27572 | Use (do not use) revision 2 of the MIPS DSP ASE@. |
27573 | @xref{MIPS DSP Built-in Functions}. This option defines the | |
27574 | preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}. | |
27575 | It also defines @code{__mips_dsp_rev} to 2. | |
27576 | ||
d77de738 ML |
27577 | @opindex msmartmips |
27578 | @opindex mno-smartmips | |
ddf6fe37 AA |
27579 | @item -msmartmips |
27580 | @itemx -mno-smartmips | |
d77de738 ML |
27581 | Use (do not use) the MIPS SmartMIPS ASE. |
27582 | ||
d77de738 ML |
27583 | @opindex mpaired-single |
27584 | @opindex mno-paired-single | |
ddf6fe37 AA |
27585 | @item -mpaired-single |
27586 | @itemx -mno-paired-single | |
d77de738 ML |
27587 | Use (do not use) paired-single floating-point instructions. |
27588 | @xref{MIPS Paired-Single Support}. This option requires | |
27589 | hardware floating-point support to be enabled. | |
27590 | ||
d77de738 ML |
27591 | @opindex mdmx |
27592 | @opindex mno-mdmx | |
ddf6fe37 AA |
27593 | @item -mdmx |
27594 | @itemx -mno-mdmx | |
d77de738 ML |
27595 | Use (do not use) MIPS Digital Media Extension instructions. |
27596 | This option can only be used when generating 64-bit code and requires | |
27597 | hardware floating-point support to be enabled. | |
27598 | ||
d77de738 ML |
27599 | @opindex mips3d |
27600 | @opindex mno-mips3d | |
ddf6fe37 AA |
27601 | @item -mips3d |
27602 | @itemx -mno-mips3d | |
d77de738 ML |
27603 | Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}. |
27604 | The option @option{-mips3d} implies @option{-mpaired-single}. | |
27605 | ||
d77de738 ML |
27606 | @opindex mmicromips |
27607 | @opindex mno-mmicromips | |
ddf6fe37 AA |
27608 | @item -mmicromips |
27609 | @itemx -mno-micromips | |
d77de738 ML |
27610 | Generate (do not generate) microMIPS code. |
27611 | ||
27612 | MicroMIPS code generation can also be controlled on a per-function basis | |
27613 | by means of @code{micromips} and @code{nomicromips} attributes. | |
27614 | @xref{Function Attributes}, for more information. | |
27615 | ||
d77de738 ML |
27616 | @opindex mmt |
27617 | @opindex mno-mt | |
ddf6fe37 AA |
27618 | @item -mmt |
27619 | @itemx -mno-mt | |
d77de738 ML |
27620 | Use (do not use) MT Multithreading instructions. |
27621 | ||
d77de738 ML |
27622 | @opindex mmcu |
27623 | @opindex mno-mcu | |
ddf6fe37 AA |
27624 | @item -mmcu |
27625 | @itemx -mno-mcu | |
d77de738 ML |
27626 | Use (do not use) the MIPS MCU ASE instructions. |
27627 | ||
d77de738 ML |
27628 | @opindex meva |
27629 | @opindex mno-eva | |
ddf6fe37 AA |
27630 | @item -meva |
27631 | @itemx -mno-eva | |
d77de738 ML |
27632 | Use (do not use) the MIPS Enhanced Virtual Addressing instructions. |
27633 | ||
d77de738 ML |
27634 | @opindex mvirt |
27635 | @opindex mno-virt | |
ddf6fe37 AA |
27636 | @item -mvirt |
27637 | @itemx -mno-virt | |
d77de738 ML |
27638 | Use (do not use) the MIPS Virtualization (VZ) instructions. |
27639 | ||
d77de738 ML |
27640 | @opindex mxpa |
27641 | @opindex mno-xpa | |
ddf6fe37 AA |
27642 | @item -mxpa |
27643 | @itemx -mno-xpa | |
d77de738 ML |
27644 | Use (do not use) the MIPS eXtended Physical Address (XPA) instructions. |
27645 | ||
d77de738 ML |
27646 | @opindex mcrc |
27647 | @opindex mno-crc | |
ddf6fe37 AA |
27648 | @item -mcrc |
27649 | @itemx -mno-crc | |
d77de738 ML |
27650 | Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions. |
27651 | ||
d77de738 ML |
27652 | @opindex mginv |
27653 | @opindex mno-ginv | |
ddf6fe37 AA |
27654 | @item -mginv |
27655 | @itemx -mno-ginv | |
d77de738 ML |
27656 | Use (do not use) the MIPS Global INValidate (GINV) instructions. |
27657 | ||
d77de738 ML |
27658 | @opindex mloongson-mmi |
27659 | @opindex mno-loongson-mmi | |
ddf6fe37 AA |
27660 | @item -mloongson-mmi |
27661 | @itemx -mno-loongson-mmi | |
d77de738 ML |
27662 | Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI). |
27663 | ||
d77de738 ML |
27664 | @opindex mloongson-ext |
27665 | @opindex mno-loongson-ext | |
ddf6fe37 AA |
27666 | @item -mloongson-ext |
27667 | @itemx -mno-loongson-ext | |
d77de738 ML |
27668 | Use (do not use) the MIPS Loongson EXTensions (EXT) instructions. |
27669 | ||
d77de738 ML |
27670 | @opindex mloongson-ext2 |
27671 | @opindex mno-loongson-ext2 | |
ddf6fe37 AA |
27672 | @item -mloongson-ext2 |
27673 | @itemx -mno-loongson-ext2 | |
d77de738 ML |
27674 | Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions. |
27675 | ||
d77de738 | 27676 | @opindex mlong64 |
ddf6fe37 | 27677 | @item -mlong64 |
d77de738 ML |
27678 | Force @code{long} types to be 64 bits wide. See @option{-mlong32} for |
27679 | an explanation of the default and the way that the pointer size is | |
27680 | determined. | |
27681 | ||
d77de738 | 27682 | @opindex mlong32 |
ddf6fe37 | 27683 | @item -mlong32 |
d77de738 ML |
27684 | Force @code{long}, @code{int}, and pointer types to be 32 bits wide. |
27685 | ||
27686 | The default size of @code{int}s, @code{long}s and pointers depends on | |
27687 | the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI | |
27688 | uses 64-bit @code{long}s, as does the 64-bit EABI; the others use | |
27689 | 32-bit @code{long}s. Pointers are the same size as @code{long}s, | |
27690 | or the same size as integer registers, whichever is smaller. | |
27691 | ||
d77de738 ML |
27692 | @opindex msym32 |
27693 | @opindex mno-sym32 | |
ddf6fe37 AA |
27694 | @item -msym32 |
27695 | @itemx -mno-sym32 | |
d77de738 ML |
27696 | Assume (do not assume) that all symbols have 32-bit values, regardless |
27697 | of the selected ABI@. This option is useful in combination with | |
27698 | @option{-mabi=64} and @option{-mno-abicalls} because it allows GCC | |
27699 | to generate shorter and faster references to symbolic addresses. | |
27700 | ||
d77de738 | 27701 | @opindex G |
ddf6fe37 | 27702 | @item -G @var{num} |
d77de738 ML |
27703 | Put definitions of externally-visible data in a small data section |
27704 | if that data is no bigger than @var{num} bytes. GCC can then generate | |
27705 | more efficient accesses to the data; see @option{-mgpopt} for details. | |
27706 | ||
27707 | The default @option{-G} option depends on the configuration. | |
27708 | ||
d77de738 ML |
27709 | @opindex mlocal-sdata |
27710 | @opindex mno-local-sdata | |
ddf6fe37 AA |
27711 | @item -mlocal-sdata |
27712 | @itemx -mno-local-sdata | |
d77de738 ML |
27713 | Extend (do not extend) the @option{-G} behavior to local data too, |
27714 | such as to static variables in C@. @option{-mlocal-sdata} is the | |
27715 | default for all configurations. | |
27716 | ||
27717 | If the linker complains that an application is using too much small data, | |
27718 | you might want to try rebuilding the less performance-critical parts with | |
27719 | @option{-mno-local-sdata}. You might also want to build large | |
27720 | libraries with @option{-mno-local-sdata}, so that the libraries leave | |
27721 | more room for the main program. | |
27722 | ||
d77de738 ML |
27723 | @opindex mextern-sdata |
27724 | @opindex mno-extern-sdata | |
ddf6fe37 AA |
27725 | @item -mextern-sdata |
27726 | @itemx -mno-extern-sdata | |
d77de738 ML |
27727 | Assume (do not assume) that externally-defined data is in |
27728 | a small data section if the size of that data is within the @option{-G} limit. | |
27729 | @option{-mextern-sdata} is the default for all configurations. | |
27730 | ||
27731 | If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G | |
27732 | @var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var} | |
27733 | that is no bigger than @var{num} bytes, you must make sure that @var{Var} | |
27734 | is placed in a small data section. If @var{Var} is defined by another | |
27735 | module, you must either compile that module with a high-enough | |
27736 | @option{-G} setting or attach a @code{section} attribute to @var{Var}'s | |
27737 | definition. If @var{Var} is common, you must link the application | |
27738 | with a high-enough @option{-G} setting. | |
27739 | ||
27740 | The easiest way of satisfying these restrictions is to compile | |
27741 | and link every module with the same @option{-G} option. However, | |
27742 | you may wish to build a library that supports several different | |
27743 | small data limits. You can do this by compiling the library with | |
27744 | the highest supported @option{-G} setting and additionally using | |
27745 | @option{-mno-extern-sdata} to stop the library from making assumptions | |
27746 | about externally-defined data. | |
27747 | ||
d77de738 ML |
27748 | @opindex mgpopt |
27749 | @opindex mno-gpopt | |
ddf6fe37 AA |
27750 | @item -mgpopt |
27751 | @itemx -mno-gpopt | |
d77de738 ML |
27752 | Use (do not use) GP-relative accesses for symbols that are known to be |
27753 | in a small data section; see @option{-G}, @option{-mlocal-sdata} and | |
27754 | @option{-mextern-sdata}. @option{-mgpopt} is the default for all | |
27755 | configurations. | |
27756 | ||
27757 | @option{-mno-gpopt} is useful for cases where the @code{$gp} register | |
27758 | might not hold the value of @code{_gp}. For example, if the code is | |
27759 | part of a library that might be used in a boot monitor, programs that | |
27760 | call boot monitor routines pass an unknown value in @code{$gp}. | |
27761 | (In such situations, the boot monitor itself is usually compiled | |
27762 | with @option{-G0}.) | |
27763 | ||
27764 | @option{-mno-gpopt} implies @option{-mno-local-sdata} and | |
27765 | @option{-mno-extern-sdata}. | |
27766 | ||
d77de738 ML |
27767 | @opindex membedded-data |
27768 | @opindex mno-embedded-data | |
ddf6fe37 AA |
27769 | @item -membedded-data |
27770 | @itemx -mno-embedded-data | |
d77de738 ML |
27771 | Allocate variables to the read-only data section first if possible, then |
27772 | next in the small data section if possible, otherwise in data. This gives | |
27773 | slightly slower code than the default, but reduces the amount of RAM required | |
27774 | when executing, and thus may be preferred for some embedded systems. | |
27775 | ||
d77de738 ML |
27776 | @opindex muninit-const-in-rodata |
27777 | @opindex mno-uninit-const-in-rodata | |
ddf6fe37 AA |
27778 | @item -muninit-const-in-rodata |
27779 | @itemx -mno-uninit-const-in-rodata | |
d77de738 ML |
27780 | Put uninitialized @code{const} variables in the read-only data section. |
27781 | This option is only meaningful in conjunction with @option{-membedded-data}. | |
27782 | ||
d77de738 | 27783 | @opindex mcode-readable |
ddf6fe37 | 27784 | @item -mcode-readable=@var{setting} |
d77de738 ML |
27785 | Specify whether GCC may generate code that reads from executable sections. |
27786 | There are three possible settings: | |
27787 | ||
27788 | @table @gcctabopt | |
27789 | @item -mcode-readable=yes | |
27790 | Instructions may freely access executable sections. This is the | |
27791 | default setting. | |
27792 | ||
27793 | @item -mcode-readable=pcrel | |
27794 | MIPS16 PC-relative load instructions can access executable sections, | |
27795 | but other instructions must not do so. This option is useful on 4KSc | |
27796 | and 4KSd processors when the code TLBs have the Read Inhibit bit set. | |
27797 | It is also useful on processors that can be configured to have a dual | |
27798 | instruction/data SRAM interface and that, like the M4K, automatically | |
27799 | redirect PC-relative loads to the instruction RAM. | |
27800 | ||
27801 | @item -mcode-readable=no | |
27802 | Instructions must not access executable sections. This option can be | |
27803 | useful on targets that are configured to have a dual instruction/data | |
27804 | SRAM interface but that (unlike the M4K) do not automatically redirect | |
27805 | PC-relative loads to the instruction RAM. | |
27806 | @end table | |
27807 | ||
d77de738 ML |
27808 | @opindex msplit-addresses |
27809 | @opindex mno-split-addresses | |
ddf6fe37 AA |
27810 | @item -msplit-addresses |
27811 | @itemx -mno-split-addresses | |
d77de738 ML |
27812 | Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler |
27813 | relocation operators. This option has been superseded by | |
27814 | @option{-mexplicit-relocs} but is retained for backwards compatibility. | |
27815 | ||
d77de738 ML |
27816 | @opindex mexplicit-relocs |
27817 | @opindex mno-explicit-relocs | |
ddf6fe37 AA |
27818 | @item -mexplicit-relocs |
27819 | @itemx -mno-explicit-relocs | |
d77de738 ML |
27820 | Use (do not use) assembler relocation operators when dealing with symbolic |
27821 | addresses. The alternative, selected by @option{-mno-explicit-relocs}, | |
27822 | is to use assembler macros instead. | |
27823 | ||
27824 | @option{-mexplicit-relocs} is the default if GCC was configured | |
27825 | to use an assembler that supports relocation operators. | |
27826 | ||
d77de738 ML |
27827 | @opindex mcheck-zero-division |
27828 | @opindex mno-check-zero-division | |
ddf6fe37 AA |
27829 | @item -mcheck-zero-division |
27830 | @itemx -mno-check-zero-division | |
d77de738 ML |
27831 | Trap (do not trap) on integer division by zero. |
27832 | ||
27833 | The default is @option{-mcheck-zero-division}. | |
27834 | ||
d77de738 ML |
27835 | @opindex mdivide-traps |
27836 | @opindex mdivide-breaks | |
ddf6fe37 AA |
27837 | @item -mdivide-traps |
27838 | @itemx -mdivide-breaks | |
d77de738 ML |
27839 | MIPS systems check for division by zero by generating either a |
27840 | conditional trap or a break instruction. Using traps results in | |
27841 | smaller code, but is only supported on MIPS II and later. Also, some | |
27842 | versions of the Linux kernel have a bug that prevents trap from | |
27843 | generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to | |
27844 | allow conditional traps on architectures that support them and | |
27845 | @option{-mdivide-breaks} to force the use of breaks. | |
27846 | ||
27847 | The default is usually @option{-mdivide-traps}, but this can be | |
27848 | overridden at configure time using @option{--with-divide=breaks}. | |
27849 | Divide-by-zero checks can be completely disabled using | |
27850 | @option{-mno-check-zero-division}. | |
27851 | ||
d77de738 ML |
27852 | @opindex mload-store-pairs |
27853 | @opindex mno-load-store-pairs | |
ddf6fe37 AA |
27854 | @item -mload-store-pairs |
27855 | @itemx -mno-load-store-pairs | |
d77de738 ML |
27856 | Enable (disable) an optimization that pairs consecutive load or store |
27857 | instructions to enable load/store bonding. This option is enabled by | |
27858 | default but only takes effect when the selected architecture is known | |
27859 | to support bonding. | |
27860 | ||
d77de738 ML |
27861 | @opindex munaligned-access |
27862 | @opindex mno-unaligned-access | |
ddf6fe37 AA |
27863 | @item -munaligned-access |
27864 | @itemx -mno-unaligned-access | |
d77de738 ML |
27865 | Enable (disable) direct unaligned access for MIPS Release 6. |
27866 | MIPSr6 requires load/store unaligned-access support, | |
27867 | by hardware or trap&emulate. | |
27868 | So @option{-mno-unaligned-access} may be needed by kernel. | |
27869 | ||
d77de738 ML |
27870 | @opindex mmemcpy |
27871 | @opindex mno-memcpy | |
ddf6fe37 AA |
27872 | @item -mmemcpy |
27873 | @itemx -mno-memcpy | |
d77de738 ML |
27874 | Force (do not force) the use of @code{memcpy} for non-trivial block |
27875 | moves. The default is @option{-mno-memcpy}, which allows GCC to inline | |
27876 | most constant-sized copies. | |
27877 | ||
d77de738 ML |
27878 | @opindex mlong-calls |
27879 | @opindex mno-long-calls | |
ddf6fe37 AA |
27880 | @item -mlong-calls |
27881 | @itemx -mno-long-calls | |
d77de738 ML |
27882 | Disable (do not disable) use of the @code{jal} instruction. Calling |
27883 | functions using @code{jal} is more efficient but requires the caller | |
27884 | and callee to be in the same 256 megabyte segment. | |
27885 | ||
27886 | This option has no effect on abicalls code. The default is | |
27887 | @option{-mno-long-calls}. | |
27888 | ||
d77de738 ML |
27889 | @opindex mmad |
27890 | @opindex mno-mad | |
ddf6fe37 AA |
27891 | @item -mmad |
27892 | @itemx -mno-mad | |
d77de738 ML |
27893 | Enable (disable) use of the @code{mad}, @code{madu} and @code{mul} |
27894 | instructions, as provided by the R4650 ISA@. | |
27895 | ||
d77de738 ML |
27896 | @opindex mimadd |
27897 | @opindex mno-imadd | |
ddf6fe37 AA |
27898 | @item -mimadd |
27899 | @itemx -mno-imadd | |
d77de738 ML |
27900 | Enable (disable) use of the @code{madd} and @code{msub} integer |
27901 | instructions. The default is @option{-mimadd} on architectures | |
27902 | that support @code{madd} and @code{msub} except for the 74k | |
27903 | architecture where it was found to generate slower code. | |
27904 | ||
d77de738 ML |
27905 | @opindex mfused-madd |
27906 | @opindex mno-fused-madd | |
ddf6fe37 AA |
27907 | @item -mfused-madd |
27908 | @itemx -mno-fused-madd | |
d77de738 ML |
27909 | Enable (disable) use of the floating-point multiply-accumulate |
27910 | instructions, when they are available. The default is | |
27911 | @option{-mfused-madd}. | |
27912 | ||
27913 | On the R8000 CPU when multiply-accumulate instructions are used, | |
27914 | the intermediate product is calculated to infinite precision | |
27915 | and is not subject to the FCSR Flush to Zero bit. This may be | |
27916 | undesirable in some circumstances. On other processors the result | |
27917 | is numerically identical to the equivalent computation using | |
27918 | separate multiply, add, subtract and negate instructions. | |
27919 | ||
d77de738 | 27920 | @opindex nocpp |
ddf6fe37 | 27921 | @item -nocpp |
d77de738 ML |
27922 | Tell the MIPS assembler to not run its preprocessor over user |
27923 | assembler files (with a @samp{.s} suffix) when assembling them. | |
27924 | ||
d77de738 ML |
27925 | @opindex mfix-24k |
27926 | @opindex mno-fix-24k | |
ddf6fe37 AA |
27927 | @item -mfix-24k |
27928 | @itemx -mno-fix-24k | |
d77de738 ML |
27929 | Work around the 24K E48 (lost data on stores during refill) errata. |
27930 | The workarounds are implemented by the assembler rather than by GCC@. | |
27931 | ||
d77de738 ML |
27932 | @opindex mfix-r4000 |
27933 | @opindex mno-fix-r4000 | |
ddf6fe37 AA |
27934 | @item -mfix-r4000 |
27935 | @itemx -mno-fix-r4000 | |
d77de738 ML |
27936 | Work around certain R4000 CPU errata: |
27937 | @itemize @minus | |
27938 | @item | |
27939 | A double-word or a variable shift may give an incorrect result if executed | |
27940 | immediately after starting an integer division. | |
27941 | @item | |
27942 | A double-word or a variable shift may give an incorrect result if executed | |
27943 | while an integer multiplication is in progress. | |
27944 | @item | |
27945 | An integer division may give an incorrect result if started in a delay slot | |
27946 | of a taken branch or a jump. | |
27947 | @end itemize | |
27948 | ||
d77de738 ML |
27949 | @opindex mfix-r4400 |
27950 | @opindex mno-fix-r4400 | |
ddf6fe37 AA |
27951 | @item -mfix-r4400 |
27952 | @itemx -mno-fix-r4400 | |
d77de738 ML |
27953 | Work around certain R4400 CPU errata: |
27954 | @itemize @minus | |
27955 | @item | |
27956 | A double-word or a variable shift may give an incorrect result if executed | |
27957 | immediately after starting an integer division. | |
27958 | @end itemize | |
27959 | ||
d77de738 ML |
27960 | @opindex mfix-r10000 |
27961 | @opindex mno-fix-r10000 | |
ddf6fe37 AA |
27962 | @item -mfix-r10000 |
27963 | @itemx -mno-fix-r10000 | |
d77de738 ML |
27964 | Work around certain R10000 errata: |
27965 | @itemize @minus | |
27966 | @item | |
27967 | @code{ll}/@code{sc} sequences may not behave atomically on revisions | |
27968 | prior to 3.0. They may deadlock on revisions 2.6 and earlier. | |
27969 | @end itemize | |
27970 | ||
27971 | This option can only be used if the target architecture supports | |
27972 | branch-likely instructions. @option{-mfix-r10000} is the default when | |
27973 | @option{-march=r10000} is used; @option{-mno-fix-r10000} is the default | |
27974 | otherwise. | |
27975 | ||
ddf6fe37 | 27976 | @opindex mfix-r5900 |
d77de738 ML |
27977 | @item -mfix-r5900 |
27978 | @itemx -mno-fix-r5900 | |
d77de738 ML |
27979 | Do not attempt to schedule the preceding instruction into the delay slot |
27980 | of a branch instruction placed at the end of a short loop of six | |
27981 | instructions or fewer and always schedule a @code{nop} instruction there | |
27982 | instead. The short loop bug under certain conditions causes loops to | |
27983 | execute only once or twice, due to a hardware bug in the R5900 chip. The | |
27984 | workaround is implemented by the assembler rather than by GCC@. | |
27985 | ||
ddf6fe37 | 27986 | @opindex mfix-rm7000 |
d77de738 ML |
27987 | @item -mfix-rm7000 |
27988 | @itemx -mno-fix-rm7000 | |
d77de738 ML |
27989 | Work around the RM7000 @code{dmult}/@code{dmultu} errata. The |
27990 | workarounds are implemented by the assembler rather than by GCC@. | |
27991 | ||
ddf6fe37 | 27992 | @opindex mfix-vr4120 |
d77de738 ML |
27993 | @item -mfix-vr4120 |
27994 | @itemx -mno-fix-vr4120 | |
d77de738 ML |
27995 | Work around certain VR4120 errata: |
27996 | @itemize @minus | |
27997 | @item | |
27998 | @code{dmultu} does not always produce the correct result. | |
27999 | @item | |
28000 | @code{div} and @code{ddiv} do not always produce the correct result if one | |
28001 | of the operands is negative. | |
28002 | @end itemize | |
28003 | The workarounds for the division errata rely on special functions in | |
28004 | @file{libgcc.a}. At present, these functions are only provided by | |
28005 | the @code{mips64vr*-elf} configurations. | |
28006 | ||
28007 | Other VR4120 errata require a NOP to be inserted between certain pairs of | |
28008 | instructions. These errata are handled by the assembler, not by GCC itself. | |
28009 | ||
d77de738 | 28010 | @opindex mfix-vr4130 |
ddf6fe37 | 28011 | @item -mfix-vr4130 |
d77de738 ML |
28012 | Work around the VR4130 @code{mflo}/@code{mfhi} errata. The |
28013 | workarounds are implemented by the assembler rather than by GCC, | |
28014 | although GCC avoids using @code{mflo} and @code{mfhi} if the | |
28015 | VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi} | |
28016 | instructions are available instead. | |
28017 | ||
ddf6fe37 | 28018 | @opindex mfix-sb1 |
d77de738 ML |
28019 | @item -mfix-sb1 |
28020 | @itemx -mno-fix-sb1 | |
d77de738 ML |
28021 | Work around certain SB-1 CPU core errata. |
28022 | (This flag currently works around the SB-1 revision 2 | |
28023 | ``F1'' and ``F2'' floating-point errata.) | |
28024 | ||
d77de738 | 28025 | @opindex mr10k-cache-barrier |
ddf6fe37 | 28026 | @item -mr10k-cache-barrier=@var{setting} |
d77de738 ML |
28027 | Specify whether GCC should insert cache barriers to avoid the |
28028 | side effects of speculation on R10K processors. | |
28029 | ||
28030 | In common with many processors, the R10K tries to predict the outcome | |
28031 | of a conditional branch and speculatively executes instructions from | |
28032 | the ``taken'' branch. It later aborts these instructions if the | |
28033 | predicted outcome is wrong. However, on the R10K, even aborted | |
28034 | instructions can have side effects. | |
28035 | ||
28036 | This problem only affects kernel stores and, depending on the system, | |
28037 | kernel loads. As an example, a speculatively-executed store may load | |
28038 | the target memory into cache and mark the cache line as dirty, even if | |
28039 | the store itself is later aborted. If a DMA operation writes to the | |
28040 | same area of memory before the ``dirty'' line is flushed, the cached | |
28041 | data overwrites the DMA-ed data. See the R10K processor manual | |
28042 | for a full description, including other potential problems. | |
28043 | ||
28044 | One workaround is to insert cache barrier instructions before every memory | |
28045 | access that might be speculatively executed and that might have side | |
28046 | effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}} | |
28047 | controls GCC's implementation of this workaround. It assumes that | |
28048 | aborted accesses to any byte in the following regions does not have | |
28049 | side effects: | |
28050 | ||
28051 | @enumerate | |
28052 | @item | |
28053 | the memory occupied by the current function's stack frame; | |
28054 | ||
28055 | @item | |
28056 | the memory occupied by an incoming stack argument; | |
28057 | ||
28058 | @item | |
28059 | the memory occupied by an object with a link-time-constant address. | |
28060 | @end enumerate | |
28061 | ||
28062 | It is the kernel's responsibility to ensure that speculative | |
28063 | accesses to these regions are indeed safe. | |
28064 | ||
28065 | If the input program contains a function declaration such as: | |
28066 | ||
28067 | @smallexample | |
28068 | void foo (void); | |
28069 | @end smallexample | |
28070 | ||
28071 | then the implementation of @code{foo} must allow @code{j foo} and | |
28072 | @code{jal foo} to be executed speculatively. GCC honors this | |
28073 | restriction for functions it compiles itself. It expects non-GCC | |
28074 | functions (such as hand-written assembly code) to do the same. | |
28075 | ||
28076 | The option has three forms: | |
28077 | ||
28078 | @table @gcctabopt | |
28079 | @item -mr10k-cache-barrier=load-store | |
28080 | Insert a cache barrier before a load or store that might be | |
28081 | speculatively executed and that might have side effects even | |
28082 | if aborted. | |
28083 | ||
28084 | @item -mr10k-cache-barrier=store | |
28085 | Insert a cache barrier before a store that might be speculatively | |
28086 | executed and that might have side effects even if aborted. | |
28087 | ||
28088 | @item -mr10k-cache-barrier=none | |
28089 | Disable the insertion of cache barriers. This is the default setting. | |
28090 | @end table | |
28091 | ||
ddf6fe37 | 28092 | @opindex mflush-func |
d77de738 ML |
28093 | @item -mflush-func=@var{func} |
28094 | @itemx -mno-flush-func | |
d77de738 ML |
28095 | Specifies the function to call to flush the I and D caches, or to not |
28096 | call any such function. If called, the function must take the same | |
28097 | arguments as the common @code{_flush_func}, that is, the address of the | |
28098 | memory range for which the cache is being flushed, the size of the | |
28099 | memory range, and the number 3 (to flush both caches). The default | |
28100 | depends on the target GCC was configured for, but commonly is either | |
28101 | @code{_flush_func} or @code{__cpu_flush}. | |
28102 | ||
d77de738 | 28103 | @opindex mbranch-cost |
ddf6fe37 | 28104 | @item mbranch-cost=@var{num} |
d77de738 ML |
28105 | Set the cost of branches to roughly @var{num} ``simple'' instructions. |
28106 | This cost is only a heuristic and is not guaranteed to produce | |
28107 | consistent results across releases. A zero cost redundantly selects | |
28108 | the default, which is based on the @option{-mtune} setting. | |
28109 | ||
d77de738 ML |
28110 | @opindex mbranch-likely |
28111 | @opindex mno-branch-likely | |
ddf6fe37 AA |
28112 | @item -mbranch-likely |
28113 | @itemx -mno-branch-likely | |
d77de738 ML |
28114 | Enable or disable use of Branch Likely instructions, regardless of the |
28115 | default for the selected architecture. By default, Branch Likely | |
28116 | instructions may be generated if they are supported by the selected | |
28117 | architecture. An exception is for the MIPS32 and MIPS64 architectures | |
28118 | and processors that implement those architectures; for those, Branch | |
28119 | Likely instructions are not be generated by default because the MIPS32 | |
28120 | and MIPS64 architectures specifically deprecate their use. | |
28121 | ||
d77de738 ML |
28122 | @opindex mcompact-branches=never |
28123 | @opindex mcompact-branches=optimal | |
28124 | @opindex mcompact-branches=always | |
ddf6fe37 AA |
28125 | @item -mcompact-branches=never |
28126 | @itemx -mcompact-branches=optimal | |
28127 | @itemx -mcompact-branches=always | |
d77de738 ML |
28128 | These options control which form of branches will be generated. The |
28129 | default is @option{-mcompact-branches=optimal}. | |
28130 | ||
28131 | The @option{-mcompact-branches=never} option ensures that compact branch | |
28132 | instructions will never be generated. | |
28133 | ||
28134 | The @option{-mcompact-branches=always} option ensures that a compact | |
28135 | branch instruction will be generated if available for MIPS Release 6 onwards. | |
28136 | If a compact branch instruction is not available (or pre-R6), | |
28137 | a delay slot form of the branch will be used instead. | |
28138 | ||
28139 | If it is used for MIPS16/microMIPS targets, it will be just ignored now. | |
28140 | The behaviour for MIPS16/microMIPS may change in future, | |
28141 | since they do have some compact branch instructions. | |
28142 | ||
28143 | The @option{-mcompact-branches=optimal} option will cause a delay slot | |
28144 | branch to be used if one is available in the current ISA and the delay | |
28145 | slot is successfully filled. If the delay slot is not filled, a compact | |
28146 | branch will be chosen if one is available. | |
28147 | ||
ddf6fe37 | 28148 | @opindex mfp-exceptions |
d77de738 ML |
28149 | @item -mfp-exceptions |
28150 | @itemx -mno-fp-exceptions | |
d77de738 ML |
28151 | Specifies whether FP exceptions are enabled. This affects how |
28152 | FP instructions are scheduled for some processors. | |
28153 | The default is that FP exceptions are | |
28154 | enabled. | |
28155 | ||
28156 | For instance, on the SB-1, if FP exceptions are disabled, and we are emitting | |
28157 | 64-bit code, then we can use both FP pipes. Otherwise, we can only use one | |
28158 | FP pipe. | |
28159 | ||
ddf6fe37 | 28160 | @opindex mvr4130-align |
d77de738 ML |
28161 | @item -mvr4130-align |
28162 | @itemx -mno-vr4130-align | |
d77de738 ML |
28163 | The VR4130 pipeline is two-way superscalar, but can only issue two |
28164 | instructions together if the first one is 8-byte aligned. When this | |
28165 | option is enabled, GCC aligns pairs of instructions that it | |
28166 | thinks should execute in parallel. | |
28167 | ||
28168 | This option only has an effect when optimizing for the VR4130. | |
28169 | It normally makes code faster, but at the expense of making it bigger. | |
28170 | It is enabled by default at optimization level @option{-O3}. | |
28171 | ||
ddf6fe37 | 28172 | @opindex msynci |
d77de738 ML |
28173 | @item -msynci |
28174 | @itemx -mno-synci | |
d77de738 ML |
28175 | Enable (disable) generation of @code{synci} instructions on |
28176 | architectures that support it. The @code{synci} instructions (if | |
28177 | enabled) are generated when @code{__builtin___clear_cache} is | |
28178 | compiled. | |
28179 | ||
28180 | This option defaults to @option{-mno-synci}, but the default can be | |
28181 | overridden by configuring GCC with @option{--with-synci}. | |
28182 | ||
28183 | When compiling code for single processor systems, it is generally safe | |
28184 | to use @code{synci}. However, on many multi-core (SMP) systems, it | |
28185 | does not invalidate the instruction caches on all cores and may lead | |
28186 | to undefined behavior. | |
28187 | ||
ddf6fe37 | 28188 | @opindex mrelax-pic-calls |
d77de738 ML |
28189 | @item -mrelax-pic-calls |
28190 | @itemx -mno-relax-pic-calls | |
d77de738 ML |
28191 | Try to turn PIC calls that are normally dispatched via register |
28192 | @code{$25} into direct calls. This is only possible if the linker can | |
28193 | resolve the destination at link time and if the destination is within | |
28194 | range for a direct call. | |
28195 | ||
28196 | @option{-mrelax-pic-calls} is the default if GCC was configured to use | |
28197 | an assembler and a linker that support the @code{.reloc} assembly | |
28198 | directive and @option{-mexplicit-relocs} is in effect. With | |
28199 | @option{-mno-explicit-relocs}, this optimization can be performed by the | |
28200 | assembler and the linker alone without help from the compiler. | |
28201 | ||
d77de738 ML |
28202 | @opindex mmcount-ra-address |
28203 | @opindex mno-mcount-ra-address | |
ddf6fe37 AA |
28204 | @item -mmcount-ra-address |
28205 | @itemx -mno-mcount-ra-address | |
d77de738 ML |
28206 | Emit (do not emit) code that allows @code{_mcount} to modify the |
28207 | calling function's return address. When enabled, this option extends | |
28208 | the usual @code{_mcount} interface with a new @var{ra-address} | |
28209 | parameter, which has type @code{intptr_t *} and is passed in register | |
28210 | @code{$12}. @code{_mcount} can then modify the return address by | |
28211 | doing both of the following: | |
28212 | @itemize | |
28213 | @item | |
28214 | Returning the new address in register @code{$31}. | |
28215 | @item | |
28216 | Storing the new address in @code{*@var{ra-address}}, | |
28217 | if @var{ra-address} is nonnull. | |
28218 | @end itemize | |
28219 | ||
28220 | The default is @option{-mno-mcount-ra-address}. | |
28221 | ||
ddf6fe37 | 28222 | @opindex mframe-header-opt |
d77de738 ML |
28223 | @item -mframe-header-opt |
28224 | @itemx -mno-frame-header-opt | |
d77de738 ML |
28225 | Enable (disable) frame header optimization in the o32 ABI. When using the |
28226 | o32 ABI, calling functions will allocate 16 bytes on the stack for the called | |
28227 | function to write out register arguments. When enabled, this optimization | |
28228 | will suppress the allocation of the frame header if it can be determined that | |
28229 | it is unused. | |
28230 | ||
28231 | This optimization is off by default at all optimization levels. | |
28232 | ||
ddf6fe37 | 28233 | @opindex mlxc1-sxc1 |
d77de738 ML |
28234 | @item -mlxc1-sxc1 |
28235 | @itemx -mno-lxc1-sxc1 | |
d77de738 ML |
28236 | When applicable, enable (disable) the generation of @code{lwxc1}, |
28237 | @code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default. | |
28238 | ||
ddf6fe37 | 28239 | @opindex mmadd4 |
d77de738 ML |
28240 | @item -mmadd4 |
28241 | @itemx -mno-madd4 | |
d77de738 ML |
28242 | When applicable, enable (disable) the generation of 4-operand @code{madd.s}, |
28243 | @code{madd.d} and related instructions. Enabled by default. | |
28244 | ||
28245 | @end table | |
28246 | ||
28247 | @node MMIX Options | |
28248 | @subsection MMIX Options | |
28249 | @cindex MMIX Options | |
28250 | ||
28251 | These options are defined for the MMIX: | |
28252 | ||
28253 | @table @gcctabopt | |
d77de738 ML |
28254 | @opindex mlibfuncs |
28255 | @opindex mno-libfuncs | |
ddf6fe37 AA |
28256 | @item -mlibfuncs |
28257 | @itemx -mno-libfuncs | |
d77de738 ML |
28258 | Specify that intrinsic library functions are being compiled, passing all |
28259 | values in registers, no matter the size. | |
28260 | ||
d77de738 ML |
28261 | @opindex mepsilon |
28262 | @opindex mno-epsilon | |
ddf6fe37 AA |
28263 | @item -mepsilon |
28264 | @itemx -mno-epsilon | |
d77de738 ML |
28265 | Generate floating-point comparison instructions that compare with respect |
28266 | to the @code{rE} epsilon register. | |
28267 | ||
d77de738 ML |
28268 | @opindex mabi=mmixware |
28269 | @opindex mabi=gnu | |
ddf6fe37 AA |
28270 | @item -mabi=mmixware |
28271 | @itemx -mabi=gnu | |
d77de738 ML |
28272 | Generate code that passes function parameters and return values that (in |
28273 | the called function) are seen as registers @code{$0} and up, as opposed to | |
28274 | the GNU ABI which uses global registers @code{$231} and up. | |
28275 | ||
d77de738 ML |
28276 | @opindex mzero-extend |
28277 | @opindex mno-zero-extend | |
ddf6fe37 AA |
28278 | @item -mzero-extend |
28279 | @itemx -mno-zero-extend | |
d77de738 ML |
28280 | When reading data from memory in sizes shorter than 64 bits, use (do not |
28281 | use) zero-extending load instructions by default, rather than | |
28282 | sign-extending ones. | |
28283 | ||
d77de738 ML |
28284 | @opindex mknuthdiv |
28285 | @opindex mno-knuthdiv | |
ddf6fe37 AA |
28286 | @item -mknuthdiv |
28287 | @itemx -mno-knuthdiv | |
d77de738 ML |
28288 | Make the result of a division yielding a remainder have the same sign as |
28289 | the divisor. With the default, @option{-mno-knuthdiv}, the sign of the | |
28290 | remainder follows the sign of the dividend. Both methods are | |
28291 | arithmetically valid, the latter being almost exclusively used. | |
28292 | ||
d77de738 ML |
28293 | @opindex mtoplevel-symbols |
28294 | @opindex mno-toplevel-symbols | |
ddf6fe37 AA |
28295 | @item -mtoplevel-symbols |
28296 | @itemx -mno-toplevel-symbols | |
d77de738 ML |
28297 | Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly |
28298 | code can be used with the @code{PREFIX} assembly directive. | |
28299 | ||
d77de738 | 28300 | @opindex melf |
ddf6fe37 | 28301 | @item -melf |
d77de738 ML |
28302 | Generate an executable in the ELF format, rather than the default |
28303 | @samp{mmo} format used by the @command{mmix} simulator. | |
28304 | ||
d77de738 ML |
28305 | @opindex mbranch-predict |
28306 | @opindex mno-branch-predict | |
ddf6fe37 AA |
28307 | @item -mbranch-predict |
28308 | @itemx -mno-branch-predict | |
d77de738 ML |
28309 | Use (do not use) the probable-branch instructions, when static branch |
28310 | prediction indicates a probable branch. | |
28311 | ||
d77de738 ML |
28312 | @opindex mbase-addresses |
28313 | @opindex mno-base-addresses | |
ddf6fe37 AA |
28314 | @item -mbase-addresses |
28315 | @itemx -mno-base-addresses | |
d77de738 ML |
28316 | Generate (do not generate) code that uses @emph{base addresses}. Using a |
28317 | base address automatically generates a request (handled by the assembler | |
28318 | and the linker) for a constant to be set up in a global register. The | |
28319 | register is used for one or more base address requests within the range 0 | |
28320 | to 255 from the value held in the register. The generally leads to short | |
28321 | and fast code, but the number of different data items that can be | |
28322 | addressed is limited. This means that a program that uses lots of static | |
28323 | data may require @option{-mno-base-addresses}. | |
28324 | ||
d77de738 ML |
28325 | @opindex msingle-exit |
28326 | @opindex mno-single-exit | |
ddf6fe37 AA |
28327 | @item -msingle-exit |
28328 | @itemx -mno-single-exit | |
d77de738 ML |
28329 | Force (do not force) generated code to have a single exit point in each |
28330 | function. | |
28331 | @end table | |
28332 | ||
28333 | @node MN10300 Options | |
28334 | @subsection MN10300 Options | |
28335 | @cindex MN10300 options | |
28336 | ||
28337 | These @option{-m} options are defined for Matsushita MN10300 architectures: | |
28338 | ||
28339 | @table @gcctabopt | |
d77de738 | 28340 | @opindex mmult-bug |
ddf6fe37 | 28341 | @item -mmult-bug |
d77de738 ML |
28342 | Generate code to avoid bugs in the multiply instructions for the MN10300 |
28343 | processors. This is the default. | |
28344 | ||
d77de738 | 28345 | @opindex mno-mult-bug |
ddf6fe37 | 28346 | @item -mno-mult-bug |
d77de738 ML |
28347 | Do not generate code to avoid bugs in the multiply instructions for the |
28348 | MN10300 processors. | |
28349 | ||
d77de738 | 28350 | @opindex mam33 |
ddf6fe37 | 28351 | @item -mam33 |
d77de738 ML |
28352 | Generate code using features specific to the AM33 processor. |
28353 | ||
d77de738 | 28354 | @opindex mno-am33 |
ddf6fe37 | 28355 | @item -mno-am33 |
d77de738 ML |
28356 | Do not generate code using features specific to the AM33 processor. This |
28357 | is the default. | |
28358 | ||
d77de738 | 28359 | @opindex mam33-2 |
ddf6fe37 | 28360 | @item -mam33-2 |
d77de738 ML |
28361 | Generate code using features specific to the AM33/2.0 processor. |
28362 | ||
d77de738 | 28363 | @opindex mam34 |
ddf6fe37 | 28364 | @item -mam34 |
d77de738 ML |
28365 | Generate code using features specific to the AM34 processor. |
28366 | ||
d77de738 | 28367 | @opindex mtune |
ddf6fe37 | 28368 | @item -mtune=@var{cpu-type} |
d77de738 ML |
28369 | Use the timing characteristics of the indicated CPU type when |
28370 | scheduling instructions. This does not change the targeted processor | |
28371 | type. The CPU type must be one of @samp{mn10300}, @samp{am33}, | |
28372 | @samp{am33-2} or @samp{am34}. | |
28373 | ||
d77de738 | 28374 | @opindex mreturn-pointer-on-d0 |
ddf6fe37 | 28375 | @item -mreturn-pointer-on-d0 |
d77de738 ML |
28376 | When generating a function that returns a pointer, return the pointer |
28377 | in both @code{a0} and @code{d0}. Otherwise, the pointer is returned | |
28378 | only in @code{a0}, and attempts to call such functions without a prototype | |
28379 | result in errors. Note that this option is on by default; use | |
28380 | @option{-mno-return-pointer-on-d0} to disable it. | |
28381 | ||
d77de738 | 28382 | @opindex mno-crt0 |
ddf6fe37 | 28383 | @item -mno-crt0 |
d77de738 ML |
28384 | Do not link in the C run-time initialization object file. |
28385 | ||
d77de738 | 28386 | @opindex mrelax |
ddf6fe37 | 28387 | @item -mrelax |
d77de738 ML |
28388 | Indicate to the linker that it should perform a relaxation optimization pass |
28389 | to shorten branches, calls and absolute memory addresses. This option only | |
28390 | has an effect when used on the command line for the final link step. | |
28391 | ||
28392 | This option makes symbolic debugging impossible. | |
28393 | ||
d77de738 | 28394 | @opindex mliw |
ddf6fe37 | 28395 | @item -mliw |
d77de738 ML |
28396 | Allow the compiler to generate @emph{Long Instruction Word} |
28397 | instructions if the target is the @samp{AM33} or later. This is the | |
28398 | default. This option defines the preprocessor macro @code{__LIW__}. | |
28399 | ||
d77de738 | 28400 | @opindex mno-liw |
ddf6fe37 | 28401 | @item -mno-liw |
d77de738 ML |
28402 | Do not allow the compiler to generate @emph{Long Instruction Word} |
28403 | instructions. This option defines the preprocessor macro | |
28404 | @code{__NO_LIW__}. | |
28405 | ||
d77de738 | 28406 | @opindex msetlb |
ddf6fe37 | 28407 | @item -msetlb |
d77de738 ML |
28408 | Allow the compiler to generate the @emph{SETLB} and @emph{Lcc} |
28409 | instructions if the target is the @samp{AM33} or later. This is the | |
28410 | default. This option defines the preprocessor macro @code{__SETLB__}. | |
28411 | ||
d77de738 | 28412 | @opindex mno-setlb |
ddf6fe37 | 28413 | @item -mno-setlb |
d77de738 ML |
28414 | Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc} |
28415 | instructions. This option defines the preprocessor macro | |
28416 | @code{__NO_SETLB__}. | |
28417 | ||
28418 | @end table | |
28419 | ||
28420 | @node Moxie Options | |
28421 | @subsection Moxie Options | |
28422 | @cindex Moxie Options | |
28423 | ||
28424 | @table @gcctabopt | |
28425 | ||
d77de738 | 28426 | @opindex meb |
ddf6fe37 | 28427 | @item -meb |
d77de738 ML |
28428 | Generate big-endian code. This is the default for @samp{moxie-*-*} |
28429 | configurations. | |
28430 | ||
d77de738 | 28431 | @opindex mel |
ddf6fe37 | 28432 | @item -mel |
d77de738 ML |
28433 | Generate little-endian code. |
28434 | ||
d77de738 | 28435 | @opindex mmul.x |
ddf6fe37 | 28436 | @item -mmul.x |
d77de738 ML |
28437 | Generate mul.x and umul.x instructions. This is the default for |
28438 | @samp{moxiebox-*-*} configurations. | |
28439 | ||
d77de738 | 28440 | @opindex mno-crt0 |
ddf6fe37 | 28441 | @item -mno-crt0 |
d77de738 ML |
28442 | Do not link in the C run-time initialization object file. |
28443 | ||
28444 | @end table | |
28445 | ||
28446 | @node MSP430 Options | |
28447 | @subsection MSP430 Options | |
28448 | @cindex MSP430 Options | |
28449 | ||
28450 | These options are defined for the MSP430: | |
28451 | ||
28452 | @table @gcctabopt | |
28453 | ||
d77de738 | 28454 | @opindex masm-hex |
ddf6fe37 | 28455 | @item -masm-hex |
d77de738 ML |
28456 | Force assembly output to always use hex constants. Normally such |
28457 | constants are signed decimals, but this option is available for | |
28458 | testsuite and/or aesthetic purposes. | |
28459 | ||
d77de738 | 28460 | @opindex mmcu= |
ddf6fe37 | 28461 | @item -mmcu= |
d77de738 ML |
28462 | Select the MCU to target. This is used to create a C preprocessor |
28463 | symbol based upon the MCU name, converted to upper case and pre- and | |
28464 | post-fixed with @samp{__}. This in turn is used by the | |
28465 | @file{msp430.h} header file to select an MCU-specific supplementary | |
28466 | header file. | |
28467 | ||
28468 | The option also sets the ISA to use. If the MCU name is one that is | |
28469 | known to only support the 430 ISA then that is selected, otherwise the | |
28470 | 430X ISA is selected. A generic MCU name of @samp{msp430} can also be | |
28471 | used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU | |
28472 | name selects the 430X ISA. | |
28473 | ||
28474 | In addition an MCU-specific linker script is added to the linker | |
28475 | command line. The script's name is the name of the MCU with | |
28476 | @file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc} | |
28477 | command line defines the C preprocessor symbol @code{__XXX__} and | |
28478 | cause the linker to search for a script called @file{xxx.ld}. | |
28479 | ||
28480 | The ISA and hardware multiply supported for the different MCUs is hard-coded | |
28481 | into GCC. However, an external @samp{devices.csv} file can be used to | |
28482 | extend device support beyond those that have been hard-coded. | |
28483 | ||
28484 | GCC searches for the @samp{devices.csv} file using the following methods in the | |
28485 | given precedence order, where the first method takes precendence over the | |
28486 | second which takes precedence over the third. | |
28487 | ||
28488 | @table @asis | |
28489 | @item Include path specified with @code{-I} and @code{-L} | |
28490 | @samp{devices.csv} will be searched for in each of the directories specified by | |
28491 | include paths and linker library search paths. | |
28492 | @item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR} | |
28493 | Define the value of the global environment variable | |
28494 | @samp{MSP430_GCC_INCLUDE_DIR} | |
28495 | to the full path to the directory containing devices.csv, and GCC will search | |
28496 | this directory for devices.csv. If devices.csv is found, this directory will | |
28497 | also be registered as an include path, and linker library path. Header files | |
28498 | and linker scripts in this directory can therefore be used without manually | |
28499 | specifying @code{-I} and @code{-L} on the command line. | |
28500 | @item The @samp{msp430-elf@{,bare@}/include/devices} directory | |
28501 | Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the | |
28502 | toolchain root directory. This directory does not exist in a default | |
28503 | installation, but if the user has created it and copied @samp{devices.csv} | |
28504 | there, then the MCU data will be read. As above, this directory will | |
28505 | also be registered as an include path, and linker library path. | |
28506 | ||
28507 | @end table | |
28508 | If none of the above search methods find @samp{devices.csv}, then the | |
28509 | hard-coded MCU data is used. | |
28510 | ||
28511 | ||
d77de738 ML |
28512 | @opindex mwarn-mcu |
28513 | @opindex mno-warn-mcu | |
ddf6fe37 AA |
28514 | @item -mwarn-mcu |
28515 | @itemx -mno-warn-mcu | |
d77de738 ML |
28516 | This option enables or disables warnings about conflicts between the |
28517 | MCU name specified by the @option{-mmcu} option and the ISA set by the | |
28518 | @option{-mcpu} option and/or the hardware multiply support set by the | |
28519 | @option{-mhwmult} option. It also toggles warnings about unrecognized | |
28520 | MCU names. This option is on by default. | |
28521 | ||
d77de738 | 28522 | @opindex mcpu= |
ddf6fe37 | 28523 | @item -mcpu= |
d77de738 ML |
28524 | Specifies the ISA to use. Accepted values are @samp{msp430}, |
28525 | @samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The | |
28526 | @option{-mmcu=} option should be used to select the ISA. | |
28527 | ||
d77de738 | 28528 | @opindex msim |
ddf6fe37 | 28529 | @item -msim |
d77de738 ML |
28530 | Link to the simulator runtime libraries and linker script. Overrides |
28531 | any scripts that would be selected by the @option{-mmcu=} option. | |
28532 | ||
d77de738 | 28533 | @opindex mlarge |
ddf6fe37 | 28534 | @item -mlarge |
d77de738 ML |
28535 | Use large-model addressing (20-bit pointers, 20-bit @code{size_t}). |
28536 | ||
d77de738 | 28537 | @opindex msmall |
ddf6fe37 | 28538 | @item -msmall |
d77de738 ML |
28539 | Use small-model addressing (16-bit pointers, 16-bit @code{size_t}). |
28540 | ||
d77de738 | 28541 | @opindex mrelax |
ddf6fe37 | 28542 | @item -mrelax |
d77de738 ML |
28543 | This option is passed to the assembler and linker, and allows the |
28544 | linker to perform certain optimizations that cannot be done until | |
28545 | the final link. | |
28546 | ||
d77de738 | 28547 | @opindex mhwmult= |
ddf6fe37 | 28548 | @item mhwmult= |
d77de738 ML |
28549 | Describes the type of hardware multiply supported by the target. |
28550 | Accepted values are @samp{none} for no hardware multiply, @samp{16bit} | |
28551 | for the original 16-bit-only multiply supported by early MCUs. | |
28552 | @samp{32bit} for the 16/32-bit multiply supported by later MCUs and | |
28553 | @samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs. | |
28554 | A value of @samp{auto} can also be given. This tells GCC to deduce | |
28555 | the hardware multiply support based upon the MCU name provided by the | |
28556 | @option{-mmcu} option. If no @option{-mmcu} option is specified or if | |
28557 | the MCU name is not recognized then no hardware multiply support is | |
28558 | assumed. @code{auto} is the default setting. | |
28559 | ||
28560 | Hardware multiplies are normally performed by calling a library | |
28561 | routine. This saves space in the generated code. When compiling at | |
28562 | @option{-O3} or higher however the hardware multiplier is invoked | |
28563 | inline. This makes for bigger, but faster code. | |
28564 | ||
28565 | The hardware multiply routines disable interrupts whilst running and | |
28566 | restore the previous interrupt state when they finish. This makes | |
28567 | them safe to use inside interrupt handlers as well as in normal code. | |
28568 | ||
d77de738 | 28569 | @opindex minrt |
ddf6fe37 | 28570 | @item -minrt |
d77de738 ML |
28571 | Enable the use of a minimum runtime environment - no static |
28572 | initializers or constructors. This is intended for memory-constrained | |
28573 | devices. The compiler includes special symbols in some objects | |
28574 | that tell the linker and runtime which code fragments are required. | |
28575 | ||
d77de738 | 28576 | @opindex mtiny-printf |
ddf6fe37 | 28577 | @item -mtiny-printf |
d77de738 ML |
28578 | Enable reduced code size @code{printf} and @code{puts} library functions. |
28579 | The @samp{tiny} implementations of these functions are not reentrant, so | |
28580 | must be used with caution in multi-threaded applications. | |
28581 | ||
28582 | Support for streams has been removed and the string to be printed will | |
28583 | always be sent to stdout via the @code{write} syscall. The string is not | |
28584 | buffered before it is sent to write. | |
28585 | ||
28586 | This option requires Newlib Nano IO, so GCC must be configured with | |
28587 | @samp{--enable-newlib-nano-formatted-io}. | |
28588 | ||
d77de738 | 28589 | @opindex mmax-inline-shift= |
ddf6fe37 | 28590 | @item -mmax-inline-shift= |
d77de738 ML |
28591 | This option takes an integer between 0 and 64 inclusive, and sets |
28592 | the maximum number of inline shift instructions which should be emitted to | |
28593 | perform a shift operation by a constant amount. When this value needs to be | |
28594 | exceeded, an mspabi helper function is used instead. The default value is 4. | |
28595 | ||
28596 | This only affects cases where a shift by multiple positions cannot be | |
28597 | completed with a single instruction (e.g. all shifts >1 on the 430 ISA). | |
28598 | ||
28599 | Shifts of a 32-bit value are at least twice as costly, so the value passed for | |
28600 | this option is divided by 2 and the resulting value used instead. | |
28601 | ||
d77de738 ML |
28602 | @opindex mcode-region |
28603 | @opindex mdata-region | |
ddf6fe37 AA |
28604 | @item -mcode-region= |
28605 | @itemx -mdata-region= | |
d77de738 ML |
28606 | These options tell the compiler where to place functions and data that |
28607 | do not have one of the @code{lower}, @code{upper}, @code{either} or | |
28608 | @code{section} attributes. Possible values are @code{lower}, | |
28609 | @code{upper}, @code{either} or @code{any}. The first three behave | |
28610 | like the corresponding attribute. The fourth possible value - | |
28611 | @code{any} - is the default. It leaves placement entirely up to the | |
28612 | linker script and how it assigns the standard sections | |
28613 | (@code{.text}, @code{.data}, etc) to the memory regions. | |
28614 | ||
d77de738 | 28615 | @opindex msilicon-errata |
ddf6fe37 | 28616 | @item -msilicon-errata= |
d77de738 ML |
28617 | This option passes on a request to assembler to enable the fixes for |
28618 | the named silicon errata. | |
28619 | ||
d77de738 | 28620 | @opindex msilicon-errata-warn |
ddf6fe37 | 28621 | @item -msilicon-errata-warn= |
d77de738 ML |
28622 | This option passes on a request to the assembler to enable warning |
28623 | messages when a silicon errata might need to be applied. | |
28624 | ||
d77de738 ML |
28625 | @opindex mwarn-devices-csv |
28626 | @opindex mno-warn-devices-csv | |
ddf6fe37 AA |
28627 | @item -mwarn-devices-csv |
28628 | @itemx -mno-warn-devices-csv | |
d77de738 ML |
28629 | Warn if @samp{devices.csv} is not found or there are problem parsing it |
28630 | (default: on). | |
28631 | ||
28632 | @end table | |
28633 | ||
28634 | @node NDS32 Options | |
28635 | @subsection NDS32 Options | |
28636 | @cindex NDS32 Options | |
28637 | ||
28638 | These options are defined for NDS32 implementations: | |
28639 | ||
28640 | @table @gcctabopt | |
28641 | ||
d77de738 | 28642 | @opindex mbig-endian |
ddf6fe37 | 28643 | @item -mbig-endian |
d77de738 ML |
28644 | Generate code in big-endian mode. |
28645 | ||
d77de738 | 28646 | @opindex mlittle-endian |
ddf6fe37 | 28647 | @item -mlittle-endian |
d77de738 ML |
28648 | Generate code in little-endian mode. |
28649 | ||
d77de738 | 28650 | @opindex mreduced-regs |
ddf6fe37 | 28651 | @item -mreduced-regs |
d77de738 ML |
28652 | Use reduced-set registers for register allocation. |
28653 | ||
d77de738 | 28654 | @opindex mfull-regs |
ddf6fe37 | 28655 | @item -mfull-regs |
d77de738 ML |
28656 | Use full-set registers for register allocation. |
28657 | ||
d77de738 | 28658 | @opindex mcmov |
ddf6fe37 | 28659 | @item -mcmov |
d77de738 ML |
28660 | Generate conditional move instructions. |
28661 | ||
d77de738 | 28662 | @opindex mno-cmov |
ddf6fe37 | 28663 | @item -mno-cmov |
d77de738 ML |
28664 | Do not generate conditional move instructions. |
28665 | ||
d77de738 | 28666 | @opindex mext-perf |
ddf6fe37 | 28667 | @item -mext-perf |
d77de738 ML |
28668 | Generate performance extension instructions. |
28669 | ||
d77de738 | 28670 | @opindex mno-ext-perf |
ddf6fe37 | 28671 | @item -mno-ext-perf |
d77de738 ML |
28672 | Do not generate performance extension instructions. |
28673 | ||
d77de738 | 28674 | @opindex mext-perf2 |
ddf6fe37 | 28675 | @item -mext-perf2 |
d77de738 ML |
28676 | Generate performance extension 2 instructions. |
28677 | ||
d77de738 | 28678 | @opindex mno-ext-perf2 |
ddf6fe37 | 28679 | @item -mno-ext-perf2 |
d77de738 ML |
28680 | Do not generate performance extension 2 instructions. |
28681 | ||
d77de738 | 28682 | @opindex mext-string |
ddf6fe37 | 28683 | @item -mext-string |
d77de738 ML |
28684 | Generate string extension instructions. |
28685 | ||
d77de738 | 28686 | @opindex mno-ext-string |
ddf6fe37 | 28687 | @item -mno-ext-string |
d77de738 ML |
28688 | Do not generate string extension instructions. |
28689 | ||
d77de738 | 28690 | @opindex mv3push |
ddf6fe37 | 28691 | @item -mv3push |
d77de738 ML |
28692 | Generate v3 push25/pop25 instructions. |
28693 | ||
d77de738 | 28694 | @opindex mno-v3push |
ddf6fe37 | 28695 | @item -mno-v3push |
d77de738 ML |
28696 | Do not generate v3 push25/pop25 instructions. |
28697 | ||
d77de738 | 28698 | @opindex m16-bit |
ddf6fe37 | 28699 | @item -m16-bit |
d77de738 ML |
28700 | Generate 16-bit instructions. |
28701 | ||
d77de738 | 28702 | @opindex mno-16-bit |
ddf6fe37 | 28703 | @item -mno-16-bit |
d77de738 ML |
28704 | Do not generate 16-bit instructions. |
28705 | ||
d77de738 | 28706 | @opindex misr-vector-size |
ddf6fe37 | 28707 | @item -misr-vector-size=@var{num} |
d77de738 ML |
28708 | Specify the size of each interrupt vector, which must be 4 or 16. |
28709 | ||
d77de738 | 28710 | @opindex mcache-block-size |
ddf6fe37 | 28711 | @item -mcache-block-size=@var{num} |
d77de738 ML |
28712 | Specify the size of each cache block, |
28713 | which must be a power of 2 between 4 and 512. | |
28714 | ||
d77de738 | 28715 | @opindex march |
ddf6fe37 | 28716 | @item -march=@var{arch} |
d77de738 ML |
28717 | Specify the name of the target architecture. |
28718 | ||
d77de738 | 28719 | @opindex mcmodel |
ddf6fe37 | 28720 | @item -mcmodel=@var{code-model} |
d77de738 ML |
28721 | Set the code model to one of |
28722 | @table @asis | |
28723 | @item @samp{small} | |
28724 | All the data and read-only data segments must be within 512KB addressing space. | |
28725 | The text segment must be within 16MB addressing space. | |
28726 | @item @samp{medium} | |
28727 | The data segment must be within 512KB while the read-only data segment can be | |
28728 | within 4GB addressing space. The text segment should be still within 16MB | |
28729 | addressing space. | |
28730 | @item @samp{large} | |
28731 | All the text and data segments can be within 4GB addressing space. | |
28732 | @end table | |
28733 | ||
d77de738 | 28734 | @opindex mctor-dtor |
ddf6fe37 | 28735 | @item -mctor-dtor |
d77de738 ML |
28736 | Enable constructor/destructor feature. |
28737 | ||
d77de738 | 28738 | @opindex mrelax |
ddf6fe37 | 28739 | @item -mrelax |
d77de738 ML |
28740 | Guide linker to relax instructions. |
28741 | ||
28742 | @end table | |
28743 | ||
28744 | @node Nios II Options | |
28745 | @subsection Nios II Options | |
28746 | @cindex Nios II options | |
28747 | @cindex Altera Nios II options | |
28748 | ||
28749 | These are the options defined for the Altera Nios II processor. | |
28750 | ||
28751 | @table @gcctabopt | |
28752 | ||
d77de738 ML |
28753 | @opindex G |
28754 | @cindex smaller data references | |
f33d7a88 | 28755 | @item -G @var{num} |
d77de738 ML |
28756 | Put global and static objects less than or equal to @var{num} bytes |
28757 | into the small data or BSS sections instead of the normal data or BSS | |
28758 | sections. The default value of @var{num} is 8. | |
28759 | ||
ddf6fe37 AA |
28760 | @opindex mgpopt |
28761 | @opindex mno-gpopt | |
d77de738 ML |
28762 | @item -mgpopt=@var{option} |
28763 | @itemx -mgpopt | |
28764 | @itemx -mno-gpopt | |
d77de738 ML |
28765 | Generate (do not generate) GP-relative accesses. The following |
28766 | @var{option} names are recognized: | |
28767 | ||
28768 | @table @samp | |
28769 | ||
28770 | @item none | |
28771 | Do not generate GP-relative accesses. | |
28772 | ||
28773 | @item local | |
28774 | Generate GP-relative accesses for small data objects that are not | |
28775 | external, weak, or uninitialized common symbols. | |
28776 | Also use GP-relative addressing for objects that | |
28777 | have been explicitly placed in a small data section via a @code{section} | |
28778 | attribute. | |
28779 | ||
28780 | @item global | |
28781 | As for @samp{local}, but also generate GP-relative accesses for | |
28782 | small data objects that are external, weak, or common. If you use this option, | |
28783 | you must ensure that all parts of your program (including libraries) are | |
28784 | compiled with the same @option{-G} setting. | |
28785 | ||
28786 | @item data | |
28787 | Generate GP-relative accesses for all data objects in the program. If you | |
28788 | use this option, the entire data and BSS segments | |
28789 | of your program must fit in 64K of memory and you must use an appropriate | |
28790 | linker script to allocate them within the addressable range of the | |
28791 | global pointer. | |
28792 | ||
28793 | @item all | |
28794 | Generate GP-relative addresses for function pointers as well as data | |
28795 | pointers. If you use this option, the entire text, data, and BSS segments | |
28796 | of your program must fit in 64K of memory and you must use an appropriate | |
28797 | linker script to allocate them within the addressable range of the | |
28798 | global pointer. | |
28799 | ||
28800 | @end table | |
28801 | ||
28802 | @option{-mgpopt} is equivalent to @option{-mgpopt=local}, and | |
28803 | @option{-mno-gpopt} is equivalent to @option{-mgpopt=none}. | |
28804 | ||
28805 | The default is @option{-mgpopt} except when @option{-fpic} or | |
28806 | @option{-fPIC} is specified to generate position-independent code. | |
28807 | Note that the Nios II ABI does not permit GP-relative accesses from | |
28808 | shared libraries. | |
28809 | ||
28810 | You may need to specify @option{-mno-gpopt} explicitly when building | |
28811 | programs that include large amounts of small data, including large | |
28812 | GOT data sections. In this case, the 16-bit offset for GP-relative | |
28813 | addressing may not be large enough to allow access to the entire | |
28814 | small data section. | |
28815 | ||
d77de738 | 28816 | @opindex mgprel-sec |
ddf6fe37 | 28817 | @item -mgprel-sec=@var{regexp} |
d77de738 ML |
28818 | This option specifies additional section names that can be accessed via |
28819 | GP-relative addressing. It is most useful in conjunction with | |
28820 | @code{section} attributes on variable declarations | |
28821 | (@pxref{Common Variable Attributes}) and a custom linker script. | |
28822 | The @var{regexp} is a POSIX Extended Regular Expression. | |
28823 | ||
28824 | This option does not affect the behavior of the @option{-G} option, and | |
28825 | the specified sections are in addition to the standard @code{.sdata} | |
28826 | and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}. | |
28827 | ||
d77de738 | 28828 | @opindex mr0rel-sec |
ddf6fe37 | 28829 | @item -mr0rel-sec=@var{regexp} |
d77de738 ML |
28830 | This option specifies names of sections that can be accessed via a |
28831 | 16-bit offset from @code{r0}; that is, in the low 32K or high 32K | |
28832 | of the 32-bit address space. It is most useful in conjunction with | |
28833 | @code{section} attributes on variable declarations | |
28834 | (@pxref{Common Variable Attributes}) and a custom linker script. | |
28835 | The @var{regexp} is a POSIX Extended Regular Expression. | |
28836 | ||
28837 | In contrast to the use of GP-relative addressing for small data, | |
28838 | zero-based addressing is never generated by default and there are no | |
28839 | conventional section names used in standard linker scripts for sections | |
28840 | in the low or high areas of memory. | |
28841 | ||
d77de738 ML |
28842 | @opindex mel |
28843 | @opindex meb | |
ddf6fe37 AA |
28844 | @item -mel |
28845 | @itemx -meb | |
d77de738 ML |
28846 | Generate little-endian (default) or big-endian (experimental) code, |
28847 | respectively. | |
28848 | ||
d77de738 | 28849 | @opindex march |
ddf6fe37 | 28850 | @item -march=@var{arch} |
d77de738 ML |
28851 | This specifies the name of the target Nios II architecture. GCC uses this |
28852 | name to determine what kind of instructions it can emit when generating | |
28853 | assembly code. Permissible names are: @samp{r1}, @samp{r2}. | |
28854 | ||
28855 | The preprocessor macro @code{__nios2_arch__} is available to programs, | |
28856 | with value 1 or 2, indicating the targeted ISA level. | |
28857 | ||
d77de738 ML |
28858 | @opindex mno-bypass-cache |
28859 | @opindex mbypass-cache | |
ddf6fe37 AA |
28860 | @item -mbypass-cache |
28861 | @itemx -mno-bypass-cache | |
d77de738 ML |
28862 | Force all load and store instructions to always bypass cache by |
28863 | using I/O variants of the instructions. The default is not to | |
28864 | bypass the cache. | |
28865 | ||
d77de738 ML |
28866 | @opindex mcache-volatile |
28867 | @opindex mno-cache-volatile | |
ddf6fe37 AA |
28868 | @item -mno-cache-volatile |
28869 | @itemx -mcache-volatile | |
d77de738 ML |
28870 | Volatile memory access bypass the cache using the I/O variants of |
28871 | the load and store instructions. The default is not to bypass the cache. | |
28872 | ||
d77de738 ML |
28873 | @opindex mno-fast-sw-div |
28874 | @opindex mfast-sw-div | |
ddf6fe37 AA |
28875 | @item -mno-fast-sw-div |
28876 | @itemx -mfast-sw-div | |
d77de738 ML |
28877 | Do not use table-based fast divide for small numbers. The default |
28878 | is to use the fast divide at @option{-O3} and above. | |
28879 | ||
d77de738 ML |
28880 | @opindex mno-hw-mul |
28881 | @opindex mhw-mul | |
28882 | @opindex mno-hw-mulx | |
28883 | @opindex mhw-mulx | |
28884 | @opindex mno-hw-div | |
28885 | @opindex mhw-div | |
ddf6fe37 AA |
28886 | @item -mno-hw-mul |
28887 | @itemx -mhw-mul | |
28888 | @itemx -mno-hw-mulx | |
28889 | @itemx -mhw-mulx | |
28890 | @itemx -mno-hw-div | |
28891 | @itemx -mhw-div | |
d77de738 ML |
28892 | Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of |
28893 | instructions by the compiler. The default is to emit @code{mul} | |
28894 | and not emit @code{div} and @code{mulx}. | |
28895 | ||
28896 | @item -mbmx | |
28897 | @itemx -mno-bmx | |
28898 | @itemx -mcdx | |
28899 | @itemx -mno-cdx | |
28900 | Enable or disable generation of Nios II R2 BMX (bit manipulation) and | |
28901 | CDX (code density) instructions. Enabling these instructions also | |
28902 | requires @option{-march=r2}. Since these instructions are optional | |
28903 | extensions to the R2 architecture, the default is not to emit them. | |
28904 | ||
d77de738 ML |
28905 | @opindex mcustom-@var{insn} |
28906 | @opindex mno-custom-@var{insn} | |
ddf6fe37 AA |
28907 | @item -mcustom-@var{insn}=@var{N} |
28908 | @itemx -mno-custom-@var{insn} | |
d77de738 ML |
28909 | Each @option{-mcustom-@var{insn}=@var{N}} option enables use of a |
28910 | custom instruction with encoding @var{N} when generating code that uses | |
28911 | @var{insn}. For example, @option{-mcustom-fadds=253} generates custom | |
28912 | instruction 253 for single-precision floating-point add operations instead | |
28913 | of the default behavior of using a library call. | |
28914 | ||
28915 | The following values of @var{insn} are supported. Except as otherwise | |
28916 | noted, floating-point operations are expected to be implemented with | |
28917 | normal IEEE 754 semantics and correspond directly to the C operators or the | |
28918 | equivalent GCC built-in functions (@pxref{Other Builtins}). | |
28919 | ||
28920 | Single-precision floating point: | |
28921 | @table @asis | |
28922 | ||
28923 | @item @samp{fadds}, @samp{fsubs}, @samp{fdivs}, @samp{fmuls} | |
28924 | Binary arithmetic operations. | |
28925 | ||
28926 | @item @samp{fnegs} | |
28927 | Unary negation. | |
28928 | ||
28929 | @item @samp{fabss} | |
28930 | Unary absolute value. | |
28931 | ||
28932 | @item @samp{fcmpeqs}, @samp{fcmpges}, @samp{fcmpgts}, @samp{fcmples}, @samp{fcmplts}, @samp{fcmpnes} | |
28933 | Comparison operations. | |
28934 | ||
28935 | @item @samp{fmins}, @samp{fmaxs} | |
28936 | Floating-point minimum and maximum. These instructions are only | |
28937 | generated if @option{-ffinite-math-only} is specified. | |
28938 | ||
28939 | @item @samp{fsqrts} | |
28940 | Unary square root operation. | |
28941 | ||
28942 | @item @samp{fcoss}, @samp{fsins}, @samp{ftans}, @samp{fatans}, @samp{fexps}, @samp{flogs} | |
28943 | Floating-point trigonometric and exponential functions. These instructions | |
28944 | are only generated if @option{-funsafe-math-optimizations} is also specified. | |
28945 | ||
28946 | @end table | |
28947 | ||
28948 | Double-precision floating point: | |
28949 | @table @asis | |
28950 | ||
28951 | @item @samp{faddd}, @samp{fsubd}, @samp{fdivd}, @samp{fmuld} | |
28952 | Binary arithmetic operations. | |
28953 | ||
28954 | @item @samp{fnegd} | |
28955 | Unary negation. | |
28956 | ||
28957 | @item @samp{fabsd} | |
28958 | Unary absolute value. | |
28959 | ||
28960 | @item @samp{fcmpeqd}, @samp{fcmpged}, @samp{fcmpgtd}, @samp{fcmpled}, @samp{fcmpltd}, @samp{fcmpned} | |
28961 | Comparison operations. | |
28962 | ||
28963 | @item @samp{fmind}, @samp{fmaxd} | |
28964 | Double-precision minimum and maximum. These instructions are only | |
28965 | generated if @option{-ffinite-math-only} is specified. | |
28966 | ||
28967 | @item @samp{fsqrtd} | |
28968 | Unary square root operation. | |
28969 | ||
28970 | @item @samp{fcosd}, @samp{fsind}, @samp{ftand}, @samp{fatand}, @samp{fexpd}, @samp{flogd} | |
28971 | Double-precision trigonometric and exponential functions. These instructions | |
28972 | are only generated if @option{-funsafe-math-optimizations} is also specified. | |
28973 | ||
28974 | @end table | |
28975 | ||
28976 | Conversions: | |
28977 | @table @asis | |
28978 | @item @samp{fextsd} | |
28979 | Conversion from single precision to double precision. | |
28980 | ||
28981 | @item @samp{ftruncds} | |
28982 | Conversion from double precision to single precision. | |
28983 | ||
28984 | @item @samp{fixsi}, @samp{fixsu}, @samp{fixdi}, @samp{fixdu} | |
28985 | Conversion from floating point to signed or unsigned integer types, with | |
28986 | truncation towards zero. | |
28987 | ||
28988 | @item @samp{round} | |
28989 | Conversion from single-precision floating point to signed integer, | |
28990 | rounding to the nearest integer and ties away from zero. | |
28991 | This corresponds to the @code{__builtin_lroundf} function when | |
28992 | @option{-fno-math-errno} is used. | |
28993 | ||
28994 | @item @samp{floatis}, @samp{floatus}, @samp{floatid}, @samp{floatud} | |
28995 | Conversion from signed or unsigned integer types to floating-point types. | |
28996 | ||
28997 | @end table | |
28998 | ||
28999 | In addition, all of the following transfer instructions for internal | |
29000 | registers X and Y must be provided to use any of the double-precision | |
29001 | floating-point instructions. Custom instructions taking two | |
29002 | double-precision source operands expect the first operand in the | |
29003 | 64-bit register X. The other operand (or only operand of a unary | |
29004 | operation) is given to the custom arithmetic instruction with the | |
29005 | least significant half in source register @var{src1} and the most | |
29006 | significant half in @var{src2}. A custom instruction that returns a | |
29007 | double-precision result returns the most significant 32 bits in the | |
29008 | destination register and the other half in 32-bit register Y. | |
29009 | GCC automatically generates the necessary code sequences to write | |
29010 | register X and/or read register Y when double-precision floating-point | |
29011 | instructions are used. | |
29012 | ||
29013 | @table @asis | |
29014 | ||
29015 | @item @samp{fwrx} | |
29016 | Write @var{src1} into the least significant half of X and @var{src2} into | |
29017 | the most significant half of X. | |
29018 | ||
29019 | @item @samp{fwry} | |
29020 | Write @var{src1} into Y. | |
29021 | ||
29022 | @item @samp{frdxhi}, @samp{frdxlo} | |
29023 | Read the most or least (respectively) significant half of X and store it in | |
29024 | @var{dest}. | |
29025 | ||
29026 | @item @samp{frdy} | |
29027 | Read the value of Y and store it into @var{dest}. | |
29028 | @end table | |
29029 | ||
29030 | Note that you can gain more local control over generation of Nios II custom | |
29031 | instructions by using the @code{target("custom-@var{insn}=@var{N}")} | |
29032 | and @code{target("no-custom-@var{insn}")} function attributes | |
29033 | (@pxref{Function Attributes}) | |
29034 | or pragmas (@pxref{Function Specific Option Pragmas}). | |
29035 | ||
d77de738 | 29036 | @opindex mcustom-fpu-cfg |
ddf6fe37 | 29037 | @item -mcustom-fpu-cfg=@var{name} |
d77de738 ML |
29038 | |
29039 | This option enables a predefined, named set of custom instruction encodings | |
29040 | (see @option{-mcustom-@var{insn}} above). | |
29041 | Currently, the following sets are defined: | |
29042 | ||
29043 | @option{-mcustom-fpu-cfg=60-1} is equivalent to: | |
43b72ede AA |
29044 | @gccoptlist{-mcustom-fmuls=252 |
29045 | -mcustom-fadds=253 | |
29046 | -mcustom-fsubs=254 | |
d77de738 ML |
29047 | -fsingle-precision-constant} |
29048 | ||
29049 | @option{-mcustom-fpu-cfg=60-2} is equivalent to: | |
43b72ede AA |
29050 | @gccoptlist{-mcustom-fmuls=252 |
29051 | -mcustom-fadds=253 | |
29052 | -mcustom-fsubs=254 | |
29053 | -mcustom-fdivs=255 | |
d77de738 ML |
29054 | -fsingle-precision-constant} |
29055 | ||
29056 | @option{-mcustom-fpu-cfg=72-3} is equivalent to: | |
43b72ede AA |
29057 | @gccoptlist{-mcustom-floatus=243 |
29058 | -mcustom-fixsi=244 | |
29059 | -mcustom-floatis=245 | |
29060 | -mcustom-fcmpgts=246 | |
29061 | -mcustom-fcmples=249 | |
29062 | -mcustom-fcmpeqs=250 | |
29063 | -mcustom-fcmpnes=251 | |
29064 | -mcustom-fmuls=252 | |
29065 | -mcustom-fadds=253 | |
29066 | -mcustom-fsubs=254 | |
29067 | -mcustom-fdivs=255 | |
d77de738 ML |
29068 | -fsingle-precision-constant} |
29069 | ||
29070 | @option{-mcustom-fpu-cfg=fph2} is equivalent to: | |
43b72ede AA |
29071 | @gccoptlist{-mcustom-fabss=224 |
29072 | -mcustom-fnegs=225 | |
29073 | -mcustom-fcmpnes=226 | |
29074 | -mcustom-fcmpeqs=227 | |
29075 | -mcustom-fcmpges=228 | |
29076 | -mcustom-fcmpgts=229 | |
29077 | -mcustom-fcmples=230 | |
29078 | -mcustom-fcmplts=231 | |
29079 | -mcustom-fmaxs=232 | |
29080 | -mcustom-fmins=233 | |
29081 | -mcustom-round=248 | |
29082 | -mcustom-fixsi=249 | |
29083 | -mcustom-floatis=250 | |
29084 | -mcustom-fsqrts=251 | |
29085 | -mcustom-fmuls=252 | |
29086 | -mcustom-fadds=253 | |
29087 | -mcustom-fsubs=254 | |
29088 | -mcustom-fdivs=255} | |
d77de738 ML |
29089 | |
29090 | Custom instruction assignments given by individual | |
29091 | @option{-mcustom-@var{insn}=} options override those given by | |
29092 | @option{-mcustom-fpu-cfg=}, regardless of the | |
29093 | order of the options on the command line. | |
29094 | ||
29095 | Note that you can gain more local control over selection of a FPU | |
29096 | configuration by using the @code{target("custom-fpu-cfg=@var{name}")} | |
29097 | function attribute (@pxref{Function Attributes}) | |
29098 | or pragma (@pxref{Function Specific Option Pragmas}). | |
29099 | ||
29100 | The name @var{fph2} is an abbreviation for @emph{Nios II Floating Point | |
29101 | Hardware 2 Component}. Please note that the custom instructions enabled by | |
29102 | @option{-mcustom-fmins=233} and @option{-mcustom-fmaxs=234} are only generated | |
29103 | if @option{-ffinite-math-only} is specified. The custom instruction enabled by | |
29104 | @option{-mcustom-round=248} is only generated if @option{-fno-math-errno} is | |
29105 | specified. In contrast to the other configurations, | |
29106 | @option{-fsingle-precision-constant} is not set. | |
29107 | ||
29108 | @end table | |
29109 | ||
29110 | These additional @samp{-m} options are available for the Altera Nios II | |
29111 | ELF (bare-metal) target: | |
29112 | ||
29113 | @table @gcctabopt | |
29114 | ||
d77de738 | 29115 | @opindex mhal |
ddf6fe37 | 29116 | @item -mhal |
d77de738 ML |
29117 | Link with HAL BSP. This suppresses linking with the GCC-provided C runtime |
29118 | startup and termination code, and is typically used in conjunction with | |
29119 | @option{-msys-crt0=} to specify the location of the alternate startup code | |
29120 | provided by the HAL BSP. | |
29121 | ||
d77de738 | 29122 | @opindex msmallc |
ddf6fe37 | 29123 | @item -msmallc |
d77de738 ML |
29124 | Link with a limited version of the C library, @option{-lsmallc}, rather than |
29125 | Newlib. | |
29126 | ||
d77de738 | 29127 | @opindex msys-crt0 |
ddf6fe37 | 29128 | @item -msys-crt0=@var{startfile} |
d77de738 ML |
29129 | @var{startfile} is the file name of the startfile (crt0) to use |
29130 | when linking. This option is only useful in conjunction with @option{-mhal}. | |
29131 | ||
d77de738 | 29132 | @opindex msys-lib |
ddf6fe37 | 29133 | @item -msys-lib=@var{systemlib} |
d77de738 ML |
29134 | @var{systemlib} is the library name of the library that provides |
29135 | low-level system calls required by the C library, | |
29136 | e.g.@: @code{read} and @code{write}. | |
29137 | This option is typically used to link with a library provided by a HAL BSP. | |
29138 | ||
29139 | @end table | |
29140 | ||
29141 | @node Nvidia PTX Options | |
29142 | @subsection Nvidia PTX Options | |
29143 | @cindex Nvidia PTX options | |
29144 | @cindex nvptx options | |
29145 | ||
29146 | These options are defined for Nvidia PTX: | |
29147 | ||
29148 | @table @gcctabopt | |
29149 | ||
d77de738 | 29150 | @opindex m64 |
ddf6fe37 | 29151 | @item -m64 |
d77de738 ML |
29152 | Ignored, but preserved for backward compatibility. Only 64-bit ABI is |
29153 | supported. | |
29154 | ||
d77de738 | 29155 | @opindex march |
ddf6fe37 | 29156 | @item -march=@var{architecture-string} |
d77de738 ML |
29157 | Generate code for the specified PTX ISA target architecture |
29158 | (e.g.@: @samp{sm_35}). Valid architecture strings are @samp{sm_30}, | |
29159 | @samp{sm_35}, @samp{sm_53}, @samp{sm_70}, @samp{sm_75} and | |
29160 | @samp{sm_80}. | |
29161 | The default depends on how the compiler has been configured, see | |
29162 | @option{--with-arch}. | |
29163 | ||
29164 | This option sets the value of the preprocessor macro | |
29165 | @code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value | |
29166 | @samp{350}. | |
29167 | ||
d77de738 | 29168 | @opindex misa |
ddf6fe37 | 29169 | @item -misa=@var{architecture-string} |
d77de738 ML |
29170 | Alias of @option{-march=}. |
29171 | ||
d77de738 | 29172 | @opindex march |
ddf6fe37 | 29173 | @item -march-map=@var{architecture-string} |
d77de738 ML |
29174 | Select the closest available @option{-march=} value that is not more |
29175 | capable. For instance, for @option{-march-map=sm_50} select | |
29176 | @option{-march=sm_35}, and for @option{-march-map=sm_53} select | |
29177 | @option{-march=sm_53}. | |
29178 | ||
d77de738 | 29179 | @opindex mptx |
ddf6fe37 | 29180 | @item -mptx=@var{version-string} |
d77de738 ML |
29181 | Generate code for the specified PTX ISA version (e.g.@: @samp{7.0}). |
29182 | Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and | |
29183 | @samp{7.0}. The default PTX ISA version is 6.0, unless a higher | |
29184 | version is required for specified PTX ISA target architecture via | |
29185 | option @option{-march=}. | |
29186 | ||
29187 | This option sets the values of the preprocessor macros | |
29188 | @code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__}; | |
29189 | for instance, for @samp{3.1} the macros have the values @samp{3} and | |
29190 | @samp{1}, respectively. | |
29191 | ||
d77de738 | 29192 | @opindex mmainkernel |
ddf6fe37 | 29193 | @item -mmainkernel |
d77de738 ML |
29194 | Link in code for a __main kernel. This is for stand-alone instead of |
29195 | offloading execution. | |
29196 | ||
d77de738 | 29197 | @opindex moptimize |
ddf6fe37 | 29198 | @item -moptimize |
d77de738 ML |
29199 | Apply partitioned execution optimizations. This is the default when any |
29200 | level of optimization is selected. | |
29201 | ||
d77de738 | 29202 | @opindex msoft-stack |
ddf6fe37 | 29203 | @item -msoft-stack |
d77de738 ML |
29204 | Generate code that does not use @code{.local} memory |
29205 | directly for stack storage. Instead, a per-warp stack pointer is | |
29206 | maintained explicitly. This enables variable-length stack allocation (with | |
29207 | variable-length arrays or @code{alloca}), and when global memory is used for | |
29208 | underlying storage, makes it possible to access automatic variables from other | |
29209 | threads, or with atomic instructions. This code generation variant is used | |
29210 | for OpenMP offloading, but the option is exposed on its own for the purpose | |
29211 | of testing the compiler; to generate code suitable for linking into programs | |
29212 | using OpenMP offloading, use option @option{-mgomp}. | |
29213 | ||
d77de738 | 29214 | @opindex muniform-simt |
ddf6fe37 | 29215 | @item -muniform-simt |
d77de738 ML |
29216 | Switch to code generation variant that allows to execute all threads in each |
29217 | warp, while maintaining memory state and side effects as if only one thread | |
29218 | in each warp was active outside of OpenMP SIMD regions. All atomic operations | |
29219 | and calls to runtime (malloc, free, vprintf) are conditionally executed (iff | |
29220 | current lane index equals the master lane index), and the register being | |
29221 | assigned is copied via a shuffle instruction from the master lane. Outside of | |
29222 | SIMD regions lane 0 is the master; inside, each thread sees itself as the | |
29223 | master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or | |
29224 | all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD | |
29225 | regions). Each thread can bitwise-and the bitmask at position @code{tid.y} | |
29226 | with current lane index to compute the master lane index. | |
29227 | ||
d77de738 | 29228 | @opindex mgomp |
ddf6fe37 | 29229 | @item -mgomp |
d77de738 ML |
29230 | Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and |
29231 | @option{-muniform-simt} options, and selects corresponding multilib variant. | |
29232 | ||
29233 | @end table | |
29234 | ||
29235 | @node OpenRISC Options | |
29236 | @subsection OpenRISC Options | |
29237 | @cindex OpenRISC Options | |
29238 | ||
29239 | These options are defined for OpenRISC: | |
29240 | ||
29241 | @table @gcctabopt | |
29242 | ||
d77de738 | 29243 | @opindex mboard |
ddf6fe37 | 29244 | @item -mboard=@var{name} |
d77de738 ML |
29245 | Configure a board specific runtime. This will be passed to the linker for |
29246 | newlib board library linking. The default is @code{or1ksim}. | |
29247 | ||
d77de738 | 29248 | @opindex mnewlib |
ddf6fe37 | 29249 | @item -mnewlib |
d77de738 ML |
29250 | This option is ignored; it is for compatibility purposes only. This used to |
29251 | select linker and preprocessor options for use with newlib. | |
29252 | ||
d77de738 ML |
29253 | @opindex msoft-div |
29254 | @opindex mhard-div | |
ddf6fe37 AA |
29255 | @item -msoft-div |
29256 | @itemx -mhard-div | |
d77de738 ML |
29257 | Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions. |
29258 | This default is hardware divide. | |
29259 | ||
d77de738 ML |
29260 | @opindex msoft-mul |
29261 | @opindex mhard-mul | |
ddf6fe37 AA |
29262 | @item -msoft-mul |
29263 | @itemx -mhard-mul | |
d77de738 ML |
29264 | Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions. |
29265 | This default is hardware multiply. | |
29266 | ||
d77de738 ML |
29267 | @opindex msoft-float |
29268 | @opindex mhard-float | |
ddf6fe37 AA |
29269 | @item -msoft-float |
29270 | @itemx -mhard-float | |
d77de738 ML |
29271 | Select software or hardware for floating point operations. |
29272 | The default is software. | |
29273 | ||
d77de738 | 29274 | @opindex mdouble-float |
ddf6fe37 | 29275 | @item -mdouble-float |
d77de738 ML |
29276 | When @option{-mhard-float} is selected, enables generation of double-precision |
29277 | floating point instructions. By default functions from @file{libgcc} are used | |
29278 | to perform double-precision floating point operations. | |
29279 | ||
d77de738 | 29280 | @opindex munordered-float |
ddf6fe37 | 29281 | @item -munordered-float |
d77de738 ML |
29282 | When @option{-mhard-float} is selected, enables generation of unordered |
29283 | floating point compare and set flag (@code{lf.sfun*}) instructions. By default | |
29284 | functions from @file{libgcc} are used to perform unordered floating point | |
29285 | compare and set flag operations. | |
29286 | ||
d77de738 | 29287 | @opindex mcmov |
ddf6fe37 | 29288 | @item -mcmov |
d77de738 ML |
29289 | Enable generation of conditional move (@code{l.cmov}) instructions. By |
29290 | default the equivalent will be generated using set and branch. | |
29291 | ||
d77de738 | 29292 | @opindex mror |
ddf6fe37 | 29293 | @item -mror |
d77de738 ML |
29294 | Enable generation of rotate right (@code{l.ror}) instructions. By default |
29295 | functions from @file{libgcc} are used to perform rotate right operations. | |
29296 | ||
d77de738 | 29297 | @opindex mrori |
ddf6fe37 | 29298 | @item -mrori |
d77de738 ML |
29299 | Enable generation of rotate right with immediate (@code{l.rori}) instructions. |
29300 | By default functions from @file{libgcc} are used to perform rotate right with | |
29301 | immediate operations. | |
29302 | ||
d77de738 | 29303 | @opindex msext |
ddf6fe37 | 29304 | @item -msext |
d77de738 ML |
29305 | Enable generation of sign extension (@code{l.ext*}) instructions. By default |
29306 | memory loads are used to perform sign extension. | |
29307 | ||
d77de738 | 29308 | @opindex msfimm |
ddf6fe37 | 29309 | @item -msfimm |
d77de738 ML |
29310 | Enable generation of compare and set flag with immediate (@code{l.sf*i}) |
29311 | instructions. By default extra instructions will be generated to store the | |
29312 | immediate to a register first. | |
29313 | ||
d77de738 | 29314 | @opindex mshftimm |
ddf6fe37 | 29315 | @item -mshftimm |
d77de738 ML |
29316 | Enable generation of shift with immediate (@code{l.srai}, @code{l.srli}, |
29317 | @code{l.slli}) instructions. By default extra instructions will be generated | |
29318 | to store the immediate to a register first. | |
29319 | ||
d77de738 | 29320 | @opindex mcmodel=small |
ddf6fe37 | 29321 | @item -mcmodel=small |
d77de738 ML |
29322 | Generate OpenRISC code for the small model: The GOT is limited to 64k. This is |
29323 | the default model. | |
29324 | ||
d77de738 | 29325 | @opindex mcmodel=large |
ddf6fe37 | 29326 | @item -mcmodel=large |
d77de738 ML |
29327 | Generate OpenRISC code for the large model: The GOT may grow up to 4G in size. |
29328 | ||
29329 | ||
29330 | @end table | |
29331 | ||
29332 | @node PDP-11 Options | |
29333 | @subsection PDP-11 Options | |
29334 | @cindex PDP-11 Options | |
29335 | ||
29336 | These options are defined for the PDP-11: | |
29337 | ||
29338 | @table @gcctabopt | |
d77de738 | 29339 | @opindex mfpu |
ddf6fe37 | 29340 | @item -mfpu |
d77de738 ML |
29341 | Use hardware FPP floating point. This is the default. (FIS floating |
29342 | point on the PDP-11/40 is not supported.) Implies -m45. | |
29343 | ||
d77de738 | 29344 | @opindex msoft-float |
ddf6fe37 | 29345 | @item -msoft-float |
d77de738 ML |
29346 | Do not use hardware floating point. |
29347 | ||
d77de738 | 29348 | @opindex mac0 |
ddf6fe37 | 29349 | @item -mac0 |
d77de738 ML |
29350 | Return floating-point results in ac0 (fr0 in Unix assembler syntax). |
29351 | ||
d77de738 | 29352 | @opindex mno-ac0 |
ddf6fe37 | 29353 | @item -mno-ac0 |
d77de738 ML |
29354 | Return floating-point results in memory. This is the default. |
29355 | ||
d77de738 | 29356 | @opindex m40 |
ddf6fe37 | 29357 | @item -m40 |
d77de738 ML |
29358 | Generate code for a PDP-11/40. Implies -msoft-float -mno-split. |
29359 | ||
d77de738 | 29360 | @opindex m45 |
ddf6fe37 | 29361 | @item -m45 |
d77de738 ML |
29362 | Generate code for a PDP-11/45. This is the default. |
29363 | ||
d77de738 | 29364 | @opindex m10 |
ddf6fe37 | 29365 | @item -m10 |
d77de738 ML |
29366 | Generate code for a PDP-11/10. Implies -msoft-float -mno-split. |
29367 | ||
d77de738 ML |
29368 | @opindex mint16 |
29369 | @opindex mno-int32 | |
ddf6fe37 AA |
29370 | @item -mint16 |
29371 | @itemx -mno-int32 | |
d77de738 ML |
29372 | Use 16-bit @code{int}. This is the default. |
29373 | ||
d77de738 ML |
29374 | @opindex mint32 |
29375 | @opindex mno-int16 | |
ddf6fe37 AA |
29376 | @item -mint32 |
29377 | @itemx -mno-int16 | |
d77de738 ML |
29378 | Use 32-bit @code{int}. |
29379 | ||
d77de738 | 29380 | @opindex msplit |
ddf6fe37 | 29381 | @item -msplit |
d77de738 ML |
29382 | Target has split instruction and data space. Implies -m45. |
29383 | ||
d77de738 | 29384 | @opindex munix-asm |
ddf6fe37 | 29385 | @item -munix-asm |
d77de738 ML |
29386 | Use Unix assembler syntax. |
29387 | ||
d77de738 | 29388 | @opindex mdec-asm |
ddf6fe37 | 29389 | @item -mdec-asm |
d77de738 ML |
29390 | Use DEC assembler syntax. |
29391 | ||
d77de738 | 29392 | @opindex mgnu-asm |
ddf6fe37 | 29393 | @item -mgnu-asm |
d77de738 ML |
29394 | Use GNU assembler syntax. This is the default. |
29395 | ||
d77de738 | 29396 | @opindex mlra |
ddf6fe37 | 29397 | @item -mlra |
d77de738 ML |
29398 | Use the new LRA register allocator. By default, the old ``reload'' |
29399 | allocator is used. | |
29400 | @end table | |
29401 | ||
d77de738 ML |
29402 | @node PowerPC Options |
29403 | @subsection PowerPC Options | |
29404 | @cindex PowerPC options | |
29405 | ||
29406 | These are listed under @xref{RS/6000 and PowerPC Options}. | |
29407 | ||
29408 | @node PRU Options | |
29409 | @subsection PRU Options | |
29410 | @cindex PRU Options | |
29411 | ||
29412 | These command-line options are defined for PRU target: | |
29413 | ||
29414 | @table @gcctabopt | |
d77de738 | 29415 | @opindex minrt |
ddf6fe37 | 29416 | @item -minrt |
d77de738 ML |
29417 | Link with a minimum runtime environment, with no support for static |
29418 | initializers and constructors. Using this option can significantly reduce | |
29419 | the size of the final ELF binary. Beware that the compiler could still | |
29420 | generate code with static initializers and constructors. It is up to the | |
29421 | programmer to ensure that the source program will not use those features. | |
29422 | ||
d77de738 | 29423 | @opindex mmcu |
ddf6fe37 | 29424 | @item -mmcu=@var{mcu} |
d77de738 ML |
29425 | Specify the PRU MCU variant to use. Check Newlib for the exact list of |
29426 | supported MCUs. | |
29427 | ||
d77de738 | 29428 | @opindex mno-relax |
ddf6fe37 | 29429 | @item -mno-relax |
d77de738 ML |
29430 | Make GCC pass the @option{--no-relax} command-line option to the linker |
29431 | instead of the @option{--relax} option. | |
29432 | ||
d77de738 | 29433 | @opindex mloop |
ddf6fe37 | 29434 | @item -mloop |
d77de738 ML |
29435 | Allow (or do not allow) GCC to use the LOOP instruction. |
29436 | ||
d77de738 | 29437 | @opindex mabi |
ddf6fe37 | 29438 | @item -mabi=@var{variant} |
d77de738 ML |
29439 | Specify the ABI variant to output code for. @option{-mabi=ti} selects the |
29440 | unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes | |
29441 | more naturally with certain GCC assumptions. These are the differences: | |
29442 | ||
29443 | @table @samp | |
29444 | @item Function Pointer Size | |
29445 | TI ABI specifies that function (code) pointers are 16-bit, whereas GNU | |
29446 | supports only 32-bit data and code pointers. | |
29447 | ||
29448 | @item Optional Return Value Pointer | |
29449 | Function return values larger than 64 bits are passed by using a hidden | |
29450 | pointer as the first argument of the function. TI ABI, though, mandates that | |
29451 | the pointer can be NULL in case the caller is not using the returned value. | |
29452 | GNU always passes and expects a valid return value pointer. | |
29453 | ||
29454 | @end table | |
29455 | ||
29456 | The current @option{-mabi=ti} implementation simply raises a compile error | |
29457 | when any of the above code constructs is detected. As a consequence | |
29458 | the standard C library cannot be built and it is omitted when linking with | |
29459 | @option{-mabi=ti}. | |
29460 | ||
29461 | Relaxation is a GNU feature and for safety reasons is disabled when using | |
29462 | @option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx | |
29463 | instructions, so the GNU linker cannot adjust them when shortening adjacent | |
29464 | LDI32 pseudo instructions. | |
29465 | ||
29466 | @end table | |
29467 | ||
29468 | @node RISC-V Options | |
29469 | @subsection RISC-V Options | |
29470 | @cindex RISC-V Options | |
29471 | ||
29472 | These command-line options are defined for RISC-V targets: | |
29473 | ||
29474 | @table @gcctabopt | |
d77de738 | 29475 | @opindex mbranch-cost |
ddf6fe37 | 29476 | @item -mbranch-cost=@var{n} |
d77de738 ML |
29477 | Set the cost of branches to roughly @var{n} instructions. |
29478 | ||
ddf6fe37 | 29479 | @opindex plt |
d77de738 ML |
29480 | @item -mplt |
29481 | @itemx -mno-plt | |
d77de738 ML |
29482 | When generating PIC code, do or don't allow the use of PLTs. Ignored for |
29483 | non-PIC. The default is @option{-mplt}. | |
29484 | ||
d77de738 | 29485 | @opindex mabi |
ddf6fe37 | 29486 | @item -mabi=@var{ABI-string} |
d77de738 ML |
29487 | Specify integer and floating-point calling convention. @var{ABI-string} |
29488 | contains two parts: the size of integer types and the registers used for | |
29489 | floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that | |
29490 | @samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be | |
29491 | 32-bit), and that floating-point values up to 64 bits wide are passed in F | |
29492 | registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still | |
29493 | allows the compiler to generate code that uses the F and D extensions but only | |
29494 | allows floating-point values up to 32 bits long to be passed in registers; or | |
29495 | @samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be | |
29496 | passed in registers. | |
29497 | ||
29498 | The default for this argument is system dependent, users who want a specific | |
29499 | calling convention should specify one explicitly. The valid calling | |
29500 | conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64}, | |
29501 | @samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to | |
29502 | implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is | |
29503 | invalid because the ABI requires 64-bit values be passed in F registers, but F | |
29504 | registers are only 32 bits wide. There is also the @samp{ilp32e} ABI that can | |
29505 | only be used with the @samp{rv32e} architecture. This ABI is not well | |
29506 | specified at present, and is subject to change. | |
29507 | ||
ddf6fe37 | 29508 | @opindex mfdiv |
d77de738 ML |
29509 | @item -mfdiv |
29510 | @itemx -mno-fdiv | |
d77de738 ML |
29511 | Do or don't use hardware floating-point divide and square root instructions. |
29512 | This requires the F or D extensions for floating-point registers. The default | |
29513 | is to use them if the specified architecture has these instructions. | |
29514 | ||
ddf6fe37 | 29515 | @opindex mdiv |
d77de738 ML |
29516 | @item -mdiv |
29517 | @itemx -mno-div | |
d77de738 ML |
29518 | Do or don't use hardware instructions for integer division. This requires the |
29519 | M extension. The default is to use them if the specified architecture has | |
29520 | these instructions. | |
29521 | ||
d77de738 | 29522 | @opindex misa-spec |
ddf6fe37 | 29523 | @item -misa-spec=@var{ISA-spec-string} |
d77de738 ML |
29524 | Specify the version of the RISC-V Unprivileged (formerly User-Level) |
29525 | ISA specification to produce code conforming to. The possibilities | |
29526 | for @var{ISA-spec-string} are: | |
29527 | @table @code | |
29528 | @item 2.2 | |
29529 | Produce code conforming to version 2.2. | |
29530 | @item 20190608 | |
29531 | Produce code conforming to version 20190608. | |
29532 | @item 20191213 | |
29533 | Produce code conforming to version 20191213. | |
29534 | @end table | |
29535 | The default is @option{-misa-spec=20191213} unless GCC has been configured | |
29536 | with @option{--with-isa-spec=} specifying a different default version. | |
29537 | ||
d77de738 | 29538 | @opindex march |
ddf6fe37 | 29539 | @item -march=@var{ISA-string} |
d77de738 ML |
29540 | Generate code for given RISC-V ISA (e.g.@: @samp{rv64im}). ISA strings must be |
29541 | lower-case. Examples include @samp{rv64i}, @samp{rv32g}, @samp{rv32e}, and | |
29542 | @samp{rv32imaf}. | |
29543 | ||
29544 | When @option{-march=} is not specified, use the setting from @option{-mcpu}. | |
29545 | ||
29546 | If both @option{-march} and @option{-mcpu=} are not specified, the default for | |
29547 | this argument is system dependent, users who want a specific architecture | |
29548 | extensions should specify one explicitly. | |
29549 | ||
d77de738 | 29550 | @opindex mcpu |
ddf6fe37 | 29551 | @item -mcpu=@var{processor-string} |
d77de738 ML |
29552 | Use architecture of and optimize the output for the given processor, specified |
29553 | by particular CPU name. | |
29554 | Permissible values for this option are: @samp{sifive-e20}, @samp{sifive-e21}, | |
29555 | @samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34}, @samp{sifive-e76}, | |
29556 | @samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54}, @samp{sifive-s76}, | |
aa37a91c | 29557 | @samp{sifive-u54}, and @samp{sifive-u74}. |
d77de738 | 29558 | |
d77de738 | 29559 | @opindex mtune |
ddf6fe37 | 29560 | @item -mtune=@var{processor-string} |
d77de738 ML |
29561 | Optimize the output for the given processor, specified by microarchitecture or |
29562 | particular CPU name. Permissible values for this option are: @samp{rocket}, | |
29563 | @samp{sifive-3-series}, @samp{sifive-5-series}, @samp{sifive-7-series}, | |
aa37a91c | 29564 | @samp{thead-c906}, @samp{size}, and all valid options for @option{-mcpu=}. |
d77de738 ML |
29565 | |
29566 | When @option{-mtune=} is not specified, use the setting from @option{-mcpu}, | |
29567 | the default is @samp{rocket} if both are not specified. | |
29568 | ||
29569 | The @samp{size} choice is not intended for use by end-users. This is used | |
29570 | when @option{-Os} is specified. It overrides the instruction cost info | |
29571 | provided by @option{-mtune=}, but does not override the pipeline info. This | |
29572 | helps reduce code size while still giving good performance. | |
29573 | ||
d77de738 | 29574 | @opindex mpreferred-stack-boundary |
ddf6fe37 | 29575 | @item -mpreferred-stack-boundary=@var{num} |
d77de738 ML |
29576 | Attempt to keep the stack boundary aligned to a 2 raised to @var{num} |
29577 | byte boundary. If @option{-mpreferred-stack-boundary} is not specified, | |
29578 | the default is 4 (16 bytes or 128-bits). | |
29579 | ||
29580 | @strong{Warning:} If you use this switch, then you must build all modules with | |
29581 | the same value, including any libraries. This includes the system libraries | |
29582 | and startup modules. | |
29583 | ||
d77de738 | 29584 | @opindex msmall-data-limit |
ddf6fe37 | 29585 | @item -msmall-data-limit=@var{n} |
d77de738 ML |
29586 | Put global and static data smaller than @var{n} bytes into a special section |
29587 | (on some targets). | |
29588 | ||
ddf6fe37 | 29589 | @opindex msave-restore |
d77de738 ML |
29590 | @item -msave-restore |
29591 | @itemx -mno-save-restore | |
d77de738 ML |
29592 | Do or don't use smaller but slower prologue and epilogue code that uses |
29593 | library function calls. The default is to use fast inline prologues and | |
29594 | epilogues. | |
29595 | ||
f797260a PN |
29596 | @opindex minline-atomics |
29597 | @item -minline-atomics | |
29598 | @itemx -mno-inline-atomics | |
29599 | Do or don't use smaller but slower subword atomic emulation code that uses | |
29600 | libatomic function calls. The default is to use fast inline subword atomics | |
29601 | that do not require libatomic. | |
29602 | ||
df48285b CM |
29603 | @opindex minline-strlen |
29604 | @item -minline-strlen | |
29605 | @itemx -mno-inline-strlen | |
29606 | Do or do not attempt to inline strlen calls if possible. | |
29607 | Inlining will only be done if the string is properly aligned | |
29608 | and instructions for accelerated processing are available. | |
29609 | The default is to not inline strlen calls. | |
29610 | ||
949f1ccf CM |
29611 | @opindex minline-strcmp |
29612 | @item -minline-strcmp | |
29613 | @itemx -mno-inline-strcmp | |
29614 | Do or do not attempt to inline strcmp calls if possible. | |
29615 | Inlining will only be done if the strings are properly aligned | |
29616 | and instructions for accelerated processing are available. | |
29617 | The default is to not inline strcmp calls. | |
29618 | ||
29619 | @opindex minline-strncmp | |
29620 | @item -minline-strncmp | |
29621 | @itemx -mno-inline-strncmp | |
29622 | Do or do not attempt to inline strncmp calls if possible. | |
29623 | Inlining will only be done if the strings are properly aligned | |
29624 | and instructions for accelerated processing are available. | |
29625 | The default is to not inline strncmp calls. | |
29626 | ||
ddf6fe37 | 29627 | @opindex mshorten-memrefs |
d77de738 ML |
29628 | @item -mshorten-memrefs |
29629 | @itemx -mno-shorten-memrefs | |
d77de738 ML |
29630 | Do or do not attempt to make more use of compressed load/store instructions by |
29631 | replacing a load/store of 'base register + large offset' with a new load/store | |
29632 | of 'new base + small offset'. If the new base gets stored in a compressed | |
29633 | register, then the new load/store can be compressed. Currently targets 32-bit | |
29634 | integer load/stores only. | |
29635 | ||
ddf6fe37 | 29636 | @opindex mstrict-align |
d77de738 ML |
29637 | @item -mstrict-align |
29638 | @itemx -mno-strict-align | |
d77de738 ML |
29639 | Do not or do generate unaligned memory accesses. The default is set depending |
29640 | on whether the processor we are optimizing for supports fast unaligned access | |
29641 | or not. | |
29642 | ||
d77de738 | 29643 | @opindex mcmodel=medlow |
ddf6fe37 | 29644 | @item -mcmodel=medlow |
d77de738 ML |
29645 | Generate code for the medium-low code model. The program and its statically |
29646 | defined symbols must lie within a single 2 GiB address range and must lie | |
29647 | between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be | |
29648 | statically or dynamically linked. This is the default code model. | |
29649 | ||
d77de738 | 29650 | @opindex mcmodel=medany |
ddf6fe37 | 29651 | @item -mcmodel=medany |
d77de738 ML |
29652 | Generate code for the medium-any code model. The program and its statically |
29653 | defined symbols must be within any single 2 GiB address range. Programs can be | |
29654 | statically or dynamically linked. | |
29655 | ||
29656 | The code generated by the medium-any code model is position-independent, but is | |
29657 | not guaranteed to function correctly when linked into position-independent | |
29658 | executables or libraries. | |
29659 | ||
29660 | @item -mexplicit-relocs | |
29661 | @itemx -mno-exlicit-relocs | |
29662 | Use or do not use assembler relocation operators when dealing with symbolic | |
29663 | addresses. The alternative is to use assembler macros instead, which may | |
29664 | limit optimization. | |
29665 | ||
ddf6fe37 | 29666 | @opindex mrelax |
d77de738 ML |
29667 | @item -mrelax |
29668 | @itemx -mno-relax | |
d77de738 ML |
29669 | Take advantage of linker relaxations to reduce the number of instructions |
29670 | required to materialize symbol addresses. The default is to take advantage of | |
29671 | linker relaxations. | |
29672 | ||
ddf6fe37 | 29673 | @opindex mriscv-attribute |
d77de738 ML |
29674 | @item -mriscv-attribute |
29675 | @itemx -mno-riscv-attribute | |
d77de738 ML |
29676 | Emit (do not emit) RISC-V attribute to record extra information into ELF |
29677 | objects. This feature requires at least binutils 2.32. | |
29678 | ||
ddf6fe37 | 29679 | @opindex mcsr-check |
d77de738 ML |
29680 | @item -mcsr-check |
29681 | @itemx -mno-csr-check | |
d77de738 ML |
29682 | Enables or disables the CSR checking. |
29683 | ||
d77de738 | 29684 | @opindex malign-data |
ddf6fe37 | 29685 | @item -malign-data=@var{type} |
d77de738 ML |
29686 | Control how GCC aligns variables and constants of array, structure, or union |
29687 | types. Supported values for @var{type} are @samp{xlen} which uses x register | |
29688 | width as the alignment value, and @samp{natural} which uses natural alignment. | |
29689 | @samp{xlen} is the default. | |
29690 | ||
d77de738 | 29691 | @opindex mbig-endian |
ddf6fe37 | 29692 | @item -mbig-endian |
d77de738 ML |
29693 | Generate big-endian code. This is the default when GCC is configured for a |
29694 | @samp{riscv64be-*-*} or @samp{riscv32be-*-*} target. | |
29695 | ||
d77de738 | 29696 | @opindex mlittle-endian |
ddf6fe37 | 29697 | @item -mlittle-endian |
d77de738 ML |
29698 | Generate little-endian code. This is the default when GCC is configured for a |
29699 | @samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or | |
29700 | @samp{riscv32be-*-*} target. | |
29701 | ||
d77de738 ML |
29702 | @opindex mstack-protector-guard |
29703 | @opindex mstack-protector-guard-reg | |
29704 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
29705 | @item -mstack-protector-guard=@var{guard} |
29706 | @itemx -mstack-protector-guard-reg=@var{reg} | |
29707 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
29708 | Generate stack protection code using canary at @var{guard}. Supported |
29709 | locations are @samp{global} for a global canary or @samp{tls} for per-thread | |
29710 | canary in the TLS block. | |
29711 | ||
29712 | With the latter choice the options | |
29713 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
29714 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
29715 | which register to use as base register for reading the canary, | |
29716 | and from what offset from that base register. There is no default | |
29717 | register or offset as this is entirely for use within the Linux | |
29718 | kernel. | |
29719 | @end table | |
29720 | ||
29721 | @node RL78 Options | |
29722 | @subsection RL78 Options | |
29723 | @cindex RL78 Options | |
29724 | ||
29725 | @table @gcctabopt | |
29726 | ||
d77de738 | 29727 | @opindex msim |
ddf6fe37 | 29728 | @item -msim |
d77de738 ML |
29729 | Links in additional target libraries to support operation within a |
29730 | simulator. | |
29731 | ||
ddf6fe37 | 29732 | @opindex mmul |
d77de738 ML |
29733 | @item -mmul=none |
29734 | @itemx -mmul=g10 | |
29735 | @itemx -mmul=g13 | |
29736 | @itemx -mmul=g14 | |
29737 | @itemx -mmul=rl78 | |
d77de738 ML |
29738 | Specifies the type of hardware multiplication and division support to |
29739 | be used. The simplest is @code{none}, which uses software for both | |
29740 | multiplication and division. This is the default. The @code{g13} | |
29741 | value is for the hardware multiply/divide peripheral found on the | |
29742 | RL78/G13 (S2 core) targets. The @code{g14} value selects the use of | |
29743 | the multiplication and division instructions supported by the RL78/G14 | |
29744 | (S3 core) parts. The value @code{rl78} is an alias for @code{g14} and | |
29745 | the value @code{mg10} is an alias for @code{none}. | |
29746 | ||
29747 | In addition a C preprocessor macro is defined, based upon the setting | |
29748 | of this option. Possible values are: @code{__RL78_MUL_NONE__}, | |
29749 | @code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}. | |
29750 | ||
ddf6fe37 | 29751 | @opindex mcpu |
d77de738 ML |
29752 | @item -mcpu=g10 |
29753 | @itemx -mcpu=g13 | |
29754 | @itemx -mcpu=g14 | |
29755 | @itemx -mcpu=rl78 | |
d77de738 ML |
29756 | Specifies the RL78 core to target. The default is the G14 core, also |
29757 | known as an S3 core or just RL78. The G13 or S2 core does not have | |
29758 | multiply or divide instructions, instead it uses a hardware peripheral | |
29759 | for these operations. The G10 or S1 core does not have register | |
29760 | banks, so it uses a different calling convention. | |
29761 | ||
29762 | If this option is set it also selects the type of hardware multiply | |
29763 | support to use, unless this is overridden by an explicit | |
29764 | @option{-mmul=none} option on the command line. Thus specifying | |
29765 | @option{-mcpu=g13} enables the use of the G13 hardware multiply | |
29766 | peripheral and specifying @option{-mcpu=g10} disables the use of | |
29767 | hardware multiplications altogether. | |
29768 | ||
29769 | Note, although the RL78/G14 core is the default target, specifying | |
29770 | @option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does | |
29771 | change the behavior of the toolchain since it also enables G14 | |
29772 | hardware multiply support. If these options are not specified on the | |
29773 | command line then software multiplication routines will be used even | |
29774 | though the code targets the RL78 core. This is for backwards | |
29775 | compatibility with older toolchains which did not have hardware | |
29776 | multiply and divide support. | |
29777 | ||
29778 | In addition a C preprocessor macro is defined, based upon the setting | |
29779 | of this option. Possible values are: @code{__RL78_G10__}, | |
29780 | @code{__RL78_G13__} or @code{__RL78_G14__}. | |
29781 | ||
d77de738 ML |
29782 | @opindex mg10 |
29783 | @opindex mg13 | |
29784 | @opindex mg14 | |
29785 | @opindex mrl78 | |
ddf6fe37 AA |
29786 | @item -mg10 |
29787 | @itemx -mg13 | |
29788 | @itemx -mg14 | |
29789 | @itemx -mrl78 | |
d77de738 ML |
29790 | These are aliases for the corresponding @option{-mcpu=} option. They |
29791 | are provided for backwards compatibility. | |
29792 | ||
d77de738 | 29793 | @opindex mallregs |
ddf6fe37 | 29794 | @item -mallregs |
d77de738 ML |
29795 | Allow the compiler to use all of the available registers. By default |
29796 | registers @code{r24..r31} are reserved for use in interrupt handlers. | |
29797 | With this option enabled these registers can be used in ordinary | |
29798 | functions as well. | |
29799 | ||
d77de738 ML |
29800 | @opindex m64bit-doubles |
29801 | @opindex m32bit-doubles | |
ddf6fe37 AA |
29802 | @item -m64bit-doubles |
29803 | @itemx -m32bit-doubles | |
d77de738 ML |
29804 | Make the @code{double} data type be 64 bits (@option{-m64bit-doubles}) |
29805 | or 32 bits (@option{-m32bit-doubles}) in size. The default is | |
29806 | @option{-m32bit-doubles}. | |
29807 | ||
d77de738 ML |
29808 | @opindex msave-mduc-in-interrupts |
29809 | @opindex mno-save-mduc-in-interrupts | |
ddf6fe37 AA |
29810 | @item -msave-mduc-in-interrupts |
29811 | @itemx -mno-save-mduc-in-interrupts | |
d77de738 ML |
29812 | Specifies that interrupt handler functions should preserve the |
29813 | MDUC registers. This is only necessary if normal code might use | |
29814 | the MDUC registers, for example because it performs multiplication | |
29815 | and division operations. The default is to ignore the MDUC registers | |
29816 | as this makes the interrupt handlers faster. The target option -mg13 | |
29817 | needs to be passed for this to work as this feature is only available | |
29818 | on the G13 target (S2 core). The MDUC registers will only be saved | |
29819 | if the interrupt handler performs a multiplication or division | |
29820 | operation or it calls another function. | |
29821 | ||
29822 | @end table | |
29823 | ||
29824 | @node RS/6000 and PowerPC Options | |
29825 | @subsection IBM RS/6000 and PowerPC Options | |
29826 | @cindex RS/6000 and PowerPC Options | |
29827 | @cindex IBM RS/6000 and PowerPC Options | |
29828 | ||
29829 | These @samp{-m} options are defined for the IBM RS/6000 and PowerPC: | |
29830 | @table @gcctabopt | |
29831 | @item -mpowerpc-gpopt | |
29832 | @itemx -mno-powerpc-gpopt | |
29833 | @itemx -mpowerpc-gfxopt | |
29834 | @itemx -mno-powerpc-gfxopt | |
29835 | @need 800 | |
29836 | @itemx -mpowerpc64 | |
29837 | @itemx -mno-powerpc64 | |
29838 | @itemx -mmfcrf | |
29839 | @itemx -mno-mfcrf | |
29840 | @itemx -mpopcntb | |
29841 | @itemx -mno-popcntb | |
29842 | @itemx -mpopcntd | |
29843 | @itemx -mno-popcntd | |
29844 | @itemx -mfprnd | |
29845 | @itemx -mno-fprnd | |
29846 | @need 800 | |
d77de738 ML |
29847 | @opindex mpowerpc-gpopt |
29848 | @opindex mno-powerpc-gpopt | |
29849 | @opindex mpowerpc-gfxopt | |
29850 | @opindex mno-powerpc-gfxopt | |
29851 | @opindex mpowerpc64 | |
29852 | @opindex mno-powerpc64 | |
29853 | @opindex mmfcrf | |
29854 | @opindex mno-mfcrf | |
29855 | @opindex mpopcntb | |
29856 | @opindex mno-popcntb | |
29857 | @opindex mpopcntd | |
29858 | @opindex mno-popcntd | |
29859 | @opindex mfprnd | |
29860 | @opindex mno-fprnd | |
29861 | @opindex mcmpb | |
29862 | @opindex mno-cmpb | |
29863 | @opindex mhard-dfp | |
29864 | @opindex mno-hard-dfp | |
ddf6fe37 AA |
29865 | @itemx -mcmpb |
29866 | @itemx -mno-cmpb | |
29867 | @itemx -mhard-dfp | |
29868 | @itemx -mno-hard-dfp | |
d77de738 ML |
29869 | You use these options to specify which instructions are available on the |
29870 | processor you are using. The default value of these options is | |
29871 | determined when configuring GCC@. Specifying the | |
29872 | @option{-mcpu=@var{cpu_type}} overrides the specification of these | |
29873 | options. We recommend you use the @option{-mcpu=@var{cpu_type}} option | |
29874 | rather than the options listed above. | |
29875 | ||
29876 | Specifying @option{-mpowerpc-gpopt} allows | |
29877 | GCC to use the optional PowerPC architecture instructions in the | |
29878 | General Purpose group, including floating-point square root. Specifying | |
29879 | @option{-mpowerpc-gfxopt} allows GCC to | |
29880 | use the optional PowerPC architecture instructions in the Graphics | |
29881 | group, including floating-point select. | |
29882 | ||
29883 | The @option{-mmfcrf} option allows GCC to generate the move from | |
29884 | condition register field instruction implemented on the POWER4 | |
29885 | processor and other processors that support the PowerPC V2.01 | |
29886 | architecture. | |
29887 | The @option{-mpopcntb} option allows GCC to generate the popcount and | |
29888 | double-precision FP reciprocal estimate instruction implemented on the | |
29889 | POWER5 processor and other processors that support the PowerPC V2.02 | |
29890 | architecture. | |
29891 | The @option{-mpopcntd} option allows GCC to generate the popcount | |
29892 | instruction implemented on the POWER7 processor and other processors | |
29893 | that support the PowerPC V2.06 architecture. | |
29894 | The @option{-mfprnd} option allows GCC to generate the FP round to | |
29895 | integer instructions implemented on the POWER5+ processor and other | |
29896 | processors that support the PowerPC V2.03 architecture. | |
29897 | The @option{-mcmpb} option allows GCC to generate the compare bytes | |
29898 | instruction implemented on the POWER6 processor and other processors | |
29899 | that support the PowerPC V2.05 architecture. | |
29900 | The @option{-mhard-dfp} option allows GCC to generate the decimal | |
29901 | floating-point instructions implemented on some POWER processors. | |
29902 | ||
29903 | The @option{-mpowerpc64} option allows GCC to generate the additional | |
29904 | 64-bit instructions that are found in the full PowerPC64 architecture | |
29905 | and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to | |
29906 | @option{-mno-powerpc64}. | |
29907 | ||
d77de738 | 29908 | @opindex mcpu |
ddf6fe37 | 29909 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
29910 | Set architecture type, register usage, and |
29911 | instruction scheduling parameters for machine type @var{cpu_type}. | |
29912 | Supported values for @var{cpu_type} are @samp{401}, @samp{403}, | |
29913 | @samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp}, | |
29914 | @samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603}, | |
29915 | @samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740}, | |
29916 | @samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823}, | |
29917 | @samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2}, | |
29918 | @samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500}, | |
29919 | @samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5}, | |
29920 | @samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+}, | |
29921 | @samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8}, | |
29922 | @samp{power9}, @samp{power10}, @samp{powerpc}, @samp{powerpc64}, | |
29923 | @samp{powerpc64le}, @samp{rs64}, and @samp{native}. | |
29924 | ||
29925 | @option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and | |
29926 | @option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either | |
29927 | endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC | |
29928 | architecture machine types, with an appropriate, generic processor | |
29929 | model assumed for scheduling purposes. | |
29930 | ||
29931 | Specifying @samp{native} as cpu type detects and selects the | |
29932 | architecture option that corresponds to the host processor of the | |
29933 | system performing the compilation. | |
29934 | @option{-mcpu=native} has no effect if GCC does not recognize the | |
29935 | processor. | |
29936 | ||
29937 | The other options specify a specific processor. Code generated under | |
29938 | those options runs best on that processor, and may not run at all on | |
29939 | others. | |
29940 | ||
29941 | The @option{-mcpu} options automatically enable or disable the | |
29942 | following options: | |
29943 | ||
43b72ede AA |
29944 | @gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple |
29945 | -mpopcntb -mpopcntd -mpowerpc64 | |
29946 | -mpowerpc-gpopt -mpowerpc-gfxopt | |
29947 | -mmulhw -mdlmzb -mmfpgpr -mvsx | |
29948 | -mcrypto -mhtm -mpower8-fusion -mpower8-vector | |
29949 | -mquad-memory -mquad-memory-atomic -mfloat128 | |
29950 | -mfloat128-hardware -mprefixed -mpcrel -mmma | |
d77de738 ML |
29951 | -mrop-protect} |
29952 | ||
29953 | The particular options set for any particular CPU varies between | |
29954 | compiler versions, depending on what setting seems to produce optimal | |
29955 | code for that CPU; it doesn't necessarily reflect the actual hardware's | |
29956 | capabilities. If you wish to set an individual option to a particular | |
29957 | value, you may specify it after the @option{-mcpu} option, like | |
29958 | @option{-mcpu=970 -mno-altivec}. | |
29959 | ||
29960 | On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are | |
29961 | not enabled or disabled by the @option{-mcpu} option at present because | |
29962 | AIX does not have full support for these options. You may still | |
29963 | enable or disable them individually if you're sure it'll work in your | |
29964 | environment. | |
29965 | ||
d77de738 | 29966 | @opindex mtune |
ddf6fe37 | 29967 | @item -mtune=@var{cpu_type} |
d77de738 ML |
29968 | Set the instruction scheduling parameters for machine type |
29969 | @var{cpu_type}, but do not set the architecture type or register usage, | |
29970 | as @option{-mcpu=@var{cpu_type}} does. The same | |
29971 | values for @var{cpu_type} are used for @option{-mtune} as for | |
29972 | @option{-mcpu}. If both are specified, the code generated uses the | |
29973 | architecture and registers set by @option{-mcpu}, but the | |
29974 | scheduling parameters set by @option{-mtune}. | |
29975 | ||
d77de738 | 29976 | @opindex mcmodel=small |
ddf6fe37 | 29977 | @item -mcmodel=small |
d77de738 ML |
29978 | Generate PowerPC64 code for the small model: The TOC is limited to |
29979 | 64k. | |
29980 | ||
d77de738 | 29981 | @opindex mcmodel=medium |
ddf6fe37 | 29982 | @item -mcmodel=medium |
d77de738 ML |
29983 | Generate PowerPC64 code for the medium model: The TOC and other static |
29984 | data may be up to a total of 4G in size. This is the default for 64-bit | |
29985 | Linux. | |
29986 | ||
d77de738 | 29987 | @opindex mcmodel=large |
ddf6fe37 | 29988 | @item -mcmodel=large |
d77de738 ML |
29989 | Generate PowerPC64 code for the large model: The TOC may be up to 4G |
29990 | in size. Other data and code is only limited by the 64-bit address | |
29991 | space. | |
29992 | ||
d77de738 ML |
29993 | @opindex maltivec |
29994 | @opindex mno-altivec | |
ddf6fe37 AA |
29995 | @item -maltivec |
29996 | @itemx -mno-altivec | |
d77de738 ML |
29997 | Generate code that uses (does not use) AltiVec instructions, and also |
29998 | enable the use of built-in functions that allow more direct access to | |
29999 | the AltiVec instruction set. You may also need to set | |
30000 | @option{-mabi=altivec} to adjust the current ABI with AltiVec ABI | |
30001 | enhancements. | |
30002 | ||
30003 | When @option{-maltivec} is used, the element order for AltiVec intrinsics | |
30004 | such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert} | |
30005 | match array element order corresponding to the endianness of the | |
30006 | target. That is, element zero identifies the leftmost element in a | |
30007 | vector register when targeting a big-endian platform, and identifies | |
30008 | the rightmost element in a vector register when targeting a | |
30009 | little-endian platform. | |
30010 | ||
d77de738 ML |
30011 | @opindex mvrsave |
30012 | @opindex mno-vrsave | |
ddf6fe37 AA |
30013 | @item -mvrsave |
30014 | @itemx -mno-vrsave | |
d77de738 ML |
30015 | Generate VRSAVE instructions when generating AltiVec code. |
30016 | ||
d77de738 | 30017 | @opindex msecure-plt |
ddf6fe37 | 30018 | @item -msecure-plt |
d77de738 ML |
30019 | Generate code that allows @command{ld} and @command{ld.so} |
30020 | to build executables and shared | |
30021 | libraries with non-executable @code{.plt} and @code{.got} sections. | |
30022 | This is a PowerPC | |
30023 | 32-bit SYSV ABI option. | |
30024 | ||
d77de738 | 30025 | @opindex mbss-plt |
ddf6fe37 | 30026 | @item -mbss-plt |
d77de738 ML |
30027 | Generate code that uses a BSS @code{.plt} section that @command{ld.so} |
30028 | fills in, and | |
30029 | requires @code{.plt} and @code{.got} | |
30030 | sections that are both writable and executable. | |
30031 | This is a PowerPC 32-bit SYSV ABI option. | |
30032 | ||
d77de738 ML |
30033 | @opindex misel |
30034 | @opindex mno-isel | |
ddf6fe37 AA |
30035 | @item -misel |
30036 | @itemx -mno-isel | |
d77de738 ML |
30037 | This switch enables or disables the generation of ISEL instructions. |
30038 | ||
d77de738 ML |
30039 | @opindex mvsx |
30040 | @opindex mno-vsx | |
ddf6fe37 AA |
30041 | @item -mvsx |
30042 | @itemx -mno-vsx | |
d77de738 ML |
30043 | Generate code that uses (does not use) vector/scalar (VSX) |
30044 | instructions, and also enable the use of built-in functions that allow | |
30045 | more direct access to the VSX instruction set. | |
30046 | ||
d77de738 ML |
30047 | @opindex mcrypto |
30048 | @opindex mno-crypto | |
ddf6fe37 AA |
30049 | @item -mcrypto |
30050 | @itemx -mno-crypto | |
d77de738 ML |
30051 | Enable the use (disable) of the built-in functions that allow direct |
30052 | access to the cryptographic instructions that were added in version | |
30053 | 2.07 of the PowerPC ISA. | |
30054 | ||
d77de738 ML |
30055 | @opindex mhtm |
30056 | @opindex mno-htm | |
ddf6fe37 AA |
30057 | @item -mhtm |
30058 | @itemx -mno-htm | |
d77de738 ML |
30059 | Enable (disable) the use of the built-in functions that allow direct |
30060 | access to the Hardware Transactional Memory (HTM) instructions that | |
30061 | were added in version 2.07 of the PowerPC ISA. | |
30062 | ||
d77de738 ML |
30063 | @opindex mpower8-fusion |
30064 | @opindex mno-power8-fusion | |
ddf6fe37 AA |
30065 | @item -mpower8-fusion |
30066 | @itemx -mno-power8-fusion | |
d77de738 ML |
30067 | Generate code that keeps (does not keeps) some integer operations |
30068 | adjacent so that the instructions can be fused together on power8 and | |
30069 | later processors. | |
30070 | ||
d77de738 ML |
30071 | @opindex mpower8-vector |
30072 | @opindex mno-power8-vector | |
ddf6fe37 AA |
30073 | @item -mpower8-vector |
30074 | @itemx -mno-power8-vector | |
d77de738 ML |
30075 | Generate code that uses (does not use) the vector and scalar |
30076 | instructions that were added in version 2.07 of the PowerPC ISA. Also | |
30077 | enable the use of built-in functions that allow more direct access to | |
30078 | the vector instructions. | |
30079 | ||
d77de738 ML |
30080 | @opindex mquad-memory |
30081 | @opindex mno-quad-memory | |
ddf6fe37 AA |
30082 | @item -mquad-memory |
30083 | @itemx -mno-quad-memory | |
d77de738 ML |
30084 | Generate code that uses (does not use) the non-atomic quad word memory |
30085 | instructions. The @option{-mquad-memory} option requires use of | |
30086 | 64-bit mode. | |
30087 | ||
d77de738 ML |
30088 | @opindex mquad-memory-atomic |
30089 | @opindex mno-quad-memory-atomic | |
ddf6fe37 AA |
30090 | @item -mquad-memory-atomic |
30091 | @itemx -mno-quad-memory-atomic | |
d77de738 ML |
30092 | Generate code that uses (does not use) the atomic quad word memory |
30093 | instructions. The @option{-mquad-memory-atomic} option requires use of | |
30094 | 64-bit mode. | |
30095 | ||
d77de738 ML |
30096 | @opindex mfloat128 |
30097 | @opindex mno-float128 | |
ddf6fe37 AA |
30098 | @item -mfloat128 |
30099 | @itemx -mno-float128 | |
d77de738 ML |
30100 | Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point |
30101 | and use either software emulation for IEEE 128-bit floating point or | |
30102 | hardware instructions. | |
30103 | ||
30104 | The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE | |
30105 | 128-bit floating point support. The IEEE 128-bit floating point is only | |
30106 | supported on Linux. | |
30107 | ||
30108 | The default for @option{-mfloat128} is enabled on PowerPC Linux | |
30109 | systems using the VSX instruction set, and disabled on other systems. | |
30110 | ||
30111 | If you use the ISA 3.0 instruction set (@option{-mpower9-vector} or | |
30112 | @option{-mcpu=power9}) on a 64-bit system, the IEEE 128-bit floating | |
30113 | point support will also enable the generation of ISA 3.0 IEEE 128-bit | |
30114 | floating point instructions. Otherwise, if you do not specify to | |
30115 | generate ISA 3.0 instructions or you are targeting a 32-bit big endian | |
30116 | system, IEEE 128-bit floating point will be done with software | |
30117 | emulation. | |
30118 | ||
d77de738 ML |
30119 | @opindex mfloat128-hardware |
30120 | @opindex mno-float128-hardware | |
ddf6fe37 AA |
30121 | @item -mfloat128-hardware |
30122 | @itemx -mno-float128-hardware | |
d77de738 ML |
30123 | Enable/disable using ISA 3.0 hardware instructions to support the |
30124 | @var{__float128} data type. | |
30125 | ||
30126 | The default for @option{-mfloat128-hardware} is enabled on PowerPC | |
30127 | Linux systems using the ISA 3.0 instruction set, and disabled on other | |
30128 | systems. | |
30129 | ||
d77de738 ML |
30130 | @opindex m32 |
30131 | @opindex m64 | |
ddf6fe37 AA |
30132 | @item -m32 |
30133 | @itemx -m64 | |
d77de738 ML |
30134 | Generate code for 32-bit or 64-bit environments of Darwin and SVR4 |
30135 | targets (including GNU/Linux). The 32-bit environment sets int, long | |
30136 | and pointer to 32 bits and generates code that runs on any PowerPC | |
30137 | variant. The 64-bit environment sets int to 32 bits and long and | |
30138 | pointer to 64 bits, and generates code for PowerPC64, as for | |
30139 | @option{-mpowerpc64}. | |
30140 | ||
d77de738 ML |
30141 | @opindex mfull-toc |
30142 | @opindex mno-fp-in-toc | |
30143 | @opindex mno-sum-in-toc | |
30144 | @opindex mminimal-toc | |
ddf6fe37 AA |
30145 | @item -mfull-toc |
30146 | @itemx -mno-fp-in-toc | |
30147 | @itemx -mno-sum-in-toc | |
30148 | @itemx -mminimal-toc | |
d77de738 ML |
30149 | Modify generation of the TOC (Table Of Contents), which is created for |
30150 | every executable file. The @option{-mfull-toc} option is selected by | |
30151 | default. In that case, GCC allocates at least one TOC entry for | |
30152 | each unique non-automatic variable reference in your program. GCC | |
30153 | also places floating-point constants in the TOC@. However, only | |
30154 | 16,384 entries are available in the TOC@. | |
30155 | ||
30156 | If you receive a linker error message that saying you have overflowed | |
30157 | the available TOC space, you can reduce the amount of TOC space used | |
30158 | with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options. | |
30159 | @option{-mno-fp-in-toc} prevents GCC from putting floating-point | |
30160 | constants in the TOC and @option{-mno-sum-in-toc} forces GCC to | |
30161 | generate code to calculate the sum of an address and a constant at | |
30162 | run time instead of putting that sum into the TOC@. You may specify one | |
30163 | or both of these options. Each causes GCC to produce very slightly | |
30164 | slower and larger code at the expense of conserving TOC space. | |
30165 | ||
30166 | If you still run out of space in the TOC even when you specify both of | |
30167 | these options, specify @option{-mminimal-toc} instead. This option causes | |
30168 | GCC to make only one TOC entry for every file. When you specify this | |
30169 | option, GCC produces code that is slower and larger but which | |
30170 | uses extremely little TOC space. You may wish to use this option | |
30171 | only on files that contain less frequently-executed code. | |
30172 | ||
d77de738 ML |
30173 | @opindex maix64 |
30174 | @opindex maix32 | |
ddf6fe37 AA |
30175 | @item -maix64 |
30176 | @itemx -maix32 | |
d77de738 ML |
30177 | Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit |
30178 | @code{long} type, and the infrastructure needed to support them. | |
30179 | Specifying @option{-maix64} implies @option{-mpowerpc64}, | |
30180 | while @option{-maix32} disables the 64-bit ABI and | |
30181 | implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}. | |
30182 | ||
d77de738 ML |
30183 | @opindex mxl-compat |
30184 | @opindex mno-xl-compat | |
ddf6fe37 AA |
30185 | @item -mxl-compat |
30186 | @itemx -mno-xl-compat | |
d77de738 ML |
30187 | Produce code that conforms more closely to IBM XL compiler semantics |
30188 | when using AIX-compatible ABI@. Pass floating-point arguments to | |
30189 | prototyped functions beyond the register save area (RSA) on the stack | |
30190 | in addition to argument FPRs. Do not assume that most significant | |
30191 | double in 128-bit long double value is properly rounded when comparing | |
30192 | values and converting to double. Use XL symbol names for long double | |
30193 | support routines. | |
30194 | ||
30195 | The AIX calling convention was extended but not initially documented to | |
30196 | handle an obscure K&R C case of calling a function that takes the | |
30197 | address of its arguments with fewer arguments than declared. IBM XL | |
30198 | compilers access floating-point arguments that do not fit in the | |
30199 | RSA from the stack when a subroutine is compiled without | |
30200 | optimization. Because always storing floating-point arguments on the | |
30201 | stack is inefficient and rarely needed, this option is not enabled by | |
30202 | default and only is necessary when calling subroutines compiled by IBM | |
30203 | XL compilers without optimization. | |
30204 | ||
d77de738 | 30205 | @opindex mpe |
ddf6fe37 | 30206 | @item -mpe |
d77de738 ML |
30207 | Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an |
30208 | application written to use message passing with special startup code to | |
30209 | enable the application to run. The system must have PE installed in the | |
30210 | standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file | |
30211 | must be overridden with the @option{-specs=} option to specify the | |
30212 | appropriate directory location. The Parallel Environment does not | |
30213 | support threads, so the @option{-mpe} option and the @option{-pthread} | |
30214 | option are incompatible. | |
30215 | ||
d77de738 ML |
30216 | @opindex malign-natural |
30217 | @opindex malign-power | |
ddf6fe37 AA |
30218 | @item -malign-natural |
30219 | @itemx -malign-power | |
d77de738 ML |
30220 | On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option |
30221 | @option{-malign-natural} overrides the ABI-defined alignment of larger | |
30222 | types, such as floating-point doubles, on their natural size-based boundary. | |
30223 | The option @option{-malign-power} instructs GCC to follow the ABI-specified | |
30224 | alignment rules. GCC defaults to the standard alignment defined in the ABI@. | |
30225 | ||
30226 | On 64-bit Darwin, natural alignment is the default, and @option{-malign-power} | |
30227 | is not supported. | |
30228 | ||
d77de738 ML |
30229 | @opindex msoft-float |
30230 | @opindex mhard-float | |
ddf6fe37 AA |
30231 | @item -msoft-float |
30232 | @itemx -mhard-float | |
d77de738 ML |
30233 | Generate code that does not use (uses) the floating-point register set. |
30234 | Software floating-point emulation is provided if you use the | |
30235 | @option{-msoft-float} option, and pass the option to GCC when linking. | |
30236 | ||
d77de738 ML |
30237 | @opindex mmultiple |
30238 | @opindex mno-multiple | |
ddf6fe37 AA |
30239 | @item -mmultiple |
30240 | @itemx -mno-multiple | |
d77de738 ML |
30241 | Generate code that uses (does not use) the load multiple word |
30242 | instructions and the store multiple word instructions. These | |
30243 | instructions are generated by default on POWER systems, and not | |
30244 | generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian | |
30245 | PowerPC systems, since those instructions do not work when the | |
30246 | processor is in little-endian mode. The exceptions are PPC740 and | |
30247 | PPC750 which permit these instructions in little-endian mode. | |
30248 | ||
d77de738 ML |
30249 | @opindex mupdate |
30250 | @opindex mno-update | |
ddf6fe37 AA |
30251 | @item -mupdate |
30252 | @itemx -mno-update | |
d77de738 ML |
30253 | Generate code that uses (does not use) the load or store instructions |
30254 | that update the base register to the address of the calculated memory | |
30255 | location. These instructions are generated by default. If you use | |
30256 | @option{-mno-update}, there is a small window between the time that the | |
30257 | stack pointer is updated and the address of the previous frame is | |
30258 | stored, which means code that walks the stack frame across interrupts or | |
30259 | signals may get corrupted data. | |
30260 | ||
d77de738 ML |
30261 | @opindex mavoid-indexed-addresses |
30262 | @opindex mno-avoid-indexed-addresses | |
ddf6fe37 AA |
30263 | @item -mavoid-indexed-addresses |
30264 | @itemx -mno-avoid-indexed-addresses | |
d77de738 ML |
30265 | Generate code that tries to avoid (not avoid) the use of indexed load |
30266 | or store instructions. These instructions can incur a performance | |
30267 | penalty on Power6 processors in certain situations, such as when | |
30268 | stepping through large arrays that cross a 16M boundary. This option | |
30269 | is enabled by default when targeting Power6 and disabled otherwise. | |
30270 | ||
d77de738 ML |
30271 | @opindex mfused-madd |
30272 | @opindex mno-fused-madd | |
ddf6fe37 AA |
30273 | @item -mfused-madd |
30274 | @itemx -mno-fused-madd | |
d77de738 ML |
30275 | Generate code that uses (does not use) the floating-point multiply and |
30276 | accumulate instructions. These instructions are generated by default | |
30277 | if hardware floating point is used. The machine-dependent | |
30278 | @option{-mfused-madd} option is now mapped to the machine-independent | |
30279 | @option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is | |
30280 | mapped to @option{-ffp-contract=off}. | |
30281 | ||
d77de738 ML |
30282 | @opindex mmulhw |
30283 | @opindex mno-mulhw | |
ddf6fe37 AA |
30284 | @item -mmulhw |
30285 | @itemx -mno-mulhw | |
d77de738 ML |
30286 | Generate code that uses (does not use) the half-word multiply and |
30287 | multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors. | |
30288 | These instructions are generated by default when targeting those | |
30289 | processors. | |
30290 | ||
d77de738 ML |
30291 | @opindex mdlmzb |
30292 | @opindex mno-dlmzb | |
ddf6fe37 AA |
30293 | @item -mdlmzb |
30294 | @itemx -mno-dlmzb | |
d77de738 ML |
30295 | Generate code that uses (does not use) the string-search @samp{dlmzb} |
30296 | instruction on the IBM 405, 440, 464 and 476 processors. This instruction is | |
30297 | generated by default when targeting those processors. | |
30298 | ||
d77de738 ML |
30299 | @opindex mno-bit-align |
30300 | @opindex mbit-align | |
ddf6fe37 AA |
30301 | @item -mno-bit-align |
30302 | @itemx -mbit-align | |
d77de738 ML |
30303 | On System V.4 and embedded PowerPC systems do not (do) force structures |
30304 | and unions that contain bit-fields to be aligned to the base type of the | |
30305 | bit-field. | |
30306 | ||
30307 | For example, by default a structure containing nothing but 8 | |
30308 | @code{unsigned} bit-fields of length 1 is aligned to a 4-byte | |
30309 | boundary and has a size of 4 bytes. By using @option{-mno-bit-align}, | |
30310 | the structure is aligned to a 1-byte boundary and is 1 byte in | |
30311 | size. | |
30312 | ||
d77de738 ML |
30313 | @opindex mno-strict-align |
30314 | @opindex mstrict-align | |
ddf6fe37 AA |
30315 | @item -mno-strict-align |
30316 | @itemx -mstrict-align | |
d77de738 ML |
30317 | On System V.4 and embedded PowerPC systems do not (do) assume that |
30318 | unaligned memory references are handled by the system. | |
30319 | ||
d77de738 ML |
30320 | @opindex mrelocatable |
30321 | @opindex mno-relocatable | |
ddf6fe37 AA |
30322 | @item -mrelocatable |
30323 | @itemx -mno-relocatable | |
d77de738 ML |
30324 | Generate code that allows (does not allow) a static executable to be |
30325 | relocated to a different address at run time. A simple embedded | |
30326 | PowerPC system loader should relocate the entire contents of | |
30327 | @code{.got2} and 4-byte locations listed in the @code{.fixup} section, | |
30328 | a table of 32-bit addresses generated by this option. For this to | |
30329 | work, all objects linked together must be compiled with | |
30330 | @option{-mrelocatable} or @option{-mrelocatable-lib}. | |
30331 | @option{-mrelocatable} code aligns the stack to an 8-byte boundary. | |
30332 | ||
d77de738 ML |
30333 | @opindex mrelocatable-lib |
30334 | @opindex mno-relocatable-lib | |
ddf6fe37 AA |
30335 | @item -mrelocatable-lib |
30336 | @itemx -mno-relocatable-lib | |
d77de738 ML |
30337 | Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a |
30338 | @code{.fixup} section to allow static executables to be relocated at | |
30339 | run time, but @option{-mrelocatable-lib} does not use the smaller stack | |
30340 | alignment of @option{-mrelocatable}. Objects compiled with | |
30341 | @option{-mrelocatable-lib} may be linked with objects compiled with | |
30342 | any combination of the @option{-mrelocatable} options. | |
30343 | ||
d77de738 ML |
30344 | @opindex mno-toc |
30345 | @opindex mtoc | |
ddf6fe37 AA |
30346 | @item -mno-toc |
30347 | @itemx -mtoc | |
d77de738 ML |
30348 | On System V.4 and embedded PowerPC systems do not (do) assume that |
30349 | register 2 contains a pointer to a global area pointing to the addresses | |
30350 | used in the program. | |
30351 | ||
d77de738 ML |
30352 | @opindex mlittle |
30353 | @opindex mlittle-endian | |
ddf6fe37 AA |
30354 | @item -mlittle |
30355 | @itemx -mlittle-endian | |
d77de738 ML |
30356 | On System V.4 and embedded PowerPC systems compile code for the |
30357 | processor in little-endian mode. The @option{-mlittle-endian} option is | |
30358 | the same as @option{-mlittle}. | |
30359 | ||
d77de738 ML |
30360 | @opindex mbig |
30361 | @opindex mbig-endian | |
ddf6fe37 AA |
30362 | @item -mbig |
30363 | @itemx -mbig-endian | |
d77de738 ML |
30364 | On System V.4 and embedded PowerPC systems compile code for the |
30365 | processor in big-endian mode. The @option{-mbig-endian} option is | |
30366 | the same as @option{-mbig}. | |
30367 | ||
d77de738 | 30368 | @opindex mdynamic-no-pic |
ddf6fe37 | 30369 | @item -mdynamic-no-pic |
a335cf24 | 30370 | On Darwin / macOS systems, compile code so that it is not |
d77de738 ML |
30371 | relocatable, but that its external references are relocatable. The |
30372 | resulting code is suitable for applications, but not shared | |
30373 | libraries. | |
30374 | ||
d77de738 | 30375 | @opindex msingle-pic-base |
ddf6fe37 | 30376 | @item -msingle-pic-base |
d77de738 ML |
30377 | Treat the register used for PIC addressing as read-only, rather than |
30378 | loading it in the prologue for each function. The runtime system is | |
30379 | responsible for initializing this register with an appropriate value | |
30380 | before execution begins. | |
30381 | ||
d77de738 | 30382 | @opindex mprioritize-restricted-insns |
ddf6fe37 | 30383 | @item -mprioritize-restricted-insns=@var{priority} |
d77de738 ML |
30384 | This option controls the priority that is assigned to |
30385 | dispatch-slot restricted instructions during the second scheduling | |
30386 | pass. The argument @var{priority} takes the value @samp{0}, @samp{1}, | |
30387 | or @samp{2} to assign no, highest, or second-highest (respectively) | |
30388 | priority to dispatch-slot restricted | |
30389 | instructions. | |
30390 | ||
d77de738 | 30391 | @opindex msched-costly-dep |
ddf6fe37 | 30392 | @item -msched-costly-dep=@var{dependence_type} |
d77de738 ML |
30393 | This option controls which dependences are considered costly |
30394 | by the target during instruction scheduling. The argument | |
30395 | @var{dependence_type} takes one of the following values: | |
30396 | ||
30397 | @table @asis | |
30398 | @item @samp{no} | |
30399 | No dependence is costly. | |
30400 | ||
30401 | @item @samp{all} | |
30402 | All dependences are costly. | |
30403 | ||
30404 | @item @samp{true_store_to_load} | |
30405 | A true dependence from store to load is costly. | |
30406 | ||
30407 | @item @samp{store_to_load} | |
30408 | Any dependence from store to load is costly. | |
30409 | ||
30410 | @item @var{number} | |
30411 | Any dependence for which the latency is greater than or equal to | |
30412 | @var{number} is costly. | |
30413 | @end table | |
30414 | ||
d77de738 | 30415 | @opindex minsert-sched-nops |
ddf6fe37 | 30416 | @item -minsert-sched-nops=@var{scheme} |
d77de738 ML |
30417 | This option controls which NOP insertion scheme is used during |
30418 | the second scheduling pass. The argument @var{scheme} takes one of the | |
30419 | following values: | |
30420 | ||
30421 | @table @asis | |
30422 | @item @samp{no} | |
30423 | Don't insert NOPs. | |
30424 | ||
30425 | @item @samp{pad} | |
30426 | Pad with NOPs any dispatch group that has vacant issue slots, | |
30427 | according to the scheduler's grouping. | |
30428 | ||
30429 | @item @samp{regroup_exact} | |
30430 | Insert NOPs to force costly dependent insns into | |
30431 | separate groups. Insert exactly as many NOPs as needed to force an insn | |
30432 | to a new group, according to the estimated processor grouping. | |
30433 | ||
30434 | @item @var{number} | |
30435 | Insert NOPs to force costly dependent insns into | |
30436 | separate groups. Insert @var{number} NOPs to force an insn to a new group. | |
30437 | @end table | |
30438 | ||
d77de738 | 30439 | @opindex mcall-sysv |
ddf6fe37 | 30440 | @item -mcall-sysv |
d77de738 ML |
30441 | On System V.4 and embedded PowerPC systems compile code using calling |
30442 | conventions that adhere to the March 1995 draft of the System V | |
30443 | Application Binary Interface, PowerPC processor supplement. This is the | |
30444 | default unless you configured GCC using @samp{powerpc-*-eabiaix}. | |
30445 | ||
d77de738 ML |
30446 | @opindex mcall-sysv-eabi |
30447 | @opindex mcall-eabi | |
ddf6fe37 AA |
30448 | @item -mcall-sysv-eabi |
30449 | @itemx -mcall-eabi | |
d77de738 ML |
30450 | Specify both @option{-mcall-sysv} and @option{-meabi} options. |
30451 | ||
d77de738 | 30452 | @opindex mcall-sysv-noeabi |
ddf6fe37 | 30453 | @item -mcall-sysv-noeabi |
d77de738 ML |
30454 | Specify both @option{-mcall-sysv} and @option{-mno-eabi} options. |
30455 | ||
d7971cf7 | 30456 | @opindex mcall-aixdesc |
ddf6fe37 | 30457 | @item -mcall-aixdesc |
d77de738 ML |
30458 | On System V.4 and embedded PowerPC systems compile code for the AIX |
30459 | operating system. | |
30460 | ||
d77de738 | 30461 | @opindex mcall-linux |
ddf6fe37 | 30462 | @item -mcall-linux |
d77de738 ML |
30463 | On System V.4 and embedded PowerPC systems compile code for the |
30464 | Linux-based GNU system. | |
30465 | ||
d77de738 | 30466 | @opindex mcall-freebsd |
ddf6fe37 | 30467 | @item -mcall-freebsd |
d77de738 ML |
30468 | On System V.4 and embedded PowerPC systems compile code for the |
30469 | FreeBSD operating system. | |
30470 | ||
d77de738 | 30471 | @opindex mcall-netbsd |
ddf6fe37 | 30472 | @item -mcall-netbsd |
d77de738 ML |
30473 | On System V.4 and embedded PowerPC systems compile code for the |
30474 | NetBSD operating system. | |
30475 | ||
d7971cf7 | 30476 | @opindex mcall-openbsd |
ddf6fe37 | 30477 | @item -mcall-openbsd |
d77de738 ML |
30478 | On System V.4 and embedded PowerPC systems compile code for the |
30479 | OpenBSD operating system. | |
30480 | ||
d77de738 | 30481 | @opindex mtraceback |
ddf6fe37 | 30482 | @item -mtraceback=@var{traceback_type} |
d77de738 ML |
30483 | Select the type of traceback table. Valid values for @var{traceback_type} |
30484 | are @samp{full}, @samp{part}, and @samp{no}. | |
30485 | ||
d77de738 | 30486 | @opindex maix-struct-return |
ddf6fe37 | 30487 | @item -maix-struct-return |
d77de738 ML |
30488 | Return all structures in memory (as specified by the AIX ABI)@. |
30489 | ||
d77de738 | 30490 | @opindex msvr4-struct-return |
ddf6fe37 | 30491 | @item -msvr4-struct-return |
d77de738 ML |
30492 | Return structures smaller than 8 bytes in registers (as specified by the |
30493 | SVR4 ABI)@. | |
30494 | ||
d77de738 | 30495 | @opindex mabi |
ddf6fe37 | 30496 | @item -mabi=@var{abi-type} |
d77de738 ML |
30497 | Extend the current ABI with a particular extension, or remove such extension. |
30498 | Valid values are: @samp{altivec}, @samp{no-altivec}, | |
30499 | @samp{ibmlongdouble}, @samp{ieeelongdouble}, | |
30500 | @samp{elfv1}, @samp{elfv2}, | |
30501 | and for AIX: @samp{vec-extabi}, @samp{vec-default}@. | |
30502 | ||
d77de738 | 30503 | @opindex mabi=ibmlongdouble |
ddf6fe37 | 30504 | @item -mabi=ibmlongdouble |
d77de738 ML |
30505 | Change the current ABI to use IBM extended-precision long double. |
30506 | This is not likely to work if your system defaults to using IEEE | |
30507 | extended-precision long double. If you change the long double type | |
30508 | from IEEE extended-precision, the compiler will issue a warning unless | |
30509 | you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128} | |
30510 | to be enabled. | |
30511 | ||
d77de738 | 30512 | @opindex mabi=ieeelongdouble |
ddf6fe37 | 30513 | @item -mabi=ieeelongdouble |
d77de738 ML |
30514 | Change the current ABI to use IEEE extended-precision long double. |
30515 | This is not likely to work if your system defaults to using IBM | |
30516 | extended-precision long double. If you change the long double type | |
30517 | from IBM extended-precision, the compiler will issue a warning unless | |
30518 | you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128} | |
30519 | to be enabled. | |
30520 | ||
d77de738 | 30521 | @opindex mabi=elfv1 |
ddf6fe37 | 30522 | @item -mabi=elfv1 |
d77de738 ML |
30523 | Change the current ABI to use the ELFv1 ABI. |
30524 | This is the default ABI for big-endian PowerPC 64-bit Linux. | |
30525 | Overriding the default ABI requires special system support and is | |
30526 | likely to fail in spectacular ways. | |
30527 | ||
d77de738 | 30528 | @opindex mabi=elfv2 |
ddf6fe37 | 30529 | @item -mabi=elfv2 |
d77de738 ML |
30530 | Change the current ABI to use the ELFv2 ABI. |
30531 | This is the default ABI for little-endian PowerPC 64-bit Linux. | |
30532 | Overriding the default ABI requires special system support and is | |
30533 | likely to fail in spectacular ways. | |
30534 | ||
d77de738 ML |
30535 | @opindex mgnu-attribute |
30536 | @opindex mno-gnu-attribute | |
ddf6fe37 AA |
30537 | @item -mgnu-attribute |
30538 | @itemx -mno-gnu-attribute | |
d77de738 ML |
30539 | Emit .gnu_attribute assembly directives to set tag/value pairs in a |
30540 | .gnu.attributes section that specify ABI variations in function | |
30541 | parameters or return values. | |
30542 | ||
d77de738 ML |
30543 | @opindex mprototype |
30544 | @opindex mno-prototype | |
ddf6fe37 AA |
30545 | @item -mprototype |
30546 | @itemx -mno-prototype | |
d77de738 ML |
30547 | On System V.4 and embedded PowerPC systems assume that all calls to |
30548 | variable argument functions are properly prototyped. Otherwise, the | |
30549 | compiler must insert an instruction before every non-prototyped call to | |
30550 | set or clear bit 6 of the condition code register (@code{CR}) to | |
30551 | indicate whether floating-point values are passed in the floating-point | |
30552 | registers in case the function takes variable arguments. With | |
30553 | @option{-mprototype}, only calls to prototyped variable argument functions | |
30554 | set or clear the bit. | |
30555 | ||
d77de738 | 30556 | @opindex msim |
ddf6fe37 | 30557 | @item -msim |
d77de738 ML |
30558 | On embedded PowerPC systems, assume that the startup module is called |
30559 | @file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and | |
30560 | @file{libc.a}. This is the default for @samp{powerpc-*-eabisim} | |
30561 | configurations. | |
30562 | ||
d77de738 | 30563 | @opindex mmvme |
ddf6fe37 | 30564 | @item -mmvme |
d77de738 ML |
30565 | On embedded PowerPC systems, assume that the startup module is called |
30566 | @file{crt0.o} and the standard C libraries are @file{libmvme.a} and | |
30567 | @file{libc.a}. | |
30568 | ||
d77de738 | 30569 | @opindex mads |
ddf6fe37 | 30570 | @item -mads |
d77de738 ML |
30571 | On embedded PowerPC systems, assume that the startup module is called |
30572 | @file{crt0.o} and the standard C libraries are @file{libads.a} and | |
30573 | @file{libc.a}. | |
30574 | ||
d77de738 | 30575 | @opindex myellowknife |
ddf6fe37 | 30576 | @item -myellowknife |
d77de738 ML |
30577 | On embedded PowerPC systems, assume that the startup module is called |
30578 | @file{crt0.o} and the standard C libraries are @file{libyk.a} and | |
30579 | @file{libc.a}. | |
30580 | ||
d77de738 | 30581 | @opindex mvxworks |
ddf6fe37 | 30582 | @item -mvxworks |
d77de738 ML |
30583 | On System V.4 and embedded PowerPC systems, specify that you are |
30584 | compiling for a VxWorks system. | |
30585 | ||
d77de738 | 30586 | @opindex memb |
ddf6fe37 | 30587 | @item -memb |
d77de738 ML |
30588 | On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags |
30589 | header to indicate that @samp{eabi} extended relocations are used. | |
30590 | ||
d77de738 ML |
30591 | @opindex meabi |
30592 | @opindex mno-eabi | |
ddf6fe37 AA |
30593 | @item -meabi |
30594 | @itemx -mno-eabi | |
d77de738 ML |
30595 | On System V.4 and embedded PowerPC systems do (do not) adhere to the |
30596 | Embedded Applications Binary Interface (EABI), which is a set of | |
30597 | modifications to the System V.4 specifications. Selecting @option{-meabi} | |
30598 | means that the stack is aligned to an 8-byte boundary, a function | |
30599 | @code{__eabi} is called from @code{main} to set up the EABI | |
30600 | environment, and the @option{-msdata} option can use both @code{r2} and | |
30601 | @code{r13} to point to two separate small data areas. Selecting | |
30602 | @option{-mno-eabi} means that the stack is aligned to a 16-byte boundary, | |
30603 | no EABI initialization function is called from @code{main}, and the | |
30604 | @option{-msdata} option only uses @code{r13} to point to a single | |
30605 | small data area. The @option{-meabi} option is on by default if you | |
30606 | configured GCC using one of the @samp{powerpc*-*-eabi*} options. | |
30607 | ||
d77de738 | 30608 | @opindex msdata=eabi |
ddf6fe37 | 30609 | @item -msdata=eabi |
d77de738 ML |
30610 | On System V.4 and embedded PowerPC systems, put small initialized |
30611 | @code{const} global and static data in the @code{.sdata2} section, which | |
30612 | is pointed to by register @code{r2}. Put small initialized | |
30613 | non-@code{const} global and static data in the @code{.sdata} section, | |
30614 | which is pointed to by register @code{r13}. Put small uninitialized | |
30615 | global and static data in the @code{.sbss} section, which is adjacent to | |
30616 | the @code{.sdata} section. The @option{-msdata=eabi} option is | |
30617 | incompatible with the @option{-mrelocatable} option. The | |
30618 | @option{-msdata=eabi} option also sets the @option{-memb} option. | |
30619 | ||
d77de738 | 30620 | @opindex msdata=sysv |
ddf6fe37 | 30621 | @item -msdata=sysv |
d77de738 ML |
30622 | On System V.4 and embedded PowerPC systems, put small global and static |
30623 | data in the @code{.sdata} section, which is pointed to by register | |
30624 | @code{r13}. Put small uninitialized global and static data in the | |
30625 | @code{.sbss} section, which is adjacent to the @code{.sdata} section. | |
30626 | The @option{-msdata=sysv} option is incompatible with the | |
30627 | @option{-mrelocatable} option. | |
30628 | ||
d77de738 ML |
30629 | @opindex msdata=default |
30630 | @opindex msdata | |
ddf6fe37 AA |
30631 | @item -msdata=default |
30632 | @itemx -msdata | |
d77de738 ML |
30633 | On System V.4 and embedded PowerPC systems, if @option{-meabi} is used, |
30634 | compile code the same as @option{-msdata=eabi}, otherwise compile code the | |
30635 | same as @option{-msdata=sysv}. | |
30636 | ||
d77de738 | 30637 | @opindex msdata=data |
ddf6fe37 | 30638 | @item -msdata=data |
d77de738 ML |
30639 | On System V.4 and embedded PowerPC systems, put small global |
30640 | data in the @code{.sdata} section. Put small uninitialized global | |
30641 | data in the @code{.sbss} section. Do not use register @code{r13} | |
30642 | to address small data however. This is the default behavior unless | |
30643 | other @option{-msdata} options are used. | |
30644 | ||
d77de738 ML |
30645 | @opindex msdata=none |
30646 | @opindex mno-sdata | |
ddf6fe37 AA |
30647 | @item -msdata=none |
30648 | @itemx -mno-sdata | |
d77de738 ML |
30649 | On embedded PowerPC systems, put all initialized global and static data |
30650 | in the @code{.data} section, and all uninitialized data in the | |
30651 | @code{.bss} section. | |
30652 | ||
d77de738 ML |
30653 | @opindex mreadonly-in-sdata |
30654 | @opindex mno-readonly-in-sdata | |
ddf6fe37 | 30655 | @item -mreadonly-in-sdata |
d77de738 ML |
30656 | Put read-only objects in the @code{.sdata} section as well. This is the |
30657 | default. | |
30658 | ||
d77de738 | 30659 | @opindex mblock-move-inline-limit |
ddf6fe37 | 30660 | @item -mblock-move-inline-limit=@var{num} |
d77de738 ML |
30661 | Inline all block moves (such as calls to @code{memcpy} or structure |
30662 | copies) less than or equal to @var{num} bytes. The minimum value for | |
30663 | @var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit | |
30664 | targets. The default value is target-specific. | |
30665 | ||
d77de738 | 30666 | @opindex mblock-compare-inline-limit |
ddf6fe37 | 30667 | @item -mblock-compare-inline-limit=@var{num} |
d77de738 ML |
30668 | Generate non-looping inline code for all block compares (such as calls |
30669 | to @code{memcmp} or structure compares) less than or equal to @var{num} | |
30670 | bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of | |
30671 | block compare is disabled. The default value is target-specific. | |
30672 | ||
d77de738 | 30673 | @opindex mblock-compare-inline-loop-limit |
ddf6fe37 | 30674 | @item -mblock-compare-inline-loop-limit=@var{num} |
d77de738 ML |
30675 | Generate an inline expansion using loop code for all block compares that |
30676 | are less than or equal to @var{num} bytes, but greater than the limit | |
30677 | for non-loop inline block compare expansion. If the block length is not | |
30678 | constant, at most @var{num} bytes will be compared before @code{memcmp} | |
30679 | is called to compare the remainder of the block. The default value is | |
30680 | target-specific. | |
30681 | ||
d77de738 | 30682 | @opindex mstring-compare-inline-limit |
ddf6fe37 | 30683 | @item -mstring-compare-inline-limit=@var{num} |
d77de738 ML |
30684 | Compare at most @var{num} string bytes with inline code. |
30685 | If the difference or end of string is not found at the | |
30686 | end of the inline compare a call to @code{strcmp} or @code{strncmp} will | |
30687 | take care of the rest of the comparison. The default is 64 bytes. | |
30688 | ||
d77de738 ML |
30689 | @opindex G |
30690 | @cindex smaller data references (PowerPC) | |
30691 | @cindex .sdata/.sdata2 references (PowerPC) | |
f33d7a88 | 30692 | @item -G @var{num} |
d77de738 ML |
30693 | On embedded PowerPC systems, put global and static items less than or |
30694 | equal to @var{num} bytes into the small data or BSS sections instead of | |
30695 | the normal data or BSS section. By default, @var{num} is 8. The | |
30696 | @option{-G @var{num}} switch is also passed to the linker. | |
30697 | All modules should be compiled with the same @option{-G @var{num}} value. | |
30698 | ||
d77de738 ML |
30699 | @opindex mregnames |
30700 | @opindex mno-regnames | |
ddf6fe37 AA |
30701 | @item -mregnames |
30702 | @itemx -mno-regnames | |
d77de738 ML |
30703 | On System V.4 and embedded PowerPC systems do (do not) emit register |
30704 | names in the assembly language output using symbolic forms. | |
30705 | ||
d77de738 ML |
30706 | @opindex mlongcall |
30707 | @opindex mno-longcall | |
ddf6fe37 AA |
30708 | @item -mlongcall |
30709 | @itemx -mno-longcall | |
d77de738 ML |
30710 | By default assume that all calls are far away so that a longer and more |
30711 | expensive calling sequence is required. This is required for calls | |
30712 | farther than 32 megabytes (33,554,432 bytes) from the current location. | |
30713 | A short call is generated if the compiler knows | |
30714 | the call cannot be that far away. This setting can be overridden by | |
30715 | the @code{shortcall} function attribute, or by @code{#pragma | |
30716 | longcall(0)}. | |
30717 | ||
30718 | Some linkers are capable of detecting out-of-range calls and generating | |
30719 | glue code on the fly. On these systems, long calls are unnecessary and | |
30720 | generate slower code. As of this writing, the AIX linker can do this, | |
30721 | as can the GNU linker for PowerPC/64. It is planned to add this feature | |
30722 | to the GNU linker for 32-bit PowerPC systems as well. | |
30723 | ||
30724 | On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers, | |
30725 | GCC can generate long calls using an inline PLT call sequence (see | |
30726 | @option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64 | |
30727 | ELFv1 (big-endian) do not support inline PLT calls. | |
30728 | ||
30729 | On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr | |
30730 | callee, L42}, plus a @dfn{branch island} (glue code). The two target | |
30731 | addresses represent the callee and the branch island. The | |
30732 | Darwin/PPC linker prefers the first address and generates a @code{bl | |
30733 | callee} if the PPC @code{bl} instruction reaches the callee directly; | |
30734 | otherwise, the linker generates @code{bl L42} to call the branch | |
30735 | island. The branch island is appended to the body of the | |
30736 | calling function; it computes the full 32-bit address of the callee | |
30737 | and jumps to it. | |
30738 | ||
30739 | On Mach-O (Darwin) systems, this option directs the compiler emit to | |
30740 | the glue for every direct call, and the Darwin linker decides whether | |
30741 | to use or discard it. | |
30742 | ||
30743 | In the future, GCC may ignore all longcall specifications | |
30744 | when the linker is known to generate glue. | |
30745 | ||
d77de738 ML |
30746 | @opindex mpltseq |
30747 | @opindex mno-pltseq | |
ddf6fe37 AA |
30748 | @item -mpltseq |
30749 | @itemx -mno-pltseq | |
d77de738 ML |
30750 | Implement (do not implement) -fno-plt and long calls using an inline |
30751 | PLT call sequence that supports lazy linking and long calls to | |
30752 | functions in dlopen'd shared libraries. Inline PLT calls are only | |
30753 | supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU | |
30754 | linkers, and are enabled by default if the support is detected when | |
30755 | configuring GCC, and, in the case of 32-bit PowerPC, if GCC is | |
30756 | configured with @option{--enable-secureplt}. @option{-mpltseq} code | |
30757 | and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be | |
30758 | linked together. | |
30759 | ||
d77de738 ML |
30760 | @opindex mtls-markers |
30761 | @opindex mno-tls-markers | |
ddf6fe37 AA |
30762 | @item -mtls-markers |
30763 | @itemx -mno-tls-markers | |
d77de738 ML |
30764 | Mark (do not mark) calls to @code{__tls_get_addr} with a relocation |
30765 | specifying the function argument. The relocation allows the linker to | |
30766 | reliably associate function call with argument setup instructions for | |
30767 | TLS optimization, which in turn allows GCC to better schedule the | |
30768 | sequence. | |
30769 | ||
ddf6fe37 | 30770 | @opindex mrecip |
d77de738 ML |
30771 | @item -mrecip |
30772 | @itemx -mno-recip | |
d77de738 ML |
30773 | This option enables use of the reciprocal estimate and |
30774 | reciprocal square root estimate instructions with additional | |
30775 | Newton-Raphson steps to increase precision instead of doing a divide or | |
30776 | square root and divide for floating-point arguments. You should use | |
30777 | the @option{-ffast-math} option when using @option{-mrecip} (or at | |
30778 | least @option{-funsafe-math-optimizations}, | |
30779 | @option{-ffinite-math-only}, @option{-freciprocal-math} and | |
30780 | @option{-fno-trapping-math}). Note that while the throughput of the | |
30781 | sequence is generally higher than the throughput of the non-reciprocal | |
30782 | instruction, the precision of the sequence can be decreased by up to 2 | |
30783 | ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square | |
30784 | roots. | |
30785 | ||
d77de738 | 30786 | @opindex mrecip=opt |
ddf6fe37 | 30787 | @item -mrecip=@var{opt} |
d77de738 ML |
30788 | This option controls which reciprocal estimate instructions |
30789 | may be used. @var{opt} is a comma-separated list of options, which may | |
30790 | be preceded by a @code{!} to invert the option: | |
30791 | ||
30792 | @table @samp | |
30793 | ||
30794 | @item all | |
30795 | Enable all estimate instructions. | |
30796 | ||
30797 | @item default | |
30798 | Enable the default instructions, equivalent to @option{-mrecip}. | |
30799 | ||
30800 | @item none | |
30801 | Disable all estimate instructions, equivalent to @option{-mno-recip}. | |
30802 | ||
30803 | @item div | |
30804 | Enable the reciprocal approximation instructions for both | |
30805 | single and double precision. | |
30806 | ||
30807 | @item divf | |
30808 | Enable the single-precision reciprocal approximation instructions. | |
30809 | ||
30810 | @item divd | |
30811 | Enable the double-precision reciprocal approximation instructions. | |
30812 | ||
30813 | @item rsqrt | |
30814 | Enable the reciprocal square root approximation instructions for both | |
30815 | single and double precision. | |
30816 | ||
30817 | @item rsqrtf | |
30818 | Enable the single-precision reciprocal square root approximation instructions. | |
30819 | ||
30820 | @item rsqrtd | |
30821 | Enable the double-precision reciprocal square root approximation instructions. | |
30822 | ||
30823 | @end table | |
30824 | ||
30825 | So, for example, @option{-mrecip=all,!rsqrtd} enables | |
30826 | all of the reciprocal estimate instructions, except for the | |
30827 | @code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions | |
30828 | which handle the double-precision reciprocal square root calculations. | |
30829 | ||
ddf6fe37 | 30830 | @opindex mrecip-precision |
d77de738 ML |
30831 | @item -mrecip-precision |
30832 | @itemx -mno-recip-precision | |
d77de738 ML |
30833 | Assume (do not assume) that the reciprocal estimate instructions |
30834 | provide higher-precision estimates than is mandated by the PowerPC | |
30835 | ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or | |
30836 | @option{-mcpu=power8} automatically selects @option{-mrecip-precision}. | |
30837 | The double-precision square root estimate instructions are not generated by | |
30838 | default on low-precision machines, since they do not provide an | |
30839 | estimate that converges after three steps. | |
30840 | ||
d77de738 | 30841 | @opindex mveclibabi |
ddf6fe37 | 30842 | @item -mveclibabi=@var{type} |
d77de738 ML |
30843 | Specifies the ABI type to use for vectorizing intrinsics using an |
30844 | external library. The only type supported at present is @samp{mass}, | |
30845 | which specifies to use IBM's Mathematical Acceleration Subsystem | |
30846 | (MASS) libraries for vectorizing intrinsics using external libraries. | |
30847 | GCC currently emits calls to @code{acosd2}, @code{acosf4}, | |
30848 | @code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4}, | |
30849 | @code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4}, | |
30850 | @code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4}, | |
30851 | @code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4}, | |
30852 | @code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4}, | |
30853 | @code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4}, | |
30854 | @code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4}, | |
30855 | @code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4}, | |
30856 | @code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4}, | |
30857 | @code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4}, | |
30858 | @code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2}, | |
30859 | @code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2}, | |
30860 | @code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code | |
30861 | for power7. Both @option{-ftree-vectorize} and | |
30862 | @option{-funsafe-math-optimizations} must also be enabled. The MASS | |
30863 | libraries must be specified at link time. | |
30864 | ||
ddf6fe37 | 30865 | @opindex mfriz |
d77de738 ML |
30866 | @item -mfriz |
30867 | @itemx -mno-friz | |
d77de738 ML |
30868 | Generate (do not generate) the @code{friz} instruction when the |
30869 | @option{-funsafe-math-optimizations} option is used to optimize | |
30870 | rounding of floating-point values to 64-bit integer and back to floating | |
30871 | point. The @code{friz} instruction does not return the same value if | |
30872 | the floating-point number is too large to fit in an integer. | |
30873 | ||
ddf6fe37 | 30874 | @opindex mpointers-to-nested-functions |
d77de738 ML |
30875 | @item -mpointers-to-nested-functions |
30876 | @itemx -mno-pointers-to-nested-functions | |
d77de738 ML |
30877 | Generate (do not generate) code to load up the static chain register |
30878 | (@code{r11}) when calling through a pointer on AIX and 64-bit Linux | |
30879 | systems where a function pointer points to a 3-word descriptor giving | |
30880 | the function address, TOC value to be loaded in register @code{r2}, and | |
30881 | static chain value to be loaded in register @code{r11}. The | |
30882 | @option{-mpointers-to-nested-functions} is on by default. You cannot | |
30883 | call through pointers to nested functions or pointers | |
30884 | to functions compiled in other languages that use the static chain if | |
30885 | you use @option{-mno-pointers-to-nested-functions}. | |
30886 | ||
ddf6fe37 | 30887 | @opindex msave-toc-indirect |
d77de738 ML |
30888 | @item -msave-toc-indirect |
30889 | @itemx -mno-save-toc-indirect | |
d77de738 ML |
30890 | Generate (do not generate) code to save the TOC value in the reserved |
30891 | stack location in the function prologue if the function calls through | |
30892 | a pointer on AIX and 64-bit Linux systems. If the TOC value is not | |
30893 | saved in the prologue, it is saved just before the call through the | |
30894 | pointer. The @option{-mno-save-toc-indirect} option is the default. | |
30895 | ||
ddf6fe37 | 30896 | @opindex mcompat-align-parm |
d77de738 ML |
30897 | @item -mcompat-align-parm |
30898 | @itemx -mno-compat-align-parm | |
d77de738 ML |
30899 | Generate (do not generate) code to pass structure parameters with a |
30900 | maximum alignment of 64 bits, for compatibility with older versions | |
30901 | of GCC. | |
30902 | ||
30903 | Older versions of GCC (prior to 4.9.0) incorrectly did not align a | |
30904 | structure parameter on a 128-bit boundary when that structure contained | |
30905 | a member requiring 128-bit alignment. This is corrected in more | |
30906 | recent versions of GCC. This option may be used to generate code | |
30907 | that is compatible with functions compiled with older versions of | |
30908 | GCC. | |
30909 | ||
30910 | The @option{-mno-compat-align-parm} option is the default. | |
30911 | ||
d77de738 ML |
30912 | @opindex mstack-protector-guard |
30913 | @opindex mstack-protector-guard-reg | |
30914 | @opindex mstack-protector-guard-offset | |
30915 | @opindex mstack-protector-guard-symbol | |
ddf6fe37 AA |
30916 | @item -mstack-protector-guard=@var{guard} |
30917 | @itemx -mstack-protector-guard-reg=@var{reg} | |
30918 | @itemx -mstack-protector-guard-offset=@var{offset} | |
30919 | @itemx -mstack-protector-guard-symbol=@var{symbol} | |
d77de738 ML |
30920 | Generate stack protection code using canary at @var{guard}. Supported |
30921 | locations are @samp{global} for global canary or @samp{tls} for per-thread | |
30922 | canary in the TLS block (the default with GNU libc version 2.4 or later). | |
30923 | ||
30924 | With the latter choice the options | |
30925 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
30926 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
30927 | which register to use as base register for reading the canary, and from what | |
30928 | offset from that base register. The default for those is as specified in the | |
30929 | relevant ABI. @option{-mstack-protector-guard-symbol=@var{symbol}} overrides | |
30930 | the offset with a symbol reference to a canary in the TLS block. | |
30931 | ||
d77de738 ML |
30932 | @opindex mpcrel |
30933 | @opindex mno-pcrel | |
ddf6fe37 AA |
30934 | @item -mpcrel |
30935 | @itemx -mno-pcrel | |
d77de738 ML |
30936 | Generate (do not generate) pc-relative addressing. The @option{-mpcrel} |
30937 | option requires that the medium code model (@option{-mcmodel=medium}) | |
30938 | and prefixed addressing (@option{-mprefixed}) options are enabled. | |
30939 | ||
d77de738 ML |
30940 | @opindex mprefixed |
30941 | @opindex mno-prefixed | |
ddf6fe37 AA |
30942 | @item -mprefixed |
30943 | @itemx -mno-prefixed | |
d77de738 ML |
30944 | Generate (do not generate) addressing modes using prefixed load and |
30945 | store instructions. The @option{-mprefixed} option requires that | |
30946 | the option @option{-mcpu=power10} (or later) is enabled. | |
30947 | ||
d77de738 ML |
30948 | @opindex mmma |
30949 | @opindex mno-mma | |
ddf6fe37 AA |
30950 | @item -mmma |
30951 | @itemx -mno-mma | |
d77de738 ML |
30952 | Generate (do not generate) the MMA instructions. The @option{-mma} |
30953 | option requires that the option @option{-mcpu=power10} (or later) | |
30954 | is enabled. | |
30955 | ||
d77de738 ML |
30956 | @opindex mrop-protect |
30957 | @opindex mno-rop-protect | |
ddf6fe37 AA |
30958 | @item -mrop-protect |
30959 | @itemx -mno-rop-protect | |
d77de738 ML |
30960 | Generate (do not generate) ROP protection instructions when the target |
30961 | processor supports them. Currently this option disables the shrink-wrap | |
30962 | optimization (@option{-fshrink-wrap}). | |
30963 | ||
d77de738 ML |
30964 | @opindex mprivileged |
30965 | @opindex mno-privileged | |
ddf6fe37 AA |
30966 | @item -mprivileged |
30967 | @itemx -mno-privileged | |
d77de738 ML |
30968 | Generate (do not generate) code that will run in privileged state. |
30969 | ||
d77de738 ML |
30970 | @opindex block-ops-unaligned-vsx |
30971 | @opindex no-block-ops-unaligned-vsx | |
ddf6fe37 AA |
30972 | @item -mblock-ops-unaligned-vsx |
30973 | @itemx -mno-block-ops-unaligned-vsx | |
d77de738 ML |
30974 | Generate (do not generate) unaligned vsx loads and stores for |
30975 | inline expansion of @code{memcpy} and @code{memmove}. | |
30976 | ||
30977 | @item --param rs6000-vect-unroll-limit= | |
30978 | The vectorizer will check with target information to determine whether it | |
30979 | would be beneficial to unroll the main vectorized loop and by how much. This | |
30980 | parameter sets the upper bound of how much the vectorizer will unroll the main | |
30981 | loop. The default value is four. | |
30982 | ||
30983 | @end table | |
30984 | ||
30985 | @node RX Options | |
30986 | @subsection RX Options | |
30987 | @cindex RX Options | |
30988 | ||
30989 | These command-line options are defined for RX targets: | |
30990 | ||
30991 | @table @gcctabopt | |
d77de738 ML |
30992 | @opindex m64bit-doubles |
30993 | @opindex m32bit-doubles | |
ddf6fe37 AA |
30994 | @item -m64bit-doubles |
30995 | @itemx -m32bit-doubles | |
d77de738 ML |
30996 | Make the @code{double} data type be 64 bits (@option{-m64bit-doubles}) |
30997 | or 32 bits (@option{-m32bit-doubles}) in size. The default is | |
30998 | @option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only | |
30999 | works on 32-bit values, which is why the default is | |
31000 | @option{-m32bit-doubles}. | |
31001 | ||
d77de738 ML |
31002 | @opindex fpu |
31003 | @opindex nofpu | |
ddf6fe37 AA |
31004 | @item -fpu |
31005 | @itemx -nofpu | |
d77de738 ML |
31006 | Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX |
31007 | floating-point hardware. The default is enabled for the RX600 | |
31008 | series and disabled for the RX200 series. | |
31009 | ||
31010 | Floating-point instructions are only generated for 32-bit floating-point | |
31011 | values, however, so the FPU hardware is not used for doubles if the | |
31012 | @option{-m64bit-doubles} option is used. | |
31013 | ||
31014 | @emph{Note} If the @option{-fpu} option is enabled then | |
31015 | @option{-funsafe-math-optimizations} is also enabled automatically. | |
31016 | This is because the RX FPU instructions are themselves unsafe. | |
31017 | ||
d77de738 | 31018 | @opindex mcpu |
ddf6fe37 | 31019 | @item -mcpu=@var{name} |
d77de738 ML |
31020 | Selects the type of RX CPU to be targeted. Currently three types are |
31021 | supported, the generic @samp{RX600} and @samp{RX200} series hardware and | |
31022 | the specific @samp{RX610} CPU. The default is @samp{RX600}. | |
31023 | ||
31024 | The only difference between @samp{RX600} and @samp{RX610} is that the | |
31025 | @samp{RX610} does not support the @code{MVTIPL} instruction. | |
31026 | ||
31027 | The @samp{RX200} series does not have a hardware floating-point unit | |
31028 | and so @option{-nofpu} is enabled by default when this type is | |
31029 | selected. | |
31030 | ||
d77de738 ML |
31031 | @opindex mbig-endian-data |
31032 | @opindex mlittle-endian-data | |
ddf6fe37 AA |
31033 | @item -mbig-endian-data |
31034 | @itemx -mlittle-endian-data | |
d77de738 ML |
31035 | Store data (but not code) in the big-endian format. The default is |
31036 | @option{-mlittle-endian-data}, i.e.@: to store data in the little-endian | |
31037 | format. | |
31038 | ||
d77de738 | 31039 | @opindex msmall-data-limit |
ddf6fe37 | 31040 | @item -msmall-data-limit=@var{N} |
d77de738 ML |
31041 | Specifies the maximum size in bytes of global and static variables |
31042 | which can be placed into the small data area. Using the small data | |
31043 | area can lead to smaller and faster code, but the size of area is | |
31044 | limited and it is up to the programmer to ensure that the area does | |
31045 | not overflow. Also when the small data area is used one of the RX's | |
31046 | registers (usually @code{r13}) is reserved for use pointing to this | |
31047 | area, so it is no longer available for use by the compiler. This | |
31048 | could result in slower and/or larger code if variables are pushed onto | |
31049 | the stack instead of being held in this register. | |
31050 | ||
31051 | Note, common variables (variables that have not been initialized) and | |
31052 | constants are not placed into the small data area as they are assigned | |
31053 | to other sections in the output executable. | |
31054 | ||
31055 | The default value is zero, which disables this feature. Note, this | |
31056 | feature is not enabled by default with higher optimization levels | |
31057 | (@option{-O2} etc) because of the potentially detrimental effects of | |
31058 | reserving a register. It is up to the programmer to experiment and | |
31059 | discover whether this feature is of benefit to their program. See the | |
31060 | description of the @option{-mpid} option for a description of how the | |
31061 | actual register to hold the small data area pointer is chosen. | |
31062 | ||
d77de738 ML |
31063 | @opindex msim |
31064 | @opindex mno-sim | |
ddf6fe37 AA |
31065 | @item -msim |
31066 | @itemx -mno-sim | |
d77de738 ML |
31067 | Use the simulator runtime. The default is to use the libgloss |
31068 | board-specific runtime. | |
31069 | ||
d77de738 ML |
31070 | @opindex mas100-syntax |
31071 | @opindex mno-as100-syntax | |
ddf6fe37 AA |
31072 | @item -mas100-syntax |
31073 | @itemx -mno-as100-syntax | |
d77de738 ML |
31074 | When generating assembler output use a syntax that is compatible with |
31075 | Renesas's AS100 assembler. This syntax can also be handled by the GAS | |
31076 | assembler, but it has some restrictions so it is not generated by default. | |
31077 | ||
d77de738 | 31078 | @opindex mmax-constant-size |
ddf6fe37 | 31079 | @item -mmax-constant-size=@var{N} |
d77de738 ML |
31080 | Specifies the maximum size, in bytes, of a constant that can be used as |
31081 | an operand in a RX instruction. Although the RX instruction set does | |
31082 | allow constants of up to 4 bytes in length to be used in instructions, | |
31083 | a longer value equates to a longer instruction. Thus in some | |
31084 | circumstances it can be beneficial to restrict the size of constants | |
31085 | that are used in instructions. Constants that are too big are instead | |
31086 | placed into a constant pool and referenced via register indirection. | |
31087 | ||
31088 | The value @var{N} can be between 0 and 4. A value of 0 (the default) | |
31089 | or 4 means that constants of any size are allowed. | |
31090 | ||
d77de738 | 31091 | @opindex mrelax |
ddf6fe37 | 31092 | @item -mrelax |
d77de738 ML |
31093 | Enable linker relaxation. Linker relaxation is a process whereby the |
31094 | linker attempts to reduce the size of a program by finding shorter | |
31095 | versions of various instructions. Disabled by default. | |
31096 | ||
d77de738 | 31097 | @opindex mint-register |
ddf6fe37 | 31098 | @item -mint-register=@var{N} |
d77de738 ML |
31099 | Specify the number of registers to reserve for fast interrupt handler |
31100 | functions. The value @var{N} can be between 0 and 4. A value of 1 | |
31101 | means that register @code{r13} is reserved for the exclusive use | |
31102 | of fast interrupt handlers. A value of 2 reserves @code{r13} and | |
31103 | @code{r12}. A value of 3 reserves @code{r13}, @code{r12} and | |
31104 | @code{r11}, and a value of 4 reserves @code{r13} through @code{r10}. | |
31105 | A value of 0, the default, does not reserve any registers. | |
31106 | ||
d77de738 | 31107 | @opindex msave-acc-in-interrupts |
ddf6fe37 | 31108 | @item -msave-acc-in-interrupts |
d77de738 ML |
31109 | Specifies that interrupt handler functions should preserve the |
31110 | accumulator register. This is only necessary if normal code might use | |
31111 | the accumulator register, for example because it performs 64-bit | |
31112 | multiplications. The default is to ignore the accumulator as this | |
31113 | makes the interrupt handlers faster. | |
31114 | ||
d77de738 ML |
31115 | @opindex mpid |
31116 | @opindex mno-pid | |
ddf6fe37 AA |
31117 | @item -mpid |
31118 | @itemx -mno-pid | |
d77de738 ML |
31119 | Enables the generation of position independent data. When enabled any |
31120 | access to constant data is done via an offset from a base address | |
31121 | held in a register. This allows the location of constant data to be | |
31122 | determined at run time without requiring the executable to be | |
31123 | relocated, which is a benefit to embedded applications with tight | |
31124 | memory constraints. Data that can be modified is not affected by this | |
31125 | option. | |
31126 | ||
31127 | Note, using this feature reserves a register, usually @code{r13}, for | |
31128 | the constant data base address. This can result in slower and/or | |
31129 | larger code, especially in complicated functions. | |
31130 | ||
31131 | The actual register chosen to hold the constant data base address | |
31132 | depends upon whether the @option{-msmall-data-limit} and/or the | |
31133 | @option{-mint-register} command-line options are enabled. Starting | |
31134 | with register @code{r13} and proceeding downwards, registers are | |
31135 | allocated first to satisfy the requirements of @option{-mint-register}, | |
31136 | then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it | |
31137 | is possible for the small data area register to be @code{r8} if both | |
31138 | @option{-mint-register=4} and @option{-mpid} are specified on the | |
31139 | command line. | |
31140 | ||
31141 | By default this feature is not enabled. The default can be restored | |
31142 | via the @option{-mno-pid} command-line option. | |
31143 | ||
d77de738 ML |
31144 | @opindex mno-warn-multiple-fast-interrupts |
31145 | @opindex mwarn-multiple-fast-interrupts | |
ddf6fe37 AA |
31146 | @item -mno-warn-multiple-fast-interrupts |
31147 | @itemx -mwarn-multiple-fast-interrupts | |
d77de738 ML |
31148 | Prevents GCC from issuing a warning message if it finds more than one |
31149 | fast interrupt handler when it is compiling a file. The default is to | |
31150 | issue a warning for each extra fast interrupt handler found, as the RX | |
31151 | only supports one such interrupt. | |
31152 | ||
d77de738 ML |
31153 | @opindex mallow-string-insns |
31154 | @opindex mno-allow-string-insns | |
ddf6fe37 AA |
31155 | @item -mallow-string-insns |
31156 | @itemx -mno-allow-string-insns | |
d77de738 ML |
31157 | Enables or disables the use of the string manipulation instructions |
31158 | @code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL} | |
31159 | @code{SWHILE} and also the @code{RMPA} instruction. These | |
31160 | instructions may prefetch data, which is not safe to do if accessing | |
31161 | an I/O register. (See section 12.2.7 of the RX62N Group User's Manual | |
31162 | for more information). | |
31163 | ||
31164 | The default is to allow these instructions, but it is not possible for | |
31165 | GCC to reliably detect all circumstances where a string instruction | |
31166 | might be used to access an I/O register, so their use cannot be | |
31167 | disabled automatically. Instead it is reliant upon the programmer to | |
31168 | use the @option{-mno-allow-string-insns} option if their program | |
31169 | accesses I/O space. | |
31170 | ||
31171 | When the instructions are enabled GCC defines the C preprocessor | |
31172 | symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the | |
31173 | symbol @code{__RX_DISALLOW_STRING_INSNS__}. | |
31174 | ||
d77de738 ML |
31175 | @opindex mjsr |
31176 | @opindex mno-jsr | |
ddf6fe37 AA |
31177 | @item -mjsr |
31178 | @itemx -mno-jsr | |
d77de738 ML |
31179 | Use only (or not only) @code{JSR} instructions to access functions. |
31180 | This option can be used when code size exceeds the range of @code{BSR} | |
31181 | instructions. Note that @option{-mno-jsr} does not mean to not use | |
31182 | @code{JSR} but instead means that any type of branch may be used. | |
31183 | @end table | |
31184 | ||
31185 | @emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}} | |
31186 | has special significance to the RX port when used with the | |
31187 | @code{interrupt} function attribute. This attribute indicates a | |
31188 | function intended to process fast interrupts. GCC ensures | |
31189 | that it only uses the registers @code{r10}, @code{r11}, @code{r12} | |
31190 | and/or @code{r13} and only provided that the normal use of the | |
31191 | corresponding registers have been restricted via the | |
31192 | @option{-ffixed-@var{reg}} or @option{-mint-register} command-line | |
31193 | options. | |
31194 | ||
31195 | @node S/390 and zSeries Options | |
31196 | @subsection S/390 and zSeries Options | |
31197 | @cindex S/390 and zSeries Options | |
31198 | ||
31199 | These are the @samp{-m} options defined for the S/390 and zSeries architecture. | |
31200 | ||
31201 | @table @gcctabopt | |
d77de738 ML |
31202 | @opindex mhard-float |
31203 | @opindex msoft-float | |
ddf6fe37 AA |
31204 | @item -mhard-float |
31205 | @itemx -msoft-float | |
d77de738 ML |
31206 | Use (do not use) the hardware floating-point instructions and registers |
31207 | for floating-point operations. When @option{-msoft-float} is specified, | |
31208 | functions in @file{libgcc.a} are used to perform floating-point | |
31209 | operations. When @option{-mhard-float} is specified, the compiler | |
31210 | generates IEEE floating-point instructions. This is the default. | |
31211 | ||
d77de738 ML |
31212 | @opindex mhard-dfp |
31213 | @opindex mno-hard-dfp | |
ddf6fe37 AA |
31214 | @item -mhard-dfp |
31215 | @itemx -mno-hard-dfp | |
d77de738 ML |
31216 | Use (do not use) the hardware decimal-floating-point instructions for |
31217 | decimal-floating-point operations. When @option{-mno-hard-dfp} is | |
31218 | specified, functions in @file{libgcc.a} are used to perform | |
31219 | decimal-floating-point operations. When @option{-mhard-dfp} is | |
31220 | specified, the compiler generates decimal-floating-point hardware | |
31221 | instructions. This is the default for @option{-march=z9-ec} or higher. | |
31222 | ||
d77de738 ML |
31223 | @opindex mlong-double-64 |
31224 | @opindex mlong-double-128 | |
ddf6fe37 AA |
31225 | @item -mlong-double-64 |
31226 | @itemx -mlong-double-128 | |
d77de738 ML |
31227 | These switches control the size of @code{long double} type. A size |
31228 | of 64 bits makes the @code{long double} type equivalent to the @code{double} | |
31229 | type. This is the default. | |
31230 | ||
d77de738 ML |
31231 | @opindex mbackchain |
31232 | @opindex mno-backchain | |
ddf6fe37 AA |
31233 | @item -mbackchain |
31234 | @itemx -mno-backchain | |
d77de738 ML |
31235 | Store (do not store) the address of the caller's frame as backchain pointer |
31236 | into the callee's stack frame. | |
31237 | A backchain may be needed to allow debugging using tools that do not understand | |
31238 | DWARF call frame information. | |
31239 | When @option{-mno-packed-stack} is in effect, the backchain pointer is stored | |
31240 | at the bottom of the stack frame; when @option{-mpacked-stack} is in effect, | |
31241 | the backchain is placed into the topmost word of the 96/160 byte register | |
31242 | save area. | |
31243 | ||
31244 | In general, code compiled with @option{-mbackchain} is call-compatible with | |
31245 | code compiled with @option{-mno-backchain}; however, use of the backchain | |
31246 | for debugging purposes usually requires that the whole binary is built with | |
31247 | @option{-mbackchain}. Note that the combination of @option{-mbackchain}, | |
31248 | @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order | |
31249 | to build a linux kernel use @option{-msoft-float}. | |
31250 | ||
31251 | The default is to not maintain the backchain. | |
31252 | ||
d77de738 ML |
31253 | @opindex mpacked-stack |
31254 | @opindex mno-packed-stack | |
ddf6fe37 AA |
31255 | @item -mpacked-stack |
31256 | @itemx -mno-packed-stack | |
d77de738 ML |
31257 | Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is |
31258 | specified, the compiler uses the all fields of the 96/160 byte register save | |
31259 | area only for their default purpose; unused fields still take up stack space. | |
31260 | When @option{-mpacked-stack} is specified, register save slots are densely | |
31261 | packed at the top of the register save area; unused space is reused for other | |
31262 | purposes, allowing for more efficient use of the available stack space. | |
31263 | However, when @option{-mbackchain} is also in effect, the topmost word of | |
31264 | the save area is always used to store the backchain, and the return address | |
31265 | register is always saved two words below the backchain. | |
31266 | ||
31267 | As long as the stack frame backchain is not used, code generated with | |
31268 | @option{-mpacked-stack} is call-compatible with code generated with | |
31269 | @option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for | |
31270 | S/390 or zSeries generated code that uses the stack frame backchain at run | |
31271 | time, not just for debugging purposes. Such code is not call-compatible | |
31272 | with code compiled with @option{-mpacked-stack}. Also, note that the | |
31273 | combination of @option{-mbackchain}, | |
31274 | @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order | |
31275 | to build a linux kernel use @option{-msoft-float}. | |
31276 | ||
31277 | The default is to not use the packed stack layout. | |
31278 | ||
d77de738 ML |
31279 | @opindex msmall-exec |
31280 | @opindex mno-small-exec | |
ddf6fe37 AA |
31281 | @item -msmall-exec |
31282 | @itemx -mno-small-exec | |
d77de738 ML |
31283 | Generate (or do not generate) code using the @code{bras} instruction |
31284 | to do subroutine calls. | |
31285 | This only works reliably if the total executable size does not | |
31286 | exceed 64k. The default is to use the @code{basr} instruction instead, | |
31287 | which does not have this limitation. | |
31288 | ||
d77de738 ML |
31289 | @opindex m64 |
31290 | @opindex m31 | |
ddf6fe37 AA |
31291 | @item -m64 |
31292 | @itemx -m31 | |
d77de738 ML |
31293 | When @option{-m31} is specified, generate code compliant to the |
31294 | GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate | |
31295 | code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in | |
31296 | particular to generate 64-bit instructions. For the @samp{s390} | |
31297 | targets, the default is @option{-m31}, while the @samp{s390x} | |
31298 | targets default to @option{-m64}. | |
31299 | ||
d77de738 ML |
31300 | @opindex mzarch |
31301 | @opindex mesa | |
ddf6fe37 AA |
31302 | @item -mzarch |
31303 | @itemx -mesa | |
d77de738 ML |
31304 | When @option{-mzarch} is specified, generate code using the |
31305 | instructions available on z/Architecture. | |
31306 | When @option{-mesa} is specified, generate code using the | |
31307 | instructions available on ESA/390. Note that @option{-mesa} is | |
31308 | not possible with @option{-m64}. | |
31309 | When generating code compliant to the GNU/Linux for S/390 ABI, | |
31310 | the default is @option{-mesa}. When generating code compliant | |
31311 | to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}. | |
31312 | ||
d77de738 ML |
31313 | @opindex mhtm |
31314 | @opindex mno-htm | |
ddf6fe37 AA |
31315 | @item -mhtm |
31316 | @itemx -mno-htm | |
d77de738 ML |
31317 | The @option{-mhtm} option enables a set of builtins making use of |
31318 | instructions available with the transactional execution facility | |
31319 | introduced with the IBM zEnterprise EC12 machine generation | |
31320 | @ref{S/390 System z Built-in Functions}. | |
31321 | @option{-mhtm} is enabled by default when using @option{-march=zEC12}. | |
31322 | ||
d77de738 ML |
31323 | @opindex mvx |
31324 | @opindex mno-vx | |
ddf6fe37 AA |
31325 | @item -mvx |
31326 | @itemx -mno-vx | |
d77de738 ML |
31327 | When @option{-mvx} is specified, generate code using the instructions |
31328 | available with the vector extension facility introduced with the IBM | |
31329 | z13 machine generation. | |
31330 | This option changes the ABI for some vector type values with regard to | |
31331 | alignment and calling conventions. In case vector type values are | |
31332 | being used in an ABI-relevant context a GAS @samp{.gnu_attribute} | |
31333 | command will be added to mark the resulting binary with the ABI used. | |
31334 | @option{-mvx} is enabled by default when using @option{-march=z13}. | |
31335 | ||
d77de738 ML |
31336 | @opindex mzvector |
31337 | @opindex mno-zvector | |
ddf6fe37 AA |
31338 | @item -mzvector |
31339 | @itemx -mno-zvector | |
d77de738 ML |
31340 | The @option{-mzvector} option enables vector language extensions and |
31341 | builtins using instructions available with the vector extension | |
31342 | facility introduced with the IBM z13 machine generation. | |
31343 | This option adds support for @samp{vector} to be used as a keyword to | |
31344 | define vector type variables and arguments. @samp{vector} is only | |
31345 | available when GNU extensions are enabled. It will not be expanded | |
31346 | when requesting strict standard compliance e.g.@: with @option{-std=c99}. | |
31347 | In addition to the GCC low-level builtins @option{-mzvector} enables | |
31348 | a set of builtins added for compatibility with AltiVec-style | |
31349 | implementations like Power and Cell. In order to make use of these | |
31350 | builtins the header file @file{vecintrin.h} needs to be included. | |
31351 | @option{-mzvector} is disabled by default. | |
31352 | ||
d77de738 ML |
31353 | @opindex mmvcle |
31354 | @opindex mno-mvcle | |
ddf6fe37 AA |
31355 | @item -mmvcle |
31356 | @itemx -mno-mvcle | |
d77de738 ML |
31357 | Generate (or do not generate) code using the @code{mvcle} instruction |
31358 | to perform block moves. When @option{-mno-mvcle} is specified, | |
31359 | use a @code{mvc} loop instead. This is the default unless optimizing for | |
31360 | size. | |
31361 | ||
d77de738 ML |
31362 | @opindex mdebug |
31363 | @opindex mno-debug | |
ddf6fe37 AA |
31364 | @item -mdebug |
31365 | @itemx -mno-debug | |
d77de738 ML |
31366 | Print (or do not print) additional debug information when compiling. |
31367 | The default is to not print debug information. | |
31368 | ||
d77de738 | 31369 | @opindex march |
ddf6fe37 | 31370 | @item -march=@var{cpu-type} |
d77de738 ML |
31371 | Generate code that runs on @var{cpu-type}, which is the name of a |
31372 | system representing a certain processor type. Possible values for | |
31373 | @var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6}, | |
31374 | @samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8}, | |
31375 | @samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11}, | |
31376 | @samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13}, | |
31377 | @samp{z16}/@samp{arch14}, and @samp{native}. | |
31378 | ||
31379 | The default is @option{-march=z900}. | |
31380 | ||
31381 | Specifying @samp{native} as cpu type can be used to select the best | |
31382 | architecture option for the host processor. | |
31383 | @option{-march=native} has no effect if GCC does not recognize the | |
31384 | processor. | |
31385 | ||
d77de738 | 31386 | @opindex mtune |
ddf6fe37 | 31387 | @item -mtune=@var{cpu-type} |
d77de738 ML |
31388 | Tune to @var{cpu-type} everything applicable about the generated code, |
31389 | except for the ABI and the set of available instructions. | |
31390 | The list of @var{cpu-type} values is the same as for @option{-march}. | |
31391 | The default is the value used for @option{-march}. | |
31392 | ||
d77de738 ML |
31393 | @opindex mtpf-trace |
31394 | @opindex mno-tpf-trace | |
ddf6fe37 AA |
31395 | @item -mtpf-trace |
31396 | @itemx -mno-tpf-trace | |
d77de738 ML |
31397 | Generate code that adds (does not add) in TPF OS specific branches to trace |
31398 | routines in the operating system. This option is off by default, even | |
31399 | when compiling for the TPF OS@. | |
31400 | ||
d77de738 ML |
31401 | @opindex mtpf-trace-skip |
31402 | @opindex mno-tpf-trace-skip | |
ddf6fe37 AA |
31403 | @item -mtpf-trace-skip |
31404 | @itemx -mno-tpf-trace-skip | |
d77de738 ML |
31405 | Generate code that changes (does not change) the default branch |
31406 | targets enabled by @option{-mtpf-trace} to point to specialized trace | |
31407 | routines providing the ability of selectively skipping function trace | |
31408 | entries for the TPF OS. This option is off by default, even when | |
31409 | compiling for the TPF OS and specifying @option{-mtpf-trace}. | |
31410 | ||
d77de738 ML |
31411 | @opindex mfused-madd |
31412 | @opindex mno-fused-madd | |
ddf6fe37 AA |
31413 | @item -mfused-madd |
31414 | @itemx -mno-fused-madd | |
d77de738 ML |
31415 | Generate code that uses (does not use) the floating-point multiply and |
31416 | accumulate instructions. These instructions are generated by default if | |
31417 | hardware floating point is used. | |
31418 | ||
d77de738 | 31419 | @opindex mwarn-framesize |
ddf6fe37 | 31420 | @item -mwarn-framesize=@var{framesize} |
d77de738 ML |
31421 | Emit a warning if the current function exceeds the given frame size. Because |
31422 | this is a compile-time check it doesn't need to be a real problem when the program | |
31423 | runs. It is intended to identify functions that most probably cause | |
31424 | a stack overflow. It is useful to be used in an environment with limited stack | |
31425 | size e.g.@: the linux kernel. | |
31426 | ||
d77de738 | 31427 | @opindex mwarn-dynamicstack |
ddf6fe37 | 31428 | @item -mwarn-dynamicstack |
d77de738 ML |
31429 | Emit a warning if the function calls @code{alloca} or uses dynamically-sized |
31430 | arrays. This is generally a bad idea with a limited stack size. | |
31431 | ||
d77de738 ML |
31432 | @opindex mstack-guard |
31433 | @opindex mstack-size | |
ddf6fe37 AA |
31434 | @item -mstack-guard=@var{stack-guard} |
31435 | @itemx -mstack-size=@var{stack-size} | |
d77de738 ML |
31436 | If these options are provided the S/390 back end emits additional instructions in |
31437 | the function prologue that trigger a trap if the stack size is @var{stack-guard} | |
31438 | bytes above the @var{stack-size} (remember that the stack on S/390 grows downward). | |
31439 | If the @var{stack-guard} option is omitted the smallest power of 2 larger than | |
31440 | the frame size of the compiled function is chosen. | |
31441 | These options are intended to be used to help debugging stack overflow problems. | |
31442 | The additionally emitted code causes only little overhead and hence can also be | |
31443 | used in production-like systems without greater performance degradation. The given | |
31444 | values have to be exact powers of 2 and @var{stack-size} has to be greater than | |
31445 | @var{stack-guard} without exceeding 64k. | |
31446 | In order to be efficient the extra code makes the assumption that the stack starts | |
31447 | at an address aligned to the value given by @var{stack-size}. | |
31448 | The @var{stack-guard} option can only be used in conjunction with @var{stack-size}. | |
31449 | ||
d77de738 | 31450 | @opindex mhotpatch |
ddf6fe37 | 31451 | @item -mhotpatch=@var{pre-halfwords},@var{post-halfwords} |
d77de738 ML |
31452 | If the hotpatch option is enabled, a ``hot-patching'' function |
31453 | prologue is generated for all functions in the compilation unit. | |
31454 | The funtion label is prepended with the given number of two-byte | |
31455 | NOP instructions (@var{pre-halfwords}, maximum 1000000). After | |
31456 | the label, 2 * @var{post-halfwords} bytes are appended, using the | |
31457 | largest NOP like instructions the architecture allows (maximum | |
31458 | 1000000). | |
31459 | ||
31460 | If both arguments are zero, hotpatching is disabled. | |
31461 | ||
31462 | This option can be overridden for individual functions with the | |
31463 | @code{hotpatch} attribute. | |
31464 | @end table | |
31465 | ||
d77de738 ML |
31466 | @node SH Options |
31467 | @subsection SH Options | |
31468 | ||
31469 | These @samp{-m} options are defined for the SH implementations: | |
31470 | ||
31471 | @table @gcctabopt | |
d77de738 | 31472 | @opindex m1 |
ddf6fe37 | 31473 | @item -m1 |
d77de738 ML |
31474 | Generate code for the SH1. |
31475 | ||
d77de738 | 31476 | @opindex m2 |
ddf6fe37 | 31477 | @item -m2 |
d77de738 ML |
31478 | Generate code for the SH2. |
31479 | ||
31480 | @item -m2e | |
31481 | Generate code for the SH2e. | |
31482 | ||
d77de738 | 31483 | @opindex m2a-nofpu |
ddf6fe37 | 31484 | @item -m2a-nofpu |
d77de738 ML |
31485 | Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way |
31486 | that the floating-point unit is not used. | |
31487 | ||
d77de738 | 31488 | @opindex m2a-single-only |
ddf6fe37 | 31489 | @item -m2a-single-only |
d77de738 ML |
31490 | Generate code for the SH2a-FPU, in such a way that no double-precision |
31491 | floating-point operations are used. | |
31492 | ||
d77de738 | 31493 | @opindex m2a-single |
ddf6fe37 | 31494 | @item -m2a-single |
d77de738 ML |
31495 | Generate code for the SH2a-FPU assuming the floating-point unit is in |
31496 | single-precision mode by default. | |
31497 | ||
d77de738 | 31498 | @opindex m2a |
ddf6fe37 | 31499 | @item -m2a |
d77de738 ML |
31500 | Generate code for the SH2a-FPU assuming the floating-point unit is in |
31501 | double-precision mode by default. | |
31502 | ||
d77de738 | 31503 | @opindex m3 |
ddf6fe37 | 31504 | @item -m3 |
d77de738 ML |
31505 | Generate code for the SH3. |
31506 | ||
d77de738 | 31507 | @opindex m3e |
ddf6fe37 | 31508 | @item -m3e |
d77de738 ML |
31509 | Generate code for the SH3e. |
31510 | ||
d77de738 | 31511 | @opindex m4-nofpu |
ddf6fe37 | 31512 | @item -m4-nofpu |
d77de738 ML |
31513 | Generate code for the SH4 without a floating-point unit. |
31514 | ||
d77de738 | 31515 | @opindex m4-single-only |
ddf6fe37 | 31516 | @item -m4-single-only |
d77de738 ML |
31517 | Generate code for the SH4 with a floating-point unit that only |
31518 | supports single-precision arithmetic. | |
31519 | ||
d77de738 | 31520 | @opindex m4-single |
ddf6fe37 | 31521 | @item -m4-single |
d77de738 ML |
31522 | Generate code for the SH4 assuming the floating-point unit is in |
31523 | single-precision mode by default. | |
31524 | ||
d77de738 | 31525 | @opindex m4 |
ddf6fe37 | 31526 | @item -m4 |
d77de738 ML |
31527 | Generate code for the SH4. |
31528 | ||
d77de738 | 31529 | @opindex m4-100 |
ddf6fe37 | 31530 | @item -m4-100 |
d77de738 ML |
31531 | Generate code for SH4-100. |
31532 | ||
d77de738 | 31533 | @opindex m4-100-nofpu |
ddf6fe37 | 31534 | @item -m4-100-nofpu |
d77de738 ML |
31535 | Generate code for SH4-100 in such a way that the |
31536 | floating-point unit is not used. | |
31537 | ||
d77de738 | 31538 | @opindex m4-100-single |
ddf6fe37 | 31539 | @item -m4-100-single |
d77de738 ML |
31540 | Generate code for SH4-100 assuming the floating-point unit is in |
31541 | single-precision mode by default. | |
31542 | ||
d77de738 | 31543 | @opindex m4-100-single-only |
ddf6fe37 | 31544 | @item -m4-100-single-only |
d77de738 ML |
31545 | Generate code for SH4-100 in such a way that no double-precision |
31546 | floating-point operations are used. | |
31547 | ||
d77de738 | 31548 | @opindex m4-200 |
ddf6fe37 | 31549 | @item -m4-200 |
d77de738 ML |
31550 | Generate code for SH4-200. |
31551 | ||
d77de738 | 31552 | @opindex m4-200-nofpu |
ddf6fe37 | 31553 | @item -m4-200-nofpu |
d77de738 ML |
31554 | Generate code for SH4-200 without in such a way that the |
31555 | floating-point unit is not used. | |
31556 | ||
d77de738 | 31557 | @opindex m4-200-single |
ddf6fe37 | 31558 | @item -m4-200-single |
d77de738 ML |
31559 | Generate code for SH4-200 assuming the floating-point unit is in |
31560 | single-precision mode by default. | |
31561 | ||
d77de738 | 31562 | @opindex m4-200-single-only |
ddf6fe37 | 31563 | @item -m4-200-single-only |
d77de738 ML |
31564 | Generate code for SH4-200 in such a way that no double-precision |
31565 | floating-point operations are used. | |
31566 | ||
d77de738 | 31567 | @opindex m4-300 |
ddf6fe37 | 31568 | @item -m4-300 |
d77de738 ML |
31569 | Generate code for SH4-300. |
31570 | ||
d77de738 | 31571 | @opindex m4-300-nofpu |
ddf6fe37 | 31572 | @item -m4-300-nofpu |
d77de738 ML |
31573 | Generate code for SH4-300 without in such a way that the |
31574 | floating-point unit is not used. | |
31575 | ||
d77de738 | 31576 | @opindex m4-300-single |
ddf6fe37 | 31577 | @item -m4-300-single |
d77de738 ML |
31578 | Generate code for SH4-300 in such a way that no double-precision |
31579 | floating-point operations are used. | |
31580 | ||
d77de738 | 31581 | @opindex m4-300-single-only |
ddf6fe37 | 31582 | @item -m4-300-single-only |
d77de738 ML |
31583 | Generate code for SH4-300 in such a way that no double-precision |
31584 | floating-point operations are used. | |
31585 | ||
d77de738 | 31586 | @opindex m4-340 |
ddf6fe37 | 31587 | @item -m4-340 |
d77de738 ML |
31588 | Generate code for SH4-340 (no MMU, no FPU). |
31589 | ||
d77de738 | 31590 | @opindex m4-500 |
ddf6fe37 | 31591 | @item -m4-500 |
d77de738 ML |
31592 | Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the |
31593 | assembler. | |
31594 | ||
d77de738 | 31595 | @opindex m4a-nofpu |
ddf6fe37 | 31596 | @item -m4a-nofpu |
d77de738 ML |
31597 | Generate code for the SH4al-dsp, or for a SH4a in such a way that the |
31598 | floating-point unit is not used. | |
31599 | ||
d77de738 | 31600 | @opindex m4a-single-only |
ddf6fe37 | 31601 | @item -m4a-single-only |
d77de738 ML |
31602 | Generate code for the SH4a, in such a way that no double-precision |
31603 | floating-point operations are used. | |
31604 | ||
d77de738 | 31605 | @opindex m4a-single |
ddf6fe37 | 31606 | @item -m4a-single |
d77de738 ML |
31607 | Generate code for the SH4a assuming the floating-point unit is in |
31608 | single-precision mode by default. | |
31609 | ||
d77de738 | 31610 | @opindex m4a |
ddf6fe37 | 31611 | @item -m4a |
d77de738 ML |
31612 | Generate code for the SH4a. |
31613 | ||
d77de738 | 31614 | @opindex m4al |
ddf6fe37 | 31615 | @item -m4al |
d77de738 ML |
31616 | Same as @option{-m4a-nofpu}, except that it implicitly passes |
31617 | @option{-dsp} to the assembler. GCC doesn't generate any DSP | |
31618 | instructions at the moment. | |
31619 | ||
d77de738 | 31620 | @opindex mb |
ddf6fe37 | 31621 | @item -mb |
d77de738 ML |
31622 | Compile code for the processor in big-endian mode. |
31623 | ||
d77de738 | 31624 | @opindex ml |
ddf6fe37 | 31625 | @item -ml |
d77de738 ML |
31626 | Compile code for the processor in little-endian mode. |
31627 | ||
d77de738 | 31628 | @opindex mdalign |
ddf6fe37 | 31629 | @item -mdalign |
d77de738 ML |
31630 | Align doubles at 64-bit boundaries. Note that this changes the calling |
31631 | conventions, and thus some functions from the standard C library do | |
31632 | not work unless you recompile it first with @option{-mdalign}. | |
31633 | ||
d77de738 | 31634 | @opindex mrelax |
ddf6fe37 | 31635 | @item -mrelax |
d77de738 ML |
31636 | Shorten some address references at link time, when possible; uses the |
31637 | linker option @option{-relax}. | |
31638 | ||
d77de738 | 31639 | @opindex mbigtable |
ddf6fe37 | 31640 | @item -mbigtable |
d77de738 ML |
31641 | Use 32-bit offsets in @code{switch} tables. The default is to use |
31642 | 16-bit offsets. | |
31643 | ||
d77de738 | 31644 | @opindex mbitops |
ddf6fe37 | 31645 | @item -mbitops |
d77de738 ML |
31646 | Enable the use of bit manipulation instructions on SH2A. |
31647 | ||
d77de738 | 31648 | @opindex mfmovd |
ddf6fe37 | 31649 | @item -mfmovd |
d77de738 ML |
31650 | Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for |
31651 | alignment constraints. | |
31652 | ||
d77de738 | 31653 | @opindex mrenesas |
ddf6fe37 | 31654 | @item -mrenesas |
d77de738 ML |
31655 | Comply with the calling conventions defined by Renesas. |
31656 | ||
d77de738 | 31657 | @opindex mno-renesas |
ddf6fe37 | 31658 | @item -mno-renesas |
d77de738 ML |
31659 | Comply with the calling conventions defined for GCC before the Renesas |
31660 | conventions were available. This option is the default for all | |
31661 | targets of the SH toolchain. | |
31662 | ||
d77de738 | 31663 | @opindex mnomacsave |
ddf6fe37 | 31664 | @item -mnomacsave |
d77de738 ML |
31665 | Mark the @code{MAC} register as call-clobbered, even if |
31666 | @option{-mrenesas} is given. | |
31667 | ||
d77de738 ML |
31668 | @opindex mieee |
31669 | @opindex mno-ieee | |
ddf6fe37 AA |
31670 | @item -mieee |
31671 | @itemx -mno-ieee | |
d77de738 ML |
31672 | Control the IEEE compliance of floating-point comparisons, which affects the |
31673 | handling of cases where the result of a comparison is unordered. By default | |
31674 | @option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is | |
31675 | enabled @option{-mno-ieee} is implicitly set, which results in faster | |
31676 | floating-point greater-equal and less-equal comparisons. The implicit settings | |
31677 | can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}. | |
31678 | ||
d77de738 | 31679 | @opindex minline-ic_invalidate |
ddf6fe37 | 31680 | @item -minline-ic_invalidate |
d77de738 ML |
31681 | Inline code to invalidate instruction cache entries after setting up |
31682 | nested function trampolines. | |
31683 | This option has no effect if @option{-musermode} is in effect and the selected | |
31684 | code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi} | |
31685 | instruction. | |
31686 | If the selected code generation option does not allow the use of the @code{icbi} | |
31687 | instruction, and @option{-musermode} is not in effect, the inlined code | |
31688 | manipulates the instruction cache address array directly with an associative | |
31689 | write. This not only requires privileged mode at run time, but it also | |
31690 | fails if the cache line had been mapped via the TLB and has become unmapped. | |
31691 | ||
d77de738 | 31692 | @opindex misize |
ddf6fe37 | 31693 | @item -misize |
d77de738 ML |
31694 | Dump instruction size and location in the assembly code. |
31695 | ||
d77de738 | 31696 | @opindex mpadstruct |
ddf6fe37 | 31697 | @item -mpadstruct |
d77de738 ML |
31698 | This option is deprecated. It pads structures to multiple of 4 bytes, |
31699 | which is incompatible with the SH ABI@. | |
31700 | ||
d77de738 | 31701 | @opindex matomic-model=@var{model} |
ddf6fe37 | 31702 | @item -matomic-model=@var{model} |
d77de738 ML |
31703 | Sets the model of atomic operations and additional parameters as a comma |
31704 | separated list. For details on the atomic built-in functions see | |
31705 | @ref{__atomic Builtins}. The following models and parameters are supported: | |
31706 | ||
31707 | @table @samp | |
31708 | ||
31709 | @item none | |
31710 | Disable compiler generated atomic sequences and emit library calls for atomic | |
31711 | operations. This is the default if the target is not @code{sh*-*-linux*}. | |
31712 | ||
31713 | @item soft-gusa | |
31714 | Generate GNU/Linux compatible gUSA software atomic sequences for the atomic | |
31715 | built-in functions. The generated atomic sequences require additional support | |
31716 | from the interrupt/exception handling code of the system and are only suitable | |
31717 | for SH3* and SH4* single-core systems. This option is enabled by default when | |
31718 | the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A, | |
31719 | this option also partially utilizes the hardware atomic instructions | |
31720 | @code{movli.l} and @code{movco.l} to create more efficient code, unless | |
31721 | @samp{strict} is specified. | |
31722 | ||
31723 | @item soft-tcb | |
31724 | Generate software atomic sequences that use a variable in the thread control | |
31725 | block. This is a variation of the gUSA sequences which can also be used on | |
31726 | SH1* and SH2* targets. The generated atomic sequences require additional | |
31727 | support from the interrupt/exception handling code of the system and are only | |
31728 | suitable for single-core systems. When using this model, the @samp{gbr-offset=} | |
31729 | parameter has to be specified as well. | |
31730 | ||
31731 | @item soft-imask | |
31732 | Generate software atomic sequences that temporarily disable interrupts by | |
31733 | setting @code{SR.IMASK = 1111}. This model works only when the program runs | |
31734 | in privileged mode and is only suitable for single-core systems. Additional | |
31735 | support from the interrupt/exception handling code of the system is not | |
31736 | required. This model is enabled by default when the target is | |
31737 | @code{sh*-*-linux*} and SH1* or SH2*. | |
31738 | ||
31739 | @item hard-llcs | |
31740 | Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l} | |
31741 | instructions only. This is only available on SH4A and is suitable for | |
31742 | multi-core systems. Since the hardware instructions support only 32 bit atomic | |
31743 | variables access to 8 or 16 bit variables is emulated with 32 bit accesses. | |
31744 | Code compiled with this option is also compatible with other software | |
31745 | atomic model interrupt/exception handling systems if executed on an SH4A | |
31746 | system. Additional support from the interrupt/exception handling code of the | |
31747 | system is not required for this model. | |
31748 | ||
31749 | @item gbr-offset= | |
31750 | This parameter specifies the offset in bytes of the variable in the thread | |
31751 | control block structure that should be used by the generated atomic sequences | |
31752 | when the @samp{soft-tcb} model has been selected. For other models this | |
31753 | parameter is ignored. The specified value must be an integer multiple of four | |
31754 | and in the range 0-1020. | |
31755 | ||
31756 | @item strict | |
31757 | This parameter prevents mixed usage of multiple atomic models, even if they | |
31758 | are compatible, and makes the compiler generate atomic sequences of the | |
31759 | specified model only. | |
31760 | ||
31761 | @end table | |
31762 | ||
d77de738 | 31763 | @opindex mtas |
ddf6fe37 | 31764 | @item -mtas |
d77de738 ML |
31765 | Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}. |
31766 | Notice that depending on the particular hardware and software configuration | |
31767 | this can degrade overall performance due to the operand cache line flushes | |
31768 | that are implied by the @code{tas.b} instruction. On multi-core SH4A | |
31769 | processors the @code{tas.b} instruction must be used with caution since it | |
31770 | can result in data corruption for certain cache configurations. | |
31771 | ||
d77de738 | 31772 | @opindex mprefergot |
ddf6fe37 | 31773 | @item -mprefergot |
d77de738 ML |
31774 | When generating position-independent code, emit function calls using |
31775 | the Global Offset Table instead of the Procedure Linkage Table. | |
31776 | ||
d77de738 ML |
31777 | @opindex musermode |
31778 | @opindex mno-usermode | |
ddf6fe37 AA |
31779 | @item -musermode |
31780 | @itemx -mno-usermode | |
d77de738 ML |
31781 | Don't allow (allow) the compiler generating privileged mode code. Specifying |
31782 | @option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the | |
31783 | inlined code would not work in user mode. @option{-musermode} is the default | |
31784 | when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2* | |
31785 | @option{-musermode} has no effect, since there is no user mode. | |
31786 | ||
d77de738 | 31787 | @opindex multcost=@var{number} |
ddf6fe37 | 31788 | @item -multcost=@var{number} |
d77de738 ML |
31789 | Set the cost to assume for a multiply insn. |
31790 | ||
d77de738 | 31791 | @opindex mdiv=@var{strategy} |
ddf6fe37 | 31792 | @item -mdiv=@var{strategy} |
d77de738 ML |
31793 | Set the division strategy to be used for integer division operations. |
31794 | @var{strategy} can be one of: | |
31795 | ||
31796 | @table @samp | |
31797 | ||
31798 | @item call-div1 | |
31799 | Calls a library function that uses the single-step division instruction | |
31800 | @code{div1} to perform the operation. Division by zero calculates an | |
31801 | unspecified result and does not trap. This is the default except for SH4, | |
31802 | SH2A and SHcompact. | |
31803 | ||
31804 | @item call-fp | |
31805 | Calls a library function that performs the operation in double precision | |
31806 | floating point. Division by zero causes a floating-point exception. This is | |
31807 | the default for SHcompact with FPU. Specifying this for targets that do not | |
31808 | have a double precision FPU defaults to @code{call-div1}. | |
31809 | ||
31810 | @item call-table | |
31811 | Calls a library function that uses a lookup table for small divisors and | |
31812 | the @code{div1} instruction with case distinction for larger divisors. Division | |
31813 | by zero calculates an unspecified result and does not trap. This is the default | |
31814 | for SH4. Specifying this for targets that do not have dynamic shift | |
31815 | instructions defaults to @code{call-div1}. | |
31816 | ||
31817 | @end table | |
31818 | ||
31819 | When a division strategy has not been specified the default strategy is | |
31820 | selected based on the current target. For SH2A the default strategy is to | |
31821 | use the @code{divs} and @code{divu} instructions instead of library function | |
31822 | calls. | |
31823 | ||
d77de738 | 31824 | @opindex maccumulate-outgoing-args |
ddf6fe37 | 31825 | @item -maccumulate-outgoing-args |
d77de738 ML |
31826 | Reserve space once for outgoing arguments in the function prologue rather |
31827 | than around each call. Generally beneficial for performance and size. Also | |
31828 | needed for unwinding to avoid changing the stack frame around conditional code. | |
31829 | ||
d77de738 | 31830 | @opindex mdivsi3_libfunc=@var{name} |
ddf6fe37 | 31831 | @item -mdivsi3_libfunc=@var{name} |
d77de738 ML |
31832 | Set the name of the library function used for 32-bit signed division to |
31833 | @var{name}. | |
31834 | This only affects the name used in the @samp{call} division strategies, and | |
31835 | the compiler still expects the same sets of input/output/clobbered registers as | |
31836 | if this option were not present. | |
31837 | ||
d77de738 | 31838 | @opindex mfixed-range |
ddf6fe37 | 31839 | @item -mfixed-range=@var{register-range} |
d77de738 ML |
31840 | Generate code treating the given register range as fixed registers. |
31841 | A fixed register is one that the register allocator cannot use. This is | |
31842 | useful when compiling kernel code. A register range is specified as | |
31843 | two registers separated by a dash. Multiple register ranges can be | |
31844 | specified separated by a comma. | |
31845 | ||
d77de738 | 31846 | @opindex mbranch-cost=@var{num} |
ddf6fe37 | 31847 | @item -mbranch-cost=@var{num} |
d77de738 ML |
31848 | Assume @var{num} to be the cost for a branch instruction. Higher numbers |
31849 | make the compiler try to generate more branch-free code if possible. | |
31850 | If not specified the value is selected depending on the processor type that | |
31851 | is being compiled for. | |
31852 | ||
d77de738 ML |
31853 | @opindex mzdcbranch |
31854 | @opindex mno-zdcbranch | |
ddf6fe37 AA |
31855 | @item -mzdcbranch |
31856 | @itemx -mno-zdcbranch | |
d77de738 ML |
31857 | Assume (do not assume) that zero displacement conditional branch instructions |
31858 | @code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the | |
31859 | compiler prefers zero displacement branch code sequences. This is | |
31860 | enabled by default when generating code for SH4 and SH4A. It can be explicitly | |
31861 | disabled by specifying @option{-mno-zdcbranch}. | |
31862 | ||
d77de738 | 31863 | @opindex mcbranch-force-delay-slot |
ddf6fe37 | 31864 | @item -mcbranch-force-delay-slot |
d77de738 ML |
31865 | Force the usage of delay slots for conditional branches, which stuffs the delay |
31866 | slot with a @code{nop} if a suitable instruction cannot be found. By default | |
31867 | this option is disabled. It can be enabled to work around hardware bugs as | |
31868 | found in the original SH7055. | |
31869 | ||
d77de738 ML |
31870 | @opindex mfused-madd |
31871 | @opindex mno-fused-madd | |
ddf6fe37 AA |
31872 | @item -mfused-madd |
31873 | @itemx -mno-fused-madd | |
d77de738 ML |
31874 | Generate code that uses (does not use) the floating-point multiply and |
31875 | accumulate instructions. These instructions are generated by default | |
31876 | if hardware floating point is used. The machine-dependent | |
31877 | @option{-mfused-madd} option is now mapped to the machine-independent | |
31878 | @option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is | |
31879 | mapped to @option{-ffp-contract=off}. | |
31880 | ||
d77de738 ML |
31881 | @opindex mfsca |
31882 | @opindex mno-fsca | |
ddf6fe37 AA |
31883 | @item -mfsca |
31884 | @itemx -mno-fsca | |
d77de738 ML |
31885 | Allow or disallow the compiler to emit the @code{fsca} instruction for sine |
31886 | and cosine approximations. The option @option{-mfsca} must be used in | |
31887 | combination with @option{-funsafe-math-optimizations}. It is enabled by default | |
31888 | when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine | |
31889 | approximations even if @option{-funsafe-math-optimizations} is in effect. | |
31890 | ||
d77de738 ML |
31891 | @opindex mfsrra |
31892 | @opindex mno-fsrra | |
ddf6fe37 AA |
31893 | @item -mfsrra |
31894 | @itemx -mno-fsrra | |
d77de738 ML |
31895 | Allow or disallow the compiler to emit the @code{fsrra} instruction for |
31896 | reciprocal square root approximations. The option @option{-mfsrra} must be used | |
31897 | in combination with @option{-funsafe-math-optimizations} and | |
31898 | @option{-ffinite-math-only}. It is enabled by default when generating code for | |
31899 | SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations | |
31900 | even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are | |
31901 | in effect. | |
31902 | ||
d77de738 | 31903 | @opindex mpretend-cmove |
ddf6fe37 | 31904 | @item -mpretend-cmove |
d77de738 ML |
31905 | Prefer zero-displacement conditional branches for conditional move instruction |
31906 | patterns. This can result in faster code on the SH4 processor. | |
31907 | ||
d77de738 | 31908 | @opindex fdpic |
ddf6fe37 | 31909 | @item -mfdpic |
d77de738 ML |
31910 | Generate code using the FDPIC ABI. |
31911 | ||
31912 | @end table | |
31913 | ||
31914 | @node Solaris 2 Options | |
31915 | @subsection Solaris 2 Options | |
31916 | @cindex Solaris 2 options | |
31917 | ||
31918 | These @samp{-m} options are supported on Solaris 2: | |
31919 | ||
31920 | @table @gcctabopt | |
d77de738 | 31921 | @opindex mclear-hwcap |
ddf6fe37 | 31922 | @item -mclear-hwcap |
d77de738 ML |
31923 | @option{-mclear-hwcap} tells the compiler to remove the hardware |
31924 | capabilities generated by the Solaris assembler. This is only necessary | |
31925 | when object files use ISA extensions not supported by the current | |
31926 | machine, but check at runtime whether or not to use them. | |
31927 | ||
d77de738 | 31928 | @opindex mimpure-text |
ddf6fe37 | 31929 | @item -mimpure-text |
d77de738 ML |
31930 | @option{-mimpure-text}, used in addition to @option{-shared}, tells |
31931 | the compiler to not pass @option{-z text} to the linker when linking a | |
31932 | shared object. Using this option, you can link position-dependent | |
31933 | code into a shared object. | |
31934 | ||
31935 | @option{-mimpure-text} suppresses the ``relocations remain against | |
31936 | allocatable but non-writable sections'' linker error message. | |
31937 | However, the necessary relocations trigger copy-on-write, and the | |
31938 | shared object is not actually shared across processes. Instead of | |
31939 | using @option{-mimpure-text}, you should compile all source code with | |
31940 | @option{-fpic} or @option{-fPIC}. | |
31941 | ||
31942 | @end table | |
31943 | ||
31944 | These switches are supported in addition to the above on Solaris 2: | |
31945 | ||
31946 | @table @gcctabopt | |
d77de738 | 31947 | @opindex pthreads |
ddf6fe37 | 31948 | @item -pthreads |
d77de738 ML |
31949 | This is a synonym for @option{-pthread}. |
31950 | @end table | |
31951 | ||
31952 | @node SPARC Options | |
31953 | @subsection SPARC Options | |
31954 | @cindex SPARC options | |
31955 | ||
31956 | These @samp{-m} options are supported on the SPARC: | |
31957 | ||
31958 | @table @gcctabopt | |
d77de738 ML |
31959 | @opindex mno-app-regs |
31960 | @opindex mapp-regs | |
ddf6fe37 AA |
31961 | @item -mno-app-regs |
31962 | @itemx -mapp-regs | |
d77de738 ML |
31963 | Specify @option{-mapp-regs} to generate output using the global registers |
31964 | 2 through 4, which the SPARC SVR4 ABI reserves for applications. Like the | |
31965 | global register 1, each global register 2 through 4 is then treated as an | |
31966 | allocable register that is clobbered by function calls. This is the default. | |
31967 | ||
31968 | To be fully SVR4 ABI-compliant at the cost of some performance loss, | |
31969 | specify @option{-mno-app-regs}. You should compile libraries and system | |
31970 | software with this option. | |
31971 | ||
d77de738 ML |
31972 | @opindex mflat |
31973 | @opindex mno-flat | |
ddf6fe37 AA |
31974 | @item -mflat |
31975 | @itemx -mno-flat | |
d77de738 ML |
31976 | With @option{-mflat}, the compiler does not generate save/restore instructions |
31977 | and uses a ``flat'' or single register window model. This model is compatible | |
31978 | with the regular register window model. The local registers and the input | |
31979 | registers (0--5) are still treated as ``call-saved'' registers and are | |
31980 | saved on the stack as needed. | |
31981 | ||
31982 | With @option{-mno-flat} (the default), the compiler generates save/restore | |
31983 | instructions (except for leaf functions). This is the normal operating mode. | |
31984 | ||
d77de738 ML |
31985 | @opindex mfpu |
31986 | @opindex mhard-float | |
ddf6fe37 AA |
31987 | @item -mfpu |
31988 | @itemx -mhard-float | |
d77de738 ML |
31989 | Generate output containing floating-point instructions. This is the |
31990 | default. | |
31991 | ||
d77de738 ML |
31992 | @opindex mno-fpu |
31993 | @opindex msoft-float | |
ddf6fe37 AA |
31994 | @item -mno-fpu |
31995 | @itemx -msoft-float | |
d77de738 ML |
31996 | Generate output containing library calls for floating point. |
31997 | @strong{Warning:} the requisite libraries are not available for all SPARC | |
31998 | targets. Normally the facilities of the machine's usual C compiler are | |
31999 | used, but this cannot be done directly in cross-compilation. You must make | |
32000 | your own arrangements to provide suitable library functions for | |
32001 | cross-compilation. The embedded targets @samp{sparc-*-aout} and | |
32002 | @samp{sparclite-*-*} do provide software floating-point support. | |
32003 | ||
32004 | @option{-msoft-float} changes the calling convention in the output file; | |
32005 | therefore, it is only useful if you compile @emph{all} of a program with | |
32006 | this option. In particular, you need to compile @file{libgcc.a}, the | |
32007 | library that comes with GCC, with @option{-msoft-float} in order for | |
32008 | this to work. | |
32009 | ||
d77de738 | 32010 | @opindex mhard-quad-float |
ddf6fe37 | 32011 | @item -mhard-quad-float |
d77de738 ML |
32012 | Generate output containing quad-word (long double) floating-point |
32013 | instructions. | |
32014 | ||
d77de738 | 32015 | @opindex msoft-quad-float |
ddf6fe37 | 32016 | @item -msoft-quad-float |
d77de738 ML |
32017 | Generate output containing library calls for quad-word (long double) |
32018 | floating-point instructions. The functions called are those specified | |
32019 | in the SPARC ABI@. This is the default. | |
32020 | ||
32021 | As of this writing, there are no SPARC implementations that have hardware | |
32022 | support for the quad-word floating-point instructions. They all invoke | |
32023 | a trap handler for one of these instructions, and then the trap handler | |
32024 | emulates the effect of the instruction. Because of the trap handler overhead, | |
32025 | this is much slower than calling the ABI library routines. Thus the | |
32026 | @option{-msoft-quad-float} option is the default. | |
32027 | ||
d77de738 ML |
32028 | @opindex mno-unaligned-doubles |
32029 | @opindex munaligned-doubles | |
ddf6fe37 AA |
32030 | @item -mno-unaligned-doubles |
32031 | @itemx -munaligned-doubles | |
d77de738 ML |
32032 | Assume that doubles have 8-byte alignment. This is the default. |
32033 | ||
32034 | With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte | |
32035 | alignment only if they are contained in another type, or if they have an | |
32036 | absolute address. Otherwise, it assumes they have 4-byte alignment. | |
32037 | Specifying this option avoids some rare compatibility problems with code | |
32038 | generated by other compilers. It is not the default because it results | |
32039 | in a performance loss, especially for floating-point code. | |
32040 | ||
d77de738 ML |
32041 | @opindex muser-mode |
32042 | @opindex mno-user-mode | |
ddf6fe37 AA |
32043 | @item -muser-mode |
32044 | @itemx -mno-user-mode | |
d77de738 ML |
32045 | Do not generate code that can only run in supervisor mode. This is relevant |
32046 | only for the @code{casa} instruction emitted for the LEON3 processor. This | |
32047 | is the default. | |
32048 | ||
d77de738 ML |
32049 | @opindex mfaster-structs |
32050 | @opindex mno-faster-structs | |
ddf6fe37 AA |
32051 | @item -mfaster-structs |
32052 | @itemx -mno-faster-structs | |
d77de738 ML |
32053 | With @option{-mfaster-structs}, the compiler assumes that structures |
32054 | should have 8-byte alignment. This enables the use of pairs of | |
32055 | @code{ldd} and @code{std} instructions for copies in structure | |
32056 | assignment, in place of twice as many @code{ld} and @code{st} pairs. | |
32057 | However, the use of this changed alignment directly violates the SPARC | |
32058 | ABI@. Thus, it's intended only for use on targets where the developer | |
32059 | acknowledges that their resulting code is not directly in line with | |
32060 | the rules of the ABI@. | |
32061 | ||
d77de738 ML |
32062 | @opindex mstd-struct-return |
32063 | @opindex mno-std-struct-return | |
ddf6fe37 AA |
32064 | @item -mstd-struct-return |
32065 | @itemx -mno-std-struct-return | |
d77de738 ML |
32066 | With @option{-mstd-struct-return}, the compiler generates checking code |
32067 | in functions returning structures or unions to detect size mismatches | |
32068 | between the two sides of function calls, as per the 32-bit ABI@. | |
32069 | ||
32070 | The default is @option{-mno-std-struct-return}. This option has no effect | |
32071 | in 64-bit mode. | |
32072 | ||
d77de738 ML |
32073 | @opindex mlra |
32074 | @opindex mno-lra | |
ddf6fe37 AA |
32075 | @item -mlra |
32076 | @itemx -mno-lra | |
d77de738 ML |
32077 | Enable Local Register Allocation. This is the default for SPARC since GCC 7 |
32078 | so @option{-mno-lra} needs to be passed to get old Reload. | |
32079 | ||
d77de738 | 32080 | @opindex mcpu |
ddf6fe37 | 32081 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
32082 | Set the instruction set, register set, and instruction scheduling parameters |
32083 | for machine type @var{cpu_type}. Supported values for @var{cpu_type} are | |
32084 | @samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc}, | |
32085 | @samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite}, | |
32086 | @samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701}, | |
32087 | @samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara}, | |
32088 | @samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and | |
32089 | @samp{m8}. | |
32090 | ||
32091 | Native Solaris and GNU/Linux toolchains also support the value @samp{native}, | |
32092 | which selects the best architecture option for the host processor. | |
32093 | @option{-mcpu=native} has no effect if GCC does not recognize | |
32094 | the processor. | |
32095 | ||
32096 | Default instruction scheduling parameters are used for values that select | |
32097 | an architecture and not an implementation. These are @samp{v7}, @samp{v8}, | |
32098 | @samp{sparclite}, @samp{sparclet}, @samp{v9}. | |
32099 | ||
32100 | Here is a list of each supported architecture and their supported | |
32101 | implementations. | |
32102 | ||
32103 | @table @asis | |
32104 | @item v7 | |
32105 | cypress, leon3v7 | |
32106 | ||
32107 | @item v8 | |
32108 | supersparc, hypersparc, leon, leon3, leon5 | |
32109 | ||
32110 | @item sparclite | |
32111 | f930, f934, sparclite86x | |
32112 | ||
32113 | @item sparclet | |
32114 | tsc701 | |
32115 | ||
32116 | @item v9 | |
32117 | ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4, | |
32118 | niagara7, m8 | |
32119 | @end table | |
32120 | ||
32121 | By default (unless configured otherwise), GCC generates code for the V7 | |
32122 | variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler | |
32123 | additionally optimizes it for the Cypress CY7C602 chip, as used in the | |
32124 | SPARCStation/SPARCServer 3xx series. This is also appropriate for the older | |
32125 | SPARCStation 1, 2, IPX etc. | |
32126 | ||
32127 | With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC | |
32128 | architecture. The only difference from V7 code is that the compiler emits | |
32129 | the integer multiply and integer divide instructions which exist in SPARC-V8 | |
32130 | but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally | |
32131 | optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and | |
32132 | 2000 series. | |
32133 | ||
32134 | With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of | |
32135 | the SPARC architecture. This adds the integer multiply, integer divide step | |
32136 | and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7. | |
32137 | With @option{-mcpu=f930}, the compiler additionally optimizes it for the | |
32138 | Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With | |
32139 | @option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu | |
32140 | MB86934 chip, which is the more recent SPARClite with FPU@. | |
32141 | ||
32142 | With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of | |
32143 | the SPARC architecture. This adds the integer multiply, multiply/accumulate, | |
32144 | integer divide step and scan (@code{ffs}) instructions which exist in SPARClet | |
32145 | but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally | |
32146 | optimizes it for the TEMIC SPARClet chip. | |
32147 | ||
32148 | With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC | |
32149 | architecture. This adds 64-bit integer and floating-point move instructions, | |
32150 | 3 additional floating-point condition code registers and conditional move | |
32151 | instructions. With @option{-mcpu=ultrasparc}, the compiler additionally | |
32152 | optimizes it for the Sun UltraSPARC I/II/IIi chips. With | |
32153 | @option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the | |
32154 | Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With | |
32155 | @option{-mcpu=niagara}, the compiler additionally optimizes it for | |
32156 | Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler | |
32157 | additionally optimizes it for Sun UltraSPARC T2 chips. With | |
32158 | @option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun | |
32159 | UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler | |
32160 | additionally optimizes it for Sun UltraSPARC T4 chips. With | |
32161 | @option{-mcpu=niagara7}, the compiler additionally optimizes it for | |
32162 | Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler | |
32163 | additionally optimizes it for Oracle M8 chips. | |
32164 | ||
d77de738 | 32165 | @opindex mtune |
ddf6fe37 | 32166 | @item -mtune=@var{cpu_type} |
d77de738 ML |
32167 | Set the instruction scheduling parameters for machine type |
32168 | @var{cpu_type}, but do not set the instruction set or register set that the | |
32169 | option @option{-mcpu=@var{cpu_type}} does. | |
32170 | ||
32171 | The same values for @option{-mcpu=@var{cpu_type}} can be used for | |
32172 | @option{-mtune=@var{cpu_type}}, but the only useful values are those | |
32173 | that select a particular CPU implementation. Those are | |
32174 | @samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon}, | |
32175 | @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934}, | |
32176 | @samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc}, | |
32177 | @samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3}, | |
32178 | @samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris | |
32179 | and GNU/Linux toolchains, @samp{native} can also be used. | |
32180 | ||
d77de738 ML |
32181 | @opindex mv8plus |
32182 | @opindex mno-v8plus | |
ddf6fe37 AA |
32183 | @item -mv8plus |
32184 | @itemx -mno-v8plus | |
d77de738 ML |
32185 | With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The |
32186 | difference from the V8 ABI is that the global and out registers are | |
32187 | considered 64 bits wide. This is enabled by default on Solaris in 32-bit | |
32188 | mode for all SPARC-V9 processors. | |
32189 | ||
d77de738 ML |
32190 | @opindex mvis |
32191 | @opindex mno-vis | |
ddf6fe37 AA |
32192 | @item -mvis |
32193 | @itemx -mno-vis | |
d77de738 ML |
32194 | With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC |
32195 | Visual Instruction Set extensions. The default is @option{-mno-vis}. | |
32196 | ||
d77de738 ML |
32197 | @opindex mvis2 |
32198 | @opindex mno-vis2 | |
ddf6fe37 AA |
32199 | @item -mvis2 |
32200 | @itemx -mno-vis2 | |
d77de738 ML |
32201 | With @option{-mvis2}, GCC generates code that takes advantage of |
32202 | version 2.0 of the UltraSPARC Visual Instruction Set extensions. The | |
32203 | default is @option{-mvis2} when targeting a cpu that supports such | |
32204 | instructions, such as UltraSPARC-III and later. Setting @option{-mvis2} | |
32205 | also sets @option{-mvis}. | |
32206 | ||
d77de738 ML |
32207 | @opindex mvis3 |
32208 | @opindex mno-vis3 | |
ddf6fe37 AA |
32209 | @item -mvis3 |
32210 | @itemx -mno-vis3 | |
d77de738 ML |
32211 | With @option{-mvis3}, GCC generates code that takes advantage of |
32212 | version 3.0 of the UltraSPARC Visual Instruction Set extensions. The | |
32213 | default is @option{-mvis3} when targeting a cpu that supports such | |
32214 | instructions, such as niagara-3 and later. Setting @option{-mvis3} | |
32215 | also sets @option{-mvis2} and @option{-mvis}. | |
32216 | ||
d77de738 ML |
32217 | @opindex mvis4 |
32218 | @opindex mno-vis4 | |
ddf6fe37 AA |
32219 | @item -mvis4 |
32220 | @itemx -mno-vis4 | |
d77de738 ML |
32221 | With @option{-mvis4}, GCC generates code that takes advantage of |
32222 | version 4.0 of the UltraSPARC Visual Instruction Set extensions. The | |
32223 | default is @option{-mvis4} when targeting a cpu that supports such | |
32224 | instructions, such as niagara-7 and later. Setting @option{-mvis4} | |
32225 | also sets @option{-mvis3}, @option{-mvis2} and @option{-mvis}. | |
32226 | ||
d77de738 ML |
32227 | @opindex mvis4b |
32228 | @opindex mno-vis4b | |
ddf6fe37 AA |
32229 | @item -mvis4b |
32230 | @itemx -mno-vis4b | |
d77de738 ML |
32231 | With @option{-mvis4b}, GCC generates code that takes advantage of |
32232 | version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus | |
32233 | the additional VIS instructions introduced in the Oracle SPARC | |
32234 | Architecture 2017. The default is @option{-mvis4b} when targeting a | |
32235 | cpu that supports such instructions, such as m8 and later. Setting | |
32236 | @option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3}, | |
32237 | @option{-mvis2} and @option{-mvis}. | |
32238 | ||
d77de738 ML |
32239 | @opindex mcbcond |
32240 | @opindex mno-cbcond | |
ddf6fe37 AA |
32241 | @item -mcbcond |
32242 | @itemx -mno-cbcond | |
d77de738 ML |
32243 | With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC |
32244 | Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond} | |
32245 | when targeting a CPU that supports such instructions, such as Niagara-4 and | |
32246 | later. | |
32247 | ||
d77de738 ML |
32248 | @opindex mfmaf |
32249 | @opindex mno-fmaf | |
ddf6fe37 AA |
32250 | @item -mfmaf |
32251 | @itemx -mno-fmaf | |
d77de738 ML |
32252 | With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC |
32253 | Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf} | |
32254 | when targeting a CPU that supports such instructions, such as Niagara-3 and | |
32255 | later. | |
32256 | ||
d77de738 ML |
32257 | @opindex mfsmuld |
32258 | @opindex mno-fsmuld | |
ddf6fe37 AA |
32259 | @item -mfsmuld |
32260 | @itemx -mno-fsmuld | |
d77de738 ML |
32261 | With @option{-mfsmuld}, GCC generates code that takes advantage of the |
32262 | Floating-point Multiply Single to Double (FsMULd) instruction. The default is | |
32263 | @option{-mfsmuld} when targeting a CPU supporting the architecture versions V8 | |
32264 | or V9 with FPU except @option{-mcpu=leon}. | |
32265 | ||
d77de738 ML |
32266 | @opindex mpopc |
32267 | @opindex mno-popc | |
ddf6fe37 AA |
32268 | @item -mpopc |
32269 | @itemx -mno-popc | |
d77de738 ML |
32270 | With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC |
32271 | Population Count instruction. The default is @option{-mpopc} | |
32272 | when targeting a CPU that supports such an instruction, such as Niagara-2 and | |
32273 | later. | |
32274 | ||
d77de738 ML |
32275 | @opindex msubxc |
32276 | @opindex mno-subxc | |
ddf6fe37 AA |
32277 | @item -msubxc |
32278 | @itemx -mno-subxc | |
d77de738 ML |
32279 | With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC |
32280 | Subtract-Extended-with-Carry instruction. The default is @option{-msubxc} | |
32281 | when targeting a CPU that supports such an instruction, such as Niagara-7 and | |
32282 | later. | |
32283 | ||
d77de738 | 32284 | @opindex mfix-at697f |
ddf6fe37 | 32285 | @item -mfix-at697f |
d77de738 ML |
32286 | Enable the documented workaround for the single erratum of the Atmel AT697F |
32287 | processor (which corresponds to erratum #13 of the AT697E processor). | |
32288 | ||
d77de738 | 32289 | @opindex mfix-ut699 |
ddf6fe37 | 32290 | @item -mfix-ut699 |
d77de738 ML |
32291 | Enable the documented workarounds for the floating-point errata and the data |
32292 | cache nullify errata of the UT699 processor. | |
32293 | ||
d77de738 | 32294 | @opindex mfix-ut700 |
ddf6fe37 | 32295 | @item -mfix-ut700 |
d77de738 ML |
32296 | Enable the documented workaround for the back-to-back store errata of |
32297 | the UT699E/UT700 processor. | |
32298 | ||
d77de738 | 32299 | @opindex mfix-gr712rc |
ddf6fe37 | 32300 | @item -mfix-gr712rc |
d77de738 ML |
32301 | Enable the documented workaround for the back-to-back store errata of |
32302 | the GR712RC processor. | |
32303 | @end table | |
32304 | ||
32305 | These @samp{-m} options are supported in addition to the above | |
32306 | on SPARC-V9 processors in 64-bit environments: | |
32307 | ||
32308 | @table @gcctabopt | |
d77de738 ML |
32309 | @opindex m32 |
32310 | @opindex m64 | |
ddf6fe37 AA |
32311 | @item -m32 |
32312 | @itemx -m64 | |
d77de738 ML |
32313 | Generate code for a 32-bit or 64-bit environment. |
32314 | The 32-bit environment sets int, long and pointer to 32 bits. | |
32315 | The 64-bit environment sets int to 32 bits and long and pointer | |
32316 | to 64 bits. | |
32317 | ||
d77de738 | 32318 | @opindex mcmodel |
ddf6fe37 | 32319 | @item -mcmodel=@var{which} |
d77de738 ML |
32320 | Set the code model to one of |
32321 | ||
32322 | @table @samp | |
32323 | @item medlow | |
32324 | The Medium/Low code model: 64-bit addresses, programs | |
32325 | must be linked in the low 32 bits of memory. Programs can be statically | |
32326 | or dynamically linked. | |
32327 | ||
32328 | @item medmid | |
32329 | The Medium/Middle code model: 64-bit addresses, programs | |
32330 | must be linked in the low 44 bits of memory, the text and data segments must | |
32331 | be less than 2GB in size and the data segment must be located within 2GB of | |
32332 | the text segment. | |
32333 | ||
32334 | @item medany | |
32335 | The Medium/Anywhere code model: 64-bit addresses, programs | |
32336 | may be linked anywhere in memory, the text and data segments must be less | |
32337 | than 2GB in size and the data segment must be located within 2GB of the | |
32338 | text segment. | |
32339 | ||
32340 | @item embmedany | |
32341 | The Medium/Anywhere code model for embedded systems: | |
32342 | 64-bit addresses, the text and data segments must be less than 2GB in | |
32343 | size, both starting anywhere in memory (determined at link time). The | |
32344 | global register %g4 points to the base of the data segment. Programs | |
32345 | are statically linked and PIC is not supported. | |
32346 | @end table | |
32347 | ||
d77de738 | 32348 | @opindex mmemory-model |
ddf6fe37 | 32349 | @item -mmemory-model=@var{mem-model} |
d77de738 ML |
32350 | Set the memory model in force on the processor to one of |
32351 | ||
32352 | @table @samp | |
32353 | @item default | |
32354 | The default memory model for the processor and operating system. | |
32355 | ||
32356 | @item rmo | |
32357 | Relaxed Memory Order | |
32358 | ||
32359 | @item pso | |
32360 | Partial Store Order | |
32361 | ||
32362 | @item tso | |
32363 | Total Store Order | |
32364 | ||
32365 | @item sc | |
32366 | Sequential Consistency | |
32367 | @end table | |
32368 | ||
32369 | These memory models are formally defined in Appendix D of the SPARC-V9 | |
32370 | architecture manual, as set in the processor's @code{PSTATE.MM} field. | |
32371 | ||
d77de738 ML |
32372 | @opindex mstack-bias |
32373 | @opindex mno-stack-bias | |
ddf6fe37 AA |
32374 | @item -mstack-bias |
32375 | @itemx -mno-stack-bias | |
d77de738 ML |
32376 | With @option{-mstack-bias}, GCC assumes that the stack pointer, and |
32377 | frame pointer if present, are offset by @minus{}2047 which must be added back | |
32378 | when making stack frame references. This is the default in 64-bit mode. | |
32379 | Otherwise, assume no such offset is present. | |
32380 | @end table | |
32381 | ||
32382 | @node System V Options | |
32383 | @subsection Options for System V | |
32384 | ||
32385 | These additional options are available on System V Release 4 for | |
32386 | compatibility with other compilers on those systems: | |
32387 | ||
32388 | @table @gcctabopt | |
d77de738 | 32389 | @opindex G |
ddf6fe37 | 32390 | @item -G |
d77de738 ML |
32391 | Create a shared object. |
32392 | It is recommended that @option{-symbolic} or @option{-shared} be used instead. | |
32393 | ||
d77de738 | 32394 | @opindex Qy |
ddf6fe37 | 32395 | @item -Qy |
d77de738 ML |
32396 | Identify the versions of each tool used by the compiler, in a |
32397 | @code{.ident} assembler directive in the output. | |
32398 | ||
d77de738 | 32399 | @opindex Qn |
ddf6fe37 | 32400 | @item -Qn |
d77de738 ML |
32401 | Refrain from adding @code{.ident} directives to the output file (this is |
32402 | the default). | |
32403 | ||
d77de738 | 32404 | @opindex YP |
ddf6fe37 | 32405 | @item -YP,@var{dirs} |
d77de738 ML |
32406 | Search the directories @var{dirs}, and no others, for libraries |
32407 | specified with @option{-l}. | |
32408 | ||
d77de738 | 32409 | @opindex Ym |
ddf6fe37 | 32410 | @item -Ym,@var{dir} |
d77de738 ML |
32411 | Look in the directory @var{dir} to find the M4 preprocessor. |
32412 | The assembler uses this option. | |
32413 | @c This is supposed to go with a -Yd for predefined M4 macro files, but | |
32414 | @c the generic assembler that comes with Solaris takes just -Ym. | |
32415 | @end table | |
32416 | ||
32417 | @node V850 Options | |
32418 | @subsection V850 Options | |
32419 | @cindex V850 Options | |
32420 | ||
32421 | These @samp{-m} options are defined for V850 implementations: | |
32422 | ||
32423 | @table @gcctabopt | |
d77de738 ML |
32424 | @opindex mlong-calls |
32425 | @opindex mno-long-calls | |
ddf6fe37 AA |
32426 | @item -mlong-calls |
32427 | @itemx -mno-long-calls | |
d77de738 ML |
32428 | Treat all calls as being far away (near). If calls are assumed to be |
32429 | far away, the compiler always loads the function's address into a | |
32430 | register, and calls indirect through the pointer. | |
32431 | ||
d77de738 ML |
32432 | @opindex mno-ep |
32433 | @opindex mep | |
ddf6fe37 AA |
32434 | @item -mno-ep |
32435 | @itemx -mep | |
d77de738 ML |
32436 | Do not optimize (do optimize) basic blocks that use the same index |
32437 | pointer 4 or more times to copy pointer into the @code{ep} register, and | |
32438 | use the shorter @code{sld} and @code{sst} instructions. The @option{-mep} | |
32439 | option is on by default if you optimize. | |
32440 | ||
d77de738 ML |
32441 | @opindex mno-prolog-function |
32442 | @opindex mprolog-function | |
ddf6fe37 AA |
32443 | @item -mno-prolog-function |
32444 | @itemx -mprolog-function | |
d77de738 ML |
32445 | Do not use (do use) external functions to save and restore registers |
32446 | at the prologue and epilogue of a function. The external functions | |
32447 | are slower, but use less code space if more than one function saves | |
32448 | the same number of registers. The @option{-mprolog-function} option | |
32449 | is on by default if you optimize. | |
32450 | ||
d77de738 | 32451 | @opindex mspace |
ddf6fe37 | 32452 | @item -mspace |
d77de738 ML |
32453 | Try to make the code as small as possible. At present, this just turns |
32454 | on the @option{-mep} and @option{-mprolog-function} options. | |
32455 | ||
d77de738 | 32456 | @opindex mtda |
ddf6fe37 | 32457 | @item -mtda=@var{n} |
d77de738 ML |
32458 | Put static or global variables whose size is @var{n} bytes or less into |
32459 | the tiny data area that register @code{ep} points to. The tiny data | |
32460 | area can hold up to 256 bytes in total (128 bytes for byte references). | |
32461 | ||
d77de738 | 32462 | @opindex msda |
ddf6fe37 | 32463 | @item -msda=@var{n} |
d77de738 ML |
32464 | Put static or global variables whose size is @var{n} bytes or less into |
32465 | the small data area that register @code{gp} points to. The small data | |
32466 | area can hold up to 64 kilobytes. | |
32467 | ||
d77de738 | 32468 | @opindex mzda |
ddf6fe37 | 32469 | @item -mzda=@var{n} |
d77de738 ML |
32470 | Put static or global variables whose size is @var{n} bytes or less into |
32471 | the first 32 kilobytes of memory. | |
32472 | ||
d77de738 | 32473 | @opindex mv850 |
ddf6fe37 | 32474 | @item -mv850 |
d77de738 ML |
32475 | Specify that the target processor is the V850. |
32476 | ||
d77de738 | 32477 | @opindex mv850e3v5 |
ddf6fe37 | 32478 | @item -mv850e3v5 |
d77de738 ML |
32479 | Specify that the target processor is the V850E3V5. The preprocessor |
32480 | constant @code{__v850e3v5__} is defined if this option is used. | |
32481 | ||
d77de738 | 32482 | @opindex mv850e2v4 |
ddf6fe37 | 32483 | @item -mv850e2v4 |
d77de738 ML |
32484 | Specify that the target processor is the V850E3V5. This is an alias for |
32485 | the @option{-mv850e3v5} option. | |
32486 | ||
d77de738 | 32487 | @opindex mv850e2v3 |
ddf6fe37 | 32488 | @item -mv850e2v3 |
d77de738 ML |
32489 | Specify that the target processor is the V850E2V3. The preprocessor |
32490 | constant @code{__v850e2v3__} is defined if this option is used. | |
32491 | ||
d77de738 | 32492 | @opindex mv850e2 |
ddf6fe37 | 32493 | @item -mv850e2 |
d77de738 ML |
32494 | Specify that the target processor is the V850E2. The preprocessor |
32495 | constant @code{__v850e2__} is defined if this option is used. | |
32496 | ||
d77de738 | 32497 | @opindex mv850e1 |
ddf6fe37 | 32498 | @item -mv850e1 |
d77de738 ML |
32499 | Specify that the target processor is the V850E1. The preprocessor |
32500 | constants @code{__v850e1__} and @code{__v850e__} are defined if | |
32501 | this option is used. | |
32502 | ||
d77de738 | 32503 | @opindex mv850es |
ddf6fe37 | 32504 | @item -mv850es |
d77de738 ML |
32505 | Specify that the target processor is the V850ES. This is an alias for |
32506 | the @option{-mv850e1} option. | |
32507 | ||
d77de738 | 32508 | @opindex mv850e |
ddf6fe37 | 32509 | @item -mv850e |
d77de738 ML |
32510 | Specify that the target processor is the V850E@. The preprocessor |
32511 | constant @code{__v850e__} is defined if this option is used. | |
32512 | ||
32513 | If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1} | |
32514 | nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5} | |
32515 | are defined then a default target processor is chosen and the | |
32516 | relevant @samp{__v850*__} preprocessor constant is defined. | |
32517 | ||
32518 | The preprocessor constants @code{__v850} and @code{__v851__} are always | |
32519 | defined, regardless of which processor variant is the target. | |
32520 | ||
d77de738 ML |
32521 | @opindex mdisable-callt |
32522 | @opindex mno-disable-callt | |
ddf6fe37 AA |
32523 | @item -mdisable-callt |
32524 | @itemx -mno-disable-callt | |
d77de738 ML |
32525 | This option suppresses generation of the @code{CALLT} instruction for the |
32526 | v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850 | |
32527 | architecture. | |
32528 | ||
32529 | This option is enabled by default when the RH850 ABI is | |
32530 | in use (see @option{-mrh850-abi}), and disabled by default when the | |
32531 | GCC ABI is in use. If @code{CALLT} instructions are being generated | |
32532 | then the C preprocessor symbol @code{__V850_CALLT__} is defined. | |
32533 | ||
d77de738 ML |
32534 | @opindex mrelax |
32535 | @opindex mno-relax | |
ddf6fe37 AA |
32536 | @item -mrelax |
32537 | @itemx -mno-relax | |
d77de738 ML |
32538 | Pass on (or do not pass on) the @option{-mrelax} command-line option |
32539 | to the assembler. | |
32540 | ||
d77de738 ML |
32541 | @opindex mlong-jumps |
32542 | @opindex mno-long-jumps | |
ddf6fe37 AA |
32543 | @item -mlong-jumps |
32544 | @itemx -mno-long-jumps | |
d77de738 ML |
32545 | Disable (or re-enable) the generation of PC-relative jump instructions. |
32546 | ||
d77de738 ML |
32547 | @opindex msoft-float |
32548 | @opindex mhard-float | |
ddf6fe37 AA |
32549 | @item -msoft-float |
32550 | @itemx -mhard-float | |
d77de738 ML |
32551 | Disable (or re-enable) the generation of hardware floating point |
32552 | instructions. This option is only significant when the target | |
32553 | architecture is @samp{V850E2V3} or higher. If hardware floating point | |
32554 | instructions are being generated then the C preprocessor symbol | |
32555 | @code{__FPU_OK__} is defined, otherwise the symbol | |
32556 | @code{__NO_FPU__} is defined. | |
32557 | ||
d77de738 | 32558 | @opindex mloop |
ddf6fe37 | 32559 | @item -mloop |
d77de738 ML |
32560 | Enables the use of the e3v5 LOOP instruction. The use of this |
32561 | instruction is not enabled by default when the e3v5 architecture is | |
32562 | selected because its use is still experimental. | |
32563 | ||
d77de738 ML |
32564 | @opindex mrh850-abi |
32565 | @opindex mghs | |
ddf6fe37 AA |
32566 | @item -mrh850-abi |
32567 | @itemx -mghs | |
d77de738 ML |
32568 | Enables support for the RH850 version of the V850 ABI. This is the |
32569 | default. With this version of the ABI the following rules apply: | |
32570 | ||
32571 | @itemize | |
32572 | @item | |
32573 | Integer sized structures and unions are returned via a memory pointer | |
32574 | rather than a register. | |
32575 | ||
32576 | @item | |
32577 | Large structures and unions (more than 8 bytes in size) are passed by | |
32578 | value. | |
32579 | ||
32580 | @item | |
32581 | Functions are aligned to 16-bit boundaries. | |
32582 | ||
32583 | @item | |
32584 | The @option{-m8byte-align} command-line option is supported. | |
32585 | ||
32586 | @item | |
32587 | The @option{-mdisable-callt} command-line option is enabled by | |
32588 | default. The @option{-mno-disable-callt} command-line option is not | |
32589 | supported. | |
32590 | @end itemize | |
32591 | ||
32592 | When this version of the ABI is enabled the C preprocessor symbol | |
32593 | @code{__V850_RH850_ABI__} is defined. | |
32594 | ||
d77de738 | 32595 | @opindex mgcc-abi |
ddf6fe37 | 32596 | @item -mgcc-abi |
d77de738 ML |
32597 | Enables support for the old GCC version of the V850 ABI. With this |
32598 | version of the ABI the following rules apply: | |
32599 | ||
32600 | @itemize | |
32601 | @item | |
32602 | Integer sized structures and unions are returned in register @code{r10}. | |
32603 | ||
32604 | @item | |
32605 | Large structures and unions (more than 8 bytes in size) are passed by | |
32606 | reference. | |
32607 | ||
32608 | @item | |
32609 | Functions are aligned to 32-bit boundaries, unless optimizing for | |
32610 | size. | |
32611 | ||
32612 | @item | |
32613 | The @option{-m8byte-align} command-line option is not supported. | |
32614 | ||
32615 | @item | |
32616 | The @option{-mdisable-callt} command-line option is supported but not | |
32617 | enabled by default. | |
32618 | @end itemize | |
32619 | ||
32620 | When this version of the ABI is enabled the C preprocessor symbol | |
32621 | @code{__V850_GCC_ABI__} is defined. | |
32622 | ||
d77de738 ML |
32623 | @opindex m8byte-align |
32624 | @opindex mno-8byte-align | |
ddf6fe37 AA |
32625 | @item -m8byte-align |
32626 | @itemx -mno-8byte-align | |
d77de738 ML |
32627 | Enables support for @code{double} and @code{long long} types to be |
32628 | aligned on 8-byte boundaries. The default is to restrict the | |
32629 | alignment of all objects to at most 4-bytes. When | |
32630 | @option{-m8byte-align} is in effect the C preprocessor symbol | |
32631 | @code{__V850_8BYTE_ALIGN__} is defined. | |
32632 | ||
d77de738 | 32633 | @opindex mbig-switch |
ddf6fe37 | 32634 | @item -mbig-switch |
d77de738 ML |
32635 | Generate code suitable for big switch tables. Use this option only if |
32636 | the assembler/linker complain about out of range branches within a switch | |
32637 | table. | |
32638 | ||
d77de738 | 32639 | @opindex mapp-regs |
ddf6fe37 | 32640 | @item -mapp-regs |
d77de738 ML |
32641 | This option causes r2 and r5 to be used in the code generated by |
32642 | the compiler. This setting is the default. | |
32643 | ||
d77de738 | 32644 | @opindex mno-app-regs |
ddf6fe37 | 32645 | @item -mno-app-regs |
d77de738 ML |
32646 | This option causes r2 and r5 to be treated as fixed registers. |
32647 | ||
32648 | @end table | |
32649 | ||
32650 | @node VAX Options | |
32651 | @subsection VAX Options | |
32652 | @cindex VAX options | |
32653 | ||
32654 | These @samp{-m} options are defined for the VAX: | |
32655 | ||
32656 | @table @gcctabopt | |
d77de738 | 32657 | @opindex munix |
ddf6fe37 | 32658 | @item -munix |
d77de738 ML |
32659 | Do not output certain jump instructions (@code{aobleq} and so on) |
32660 | that the Unix assembler for the VAX cannot handle across long | |
32661 | ranges. | |
32662 | ||
d77de738 | 32663 | @opindex mgnu |
ddf6fe37 | 32664 | @item -mgnu |
d77de738 ML |
32665 | Do output those jump instructions, on the assumption that the |
32666 | GNU assembler is being used. | |
32667 | ||
d77de738 | 32668 | @opindex mg |
ddf6fe37 | 32669 | @item -mg |
d77de738 ML |
32670 | Output code for G-format floating-point numbers instead of D-format. |
32671 | ||
d77de738 ML |
32672 | @opindex mlra |
32673 | @opindex mno-lra | |
ddf6fe37 AA |
32674 | @item -mlra |
32675 | @itemx -mno-lra | |
d77de738 ML |
32676 | Enable Local Register Allocation. This is still experimental for the VAX, |
32677 | so by default the compiler uses standard reload. | |
32678 | @end table | |
32679 | ||
32680 | @node Visium Options | |
32681 | @subsection Visium Options | |
32682 | @cindex Visium options | |
32683 | ||
32684 | @table @gcctabopt | |
32685 | ||
d77de738 | 32686 | @opindex mdebug |
ddf6fe37 | 32687 | @item -mdebug |
d77de738 ML |
32688 | A program which performs file I/O and is destined to run on an MCM target |
32689 | should be linked with this option. It causes the libraries libc.a and | |
32690 | libdebug.a to be linked. The program should be run on the target under | |
32691 | the control of the GDB remote debugging stub. | |
32692 | ||
d77de738 | 32693 | @opindex msim |
ddf6fe37 | 32694 | @item -msim |
d77de738 ML |
32695 | A program which performs file I/O and is destined to run on the simulator |
32696 | should be linked with option. This causes libraries libc.a and libsim.a to | |
32697 | be linked. | |
32698 | ||
d77de738 ML |
32699 | @opindex mfpu |
32700 | @opindex mhard-float | |
ddf6fe37 AA |
32701 | @item -mfpu |
32702 | @itemx -mhard-float | |
d77de738 ML |
32703 | Generate code containing floating-point instructions. This is the |
32704 | default. | |
32705 | ||
d77de738 ML |
32706 | @opindex mno-fpu |
32707 | @opindex msoft-float | |
ddf6fe37 AA |
32708 | @item -mno-fpu |
32709 | @itemx -msoft-float | |
d77de738 ML |
32710 | Generate code containing library calls for floating-point. |
32711 | ||
32712 | @option{-msoft-float} changes the calling convention in the output file; | |
32713 | therefore, it is only useful if you compile @emph{all} of a program with | |
32714 | this option. In particular, you need to compile @file{libgcc.a}, the | |
32715 | library that comes with GCC, with @option{-msoft-float} in order for | |
32716 | this to work. | |
32717 | ||
d77de738 | 32718 | @opindex mcpu |
ddf6fe37 | 32719 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
32720 | Set the instruction set, register set, and instruction scheduling parameters |
32721 | for machine type @var{cpu_type}. Supported values for @var{cpu_type} are | |
32722 | @samp{mcm}, @samp{gr5} and @samp{gr6}. | |
32723 | ||
32724 | @samp{mcm} is a synonym of @samp{gr5} present for backward compatibility. | |
32725 | ||
32726 | By default (unless configured otherwise), GCC generates code for the GR5 | |
32727 | variant of the Visium architecture. | |
32728 | ||
32729 | With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium | |
32730 | architecture. The only difference from GR5 code is that the compiler will | |
32731 | generate block move instructions. | |
32732 | ||
d77de738 | 32733 | @opindex mtune |
ddf6fe37 | 32734 | @item -mtune=@var{cpu_type} |
d77de738 ML |
32735 | Set the instruction scheduling parameters for machine type @var{cpu_type}, |
32736 | but do not set the instruction set or register set that the option | |
32737 | @option{-mcpu=@var{cpu_type}} would. | |
32738 | ||
d77de738 | 32739 | @opindex msv-mode |
ddf6fe37 | 32740 | @item -msv-mode |
d77de738 ML |
32741 | Generate code for the supervisor mode, where there are no restrictions on |
32742 | the access to general registers. This is the default. | |
32743 | ||
d77de738 | 32744 | @opindex muser-mode |
ddf6fe37 | 32745 | @item -muser-mode |
d77de738 ML |
32746 | Generate code for the user mode, where the access to some general registers |
32747 | is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this | |
32748 | mode; on the GR6, only registers r29 to r31 are affected. | |
32749 | @end table | |
32750 | ||
32751 | @node VMS Options | |
32752 | @subsection VMS Options | |
32753 | ||
32754 | These @samp{-m} options are defined for the VMS implementations: | |
32755 | ||
32756 | @table @gcctabopt | |
d77de738 | 32757 | @opindex mvms-return-codes |
ddf6fe37 | 32758 | @item -mvms-return-codes |
d77de738 ML |
32759 | Return VMS condition codes from @code{main}. The default is to return POSIX-style |
32760 | condition (e.g.@: error) codes. | |
32761 | ||
d77de738 | 32762 | @opindex mdebug-main=@var{prefix} |
ddf6fe37 | 32763 | @item -mdebug-main=@var{prefix} |
d77de738 ML |
32764 | Flag the first routine whose name starts with @var{prefix} as the main |
32765 | routine for the debugger. | |
32766 | ||
d77de738 | 32767 | @opindex mmalloc64 |
ddf6fe37 | 32768 | @item -mmalloc64 |
d77de738 ML |
32769 | Default to 64-bit memory allocation routines. |
32770 | ||
d77de738 | 32771 | @opindex mpointer-size=@var{size} |
ddf6fe37 | 32772 | @item -mpointer-size=@var{size} |
d77de738 ML |
32773 | Set the default size of pointers. Possible options for @var{size} are |
32774 | @samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long} | |
32775 | for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers. | |
32776 | The later option disables @code{pragma pointer_size}. | |
32777 | @end table | |
32778 | ||
32779 | @node VxWorks Options | |
32780 | @subsection VxWorks Options | |
32781 | @cindex VxWorks Options | |
32782 | ||
32783 | The options in this section are defined for all VxWorks targets. | |
32784 | Options specific to the target hardware are listed with the other | |
32785 | options for that target. | |
32786 | ||
32787 | @table @gcctabopt | |
d77de738 | 32788 | @opindex mrtp |
ddf6fe37 | 32789 | @item -mrtp |
d77de738 ML |
32790 | GCC can generate code for both VxWorks kernels and real time processes |
32791 | (RTPs). This option switches from the former to the latter. It also | |
32792 | defines the preprocessor macro @code{__RTP__}. | |
32793 | ||
b6f4b000 AO |
32794 | @opindex msmp |
32795 | @item -msmp | |
32796 | Select SMP runtimes for linking. Not available on architectures other | |
32797 | than PowerPC, nor on VxWorks version 7 or later, in which the selection | |
32798 | is part of the VxWorks build configuration and the library paths are the | |
32799 | same for either choice. | |
32800 | ||
d77de738 | 32801 | @opindex non-static |
ddf6fe37 | 32802 | @item -non-static |
d77de738 ML |
32803 | Link an RTP executable against shared libraries rather than static |
32804 | libraries. The options @option{-static} and @option{-shared} can | |
32805 | also be used for RTPs (@pxref{Link Options}); @option{-static} | |
32806 | is the default. | |
32807 | ||
d77de738 ML |
32808 | @opindex Bstatic |
32809 | @opindex Bdynamic | |
ddf6fe37 AA |
32810 | @item -Bstatic |
32811 | @itemx -Bdynamic | |
d77de738 ML |
32812 | These options are passed down to the linker. They are defined for |
32813 | compatibility with Diab. | |
32814 | ||
d77de738 | 32815 | @opindex Xbind-lazy |
ddf6fe37 | 32816 | @item -Xbind-lazy |
d77de738 ML |
32817 | Enable lazy binding of function calls. This option is equivalent to |
32818 | @option{-Wl,-z,now} and is defined for compatibility with Diab. | |
32819 | ||
d77de738 | 32820 | @opindex Xbind-now |
ddf6fe37 | 32821 | @item -Xbind-now |
d77de738 ML |
32822 | Disable lazy binding of function calls. This option is the default and |
32823 | is defined for compatibility with Diab. | |
32824 | @end table | |
32825 | ||
32826 | @node x86 Options | |
32827 | @subsection x86 Options | |
32828 | @cindex x86 Options | |
32829 | ||
32830 | These @samp{-m} options are defined for the x86 family of computers. | |
32831 | ||
32832 | @table @gcctabopt | |
32833 | ||
d77de738 | 32834 | @opindex march |
ddf6fe37 | 32835 | @item -march=@var{cpu-type} |
d77de738 ML |
32836 | Generate instructions for the machine type @var{cpu-type}. In contrast to |
32837 | @option{-mtune=@var{cpu-type}}, which merely tunes the generated code | |
32838 | for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC | |
32839 | to generate code that may not run at all on processors other than the one | |
32840 | indicated. Specifying @option{-march=@var{cpu-type}} implies | |
32841 | @option{-mtune=@var{cpu-type}}, except where noted otherwise. | |
32842 | ||
32843 | The choices for @var{cpu-type} are: | |
32844 | ||
32845 | @table @samp | |
32846 | @item native | |
32847 | This selects the CPU to generate code for at compilation time by determining | |
32848 | the processor type of the compiling machine. Using @option{-march=native} | |
32849 | enables all instruction subsets supported by the local machine (hence | |
32850 | the result might not run on different machines). Using @option{-mtune=native} | |
32851 | produces code optimized for the local machine under the constraints | |
32852 | of the selected instruction set. | |
32853 | ||
32854 | @item x86-64 | |
32855 | A generic CPU with 64-bit extensions. | |
32856 | ||
32857 | @item x86-64-v2 | |
32858 | @itemx x86-64-v3 | |
32859 | @itemx x86-64-v4 | |
32860 | These choices for @var{cpu-type} select the corresponding | |
32861 | micro-architecture level from the x86-64 psABI. On ABIs other than | |
32862 | the x86-64 psABI they select the same CPU features as the x86-64 psABI | |
32863 | documents for the particular micro-architecture level. | |
32864 | ||
32865 | Since these @var{cpu-type} values do not have a corresponding | |
32866 | @option{-mtune} setting, using @option{-march} with these values enables | |
32867 | generic tuning. Specific tuning can be enabled using the | |
32868 | @option{-mtune=@var{other-cpu-type}} option with an appropriate | |
32869 | @var{other-cpu-type} value. | |
32870 | ||
32871 | @item i386 | |
32872 | Original Intel i386 CPU@. | |
32873 | ||
32874 | @item i486 | |
32875 | Intel i486 CPU@. (No scheduling is implemented for this chip.) | |
32876 | ||
32877 | @item i586 | |
32878 | @itemx pentium | |
32879 | Intel Pentium CPU with no MMX support. | |
32880 | ||
32881 | @item lakemont | |
32882 | Intel Lakemont MCU, based on Intel Pentium CPU. | |
32883 | ||
32884 | @item pentium-mmx | |
32885 | Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support. | |
32886 | ||
32887 | @item pentiumpro | |
32888 | Intel Pentium Pro CPU@. | |
32889 | ||
32890 | @item i686 | |
32891 | When used with @option{-march}, the Pentium Pro | |
32892 | instruction set is used, so the code runs on all i686 family chips. | |
32893 | When used with @option{-mtune}, it has the same meaning as @samp{generic}. | |
32894 | ||
32895 | @item pentium2 | |
32896 | Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction | |
32897 | set support. | |
32898 | ||
32899 | @item pentium3 | |
32900 | @itemx pentium3m | |
32901 | Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE | |
32902 | instruction set support. | |
32903 | ||
32904 | @item pentium-m | |
32905 | Intel Pentium M; low-power version of Intel Pentium III CPU | |
32906 | with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino | |
32907 | notebooks. | |
32908 | ||
32909 | @item pentium4 | |
32910 | @itemx pentium4m | |
32911 | Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support. | |
32912 | ||
32913 | @item prescott | |
32914 | Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR | |
32915 | instruction set support. | |
32916 | ||
32917 | @item nocona | |
32918 | Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE, | |
32919 | SSE2, SSE3 and FXSR instruction set support. | |
32920 | ||
32921 | @item core2 | |
32922 | Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16, | |
32923 | SAHF and FXSR instruction set support. | |
32924 | ||
32925 | @item nehalem | |
32926 | Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
32927 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support. | |
32928 | ||
32929 | @item westmere | |
32930 | Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
32931 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support. | |
32932 | ||
32933 | @item sandybridge | |
32934 | Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
32935 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set | |
32936 | support. | |
32937 | ||
32938 | @item ivybridge | |
32939 | Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
32940 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND | |
32941 | and F16C instruction set support. | |
32942 | ||
32943 | @item haswell | |
32944 | Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32945 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32946 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support. | |
32947 | ||
32948 | @item broadwell | |
32949 | Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32950 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32951 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW | |
32952 | instruction set support. | |
32953 | ||
32954 | @item skylake | |
32955 | Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32956 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32957 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
32958 | CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support. | |
32959 | ||
32960 | @item bonnell | |
32961 | Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3 | |
32962 | instruction set support. | |
32963 | ||
32964 | @item silvermont | |
32965 | Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32966 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND | |
32967 | instruction set support. | |
32968 | ||
32969 | @item goldmont | |
32970 | Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32971 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA, | |
32972 | RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction | |
32973 | set support. | |
32974 | ||
32975 | @item goldmont-plus | |
32976 | Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32977 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, | |
32978 | SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, | |
32979 | RDPID and SGX instruction set support. | |
32980 | ||
32981 | @item tremont | |
32982 | Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32983 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA, | |
32984 | RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID, | |
32985 | SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set | |
32986 | support. | |
32987 | ||
32988 | @item sierraforest | |
32989 | Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32990 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
32991 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
32992 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
32993 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
503643e8 LC |
32994 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD and UINTR instruction set |
32995 | support. | |
d77de738 ML |
32996 | |
32997 | @item grandridge | |
32998 | Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32999 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
33000 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
33001 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
33002 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
503643e8 LC |
33003 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, ENQCMD, UINTR and RAOINT |
33004 | instruction set support. | |
d77de738 | 33005 | |
7370c479 HJ |
33006 | @item clearwaterforest |
33007 | Intel Clearwater Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, | |
33008 | SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, | |
33009 | XSAVEC, XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, | |
33010 | MOVDIRI, MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, | |
33011 | LZCNT, PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
faa0e82b HJ |
33012 | ENQCMD, UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, |
33013 | SHA512, SM3, SM4, USER_MSR and PREFETCHI instruction set support. | |
f019251a | 33014 | |
d77de738 ML |
33015 | @item knl |
33016 | Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33017 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33018 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33019 | AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1 instruction set support. | |
33020 | ||
33021 | @item knm | |
33022 | Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33023 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33024 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33025 | AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1, AVX5124VNNIW, | |
33026 | AVX5124FMAPS and AVX512VPOPCNTDQ instruction set support. | |
33027 | ||
33028 | @item skylake-avx512 | |
33029 | Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33030 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33031 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33032 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, | |
33033 | AVX512DQ and AVX512CD instruction set support. | |
33034 | ||
33035 | @item cannonlake | |
33036 | Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, | |
33037 | SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, | |
33038 | FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, | |
33039 | PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, | |
33040 | AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set | |
33041 | support. | |
33042 | ||
33043 | @item icelake-client | |
33044 | Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33045 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33046 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33047 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
33048 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2 | |
33049 | , VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support. | |
33050 | ||
33051 | @item icelake-server | |
33052 | Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33053 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33054 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33055 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
33056 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2 | |
33057 | , VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB | |
33058 | instruction set support. | |
33059 | ||
33060 | @item cascadelake | |
33061 | Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33062 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
33063 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
33064 | CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ, | |
33065 | AVX512CD and AVX512VNNI instruction set support. | |
33066 | ||
33067 | @item cooperlake | |
33068 | Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33069 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
33070 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
33071 | CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ, | |
33072 | AVX512CD, AVX512VNNI and AVX512BF16 instruction set support. | |
33073 | ||
33074 | @item tigerlake | |
33075 | Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33076 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
33077 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
33078 | CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD | |
33079 | PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
33080 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB, | |
33081 | AVX512VP2INTERSECT and KEYLOCKER instruction set support. | |
33082 | ||
33083 | @item sapphirerapids | |
33084 | Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33085 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33086 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33087 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
33088 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
33089 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB, | |
33090 | MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK, | |
29ecb952 | 33091 | UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16 and AVX512BF16 |
d77de738 ML |
33092 | instruction set support. |
33093 | ||
33094 | @item alderlake | |
33095 | Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
33096 | SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES, | |
33097 | XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B, | |
33098 | CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU, | |
33099 | VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set | |
33100 | support. | |
33101 | ||
33102 | @item rocketlake | |
33103 | Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3 | |
33104 | , SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
33105 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
33106 | CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD | |
33107 | PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
33108 | VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support. | |
33109 | ||
33110 | @item graniterapids | |
33111 | Intel graniterapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33112 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33113 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33114 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
33115 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
33116 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB, | |
38daaaa9 HJ |
33117 | MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK, |
33118 | UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16, AVX512BF16, AMX-FP16 | |
33119 | and PREFETCHI instruction set support. | |
d77de738 | 33120 | |
a0cb65d3 MZ |
33121 | @item graniterapids-d |
33122 | Intel graniterapids D CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33123 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
33124 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
33125 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
33126 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
33127 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB, | |
38daaaa9 HJ |
33128 | MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK, |
33129 | UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512FP16, AVX512BF16, AMX-FP16, | |
33130 | PREFETCHI and AMX-COMPLEX instruction set support. | |
a0cb65d3 | 33131 | |
faa0e82b HJ |
33132 | @item arrowlake |
33133 | Intel Arrow Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33134 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
33135 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
33136 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
33137 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
33138 | UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set | |
33139 | support. | |
33140 | ||
33141 | @item arrowlake-s | |
33142 | Intel Arrow Lake S CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33143 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
33144 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
33145 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
33146 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
33147 | UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, | |
33148 | SM3 and SM4 instruction set support. | |
33149 | ||
33150 | @item pantherlake | |
33151 | Intel Panther Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
33152 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
33153 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
33154 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
33155 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
33156 | UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, | |
33157 | SM3, SM4 and PREFETCHI instruction set support. | |
33158 | ||
d77de738 ML |
33159 | @item k6 |
33160 | AMD K6 CPU with MMX instruction set support. | |
33161 | ||
33162 | @item k6-2 | |
33163 | @itemx k6-3 | |
33164 | Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support. | |
33165 | ||
33166 | @item athlon | |
33167 | @itemx athlon-tbird | |
33168 | AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions | |
33169 | support. | |
33170 | ||
33171 | @item athlon-4 | |
33172 | @itemx athlon-xp | |
33173 | @itemx athlon-mp | |
33174 | Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE | |
33175 | instruction set support. | |
33176 | ||
33177 | @item k8 | |
33178 | @itemx opteron | |
33179 | @itemx athlon64 | |
33180 | @itemx athlon-fx | |
33181 | Processors based on the AMD K8 core with x86-64 instruction set support, | |
33182 | including the AMD Opteron, Athlon 64, and Athlon 64 FX processors. | |
33183 | (This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit | |
33184 | instruction set extensions.) | |
33185 | ||
33186 | @item k8-sse3 | |
33187 | @itemx opteron-sse3 | |
33188 | @itemx athlon64-sse3 | |
33189 | Improved versions of AMD K8 cores with SSE3 instruction set support. | |
33190 | ||
33191 | @item amdfam10 | |
33192 | @itemx barcelona | |
33193 | CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This | |
33194 | supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit | |
33195 | instruction set extensions.) | |
33196 | ||
33197 | @item bdver1 | |
33198 | CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This | |
33199 | supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, | |
33200 | SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.) | |
33201 | ||
33202 | @item bdver2 | |
33203 | AMD Family 15h core based CPUs with x86-64 instruction set support. (This | |
33204 | supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, | |
33205 | SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set | |
33206 | extensions.) | |
33207 | ||
33208 | @item bdver3 | |
33209 | AMD Family 15h core based CPUs with x86-64 instruction set support. (This | |
33210 | supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES, | |
33211 | PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and | |
33212 | 64-bit instruction set extensions.) | |
33213 | ||
33214 | @item bdver4 | |
33215 | AMD Family 15h core based CPUs with x86-64 instruction set support. (This | |
33216 | supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP, | |
33217 | AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, | |
33218 | SSE4.2, ABM and 64-bit instruction set extensions.) | |
33219 | ||
33220 | @item znver1 | |
33221 | AMD Family 17h core based CPUs with x86-64 instruction set support. (This | |
33222 | supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX, | |
33223 | SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, | |
33224 | SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit | |
33225 | instruction set extensions.) | |
33226 | ||
33227 | @item znver2 | |
33228 | AMD Family 17h core based CPUs with x86-64 instruction set support. (This | |
33229 | supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, | |
33230 | MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, | |
33231 | SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, | |
33232 | WBNOINVD, and 64-bit instruction set extensions.) | |
33233 | ||
33234 | @item znver3 | |
33235 | AMD Family 19h core based CPUs with x86-64 instruction set support. (This | |
33236 | supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, | |
33237 | MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, | |
33238 | SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, | |
33239 | WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.) | |
33240 | ||
33241 | @item znver4 | |
33242 | AMD Family 19h core based CPUs with x86-64 instruction set support. (This | |
33243 | supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, | |
33244 | MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, | |
33245 | SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, | |
33246 | WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD, | |
33247 | AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI, | |
33248 | AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.) | |
33249 | ||
33250 | @item btver1 | |
33251 | CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This | |
33252 | supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit | |
33253 | instruction set extensions.) | |
33254 | ||
33255 | @item btver2 | |
33256 | CPUs based on AMD Family 16h cores with x86-64 instruction set support. This | |
33257 | includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM, | |
33258 | SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions. | |
33259 | ||
33260 | @item winchip-c6 | |
33261 | IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction | |
33262 | set support. | |
33263 | ||
33264 | @item winchip2 | |
33265 | IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@: | |
33266 | instruction set support. | |
33267 | ||
33268 | @item c3 | |
33269 | VIA C3 CPU with MMX and 3DNow!@: instruction set support. | |
33270 | (No scheduling is implemented for this chip.) | |
33271 | ||
33272 | @item c3-2 | |
33273 | VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support. | |
33274 | (No scheduling is implemented for this chip.) | |
33275 | ||
33276 | @item c7 | |
33277 | VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support. | |
33278 | (No scheduling is implemented for this chip.) | |
33279 | ||
33280 | @item samuel-2 | |
33281 | VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support. | |
33282 | (No scheduling is implemented for this chip.) | |
33283 | ||
33284 | @item nehemiah | |
33285 | VIA Eden Nehemiah CPU with MMX and SSE instruction set support. | |
33286 | (No scheduling is implemented for this chip.) | |
33287 | ||
33288 | @item esther | |
33289 | VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support. | |
33290 | (No scheduling is implemented for this chip.) | |
33291 | ||
33292 | @item eden-x2 | |
33293 | VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support. | |
33294 | (No scheduling is implemented for this chip.) | |
33295 | ||
33296 | @item eden-x4 | |
33297 | VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, | |
33298 | AVX and AVX2 instruction set support. | |
33299 | (No scheduling is implemented for this chip.) | |
33300 | ||
33301 | @item nano | |
33302 | Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 | |
33303 | instruction set support. | |
33304 | (No scheduling is implemented for this chip.) | |
33305 | ||
33306 | @item nano-1000 | |
33307 | VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 | |
33308 | instruction set support. | |
33309 | (No scheduling is implemented for this chip.) | |
33310 | ||
33311 | @item nano-2000 | |
33312 | VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 | |
33313 | instruction set support. | |
33314 | (No scheduling is implemented for this chip.) | |
33315 | ||
33316 | @item nano-3000 | |
33317 | VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 | |
33318 | instruction set support. | |
33319 | (No scheduling is implemented for this chip.) | |
33320 | ||
33321 | @item nano-x2 | |
33322 | VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 | |
33323 | instruction set support. | |
33324 | (No scheduling is implemented for this chip.) | |
33325 | ||
33326 | @item nano-x4 | |
33327 | VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 | |
33328 | instruction set support. | |
33329 | (No scheduling is implemented for this chip.) | |
33330 | ||
33331 | @item lujiazui | |
33332 | ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, | |
33333 | SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16, | |
33334 | ABM, BMI, BMI2, F16C, FXSR, RDSEED instruction set support. | |
33335 | ||
94c0b26f M |
33336 | @item yongfeng |
33337 | ZHAOXIN yongfeng CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, | |
33338 | SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16, | |
33339 | ABM, BMI, BMI2, F16C, FXSR, RDSEED, AVX2, FMA, SHA, LZCNT | |
33340 | instruction set support. | |
33341 | ||
d77de738 ML |
33342 | @item geode |
33343 | AMD Geode embedded processor with MMX and 3DNow!@: instruction set support. | |
33344 | @end table | |
33345 | ||
d77de738 | 33346 | @opindex mtune |
ddf6fe37 | 33347 | @item -mtune=@var{cpu-type} |
d77de738 ML |
33348 | Tune to @var{cpu-type} everything applicable about the generated code, except |
33349 | for the ABI and the set of available instructions. | |
33350 | While picking a specific @var{cpu-type} schedules things appropriately | |
33351 | for that particular chip, the compiler does not generate any code that | |
33352 | cannot run on the default machine type unless you use a | |
33353 | @option{-march=@var{cpu-type}} option. | |
33354 | For example, if GCC is configured for i686-pc-linux-gnu | |
33355 | then @option{-mtune=pentium4} generates code that is tuned for Pentium 4 | |
33356 | but still runs on i686 machines. | |
33357 | ||
33358 | The choices for @var{cpu-type} are the same as for @option{-march}. | |
33359 | In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}: | |
33360 | ||
33361 | @table @samp | |
33362 | @item generic | |
33363 | Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors. | |
33364 | If you know the CPU on which your code will run, then you should use | |
33365 | the corresponding @option{-mtune} or @option{-march} option instead of | |
33366 | @option{-mtune=generic}. But, if you do not know exactly what CPU users | |
33367 | of your application will have, then you should use this option. | |
33368 | ||
33369 | As new processors are deployed in the marketplace, the behavior of this | |
33370 | option will change. Therefore, if you upgrade to a newer version of | |
33371 | GCC, code generation controlled by this option will change to reflect | |
33372 | the processors | |
33373 | that are most common at the time that version of GCC is released. | |
33374 | ||
33375 | There is no @option{-march=generic} option because @option{-march} | |
33376 | indicates the instruction set the compiler can use, and there is no | |
33377 | generic instruction set applicable to all processors. In contrast, | |
33378 | @option{-mtune} indicates the processor (or, in this case, collection of | |
33379 | processors) for which the code is optimized. | |
33380 | ||
33381 | @item intel | |
33382 | Produce code optimized for the most current Intel processors, which are | |
33383 | Haswell and Silvermont for this version of GCC. If you know the CPU | |
33384 | on which your code will run, then you should use the corresponding | |
33385 | @option{-mtune} or @option{-march} option instead of @option{-mtune=intel}. | |
33386 | But, if you want your application performs better on both Haswell and | |
33387 | Silvermont, then you should use this option. | |
33388 | ||
33389 | As new Intel processors are deployed in the marketplace, the behavior of | |
33390 | this option will change. Therefore, if you upgrade to a newer version of | |
33391 | GCC, code generation controlled by this option will change to reflect | |
33392 | the most current Intel processors at the time that version of GCC is | |
33393 | released. | |
33394 | ||
33395 | There is no @option{-march=intel} option because @option{-march} indicates | |
33396 | the instruction set the compiler can use, and there is no common | |
33397 | instruction set applicable to all processors. In contrast, | |
33398 | @option{-mtune} indicates the processor (or, in this case, collection of | |
33399 | processors) for which the code is optimized. | |
33400 | @end table | |
33401 | ||
d77de738 | 33402 | @opindex mcpu |
ddf6fe37 | 33403 | @item -mcpu=@var{cpu-type} |
d77de738 ML |
33404 | A deprecated synonym for @option{-mtune}. |
33405 | ||
d77de738 | 33406 | @opindex mfpmath |
ddf6fe37 | 33407 | @item -mfpmath=@var{unit} |
d77de738 ML |
33408 | Generate floating-point arithmetic for selected unit @var{unit}. The choices |
33409 | for @var{unit} are: | |
33410 | ||
33411 | @table @samp | |
33412 | @item 387 | |
33413 | Use the standard 387 floating-point coprocessor present on the majority of chips and | |
33414 | emulated otherwise. Code compiled with this option runs almost everywhere. | |
33415 | The temporary results are computed in 80-bit precision instead of the precision | |
33416 | specified by the type, resulting in slightly different results compared to most | |
33417 | of other chips. See @option{-ffloat-store} for more detailed description. | |
33418 | ||
33419 | This is the default choice for non-Darwin x86-32 targets. | |
33420 | ||
33421 | @item sse | |
33422 | Use scalar floating-point instructions present in the SSE instruction set. | |
33423 | This instruction set is supported by Pentium III and newer chips, | |
33424 | and in the AMD line | |
33425 | by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE | |
33426 | instruction set supports only single-precision arithmetic, thus the double and | |
33427 | extended-precision arithmetic are still done using 387. A later version, present | |
33428 | only in Pentium 4 and AMD x86-64 chips, supports double-precision | |
33429 | arithmetic too. | |
33430 | ||
33431 | For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse} | |
33432 | or @option{-msse2} switches to enable SSE extensions and make this option | |
33433 | effective. For the x86-64 compiler, these extensions are enabled by default. | |
33434 | ||
33435 | The resulting code should be considerably faster in the majority of cases and avoid | |
33436 | the numerical instability problems of 387 code, but may break some existing | |
33437 | code that expects temporaries to be 80 bits. | |
33438 | ||
33439 | This is the default choice for the x86-64 compiler, Darwin x86-32 targets, | |
33440 | and the default choice for x86-32 targets with the SSE2 instruction set | |
33441 | when @option{-ffast-math} is enabled. | |
33442 | ||
33443 | @item sse,387 | |
33444 | @itemx sse+387 | |
33445 | @itemx both | |
33446 | Attempt to utilize both instruction sets at once. This effectively doubles the | |
33447 | amount of available registers, and on chips with separate execution units for | |
33448 | 387 and SSE the execution resources too. Use this option with care, as it is | |
33449 | still experimental, because the GCC register allocator does not model separate | |
33450 | functional units well, resulting in unstable performance. | |
33451 | @end table | |
33452 | ||
d77de738 | 33453 | @opindex masm=@var{dialect} |
ddf6fe37 | 33454 | @item -masm=@var{dialect} |
d77de738 ML |
33455 | Output assembly instructions using selected @var{dialect}. Also affects |
33456 | which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and | |
33457 | extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect | |
33458 | order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does | |
33459 | not support @samp{intel}. | |
33460 | ||
d77de738 ML |
33461 | @opindex mieee-fp |
33462 | @opindex mno-ieee-fp | |
ddf6fe37 AA |
33463 | @item -mieee-fp |
33464 | @itemx -mno-ieee-fp | |
d77de738 ML |
33465 | Control whether or not the compiler uses IEEE floating-point |
33466 | comparisons. These correctly handle the case where the result of a | |
33467 | comparison is unordered. | |
33468 | ||
30348d30 | 33469 | @opindex m80387 |
d77de738 | 33470 | @opindex mhard-float |
ddf6fe37 AA |
33471 | @item -m80387 |
33472 | @itemx -mhard-float | |
d77de738 ML |
33473 | Generate output containing 80387 instructions for floating point. |
33474 | ||
d77de738 ML |
33475 | @opindex no-80387 |
33476 | @opindex msoft-float | |
ddf6fe37 AA |
33477 | @item -mno-80387 |
33478 | @itemx -msoft-float | |
d77de738 ML |
33479 | Generate output containing library calls for floating point. |
33480 | ||
33481 | @strong{Warning:} the requisite libraries are not part of GCC@. | |
33482 | Normally the facilities of the machine's usual C compiler are used, but | |
33483 | this cannot be done directly in cross-compilation. You must make your | |
33484 | own arrangements to provide suitable library functions for | |
33485 | cross-compilation. | |
33486 | ||
33487 | On machines where a function returns floating-point results in the 80387 | |
33488 | register stack, some floating-point opcodes may be emitted even if | |
33489 | @option{-msoft-float} is used. | |
33490 | ||
d77de738 ML |
33491 | @opindex mno-fp-ret-in-387 |
33492 | @opindex mfp-ret-in-387 | |
ddf6fe37 | 33493 | @item -mno-fp-ret-in-387 |
d77de738 ML |
33494 | Do not use the FPU registers for return values of functions. |
33495 | ||
33496 | The usual calling convention has functions return values of types | |
33497 | @code{float} and @code{double} in an FPU register, even if there | |
33498 | is no FPU@. The idea is that the operating system should emulate | |
33499 | an FPU@. | |
33500 | ||
33501 | The option @option{-mno-fp-ret-in-387} causes such values to be returned | |
33502 | in ordinary CPU registers instead. | |
33503 | ||
d77de738 ML |
33504 | @opindex mno-fancy-math-387 |
33505 | @opindex mfancy-math-387 | |
ddf6fe37 | 33506 | @item -mno-fancy-math-387 |
d77de738 ML |
33507 | Some 387 emulators do not support the @code{sin}, @code{cos} and |
33508 | @code{sqrt} instructions for the 387. Specify this option to avoid | |
33509 | generating those instructions. | |
33510 | This option is overridden when @option{-march} | |
33511 | indicates that the target CPU always has an FPU and so the | |
33512 | instruction does not need emulation. These | |
33513 | instructions are not generated unless you also use the | |
33514 | @option{-funsafe-math-optimizations} switch. | |
33515 | ||
d77de738 ML |
33516 | @opindex malign-double |
33517 | @opindex mno-align-double | |
ddf6fe37 AA |
33518 | @item -malign-double |
33519 | @itemx -mno-align-double | |
d77de738 ML |
33520 | Control whether GCC aligns @code{double}, @code{long double}, and |
33521 | @code{long long} variables on a two-word boundary or a one-word | |
33522 | boundary. Aligning @code{double} variables on a two-word boundary | |
33523 | produces code that runs somewhat faster on a Pentium at the | |
33524 | expense of more memory. | |
33525 | ||
33526 | On x86-64, @option{-malign-double} is enabled by default. | |
33527 | ||
33528 | @strong{Warning:} if you use the @option{-malign-double} switch, | |
33529 | structures containing the above types are aligned differently than | |
33530 | the published application binary interface specifications for the x86-32 | |
33531 | and are not binary compatible with structures in code compiled | |
33532 | without that switch. | |
33533 | ||
d77de738 ML |
33534 | @opindex m96bit-long-double |
33535 | @opindex m128bit-long-double | |
ddf6fe37 AA |
33536 | @item -m96bit-long-double |
33537 | @itemx -m128bit-long-double | |
d77de738 ML |
33538 | These switches control the size of @code{long double} type. The x86-32 |
33539 | application binary interface specifies the size to be 96 bits, | |
33540 | so @option{-m96bit-long-double} is the default in 32-bit mode. | |
33541 | ||
33542 | Modern architectures (Pentium and newer) prefer @code{long double} | |
33543 | to be aligned to an 8- or 16-byte boundary. In arrays or structures | |
33544 | conforming to the ABI, this is not possible. So specifying | |
33545 | @option{-m128bit-long-double} aligns @code{long double} | |
33546 | to a 16-byte boundary by padding the @code{long double} with an additional | |
33547 | 32-bit zero. | |
33548 | ||
33549 | In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as | |
33550 | its ABI specifies that @code{long double} is aligned on 16-byte boundary. | |
33551 | ||
33552 | Notice that neither of these options enable any extra precision over the x87 | |
33553 | standard of 80 bits for a @code{long double}. | |
33554 | ||
33555 | @strong{Warning:} if you override the default value for your target ABI, this | |
33556 | changes the size of | |
33557 | structures and arrays containing @code{long double} variables, | |
33558 | as well as modifying the function calling convention for functions taking | |
33559 | @code{long double}. Hence they are not binary-compatible | |
33560 | with code compiled without that switch. | |
33561 | ||
d77de738 ML |
33562 | @opindex mlong-double-64 |
33563 | @opindex mlong-double-80 | |
33564 | @opindex mlong-double-128 | |
ddf6fe37 AA |
33565 | @item -mlong-double-64 |
33566 | @itemx -mlong-double-80 | |
33567 | @itemx -mlong-double-128 | |
d77de738 ML |
33568 | These switches control the size of @code{long double} type. A size |
33569 | of 64 bits makes the @code{long double} type equivalent to the @code{double} | |
33570 | type. This is the default for 32-bit Bionic C library. A size | |
33571 | of 128 bits makes the @code{long double} type equivalent to the | |
33572 | @code{__float128} type. This is the default for 64-bit Bionic C library. | |
33573 | ||
33574 | @strong{Warning:} if you override the default value for your target ABI, this | |
33575 | changes the size of | |
33576 | structures and arrays containing @code{long double} variables, | |
33577 | as well as modifying the function calling convention for functions taking | |
33578 | @code{long double}. Hence they are not binary-compatible | |
33579 | with code compiled without that switch. | |
33580 | ||
d77de738 | 33581 | @opindex malign-data |
ddf6fe37 | 33582 | @item -malign-data=@var{type} |
d77de738 ML |
33583 | Control how GCC aligns variables. Supported values for @var{type} are |
33584 | @samp{compat} uses increased alignment value compatible uses GCC 4.8 | |
33585 | and earlier, @samp{abi} uses alignment value as specified by the | |
33586 | psABI, and @samp{cacheline} uses increased alignment value to match | |
33587 | the cache line size. @samp{compat} is the default. | |
33588 | ||
d77de738 | 33589 | @opindex mlarge-data-threshold |
ddf6fe37 | 33590 | @item -mlarge-data-threshold=@var{threshold} |
1a64156c UB |
33591 | When @option{-mcmodel=medium} or @option{-mcmodel=large} is specified, data |
33592 | objects larger than @var{threshold} are placed in large data sections. The | |
33593 | default is 65535. | |
d77de738 | 33594 | |
d77de738 | 33595 | @opindex mrtd |
ddf6fe37 | 33596 | @item -mrtd |
d77de738 ML |
33597 | Use a different function-calling convention, in which functions that |
33598 | take a fixed number of arguments return with the @code{ret @var{num}} | |
33599 | instruction, which pops their arguments while returning. This saves one | |
33600 | instruction in the caller since there is no need to pop the arguments | |
33601 | there. | |
33602 | ||
33603 | You can specify that an individual function is called with this calling | |
33604 | sequence with the function attribute @code{stdcall}. You can also | |
33605 | override the @option{-mrtd} option by using the function attribute | |
33606 | @code{cdecl}. @xref{Function Attributes}. | |
33607 | ||
33608 | @strong{Warning:} this calling convention is incompatible with the one | |
33609 | normally used on Unix, so you cannot use it if you need to call | |
33610 | libraries compiled with the Unix compiler. | |
33611 | ||
33612 | Also, you must provide function prototypes for all functions that | |
33613 | take variable numbers of arguments (including @code{printf}); | |
33614 | otherwise incorrect code is generated for calls to those | |
33615 | functions. | |
33616 | ||
33617 | In addition, seriously incorrect code results if you call a | |
33618 | function with too many arguments. (Normally, extra arguments are | |
33619 | harmlessly ignored.) | |
33620 | ||
d77de738 | 33621 | @opindex mregparm |
ddf6fe37 | 33622 | @item -mregparm=@var{num} |
d77de738 ML |
33623 | Control how many registers are used to pass integer arguments. By |
33624 | default, no registers are used to pass arguments, and at most 3 | |
33625 | registers can be used. You can control this behavior for a specific | |
33626 | function by using the function attribute @code{regparm}. | |
33627 | @xref{Function Attributes}. | |
33628 | ||
33629 | @strong{Warning:} if you use this switch, and | |
33630 | @var{num} is nonzero, then you must build all modules with the same | |
33631 | value, including any libraries. This includes the system libraries and | |
33632 | startup modules. | |
33633 | ||
d77de738 | 33634 | @opindex msseregparm |
ddf6fe37 | 33635 | @item -msseregparm |
d77de738 ML |
33636 | Use SSE register passing conventions for float and double arguments |
33637 | and return values. You can control this behavior for a specific | |
33638 | function by using the function attribute @code{sseregparm}. | |
33639 | @xref{Function Attributes}. | |
33640 | ||
33641 | @strong{Warning:} if you use this switch then you must build all | |
33642 | modules with the same value, including any libraries. This includes | |
33643 | the system libraries and startup modules. | |
33644 | ||
d77de738 | 33645 | @opindex mvect8-ret-in-mem |
ddf6fe37 | 33646 | @item -mvect8-ret-in-mem |
d77de738 ML |
33647 | Return 8-byte vectors in memory instead of MMX registers. This is the |
33648 | default on VxWorks to match the ABI of the Sun Studio compilers until | |
33649 | version 12. @emph{Only} use this option if you need to remain | |
33650 | compatible with existing code produced by those previous compiler | |
33651 | versions or older versions of GCC@. | |
33652 | ||
d77de738 ML |
33653 | @opindex mpc32 |
33654 | @opindex mpc64 | |
33655 | @opindex mpc80 | |
ddf6fe37 AA |
33656 | @item -mpc32 |
33657 | @itemx -mpc64 | |
33658 | @itemx -mpc80 | |
d77de738 ML |
33659 | |
33660 | Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32} | |
33661 | is specified, the significands of results of floating-point operations are | |
33662 | rounded to 24 bits (single precision); @option{-mpc64} rounds the | |
33663 | significands of results of floating-point operations to 53 bits (double | |
33664 | precision) and @option{-mpc80} rounds the significands of results of | |
33665 | floating-point operations to 64 bits (extended double precision), which is | |
33666 | the default. When this option is used, floating-point operations in higher | |
33667 | precisions are not available to the programmer without setting the FPU | |
33668 | control word explicitly. | |
33669 | ||
33670 | Setting the rounding of floating-point operations to less than the default | |
33671 | 80 bits can speed some programs by 2% or more. Note that some mathematical | |
33672 | libraries assume that extended-precision (80-bit) floating-point operations | |
33673 | are enabled by default; routines in such libraries could suffer significant | |
33674 | loss of accuracy, typically through so-called ``catastrophic cancellation'', | |
33675 | when this option is used to set the precision to less than extended precision. | |
33676 | ||
e54375d8 | 33677 | @opindex mdaz-ftz |
ddf6fe37 | 33678 | @item -mdaz-ftz |
e54375d8 | 33679 | |
33680 | The flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register | |
33681 | are used to control floating-point calculations.SSE and AVX instructions | |
33682 | including scalar and vector instructions could benefit from enabling the FTZ | |
33683 | and DAZ flags when @option{-mdaz-ftz} is specified. Don't set FTZ/DAZ flags | |
33684 | when @option{-mno-daz-ftz} or @option{-shared} is specified, @option{-mdaz-ftz} | |
33685 | will set FTZ/DAZ flags even with @option{-shared}. | |
33686 | ||
d77de738 | 33687 | @opindex mstackrealign |
ddf6fe37 | 33688 | @item -mstackrealign |
d77de738 ML |
33689 | Realign the stack at entry. On the x86, the @option{-mstackrealign} |
33690 | option generates an alternate prologue and epilogue that realigns the | |
33691 | run-time stack if necessary. This supports mixing legacy codes that keep | |
33692 | 4-byte stack alignment with modern codes that keep 16-byte stack alignment for | |
33693 | SSE compatibility. See also the attribute @code{force_align_arg_pointer}, | |
33694 | applicable to individual functions. | |
33695 | ||
d77de738 | 33696 | @opindex mpreferred-stack-boundary |
ddf6fe37 | 33697 | @item -mpreferred-stack-boundary=@var{num} |
d77de738 ML |
33698 | Attempt to keep the stack boundary aligned to a 2 raised to @var{num} |
33699 | byte boundary. If @option{-mpreferred-stack-boundary} is not specified, | |
33700 | the default is 4 (16 bytes or 128 bits). | |
33701 | ||
33702 | @strong{Warning:} When generating code for the x86-64 architecture with | |
33703 | SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be | |
33704 | used to keep the stack boundary aligned to 8 byte boundary. Since | |
33705 | x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and | |
33706 | intended to be used in controlled environment where stack space is | |
33707 | important limitation. This option leads to wrong code when functions | |
33708 | compiled with 16 byte stack alignment (such as functions from a standard | |
33709 | library) are called with misaligned stack. In this case, SSE | |
33710 | instructions may lead to misaligned memory access traps. In addition, | |
33711 | variable arguments are handled incorrectly for 16 byte aligned | |
33712 | objects (including x87 long double and __int128), leading to wrong | |
33713 | results. You must build all modules with | |
33714 | @option{-mpreferred-stack-boundary=3}, including any libraries. This | |
33715 | includes the system libraries and startup modules. | |
33716 | ||
d77de738 | 33717 | @opindex mincoming-stack-boundary |
ddf6fe37 | 33718 | @item -mincoming-stack-boundary=@var{num} |
d77de738 ML |
33719 | Assume the incoming stack is aligned to a 2 raised to @var{num} byte |
33720 | boundary. If @option{-mincoming-stack-boundary} is not specified, | |
33721 | the one specified by @option{-mpreferred-stack-boundary} is used. | |
33722 | ||
33723 | On Pentium and Pentium Pro, @code{double} and @code{long double} values | |
33724 | should be aligned to an 8-byte boundary (see @option{-malign-double}) or | |
33725 | suffer significant run time performance penalties. On Pentium III, the | |
33726 | Streaming SIMD Extension (SSE) data type @code{__m128} may not work | |
33727 | properly if it is not 16-byte aligned. | |
33728 | ||
33729 | To ensure proper alignment of this values on the stack, the stack boundary | |
33730 | must be as aligned as that required by any value stored on the stack. | |
33731 | Further, every function must be generated such that it keeps the stack | |
33732 | aligned. Thus calling a function compiled with a higher preferred | |
33733 | stack boundary from a function compiled with a lower preferred stack | |
33734 | boundary most likely misaligns the stack. It is recommended that | |
33735 | libraries that use callbacks always use the default setting. | |
33736 | ||
33737 | This extra alignment does consume extra stack space, and generally | |
33738 | increases code size. Code that is sensitive to stack space usage, such | |
33739 | as embedded systems and operating system kernels, may want to reduce the | |
33740 | preferred alignment to @option{-mpreferred-stack-boundary=2}. | |
33741 | ||
33742 | @need 200 | |
d77de738 | 33743 | @opindex mmmx |
ddf6fe37 | 33744 | @item -mmmx |
d77de738 | 33745 | @need 200 |
d77de738 | 33746 | @opindex msse |
ddf6fe37 | 33747 | @itemx -msse |
d77de738 | 33748 | @need 200 |
d77de738 | 33749 | @opindex msse2 |
ddf6fe37 | 33750 | @itemx -msse2 |
d77de738 | 33751 | @need 200 |
d77de738 | 33752 | @opindex msse3 |
ddf6fe37 | 33753 | @itemx -msse3 |
d77de738 | 33754 | @need 200 |
d77de738 | 33755 | @opindex mssse3 |
ddf6fe37 | 33756 | @itemx -mssse3 |
d77de738 | 33757 | @need 200 |
d77de738 | 33758 | @opindex msse4 |
ddf6fe37 | 33759 | @itemx -msse4 |
d77de738 | 33760 | @need 200 |
d77de738 | 33761 | @opindex msse4a |
ddf6fe37 | 33762 | @itemx -msse4a |
d77de738 | 33763 | @need 200 |
d77de738 | 33764 | @opindex msse4.1 |
ddf6fe37 | 33765 | @itemx -msse4.1 |
d77de738 | 33766 | @need 200 |
d77de738 | 33767 | @opindex msse4.2 |
ddf6fe37 | 33768 | @itemx -msse4.2 |
d77de738 | 33769 | @need 200 |
d77de738 | 33770 | @opindex mavx |
ddf6fe37 | 33771 | @itemx -mavx |
d77de738 | 33772 | @need 200 |
d77de738 | 33773 | @opindex mavx2 |
ddf6fe37 | 33774 | @itemx -mavx2 |
d77de738 | 33775 | @need 200 |
d77de738 | 33776 | @opindex mavx512f |
ddf6fe37 | 33777 | @itemx -mavx512f |
d77de738 | 33778 | @need 200 |
d77de738 | 33779 | @opindex mavx512pf |
ddf6fe37 | 33780 | @itemx -mavx512pf |
d77de738 | 33781 | @need 200 |
d77de738 | 33782 | @opindex mavx512er |
ddf6fe37 | 33783 | @itemx -mavx512er |
d77de738 | 33784 | @need 200 |
d77de738 | 33785 | @opindex mavx512cd |
ddf6fe37 | 33786 | @itemx -mavx512cd |
d77de738 | 33787 | @need 200 |
d77de738 | 33788 | @opindex mavx512vl |
ddf6fe37 | 33789 | @itemx -mavx512vl |
d77de738 | 33790 | @need 200 |
d77de738 | 33791 | @opindex mavx512bw |
ddf6fe37 | 33792 | @itemx -mavx512bw |
d77de738 | 33793 | @need 200 |
d77de738 | 33794 | @opindex mavx512dq |
ddf6fe37 | 33795 | @itemx -mavx512dq |
d77de738 | 33796 | @need 200 |
d77de738 | 33797 | @opindex mavx512ifma |
ddf6fe37 | 33798 | @itemx -mavx512ifma |
d77de738 | 33799 | @need 200 |
d77de738 | 33800 | @opindex mavx512vbmi |
ddf6fe37 | 33801 | @itemx -mavx512vbmi |
d77de738 | 33802 | @need 200 |
d77de738 | 33803 | @opindex msha |
ddf6fe37 | 33804 | @itemx -msha |
d77de738 | 33805 | @need 200 |
d77de738 | 33806 | @opindex maes |
ddf6fe37 | 33807 | @itemx -maes |
d77de738 | 33808 | @need 200 |
d77de738 | 33809 | @opindex mpclmul |
ddf6fe37 | 33810 | @itemx -mpclmul |
d77de738 | 33811 | @need 200 |
d77de738 | 33812 | @opindex mclflushopt |
ddf6fe37 | 33813 | @itemx -mclflushopt |
d77de738 | 33814 | @need 200 |
d77de738 | 33815 | @opindex mclwb |
ddf6fe37 | 33816 | @itemx -mclwb |
d77de738 | 33817 | @need 200 |
d77de738 | 33818 | @opindex mfsgsbase |
ddf6fe37 | 33819 | @itemx -mfsgsbase |
d77de738 | 33820 | @need 200 |
d77de738 | 33821 | @opindex mptwrite |
ddf6fe37 | 33822 | @itemx -mptwrite |
d77de738 | 33823 | @need 200 |
d77de738 | 33824 | @opindex mrdrnd |
ddf6fe37 | 33825 | @itemx -mrdrnd |
d77de738 | 33826 | @need 200 |
d77de738 | 33827 | @opindex mf16c |
ddf6fe37 | 33828 | @itemx -mf16c |
d77de738 | 33829 | @need 200 |
d77de738 | 33830 | @opindex mfma |
ddf6fe37 | 33831 | @itemx -mfma |
d77de738 | 33832 | @need 200 |
d77de738 | 33833 | @opindex mpconfig |
ddf6fe37 | 33834 | @itemx -mpconfig |
d77de738 | 33835 | @need 200 |
d77de738 | 33836 | @opindex mwbnoinvd |
ddf6fe37 | 33837 | @itemx -mwbnoinvd |
d77de738 | 33838 | @need 200 |
d77de738 | 33839 | @opindex mfma4 |
ddf6fe37 | 33840 | @itemx -mfma4 |
d77de738 | 33841 | @need 200 |
d77de738 | 33842 | @opindex mprfchw |
ddf6fe37 | 33843 | @itemx -mprfchw |
d77de738 | 33844 | @need 200 |
d77de738 | 33845 | @opindex mrdpid |
ddf6fe37 | 33846 | @itemx -mrdpid |
d77de738 | 33847 | @need 200 |
d77de738 | 33848 | @opindex mprefetchwt1 |
ddf6fe37 | 33849 | @itemx -mprefetchwt1 |
d77de738 | 33850 | @need 200 |
d77de738 | 33851 | @opindex mrdseed |
ddf6fe37 | 33852 | @itemx -mrdseed |
d77de738 | 33853 | @need 200 |
d77de738 | 33854 | @opindex msgx |
ddf6fe37 | 33855 | @itemx -msgx |
d77de738 | 33856 | @need 200 |
d77de738 | 33857 | @opindex mxop |
ddf6fe37 | 33858 | @itemx -mxop |
d77de738 | 33859 | @need 200 |
d77de738 | 33860 | @opindex mlwp |
ddf6fe37 | 33861 | @itemx -mlwp |
d77de738 | 33862 | @need 200 |
d77de738 | 33863 | @opindex m3dnow |
ddf6fe37 | 33864 | @itemx -m3dnow |
d77de738 | 33865 | @need 200 |
d77de738 | 33866 | @opindex m3dnowa |
ddf6fe37 | 33867 | @itemx -m3dnowa |
d77de738 | 33868 | @need 200 |
d77de738 | 33869 | @opindex mpopcnt |
ddf6fe37 | 33870 | @itemx -mpopcnt |
d77de738 | 33871 | @need 200 |
d77de738 | 33872 | @opindex mabm |
ddf6fe37 | 33873 | @itemx -mabm |
d77de738 | 33874 | @need 200 |
d77de738 | 33875 | @opindex madx |
ddf6fe37 | 33876 | @itemx -madx |
d77de738 | 33877 | @need 200 |
d77de738 | 33878 | @opindex mbmi |
ddf6fe37 | 33879 | @itemx -mbmi |
d77de738 | 33880 | @need 200 |
d77de738 | 33881 | @opindex mbmi2 |
ddf6fe37 | 33882 | @itemx -mbmi2 |
d77de738 | 33883 | @need 200 |
d77de738 | 33884 | @opindex mlzcnt |
ddf6fe37 | 33885 | @itemx -mlzcnt |
d77de738 | 33886 | @need 200 |
d77de738 | 33887 | @opindex mfxsr |
ddf6fe37 | 33888 | @itemx -mfxsr |
d77de738 | 33889 | @need 200 |
d77de738 | 33890 | @opindex mxsave |
ddf6fe37 | 33891 | @itemx -mxsave |
d77de738 | 33892 | @need 200 |
d77de738 | 33893 | @opindex mxsaveopt |
ddf6fe37 | 33894 | @itemx -mxsaveopt |
d77de738 | 33895 | @need 200 |
d77de738 | 33896 | @opindex mxsavec |
ddf6fe37 | 33897 | @itemx -mxsavec |
d77de738 | 33898 | @need 200 |
d77de738 | 33899 | @opindex mxsaves |
ddf6fe37 | 33900 | @itemx -mxsaves |
d77de738 | 33901 | @need 200 |
d77de738 | 33902 | @opindex mrtm |
ddf6fe37 | 33903 | @itemx -mrtm |
d77de738 | 33904 | @need 200 |
d77de738 | 33905 | @opindex mhle |
ddf6fe37 | 33906 | @itemx -mhle |
d77de738 | 33907 | @need 200 |
d77de738 | 33908 | @opindex mtbm |
ddf6fe37 | 33909 | @itemx -mtbm |
d77de738 | 33910 | @need 200 |
d77de738 | 33911 | @opindex mmwaitx |
ddf6fe37 | 33912 | @itemx -mmwaitx |
d77de738 | 33913 | @need 200 |
d77de738 | 33914 | @opindex mclzero |
ddf6fe37 | 33915 | @itemx -mclzero |
d77de738 | 33916 | @need 200 |
d77de738 | 33917 | @opindex mpku |
ddf6fe37 | 33918 | @itemx -mpku |
d77de738 | 33919 | @need 200 |
d77de738 | 33920 | @opindex mavx512vbmi2 |
ddf6fe37 | 33921 | @itemx -mavx512vbmi2 |
d77de738 | 33922 | @need 200 |
d77de738 | 33923 | @opindex mavx512bf16 |
ddf6fe37 | 33924 | @itemx -mavx512bf16 |
d77de738 | 33925 | @need 200 |
d77de738 | 33926 | @opindex mavx512fp16 |
ddf6fe37 | 33927 | @itemx -mavx512fp16 |
d77de738 | 33928 | @need 200 |
d77de738 | 33929 | @opindex mgfni |
ddf6fe37 | 33930 | @itemx -mgfni |
d77de738 | 33931 | @need 200 |
d77de738 | 33932 | @opindex mvaes |
ddf6fe37 | 33933 | @itemx -mvaes |
d77de738 | 33934 | @need 200 |
d77de738 | 33935 | @opindex mwaitpkg |
ddf6fe37 | 33936 | @itemx -mwaitpkg |
d77de738 | 33937 | @need 200 |
d77de738 | 33938 | @opindex mvpclmulqdq |
ddf6fe37 | 33939 | @itemx -mvpclmulqdq |
d77de738 | 33940 | @need 200 |
d77de738 | 33941 | @opindex mavx512bitalg |
ddf6fe37 | 33942 | @itemx -mavx512bitalg |
d77de738 | 33943 | @need 200 |
d77de738 | 33944 | @opindex mmovdiri |
ddf6fe37 | 33945 | @itemx -mmovdiri |
d77de738 | 33946 | @need 200 |
d77de738 | 33947 | @opindex mmovdir64b |
ddf6fe37 | 33948 | @itemx -mmovdir64b |
d77de738 | 33949 | @need 200 |
d77de738 | 33950 | @opindex menqcmd |
d77de738 | 33951 | @opindex muintr |
ddf6fe37 AA |
33952 | @itemx -menqcmd |
33953 | @itemx -muintr | |
d77de738 | 33954 | @need 200 |
d77de738 | 33955 | @opindex mtsxldtrk |
ddf6fe37 | 33956 | @itemx -mtsxldtrk |
d77de738 | 33957 | @need 200 |
d77de738 | 33958 | @opindex mavx512vpopcntdq |
ddf6fe37 | 33959 | @itemx -mavx512vpopcntdq |
d77de738 | 33960 | @need 200 |
d77de738 | 33961 | @opindex mavx512vp2intersect |
ddf6fe37 | 33962 | @itemx -mavx512vp2intersect |
d77de738 | 33963 | @need 200 |
d77de738 | 33964 | @opindex mavx5124fmaps |
ddf6fe37 | 33965 | @itemx -mavx5124fmaps |
d77de738 | 33966 | @need 200 |
d77de738 | 33967 | @opindex mavx512vnni |
ddf6fe37 | 33968 | @itemx -mavx512vnni |
d77de738 | 33969 | @need 200 |
d77de738 | 33970 | @opindex mavxvnni |
ddf6fe37 | 33971 | @itemx -mavxvnni |
d77de738 | 33972 | @need 200 |
d77de738 | 33973 | @opindex mavx5124vnniw |
ddf6fe37 | 33974 | @itemx -mavx5124vnniw |
d77de738 | 33975 | @need 200 |
d77de738 | 33976 | @opindex mcldemote |
ddf6fe37 | 33977 | @itemx -mcldemote |
d77de738 | 33978 | @need 200 |
d77de738 | 33979 | @opindex mserialize |
ddf6fe37 | 33980 | @itemx -mserialize |
d77de738 | 33981 | @need 200 |
d77de738 | 33982 | @opindex mamx-tile |
ddf6fe37 | 33983 | @itemx -mamx-tile |
d77de738 | 33984 | @need 200 |
d77de738 | 33985 | @opindex mamx-int8 |
ddf6fe37 | 33986 | @itemx -mamx-int8 |
d77de738 | 33987 | @need 200 |
d77de738 | 33988 | @opindex mamx-bf16 |
ddf6fe37 | 33989 | @itemx -mamx-bf16 |
d77de738 | 33990 | @need 200 |
d77de738 | 33991 | @opindex mhreset |
d77de738 | 33992 | @opindex mkl |
ddf6fe37 AA |
33993 | @itemx -mhreset |
33994 | @itemx -mkl | |
d77de738 | 33995 | @need 200 |
d77de738 | 33996 | @opindex mwidekl |
ddf6fe37 | 33997 | @itemx -mwidekl |
d77de738 | 33998 | @need 200 |
d77de738 | 33999 | @opindex mavxifma |
ddf6fe37 | 34000 | @itemx -mavxifma |
d77de738 | 34001 | @need 200 |
d77de738 | 34002 | @opindex mavxvnniint8 |
ddf6fe37 | 34003 | @itemx -mavxvnniint8 |
d77de738 | 34004 | @need 200 |
d77de738 | 34005 | @opindex mavxneconvert |
ddf6fe37 | 34006 | @itemx -mavxneconvert |
d77de738 | 34007 | @need 200 |
d77de738 | 34008 | @opindex mcmpccxadd |
ddf6fe37 | 34009 | @itemx -mcmpccxadd |
d77de738 | 34010 | @need 200 |
d77de738 | 34011 | @opindex mamx-fp16 |
ddf6fe37 | 34012 | @itemx -mamx-fp16 |
d77de738 | 34013 | @need 200 |
d77de738 | 34014 | @opindex mprefetchi |
ddf6fe37 | 34015 | @itemx -mprefetchi |
d77de738 | 34016 | @need 200 |
d77de738 | 34017 | @opindex mraoint |
ddf6fe37 | 34018 | @itemx -mraoint |
efa6a82b HJ |
34019 | @need 200 |
34020 | @opindex mamx-complex | |
34021 | @itemx -mamx-complex | |
1dbc1081 KL |
34022 | @need 200 |
34023 | @opindex mavxvnniint16 | |
34024 | @itemx -mavxvnniint16 | |
8643bcba HJ |
34025 | @need 200 |
34026 | @opindex msm3 | |
34027 | @itemx -msm3 | |
86446132 HJ |
34028 | @need 200 |
34029 | @opindex msha512 | |
34030 | @itemx -msha512 | |
37bdeb8f HJ |
34031 | @need 200 |
34032 | @opindex msm4 | |
34033 | @itemx -msm4 | |
e686416b KL |
34034 | @need 200 |
34035 | @opindex mapxf | |
34036 | @itemx -mapxf | |
5fbd91b1 HL |
34037 | @need 200 |
34038 | @opindex musermsr | |
34039 | @itemx -musermsr | |
d77de738 | 34040 | These switches enable the use of instructions in the MMX, SSE, |
d77de738 ML |
34041 | AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA, |
34042 | AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG, | |
34043 | WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP, | |
34044 | 3DNow!@:, enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE, | |
34045 | XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2, | |
34046 | GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16, | |
34047 | ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE, | |
29ecb952 | 34048 | UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512-FP16, |
efa6a82b | 34049 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT, |
5fbd91b1 HL |
34050 | AMX-COMPLEX, AVXVNNIINT16, SM3, SHA512, SM4, APX_F, USER_MSR or CLDEMOTE |
34051 | extended instruction sets. Each has a corresponding @option{-mno-} option | |
34052 | to disable use of these instructions. | |
d77de738 ML |
34053 | |
34054 | These extensions are also available as built-in functions: see | |
34055 | @ref{x86 Built-in Functions}, for details of the functions enabled and | |
34056 | disabled by these switches. | |
34057 | ||
34058 | To generate SSE/SSE2 instructions automatically from floating-point | |
34059 | code (as opposed to 387 instructions), see @option{-mfpmath=sse}. | |
34060 | ||
34061 | GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it | |
34062 | generates new AVX instructions or AVX equivalence for all SSEx instructions | |
34063 | when needed. | |
34064 | ||
34065 | These options enable GCC to use these extended instructions in | |
34066 | generated code, even without @option{-mfpmath=sse}. Applications that | |
34067 | perform run-time CPU detection must compile separate files for each | |
34068 | supported architecture, using the appropriate flags. In particular, | |
34069 | the file containing the CPU detection code should be compiled without | |
34070 | these options. | |
34071 | ||
d77de738 | 34072 | @opindex mdump-tune-features |
ddf6fe37 | 34073 | @item -mdump-tune-features |
d77de738 ML |
34074 | This option instructs GCC to dump the names of the x86 performance |
34075 | tuning features and default settings. The names can be used in | |
34076 | @option{-mtune-ctrl=@var{feature-list}}. | |
34077 | ||
d77de738 | 34078 | @opindex mtune-ctrl=@var{feature-list} |
ddf6fe37 | 34079 | @item -mtune-ctrl=@var{feature-list} |
d77de738 ML |
34080 | This option is used to do fine grain control of x86 code generation features. |
34081 | @var{feature-list} is a comma separated list of @var{feature} names. See also | |
34082 | @option{-mdump-tune-features}. When specified, the @var{feature} is turned | |
34083 | on if it is not preceded with @samp{^}, otherwise, it is turned off. | |
34084 | @option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC | |
34085 | developers. Using it may lead to code paths not covered by testing and can | |
34086 | potentially result in compiler ICEs or runtime errors. | |
34087 | ||
d77de738 | 34088 | @opindex mno-default |
ddf6fe37 | 34089 | @item -mno-default |
d77de738 ML |
34090 | This option instructs GCC to turn off all tunable features. See also |
34091 | @option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}. | |
34092 | ||
d77de738 | 34093 | @opindex mcld |
ddf6fe37 | 34094 | @item -mcld |
d77de738 ML |
34095 | This option instructs GCC to emit a @code{cld} instruction in the prologue |
34096 | of functions that use string instructions. String instructions depend on | |
34097 | the DF flag to select between autoincrement or autodecrement mode. While the | |
34098 | ABI specifies the DF flag to be cleared on function entry, some operating | |
34099 | systems violate this specification by not clearing the DF flag in their | |
34100 | exception dispatchers. The exception handler can be invoked with the DF flag | |
34101 | set, which leads to wrong direction mode when string instructions are used. | |
34102 | This option can be enabled by default on 32-bit x86 targets by configuring | |
34103 | GCC with the @option{--enable-cld} configure option. Generation of @code{cld} | |
34104 | instructions can be suppressed with the @option{-mno-cld} compiler option | |
34105 | in this case. | |
34106 | ||
d77de738 | 34107 | @opindex mvzeroupper |
ddf6fe37 | 34108 | @item -mvzeroupper |
d77de738 ML |
34109 | This option instructs GCC to emit a @code{vzeroupper} instruction |
34110 | before a transfer of control flow out of the function to minimize | |
34111 | the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper} | |
34112 | intrinsics. | |
34113 | ||
d77de738 | 34114 | @opindex mprefer-avx128 |
ddf6fe37 | 34115 | @item -mprefer-avx128 |
d77de738 ML |
34116 | This option instructs GCC to use 128-bit AVX instructions instead of |
34117 | 256-bit AVX instructions in the auto-vectorizer. | |
34118 | ||
d77de738 | 34119 | @opindex mprefer-vector-width |
ddf6fe37 | 34120 | @item -mprefer-vector-width=@var{opt} |
d77de738 ML |
34121 | This option instructs GCC to use @var{opt}-bit vector width in instructions |
34122 | instead of default on the selected platform. | |
34123 | ||
ad5b757d UB |
34124 | @opindex mpartial-vector-fp-math |
34125 | @item -mpartial-vector-fp-math | |
34126 | This option enables GCC to generate floating-point operations that might | |
34127 | affect the set of floating-point status flags on partial vectors, where | |
34128 | vector elements reside in the low part of the 128-bit SSE register. Unless | |
34129 | @option{-fno-trapping-math} is specified, the compiler guarantees correct | |
34130 | behavior by sanitizing all input operands to have zeroes in the unused | |
34131 | upper part of the vector register. Note that by using built-in functions | |
34132 | or inline assembly with partial vector arguments, NaNs, denormal or invalid | |
34133 | values can leak into the upper part of the vector, causing possible | |
34134 | performance issues when @option{-fno-trapping-math} is in effect. These | |
34135 | issues can be mitigated by manually sanitizing the upper part of the partial | |
34136 | vector argument register or by using @option{-mdaz-ftz} to set | |
34137 | denormals-are-zero (DAZ) flag in the MXCSR register. | |
34138 | ||
34139 | This option is enabled by default. | |
34140 | ||
d77de738 | 34141 | @opindex mmove-max |
ddf6fe37 | 34142 | @item -mmove-max=@var{bits} |
d77de738 ML |
34143 | This option instructs GCC to set the maximum number of bits can be |
34144 | moved from memory to memory efficiently to @var{bits}. The valid | |
34145 | @var{bits} are 128, 256 and 512. | |
34146 | ||
d77de738 | 34147 | @opindex mstore-max |
ddf6fe37 | 34148 | @item -mstore-max=@var{bits} |
d77de738 ML |
34149 | This option instructs GCC to set the maximum number of bits can be |
34150 | stored to memory efficiently to @var{bits}. The valid @var{bits} are | |
34151 | 128, 256 and 512. | |
34152 | ||
34153 | @table @samp | |
34154 | @item none | |
34155 | No extra limitations applied to GCC other than defined by the selected platform. | |
34156 | ||
34157 | @item 128 | |
34158 | Prefer 128-bit vector width for instructions. | |
34159 | ||
34160 | @item 256 | |
34161 | Prefer 256-bit vector width for instructions. | |
34162 | ||
34163 | @item 512 | |
34164 | Prefer 512-bit vector width for instructions. | |
34165 | @end table | |
34166 | ||
d77de738 | 34167 | @opindex mcx16 |
ddf6fe37 | 34168 | @item -mcx16 |
d77de738 ML |
34169 | This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit |
34170 | code to implement compare-and-exchange operations on 16-byte aligned 128-bit | |
34171 | objects. This is useful for atomic updates of data structures exceeding one | |
34172 | machine word in size. The compiler uses this instruction to implement | |
34173 | @ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on | |
34174 | 128-bit integers, a library call is always used. | |
34175 | ||
d77de738 | 34176 | @opindex msahf |
ddf6fe37 | 34177 | @item -msahf |
d77de738 ML |
34178 | This option enables generation of @code{SAHF} instructions in 64-bit code. |
34179 | Early Intel Pentium 4 CPUs with Intel 64 support, | |
34180 | prior to the introduction of Pentium 4 G1 step in December 2005, | |
34181 | lacked the @code{LAHF} and @code{SAHF} instructions | |
34182 | which are supported by AMD64. | |
34183 | These are load and store instructions, respectively, for certain status flags. | |
34184 | In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod}, | |
34185 | @code{drem}, and @code{remainder} built-in functions; | |
34186 | see @ref{Other Builtins} for details. | |
34187 | ||
d77de738 | 34188 | @opindex mmovbe |
ddf6fe37 | 34189 | @item -mmovbe |
d77de738 ML |
34190 | This option enables use of the @code{movbe} instruction to implement |
34191 | @code{__builtin_bswap32} and @code{__builtin_bswap64}. | |
34192 | ||
d77de738 | 34193 | @opindex mshstk |
ddf6fe37 | 34194 | @item -mshstk |
d77de738 ML |
34195 | The @option{-mshstk} option enables shadow stack built-in functions |
34196 | from x86 Control-flow Enforcement Technology (CET). | |
34197 | ||
d77de738 | 34198 | @opindex mcrc32 |
ddf6fe37 | 34199 | @item -mcrc32 |
d77de738 ML |
34200 | This option enables built-in functions @code{__builtin_ia32_crc32qi}, |
34201 | @code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and | |
34202 | @code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction. | |
34203 | ||
d77de738 | 34204 | @opindex mmwait |
ddf6fe37 | 34205 | @item -mmwait |
d77de738 ML |
34206 | This option enables built-in functions @code{__builtin_ia32_monitor}, |
34207 | and @code{__builtin_ia32_mwait} to generate the @code{monitor} and | |
34208 | @code{mwait} machine instructions. | |
34209 | ||
d77de738 | 34210 | @opindex mrecip |
ddf6fe37 | 34211 | @item -mrecip |
d77de738 ML |
34212 | This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions |
34213 | (and their vectorized variants @code{RCPPS} and @code{RSQRTPS}) | |
34214 | with an additional Newton-Raphson step | |
34215 | to increase precision instead of @code{DIVSS} and @code{SQRTSS} | |
34216 | (and their vectorized | |
34217 | variants) for single-precision floating-point arguments. These instructions | |
34218 | are generated only when @option{-funsafe-math-optimizations} is enabled | |
34219 | together with @option{-ffinite-math-only} and @option{-fno-trapping-math}. | |
34220 | Note that while the throughput of the sequence is higher than the throughput | |
34221 | of the non-reciprocal instruction, the precision of the sequence can be | |
34222 | decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994). | |
34223 | ||
34224 | Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS} | |
34225 | (or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option | |
34226 | combination), and doesn't need @option{-mrecip}. | |
34227 | ||
34228 | Also note that GCC emits the above sequence with additional Newton-Raphson step | |
34229 | for vectorized single-float division and vectorized @code{sqrtf(@var{x})} | |
34230 | already with @option{-ffast-math} (or the above option combination), and | |
34231 | doesn't need @option{-mrecip}. | |
34232 | ||
d77de738 | 34233 | @opindex mrecip=opt |
ddf6fe37 | 34234 | @item -mrecip=@var{opt} |
d77de738 ML |
34235 | This option controls which reciprocal estimate instructions |
34236 | may be used. @var{opt} is a comma-separated list of options, which may | |
34237 | be preceded by a @samp{!} to invert the option: | |
34238 | ||
34239 | @table @samp | |
34240 | @item all | |
34241 | Enable all estimate instructions. | |
34242 | ||
34243 | @item default | |
34244 | Enable the default instructions, equivalent to @option{-mrecip}. | |
34245 | ||
34246 | @item none | |
34247 | Disable all estimate instructions, equivalent to @option{-mno-recip}. | |
34248 | ||
34249 | @item div | |
34250 | Enable the approximation for scalar division. | |
34251 | ||
34252 | @item vec-div | |
34253 | Enable the approximation for vectorized division. | |
34254 | ||
34255 | @item sqrt | |
34256 | Enable the approximation for scalar square root. | |
34257 | ||
34258 | @item vec-sqrt | |
34259 | Enable the approximation for vectorized square root. | |
34260 | @end table | |
34261 | ||
34262 | So, for example, @option{-mrecip=all,!sqrt} enables | |
34263 | all of the reciprocal approximations, except for square root. | |
34264 | ||
d77de738 | 34265 | @opindex mveclibabi |
ddf6fe37 | 34266 | @item -mveclibabi=@var{type} |
d77de738 ML |
34267 | Specifies the ABI type to use for vectorizing intrinsics using an |
34268 | external library. Supported values for @var{type} are @samp{svml} | |
34269 | for the Intel short | |
34270 | vector math library and @samp{acml} for the AMD math core library. | |
34271 | To use this option, both @option{-ftree-vectorize} and | |
34272 | @option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML | |
34273 | ABI-compatible library must be specified at link time. | |
34274 | ||
34275 | GCC currently emits calls to @code{vmldExp2}, | |
34276 | @code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2}, | |
34277 | @code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2}, | |
34278 | @code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2}, | |
34279 | @code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2}, | |
34280 | @code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4}, | |
34281 | @code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4}, | |
34282 | @code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4}, | |
34283 | @code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4}, | |
34284 | @code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for corresponding | |
34285 | function type when @option{-mveclibabi=svml} is used, and @code{__vrd2_sin}, | |
34286 | @code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2}, | |
34287 | @code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf}, | |
34288 | @code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f}, | |
34289 | @code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type | |
34290 | when @option{-mveclibabi=acml} is used. | |
34291 | ||
d77de738 | 34292 | @opindex mabi |
ddf6fe37 | 34293 | @item -mabi=@var{name} |
d77de738 ML |
34294 | Generate code for the specified calling convention. Permissible values |
34295 | are @samp{sysv} for the ABI used on GNU/Linux and other systems, and | |
34296 | @samp{ms} for the Microsoft ABI. The default is to use the Microsoft | |
34297 | ABI when targeting Microsoft Windows and the SysV ABI on all other systems. | |
34298 | You can control this behavior for specific functions by | |
34299 | using the function attributes @code{ms_abi} and @code{sysv_abi}. | |
34300 | @xref{Function Attributes}. | |
34301 | ||
d77de738 | 34302 | @opindex mforce-indirect-call |
ddf6fe37 | 34303 | @item -mforce-indirect-call |
d77de738 ML |
34304 | Force all calls to functions to be indirect. This is useful |
34305 | when using Intel Processor Trace where it generates more precise timing | |
34306 | information for function calls. | |
34307 | ||
d77de738 | 34308 | @opindex mmanual-endbr |
ddf6fe37 | 34309 | @item -mmanual-endbr |
d77de738 ML |
34310 | Insert ENDBR instruction at function entry only via the @code{cf_check} |
34311 | function attribute. This is useful when used with the option | |
34312 | @option{-fcf-protection=branch} to control ENDBR insertion at the | |
34313 | function entry. | |
34314 | ||
d77de738 | 34315 | @opindex mcet-switch |
ddf6fe37 | 34316 | @item -mcet-switch |
d77de738 ML |
34317 | By default, CET instrumentation is turned off on switch statements that |
34318 | use a jump table and indirect branch track is disabled. Since jump | |
34319 | tables are stored in read-only memory, this does not result in a direct | |
34320 | loss of hardening. But if the jump table index is attacker-controlled, | |
34321 | the indirect jump may not be constrained by CET. This option turns on | |
34322 | CET instrumentation to enable indirect branch track for switch statements | |
34323 | with jump tables which leads to the jump targets reachable via any indirect | |
34324 | jumps. | |
34325 | ||
d77de738 ML |
34326 | @opindex mcall-ms2sysv-xlogues |
34327 | @opindex mno-call-ms2sysv-xlogues | |
ddf6fe37 | 34328 | @item -mcall-ms2sysv-xlogues |
d77de738 ML |
34329 | Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a |
34330 | System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By | |
34331 | default, the code for saving and restoring these registers is emitted inline, | |
34332 | resulting in fairly lengthy prologues and epilogues. Using | |
34333 | @option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that | |
34334 | use stubs in the static portion of libgcc to perform these saves and restores, | |
34335 | thus reducing function size at the cost of a few extra instructions. | |
34336 | ||
d77de738 | 34337 | @opindex mtls-dialect |
ddf6fe37 | 34338 | @item -mtls-dialect=@var{type} |
d77de738 ML |
34339 | Generate code to access thread-local storage using the @samp{gnu} or |
34340 | @samp{gnu2} conventions. @samp{gnu} is the conservative default; | |
34341 | @samp{gnu2} is more efficient, but it may add compile- and run-time | |
34342 | requirements that cannot be satisfied on all systems. | |
34343 | ||
d77de738 ML |
34344 | @opindex mpush-args |
34345 | @opindex mno-push-args | |
ddf6fe37 AA |
34346 | @item -mpush-args |
34347 | @itemx -mno-push-args | |
d77de738 ML |
34348 | Use PUSH operations to store outgoing parameters. This method is shorter |
34349 | and usually equally fast as method using SUB/MOV operations and is enabled | |
34350 | by default. In some cases disabling it may improve performance because of | |
34351 | improved scheduling and reduced dependencies. | |
34352 | ||
d77de738 | 34353 | @opindex maccumulate-outgoing-args |
ddf6fe37 | 34354 | @item -maccumulate-outgoing-args |
d77de738 ML |
34355 | If enabled, the maximum amount of space required for outgoing arguments is |
34356 | computed in the function prologue. This is faster on most modern CPUs | |
34357 | because of reduced dependencies, improved scheduling and reduced stack usage | |
34358 | when the preferred stack boundary is not equal to 2. The drawback is a notable | |
34359 | increase in code size. This switch implies @option{-mno-push-args}. | |
34360 | ||
d77de738 | 34361 | @opindex mthreads |
ddf6fe37 | 34362 | @item -mthreads |
d77de738 ML |
34363 | Support thread-safe exception handling on MinGW. Programs that rely |
34364 | on thread-safe exception handling must compile and link all code with the | |
34365 | @option{-mthreads} option. When compiling, @option{-mthreads} defines | |
34366 | @option{-D_MT}; when linking, it links in a special thread helper library | |
34367 | @option{-lmingwthrd} which cleans up per-thread exception-handling data. | |
34368 | ||
d77de738 ML |
34369 | @opindex mms-bitfields |
34370 | @opindex mno-ms-bitfields | |
ddf6fe37 AA |
34371 | @item -mms-bitfields |
34372 | @itemx -mno-ms-bitfields | |
d77de738 ML |
34373 | |
34374 | Enable/disable bit-field layout compatible with the native Microsoft | |
34375 | Windows compiler. | |
34376 | ||
34377 | If @code{packed} is used on a structure, or if bit-fields are used, | |
34378 | it may be that the Microsoft ABI lays out the structure differently | |
34379 | than the way GCC normally does. Particularly when moving packed | |
34380 | data between functions compiled with GCC and the native Microsoft compiler | |
34381 | (either via function call or as data in a file), it may be necessary to access | |
34382 | either format. | |
34383 | ||
34384 | This option is enabled by default for Microsoft Windows | |
34385 | targets. This behavior can also be controlled locally by use of variable | |
34386 | or type attributes. For more information, see @ref{x86 Variable Attributes} | |
34387 | and @ref{x86 Type Attributes}. | |
34388 | ||
34389 | The Microsoft structure layout algorithm is fairly simple with the exception | |
34390 | of the bit-field packing. | |
34391 | The padding and alignment of members of structures and whether a bit-field | |
34392 | can straddle a storage-unit boundary are determine by these rules: | |
34393 | ||
34394 | @enumerate | |
34395 | @item Structure members are stored sequentially in the order in which they are | |
34396 | declared: the first member has the lowest memory address and the last member | |
34397 | the highest. | |
34398 | ||
34399 | @item Every data object has an alignment requirement. The alignment requirement | |
34400 | for all data except structures, unions, and arrays is either the size of the | |
34401 | object or the current packing size (specified with either the | |
34402 | @code{aligned} attribute or the @code{pack} pragma), | |
34403 | whichever is less. For structures, unions, and arrays, | |
34404 | the alignment requirement is the largest alignment requirement of its members. | |
34405 | Every object is allocated an offset so that: | |
34406 | ||
34407 | @smallexample | |
34408 | offset % alignment_requirement == 0 | |
34409 | @end smallexample | |
34410 | ||
34411 | @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation | |
34412 | unit if the integral types are the same size and if the next bit-field fits | |
34413 | into the current allocation unit without crossing the boundary imposed by the | |
34414 | common alignment requirements of the bit-fields. | |
34415 | @end enumerate | |
34416 | ||
34417 | MSVC interprets zero-length bit-fields in the following ways: | |
34418 | ||
34419 | @enumerate | |
34420 | @item If a zero-length bit-field is inserted between two bit-fields that | |
34421 | are normally coalesced, the bit-fields are not coalesced. | |
34422 | ||
34423 | For example: | |
34424 | ||
34425 | @smallexample | |
34426 | struct | |
34427 | @{ | |
34428 | unsigned long bf_1 : 12; | |
34429 | unsigned long : 0; | |
34430 | unsigned long bf_2 : 12; | |
34431 | @} t1; | |
34432 | @end smallexample | |
34433 | ||
34434 | @noindent | |
34435 | The size of @code{t1} is 8 bytes with the zero-length bit-field. If the | |
34436 | zero-length bit-field were removed, @code{t1}'s size would be 4 bytes. | |
34437 | ||
34438 | @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the | |
34439 | alignment of the zero-length bit-field is greater than the member that follows it, | |
34440 | @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field. | |
34441 | ||
34442 | For example: | |
34443 | ||
34444 | @smallexample | |
34445 | struct | |
34446 | @{ | |
34447 | char foo : 4; | |
34448 | short : 0; | |
34449 | char bar; | |
34450 | @} t2; | |
34451 | ||
34452 | struct | |
34453 | @{ | |
34454 | char foo : 4; | |
34455 | short : 0; | |
34456 | double bar; | |
34457 | @} t3; | |
34458 | @end smallexample | |
34459 | ||
34460 | @noindent | |
34461 | For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1. | |
34462 | Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length | |
34463 | bit-field does not affect the alignment of @code{bar} or, as a result, the size | |
34464 | of the structure. | |
34465 | ||
34466 | Taking this into account, it is important to note the following: | |
34467 | ||
34468 | @enumerate | |
34469 | @item If a zero-length bit-field follows a normal bit-field, the type of the | |
34470 | zero-length bit-field may affect the alignment of the structure as whole. For | |
34471 | example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a | |
34472 | normal bit-field, and is of type short. | |
34473 | ||
34474 | @item Even if a zero-length bit-field is not followed by a normal bit-field, it may | |
34475 | still affect the alignment of the structure: | |
34476 | ||
34477 | @smallexample | |
34478 | struct | |
34479 | @{ | |
34480 | char foo : 6; | |
34481 | long : 0; | |
34482 | @} t4; | |
34483 | @end smallexample | |
34484 | ||
34485 | @noindent | |
34486 | Here, @code{t4} takes up 4 bytes. | |
34487 | @end enumerate | |
34488 | ||
34489 | @item Zero-length bit-fields following non-bit-field members are ignored: | |
34490 | ||
34491 | @smallexample | |
34492 | struct | |
34493 | @{ | |
34494 | char foo; | |
34495 | long : 0; | |
34496 | char bar; | |
34497 | @} t5; | |
34498 | @end smallexample | |
34499 | ||
34500 | @noindent | |
34501 | Here, @code{t5} takes up 2 bytes. | |
34502 | @end enumerate | |
34503 | ||
34504 | ||
d77de738 ML |
34505 | @opindex mno-align-stringops |
34506 | @opindex malign-stringops | |
ddf6fe37 | 34507 | @item -mno-align-stringops |
d77de738 ML |
34508 | Do not align the destination of inlined string operations. This switch reduces |
34509 | code size and improves performance in case the destination is already aligned, | |
34510 | but GCC doesn't know about it. | |
34511 | ||
d77de738 | 34512 | @opindex minline-all-stringops |
ddf6fe37 | 34513 | @item -minline-all-stringops |
d77de738 ML |
34514 | By default GCC inlines string operations only when the destination is |
34515 | known to be aligned to least a 4-byte boundary. | |
34516 | This enables more inlining and increases code | |
34517 | size, but may improve performance of code that depends on fast | |
34518 | @code{memcpy} and @code{memset} for short lengths. | |
34519 | The option enables inline expansion of @code{strlen} for all | |
34520 | pointer alignments. | |
34521 | ||
d77de738 | 34522 | @opindex minline-stringops-dynamically |
ddf6fe37 | 34523 | @item -minline-stringops-dynamically |
d77de738 ML |
34524 | For string operations of unknown size, use run-time checks with |
34525 | inline code for small blocks and a library call for large blocks. | |
34526 | ||
d77de738 | 34527 | @opindex mstringop-strategy=@var{alg} |
ddf6fe37 | 34528 | @item -mstringop-strategy=@var{alg} |
d77de738 ML |
34529 | Override the internal decision heuristic for the particular algorithm to use |
34530 | for inlining string operations. The allowed values for @var{alg} are: | |
34531 | ||
34532 | @table @samp | |
34533 | @item rep_byte | |
34534 | @itemx rep_4byte | |
34535 | @itemx rep_8byte | |
34536 | Expand using i386 @code{rep} prefix of the specified size. | |
34537 | ||
34538 | @item byte_loop | |
34539 | @itemx loop | |
34540 | @itemx unrolled_loop | |
34541 | Expand into an inline loop. | |
34542 | ||
34543 | @item libcall | |
34544 | Always use a library call. | |
34545 | @end table | |
34546 | ||
d77de738 | 34547 | @opindex mmemcpy-strategy=@var{strategy} |
ddf6fe37 | 34548 | @item -mmemcpy-strategy=@var{strategy} |
d77de738 ML |
34549 | Override the internal decision heuristic to decide if @code{__builtin_memcpy} |
34550 | should be inlined and what inline algorithm to use when the expected size | |
34551 | of the copy operation is known. @var{strategy} | |
34552 | is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets. | |
34553 | @var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies | |
34554 | the max byte size with which inline algorithm @var{alg} is allowed. For the last | |
34555 | triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets | |
34556 | in the list must be specified in increasing order. The minimal byte size for | |
34557 | @var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the | |
34558 | preceding range. | |
34559 | ||
d77de738 | 34560 | @opindex mmemset-strategy=@var{strategy} |
ddf6fe37 | 34561 | @item -mmemset-strategy=@var{strategy} |
d77de738 ML |
34562 | The option is similar to @option{-mmemcpy-strategy=} except that it is to control |
34563 | @code{__builtin_memset} expansion. | |
34564 | ||
d77de738 | 34565 | @opindex momit-leaf-frame-pointer |
ddf6fe37 | 34566 | @item -momit-leaf-frame-pointer |
d77de738 ML |
34567 | Don't keep the frame pointer in a register for leaf functions. This |
34568 | avoids the instructions to save, set up, and restore frame pointers and | |
34569 | makes an extra register available in leaf functions. The option | |
34570 | @option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions, | |
34571 | which might make debugging harder. | |
34572 | ||
ddf6fe37 | 34573 | @opindex mtls-direct-seg-refs |
d77de738 ML |
34574 | @item -mtls-direct-seg-refs |
34575 | @itemx -mno-tls-direct-seg-refs | |
d77de738 ML |
34576 | Controls whether TLS variables may be accessed with offsets from the |
34577 | TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit), | |
34578 | or whether the thread base pointer must be added. Whether or not this | |
34579 | is valid depends on the operating system, and whether it maps the | |
34580 | segment to cover the entire TLS area. | |
34581 | ||
34582 | For systems that use the GNU C Library, the default is on. | |
34583 | ||
ddf6fe37 | 34584 | @opindex msse2avx |
d77de738 ML |
34585 | @item -msse2avx |
34586 | @itemx -mno-sse2avx | |
d77de738 ML |
34587 | Specify that the assembler should encode SSE instructions with VEX |
34588 | prefix. The option @option{-mavx} turns this on by default. | |
34589 | ||
ddf6fe37 | 34590 | @opindex mfentry |
d77de738 ML |
34591 | @item -mfentry |
34592 | @itemx -mno-fentry | |
d77de738 ML |
34593 | If profiling is active (@option{-pg}), put the profiling |
34594 | counter call before the prologue. | |
34595 | Note: On x86 architectures the attribute @code{ms_hook_prologue} | |
34596 | isn't possible at the moment for @option{-mfentry} and @option{-pg}. | |
34597 | ||
ddf6fe37 | 34598 | @opindex mrecord-mcount |
d77de738 ML |
34599 | @item -mrecord-mcount |
34600 | @itemx -mno-record-mcount | |
d77de738 ML |
34601 | If profiling is active (@option{-pg}), generate a __mcount_loc section |
34602 | that contains pointers to each profiling call. This is useful for | |
34603 | automatically patching and out calls. | |
34604 | ||
ddf6fe37 | 34605 | @opindex mnop-mcount |
d77de738 ML |
34606 | @item -mnop-mcount |
34607 | @itemx -mno-nop-mcount | |
d77de738 ML |
34608 | If profiling is active (@option{-pg}), generate the calls to |
34609 | the profiling functions as NOPs. This is useful when they | |
34610 | should be patched in later dynamically. This is likely only | |
34611 | useful together with @option{-mrecord-mcount}. | |
34612 | ||
d77de738 | 34613 | @opindex minstrument-return |
ddf6fe37 | 34614 | @item -minstrument-return=@var{type} |
d77de738 ML |
34615 | Instrument function exit in -pg -mfentry instrumented functions with |
34616 | call to specified function. This only instruments true returns ending | |
34617 | with ret, but not sibling calls ending with jump. Valid types | |
34618 | are @var{none} to not instrument, @var{call} to generate a call to __return__, | |
34619 | or @var{nop5} to generate a 5 byte nop. | |
34620 | ||
ddf6fe37 | 34621 | @opindex mrecord-return |
d77de738 ML |
34622 | @item -mrecord-return |
34623 | @itemx -mno-record-return | |
d77de738 ML |
34624 | Generate a __return_loc section pointing to all return instrumentation code. |
34625 | ||
d77de738 | 34626 | @opindex mfentry-name |
ddf6fe37 | 34627 | @item -mfentry-name=@var{name} |
d77de738 ML |
34628 | Set name of __fentry__ symbol called at function entry for -pg -mfentry functions. |
34629 | ||
d77de738 | 34630 | @opindex mfentry-section |
ddf6fe37 | 34631 | @item -mfentry-section=@var{name} |
d77de738 ML |
34632 | Set name of section to record -mrecord-mcount calls (default __mcount_loc). |
34633 | ||
ddf6fe37 | 34634 | @opindex mskip-rax-setup |
d77de738 ML |
34635 | @item -mskip-rax-setup |
34636 | @itemx -mno-skip-rax-setup | |
d77de738 ML |
34637 | When generating code for the x86-64 architecture with SSE extensions |
34638 | disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX | |
34639 | register when there are no variable arguments passed in vector registers. | |
34640 | ||
34641 | @strong{Warning:} Since RAX register is used to avoid unnecessarily | |
34642 | saving vector registers on stack when passing variable arguments, the | |
34643 | impacts of this option are callees may waste some stack space, | |
34644 | misbehave or jump to a random location. GCC 4.4 or newer don't have | |
34645 | those issues, regardless the RAX register value. | |
34646 | ||
ddf6fe37 | 34647 | @opindex m8bit-idiv |
d77de738 ML |
34648 | @item -m8bit-idiv |
34649 | @itemx -mno-8bit-idiv | |
d77de738 ML |
34650 | On some processors, like Intel Atom, 8-bit unsigned integer divide is |
34651 | much faster than 32-bit/64-bit integer divide. This option generates a | |
34652 | run-time check. If both dividend and divisor are within range of 0 | |
34653 | to 255, 8-bit unsigned integer divide is used instead of | |
34654 | 32-bit/64-bit integer divide. | |
34655 | ||
d77de738 ML |
34656 | @opindex mavx256-split-unaligned-load |
34657 | @opindex mavx256-split-unaligned-store | |
ddf6fe37 AA |
34658 | @item -mavx256-split-unaligned-load |
34659 | @itemx -mavx256-split-unaligned-store | |
d77de738 ML |
34660 | Split 32-byte AVX unaligned load and store. |
34661 | ||
d77de738 ML |
34662 | @opindex mstack-protector-guard |
34663 | @opindex mstack-protector-guard-reg | |
34664 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
34665 | @item -mstack-protector-guard=@var{guard} |
34666 | @itemx -mstack-protector-guard-reg=@var{reg} | |
34667 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
34668 | Generate stack protection code using canary at @var{guard}. Supported |
34669 | locations are @samp{global} for global canary or @samp{tls} for per-thread | |
34670 | canary in the TLS block (the default). This option has effect only when | |
34671 | @option{-fstack-protector} or @option{-fstack-protector-all} is specified. | |
34672 | ||
34673 | With the latter choice the options | |
34674 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
34675 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
34676 | which segment register (@code{%fs} or @code{%gs}) to use as base register | |
34677 | for reading the canary, and from what offset from that base register. | |
34678 | The default for those is as specified in the relevant ABI. | |
34679 | ||
d77de738 | 34680 | @opindex mgeneral-regs-only |
ddf6fe37 | 34681 | @item -mgeneral-regs-only |
d77de738 ML |
34682 | Generate code that uses only the general-purpose registers. This |
34683 | prevents the compiler from using floating-point, vector, mask and bound | |
34684 | registers. | |
34685 | ||
d77de738 | 34686 | @opindex mrelax-cmpxchg-loop |
ddf6fe37 | 34687 | @item -mrelax-cmpxchg-loop |
85966f0d AM |
34688 | When emitting a compare-and-swap loop for @ref{__sync Builtins} |
34689 | and @ref{__atomic Builtins} lacking a native instruction, optimize | |
34690 | for the highly contended case by issuing an atomic load before the | |
34691 | @code{CMPXCHG} instruction, and using the @code{PAUSE} instruction | |
34692 | to save CPU power when restarting the loop. | |
d77de738 | 34693 | |
d77de738 | 34694 | @opindex mindirect-branch |
ddf6fe37 | 34695 | @item -mindirect-branch=@var{choice} |
d77de738 ML |
34696 | Convert indirect call and jump with @var{choice}. The default is |
34697 | @samp{keep}, which keeps indirect call and jump unmodified. | |
34698 | @samp{thunk} converts indirect call and jump to call and return thunk. | |
34699 | @samp{thunk-inline} converts indirect call and jump to inlined call | |
34700 | and return thunk. @samp{thunk-extern} converts indirect call and jump | |
34701 | to external call and return thunk provided in a separate object file. | |
34702 | You can control this behavior for a specific function by using the | |
34703 | function attribute @code{indirect_branch}. @xref{Function Attributes}. | |
34704 | ||
34705 | Note that @option{-mcmodel=large} is incompatible with | |
34706 | @option{-mindirect-branch=thunk} and | |
34707 | @option{-mindirect-branch=thunk-extern} since the thunk function may | |
34708 | not be reachable in the large code model. | |
34709 | ||
34710 | Note that @option{-mindirect-branch=thunk-extern} is compatible with | |
34711 | @option{-fcf-protection=branch} since the external thunk can be made | |
34712 | to enable control-flow check. | |
34713 | ||
d77de738 | 34714 | @opindex mfunction-return |
ddf6fe37 | 34715 | @item -mfunction-return=@var{choice} |
d77de738 ML |
34716 | Convert function return with @var{choice}. The default is @samp{keep}, |
34717 | which keeps function return unmodified. @samp{thunk} converts function | |
34718 | return to call and return thunk. @samp{thunk-inline} converts function | |
34719 | return to inlined call and return thunk. @samp{thunk-extern} converts | |
34720 | function return to external call and return thunk provided in a separate | |
34721 | object file. You can control this behavior for a specific function by | |
34722 | using the function attribute @code{function_return}. | |
34723 | @xref{Function Attributes}. | |
34724 | ||
34725 | Note that @option{-mindirect-return=thunk-extern} is compatible with | |
34726 | @option{-fcf-protection=branch} since the external thunk can be made | |
34727 | to enable control-flow check. | |
34728 | ||
34729 | Note that @option{-mcmodel=large} is incompatible with | |
34730 | @option{-mfunction-return=thunk} and | |
34731 | @option{-mfunction-return=thunk-extern} since the thunk function may | |
34732 | not be reachable in the large code model. | |
34733 | ||
34734 | ||
d77de738 | 34735 | @opindex mindirect-branch-register |
ddf6fe37 | 34736 | @item -mindirect-branch-register |
d77de738 ML |
34737 | Force indirect call and jump via register. |
34738 | ||
d77de738 | 34739 | @opindex mharden-sls |
ddf6fe37 | 34740 | @item -mharden-sls=@var{choice} |
d77de738 ML |
34741 | Generate code to mitigate against straight line speculation (SLS) with |
34742 | @var{choice}. The default is @samp{none} which disables all SLS | |
34743 | hardening. @samp{return} enables SLS hardening for function returns. | |
34744 | @samp{indirect-jmp} enables SLS hardening for indirect jumps. | |
34745 | @samp{all} enables all SLS hardening. | |
34746 | ||
d77de738 | 34747 | @opindex mindirect-branch-cs-prefix |
ddf6fe37 | 34748 | @item -mindirect-branch-cs-prefix |
d77de738 ML |
34749 | Add CS prefix to call and jmp to indirect thunk with branch target in |
34750 | r8-r15 registers so that the call and jmp instruction length is 6 bytes | |
34751 | to allow them to be replaced with @samp{lfence; call *%r8-r15} or | |
34752 | @samp{lfence; jmp *%r8-r15} at run-time. | |
34753 | ||
34754 | @end table | |
34755 | ||
34756 | These @samp{-m} switches are supported in addition to the above | |
34757 | on x86-64 processors in 64-bit environments. | |
34758 | ||
34759 | @table @gcctabopt | |
d77de738 ML |
34760 | @opindex m32 |
34761 | @opindex m64 | |
34762 | @opindex mx32 | |
34763 | @opindex m16 | |
34764 | @opindex miamcu | |
ddf6fe37 AA |
34765 | @item -m32 |
34766 | @itemx -m64 | |
34767 | @itemx -mx32 | |
34768 | @itemx -m16 | |
34769 | @itemx -miamcu | |
d77de738 ML |
34770 | Generate code for a 16-bit, 32-bit or 64-bit environment. |
34771 | The @option{-m32} option sets @code{int}, @code{long}, and pointer types | |
34772 | to 32 bits, and | |
eeb92704 | 34773 | generates code that runs in 32-bit mode. |
d77de738 ML |
34774 | |
34775 | The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer | |
34776 | types to 64 bits, and generates code for the x86-64 architecture. | |
34777 | For Darwin only the @option{-m64} option also turns off the @option{-fno-pic} | |
34778 | and @option{-mdynamic-no-pic} options. | |
34779 | ||
34780 | The @option{-mx32} option sets @code{int}, @code{long}, and pointer types | |
34781 | to 32 bits, and | |
34782 | generates code for the x86-64 architecture. | |
34783 | ||
34784 | The @option{-m16} option is the same as @option{-m32}, except for that | |
34785 | it outputs the @code{.code16gcc} assembly directive at the beginning of | |
34786 | the assembly output so that the binary can run in 16-bit mode. | |
34787 | ||
34788 | The @option{-miamcu} option generates code which conforms to Intel MCU | |
34789 | psABI. It requires the @option{-m32} option to be turned on. | |
34790 | ||
d77de738 ML |
34791 | @opindex mno-red-zone |
34792 | @opindex mred-zone | |
ddf6fe37 | 34793 | @item -mno-red-zone |
d77de738 ML |
34794 | Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated |
34795 | by the x86-64 ABI; it is a 128-byte area beyond the location of the | |
34796 | stack pointer that is not modified by signal or interrupt handlers | |
34797 | and therefore can be used for temporary data without adjusting the stack | |
34798 | pointer. The flag @option{-mno-red-zone} disables this red zone. | |
34799 | ||
d77de738 | 34800 | @opindex mcmodel=small |
ddf6fe37 | 34801 | @item -mcmodel=small |
d77de738 ML |
34802 | Generate code for the small code model: the program and its symbols must |
34803 | be linked in the lower 2 GB of the address space. Pointers are 64 bits. | |
34804 | Programs can be statically or dynamically linked. This is the default | |
34805 | code model. | |
34806 | ||
d77de738 | 34807 | @opindex mcmodel=kernel |
ddf6fe37 | 34808 | @item -mcmodel=kernel |
d77de738 ML |
34809 | Generate code for the kernel code model. The kernel runs in the |
34810 | negative 2 GB of the address space. | |
34811 | This model has to be used for Linux kernel code. | |
34812 | ||
d77de738 | 34813 | @opindex mcmodel=medium |
ddf6fe37 | 34814 | @item -mcmodel=medium |
d77de738 ML |
34815 | Generate code for the medium model: the program is linked in the lower 2 |
34816 | GB of the address space. Small symbols are also placed there. Symbols | |
34817 | with sizes larger than @option{-mlarge-data-threshold} are put into | |
34818 | large data or BSS sections and can be located above 2GB. Programs can | |
34819 | be statically or dynamically linked. | |
34820 | ||
d77de738 | 34821 | @opindex mcmodel=large |
ddf6fe37 | 34822 | @item -mcmodel=large |
d77de738 ML |
34823 | Generate code for the large model. This model makes no assumptions |
34824 | about addresses and sizes of sections. | |
34825 | ||
d77de738 | 34826 | @opindex maddress-mode=long |
ddf6fe37 | 34827 | @item -maddress-mode=long |
d77de738 ML |
34828 | Generate code for long address mode. This is only supported for 64-bit |
34829 | and x32 environments. It is the default address mode for 64-bit | |
34830 | environments. | |
34831 | ||
d77de738 | 34832 | @opindex maddress-mode=short |
ddf6fe37 | 34833 | @item -maddress-mode=short |
d77de738 ML |
34834 | Generate code for short address mode. This is only supported for 32-bit |
34835 | and x32 environments. It is the default address mode for 32-bit and | |
34836 | x32 environments. | |
34837 | ||
ddf6fe37 | 34838 | @opindex mneeded |
d77de738 ML |
34839 | @item -mneeded |
34840 | @itemx -mno-needed | |
d77de738 ML |
34841 | Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to |
34842 | indicate the micro-architecture ISA level required to execute the binary. | |
34843 | ||
d77de738 ML |
34844 | @opindex mno-direct-extern-access |
34845 | @opindex mdirect-extern-access | |
ddf6fe37 | 34846 | @item -mno-direct-extern-access |
d77de738 ML |
34847 | Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer |
34848 | to access external symbols. With @option{-fpic} or @option{-fPIC}, | |
34849 | treat access to protected symbols as local symbols. The default is | |
34850 | @option{-mdirect-extern-access}. | |
34851 | ||
34852 | @strong{Warning:} shared libraries compiled with | |
34853 | @option{-mno-direct-extern-access} and executable compiled with | |
34854 | @option{-mdirect-extern-access} may not be binary compatible if | |
34855 | protected symbols are used in shared libraries and executable. | |
ce51e843 | 34856 | |
ce51e843 ML |
34857 | @opindex munroll-only-small-loops |
34858 | @opindex mno-unroll-only-small-loops | |
ddf6fe37 | 34859 | @item -munroll-only-small-loops |
ce51e843 ML |
34860 | Controls conservative small loop unrolling. It is default enabled by |
34861 | O2, and unrolls loop with less than 4 insns by 1 time. Explicit | |
34862 | -f[no-]unroll-[all-]loops would disable this flag to avoid any | |
34863 | unintended unrolling behavior that user does not want. | |
bb576017 | 34864 | |
bb576017 | 34865 | @opindex mlam |
ddf6fe37 | 34866 | @item -mlam=@var{choice} |
bb576017 | 34867 | LAM(linear-address masking) allows special bits in the pointer to be used |
34868 | for metadata. The default is @samp{none}. With @samp{u48}, pointer bits in | |
34869 | positions 62:48 can be used for metadata; With @samp{u57}, pointer bits in | |
34870 | positions 62:57 can be used for metadata. | |
d77de738 ML |
34871 | @end table |
34872 | ||
34873 | @node x86 Windows Options | |
34874 | @subsection x86 Windows Options | |
34875 | @cindex x86 Windows Options | |
34876 | @cindex Windows Options for x86 | |
34877 | ||
34878 | These additional options are available for Microsoft Windows targets: | |
34879 | ||
34880 | @table @gcctabopt | |
d77de738 | 34881 | @opindex mconsole |
ddf6fe37 | 34882 | @item -mconsole |
d77de738 ML |
34883 | This option |
34884 | specifies that a console application is to be generated, by | |
34885 | instructing the linker to set the PE header subsystem type | |
34886 | required for console applications. | |
34887 | This option is available for Cygwin and MinGW targets and is | |
34888 | enabled by default on those targets. | |
34889 | ||
453cb585 PR |
34890 | @opindex mcrtdll |
34891 | @item -mcrtdll=@var{library} | |
34892 | Preprocess, compile or link with specified C RunTime DLL @var{library}. | |
34893 | This option adjust predefined macros @code{__CRTDLL__}, @code{__MSVCRT__} | |
34894 | and @code{__MSVCRT_VERSION__} for specified CRT @var{library}, choose | |
34895 | start file for CRT @var{library} and link with CRT @var{library}. | |
34896 | Recognized CRT library names for proprocessor are: | |
34897 | @code{crtdll}, @code{msvcrt10}, @code{msvcrt20}, @code{msvcrt40}, | |
34898 | @code{msvcrt-os}, @code{msvcr70}, @code{msvcr80}, @code{msvcr90}, | |
34899 | @code{msvcr100}, @code{msvcr110}, @code{msvcr120} and @code{ucrt}. | |
34900 | If this options is not specified then the default MinGW import library | |
34901 | @code{msvcrt} is used for linking and no other adjustment for | |
34902 | preprocessor is done. MinGW import library @code{msvcrt} is just a | |
34903 | symlink to (or a copy of) another MinGW CRT import library | |
34904 | chosen during MinGW compilation. MinGW import library @code{msvcrt-os} | |
34905 | is for Windows system CRT DLL library @code{msvcrt.dll} and | |
34906 | in most cases is the default MinGW import library. | |
34907 | Generally speaking, changing the CRT DLL requires recompiling | |
34908 | the entire MinGW CRT. This option is for experimental and testing | |
34909 | purposes only. | |
34910 | This option is available for MinGW targets. | |
34911 | ||
d77de738 | 34912 | @opindex mdll |
ddf6fe37 | 34913 | @item -mdll |
d77de738 ML |
34914 | This option is available for Cygwin and MinGW targets. It |
34915 | specifies that a DLL---a dynamic link library---is to be | |
34916 | generated, enabling the selection of the required runtime | |
34917 | startup object and entry point. | |
34918 | ||
d77de738 | 34919 | @opindex mnop-fun-dllimport |
ddf6fe37 | 34920 | @item -mnop-fun-dllimport |
d77de738 ML |
34921 | This option is available for Cygwin and MinGW targets. It |
34922 | specifies that the @code{dllimport} attribute should be ignored. | |
34923 | ||
d77de738 | 34924 | @opindex mthreads |
ddf6fe37 | 34925 | @item -mthreads |
d77de738 ML |
34926 | This option is available for MinGW targets. It specifies |
34927 | that MinGW-specific thread support is to be used. | |
34928 | ||
d77de738 | 34929 | @opindex municode |
ddf6fe37 | 34930 | @item -municode |
d77de738 ML |
34931 | This option is available for MinGW-w64 targets. It causes |
34932 | the @code{UNICODE} preprocessor macro to be predefined, and | |
34933 | chooses Unicode-capable runtime startup code. | |
34934 | ||
d77de738 | 34935 | @opindex mwin32 |
ddf6fe37 | 34936 | @item -mwin32 |
d77de738 ML |
34937 | This option is available for Cygwin and MinGW targets. It |
34938 | specifies that the typical Microsoft Windows predefined macros are to | |
34939 | be set in the pre-processor, but does not influence the choice | |
34940 | of runtime library/startup code. | |
34941 | ||
d77de738 | 34942 | @opindex mwindows |
ddf6fe37 | 34943 | @item -mwindows |
d77de738 ML |
34944 | This option is available for Cygwin and MinGW targets. It |
34945 | specifies that a GUI application is to be generated by | |
34946 | instructing the linker to set the PE header subsystem type | |
34947 | appropriately. | |
34948 | ||
d77de738 ML |
34949 | @opindex fno-set-stack-executable |
34950 | @opindex fset-stack-executable | |
ddf6fe37 | 34951 | @item -fno-set-stack-executable |
d77de738 ML |
34952 | This option is available for MinGW targets. It specifies that |
34953 | the executable flag for the stack used by nested functions isn't | |
34954 | set. This is necessary for binaries running in kernel mode of | |
34955 | Microsoft Windows, as there the User32 API, which is used to set executable | |
34956 | privileges, isn't available. | |
34957 | ||
d77de738 ML |
34958 | @opindex fno-writable-relocated-rdata |
34959 | @opindex fwritable-relocated-rdata | |
ddf6fe37 | 34960 | @item -fwritable-relocated-rdata |
d77de738 ML |
34961 | This option is available for MinGW and Cygwin targets. It specifies |
34962 | that relocated-data in read-only section is put into the @code{.data} | |
34963 | section. This is a necessary for older runtimes not supporting | |
34964 | modification of @code{.rdata} sections for pseudo-relocation. | |
34965 | ||
d77de738 | 34966 | @opindex mpe-aligned-commons |
ddf6fe37 | 34967 | @item -mpe-aligned-commons |
d77de738 ML |
34968 | This option is available for Cygwin and MinGW targets. It |
34969 | specifies that the GNU extension to the PE file format that | |
34970 | permits the correct alignment of COMMON variables should be | |
34971 | used when generating code. It is enabled by default if | |
34972 | GCC detects that the target assembler found during configuration | |
34973 | supports the feature. | |
34974 | @end table | |
34975 | ||
34976 | See also under @ref{x86 Options} for standard options. | |
34977 | ||
34978 | @node Xstormy16 Options | |
34979 | @subsection Xstormy16 Options | |
34980 | @cindex Xstormy16 Options | |
34981 | ||
34982 | These options are defined for Xstormy16: | |
34983 | ||
34984 | @table @gcctabopt | |
d77de738 | 34985 | @opindex msim |
ddf6fe37 | 34986 | @item -msim |
d77de738 ML |
34987 | Choose startup files and linker script suitable for the simulator. |
34988 | @end table | |
34989 | ||
34990 | @node Xtensa Options | |
34991 | @subsection Xtensa Options | |
34992 | @cindex Xtensa Options | |
34993 | ||
34994 | These options are supported for Xtensa targets: | |
34995 | ||
34996 | @table @gcctabopt | |
d77de738 ML |
34997 | @opindex mconst16 |
34998 | @opindex mno-const16 | |
ddf6fe37 AA |
34999 | @item -mconst16 |
35000 | @itemx -mno-const16 | |
d77de738 ML |
35001 | Enable or disable use of @code{CONST16} instructions for loading |
35002 | constant values. The @code{CONST16} instruction is currently not a | |
35003 | standard option from Tensilica. When enabled, @code{CONST16} | |
35004 | instructions are always used in place of the standard @code{L32R} | |
35005 | instructions. The use of @code{CONST16} is enabled by default only if | |
35006 | the @code{L32R} instruction is not available. | |
35007 | ||
d77de738 ML |
35008 | @opindex mfused-madd |
35009 | @opindex mno-fused-madd | |
ddf6fe37 AA |
35010 | @item -mfused-madd |
35011 | @itemx -mno-fused-madd | |
d77de738 ML |
35012 | Enable or disable use of fused multiply/add and multiply/subtract |
35013 | instructions in the floating-point option. This has no effect if the | |
35014 | floating-point option is not also enabled. Disabling fused multiply/add | |
35015 | and multiply/subtract instructions forces the compiler to use separate | |
35016 | instructions for the multiply and add/subtract operations. This may be | |
35017 | desirable in some cases where strict IEEE 754-compliant results are | |
35018 | required: the fused multiply add/subtract instructions do not round the | |
35019 | intermediate result, thereby producing results with @emph{more} bits of | |
35020 | precision than specified by the IEEE standard. Disabling fused multiply | |
35021 | add/subtract instructions also ensures that the program output is not | |
35022 | sensitive to the compiler's ability to combine multiply and add/subtract | |
35023 | operations. | |
35024 | ||
d77de738 ML |
35025 | @opindex mserialize-volatile |
35026 | @opindex mno-serialize-volatile | |
ddf6fe37 AA |
35027 | @item -mserialize-volatile |
35028 | @itemx -mno-serialize-volatile | |
d77de738 ML |
35029 | When this option is enabled, GCC inserts @code{MEMW} instructions before |
35030 | @code{volatile} memory references to guarantee sequential consistency. | |
35031 | The default is @option{-mserialize-volatile}. Use | |
35032 | @option{-mno-serialize-volatile} to omit the @code{MEMW} instructions. | |
35033 | ||
d77de738 | 35034 | @opindex mforce-no-pic |
ddf6fe37 | 35035 | @item -mforce-no-pic |
d77de738 ML |
35036 | For targets, like GNU/Linux, where all user-mode Xtensa code must be |
35037 | position-independent code (PIC), this option disables PIC for compiling | |
35038 | kernel code. | |
35039 | ||
d77de738 ML |
35040 | @opindex mtext-section-literals |
35041 | @opindex mno-text-section-literals | |
ddf6fe37 AA |
35042 | @item -mtext-section-literals |
35043 | @itemx -mno-text-section-literals | |
d77de738 ML |
35044 | These options control the treatment of literal pools. The default is |
35045 | @option{-mno-text-section-literals}, which places literals in a separate | |
35046 | section in the output file. This allows the literal pool to be placed | |
35047 | in a data RAM/ROM, and it also allows the linker to combine literal | |
35048 | pools from separate object files to remove redundant literals and | |
35049 | improve code size. With @option{-mtext-section-literals}, the literals | |
35050 | are interspersed in the text section in order to keep them as close as | |
35051 | possible to their references. This may be necessary for large assembly | |
35052 | files. Literals for each function are placed right before that function. | |
35053 | ||
d77de738 ML |
35054 | @opindex mauto-litpools |
35055 | @opindex mno-auto-litpools | |
ddf6fe37 AA |
35056 | @item -mauto-litpools |
35057 | @itemx -mno-auto-litpools | |
d77de738 ML |
35058 | These options control the treatment of literal pools. The default is |
35059 | @option{-mno-auto-litpools}, which places literals in a separate | |
35060 | section in the output file unless @option{-mtext-section-literals} is | |
35061 | used. With @option{-mauto-litpools} the literals are interspersed in | |
35062 | the text section by the assembler. Compiler does not produce explicit | |
35063 | @code{.literal} directives and loads literals into registers with | |
35064 | @code{MOVI} instructions instead of @code{L32R} to let the assembler | |
35065 | do relaxation and place literals as necessary. This option allows | |
35066 | assembler to create several literal pools per function and assemble | |
35067 | very big functions, which may not be possible with | |
35068 | @option{-mtext-section-literals}. | |
35069 | ||
d77de738 ML |
35070 | @opindex mtarget-align |
35071 | @opindex mno-target-align | |
ddf6fe37 AA |
35072 | @item -mtarget-align |
35073 | @itemx -mno-target-align | |
d77de738 ML |
35074 | When this option is enabled, GCC instructs the assembler to |
35075 | automatically align instructions to reduce branch penalties at the | |
35076 | expense of some code density. The assembler attempts to widen density | |
35077 | instructions to align branch targets and the instructions following call | |
35078 | instructions. If there are not enough preceding safe density | |
35079 | instructions to align a target, no widening is performed. The | |
35080 | default is @option{-mtarget-align}. These options do not affect the | |
35081 | treatment of auto-aligned instructions like @code{LOOP}, which the | |
35082 | assembler always aligns, either by widening density instructions or | |
35083 | by inserting NOP instructions. | |
35084 | ||
d77de738 ML |
35085 | @opindex mlongcalls |
35086 | @opindex mno-longcalls | |
ddf6fe37 AA |
35087 | @item -mlongcalls |
35088 | @itemx -mno-longcalls | |
d77de738 ML |
35089 | When this option is enabled, GCC instructs the assembler to translate |
35090 | direct calls to indirect calls unless it can determine that the target | |
35091 | of a direct call is in the range allowed by the call instruction. This | |
35092 | translation typically occurs for calls to functions in other source | |
35093 | files. Specifically, the assembler translates a direct @code{CALL} | |
35094 | instruction into an @code{L32R} followed by a @code{CALLX} instruction. | |
35095 | The default is @option{-mno-longcalls}. This option should be used in | |
35096 | programs where the call target can potentially be out of range. This | |
35097 | option is implemented in the assembler, not the compiler, so the | |
35098 | assembly code generated by GCC still shows direct call | |
35099 | instructions---look at the disassembled object code to see the actual | |
35100 | instructions. Note that the assembler uses an indirect call for | |
35101 | every cross-file call, not just those that really are out of range. | |
35102 | ||
d77de738 | 35103 | @opindex mabi |
ddf6fe37 | 35104 | @item -mabi=@var{name} |
d77de738 ML |
35105 | Generate code for the specified ABI@. Permissible values are: @samp{call0}, |
35106 | @samp{windowed}. Default ABI is chosen by the Xtensa core configuration. | |
35107 | ||
d77de738 | 35108 | @opindex mabi=call0 |
ddf6fe37 | 35109 | @item -mabi=call0 |
d77de738 ML |
35110 | When this option is enabled function parameters are passed in registers |
35111 | @code{a2} through @code{a7}, registers @code{a12} through @code{a15} are | |
35112 | caller-saved, and register @code{a15} may be used as a frame pointer. | |
35113 | When this version of the ABI is enabled the C preprocessor symbol | |
35114 | @code{__XTENSA_CALL0_ABI__} is defined. | |
35115 | ||
d77de738 | 35116 | @opindex mabi=windowed |
ddf6fe37 | 35117 | @item -mabi=windowed |
d77de738 ML |
35118 | When this option is enabled function parameters are passed in registers |
35119 | @code{a10} through @code{a15}, and called function rotates register window | |
35120 | by 8 registers on entry so that its arguments are found in registers | |
35121 | @code{a2} through @code{a7}. Register @code{a7} may be used as a frame | |
35122 | pointer. Register window is rotated 8 registers back upon return. | |
35123 | When this version of the ABI is enabled the C preprocessor symbol | |
35124 | @code{__XTENSA_WINDOWED_ABI__} is defined. | |
35125 | ||
d77de738 | 35126 | @opindex mextra-l32r-costs |
ddf6fe37 | 35127 | @item -mextra-l32r-costs=@var{n} |
d77de738 ML |
35128 | Specify an extra cost of instruction RAM/ROM access for @code{L32R} |
35129 | instructions, in clock cycles. This affects, when optimizing for speed, | |
35130 | whether loading a constant from literal pool using @code{L32R} or | |
35131 | synthesizing the constant from a small one with a couple of arithmetic | |
35132 | instructions. The default value is 0. | |
675b390e MF |
35133 | |
35134 | @opindex mstrict-align | |
35135 | @opindex mno-strict-align | |
35136 | @item -mstrict-align | |
35137 | @itemx -mno-strict-align | |
35138 | Avoid or allow generating memory accesses that may not be aligned on a natural | |
35139 | object boundary as described in the architecture specification. | |
35140 | The default is @option{-mno-strict-align} for cores that support both | |
35141 | unaligned loads and stores in hardware and @option{-mstrict-align} for all | |
35142 | other cores. | |
35143 | ||
d77de738 ML |
35144 | @end table |
35145 | ||
35146 | @node zSeries Options | |
35147 | @subsection zSeries Options | |
35148 | @cindex zSeries options | |
35149 | ||
35150 | These are listed under @xref{S/390 and zSeries Options}. | |
35151 | ||
35152 | ||
35153 | @c man end | |
35154 | ||
35155 | @node Spec Files | |
35156 | @section Specifying Subprocesses and the Switches to Pass to Them | |
35157 | @cindex Spec Files | |
35158 | ||
35159 | @command{gcc} is a driver program. It performs its job by invoking a | |
35160 | sequence of other programs to do the work of compiling, assembling and | |
35161 | linking. GCC interprets its command-line parameters and uses these to | |
35162 | deduce which programs it should invoke, and which command-line options | |
35163 | it ought to place on their command lines. This behavior is controlled | |
35164 | by @dfn{spec strings}. In most cases there is one spec string for each | |
35165 | program that GCC can invoke, but a few programs have multiple spec | |
35166 | strings to control their behavior. The spec strings built into GCC can | |
35167 | be overridden by using the @option{-specs=} command-line switch to specify | |
35168 | a spec file. | |
35169 | ||
35170 | @dfn{Spec files} are plain-text files that are used to construct spec | |
35171 | strings. They consist of a sequence of directives separated by blank | |
35172 | lines. The type of directive is determined by the first non-whitespace | |
35173 | character on the line, which can be one of the following: | |
35174 | ||
35175 | @table @code | |
35176 | @item %@var{command} | |
35177 | Issues a @var{command} to the spec file processor. The commands that can | |
35178 | appear here are: | |
35179 | ||
35180 | @table @code | |
d77de738 | 35181 | @cindex @code{%include} |
f33d7a88 | 35182 | @item %include <@var{file}> |
d77de738 ML |
35183 | Search for @var{file} and insert its text at the current point in the |
35184 | specs file. | |
35185 | ||
d77de738 | 35186 | @cindex @code{%include_noerr} |
f33d7a88 | 35187 | @item %include_noerr <@var{file}> |
d77de738 ML |
35188 | Just like @samp{%include}, but do not generate an error message if the include |
35189 | file cannot be found. | |
35190 | ||
d77de738 | 35191 | @cindex @code{%rename} |
f33d7a88 | 35192 | @item %rename @var{old_name} @var{new_name} |
d77de738 ML |
35193 | Rename the spec string @var{old_name} to @var{new_name}. |
35194 | ||
35195 | @end table | |
35196 | ||
35197 | @item *[@var{spec_name}]: | |
35198 | This tells the compiler to create, override or delete the named spec | |
35199 | string. All lines after this directive up to the next directive or | |
35200 | blank line are considered to be the text for the spec string. If this | |
35201 | results in an empty string then the spec is deleted. (Or, if the | |
35202 | spec did not exist, then nothing happens.) Otherwise, if the spec | |
35203 | does not currently exist a new spec is created. If the spec does | |
35204 | exist then its contents are overridden by the text of this | |
35205 | directive, unless the first character of that text is the @samp{+} | |
35206 | character, in which case the text is appended to the spec. | |
35207 | ||
35208 | @item [@var{suffix}]: | |
35209 | Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive | |
35210 | and up to the next directive or blank line are considered to make up the | |
35211 | spec string for the indicated suffix. When the compiler encounters an | |
35212 | input file with the named suffix, it processes the spec string in | |
35213 | order to work out how to compile that file. For example: | |
35214 | ||
35215 | @smallexample | |
35216 | .ZZ: | |
35217 | z-compile -input %i | |
35218 | @end smallexample | |
35219 | ||
35220 | This says that any input file whose name ends in @samp{.ZZ} should be | |
35221 | passed to the program @samp{z-compile}, which should be invoked with the | |
35222 | command-line switch @option{-input} and with the result of performing the | |
35223 | @samp{%i} substitution. (See below.) | |
35224 | ||
35225 | As an alternative to providing a spec string, the text following a | |
35226 | suffix directive can be one of the following: | |
35227 | ||
35228 | @table @code | |
35229 | @item @@@var{language} | |
35230 | This says that the suffix is an alias for a known @var{language}. This is | |
35231 | similar to using the @option{-x} command-line switch to GCC to specify a | |
35232 | language explicitly. For example: | |
35233 | ||
35234 | @smallexample | |
35235 | .ZZ: | |
35236 | @@c++ | |
35237 | @end smallexample | |
35238 | ||
35239 | Says that .ZZ files are, in fact, C++ source files. | |
35240 | ||
35241 | @item #@var{name} | |
35242 | This causes an error messages saying: | |
35243 | ||
35244 | @smallexample | |
35245 | @var{name} compiler not installed on this system. | |
35246 | @end smallexample | |
35247 | @end table | |
35248 | ||
35249 | GCC already has an extensive list of suffixes built into it. | |
35250 | This directive adds an entry to the end of the list of suffixes, but | |
35251 | since the list is searched from the end backwards, it is effectively | |
35252 | possible to override earlier entries using this technique. | |
35253 | ||
35254 | @end table | |
35255 | ||
35256 | GCC has the following spec strings built into it. Spec files can | |
35257 | override these strings or create their own. Note that individual | |
35258 | targets can also add their own spec strings to this list. | |
35259 | ||
35260 | @smallexample | |
35261 | asm Options to pass to the assembler | |
35262 | asm_final Options to pass to the assembler post-processor | |
35263 | cpp Options to pass to the C preprocessor | |
35264 | cc1 Options to pass to the C compiler | |
35265 | cc1plus Options to pass to the C++ compiler | |
35266 | endfile Object files to include at the end of the link | |
35267 | link Options to pass to the linker | |
35268 | lib Libraries to include on the command line to the linker | |
35269 | libgcc Decides which GCC support library to pass to the linker | |
35270 | linker Sets the name of the linker | |
35271 | predefines Defines to be passed to the C preprocessor | |
35272 | signed_char Defines to pass to CPP to say whether @code{char} is signed | |
35273 | by default | |
35274 | startfile Object files to include at the start of the link | |
35275 | @end smallexample | |
35276 | ||
35277 | Here is a small example of a spec file: | |
35278 | ||
35279 | @smallexample | |
35280 | %rename lib old_lib | |
35281 | ||
35282 | *lib: | |
35283 | --start-group -lgcc -lc -leval1 --end-group %(old_lib) | |
35284 | @end smallexample | |
35285 | ||
35286 | This example renames the spec called @samp{lib} to @samp{old_lib} and | |
35287 | then overrides the previous definition of @samp{lib} with a new one. | |
35288 | The new definition adds in some extra command-line options before | |
35289 | including the text of the old definition. | |
35290 | ||
35291 | @dfn{Spec strings} are a list of command-line options to be passed to their | |
35292 | corresponding program. In addition, the spec strings can contain | |
35293 | @samp{%}-prefixed sequences to substitute variable text or to | |
35294 | conditionally insert text into the command line. Using these constructs | |
35295 | it is possible to generate quite complex command lines. | |
35296 | ||
35297 | Here is a table of all defined @samp{%}-sequences for spec | |
35298 | strings. Note that spaces are not generated automatically around the | |
35299 | results of expanding these sequences. Therefore you can concatenate them | |
35300 | together or combine them with constant text in a single argument. | |
35301 | ||
35302 | @table @code | |
35303 | @item %% | |
35304 | Substitute one @samp{%} into the program name or argument. | |
35305 | ||
35306 | @item %" | |
35307 | Substitute an empty argument. | |
35308 | ||
35309 | @item %i | |
35310 | Substitute the name of the input file being processed. | |
35311 | ||
35312 | @item %b | |
35313 | Substitute the basename for outputs related with the input file being | |
35314 | processed. This is often the substring up to (and not including) the | |
35315 | last period and not including the directory but, unless %w is active, it | |
35316 | expands to the basename for auxiliary outputs, which may be influenced | |
35317 | by an explicit output name, and by various other options that control | |
35318 | how auxiliary outputs are named. | |
35319 | ||
35320 | @item %B | |
35321 | This is the same as @samp{%b}, but include the file suffix (text after | |
35322 | the last period). Without %w, it expands to the basename for dump | |
35323 | outputs. | |
35324 | ||
35325 | @item %d | |
35326 | Marks the argument containing or following the @samp{%d} as a | |
35327 | temporary file name, so that that file is deleted if GCC exits | |
35328 | successfully. Unlike @samp{%g}, this contributes no text to the | |
35329 | argument. | |
35330 | ||
35331 | @item %g@var{suffix} | |
35332 | Substitute a file name that has suffix @var{suffix} and is chosen | |
35333 | once per compilation, and mark the argument in the same way as | |
35334 | @samp{%d}. To reduce exposure to denial-of-service attacks, the file | |
35335 | name is now chosen in a way that is hard to predict even when previously | |
35336 | chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s} | |
35337 | might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches | |
35338 | the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is | |
35339 | treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g} | |
35340 | was simply substituted with a file name chosen once per compilation, | |
35341 | without regard to any appended suffix (which was therefore treated | |
35342 | just like ordinary text), making such attacks more likely to succeed. | |
35343 | ||
35344 | @item %u@var{suffix} | |
35345 | Like @samp{%g}, but generates a new temporary file name | |
35346 | each time it appears instead of once per compilation. | |
35347 | ||
35348 | @item %U@var{suffix} | |
35349 | Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a | |
35350 | new one if there is no such last file name. In the absence of any | |
35351 | @samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share | |
35352 | the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s} | |
35353 | involves the generation of two distinct file names, one | |
35354 | for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was | |
35355 | simply substituted with a file name chosen for the previous @samp{%u}, | |
35356 | without regard to any appended suffix. | |
35357 | ||
35358 | @item %j@var{suffix} | |
35359 | Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is | |
35360 | writable, and if @option{-save-temps} is not used; | |
35361 | otherwise, substitute the name | |
35362 | of a temporary file, just like @samp{%u}. This temporary file is not | |
35363 | meant for communication between processes, but rather as a junk | |
35364 | disposal mechanism. | |
35365 | ||
35366 | @item %|@var{suffix} | |
35367 | @itemx %m@var{suffix} | |
35368 | Like @samp{%g}, except if @option{-pipe} is in effect. In that case | |
35369 | @samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at | |
35370 | all. These are the two most common ways to instruct a program that it | |
35371 | should read from standard input or write to standard output. If you | |
35372 | need something more elaborate you can use an @samp{%@{pipe:@code{X}@}} | |
35373 | construct: see for example @file{gcc/fortran/lang-specs.h}. | |
35374 | ||
35375 | @item %.@var{SUFFIX} | |
35376 | Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args | |
35377 | when it is subsequently output with @samp{%*}. @var{SUFFIX} is | |
35378 | terminated by the next space or %. | |
35379 | ||
35380 | @item %w | |
35381 | Marks the argument containing or following the @samp{%w} as the | |
35382 | designated output file of this compilation. This puts the argument | |
35383 | into the sequence of arguments that @samp{%o} substitutes. | |
35384 | ||
35385 | @item %V | |
35386 | Indicates that this compilation produces no output file. | |
35387 | ||
35388 | @item %o | |
35389 | Substitutes the names of all the output files, with spaces | |
35390 | automatically placed around them. You should write spaces | |
35391 | around the @samp{%o} as well or the results are undefined. | |
35392 | @samp{%o} is for use in the specs for running the linker. | |
35393 | Input files whose names have no recognized suffix are not compiled | |
35394 | at all, but they are included among the output files, so they are | |
35395 | linked. | |
35396 | ||
35397 | @item %O | |
35398 | Substitutes the suffix for object files. Note that this is | |
35399 | handled specially when it immediately follows @samp{%g, %u, or %U}, | |
35400 | because of the need for those to form complete file names. The | |
35401 | handling is such that @samp{%O} is treated exactly as if it had already | |
35402 | been substituted, except that @samp{%g, %u, and %U} do not currently | |
35403 | support additional @var{suffix} characters following @samp{%O} as they do | |
35404 | following, for example, @samp{.o}. | |
35405 | ||
35406 | @item %I | |
35407 | Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}), | |
35408 | @option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}), | |
35409 | @option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options) | |
35410 | and @option{-imultilib} as necessary. | |
35411 | ||
35412 | @item %s | |
35413 | Current argument is the name of a library or startup file of some sort. | |
35414 | Search for that file in a standard list of directories and substitute | |
35415 | the full name found. The current working directory is included in the | |
35416 | list of directories scanned. | |
35417 | ||
35418 | @item %T | |
35419 | Current argument is the name of a linker script. Search for that file | |
35420 | in the current list of directories to scan for libraries. If the file | |
35421 | is located insert a @option{--script} option into the command line | |
35422 | followed by the full path name found. If the file is not found then | |
35423 | generate an error message. Note: the current working directory is not | |
35424 | searched. | |
35425 | ||
35426 | @item %e@var{str} | |
35427 | Print @var{str} as an error message. @var{str} is terminated by a newline. | |
35428 | Use this when inconsistent options are detected. | |
35429 | ||
35430 | @item %n@var{str} | |
35431 | Print @var{str} as a notice. @var{str} is terminated by a newline. | |
35432 | ||
35433 | @item %(@var{name}) | |
35434 | Substitute the contents of spec string @var{name} at this point. | |
35435 | ||
35436 | @item %x@{@var{option}@} | |
35437 | Accumulate an option for @samp{%X}. | |
35438 | ||
35439 | @item %X | |
35440 | Output the accumulated linker options specified by a @samp{%x} spec string. | |
35441 | ||
35442 | @item %Y | |
35443 | Output the accumulated assembler options specified by @option{-Wa}. | |
35444 | ||
35445 | @item %Z | |
35446 | Output the accumulated preprocessor options specified by @option{-Wp}. | |
35447 | ||
35448 | @item %M | |
35449 | Output @code{multilib_os_dir}. | |
35450 | ||
35451 | @item %R | |
35452 | Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}. | |
35453 | ||
35454 | @item %a | |
35455 | Process the @code{asm} spec. This is used to compute the | |
35456 | switches to be passed to the assembler. | |
35457 | ||
35458 | @item %A | |
35459 | Process the @code{asm_final} spec. This is a spec string for | |
35460 | passing switches to an assembler post-processor, if such a program is | |
35461 | needed. | |
35462 | ||
35463 | @item %l | |
35464 | Process the @code{link} spec. This is the spec for computing the | |
35465 | command line passed to the linker. Typically it makes use of the | |
35466 | @samp{%L %G %S %D and %E} sequences. | |
35467 | ||
35468 | @item %D | |
35469 | Dump out a @option{-L} option for each directory that GCC believes might | |
35470 | contain startup files. If the target supports multilibs then the | |
35471 | current multilib directory is prepended to each of these paths. | |
35472 | ||
35473 | @item %L | |
35474 | Process the @code{lib} spec. This is a spec string for deciding which | |
35475 | libraries are included on the command line to the linker. | |
35476 | ||
35477 | @item %G | |
35478 | Process the @code{libgcc} spec. This is a spec string for deciding | |
35479 | which GCC support library is included on the command line to the linker. | |
35480 | ||
35481 | @item %S | |
35482 | Process the @code{startfile} spec. This is a spec for deciding which | |
35483 | object files are the first ones passed to the linker. Typically | |
35484 | this might be a file named @file{crt0.o}. | |
35485 | ||
35486 | @item %E | |
35487 | Process the @code{endfile} spec. This is a spec string that specifies | |
35488 | the last object files that are passed to the linker. | |
35489 | ||
35490 | @item %C | |
35491 | Process the @code{cpp} spec. This is used to construct the arguments | |
35492 | to be passed to the C preprocessor. | |
35493 | ||
35494 | @item %1 | |
35495 | Process the @code{cc1} spec. This is used to construct the options to be | |
35496 | passed to the actual C compiler (@command{cc1}). | |
35497 | ||
35498 | @item %2 | |
35499 | Process the @code{cc1plus} spec. This is used to construct the options to be | |
35500 | passed to the actual C++ compiler (@command{cc1plus}). | |
35501 | ||
35502 | @item %* | |
35503 | Substitute the variable part of a matched option. See below. | |
35504 | Note that each comma in the substituted string is replaced by | |
35505 | a single space. | |
35506 | ||
35507 | @item %<S | |
35508 | Remove all occurrences of @code{-S} from the command line. Note---this | |
35509 | command is position dependent. @samp{%} commands in the spec string | |
35510 | before this one see @code{-S}, @samp{%} commands in the spec string | |
35511 | after this one do not. | |
35512 | ||
35513 | @item %<S* | |
35514 | Similar to @samp{%<S}, but match all switches beginning with @code{-S}. | |
35515 | ||
35516 | @item %>S | |
35517 | Similar to @samp{%<S}, but keep @code{-S} in the GCC command line. | |
35518 | ||
35519 | @item %:@var{function}(@var{args}) | |
35520 | Call the named function @var{function}, passing it @var{args}. | |
35521 | @var{args} is first processed as a nested spec string, then split | |
35522 | into an argument vector in the usual fashion. The function returns | |
35523 | a string which is processed as if it had appeared literally as part | |
35524 | of the current spec. | |
35525 | ||
35526 | The following built-in spec functions are provided: | |
35527 | ||
35528 | @table @code | |
35529 | @item @code{getenv} | |
35530 | The @code{getenv} spec function takes two arguments: an environment | |
35531 | variable name and a string. If the environment variable is not | |
35532 | defined, a fatal error is issued. Otherwise, the return value is the | |
35533 | value of the environment variable concatenated with the string. For | |
35534 | example, if @env{TOPDIR} is defined as @file{/path/to/top}, then: | |
35535 | ||
35536 | @smallexample | |
35537 | %:getenv(TOPDIR /include) | |
35538 | @end smallexample | |
35539 | ||
35540 | expands to @file{/path/to/top/include}. | |
35541 | ||
35542 | @item @code{if-exists} | |
35543 | The @code{if-exists} spec function takes one argument, an absolute | |
35544 | pathname to a file. If the file exists, @code{if-exists} returns the | |
35545 | pathname. Here is a small example of its usage: | |
35546 | ||
35547 | @smallexample | |
35548 | *startfile: | |
35549 | crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s | |
35550 | @end smallexample | |
35551 | ||
35552 | @item @code{if-exists-else} | |
35553 | The @code{if-exists-else} spec function is similar to the @code{if-exists} | |
35554 | spec function, except that it takes two arguments. The first argument is | |
35555 | an absolute pathname to a file. If the file exists, @code{if-exists-else} | |
35556 | returns the pathname. If it does not exist, it returns the second argument. | |
35557 | This way, @code{if-exists-else} can be used to select one file or another, | |
35558 | based on the existence of the first. Here is a small example of its usage: | |
35559 | ||
35560 | @smallexample | |
35561 | *startfile: | |
35562 | crt0%O%s %:if-exists(crti%O%s) \ | |
35563 | %:if-exists-else(crtbeginT%O%s crtbegin%O%s) | |
35564 | @end smallexample | |
35565 | ||
35566 | @item @code{if-exists-then-else} | |
35567 | The @code{if-exists-then-else} spec function takes at least two arguments | |
35568 | and an optional third one. The first argument is an absolute pathname to a | |
35569 | file. If the file exists, the function returns the second argument. | |
35570 | If the file does not exist, the function returns the third argument if there | |
35571 | is one, or NULL otherwise. This can be used to expand one text, or optionally | |
35572 | another, based on the existence of a file. Here is a small example of its | |
35573 | usage: | |
35574 | ||
35575 | @smallexample | |
35576 | -l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net) | |
35577 | @end smallexample | |
35578 | ||
35579 | @item @code{sanitize} | |
35580 | The @code{sanitize} spec function takes no arguments. It returns non-NULL if | |
35581 | any address, thread or undefined behavior sanitizers are active. | |
35582 | ||
35583 | @smallexample | |
35584 | %@{%:sanitize(address):-funwind-tables@} | |
35585 | @end smallexample | |
35586 | ||
35587 | @item @code{replace-outfile} | |
35588 | The @code{replace-outfile} spec function takes two arguments. It looks for the | |
35589 | first argument in the outfiles array and replaces it with the second argument. Here | |
35590 | is a small example of its usage: | |
35591 | ||
35592 | @smallexample | |
35593 | %@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@} | |
35594 | @end smallexample | |
35595 | ||
35596 | @item @code{remove-outfile} | |
35597 | The @code{remove-outfile} spec function takes one argument. It looks for the | |
35598 | first argument in the outfiles array and removes it. Here is a small example | |
35599 | its usage: | |
35600 | ||
35601 | @smallexample | |
35602 | %:remove-outfile(-lm) | |
35603 | @end smallexample | |
35604 | ||
35605 | @item @code{version-compare} | |
35606 | The @code{version-compare} spec function takes four or five arguments of the following | |
35607 | form: | |
35608 | ||
35609 | @smallexample | |
35610 | <comparison-op> <arg1> [<arg2>] <switch> <result> | |
35611 | @end smallexample | |
35612 | ||
35613 | It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't. | |
35614 | The supported @code{comparison-op} values are: | |
35615 | ||
35616 | @table @code | |
35617 | @item >= | |
35618 | True if @code{switch} is a later (or same) version than @code{arg1} | |
35619 | ||
35620 | @item !> | |
35621 | Opposite of @code{>=} | |
35622 | ||
35623 | @item < | |
35624 | True if @code{switch} is an earlier version than @code{arg1} | |
35625 | ||
35626 | @item !< | |
35627 | Opposite of @code{<} | |
35628 | ||
35629 | @item >< | |
35630 | True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2} | |
35631 | ||
35632 | @item <> | |
35633 | True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later | |
35634 | @end table | |
35635 | ||
35636 | If the @code{switch} is not present at all, the condition is false unless the first character | |
35637 | of the @code{comparison-op} is @code{!}. | |
35638 | ||
35639 | @smallexample | |
35640 | %:version-compare(>= 10.3 mmacosx-version-min= -lmx) | |
35641 | @end smallexample | |
35642 | ||
35643 | The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was | |
35644 | passed. | |
35645 | ||
35646 | @item @code{include} | |
35647 | The @code{include} spec function behaves much like @code{%include}, with the advantage | |
35648 | that it can be nested inside a spec and thus be conditionalized. It takes one argument, | |
35649 | the filename, and looks for it in the startfile path. It always returns NULL. | |
35650 | ||
35651 | @smallexample | |
35652 | %@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@} | |
35653 | @end smallexample | |
35654 | ||
35655 | @item @code{pass-through-libs} | |
35656 | The @code{pass-through-libs} spec function takes any number of arguments. It | |
35657 | finds any @option{-l} options and any non-options ending in @file{.a} (which it | |
35658 | assumes are the names of linker input library archive files) and returns a | |
35659 | result containing all the found arguments each prepended by | |
35660 | @option{-plugin-opt=-pass-through=} and joined by spaces. This list is | |
35661 | intended to be passed to the LTO linker plugin. | |
35662 | ||
35663 | @smallexample | |
35664 | %:pass-through-libs(%G %L %G) | |
35665 | @end smallexample | |
35666 | ||
35667 | @item @code{print-asm-header} | |
35668 | The @code{print-asm-header} function takes no arguments and simply | |
35669 | prints a banner like: | |
35670 | ||
35671 | @smallexample | |
35672 | Assembler options | |
35673 | ================= | |
35674 | ||
35675 | Use "-Wa,OPTION" to pass "OPTION" to the assembler. | |
35676 | @end smallexample | |
35677 | ||
35678 | It is used to separate compiler options from assembler options | |
35679 | in the @option{--target-help} output. | |
35680 | ||
35681 | @item @code{gt} | |
35682 | The @code{gt} spec function takes two or more arguments. It returns @code{""} (the | |
35683 | empty string) if the second-to-last argument is greater than the last argument, and NULL | |
35684 | otherwise. The following example inserts the @code{link_gomp} spec if the last | |
35685 | @option{-ftree-parallelize-loops=} option given on the command line is greater than 1: | |
35686 | ||
35687 | @smallexample | |
35688 | %@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@} | |
35689 | @end smallexample | |
35690 | ||
35691 | @item @code{debug-level-gt} | |
35692 | The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the | |
35693 | empty string) if @code{debug_info_level} is greater than the specified number, and NULL | |
35694 | otherwise. | |
35695 | ||
35696 | @smallexample | |
35697 | %@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@} | |
35698 | @end smallexample | |
35699 | @end table | |
35700 | ||
35701 | @item %@{S@} | |
35702 | Substitutes the @code{-S} switch, if that switch is given to GCC@. | |
35703 | If that switch is not specified, this substitutes nothing. Note that | |
35704 | the leading dash is omitted when specifying this option, and it is | |
35705 | automatically inserted if the substitution is performed. Thus the spec | |
35706 | string @samp{%@{foo@}} matches the command-line option @option{-foo} | |
35707 | and outputs the command-line option @option{-foo}. | |
35708 | ||
35709 | @item %W@{S@} | |
35710 | Like %@{@code{S}@} but mark last argument supplied within as a file to be | |
35711 | deleted on failure. | |
35712 | ||
35713 | @item %@@@{S@} | |
35714 | Like %@{@code{S}@} but puts the result into a @code{FILE} and substitutes | |
35715 | @code{@@FILE} if an @code{@@file} argument has been supplied. | |
35716 | ||
35717 | @item %@{S*@} | |
35718 | Substitutes all the switches specified to GCC whose names start | |
35719 | with @code{-S}, but which also take an argument. This is used for | |
35720 | switches like @option{-o}, @option{-D}, @option{-I}, etc. | |
35721 | GCC considers @option{-o foo} as being | |
35722 | one switch whose name starts with @samp{o}. %@{o*@} substitutes this | |
35723 | text, including the space. Thus two arguments are generated. | |
35724 | ||
35725 | @item %@{S*&T*@} | |
35726 | Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options | |
35727 | (the order of @code{S} and @code{T} in the spec is not significant). | |
35728 | There can be any number of ampersand-separated variables; for each the | |
35729 | wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}. | |
35730 | ||
35731 | @item %@{S:X@} | |
35732 | Substitutes @code{X}, if the @option{-S} switch is given to GCC@. | |
35733 | ||
35734 | @item %@{!S:X@} | |
35735 | Substitutes @code{X}, if the @option{-S} switch is @emph{not} given to GCC@. | |
35736 | ||
35737 | @item %@{S*:X@} | |
35738 | Substitutes @code{X} if one or more switches whose names start with | |
35739 | @code{-S} are specified to GCC@. Normally @code{X} is substituted only | |
35740 | once, no matter how many such switches appeared. However, if @code{%*} | |
35741 | appears somewhere in @code{X}, then @code{X} is substituted once | |
35742 | for each matching switch, with the @code{%*} replaced by the part of | |
35743 | that switch matching the @code{*}. | |
35744 | ||
35745 | If @code{%*} appears as the last part of a spec sequence then a space | |
35746 | is added after the end of the last substitution. If there is more | |
35747 | text in the sequence, however, then a space is not generated. This | |
35748 | allows the @code{%*} substitution to be used as part of a larger | |
35749 | string. For example, a spec string like this: | |
35750 | ||
35751 | @smallexample | |
35752 | %@{mcu=*:--script=%*/memory.ld@} | |
35753 | @end smallexample | |
35754 | ||
35755 | @noindent | |
35756 | when matching an option like @option{-mcu=newchip} produces: | |
35757 | ||
35758 | @smallexample | |
35759 | --script=newchip/memory.ld | |
35760 | @end smallexample | |
35761 | ||
35762 | @item %@{.S:X@} | |
35763 | Substitutes @code{X}, if processing a file with suffix @code{S}. | |
35764 | ||
35765 | @item %@{!.S:X@} | |
35766 | Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}. | |
35767 | ||
35768 | @item %@{,S:X@} | |
35769 | Substitutes @code{X}, if processing a file for language @code{S}. | |
35770 | ||
35771 | @item %@{!,S:X@} | |
35772 | Substitutes @code{X}, if not processing a file for language @code{S}. | |
35773 | ||
35774 | @item %@{S|P:X@} | |
35775 | Substitutes @code{X} if either @code{-S} or @code{-P} is given to | |
35776 | GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and | |
35777 | @code{*} sequences as well, although they have a stronger binding than | |
35778 | the @samp{|}. If @code{%*} appears in @code{X}, all of the | |
35779 | alternatives must be starred, and only the first matching alternative | |
35780 | is substituted. | |
35781 | ||
35782 | For example, a spec string like this: | |
35783 | ||
35784 | @smallexample | |
35785 | %@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@} | |
35786 | @end smallexample | |
35787 | ||
35788 | @noindent | |
35789 | outputs the following command-line options from the following input | |
35790 | command-line options: | |
35791 | ||
35792 | @smallexample | |
35793 | fred.c -foo -baz | |
35794 | jim.d -bar -boggle | |
35795 | -d fred.c -foo -baz -boggle | |
35796 | -d jim.d -bar -baz -boggle | |
35797 | @end smallexample | |
35798 | ||
35799 | @item %@{%:@var{function}(@var{args}):X@} | |
35800 | ||
35801 | Call function named @var{function} with args @var{args}. If the | |
35802 | function returns non-NULL, then @code{X} is substituted, if it returns | |
35803 | NULL, it isn't substituted. | |
35804 | ||
35805 | @item %@{S:X; T:Y; :D@} | |
35806 | ||
35807 | If @code{S} is given to GCC, substitutes @code{X}; else if @code{T} is | |
35808 | given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can | |
35809 | be as many clauses as you need. This may be combined with @code{.}, | |
35810 | @code{,}, @code{!}, @code{|}, and @code{*} as needed. | |
35811 | ||
35812 | ||
35813 | @end table | |
35814 | ||
35815 | The switch matching text @code{S} in a @samp{%@{S@}}, @samp{%@{S:X@}} | |
35816 | or similar construct can use a backslash to ignore the special meaning | |
35817 | of the character following it, thus allowing literal matching of a | |
35818 | character that is otherwise specially treated. For example, | |
35819 | @samp{%@{std=iso9899\:1999:X@}} substitutes @code{X} if the | |
35820 | @option{-std=iso9899:1999} option is given. | |
35821 | ||
35822 | The conditional text @code{X} in a @samp{%@{S:X@}} or similar | |
35823 | construct may contain other nested @samp{%} constructs or spaces, or | |
35824 | even newlines. They are processed as usual, as described above. | |
35825 | Trailing white space in @code{X} is ignored. White space may also | |
35826 | appear anywhere on the left side of the colon in these constructs, | |
35827 | except between @code{.} or @code{*} and the corresponding word. | |
35828 | ||
35829 | The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are | |
35830 | handled specifically in these constructs. If another value of | |
35831 | @option{-O} or the negated form of a @option{-f}, @option{-m}, or | |
35832 | @option{-W} switch is found later in the command line, the earlier | |
35833 | switch value is ignored, except with @{@code{S}*@} where @code{S} is | |
35834 | just one letter, which passes all matching options. | |
35835 | ||
35836 | The character @samp{|} at the beginning of the predicate text is used to | |
35837 | indicate that a command should be piped to the following command, but | |
35838 | only if @option{-pipe} is specified. | |
35839 | ||
35840 | It is built into GCC which switches take arguments and which do not. | |
35841 | (You might think it would be useful to generalize this to allow each | |
35842 | compiler's spec to say which switches take arguments. But this cannot | |
35843 | be done in a consistent fashion. GCC cannot even decide which input | |
35844 | files have been specified without knowing which switches take arguments, | |
35845 | and it must know which input files to compile in order to tell which | |
35846 | compilers to run). | |
35847 | ||
35848 | GCC also knows implicitly that arguments starting in @option{-l} are to be | |
35849 | treated as compiler output files, and passed to the linker in their | |
35850 | proper position among the other output files. | |
35851 | ||
35852 | @node Environment Variables | |
35853 | @section Environment Variables Affecting GCC | |
35854 | @cindex environment variables | |
35855 | ||
35856 | @c man begin ENVIRONMENT | |
35857 | This section describes several environment variables that affect how GCC | |
35858 | operates. Some of them work by specifying directories or prefixes to use | |
35859 | when searching for various kinds of files. Some are used to specify other | |
35860 | aspects of the compilation environment. | |
35861 | ||
35862 | Note that you can also specify places to search using options such as | |
35863 | @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These | |
35864 | take precedence over places specified using environment variables, which | |
35865 | in turn take precedence over those specified by the configuration of GCC@. | |
35866 | @xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint, | |
35867 | GNU Compiler Collection (GCC) Internals}. | |
35868 | ||
35869 | @table @env | |
f33d7a88 AA |
35870 | @vindex LANG |
35871 | @vindex LC_CTYPE | |
35872 | @c @vindex LC_COLLATE | |
35873 | @vindex LC_MESSAGES | |
35874 | @c @vindex LC_MONETARY | |
35875 | @c @vindex LC_NUMERIC | |
35876 | @c @vindex LC_TIME | |
35877 | @vindex LC_ALL | |
35878 | @cindex locale | |
d77de738 ML |
35879 | @item LANG |
35880 | @itemx LC_CTYPE | |
35881 | @c @itemx LC_COLLATE | |
35882 | @itemx LC_MESSAGES | |
35883 | @c @itemx LC_MONETARY | |
35884 | @c @itemx LC_NUMERIC | |
35885 | @c @itemx LC_TIME | |
35886 | @itemx LC_ALL | |
d77de738 ML |
35887 | These environment variables control the way that GCC uses |
35888 | localization information which allows GCC to work with different | |
35889 | national conventions. GCC inspects the locale categories | |
35890 | @env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do | |
35891 | so. These locale categories can be set to any value supported by your | |
35892 | installation. A typical value is @samp{en_GB.UTF-8} for English in the United | |
35893 | Kingdom encoded in UTF-8. | |
35894 | ||
35895 | The @env{LC_CTYPE} environment variable specifies character | |
35896 | classification. GCC uses it to determine the character boundaries in | |
35897 | a string; this is needed for some multibyte encodings that contain quote | |
35898 | and escape characters that are otherwise interpreted as a string | |
35899 | end or escape. | |
35900 | ||
35901 | The @env{LC_MESSAGES} environment variable specifies the language to | |
35902 | use in diagnostic messages. | |
35903 | ||
35904 | If the @env{LC_ALL} environment variable is set, it overrides the value | |
35905 | of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE} | |
35906 | and @env{LC_MESSAGES} default to the value of the @env{LANG} | |
35907 | environment variable. If none of these variables are set, GCC | |
35908 | defaults to traditional C English behavior. | |
35909 | ||
f33d7a88 | 35910 | @vindex TMPDIR |
d77de738 | 35911 | @item TMPDIR |
d77de738 ML |
35912 | If @env{TMPDIR} is set, it specifies the directory to use for temporary |
35913 | files. GCC uses temporary files to hold the output of one stage of | |
35914 | compilation which is to be used as input to the next stage: for example, | |
35915 | the output of the preprocessor, which is the input to the compiler | |
35916 | proper. | |
35917 | ||
f33d7a88 | 35918 | @vindex GCC_COMPARE_DEBUG |
d77de738 | 35919 | @item GCC_COMPARE_DEBUG |
d77de738 ML |
35920 | Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing |
35921 | @option{-fcompare-debug} to the compiler driver. See the documentation | |
35922 | of this option for more details. | |
35923 | ||
f33d7a88 | 35924 | @vindex GCC_EXEC_PREFIX |
d77de738 | 35925 | @item GCC_EXEC_PREFIX |
d77de738 ML |
35926 | If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the |
35927 | names of the subprograms executed by the compiler. No slash is added | |
35928 | when this prefix is combined with the name of a subprogram, but you can | |
35929 | specify a prefix that ends with a slash if you wish. | |
35930 | ||
35931 | If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out | |
35932 | an appropriate prefix to use based on the pathname it is invoked with. | |
35933 | ||
35934 | If GCC cannot find the subprogram using the specified prefix, it | |
35935 | tries looking in the usual places for the subprogram. | |
35936 | ||
35937 | The default value of @env{GCC_EXEC_PREFIX} is | |
35938 | @file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to | |
35939 | the installed compiler. In many cases @var{prefix} is the value | |
35940 | of @code{prefix} when you ran the @file{configure} script. | |
35941 | ||
35942 | Other prefixes specified with @option{-B} take precedence over this prefix. | |
35943 | ||
35944 | This prefix is also used for finding files such as @file{crt0.o} that are | |
35945 | used for linking. | |
35946 | ||
35947 | In addition, the prefix is used in an unusual way in finding the | |
35948 | directories to search for header files. For each of the standard | |
35949 | directories whose name normally begins with @samp{/usr/local/lib/gcc} | |
35950 | (more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries | |
35951 | replacing that beginning with the specified prefix to produce an | |
35952 | alternate directory name. Thus, with @option{-Bfoo/}, GCC searches | |
35953 | @file{foo/bar} just before it searches the standard directory | |
35954 | @file{/usr/local/lib/bar}. | |
35955 | If a standard directory begins with the configured | |
35956 | @var{prefix} then the value of @var{prefix} is replaced by | |
35957 | @env{GCC_EXEC_PREFIX} when looking for header files. | |
35958 | ||
f33d7a88 | 35959 | @vindex COMPILER_PATH |
d77de738 | 35960 | @item COMPILER_PATH |
d77de738 ML |
35961 | The value of @env{COMPILER_PATH} is a colon-separated list of |
35962 | directories, much like @env{PATH}. GCC tries the directories thus | |
35963 | specified when searching for subprograms, if it cannot find the | |
35964 | subprograms using @env{GCC_EXEC_PREFIX}. | |
35965 | ||
f33d7a88 | 35966 | @vindex LIBRARY_PATH |
d77de738 | 35967 | @item LIBRARY_PATH |
d77de738 ML |
35968 | The value of @env{LIBRARY_PATH} is a colon-separated list of |
35969 | directories, much like @env{PATH}. When configured as a native compiler, | |
35970 | GCC tries the directories thus specified when searching for special | |
35971 | linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking | |
35972 | using GCC also uses these directories when searching for ordinary | |
35973 | libraries for the @option{-l} option (but directories specified with | |
35974 | @option{-L} come first). | |
35975 | ||
f33d7a88 | 35976 | @vindex LANG |
d77de738 | 35977 | @cindex locale definition |
f33d7a88 | 35978 | @item LANG |
d77de738 ML |
35979 | This variable is used to pass locale information to the compiler. One way in |
35980 | which this information is used is to determine the character set to be used | |
35981 | when character literals, string literals and comments are parsed in C and C++. | |
35982 | When the compiler is configured to allow multibyte characters, | |
35983 | the following values for @env{LANG} are recognized: | |
35984 | ||
35985 | @table @samp | |
35986 | @item C-JIS | |
35987 | Recognize JIS characters. | |
35988 | @item C-SJIS | |
35989 | Recognize SJIS characters. | |
35990 | @item C-EUCJP | |
35991 | Recognize EUCJP characters. | |
35992 | @end table | |
35993 | ||
35994 | If @env{LANG} is not defined, or if it has some other value, then the | |
35995 | compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to | |
35996 | recognize and translate multibyte characters. | |
35997 | ||
f33d7a88 | 35998 | @vindex GCC_EXTRA_DIAGNOSTIC_OUTPUT |
d77de738 | 35999 | @item GCC_EXTRA_DIAGNOSTIC_OUTPUT |
d77de738 ML |
36000 | If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values, |
36001 | then additional text will be emitted to stderr when fix-it hints are | |
36002 | emitted. @option{-fdiagnostics-parseable-fixits} and | |
36003 | @option{-fno-diagnostics-parseable-fixits} take precedence over this | |
36004 | environment variable. | |
36005 | ||
36006 | @table @samp | |
36007 | @item fixits-v1 | |
36008 | Emit parseable fix-it hints, equivalent to | |
36009 | @option{-fdiagnostics-parseable-fixits}. In particular, columns are | |
36010 | expressed as a count of bytes, starting at byte 1 for the initial column. | |
36011 | ||
36012 | @item fixits-v2 | |
36013 | As @code{fixits-v1}, but columns are expressed as display columns, | |
36014 | as per @option{-fdiagnostics-column-unit=display}. | |
36015 | @end table | |
36016 | ||
36017 | @end table | |
36018 | ||
36019 | @noindent | |
36020 | Some additional environment variables affect the behavior of the | |
36021 | preprocessor. | |
36022 | ||
36023 | @include cppenv.texi | |
36024 | ||
36025 | @c man end | |
36026 | ||
36027 | @node Precompiled Headers | |
36028 | @section Using Precompiled Headers | |
36029 | @cindex precompiled headers | |
36030 | @cindex speed of compilation | |
36031 | ||
36032 | Often large projects have many header files that are included in every | |
36033 | source file. The time the compiler takes to process these header files | |
36034 | over and over again can account for nearly all of the time required to | |
36035 | build the project. To make builds faster, GCC allows you to | |
36036 | @dfn{precompile} a header file. | |
36037 | ||
36038 | To create a precompiled header file, simply compile it as you would any | |
36039 | other file, if necessary using the @option{-x} option to make the driver | |
36040 | treat it as a C or C++ header file. You may want to use a | |
36041 | tool like @command{make} to keep the precompiled header up-to-date when | |
36042 | the headers it contains change. | |
36043 | ||
36044 | A precompiled header file is searched for when @code{#include} is | |
36045 | seen in the compilation. As it searches for the included file | |
36046 | (@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the | |
36047 | compiler looks for a precompiled header in each directory just before it | |
36048 | looks for the include file in that directory. The name searched for is | |
36049 | the name specified in the @code{#include} with @samp{.gch} appended. If | |
36050 | the precompiled header file cannot be used, it is ignored. | |
36051 | ||
36052 | For instance, if you have @code{#include "all.h"}, and you have | |
36053 | @file{all.h.gch} in the same directory as @file{all.h}, then the | |
36054 | precompiled header file is used if possible, and the original | |
36055 | header is used otherwise. | |
36056 | ||
36057 | Alternatively, you might decide to put the precompiled header file in a | |
36058 | directory and use @option{-I} to ensure that directory is searched | |
36059 | before (or instead of) the directory containing the original header. | |
36060 | Then, if you want to check that the precompiled header file is always | |
36061 | used, you can put a file of the same name as the original header in this | |
36062 | directory containing an @code{#error} command. | |
36063 | ||
36064 | This also works with @option{-include}. So yet another way to use | |
36065 | precompiled headers, good for projects not designed with precompiled | |
36066 | header files in mind, is to simply take most of the header files used by | |
36067 | a project, include them from another header file, precompile that header | |
36068 | file, and @option{-include} the precompiled header. If the header files | |
36069 | have guards against multiple inclusion, they are skipped because | |
36070 | they've already been included (in the precompiled header). | |
36071 | ||
36072 | If you need to precompile the same header file for different | |
36073 | languages, targets, or compiler options, you can instead make a | |
36074 | @emph{directory} named like @file{all.h.gch}, and put each precompiled | |
36075 | header in the directory, perhaps using @option{-o}. It doesn't matter | |
36076 | what you call the files in the directory; every precompiled header in | |
36077 | the directory is considered. The first precompiled header | |
36078 | encountered in the directory that is valid for this compilation is | |
36079 | used; they're searched in no particular order. | |
36080 | ||
36081 | There are many other possibilities, limited only by your imagination, | |
36082 | good sense, and the constraints of your build system. | |
36083 | ||
36084 | A precompiled header file can be used only when these conditions apply: | |
36085 | ||
36086 | @itemize | |
36087 | @item | |
36088 | Only one precompiled header can be used in a particular compilation. | |
36089 | ||
36090 | @item | |
36091 | A precompiled header cannot be used once the first C token is seen. You | |
36092 | can have preprocessor directives before a precompiled header; you cannot | |
36093 | include a precompiled header from inside another header. | |
36094 | ||
36095 | @item | |
36096 | The precompiled header file must be produced for the same language as | |
36097 | the current compilation. You cannot use a C precompiled header for a C++ | |
36098 | compilation. | |
36099 | ||
36100 | @item | |
36101 | The precompiled header file must have been produced by the same compiler | |
36102 | binary as the current compilation is using. | |
36103 | ||
36104 | @item | |
36105 | Any macros defined before the precompiled header is included must | |
36106 | either be defined in the same way as when the precompiled header was | |
36107 | generated, or must not affect the precompiled header, which usually | |
36108 | means that they don't appear in the precompiled header at all. | |
36109 | ||
36110 | The @option{-D} option is one way to define a macro before a | |
36111 | precompiled header is included; using a @code{#define} can also do it. | |
36112 | There are also some options that define macros implicitly, like | |
36113 | @option{-O} and @option{-Wdeprecated}; the same rule applies to macros | |
36114 | defined this way. | |
36115 | ||
36116 | @item If debugging information is output when using the precompiled | |
36117 | header, using @option{-g} or similar, the same kind of debugging information | |
36118 | must have been output when building the precompiled header. However, | |
36119 | a precompiled header built using @option{-g} can be used in a compilation | |
36120 | when no debugging information is being output. | |
36121 | ||
36122 | @item The same @option{-m} options must generally be used when building | |
36123 | and using the precompiled header. @xref{Submodel Options}, | |
36124 | for any cases where this rule is relaxed. | |
36125 | ||
36126 | @item Each of the following options must be the same when building and using | |
36127 | the precompiled header: | |
36128 | ||
36129 | @gccoptlist{-fexceptions} | |
36130 | ||
36131 | @item | |
36132 | Some other command-line options starting with @option{-f}, | |
36133 | @option{-p}, or @option{-O} must be defined in the same way as when | |
36134 | the precompiled header was generated. At present, it's not clear | |
36135 | which options are safe to change and which are not; the safest choice | |
36136 | is to use exactly the same options when generating and using the | |
36137 | precompiled header. The following are known to be safe: | |
36138 | ||
43b72ede AA |
36139 | @gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock |
36140 | -fsched-spec -fsched-spec-load -fsched-spec-load-dangerous | |
36141 | -fsched-verbose=@var{number} -fschedule-insns -fvisibility= | |
d77de738 ML |
36142 | -pedantic-errors} |
36143 | ||
36144 | @item Address space layout randomization (ASLR) can lead to not binary identical | |
36145 | PCH files. If you rely on stable PCH file contents disable ASLR when generating | |
36146 | PCH files. | |
36147 | ||
36148 | @end itemize | |
36149 | ||
36150 | For all of these except the last, the compiler automatically | |
36151 | ignores the precompiled header if the conditions aren't met. If you | |
36152 | find an option combination that doesn't work and doesn't cause the | |
36153 | precompiled header to be ignored, please consider filing a bug report, | |
36154 | see @ref{Bugs}. | |
36155 | ||
36156 | If you do use differing options when generating and using the | |
36157 | precompiled header, the actual behavior is a mixture of the | |
36158 | behavior for the options. For instance, if you use @option{-g} to | |
36159 | generate the precompiled header but not when using it, you may or may | |
36160 | not get debugging information for routines in the precompiled header. | |
36161 | ||
36162 | @node C++ Modules | |
36163 | @section C++ Modules | |
36164 | @cindex speed of compilation | |
36165 | ||
36166 | Modules are a C++20 language feature. As the name suggests, they | |
36167 | provides a modular compilation system, intending to provide both | |
36168 | faster builds and better library isolation. The ``Merging Modules'' | |
36169 | paper @uref{https://wg21.link/p1103}, provides the easiest to read set | |
36170 | of changes to the standard, although it does not capture later | |
36171 | changes. | |
36172 | ||
36173 | @emph{G++'s modules support is not complete.} Other than bugs, the | |
36174 | known missing pieces are: | |
36175 | ||
36176 | @table @emph | |
36177 | ||
36178 | @item Private Module Fragment | |
36179 | The Private Module Fragment is recognized, but an error is emitted. | |
36180 | ||
36181 | @item Partition definition visibility rules | |
36182 | Entities may be defined in implementation partitions, and those | |
36183 | definitions are not available outside of the module. This is not | |
36184 | implemented, and the definitions are available to extra-module use. | |
36185 | ||
36186 | @item Textual merging of reachable GM entities | |
36187 | Entities may be multiply defined across different header-units. | |
36188 | These must be de-duplicated, and this is implemented across imports, | |
36189 | or when an import redefines a textually-defined entity. However the | |
36190 | reverse is not implemented---textually redefining an entity that has | |
36191 | been defined in an imported header-unit. A redefinition error is | |
36192 | emitted. | |
36193 | ||
36194 | @item Translation-Unit local referencing rules | |
36195 | Papers p1815 (@uref{https://wg21.link/p1815}) and p2003 | |
36196 | (@uref{https://wg21.link/p2003}) add limitations on which entities an | |
36197 | exported region may reference (for instance, the entities an exported | |
36198 | template definition may reference). These are not fully implemented. | |
36199 | ||
36200 | @item Standard Library Header Units | |
36201 | The Standard Library is not provided as importable header units. If | |
36202 | you want to import such units, you must explicitly build them first. | |
36203 | If you do not do this with care, you may have multiple declarations, | |
36204 | which the module machinery must merge---compiler resource usage can be | |
36205 | affected by how you partition header files into header units. | |
36206 | ||
36207 | @end table | |
36208 | ||
36209 | Modular compilation is @emph{not} enabled with just the | |
36210 | @option{-std=c++20} option. You must explicitly enable it with the | |
36211 | @option{-fmodules-ts} option. It is independent of the language | |
36212 | version selected, although in pre-C++20 versions, it is of course an | |
36213 | extension. | |
36214 | ||
36215 | No new source file suffixes are required or supported. If you wish to | |
36216 | use a non-standard suffix (@pxref{Overall Options}), you also need | |
36217 | to provide a @option{-x c++} option too.@footnote{Some users like to | |
36218 | distinguish module interface files with a new suffix, such as naming | |
36219 | the source @code{module.cppm}, which involves | |
36220 | teaching all tools about the new suffix. A different scheme, such as | |
36221 | naming @code{module-m.cpp} would be less invasive.} | |
36222 | ||
36223 | Compiling a module interface unit produces an additional output (to | |
36224 | the assembly or object file), called a Compiled Module Interface | |
36225 | (CMI). This encodes the exported declarations of the module. | |
36226 | Importing a module reads in the CMI. The import graph is a Directed | |
36227 | Acyclic Graph (DAG). You must build imports before the importer. | |
36228 | ||
36229 | Header files may themselves be compiled to header units, which are a | |
36230 | transitional ability aiming at faster compilation. The | |
36231 | @option{-fmodule-header} option is used to enable this, and implies | |
36232 | the @option{-fmodules-ts} option. These CMIs are named by the fully | |
36233 | resolved underlying header file, and thus may be a complete pathname | |
36234 | containing subdirectories. If the header file is found at an absolute | |
36235 | pathname, the CMI location is still relative to a CMI root directory. | |
36236 | ||
36237 | As header files often have no suffix, you commonly have to specify a | |
36238 | @option{-x} option to tell the compiler the source is a header file. | |
36239 | You may use @option{-x c++-header}, @option{-x c++-user-header} or | |
36240 | @option{-x c++-system-header}. When used in conjunction with | |
36241 | @option{-fmodules-ts}, these all imply an appropriate | |
36242 | @option{-fmodule-header} option. The latter two variants use the | |
36243 | user or system include path to search for the file specified. This | |
36244 | allows you to, for instance, compile standard library header files as | |
36245 | header units, without needing to know exactly where they are | |
36246 | installed. Specifying the language as one of these variants also | |
36247 | inhibits output of the object file, as header files have no associated | |
36248 | object file. | |
36249 | ||
36250 | The @option{-fmodule-only} option disables generation of the | |
36251 | associated object file for compiling a module interface. Only the CMI | |
36252 | is generated. This option is implied when using the | |
36253 | @option{-fmodule-header} option. | |
36254 | ||
36255 | The @option{-flang-info-include-translate} and | |
36256 | @option{-flang-info-include-translate-not} options notes whether | |
36257 | include translation occurs or not. With no argument, the first will | |
36258 | note all include translation. The second will note all | |
36259 | non-translations of include files not known to intentionally be | |
36260 | textual. With an argument, queries about include translation of a | |
36261 | header files with that particular trailing pathname are noted. You | |
36262 | may repeat this form to cover several different header files. This | |
36263 | option may be helpful in determining whether include translation is | |
36264 | happening---if it is working correctly, it behaves as if it isn't | |
36265 | there at all. | |
36266 | ||
36267 | The @option{-flang-info-module-cmi} option can be used to determine | |
36268 | where the compiler is reading a CMI from. Without the option, the | |
36269 | compiler is silent when such a read is successful. This option has an | |
36270 | optional argument, which will restrict the notification to just the | |
36271 | set of named modules or header units specified. | |
36272 | ||
36273 | The @option{-Winvalid-imported-macros} option causes all imported macros | |
36274 | to be resolved at the end of compilation. Without this, imported | |
36275 | macros are only resolved when expanded or (re)defined. This option | |
36276 | detects conflicting import definitions for all macros. | |
36277 | ||
36278 | For details of the @option{-fmodule-mapper} family of options, | |
36279 | @pxref{C++ Module Mapper}. | |
36280 | ||
36281 | @menu | |
36282 | * C++ Module Mapper:: Module Mapper | |
36283 | * C++ Module Preprocessing:: Module Preprocessing | |
36284 | * C++ Compiled Module Interface:: Compiled Module Interface | |
36285 | @end menu | |
36286 | ||
36287 | @node C++ Module Mapper | |
36288 | @subsection Module Mapper | |
36289 | @cindex C++ Module Mapper | |
36290 | ||
36291 | A module mapper provides a server or file that the compiler queries to | |
36292 | determine the mapping between module names and CMI files. It is also | |
36293 | used to build CMIs on demand. @emph{Mapper functionality is in its | |
36294 | infancy and is intended for experimentation with build system | |
36295 | interactions.} | |
36296 | ||
36297 | You can specify a mapper with the @option{-fmodule-mapper=@var{val}} | |
36298 | option or @env{CXX_MODULE_MAPPER} environment variable. The value may | |
36299 | have one of the following forms: | |
36300 | ||
36301 | @table @gcctabopt | |
36302 | ||
36303 | @item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]} | |
36304 | An optional hostname and a numeric port number to connect to. If the | |
36305 | hostname is omitted, the loopback address is used. If the hostname | |
36306 | corresponds to multiple IPV6 addresses, these are tried in turn, until | |
36307 | one is successful. If your host lacks IPv6, this form is | |
36308 | non-functional. If you must use IPv4 use | |
36309 | @option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}. | |
36310 | ||
36311 | @item =@var{socket}@r{[}?@var{ident}@r{]} | |
36312 | A local domain socket. If your host lacks local domain sockets, this | |
36313 | form is non-functional. | |
36314 | ||
36315 | @item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]} | |
36316 | A program to spawn, and communicate with on its stdin/stdout streams. | |
36317 | Your @var{PATH} environment variable is searched for the program. | |
36318 | Arguments are separated by space characters, (it is not possible for | |
36319 | one of the arguments delivered to the program to contain a space). An | |
36320 | exception is if @var{program} begins with @@. In that case | |
36321 | @var{program} (sans @@) is looked for in the compiler's internal | |
36322 | binary directory. Thus the sample mapper-server can be specified | |
36323 | with @code{@@g++-mapper-server}. | |
36324 | ||
36325 | @item <>@r{[}?@var{ident}@r{]} | |
36326 | @item <>@var{inout}@r{[}?@var{ident}@r{]} | |
36327 | @item <@var{in}>@var{out}@r{[}?@var{ident}@r{]} | |
36328 | Named pipes or file descriptors to communicate over. The first form, | |
36329 | @option{<>}, communicates over stdin and stdout. The other forms | |
36330 | allow you to specify a file descriptor or name a pipe. A numeric value | |
36331 | is interpreted as a file descriptor, otherwise named pipe is opened. | |
36332 | The second form specifies a bidirectional pipe and the last form | |
36333 | allows specifying two independent pipes. Using file descriptors | |
36334 | directly in this manner is fragile in general, as it can require the | |
36335 | cooperation of intermediate processes. In particular using stdin & | |
36336 | stdout is fraught with danger as other compiler options might also | |
36337 | cause the compiler to read stdin or write stdout, and it can have | |
36338 | unfortunate interactions with signal delivery from the terminal. | |
36339 | ||
36340 | @item @var{file}@r{[}?@var{ident}@r{]} | |
36341 | A mapping file consisting of space-separated module-name, filename | |
36342 | pairs, one per line. Only the mappings for the direct imports and any | |
36343 | module export name need be provided. If other mappings are provided, | |
36344 | they override those stored in any imported CMI files. A repository | |
36345 | root may be specified in the mapping file by using @samp{$root} as the | |
36346 | module name in the first active line. Use of this option will disable | |
36347 | any default module->CMI name mapping. | |
36348 | ||
36349 | @end table | |
36350 | ||
36351 | As shown, an optional @var{ident} may suffix the first word of the | |
36352 | option, indicated by a @samp{?} prefix. The value is used in the | |
36353 | initial handshake with the module server, or to specify a prefix on | |
36354 | mapping file lines. In the server case, the main source file name is | |
36355 | used if no @var{ident} is specified. In the file case, all non-blank | |
36356 | lines are significant, unless a value is specified, in which case only | |
36357 | lines beginning with @var{ident} are significant. The @var{ident} | |
36358 | must be separated by whitespace from the module name. Be aware that | |
36359 | @samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often | |
36360 | significant to the shell, and therefore may need quoting. | |
36361 | ||
36362 | The mapper is connected to or loaded lazily, when the first module | |
36363 | mapping is required. The networking protocols are only supported on | |
36364 | hosts that provide networking. If no mapper is specified a default is | |
36365 | provided. | |
36366 | ||
36367 | A project-specific mapper is expected to be provided by the build | |
36368 | system that invokes the compiler. It is not expected that a | |
36369 | general-purpose server is provided for all compilations. As such, the | |
36370 | server will know the build configuration, the compiler it invoked, and | |
36371 | the environment (such as working directory) in which that is | |
36372 | operating. As it may parallelize builds, several compilations may | |
36373 | connect to the same socket. | |
36374 | ||
36375 | The default mapper generates CMI files in a @samp{gcm.cache} | |
36376 | directory. CMI files have a @samp{.gcm} suffix. The module unit name | |
36377 | is used directly to provide the basename. Header units construct a | |
36378 | relative path using the underlying header file name. If the path is | |
36379 | already relative, a @samp{,} directory is prepended. Internal | |
36380 | @samp{..} components are translated to @samp{,,}. No attempt is made | |
36381 | to canonicalize these filenames beyond that done by the preprocessor's | |
36382 | include search algorithm, as in general it is ambiguous when symbolic | |
36383 | links are present. | |
36384 | ||
36385 | The mapper protocol was published as ``A Module Mapper'' | |
36386 | @uref{https://wg21.link/p1184}. The implementation is provided by | |
36387 | @command{libcody}, @uref{https://github.com/urnathan/libcody}, | |
36388 | which specifies the canonical protocol definition. A proof of concept | |
36389 | server implementation embedded in @command{make} was described in | |
36390 | ''Make Me A Module'', @uref{https://wg21.link/p1602}. | |
36391 | ||
36392 | @node C++ Module Preprocessing | |
36393 | @subsection Module Preprocessing | |
36394 | @cindex C++ Module Preprocessing | |
36395 | ||
36396 | Modules affect preprocessing because of header units and include | |
36397 | translation. Some uses of the preprocessor as a separate step either | |
36398 | do not produce a correct output, or require CMIs to be available. | |
36399 | ||
36400 | Header units import macros. These macros can affect later conditional | |
36401 | inclusion, which therefore can cascade to differing import sets. When | |
36402 | preprocessing, it is necessary to load the CMI. If a header unit is | |
36403 | unavailable, the preprocessor issues a warning and continue (when | |
36404 | not just preprocessing, an error is emitted). Detecting such imports | |
36405 | requires preprocessor tokenization of the input stream to phase 4 | |
36406 | (macro expansion). | |
36407 | ||
36408 | Include translation converts @code{#include}, @code{#include_next} and | |
36409 | @code{#import} directives to internal @code{import} declarations. | |
36410 | Whether a particular directive is translated is controlled by the | |
36411 | module mapper. Header unit names are canonicalized during | |
36412 | preprocessing. | |
36413 | ||
36414 | Dependency information can be emitted for macro import, extending the | |
36415 | functionality of @option{-MD} and @option{-MMD} options. Detection of | |
36416 | import declarations also requires phase 4 preprocessing, and thus | |
36417 | requires full preprocessing (or compilation). | |
36418 | ||
36419 | The @option{-M}, @option{-MM} and @option{-E -fdirectives-only} options halt | |
36420 | preprocessing before phase 4. | |
36421 | ||
36422 | The @option{-save-temps} option uses @option{-fdirectives-only} for | |
36423 | preprocessing, and preserve the macro definitions in the preprocessed | |
36424 | output. Usually you also want to use this option when explicitly | |
36425 | preprocessing a header-unit, or consuming such preprocessed output: | |
36426 | ||
36427 | @smallexample | |
36428 | g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii | |
36429 | g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii | |
36430 | @end smallexample | |
36431 | ||
36432 | @node C++ Compiled Module Interface | |
36433 | @subsection Compiled Module Interface | |
36434 | @cindex C++ Compiled Module Interface | |
36435 | ||
36436 | CMIs are an additional artifact when compiling named module | |
36437 | interfaces, partitions or header units. These are read when | |
36438 | importing. CMI contents are implementation-specific, and in GCC's | |
36439 | case tied to the compiler version. Consider them a rebuildable cache | |
36440 | artifact, not a distributable object. | |
36441 | ||
36442 | When creating an output CMI, any missing directory components are | |
36443 | created in a manner that is safe for concurrent builds creating | |
36444 | multiple, different, CMIs within a common subdirectory tree. | |
36445 | ||
36446 | CMI contents are written to a temporary file, which is then atomically | |
36447 | renamed. Observers either see old contents (if there is an | |
36448 | existing file), or complete new contents. They do not observe the | |
36449 | CMI during its creation. This is unlike object file writing, which | |
36450 | may be observed by an external process. | |
36451 | ||
36452 | CMIs are read in lazily, if the host OS provides @code{mmap} | |
36453 | functionality. Generally blocks are read when name lookup or template | |
36454 | instantiation occurs. To inhibit this, the @option{-fno-module-lazy} | |
36455 | option may be used. | |
36456 | ||
36457 | The @option{--param lazy-modules=@var{n}} parameter controls the limit | |
36458 | on the number of concurrently open module files during lazy loading. | |
36459 | Should more modules be imported, an LRU algorithm is used to determine | |
36460 | which files to close---until that file is needed again. This limit | |
36461 | may be exceeded with deep module dependency hierarchies. With large | |
36462 | code bases there may be more imports than the process limit of file | |
36463 | descriptors. By default, the limit is a few less than the per-process | |
36464 | file descriptor hard limit, if that is determinable.@footnote{Where | |
36465 | applicable the soft limit is incremented as needed towards the hard limit.} | |
36466 | ||
36467 | GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism. | |
36468 | You may use @command{readelf} to inspect them, although section | |
36469 | contents are largely undecipherable. There is a section named | |
36470 | @code{.gnu.c++.README}, which contains human-readable text. Other | |
36471 | than the first line, each line consists of @code{@var{tag}: @code{value}} | |
36472 | tuples. | |
36473 | ||
36474 | @smallexample | |
36475 | > @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm} | |
36476 | ||
36477 | String dump of section '.gnu.c++.README': | |
36478 | [ 0] GNU C++ primary module interface | |
36479 | [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454] | |
36480 | [ 6f] version: 2020/11/16-04:54 | |
36481 | [ 89] module: foo | |
36482 | [ 95] source: c_b.ii | |
36483 | [ a4] dialect: C++20/coroutines | |
36484 | [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc | |
36485 | [ ee] repository: gcm.cache | |
36486 | [ 104] buildtime: 2020/11/16 15:03:21 UTC | |
36487 | [ 127] localtime: 2020/11/16 07:03:21 PST | |
36488 | [ 14a] export: foo:part1 foo-part1.gcm | |
36489 | @end smallexample | |
36490 | ||
36491 | Amongst other things, this lists the source that was built, C++ | |
36492 | dialect used and imports of the module.@footnote{The precise contents | |
36493 | of this output may change.} The timestamp is the same value as that | |
36494 | provided by the @code{__DATE__} & @code{__TIME__} macros, and may be | |
36495 | explicitly specified with the environment variable | |
36496 | @code{SOURCE_DATE_EPOCH}. For further details | |
36497 | @pxref{Environment Variables}. | |
36498 | ||
36499 | A set of related CMIs may be copied, provided the relative pathnames | |
36500 | are preserved. | |
36501 | ||
36502 | The @code{.gnu.c++.README} contents do not affect CMI integrity, and | |
36503 | it may be removed or altered. The section numbering of the sections | |
36504 | whose names do not begin with @code{.gnu.c++.}, or are not the string | |
36505 | section is significant and must not be altered. |