]>
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 | |
234 | -fno-optional-diags -fpermissive | |
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 | |
257 | -Weffc++ -Wno-exceptions -Wextra-semi -Wno-inaccessible-base | |
258 | -Wno-inherited-variadic-ctor -Wno-init-list-lifetime | |
259 | -Winvalid-constexpr -Winvalid-imported-macros | |
260 | -Wno-invalid-offsetof -Wno-literal-suffix | |
261 | -Wmismatched-new-delete -Wmismatched-tags | |
262 | -Wmultiple-inheritance -Wnamespaces -Wnarrowing | |
263 | -Wnoexcept -Wnoexcept-type -Wnon-virtual-dtor | |
264 | -Wpessimizing-move -Wno-placement-new -Wplacement-new=@var{n} | |
265 | -Wrange-loop-construct -Wredundant-move -Wredundant-tags | |
266 | -Wreorder -Wregister | |
267 | -Wstrict-null-sentinel -Wno-subobject-linkage -Wtemplates | |
268 | -Wno-non-template-friend -Wold-style-cast | |
269 | -Woverloaded-virtual -Wno-pmf-conversions -Wself-move -Wsign-promo | |
270 | -Wsized-deallocation -Wsuggest-final-methods | |
271 | -Wsuggest-final-types -Wsuggest-override | |
272 | -Wno-terminate -Wuseless-cast -Wno-vexing-parse | |
273 | -Wvirtual-inheritance | |
d77de738 ML |
274 | -Wno-virtual-move-assign -Wvolatile -Wzero-as-null-pointer-constant} |
275 | ||
276 | @item Objective-C and Objective-C++ Language Options | |
277 | @xref{Objective-C and Objective-C++ Dialect Options,,Options Controlling | |
278 | Objective-C and Objective-C++ Dialects}. | |
43b72ede AA |
279 | @gccoptlist{-fconstant-string-class=@var{class-name} |
280 | -fgnu-runtime -fnext-runtime | |
281 | -fno-nil-receivers | |
282 | -fobjc-abi-version=@var{n} | |
283 | -fobjc-call-cxx-cdtors | |
284 | -fobjc-direct-dispatch | |
285 | -fobjc-exceptions | |
286 | -fobjc-gc | |
287 | -fobjc-nilcheck | |
288 | -fobjc-std=objc1 | |
289 | -fno-local-ivars | |
290 | -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]} | |
291 | -freplace-objc-classes | |
292 | -fzero-link | |
293 | -gen-decls | |
294 | -Wassign-intercept -Wno-property-assign-default | |
295 | -Wno-protocol -Wobjc-root-class -Wselector | |
296 | -Wstrict-selector-match | |
d77de738 ML |
297 | -Wundeclared-selector} |
298 | ||
299 | @item Diagnostic Message Formatting Options | |
300 | @xref{Diagnostic Message Formatting Options,,Options to Control Diagnostic Messages Formatting}. | |
43b72ede AA |
301 | @gccoptlist{-fmessage-length=@var{n} |
302 | -fdiagnostics-plain-output | |
303 | -fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]} | |
304 | -fdiagnostics-color=@r{[}auto@r{|}never@r{|}always@r{]} | |
305 | -fdiagnostics-urls=@r{[}auto@r{|}never@r{|}always@r{]} | |
306 | -fdiagnostics-format=@r{[}text@r{|}sarif-stderr@r{|}sarif-file@r{|}json@r{|}json-stderr@r{|}json-file@r{]} | |
307 | -fno-diagnostics-show-option -fno-diagnostics-show-caret | |
308 | -fno-diagnostics-show-labels -fno-diagnostics-show-line-numbers | |
309 | -fno-diagnostics-show-cwe | |
310 | -fno-diagnostics-show-rule | |
311 | -fdiagnostics-minimum-margin-width=@var{width} | |
312 | -fdiagnostics-parseable-fixits -fdiagnostics-generate-patch | |
313 | -fdiagnostics-show-template-tree -fno-elide-type | |
314 | -fdiagnostics-path-format=@r{[}none@r{|}separate-events@r{|}inline-events@r{]} | |
315 | -fdiagnostics-show-path-depths | |
316 | -fno-show-column | |
317 | -fdiagnostics-column-unit=@r{[}display@r{|}byte@r{]} | |
318 | -fdiagnostics-column-origin=@var{origin} | |
d77de738 ML |
319 | -fdiagnostics-escape-format=@r{[}unicode@r{|}bytes@r{]}} |
320 | ||
321 | @item Warning Options | |
322 | @xref{Warning Options,,Options to Request or Suppress Warnings}. | |
43b72ede AA |
323 | @gccoptlist{-fsyntax-only -fmax-errors=@var{n} -Wpedantic |
324 | -pedantic-errors | |
325 | -w -Wextra -Wall -Wabi=@var{n} | |
326 | -Waddress -Wno-address-of-packed-member -Waggregate-return | |
327 | -Walloc-size-larger-than=@var{byte-size} -Walloc-zero | |
328 | -Walloca -Walloca-larger-than=@var{byte-size} | |
329 | -Wno-aggressive-loop-optimizations | |
330 | -Warith-conversion | |
331 | -Warray-bounds -Warray-bounds=@var{n} -Warray-compare | |
332 | -Wno-attributes -Wattribute-alias=@var{n} -Wno-attribute-alias | |
333 | -Wno-attribute-warning | |
334 | -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]} | |
335 | -Wbool-compare -Wbool-operation | |
336 | -Wno-builtin-declaration-mismatch | |
337 | -Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat | |
338 | -Wc11-c2x-compat | |
339 | -Wc++-compat -Wc++11-compat -Wc++14-compat -Wc++17-compat | |
340 | -Wc++20-compat | |
341 | -Wno-c++11-extensions -Wno-c++14-extensions -Wno-c++17-extensions | |
342 | -Wno-c++20-extensions -Wno-c++23-extensions | |
343 | -Wcast-align -Wcast-align=strict -Wcast-function-type -Wcast-qual | |
344 | -Wchar-subscripts | |
345 | -Wclobbered -Wcomment | |
346 | -Wno-complain-wrong-lang | |
347 | -Wconversion -Wno-coverage-mismatch -Wno-cpp | |
348 | -Wdangling-else -Wdangling-pointer -Wdangling-pointer=@var{n} | |
349 | -Wdate-time | |
350 | -Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init | |
351 | -Wdisabled-optimization | |
352 | -Wno-discarded-array-qualifiers -Wno-discarded-qualifiers | |
353 | -Wno-div-by-zero -Wdouble-promotion | |
354 | -Wduplicated-branches -Wduplicated-cond | |
355 | -Wempty-body -Wno-endif-labels -Wenum-compare -Wenum-conversion | |
356 | -Wenum-int-mismatch | |
357 | -Werror -Werror=* -Wexpansion-to-defined -Wfatal-errors | |
358 | -Wfloat-conversion -Wfloat-equal -Wformat -Wformat=2 | |
359 | -Wno-format-contains-nul -Wno-format-extra-args | |
360 | -Wformat-nonliteral -Wformat-overflow=@var{n} | |
361 | -Wformat-security -Wformat-signedness -Wformat-truncation=@var{n} | |
362 | -Wformat-y2k -Wframe-address | |
363 | -Wframe-larger-than=@var{byte-size} -Wno-free-nonheap-object | |
364 | -Wno-if-not-aligned -Wno-ignored-attributes | |
365 | -Wignored-qualifiers -Wno-incompatible-pointer-types | |
366 | -Wimplicit -Wimplicit-fallthrough -Wimplicit-fallthrough=@var{n} | |
367 | -Wno-implicit-function-declaration -Wno-implicit-int | |
368 | -Winfinite-recursion | |
369 | -Winit-self -Winline -Wno-int-conversion -Wint-in-bool-context | |
370 | -Wno-int-to-pointer-cast -Wno-invalid-memory-model | |
371 | -Winvalid-pch -Winvalid-utf8 -Wno-unicode -Wjump-misses-init | |
372 | -Wlarger-than=@var{byte-size} -Wlogical-not-parentheses -Wlogical-op | |
373 | -Wlong-long -Wno-lto-type-mismatch -Wmain -Wmaybe-uninitialized | |
374 | -Wmemset-elt-size -Wmemset-transposed-args | |
375 | -Wmisleading-indentation -Wmissing-attributes -Wmissing-braces | |
376 | -Wmissing-field-initializers -Wmissing-format-attribute | |
377 | -Wmissing-include-dirs -Wmissing-noreturn -Wno-missing-profile | |
378 | -Wno-multichar -Wmultistatement-macros -Wnonnull -Wnonnull-compare | |
379 | -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} | |
380 | -Wnull-dereference -Wno-odr | |
381 | -Wopenacc-parallelism | |
382 | -Wopenmp-simd | |
383 | -Wno-overflow -Woverlength-strings -Wno-override-init-side-effects | |
384 | -Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded | |
385 | -Wparentheses -Wno-pedantic-ms-format | |
386 | -Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast | |
387 | -Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls | |
388 | -Wrestrict -Wno-return-local-addr -Wreturn-type | |
389 | -Wno-scalar-storage-order -Wsequence-point | |
390 | -Wshadow -Wshadow=global -Wshadow=local -Wshadow=compatible-local | |
391 | -Wno-shadow-ivar | |
392 | -Wno-shift-count-negative -Wno-shift-count-overflow -Wshift-negative-value | |
393 | -Wno-shift-overflow -Wshift-overflow=@var{n} | |
394 | -Wsign-compare -Wsign-conversion | |
395 | -Wno-sizeof-array-argument | |
396 | -Wsizeof-array-div | |
397 | -Wsizeof-pointer-div -Wsizeof-pointer-memaccess | |
398 | -Wstack-protector -Wstack-usage=@var{byte-size} -Wstrict-aliasing | |
399 | -Wstrict-aliasing=n -Wstrict-overflow -Wstrict-overflow=@var{n} | |
400 | -Wstring-compare | |
401 | -Wno-stringop-overflow -Wno-stringop-overread | |
402 | -Wno-stringop-truncation -Wstrict-flex-arrays | |
403 | -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}malloc@r{]} | |
404 | -Wswitch -Wno-switch-bool -Wswitch-default -Wswitch-enum | |
405 | -Wno-switch-outside-range -Wno-switch-unreachable -Wsync-nand | |
406 | -Wsystem-headers -Wtautological-compare -Wtrampolines -Wtrigraphs | |
407 | -Wtrivial-auto-var-init -Wtsan -Wtype-limits -Wundef | |
408 | -Wuninitialized -Wunknown-pragmas | |
409 | -Wunsuffixed-float-constants -Wunused | |
410 | -Wunused-but-set-parameter -Wunused-but-set-variable | |
411 | -Wunused-const-variable -Wunused-const-variable=@var{n} | |
412 | -Wunused-function -Wunused-label -Wunused-local-typedefs | |
413 | -Wunused-macros | |
414 | -Wunused-parameter -Wno-unused-result | |
415 | -Wunused-value -Wunused-variable | |
416 | -Wno-varargs -Wvariadic-macros | |
417 | -Wvector-operation-performance | |
418 | -Wvla -Wvla-larger-than=@var{byte-size} -Wno-vla-larger-than | |
419 | -Wvolatile-register-var -Wwrite-strings | |
420 | -Wxor-used-as-pow | |
d77de738 ML |
421 | -Wzero-length-bounds} |
422 | ||
423 | @item Static Analyzer Options | |
424 | @gccoptlist{ | |
43b72ede AA |
425 | -fanalyzer |
426 | -fanalyzer-call-summaries | |
427 | -fanalyzer-checker=@var{name} | |
428 | -fno-analyzer-feasibility | |
429 | -fanalyzer-fine-grained | |
430 | -fno-analyzer-state-merge | |
431 | -fno-analyzer-state-purge | |
432 | -fno-analyzer-suppress-followups | |
433 | -fanalyzer-transitivity | |
434 | -fno-analyzer-undo-inlining | |
435 | -fanalyzer-verbose-edges | |
436 | -fanalyzer-verbose-state-changes | |
437 | -fanalyzer-verbosity=@var{level} | |
438 | -fdump-analyzer | |
439 | -fdump-analyzer-callgraph | |
440 | -fdump-analyzer-exploded-graph | |
441 | -fdump-analyzer-exploded-nodes | |
442 | -fdump-analyzer-exploded-nodes-2 | |
443 | -fdump-analyzer-exploded-nodes-3 | |
444 | -fdump-analyzer-exploded-paths | |
445 | -fdump-analyzer-feasibility | |
446 | -fdump-analyzer-json | |
447 | -fdump-analyzer-state-purge | |
448 | -fdump-analyzer-stderr | |
449 | -fdump-analyzer-supergraph | |
450 | -fdump-analyzer-untracked | |
451 | -Wno-analyzer-double-fclose | |
452 | -Wno-analyzer-double-free | |
453 | -Wno-analyzer-exposure-through-output-file | |
454 | -Wno-analyzer-exposure-through-uninit-copy | |
455 | -Wno-analyzer-fd-access-mode-mismatch | |
456 | -Wno-analyzer-fd-double-close | |
457 | -Wno-analyzer-fd-leak | |
458 | -Wno-analyzer-fd-phase-mismatch | |
459 | -Wno-analyzer-fd-type-mismatch | |
460 | -Wno-analyzer-fd-use-after-close | |
461 | -Wno-analyzer-fd-use-without-check | |
462 | -Wno-analyzer-file-leak | |
463 | -Wno-analyzer-free-of-non-heap | |
464 | -Wno-analyzer-imprecise-fp-arithmetic | |
465 | -Wno-analyzer-infinite-recursion | |
466 | -Wno-analyzer-jump-through-null | |
467 | -Wno-analyzer-malloc-leak | |
468 | -Wno-analyzer-mismatching-deallocation | |
469 | -Wno-analyzer-null-argument | |
470 | -Wno-analyzer-null-dereference | |
471 | -Wno-analyzer-out-of-bounds | |
472 | -Wno-analyzer-possible-null-argument | |
473 | -Wno-analyzer-possible-null-dereference | |
474 | -Wno-analyzer-putenv-of-auto-var | |
475 | -Wno-analyzer-shift-count-negative | |
476 | -Wno-analyzer-shift-count-overflow | |
477 | -Wno-analyzer-stale-setjmp-buffer | |
478 | -Wno-analyzer-tainted-allocation-size | |
479 | -Wno-analyzer-tainted-assertion | |
480 | -Wno-analyzer-tainted-array-index | |
481 | -Wno-analyzer-tainted-divisor | |
482 | -Wno-analyzer-tainted-offset | |
483 | -Wno-analyzer-tainted-size | |
484 | -Wanalyzer-too-complex | |
485 | -Wno-analyzer-unsafe-call-within-signal-handler | |
486 | -Wno-analyzer-use-after-free | |
487 | -Wno-analyzer-use-of-pointer-in-stale-stack-frame | |
488 | -Wno-analyzer-use-of-uninitialized-value | |
489 | -Wno-analyzer-va-arg-type-mismatch | |
490 | -Wno-analyzer-va-list-exhausted | |
491 | -Wno-analyzer-va-list-leak | |
492 | -Wno-analyzer-va-list-use-after-va-end | |
493 | -Wno-analyzer-write-to-const | |
494 | -Wno-analyzer-write-to-string-literal | |
d77de738 ML |
495 | } |
496 | ||
497 | @item C and Objective-C-only Warning Options | |
43b72ede AA |
498 | @gccoptlist{-Wbad-function-cast -Wmissing-declarations |
499 | -Wmissing-parameter-type -Wmissing-prototypes -Wnested-externs | |
500 | -Wold-style-declaration -Wold-style-definition | |
501 | -Wstrict-prototypes -Wtraditional -Wtraditional-conversion | |
d77de738 ML |
502 | -Wdeclaration-after-statement -Wpointer-sign} |
503 | ||
504 | @item Debugging Options | |
505 | @xref{Debugging Options,,Options for Debugging Your Program}. | |
43b72ede AA |
506 | @gccoptlist{-g -g@var{level} -gdwarf -gdwarf-@var{version} |
507 | -gbtf -gctf -gctf@var{level} | |
508 | -ggdb -grecord-gcc-switches -gno-record-gcc-switches | |
509 | -gstrict-dwarf -gno-strict-dwarf | |
510 | -gas-loc-support -gno-as-loc-support | |
511 | -gas-locview-support -gno-as-locview-support | |
512 | -gcolumn-info -gno-column-info -gdwarf32 -gdwarf64 | |
513 | -gstatement-frontiers -gno-statement-frontiers | |
514 | -gvariable-location-views -gno-variable-location-views | |
515 | -ginternal-reset-location-views -gno-internal-reset-location-views | |
516 | -ginline-points -gno-inline-points | |
517 | -gvms -gz@r{[}=@var{type}@r{]} | |
518 | -gsplit-dwarf -gdescribe-dies -gno-describe-dies | |
519 | -fdebug-prefix-map=@var{old}=@var{new} -fdebug-types-section | |
520 | -fno-eliminate-unused-debug-types | |
521 | -femit-struct-debug-baseonly -femit-struct-debug-reduced | |
522 | -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]} | |
523 | -fno-eliminate-unused-debug-symbols -femit-class-debug-always | |
524 | -fno-merge-debug-strings -fno-dwarf2-cfi-asm | |
d77de738 ML |
525 | -fvar-tracking -fvar-tracking-assignments} |
526 | ||
527 | @item Optimization Options | |
528 | @xref{Optimize Options,,Options that Control Optimization}. | |
43b72ede AA |
529 | @gccoptlist{-faggressive-loop-optimizations |
530 | -falign-functions[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] | |
531 | -falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] | |
532 | -falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] | |
533 | -falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] | |
534 | -fno-allocation-dce -fallow-store-data-races | |
535 | -fassociative-math -fauto-profile -fauto-profile[=@var{path}] | |
536 | -fauto-inc-dec -fbranch-probabilities | |
537 | -fcaller-saves | |
538 | -fcombine-stack-adjustments -fconserve-stack | |
539 | -fcompare-elim -fcprop-registers -fcrossjumping | |
540 | -fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules | |
541 | -fcx-limited-range | |
542 | -fdata-sections -fdce -fdelayed-branch | |
543 | -fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively | |
544 | -fdevirtualize-at-ltrans -fdse | |
545 | -fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects | |
546 | -ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=@var{style} | |
547 | -ffinite-loops | |
548 | -fforward-propagate -ffp-contract=@var{style} -ffunction-sections | |
549 | -fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity | |
550 | -fgcse-sm -fhoist-adjacent-loads -fif-conversion | |
551 | -fif-conversion2 -findirect-inlining | |
552 | -finline-functions -finline-functions-called-once -finline-limit=@var{n} | |
553 | -finline-small-functions -fipa-modref -fipa-cp -fipa-cp-clone | |
554 | -fipa-bit-cp -fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const | |
555 | -fipa-reference -fipa-reference-addressable | |
556 | -fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm} | |
557 | -flive-patching=@var{level} | |
558 | -fira-region=@var{region} -fira-hoist-pressure | |
559 | -fira-loop-pressure -fno-ira-share-save-slots | |
560 | -fno-ira-share-spill-slots | |
561 | -fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute | |
562 | -fivopts -fkeep-inline-functions -fkeep-static-functions | |
563 | -fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage | |
564 | -floop-block -floop-interchange -floop-strip-mine | |
565 | -floop-unroll-and-jam -floop-nest-optimize | |
566 | -floop-parallelize-all -flra-remat -flto -flto-compression-level | |
567 | -flto-partition=@var{alg} -fmerge-all-constants | |
568 | -fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves | |
569 | -fmove-loop-invariants -fmove-loop-stores -fno-branch-count-reg | |
570 | -fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse | |
571 | -fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole | |
572 | -fno-peephole2 -fno-printf-return-value -fno-sched-interblock | |
573 | -fno-sched-spec -fno-signed-zeros | |
574 | -fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss | |
575 | -fomit-frame-pointer -foptimize-sibling-calls | |
576 | -fpartial-inlining -fpeel-loops -fpredictive-commoning | |
577 | -fprefetch-loop-arrays | |
578 | -fprofile-correction | |
579 | -fprofile-use -fprofile-use=@var{path} -fprofile-partial-training | |
580 | -fprofile-values -fprofile-reorder-functions | |
581 | -freciprocal-math -free -frename-registers -freorder-blocks | |
582 | -freorder-blocks-algorithm=@var{algorithm} | |
583 | -freorder-blocks-and-partition -freorder-functions | |
584 | -frerun-cse-after-loop -freschedule-modulo-scheduled-loops | |
585 | -frounding-math -fsave-optimization-record | |
586 | -fsched2-use-superblocks -fsched-pressure | |
587 | -fsched-spec-load -fsched-spec-load-dangerous | |
588 | -fsched-stalled-insns-dep[=@var{n}] -fsched-stalled-insns[=@var{n}] | |
589 | -fsched-group-heuristic -fsched-critical-path-heuristic | |
590 | -fsched-spec-insn-heuristic -fsched-rank-heuristic | |
591 | -fsched-last-insn-heuristic -fsched-dep-count-heuristic | |
592 | -fschedule-fusion | |
593 | -fschedule-insns -fschedule-insns2 -fsection-anchors | |
594 | -fselective-scheduling -fselective-scheduling2 | |
595 | -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops | |
596 | -fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate | |
597 | -fsignaling-nans | |
598 | -fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops | |
599 | -fsplit-paths | |
600 | -fsplit-wide-types -fsplit-wide-types-early -fssa-backprop -fssa-phiopt | |
601 | -fstdarg-opt -fstore-merging -fstrict-aliasing -fipa-strict-aliasing | |
602 | -fthread-jumps -ftracer -ftree-bit-ccp | |
603 | -ftree-builtin-call-dce -ftree-ccp -ftree-ch | |
604 | -ftree-coalesce-vars -ftree-copy-prop -ftree-dce -ftree-dominator-opts | |
605 | -ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting | |
606 | -ftree-loop-if-convert -ftree-loop-im | |
607 | -ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns | |
608 | -ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize | |
609 | -ftree-loop-vectorize | |
610 | -ftree-parallelize-loops=@var{n} -ftree-pre -ftree-partial-pre -ftree-pta | |
611 | -ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slsr -ftree-sra | |
612 | -ftree-switch-conversion -ftree-tail-merge | |
613 | -ftree-ter -ftree-vectorize -ftree-vrp -ftrivial-auto-var-init | |
614 | -funconstrained-commons -funit-at-a-time -funroll-all-loops | |
615 | -funroll-loops -funsafe-math-optimizations -funswitch-loops | |
616 | -fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt | |
617 | -fweb -fwhole-program -fwpa -fuse-linker-plugin -fzero-call-used-regs | |
d77de738 ML |
618 | --param @var{name}=@var{value} |
619 | -O -O0 -O1 -O2 -O3 -Os -Ofast -Og -Oz} | |
620 | ||
621 | @item Program Instrumentation Options | |
622 | @xref{Instrumentation Options,,Program Instrumentation Options}. | |
43b72ede AA |
623 | @gccoptlist{-p -pg -fprofile-arcs --coverage -ftest-coverage |
624 | -fprofile-abs-path | |
625 | -fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path} | |
626 | -fprofile-info-section -fprofile-info-section=@var{name} | |
627 | -fprofile-note=@var{path} -fprofile-prefix-path=@var{path} | |
628 | -fprofile-update=@var{method} -fprofile-filter-files=@var{regex} | |
629 | -fprofile-exclude-files=@var{regex} | |
630 | -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]} | |
631 | -fsanitize=@var{style} -fsanitize-recover -fsanitize-recover=@var{style} | |
632 | -fsanitize-trap -fsanitize-trap=@var{style} | |
633 | -fasan-shadow-offset=@var{number} -fsanitize-sections=@var{s1},@var{s2},... | |
634 | -fsanitize-undefined-trap-on-error -fbounds-check | |
635 | -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]} | |
636 | -fharden-compares -fharden-conditional-branches | |
637 | -fstack-protector -fstack-protector-all -fstack-protector-strong | |
638 | -fstack-protector-explicit -fstack-check | |
639 | -fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} | |
640 | -fno-stack-limit -fsplit-stack | |
641 | -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} | |
642 | -fvtv-counts -fvtv-debug | |
643 | -finstrument-functions -finstrument-functions-once | |
644 | -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} | |
645 | -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{} | |
646 | -fprofile-prefix-map=@var{old}=@var{new}} | |
d77de738 ML |
647 | |
648 | @item Preprocessor Options | |
649 | @xref{Preprocessor Options,,Options Controlling the Preprocessor}. | |
43b72ede AA |
650 | @gccoptlist{-A@var{question}=@var{answer} |
651 | -A-@var{question}@r{[}=@var{answer}@r{]} | |
652 | -C -CC -D@var{macro}@r{[}=@var{defn}@r{]} | |
653 | -dD -dI -dM -dN -dU | |
654 | -fdebug-cpp -fdirectives-only -fdollars-in-identifiers | |
655 | -fexec-charset=@var{charset} -fextended-identifiers | |
656 | -finput-charset=@var{charset} -flarge-source-files | |
657 | -fmacro-prefix-map=@var{old}=@var{new} -fmax-include-depth=@var{depth} | |
658 | -fno-canonical-system-headers -fpch-deps -fpch-preprocess | |
659 | -fpreprocessed -ftabstop=@var{width} -ftrack-macro-expansion | |
660 | -fwide-exec-charset=@var{charset} -fworking-directory | |
661 | -H -imacros @var{file} -include @var{file} | |
662 | -M -MD -MF -MG -MM -MMD -MP -MQ -MT -Mno-modules | |
663 | -no-integrated-cpp -P -pthread -remap | |
664 | -traditional -traditional-cpp -trigraphs | |
665 | -U@var{macro} -undef | |
d77de738 ML |
666 | -Wp,@var{option} -Xpreprocessor @var{option}} |
667 | ||
668 | @item Assembler Options | |
669 | @xref{Assembler Options,,Passing Options to the Assembler}. | |
670 | @gccoptlist{-Wa,@var{option} -Xassembler @var{option}} | |
671 | ||
672 | @item Linker Options | |
673 | @xref{Link Options,,Options for Linking}. | |
43b72ede AA |
674 | @gccoptlist{@var{object-file-name} -fuse-ld=@var{linker} -l@var{library} |
675 | -nostartfiles -nodefaultlibs -nolibc -nostdlib -nostdlib++ | |
676 | -e @var{entry} --entry=@var{entry} | |
677 | -pie -pthread -r -rdynamic | |
678 | -s -static -static-pie -static-libgcc -static-libstdc++ | |
679 | -static-libasan -static-libtsan -static-liblsan -static-libubsan | |
680 | -shared -shared-libgcc -symbolic | |
681 | -T @var{script} -Wl,@var{option} -Xlinker @var{option} | |
d77de738 ML |
682 | -u @var{symbol} -z @var{keyword}} |
683 | ||
684 | @item Directory Options | |
685 | @xref{Directory Options,,Options for Directory Search}. | |
43b72ede AA |
686 | @gccoptlist{-B@var{prefix} -I@var{dir} -I- |
687 | -idirafter @var{dir} | |
688 | -imacros @var{file} -imultilib @var{dir} | |
689 | -iplugindir=@var{dir} -iprefix @var{file} | |
690 | -iquote @var{dir} -isysroot @var{dir} -isystem @var{dir} | |
691 | -iwithprefix @var{dir} -iwithprefixbefore @var{dir} | |
692 | -L@var{dir} -no-canonical-prefixes --no-sysroot-suffix | |
d77de738 ML |
693 | -nostdinc -nostdinc++ --sysroot=@var{dir}} |
694 | ||
695 | @item Code Generation Options | |
696 | @xref{Code Gen Options,,Options for Code Generation Conventions}. | |
43b72ede AA |
697 | @gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg} |
698 | -ffixed-@var{reg} -fexceptions | |
699 | -fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables | |
700 | -fasynchronous-unwind-tables | |
701 | -fno-gnu-unique | |
702 | -finhibit-size-directive -fcommon -fno-ident | |
703 | -fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt | |
704 | -fno-jump-tables -fno-bit-tests | |
705 | -frecord-gcc-switches | |
706 | -freg-struct-return -fshort-enums -fshort-wchar | |
707 | -fverbose-asm -fpack-struct[=@var{n}] | |
708 | -fleading-underscore -ftls-model=@var{model} | |
709 | -fstack-reuse=@var{reuse_level} | |
710 | -ftrampolines -ftrapv -fwrapv | |
711 | -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} | |
d77de738 ML |
712 | -fstrict-volatile-bitfields -fsync-libcalls} |
713 | ||
714 | @item Developer Options | |
715 | @xref{Developer Options,,GCC Developer Options}. | |
43b72ede | 716 | @gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion |
d77de738 | 717 | -dumpfullversion -fcallgraph-info@r{[}=su,da@r{]} |
43b72ede AA |
718 | -fchecking -fchecking=@var{n} |
719 | -fdbg-cnt-list -fdbg-cnt=@var{counter-value-list} | |
720 | -fdisable-ipa-@var{pass_name} | |
721 | -fdisable-rtl-@var{pass_name} | |
722 | -fdisable-rtl-@var{pass-name}=@var{range-list} | |
723 | -fdisable-tree-@var{pass_name} | |
724 | -fdisable-tree-@var{pass-name}=@var{range-list} | |
725 | -fdump-debug -fdump-earlydebug | |
726 | -fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links | |
727 | -fdump-final-insns@r{[}=@var{file}@r{]} | |
728 | -fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline | |
729 | -fdump-lang-all | |
730 | -fdump-lang-@var{switch} | |
731 | -fdump-lang-@var{switch}-@var{options} | |
732 | -fdump-lang-@var{switch}-@var{options}=@var{filename} | |
733 | -fdump-passes | |
734 | -fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename} | |
735 | -fdump-statistics | |
736 | -fdump-tree-all | |
737 | -fdump-tree-@var{switch} | |
738 | -fdump-tree-@var{switch}-@var{options} | |
739 | -fdump-tree-@var{switch}-@var{options}=@var{filename} | |
740 | -fcompare-debug@r{[}=@var{opts}@r{]} -fcompare-debug-second | |
741 | -fenable-@var{kind}-@var{pass} | |
742 | -fenable-@var{kind}-@var{pass}=@var{range-list} | |
743 | -fira-verbose=@var{n} | |
744 | -flto-report -flto-report-wpa -fmem-report-wpa | |
745 | -fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report | |
746 | -fopt-info -fopt-info-@var{options}@r{[}=@var{file}@r{]} | |
747 | -fmultiflags -fprofile-report | |
748 | -frandom-seed=@var{string} -fsched-verbose=@var{n} | |
749 | -fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose | |
750 | -fstats -fstack-usage -ftime-report -ftime-report-details | |
751 | -fvar-tracking-assignments-toggle -gtoggle | |
752 | -print-file-name=@var{library} -print-libgcc-file-name | |
753 | -print-multi-directory -print-multi-lib -print-multi-os-directory | |
754 | -print-prog-name=@var{program} -print-search-dirs -Q | |
755 | -print-sysroot -print-sysroot-headers-suffix | |
d77de738 ML |
756 | -save-temps -save-temps=cwd -save-temps=obj -time@r{[}=@var{file}@r{]}} |
757 | ||
758 | @item Machine-Dependent Options | |
759 | @xref{Submodel Options,,Machine-Dependent Options}. | |
760 | @c This list is ordered alphanumerically by subsection name. | |
761 | @c Try and put the significant identifier (CPU or system) first, | |
762 | @c so users have a clue at guessing where the ones they want will be. | |
763 | ||
764 | @emph{AArch64 Options} | |
43b72ede AA |
765 | @gccoptlist{-mabi=@var{name} -mbig-endian -mlittle-endian |
766 | -mgeneral-regs-only | |
767 | -mcmodel=tiny -mcmodel=small -mcmodel=large | |
768 | -mstrict-align -mno-strict-align | |
769 | -momit-leaf-frame-pointer | |
770 | -mtls-dialect=desc -mtls-dialect=traditional | |
771 | -mtls-size=@var{size} | |
772 | -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 | |
773 | -mlow-precision-recip-sqrt -mlow-precision-sqrt -mlow-precision-div | |
774 | -mpc-relative-literal-loads | |
775 | -msign-return-address=@var{scope} | |
d77de738 | 776 | -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf} |
43b72ede AA |
777 | +@var{b-key}]|@var{bti} |
778 | -mharden-sls=@var{opts} | |
779 | -march=@var{name} -mcpu=@var{name} -mtune=@var{name} | |
780 | -moverride=@var{string} -mverbose-cost-dump | |
781 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg} | |
782 | -mstack-protector-guard-offset=@var{offset} -mtrack-speculation | |
d77de738 ML |
783 | -moutline-atomics } |
784 | ||
785 | @emph{Adapteva Epiphany Options} | |
43b72ede AA |
786 | @gccoptlist{-mhalf-reg-file -mprefer-short-insn-regs |
787 | -mbranch-cost=@var{num} -mcmove -mnops=@var{num} -msoft-cmpsf | |
788 | -msplit-lohi -mpost-inc -mpost-modify -mstack-offset=@var{num} | |
789 | -mround-nearest -mlong-calls -mshort-calls -msmall16 | |
790 | -mfp-mode=@var{mode} -mvect-double -max-vect-align=@var{num} | |
d77de738 ML |
791 | -msplit-vecmove-early -m1reg-@var{reg}} |
792 | ||
793 | @emph{AMD GCN Options} | |
794 | @gccoptlist{-march=@var{gpu} -mtune=@var{gpu} -mstack-size=@var{bytes}} | |
795 | ||
796 | @emph{ARC Options} | |
43b72ede AA |
797 | @gccoptlist{-mbarrel-shifter -mjli-always |
798 | -mcpu=@var{cpu} -mA6 -mARC600 -mA7 -mARC700 | |
799 | -mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr | |
800 | -mea -mno-mpy -mmul32x16 -mmul64 -matomic | |
801 | -mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap | |
802 | -mcrc -mdsp-packa -mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape | |
803 | -mtelephony -mxy -misize -mannotate-align -marclinux -marclinux_prof | |
804 | -mlong-calls -mmedium-calls -msdata -mirq-ctrl-saved | |
805 | -mrgf-banked-regs -mlpc-width=@var{width} -G @var{num} | |
806 | -mvolatile-cache -mtp-regno=@var{regno} | |
807 | -malign-call -mauto-modify-reg -mbbit-peephole -mno-brcc | |
808 | -mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi | |
809 | -mexpand-adddi -mindexed-loads -mlra -mlra-priority-none | |
810 | -mlra-priority-compact -mlra-priority-noncompact -mmillicode | |
811 | -mmixed-code -mq-class -mRcq -mRcw -msize-level=@var{level} | |
812 | -mtune=@var{cpu} -mmultcost=@var{num} -mcode-density-frame | |
813 | -munalign-prob-threshold=@var{probability} -mmpy-option=@var{multo} | |
d77de738 ML |
814 | -mdiv-rem -mcode-density -mll64 -mfpu=@var{fpu} -mrf16 -mbranch-index} |
815 | ||
816 | @emph{ARM Options} | |
43b72ede AA |
817 | @gccoptlist{-mapcs-frame -mno-apcs-frame |
818 | -mabi=@var{name} | |
819 | -mapcs-stack-check -mno-apcs-stack-check | |
820 | -mapcs-reentrant -mno-apcs-reentrant | |
821 | -mgeneral-regs-only | |
822 | -msched-prolog -mno-sched-prolog | |
823 | -mlittle-endian -mbig-endian | |
824 | -mbe8 -mbe32 | |
825 | -mfloat-abi=@var{name} | |
d77de738 | 826 | -mfp16-format=@var{name} |
43b72ede AA |
827 | -mthumb-interwork -mno-thumb-interwork |
828 | -mcpu=@var{name} -march=@var{name} -mfpu=@var{name} | |
829 | -mtune=@var{name} -mprint-tune-info | |
830 | -mstructure-size-boundary=@var{n} | |
831 | -mabort-on-noreturn | |
832 | -mlong-calls -mno-long-calls | |
833 | -msingle-pic-base -mno-single-pic-base | |
834 | -mpic-register=@var{reg} | |
835 | -mnop-fun-dllimport | |
836 | -mpoke-function-name | |
837 | -mthumb -marm -mflip-thumb | |
838 | -mtpcs-frame -mtpcs-leaf-frame | |
839 | -mcaller-super-interworking -mcallee-super-interworking | |
840 | -mtp=@var{name} -mtls-dialect=@var{dialect} | |
841 | -mword-relocations | |
842 | -mfix-cortex-m3-ldrd | |
843 | -mfix-cortex-a57-aes-1742098 | |
844 | -mfix-cortex-a72-aes-1655431 | |
845 | -munaligned-access | |
846 | -mneon-for-64bits | |
847 | -mslow-flash-data | |
848 | -masm-syntax-unified | |
849 | -mrestrict-it | |
850 | -mverbose-cost-dump | |
851 | -mpure-code | |
852 | -mcmse | |
853 | -mfix-cmse-cve-2021-35465 | |
854 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset} | |
855 | -mfdpic | |
14fab5fb AC |
856 | -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}] |
857 | [+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]} | |
d77de738 ML |
858 | |
859 | @emph{AVR Options} | |
43b72ede AA |
860 | @gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args |
861 | -mbranch-cost=@var{cost} | |
862 | -mcall-prologues -mgas-isr-prologues -mint8 | |
863 | -mdouble=@var{bits} -mlong-double=@var{bits} | |
864 | -mn_flash=@var{size} -mno-interrupts | |
865 | -mmain-is-OS_task -mrelax -mrmw -mstrict-X -mtiny-stack | |
866 | -mfract-convert-truncate | |
867 | -mshort-calls -nodevicelib -nodevicespecs | |
d77de738 ML |
868 | -Waddr-space-convert -Wmisspelled-isr} |
869 | ||
870 | @emph{Blackfin Options} | |
43b72ede AA |
871 | @gccoptlist{-mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} |
872 | -msim -momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer | |
873 | -mspecld-anomaly -mno-specld-anomaly -mcsync-anomaly -mno-csync-anomaly | |
874 | -mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library | |
875 | -mno-id-shared-library -mshared-library-id=@var{n} | |
876 | -mleaf-id-shared-library -mno-leaf-id-shared-library | |
877 | -msep-data -mno-sep-data -mlong-calls -mno-long-calls | |
878 | -mfast-fp -minline-plt -mmulticore -mcorea -mcoreb -msdram | |
d77de738 ML |
879 | -micplb} |
880 | ||
881 | @emph{C6X Options} | |
43b72ede | 882 | @gccoptlist{-mbig-endian -mlittle-endian -march=@var{cpu} |
d77de738 ML |
883 | -msim -msdata=@var{sdata-type}} |
884 | ||
885 | @emph{CRIS Options} | |
886 | @gccoptlist{-mcpu=@var{cpu} -march=@var{cpu} | |
43b72ede AA |
887 | -mtune=@var{cpu} -mmax-stack-frame=@var{n} |
888 | -metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects | |
889 | -mstack-align -mdata-align -mconst-align | |
890 | -m32-bit -m16-bit -m8-bit -mno-prologue-epilogue | |
891 | -melf -maout -sim -sim2 | |
d77de738 ML |
892 | -mmul-bug-workaround -mno-mul-bug-workaround} |
893 | ||
894 | @emph{C-SKY Options} | |
43b72ede AA |
895 | @gccoptlist{-march=@var{arch} -mcpu=@var{cpu} |
896 | -mbig-endian -EB -mlittle-endian -EL | |
897 | -mhard-float -msoft-float -mfpu=@var{fpu} -mdouble-float -mfdivdu | |
898 | -mfloat-abi=@var{name} | |
899 | -melrw -mistack -mmp -mcp -mcache -msecurity -mtrust | |
900 | -mdsp -medsp -mvdsp | |
901 | -mdiv -msmart -mhigh-registers -manchor | |
902 | -mpushpop -mmultiple-stld -mconstpool -mstack-size -mccrt | |
d77de738 ML |
903 | -mbranch-cost=@var{n} -mcse-cc -msched-prolog -msim} |
904 | ||
905 | @emph{Darwin Options} | |
43b72ede AA |
906 | @gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal |
907 | -arch_only -bind_at_load -bundle -bundle_loader | |
908 | -client_name -compatibility_version -current_version | |
909 | -dead_strip | |
910 | -dependency-file -dylib_file -dylinker_install_name | |
911 | -dynamic -dynamiclib -exported_symbols_list | |
912 | -filelist -flat_namespace -force_cpusubtype_ALL | |
913 | -force_flat_namespace -headerpad_max_install_names | |
914 | -iframework | |
915 | -image_base -init -install_name -keep_private_externs | |
916 | -multi_module -multiply_defined -multiply_defined_unused | |
917 | -noall_load -no_dead_strip_inits_and_terms | |
918 | -nofixprebinding -nomultidefs -noprebind -noseglinkedit | |
919 | -pagezero_size -prebind -prebind_all_twolevel_modules | |
920 | -private_bundle -read_only_relocs -sectalign | |
921 | -sectobjectsymbols -whyload -seg1addr | |
922 | -sectcreate -sectobjectsymbols -sectorder | |
923 | -segaddr -segs_read_only_addr -segs_read_write_addr | |
924 | -seg_addr_table -seg_addr_table_filename -seglinkedit | |
925 | -segprot -segs_read_only_addr -segs_read_write_addr | |
926 | -single_module -static -sub_library -sub_umbrella | |
927 | -twolevel_namespace -umbrella -undefined | |
928 | -unexported_symbols_list -weak_reference_mismatches | |
929 | -whatsloaded -F -gused -gfull -mmacosx-version-min=@var{version} | |
d77de738 ML |
930 | -mkernel -mone-byte-bool} |
931 | ||
932 | @emph{DEC Alpha Options} | |
43b72ede AA |
933 | @gccoptlist{-mno-fp-regs -msoft-float |
934 | -mieee -mieee-with-inexact -mieee-conformant | |
935 | -mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} | |
936 | -mtrap-precision=@var{mode} -mbuild-constants | |
937 | -mcpu=@var{cpu-type} -mtune=@var{cpu-type} | |
938 | -mbwx -mmax -mfix -mcix | |
939 | -mfloat-vax -mfloat-ieee | |
940 | -mexplicit-relocs -msmall-data -mlarge-data | |
941 | -msmall-text -mlarge-text | |
d77de738 ML |
942 | -mmemory-latency=@var{time}} |
943 | ||
944 | @emph{eBPF Options} | |
945 | @gccoptlist{-mbig-endian -mlittle-endian -mkernel=@var{version} | |
946 | -mframe-limit=@var{bytes} -mxbpf -mco-re -mno-co-re | |
947 | -mjmpext -mjmp32 -malu32 -mcpu=@var{version}} | |
948 | ||
949 | @emph{FR30 Options} | |
950 | @gccoptlist{-msmall-model -mno-lsim} | |
951 | ||
952 | @emph{FT32 Options} | |
953 | @gccoptlist{-msim -mlra -mnodiv -mft32b -mcompress -mnopm} | |
954 | ||
955 | @emph{FRV Options} | |
43b72ede AA |
956 | @gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64 |
957 | -mhard-float -msoft-float | |
958 | -malloc-cc -mfixed-cc -mdword -mno-dword | |
959 | -mdouble -mno-double | |
960 | -mmedia -mno-media -mmuladd -mno-muladd | |
961 | -mfdpic -minline-plt -mgprel-ro -multilib-library-pic | |
962 | -mlinked-fp -mlong-calls -malign-labels | |
963 | -mlibrary-pic -macc-4 -macc-8 | |
964 | -mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move | |
965 | -moptimize-membar -mno-optimize-membar | |
966 | -mscc -mno-scc -mcond-exec -mno-cond-exec | |
967 | -mvliw-branch -mno-vliw-branch | |
968 | -mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec | |
969 | -mno-nested-cond-exec -mtomcat-stats | |
970 | -mTLS -mtls | |
d77de738 ML |
971 | -mcpu=@var{cpu}} |
972 | ||
973 | @emph{GNU/Linux Options} | |
43b72ede | 974 | @gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid |
d77de738 ML |
975 | -tno-android-cc -tno-android-ld} |
976 | ||
977 | @emph{H8/300 Options} | |
978 | @gccoptlist{-mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300} | |
979 | ||
980 | @emph{HPPA Options} | |
43b72ede AA |
981 | @gccoptlist{-march=@var{architecture-type} |
982 | -matomic-libcalls -mbig-switch | |
983 | -mcaller-copies -mdisable-fpregs -mdisable-indexing | |
984 | -mordered -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld | |
985 | -mfixed-range=@var{register-range} | |
986 | -mcoherent-ldcw -mjump-in-delay -mlinker-opt -mlong-calls | |
987 | -mlong-load-store -mno-atomic-libcalls -mno-disable-fpregs | |
988 | -mno-disable-indexing -mno-fast-indirect-calls -mno-gas | |
989 | -mno-jump-in-delay -mno-long-load-store | |
990 | -mno-portable-runtime -mno-soft-float | |
991 | -mno-space-regs -msoft-float -mpa-risc-1-0 | |
992 | -mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime | |
993 | -mschedule=@var{cpu-type} -mspace-regs -msoft-mult -msio -mwsio | |
d77de738 ML |
994 | -munix=@var{unix-std} -nolibdld -static -threads} |
995 | ||
996 | @emph{IA-64 Options} | |
43b72ede AA |
997 | @gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic |
998 | -mvolatile-asm-stop -mregister-names -msdata -mno-sdata | |
999 | -mconstant-gp -mauto-pic -mfused-madd | |
1000 | -minline-float-divide-min-latency | |
1001 | -minline-float-divide-max-throughput | |
1002 | -mno-inline-float-divide | |
1003 | -minline-int-divide-min-latency | |
1004 | -minline-int-divide-max-throughput | |
1005 | -mno-inline-int-divide | |
1006 | -minline-sqrt-min-latency -minline-sqrt-max-throughput | |
1007 | -mno-inline-sqrt | |
1008 | -mdwarf2-asm -mearly-stop-bits | |
1009 | -mfixed-range=@var{register-range} -mtls-size=@var{tls-size} | |
1010 | -mtune=@var{cpu-type} -milp32 -mlp64 | |
1011 | -msched-br-data-spec -msched-ar-data-spec -msched-control-spec | |
1012 | -msched-br-in-data-spec -msched-ar-in-data-spec -msched-in-control-spec | |
1013 | -msched-spec-ldc -msched-spec-control-ldc | |
1014 | -msched-prefer-non-data-spec-insns -msched-prefer-non-control-spec-insns | |
1015 | -msched-stop-bits-after-every-cycle -msched-count-spec-in-critical-path | |
1016 | -msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost | |
d77de738 ML |
1017 | -msched-max-memory-insns-hard-limit -msched-max-memory-insns=@var{max-insns}} |
1018 | ||
1019 | @emph{LM32 Options} | |
43b72ede | 1020 | @gccoptlist{-mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled |
d77de738 ML |
1021 | -msign-extend-enabled -muser-enabled} |
1022 | ||
1023 | @emph{LoongArch Options} | |
43b72ede AA |
1024 | @gccoptlist{-march=@var{cpu-type} -mtune=@var{cpu-type} -mabi=@var{base-abi-type} |
1025 | -mfpu=@var{fpu-type} -msoft-float -msingle-float -mdouble-float | |
1026 | -mbranch-cost=@var{n} -mcheck-zero-division -mno-check-zero-division | |
1027 | -mcond-move-int -mno-cond-move-int | |
1028 | -mcond-move-float -mno-cond-move-float | |
1029 | -memcpy -mno-memcpy -mstrict-align -mno-strict-align | |
1030 | -mmax-inline-memcpy-size=@var{n} | |
1031 | -mexplicit-relocs -mno-explicit-relocs | |
1032 | -mdirect-extern-access -mno-direct-extern-access | |
d77de738 ML |
1033 | -mcmodel=@var{code-model}} |
1034 | ||
1035 | @emph{M32R/D Options} | |
43b72ede AA |
1036 | @gccoptlist{-m32r2 -m32rx -m32r |
1037 | -mdebug | |
1038 | -malign-loops -mno-align-loops | |
1039 | -missue-rate=@var{number} | |
1040 | -mbranch-cost=@var{number} | |
1041 | -mmodel=@var{code-size-model-type} | |
1042 | -msdata=@var{sdata-type} | |
1043 | -mno-flush-func -mflush-func=@var{name} | |
1044 | -mno-flush-trap -mflush-trap=@var{number} | |
d77de738 ML |
1045 | -G @var{num}} |
1046 | ||
1047 | @emph{M32C Options} | |
1048 | @gccoptlist{-mcpu=@var{cpu} -msim -memregs=@var{number}} | |
1049 | ||
1050 | @emph{M680x0 Options} | |
43b72ede AA |
1051 | @gccoptlist{-march=@var{arch} -mcpu=@var{cpu} -mtune=@var{tune} |
1052 | -m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 | |
1053 | -m68060 -mcpu32 -m5200 -m5206e -m528x -m5307 -m5407 | |
1054 | -mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020 | |
1055 | -mnobitfield -mrtd -mno-rtd -mdiv -mno-div -mshort | |
1056 | -mno-short -mhard-float -m68881 -msoft-float -mpcrel | |
1057 | -malign-int -mstrict-align -msep-data -mno-sep-data | |
1058 | -mshared-library-id=n -mid-shared-library -mno-id-shared-library | |
d77de738 ML |
1059 | -mxgot -mno-xgot -mlong-jump-table-offsets} |
1060 | ||
1061 | @emph{MCore Options} | |
43b72ede AA |
1062 | @gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates |
1063 | -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields | |
1064 | -m4byte-functions -mno-4byte-functions -mcallgraph-data | |
1065 | -mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim | |
d77de738 ML |
1066 | -mlittle-endian -mbig-endian -m210 -m340 -mstack-increment} |
1067 | ||
d77de738 | 1068 | @emph{MicroBlaze Options} |
43b72ede AA |
1069 | @gccoptlist{-msoft-float -mhard-float -msmall-divides -mcpu=@var{cpu} |
1070 | -mmemcpy -mxl-soft-mul -mxl-soft-div -mxl-barrel-shift | |
1071 | -mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss | |
1072 | -mxl-multiply-high -mxl-float-convert -mxl-float-sqrt | |
1073 | -mbig-endian -mlittle-endian -mxl-reorder -mxl-mode-@var{app-model} | |
d77de738 ML |
1074 | -mpic-data-is-text-relative} |
1075 | ||
1076 | @emph{MIPS Options} | |
43b72ede AA |
1077 | @gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} |
1078 | -mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5 | |
1079 | -mips32r6 -mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6 | |
1080 | -mips16 -mno-mips16 -mflip-mips16 | |
1081 | -minterlink-compressed -mno-interlink-compressed | |
1082 | -minterlink-mips16 -mno-interlink-mips16 | |
1083 | -mabi=@var{abi} -mabicalls -mno-abicalls | |
1084 | -mshared -mno-shared -mplt -mno-plt -mxgot -mno-xgot | |
1085 | -mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float | |
1086 | -mno-float -msingle-float -mdouble-float | |
1087 | -modd-spreg -mno-odd-spreg | |
1088 | -mabs=@var{mode} -mnan=@var{encoding} | |
1089 | -mdsp -mno-dsp -mdspr2 -mno-dspr2 | |
1090 | -mmcu -mmno-mcu | |
1091 | -meva -mno-eva | |
1092 | -mvirt -mno-virt | |
1093 | -mxpa -mno-xpa | |
1094 | -mcrc -mno-crc | |
1095 | -mginv -mno-ginv | |
1096 | -mmicromips -mno-micromips | |
1097 | -mmsa -mno-msa | |
1098 | -mloongson-mmi -mno-loongson-mmi | |
1099 | -mloongson-ext -mno-loongson-ext | |
1100 | -mloongson-ext2 -mno-loongson-ext2 | |
1101 | -mfpu=@var{fpu-type} | |
1102 | -msmartmips -mno-smartmips | |
1103 | -mpaired-single -mno-paired-single -mdmx -mno-mdmx | |
1104 | -mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc | |
1105 | -mlong64 -mlong32 -msym32 -mno-sym32 | |
1106 | -G@var{num} -mlocal-sdata -mno-local-sdata | |
1107 | -mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt | |
1108 | -membedded-data -mno-embedded-data | |
1109 | -muninit-const-in-rodata -mno-uninit-const-in-rodata | |
1110 | -mcode-readable=@var{setting} | |
1111 | -msplit-addresses -mno-split-addresses | |
1112 | -mexplicit-relocs -mno-explicit-relocs | |
1113 | -mcheck-zero-division -mno-check-zero-division | |
1114 | -mdivide-traps -mdivide-breaks | |
1115 | -mload-store-pairs -mno-load-store-pairs | |
1116 | -munaligned-access -mno-unaligned-access | |
1117 | -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls | |
1118 | -mmad -mno-mad -mimadd -mno-imadd -mfused-madd -mno-fused-madd -nocpp | |
1119 | -mfix-24k -mno-fix-24k | |
1120 | -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 | |
1121 | -mfix-r5900 -mno-fix-r5900 | |
1122 | -mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000 | |
1123 | -mfix-vr4120 -mno-fix-vr4120 | |
1124 | -mfix-vr4130 -mno-fix-vr4130 -mfix-sb1 -mno-fix-sb1 | |
1125 | -mflush-func=@var{func} -mno-flush-func | |
1126 | -mbranch-cost=@var{num} -mbranch-likely -mno-branch-likely | |
1127 | -mcompact-branches=@var{policy} | |
1128 | -mfp-exceptions -mno-fp-exceptions | |
1129 | -mvr4130-align -mno-vr4130-align -msynci -mno-synci | |
1130 | -mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4 | |
1131 | -mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address | |
d77de738 ML |
1132 | -mframe-header-opt -mno-frame-header-opt} |
1133 | ||
1134 | @emph{MMIX Options} | |
43b72ede AA |
1135 | @gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu |
1136 | -mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols | |
1137 | -melf -mbranch-predict -mno-branch-predict -mbase-addresses | |
d77de738 ML |
1138 | -mno-base-addresses -msingle-exit -mno-single-exit} |
1139 | ||
1140 | @emph{MN10300 Options} | |
43b72ede AA |
1141 | @gccoptlist{-mmult-bug -mno-mult-bug |
1142 | -mno-am33 -mam33 -mam33-2 -mam34 | |
1143 | -mtune=@var{cpu-type} | |
1144 | -mreturn-pointer-on-d0 | |
d77de738 ML |
1145 | -mno-crt0 -mrelax -mliw -msetlb} |
1146 | ||
1147 | @emph{Moxie Options} | |
1148 | @gccoptlist{-meb -mel -mmul.x -mno-crt0} | |
1149 | ||
1150 | @emph{MSP430 Options} | |
43b72ede AA |
1151 | @gccoptlist{-msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax |
1152 | -mwarn-mcu | |
1153 | -mcode-region= -mdata-region= | |
1154 | -msilicon-errata= -msilicon-errata-warn= | |
d77de738 ML |
1155 | -mhwmult= -minrt -mtiny-printf -mmax-inline-shift=} |
1156 | ||
1157 | @emph{NDS32 Options} | |
43b72ede AA |
1158 | @gccoptlist{-mbig-endian -mlittle-endian |
1159 | -mreduced-regs -mfull-regs | |
1160 | -mcmov -mno-cmov | |
1161 | -mext-perf -mno-ext-perf | |
1162 | -mext-perf2 -mno-ext-perf2 | |
1163 | -mext-string -mno-ext-string | |
1164 | -mv3push -mno-v3push | |
1165 | -m16bit -mno-16bit | |
1166 | -misr-vector-size=@var{num} | |
1167 | -mcache-block-size=@var{num} | |
1168 | -march=@var{arch} | |
1169 | -mcmodel=@var{code-model} | |
d77de738 ML |
1170 | -mctor-dtor -mrelax} |
1171 | ||
1172 | @emph{Nios II Options} | |
43b72ede AA |
1173 | @gccoptlist{-G @var{num} -mgpopt=@var{option} -mgpopt -mno-gpopt |
1174 | -mgprel-sec=@var{regexp} -mr0rel-sec=@var{regexp} | |
1175 | -mel -meb | |
1176 | -mno-bypass-cache -mbypass-cache | |
1177 | -mno-cache-volatile -mcache-volatile | |
1178 | -mno-fast-sw-div -mfast-sw-div | |
1179 | -mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx -mno-hw-div -mhw-div | |
1180 | -mcustom-@var{insn}=@var{N} -mno-custom-@var{insn} | |
1181 | -mcustom-fpu-cfg=@var{name} | |
1182 | -mhal -msmallc -msys-crt0=@var{name} -msys-lib=@var{name} | |
d77de738 ML |
1183 | -march=@var{arch} -mbmx -mno-bmx -mcdx -mno-cdx} |
1184 | ||
1185 | @emph{Nvidia PTX Options} | |
1186 | @gccoptlist{-m64 -mmainkernel -moptimize} | |
1187 | ||
1188 | @emph{OpenRISC Options} | |
43b72ede AA |
1189 | @gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div |
1190 | -msoft-mul -msoft-div | |
1191 | -msoft-float -mhard-float -mdouble-float -munordered-float | |
1192 | -mcmov -mror -mrori -msext -msfimm -mshftimm | |
d77de738 ML |
1193 | -mcmodel=@var{code-model}} |
1194 | ||
1195 | @emph{PDP-11 Options} | |
43b72ede AA |
1196 | @gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 |
1197 | -mint32 -mno-int16 -mint16 -mno-int32 | |
d77de738 ML |
1198 | -msplit -munix-asm -mdec-asm -mgnu-asm -mlra} |
1199 | ||
d77de738 ML |
1200 | @emph{PowerPC Options} |
1201 | See RS/6000 and PowerPC Options. | |
1202 | ||
1203 | @emph{PRU Options} | |
43b72ede | 1204 | @gccoptlist{-mmcu=@var{mcu} -minrt -mno-relax -mloop |
f58e6d42 | 1205 | -mabi=@var{variant}} |
d77de738 ML |
1206 | |
1207 | @emph{RISC-V Options} | |
43b72ede AA |
1208 | @gccoptlist{-mbranch-cost=@var{N-instruction} |
1209 | -mplt -mno-plt | |
1210 | -mabi=@var{ABI-string} | |
1211 | -mfdiv -mno-fdiv | |
1212 | -mdiv -mno-div | |
1213 | -misa-spec=@var{ISA-spec-string} | |
1214 | -march=@var{ISA-string} | |
1215 | -mtune=@var{processor-string} | |
1216 | -mpreferred-stack-boundary=@var{num} | |
1217 | -msmall-data-limit=@var{N-bytes} | |
1218 | -msave-restore -mno-save-restore | |
1219 | -mshorten-memrefs -mno-shorten-memrefs | |
1220 | -mstrict-align -mno-strict-align | |
1221 | -mcmodel=medlow -mcmodel=medany | |
1222 | -mexplicit-relocs -mno-explicit-relocs | |
1223 | -mrelax -mno-relax | |
1224 | -mriscv-attribute -mno-riscv-attribute | |
1225 | -malign-data=@var{type} | |
1226 | -mbig-endian -mlittle-endian | |
1227 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} | |
1228 | -mstack-protector-guard-offset=@var{offset} | |
f58e6d42 | 1229 | -mcsr-check -mno-csr-check} |
d77de738 ML |
1230 | |
1231 | @emph{RL78 Options} | |
43b72ede AA |
1232 | @gccoptlist{-msim -mmul=none -mmul=g13 -mmul=g14 -mallregs |
1233 | -mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14 | |
d77de738 ML |
1234 | -m64bit-doubles -m32bit-doubles -msave-mduc-in-interrupts} |
1235 | ||
1236 | @emph{RS/6000 and PowerPC Options} | |
43b72ede AA |
1237 | @gccoptlist{-mcpu=@var{cpu-type} |
1238 | -mtune=@var{cpu-type} | |
1239 | -mcmodel=@var{code-model} | |
1240 | -mpowerpc64 | |
1241 | -maltivec -mno-altivec | |
1242 | -mpowerpc-gpopt -mno-powerpc-gpopt | |
1243 | -mpowerpc-gfxopt -mno-powerpc-gfxopt | |
1244 | -mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd -mno-popcntd | |
1245 | -mfprnd -mno-fprnd | |
1246 | -mcmpb -mno-cmpb -mhard-dfp -mno-hard-dfp | |
1247 | -mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc | |
1248 | -m64 -m32 -mxl-compat -mno-xl-compat -mpe | |
1249 | -malign-power -malign-natural | |
1250 | -msoft-float -mhard-float -mmultiple -mno-multiple | |
1251 | -mupdate -mno-update | |
1252 | -mavoid-indexed-addresses -mno-avoid-indexed-addresses | |
1253 | -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align | |
1254 | -mstrict-align -mno-strict-align -mrelocatable | |
1255 | -mno-relocatable -mrelocatable-lib -mno-relocatable-lib | |
1256 | -mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian | |
1257 | -mdynamic-no-pic -mswdiv -msingle-pic-base | |
1258 | -mprioritize-restricted-insns=@var{priority} | |
1259 | -msched-costly-dep=@var{dependence_type} | |
1260 | -minsert-sched-nops=@var{scheme} | |
1261 | -mcall-aixdesc -mcall-eabi -mcall-freebsd | |
1262 | -mcall-linux -mcall-netbsd -mcall-openbsd | |
1263 | -mcall-sysv -mcall-sysv-eabi -mcall-sysv-noeabi | |
1264 | -mtraceback=@var{traceback_type} | |
1265 | -maix-struct-return -msvr4-struct-return | |
1266 | -mabi=@var{abi-type} -msecure-plt -mbss-plt | |
1267 | -mlongcall -mno-longcall -mpltseq -mno-pltseq | |
1268 | -mblock-move-inline-limit=@var{num} | |
1269 | -mblock-compare-inline-limit=@var{num} | |
1270 | -mblock-compare-inline-loop-limit=@var{num} | |
1271 | -mno-block-ops-unaligned-vsx | |
1272 | -mstring-compare-inline-limit=@var{num} | |
1273 | -misel -mno-isel | |
1274 | -mvrsave -mno-vrsave | |
1275 | -mmulhw -mno-mulhw | |
1276 | -mdlmzb -mno-dlmzb | |
1277 | -mprototype -mno-prototype | |
1278 | -msim -mmvme -mads -myellowknife -memb -msdata | |
1279 | -msdata=@var{opt} -mreadonly-in-sdata -mvxworks -G @var{num} | |
1280 | -mrecip -mrecip=@var{opt} -mno-recip -mrecip-precision | |
1281 | -mno-recip-precision | |
1282 | -mveclibabi=@var{type} -mfriz -mno-friz | |
1283 | -mpointers-to-nested-functions -mno-pointers-to-nested-functions | |
1284 | -msave-toc-indirect -mno-save-toc-indirect | |
1285 | -mpower8-fusion -mno-mpower8-fusion -mpower8-vector -mno-power8-vector | |
1286 | -mcrypto -mno-crypto -mhtm -mno-htm | |
1287 | -mquad-memory -mno-quad-memory | |
1288 | -mquad-memory-atomic -mno-quad-memory-atomic | |
1289 | -mcompat-align-parm -mno-compat-align-parm | |
1290 | -mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware | |
1291 | -mgnu-attribute -mno-gnu-attribute | |
1292 | -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} | |
1293 | -mstack-protector-guard-offset=@var{offset} -mprefixed -mno-prefixed | |
1294 | -mpcrel -mno-pcrel -mmma -mno-mmma -mrop-protect -mno-rop-protect | |
d77de738 ML |
1295 | -mprivileged -mno-privileged} |
1296 | ||
1297 | @emph{RX Options} | |
43b72ede AA |
1298 | @gccoptlist{-m64bit-doubles -m32bit-doubles -fpu -nofpu |
1299 | -mcpu= | |
1300 | -mbig-endian-data -mlittle-endian-data | |
1301 | -msmall-data | |
1302 | -msim -mno-sim | |
1303 | -mas100-syntax -mno-as100-syntax | |
1304 | -mrelax | |
1305 | -mmax-constant-size= | |
1306 | -mint-register= | |
1307 | -mpid | |
1308 | -mallow-string-insns -mno-allow-string-insns | |
1309 | -mjsr | |
1310 | -mno-warn-multiple-fast-interrupts | |
d77de738 ML |
1311 | -msave-acc-in-interrupts} |
1312 | ||
1313 | @emph{S/390 and zSeries Options} | |
43b72ede AA |
1314 | @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} |
1315 | -mhard-float -msoft-float -mhard-dfp -mno-hard-dfp | |
1316 | -mlong-double-64 -mlong-double-128 | |
1317 | -mbackchain -mno-backchain -mpacked-stack -mno-packed-stack | |
1318 | -msmall-exec -mno-small-exec -mmvcle -mno-mvcle | |
1319 | -m64 -m31 -mdebug -mno-debug -mesa -mzarch | |
1320 | -mhtm -mvx -mzvector | |
1321 | -mtpf-trace -mno-tpf-trace -mtpf-trace-skip -mno-tpf-trace-skip | |
1322 | -mfused-madd -mno-fused-madd | |
1323 | -mwarn-framesize -mwarn-dynamicstack -mstack-size -mstack-guard | |
d77de738 ML |
1324 | -mhotpatch=@var{halfwords},@var{halfwords}} |
1325 | ||
d77de738 | 1326 | @emph{SH Options} |
43b72ede AA |
1327 | @gccoptlist{-m1 -m2 -m2e |
1328 | -m2a-nofpu -m2a-single-only -m2a-single -m2a | |
1329 | -m3 -m3e | |
1330 | -m4-nofpu -m4-single-only -m4-single -m4 | |
1331 | -m4a-nofpu -m4a-single-only -m4a-single -m4a -m4al | |
1332 | -mb -ml -mdalign -mrelax | |
1333 | -mbigtable -mfmovd -mrenesas -mno-renesas -mnomacsave | |
1334 | -mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct | |
1335 | -mprefergot -musermode -multcost=@var{number} -mdiv=@var{strategy} | |
1336 | -mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range} | |
1337 | -maccumulate-outgoing-args | |
1338 | -matomic-model=@var{atomic-model} | |
1339 | -mbranch-cost=@var{num} -mzdcbranch -mno-zdcbranch | |
1340 | -mcbranch-force-delay-slot | |
1341 | -mfused-madd -mno-fused-madd -mfsca -mno-fsca -mfsrra -mno-fsrra | |
d77de738 ML |
1342 | -mpretend-cmove -mtas} |
1343 | ||
1344 | @emph{Solaris 2 Options} | |
43b72ede | 1345 | @gccoptlist{-mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text |
d77de738 ML |
1346 | -pthreads} |
1347 | ||
1348 | @emph{SPARC Options} | |
43b72ede AA |
1349 | @gccoptlist{-mcpu=@var{cpu-type} |
1350 | -mtune=@var{cpu-type} | |
1351 | -mcmodel=@var{code-model} | |
1352 | -mmemory-model=@var{mem-model} | |
1353 | -m32 -m64 -mapp-regs -mno-app-regs | |
1354 | -mfaster-structs -mno-faster-structs -mflat -mno-flat | |
1355 | -mfpu -mno-fpu -mhard-float -msoft-float | |
1356 | -mhard-quad-float -msoft-quad-float | |
1357 | -mstack-bias -mno-stack-bias | |
1358 | -mstd-struct-return -mno-std-struct-return | |
1359 | -munaligned-doubles -mno-unaligned-doubles | |
1360 | -muser-mode -mno-user-mode | |
1361 | -mv8plus -mno-v8plus -mvis -mno-vis | |
1362 | -mvis2 -mno-vis2 -mvis3 -mno-vis3 | |
1363 | -mvis4 -mno-vis4 -mvis4b -mno-vis4b | |
1364 | -mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld | |
1365 | -mpopc -mno-popc -msubxc -mno-subxc | |
1366 | -mfix-at697f -mfix-ut699 -mfix-ut700 -mfix-gr712rc | |
d77de738 ML |
1367 | -mlra -mno-lra} |
1368 | ||
1369 | @emph{System V Options} | |
1370 | @gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}} | |
1371 | ||
1372 | @emph{V850 Options} | |
43b72ede AA |
1373 | @gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep |
1374 | -mprolog-function -mno-prolog-function -mspace | |
1375 | -mtda=@var{n} -msda=@var{n} -mzda=@var{n} | |
1376 | -mapp-regs -mno-app-regs | |
1377 | -mdisable-callt -mno-disable-callt | |
1378 | -mv850e2v3 -mv850e2 -mv850e1 -mv850es | |
1379 | -mv850e -mv850 -mv850e3v5 | |
1380 | -mloop | |
1381 | -mrelax | |
1382 | -mlong-jumps | |
1383 | -msoft-float | |
1384 | -mhard-float | |
1385 | -mgcc-abi | |
1386 | -mrh850-abi | |
d77de738 ML |
1387 | -mbig-switch} |
1388 | ||
1389 | @emph{VAX Options} | |
1390 | @gccoptlist{-mg -mgnu -munix -mlra} | |
1391 | ||
1392 | @emph{Visium Options} | |
43b72ede | 1393 | @gccoptlist{-mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float |
d77de738 ML |
1394 | -mcpu=@var{cpu-type} -mtune=@var{cpu-type} -msv-mode -muser-mode} |
1395 | ||
1396 | @emph{VMS Options} | |
43b72ede | 1397 | @gccoptlist{-mvms-return-codes -mdebug-main=@var{prefix} -mmalloc64 |
d77de738 ML |
1398 | -mpointer-size=@var{size}} |
1399 | ||
1400 | @emph{VxWorks Options} | |
43b72ede | 1401 | @gccoptlist{-mrtp -non-static -Bstatic -Bdynamic |
d77de738 ML |
1402 | -Xbind-lazy -Xbind-now} |
1403 | ||
1404 | @emph{x86 Options} | |
43b72ede AA |
1405 | @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} |
1406 | -mtune-ctrl=@var{feature-list} -mdump-tune-features -mno-default | |
1407 | -mfpmath=@var{unit} | |
1408 | -masm=@var{dialect} -mno-fancy-math-387 | |
1409 | -mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float | |
1410 | -mno-wide-multiply -mrtd -malign-double | |
1411 | -mpreferred-stack-boundary=@var{num} | |
1412 | -mincoming-stack-boundary=@var{num} | |
1413 | -mcld -mcx16 -msahf -mmovbe -mcrc32 -mmwait | |
1414 | -mrecip -mrecip=@var{opt} | |
1415 | -mvzeroupper -mprefer-avx128 -mprefer-vector-width=@var{opt} | |
1416 | -mmove-max=@var{bits} -mstore-max=@var{bits} | |
1417 | -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx | |
1418 | -mavx2 -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl | |
1419 | -mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes | |
1420 | -mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd | |
1421 | -mptwrite -mprefetchwt1 -mclflushopt -mclwb -mxsavec -mxsaves | |
1422 | -msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop | |
1423 | -madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp | |
1424 | -mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg | |
1425 | -mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call | |
1426 | -mavx512vbmi2 -mavx512bf16 -menqcmd | |
1427 | -mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq | |
1428 | -mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid | |
1429 | -mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk | |
1430 | -mamx-tile -mamx-int8 -mamx-bf16 -muintr -mhreset -mavxvnni | |
1431 | -mavx512fp16 -mavxifma -mavxvnniint8 -mavxneconvert -mcmpccxadd -mamx-fp16 | |
1432 | -mprefetchi -mraoint | |
1433 | -mcldemote -mms-bitfields -mno-align-stringops -minline-all-stringops | |
1434 | -minline-stringops-dynamically -mstringop-strategy=@var{alg} | |
1435 | -mkl -mwidekl | |
1436 | -mmemcpy-strategy=@var{strategy} -mmemset-strategy=@var{strategy} | |
1437 | -mpush-args -maccumulate-outgoing-args -m128bit-long-double | |
1438 | -m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128 | |
1439 | -mregparm=@var{num} -msseregparm | |
1440 | -mveclibabi=@var{type} -mvect8-ret-in-mem | |
1441 | -mpc32 -mpc64 -mpc80 -mdaz-ftz -mstackrealign | |
1442 | -momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs | |
1443 | -mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode} | |
1444 | -m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=@var{num} | |
1445 | -msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv | |
1446 | -minstrument-return=@var{type} -mfentry-name=@var{name} -mfentry-section=@var{name} | |
1447 | -mavx256-split-unaligned-load -mavx256-split-unaligned-store | |
1448 | -malign-data=@var{type} -mstack-protector-guard=@var{guard} | |
1449 | -mstack-protector-guard-reg=@var{reg} | |
1450 | -mstack-protector-guard-offset=@var{offset} | |
1451 | -mstack-protector-guard-symbol=@var{symbol} | |
1452 | -mgeneral-regs-only -mcall-ms2sysv-xlogues -mrelax-cmpxchg-loop | |
1453 | -mindirect-branch=@var{choice} -mfunction-return=@var{choice} | |
1454 | -mindirect-branch-register -mharden-sls=@var{choice} | |
1455 | -mindirect-branch-cs-prefix -mneeded -mno-direct-extern-access | |
bb576017 | 1456 | -munroll-only-small-loops -mlam=@var{choice}} |
d77de738 ML |
1457 | |
1458 | @emph{x86 Windows Options} | |
43b72ede AA |
1459 | @gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll |
1460 | -mnop-fun-dllimport -mthread | |
d77de738 ML |
1461 | -municode -mwin32 -mwindows -fno-set-stack-executable} |
1462 | ||
1463 | @emph{Xstormy16 Options} | |
1464 | @gccoptlist{-msim} | |
1465 | ||
1466 | @emph{Xtensa Options} | |
43b72ede AA |
1467 | @gccoptlist{-mconst16 -mno-const16 |
1468 | -mfused-madd -mno-fused-madd | |
1469 | -mforce-no-pic | |
1470 | -mserialize-volatile -mno-serialize-volatile | |
1471 | -mtext-section-literals -mno-text-section-literals | |
1472 | -mauto-litpools -mno-auto-litpools | |
1473 | -mtarget-align -mno-target-align | |
1474 | -mlongcalls -mno-longcalls | |
1475 | -mabi=@var{abi-type} | |
d77de738 ML |
1476 | -mextra-l32r-costs=@var{cycles}} |
1477 | ||
1478 | @emph{zSeries Options} | |
1479 | See S/390 and zSeries Options. | |
1480 | @end table | |
1481 | ||
1482 | ||
1483 | @node Overall Options | |
1484 | @section Options Controlling the Kind of Output | |
1485 | ||
1486 | Compilation can involve up to four stages: preprocessing, compilation | |
1487 | proper, assembly and linking, always in that order. GCC is capable of | |
1488 | preprocessing and compiling several files either into several | |
1489 | assembler input files, or into one assembler input file; then each | |
1490 | assembler input file produces an object file, and linking combines all | |
1491 | the object files (those newly compiled, and those specified as input) | |
1492 | into an executable file. | |
1493 | ||
1494 | @cindex file name suffix | |
1495 | For any given input file, the file name suffix determines what kind of | |
1496 | compilation is done: | |
1497 | ||
1498 | @table @gcctabopt | |
1499 | @item @var{file}.c | |
1500 | C source code that must be preprocessed. | |
1501 | ||
1502 | @item @var{file}.i | |
1503 | C source code that should not be preprocessed. | |
1504 | ||
1505 | @item @var{file}.ii | |
1506 | C++ source code that should not be preprocessed. | |
1507 | ||
1508 | @item @var{file}.m | |
1509 | Objective-C source code. Note that you must link with the @file{libobjc} | |
1510 | library to make an Objective-C program work. | |
1511 | ||
1512 | @item @var{file}.mi | |
1513 | Objective-C source code that should not be preprocessed. | |
1514 | ||
1515 | @item @var{file}.mm | |
1516 | @itemx @var{file}.M | |
1517 | Objective-C++ source code. Note that you must link with the @file{libobjc} | |
1518 | library to make an Objective-C++ program work. Note that @samp{.M} refers | |
1519 | to a literal capital M@. | |
1520 | ||
1521 | @item @var{file}.mii | |
1522 | Objective-C++ source code that should not be preprocessed. | |
1523 | ||
1524 | @item @var{file}.h | |
1525 | C, C++, Objective-C or Objective-C++ header file to be turned into a | |
1526 | precompiled header (default), or C, C++ header file to be turned into an | |
1527 | Ada spec (via the @option{-fdump-ada-spec} switch). | |
1528 | ||
1529 | @item @var{file}.cc | |
1530 | @itemx @var{file}.cp | |
1531 | @itemx @var{file}.cxx | |
1532 | @itemx @var{file}.cpp | |
1533 | @itemx @var{file}.CPP | |
1534 | @itemx @var{file}.c++ | |
1535 | @itemx @var{file}.C | |
1536 | C++ source code that must be preprocessed. Note that in @samp{.cxx}, | |
1537 | the last two letters must both be literally @samp{x}. Likewise, | |
1538 | @samp{.C} refers to a literal capital C@. | |
1539 | ||
1540 | @item @var{file}.mm | |
1541 | @itemx @var{file}.M | |
1542 | Objective-C++ source code that must be preprocessed. | |
1543 | ||
1544 | @item @var{file}.mii | |
1545 | Objective-C++ source code that should not be preprocessed. | |
1546 | ||
1547 | @item @var{file}.hh | |
1548 | @itemx @var{file}.H | |
1549 | @itemx @var{file}.hp | |
1550 | @itemx @var{file}.hxx | |
1551 | @itemx @var{file}.hpp | |
1552 | @itemx @var{file}.HPP | |
1553 | @itemx @var{file}.h++ | |
1554 | @itemx @var{file}.tcc | |
1555 | C++ header file to be turned into a precompiled header or Ada spec. | |
1556 | ||
1557 | @item @var{file}.f | |
1558 | @itemx @var{file}.for | |
1559 | @itemx @var{file}.ftn | |
1560 | Fixed form Fortran source code that should not be preprocessed. | |
1561 | ||
1562 | @item @var{file}.F | |
1563 | @itemx @var{file}.FOR | |
1564 | @itemx @var{file}.fpp | |
1565 | @itemx @var{file}.FPP | |
1566 | @itemx @var{file}.FTN | |
1567 | Fixed form Fortran source code that must be preprocessed (with the traditional | |
1568 | preprocessor). | |
1569 | ||
1570 | @item @var{file}.f90 | |
1571 | @itemx @var{file}.f95 | |
1572 | @itemx @var{file}.f03 | |
1573 | @itemx @var{file}.f08 | |
1574 | Free form Fortran source code that should not be preprocessed. | |
1575 | ||
1576 | @item @var{file}.F90 | |
1577 | @itemx @var{file}.F95 | |
1578 | @itemx @var{file}.F03 | |
1579 | @itemx @var{file}.F08 | |
1580 | Free form Fortran source code that must be preprocessed (with the | |
1581 | traditional preprocessor). | |
1582 | ||
1583 | @item @var{file}.go | |
1584 | Go source code. | |
1585 | ||
1586 | @item @var{file}.d | |
1587 | D source code. | |
1588 | ||
1589 | @item @var{file}.di | |
1590 | D interface file. | |
1591 | ||
1592 | @item @var{file}.dd | |
1593 | D documentation code (Ddoc). | |
1594 | ||
1595 | @item @var{file}.ads | |
1596 | Ada source code file that contains a library unit declaration (a | |
1597 | declaration of a package, subprogram, or generic, or a generic | |
1598 | instantiation), or a library unit renaming declaration (a package, | |
1599 | generic, or subprogram renaming declaration). Such files are also | |
1600 | called @dfn{specs}. | |
1601 | ||
1602 | @item @var{file}.adb | |
1603 | Ada source code file containing a library unit body (a subprogram or | |
1604 | package body). Such files are also called @dfn{bodies}. | |
1605 | ||
1606 | @c GCC also knows about some suffixes for languages not yet included: | |
1607 | @c Ratfor: | |
1608 | @c @var{file}.r | |
1609 | ||
1610 | @item @var{file}.s | |
1611 | Assembler code. | |
1612 | ||
1613 | @item @var{file}.S | |
1614 | @itemx @var{file}.sx | |
1615 | Assembler code that must be preprocessed. | |
1616 | ||
1617 | @item @var{other} | |
1618 | An object file to be fed straight into linking. | |
1619 | Any file name with no recognized suffix is treated this way. | |
1620 | @end table | |
1621 | ||
1622 | @opindex x | |
1623 | You can specify the input language explicitly with the @option{-x} option: | |
1624 | ||
1625 | @table @gcctabopt | |
1626 | @item -x @var{language} | |
1627 | Specify explicitly the @var{language} for the following input files | |
1628 | (rather than letting the compiler choose a default based on the file | |
1629 | name suffix). This option applies to all following input files until | |
1630 | the next @option{-x} option. Possible values for @var{language} are: | |
1631 | @smallexample | |
1632 | c c-header cpp-output | |
1633 | c++ c++-header c++-system-header c++-user-header c++-cpp-output | |
1634 | objective-c objective-c-header objective-c-cpp-output | |
1635 | objective-c++ objective-c++-header objective-c++-cpp-output | |
1636 | assembler assembler-with-cpp | |
1637 | ada | |
1638 | d | |
1639 | f77 f77-cpp-input f95 f95-cpp-input | |
1640 | go | |
1641 | @end smallexample | |
1642 | ||
1643 | @item -x none | |
1644 | Turn off any specification of a language, so that subsequent files are | |
1645 | handled according to their file name suffixes (as they are if @option{-x} | |
1646 | has not been used at all). | |
1647 | @end table | |
1648 | ||
1649 | If you only want some of the stages of compilation, you can use | |
1650 | @option{-x} (or filename suffixes) to tell @command{gcc} where to start, and | |
1651 | one of the options @option{-c}, @option{-S}, or @option{-E} to say where | |
1652 | @command{gcc} is to stop. Note that some combinations (for example, | |
1653 | @samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all. | |
1654 | ||
1655 | @table @gcctabopt | |
d77de738 | 1656 | @opindex c |
ddf6fe37 | 1657 | @item -c |
d77de738 ML |
1658 | Compile or assemble the source files, but do not link. The linking |
1659 | stage simply is not done. The ultimate output is in the form of an | |
1660 | object file for each source file. | |
1661 | ||
1662 | By default, the object file name for a source file is made by replacing | |
1663 | the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}. | |
1664 | ||
1665 | Unrecognized input files, not requiring compilation or assembly, are | |
1666 | ignored. | |
1667 | ||
d77de738 | 1668 | @opindex S |
ddf6fe37 | 1669 | @item -S |
d77de738 ML |
1670 | Stop after the stage of compilation proper; do not assemble. The output |
1671 | is in the form of an assembler code file for each non-assembler input | |
1672 | file specified. | |
1673 | ||
1674 | By default, the assembler file name for a source file is made by | |
1675 | replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}. | |
1676 | ||
1677 | Input files that don't require compilation are ignored. | |
1678 | ||
d77de738 | 1679 | @opindex E |
ddf6fe37 | 1680 | @item -E |
d77de738 ML |
1681 | Stop after the preprocessing stage; do not run the compiler proper. The |
1682 | output is in the form of preprocessed source code, which is sent to the | |
1683 | standard output. | |
1684 | ||
1685 | Input files that don't require preprocessing are ignored. | |
1686 | ||
1687 | @cindex output file option | |
d77de738 | 1688 | @opindex o |
ddf6fe37 | 1689 | @item -o @var{file} |
d77de738 ML |
1690 | Place the primary output in file @var{file}. This applies to whatever |
1691 | sort of output is being produced, whether it be an executable file, an | |
1692 | object file, an assembler file or preprocessed C code. | |
1693 | ||
1694 | If @option{-o} is not specified, the default is to put an executable | |
1695 | file in @file{a.out}, the object file for | |
1696 | @file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its | |
1697 | assembler file in @file{@var{source}.s}, a precompiled header file in | |
1698 | @file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on | |
1699 | standard output. | |
1700 | ||
1701 | Though @option{-o} names only the primary output, it also affects the | |
1702 | naming of auxiliary and dump outputs. See the examples below. Unless | |
1703 | overridden, both auxiliary outputs and dump outputs are placed in the | |
1704 | same directory as the primary output. In auxiliary outputs, the suffix | |
1705 | of the input file is replaced with that of the auxiliary output file | |
1706 | type; in dump outputs, the suffix of the dump file is appended to the | |
1707 | input file suffix. In compilation commands, the base name of both | |
1708 | auxiliary and dump outputs is that of the primary output; in compile and | |
1709 | link commands, the primary output name, minus the executable suffix, is | |
1710 | combined with the input file name. If both share the same base name, | |
1711 | disregarding the suffix, the result of the combination is that base | |
1712 | name, otherwise, they are concatenated, separated by a dash. | |
1713 | ||
1714 | @smallexample | |
1715 | gcc -c foo.c ... | |
1716 | @end smallexample | |
1717 | ||
1718 | will use @file{foo.o} as the primary output, and place aux outputs and | |
1719 | dumps next to it, e.g., aux file @file{foo.dwo} for | |
1720 | @option{-gsplit-dwarf}, and dump file @file{foo.c.???r.final} for | |
1721 | @option{-fdump-rtl-final}. | |
1722 | ||
1723 | If a non-linker output file is explicitly specified, aux and dump files | |
1724 | by default take the same base name: | |
1725 | ||
1726 | @smallexample | |
1727 | gcc -c foo.c -o dir/foobar.o ... | |
1728 | @end smallexample | |
1729 | ||
1730 | will name aux outputs @file{dir/foobar.*} and dump outputs | |
1731 | @file{dir/foobar.c.*}. | |
1732 | ||
1733 | A linker output will instead prefix aux and dump outputs: | |
1734 | ||
1735 | @smallexample | |
1736 | gcc foo.c bar.c -o dir/foobar ... | |
1737 | @end smallexample | |
1738 | ||
1739 | will generally name aux outputs @file{dir/foobar-foo.*} and | |
1740 | @file{dir/foobar-bar.*}, and dump outputs @file{dir/foobar-foo.c.*} and | |
1741 | @file{dir/foobar-bar.c.*}. | |
1742 | ||
1743 | The one exception to the above is when the executable shares the base | |
1744 | name with the single input: | |
1745 | ||
1746 | @smallexample | |
1747 | gcc foo.c -o dir/foo ... | |
1748 | @end smallexample | |
1749 | ||
1750 | in which case aux outputs are named @file{dir/foo.*} and dump outputs | |
1751 | named @file{dir/foo.c.*}. | |
1752 | ||
1753 | The location and the names of auxiliary and dump outputs can be adjusted | |
1754 | by the options @option{-dumpbase}, @option{-dumpbase-ext}, | |
1755 | @option{-dumpdir}, @option{-save-temps=cwd}, and | |
1756 | @option{-save-temps=obj}. | |
1757 | ||
1758 | ||
d77de738 | 1759 | @opindex dumpbase |
ddf6fe37 | 1760 | @item -dumpbase @var{dumpbase} |
d77de738 ML |
1761 | This option sets the base name for auxiliary and dump output files. It |
1762 | does not affect the name of the primary output file. Intermediate | |
1763 | outputs, when preserved, are not regarded as primary outputs, but as | |
1764 | auxiliary outputs: | |
1765 | ||
1766 | @smallexample | |
1767 | gcc -save-temps -S foo.c | |
1768 | @end smallexample | |
1769 | ||
1770 | saves the (no longer) temporary preprocessed file in @file{foo.i}, and | |
1771 | then compiles to the (implied) output file @file{foo.s}, whereas: | |
1772 | ||
1773 | @smallexample | |
1774 | gcc -save-temps -dumpbase save-foo -c foo.c | |
1775 | @end smallexample | |
1776 | ||
1777 | preprocesses to in @file{save-foo.i}, compiles to @file{save-foo.s} (now | |
1778 | an intermediate, thus auxiliary output), and then assembles to the | |
1779 | (implied) output file @file{foo.o}. | |
1780 | ||
1781 | Absent this option, dump and aux files take their names from the input | |
1782 | file, or from the (non-linker) output file, if one is explicitly | |
1783 | specified: dump output files (e.g. those requested by @option{-fdump-*} | |
1784 | options) with the input name suffix, and aux output files (those | |
1785 | requested by other non-dump options, e.g. @code{-save-temps}, | |
1786 | @code{-gsplit-dwarf}, @code{-fcallgraph-info}) without it. | |
1787 | ||
1788 | Similar suffix differentiation of dump and aux outputs can be attained | |
1789 | for explicitly-given @option{-dumpbase basename.suf} by also specifying | |
1790 | @option{-dumpbase-ext .suf}. | |
1791 | ||
1792 | If @var{dumpbase} is explicitly specified with any directory component, | |
1793 | any @var{dumppfx} specification (e.g. @option{-dumpdir} or | |
1794 | @option{-save-temps=*}) is ignored, and instead of appending to it, | |
1795 | @var{dumpbase} fully overrides it: | |
1796 | ||
1797 | @smallexample | |
1798 | gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \ | |
1799 | -dumpdir pfx- -save-temps=cwd ... | |
1800 | @end smallexample | |
1801 | ||
1802 | creates auxiliary and dump outputs named @file{alt/foo.*}, disregarding | |
1803 | @file{dir/} in @option{-o}, the @file{./} prefix implied by | |
1804 | @option{-save-temps=cwd}, and @file{pfx-} in @option{-dumpdir}. | |
1805 | ||
1806 | When @option{-dumpbase} is specified in a command that compiles multiple | |
1807 | inputs, or that compiles and then links, it may be combined with | |
1808 | @var{dumppfx}, as specified under @option{-dumpdir}. Then, each input | |
1809 | file is compiled using the combined @var{dumppfx}, and default values | |
1810 | for @var{dumpbase} and @var{auxdropsuf} are computed for each input | |
1811 | file: | |
1812 | ||
1813 | @smallexample | |
1814 | gcc foo.c bar.c -c -dumpbase main ... | |
1815 | @end smallexample | |
1816 | ||
1817 | creates @file{foo.o} and @file{bar.o} as primary outputs, and avoids | |
1818 | overwriting the auxiliary and dump outputs by using the @var{dumpbase} | |
1819 | as a prefix, creating auxiliary and dump outputs named @file{main-foo.*} | |
1820 | and @file{main-bar.*}. | |
1821 | ||
1822 | An empty string specified as @var{dumpbase} avoids the influence of the | |
1823 | output basename in the naming of auxiliary and dump outputs during | |
1824 | compilation, computing default values : | |
1825 | ||
1826 | @smallexample | |
1827 | gcc -c foo.c -o dir/foobar.o -dumpbase '' ... | |
1828 | @end smallexample | |
1829 | ||
1830 | will name aux outputs @file{dir/foo.*} and dump outputs | |
1831 | @file{dir/foo.c.*}. Note how their basenames are taken from the input | |
1832 | name, but the directory still defaults to that of the output. | |
1833 | ||
1834 | The empty-string dumpbase does not prevent the use of the output | |
1835 | basename for outputs during linking: | |
1836 | ||
1837 | @smallexample | |
1838 | gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ... | |
1839 | @end smallexample | |
1840 | ||
1841 | The compilation of the source files will name auxiliary outputs | |
1842 | @file{dir/foo.*} and @file{dir/bar.*}, and dump outputs | |
1843 | @file{dir/foo.c.*} and @file{dir/bar.c.*}. LTO recompilation during | |
1844 | linking will use @file{dir/foobar.} as the prefix for dumps and | |
1845 | auxiliary files. | |
1846 | ||
1847 | ||
d77de738 | 1848 | @opindex dumpbase-ext |
ddf6fe37 | 1849 | @item -dumpbase-ext @var{auxdropsuf} |
d77de738 ML |
1850 | When forming the name of an auxiliary (but not a dump) output file, drop |
1851 | trailing @var{auxdropsuf} from @var{dumpbase} before appending any | |
1852 | suffixes. If not specified, this option defaults to the suffix of a | |
1853 | default @var{dumpbase}, i.e., the suffix of the input file when | |
1854 | @option{-dumpbase} is not present in the command line, or @var{dumpbase} | |
1855 | is combined with @var{dumppfx}. | |
1856 | ||
1857 | @smallexample | |
1858 | gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ... | |
1859 | @end smallexample | |
1860 | ||
1861 | creates @file{dir/foo.o} as the main output, and generates auxiliary | |
1862 | outputs in @file{dir/x-foo.*}, taking the location of the primary | |
1863 | output, and dropping the @file{.c} suffix from the @var{dumpbase}. Dump | |
1864 | outputs retain the suffix: @file{dir/x-foo.c.*}. | |
1865 | ||
1866 | This option is disregarded if it does not match the suffix of a | |
1867 | specified @var{dumpbase}, except as an alternative to the executable | |
1868 | suffix when appending the linker output base name to @var{dumppfx}, as | |
1869 | specified below: | |
1870 | ||
1871 | @smallexample | |
1872 | gcc foo.c bar.c -o main.out -dumpbase-ext .out ... | |
1873 | @end smallexample | |
1874 | ||
1875 | creates @file{main.out} as the primary output, and avoids overwriting | |
1876 | the auxiliary and dump outputs by using the executable name minus | |
1877 | @var{auxdropsuf} as a prefix, creating auxiliary outputs named | |
1878 | @file{main-foo.*} and @file{main-bar.*} and dump outputs named | |
1879 | @file{main-foo.c.*} and @file{main-bar.c.*}. | |
1880 | ||
1881 | ||
d77de738 | 1882 | @opindex dumpdir |
ddf6fe37 | 1883 | @item -dumpdir @var{dumppfx} |
d77de738 ML |
1884 | When forming the name of an auxiliary or dump output file, use |
1885 | @var{dumppfx} as a prefix: | |
1886 | ||
1887 | @smallexample | |
1888 | gcc -dumpdir pfx- -c foo.c ... | |
1889 | @end smallexample | |
1890 | ||
1891 | creates @file{foo.o} as the primary output, and auxiliary outputs named | |
1892 | @file{pfx-foo.*}, combining the given @var{dumppfx} with the default | |
1893 | @var{dumpbase} derived from the default primary output, derived in turn | |
1894 | from the input name. Dump outputs also take the input name suffix: | |
1895 | @file{pfx-foo.c.*}. | |
1896 | ||
1897 | If @var{dumppfx} is to be used as a directory name, it must end with a | |
1898 | directory separator: | |
1899 | ||
1900 | @smallexample | |
1901 | gcc -dumpdir dir/ -c foo.c -o obj/bar.o ... | |
1902 | @end smallexample | |
1903 | ||
1904 | creates @file{obj/bar.o} as the primary output, and auxiliary outputs | |
1905 | named @file{dir/bar.*}, combining the given @var{dumppfx} with the | |
1906 | default @var{dumpbase} derived from the primary output name. Dump | |
1907 | outputs also take the input name suffix: @file{dir/bar.c.*}. | |
1908 | ||
1909 | It defaults to the location of the output file, unless the output | |
1910 | file is a special file like @code{/dev/null}. Options | |
1911 | @option{-save-temps=cwd} and @option{-save-temps=obj} override this | |
1912 | default, just like an explicit @option{-dumpdir} option. In case | |
1913 | multiple such options are given, the last one prevails: | |
1914 | ||
1915 | @smallexample | |
1916 | gcc -dumpdir pfx- -c foo.c -save-temps=obj ... | |
1917 | @end smallexample | |
1918 | ||
1919 | outputs @file{foo.o}, with auxiliary outputs named @file{foo.*} because | |
1920 | @option{-save-temps=*} overrides the @var{dumppfx} given by the earlier | |
1921 | @option{-dumpdir} option. It does not matter that @option{=obj} is the | |
1922 | default for @option{-save-temps}, nor that the output directory is | |
1923 | implicitly the current directory. Dump outputs are named | |
1924 | @file{foo.c.*}. | |
1925 | ||
1926 | When compiling from multiple input files, if @option{-dumpbase} is | |
1927 | specified, @var{dumpbase}, minus a @var{auxdropsuf} suffix, and a dash | |
1928 | are appended to (or override, if containing any directory components) an | |
1929 | explicit or defaulted @var{dumppfx}, so that each of the multiple | |
1930 | compilations gets differently-named aux and dump outputs. | |
1931 | ||
1932 | @smallexample | |
1933 | gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ... | |
1934 | @end smallexample | |
1935 | ||
1936 | outputs auxiliary dumps to @file{dir/pfx-main-foo.*} and | |
1937 | @file{dir/pfx-main-bar.*}, appending @var{dumpbase}- to @var{dumppfx}. | |
1938 | Dump outputs retain the input file suffix: @file{dir/pfx-main-foo.c.*} | |
1939 | and @file{dir/pfx-main-bar.c.*}, respectively. Contrast with the | |
1940 | single-input compilation: | |
1941 | ||
1942 | @smallexample | |
1943 | gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ... | |
1944 | @end smallexample | |
1945 | ||
1946 | that, applying @option{-dumpbase} to a single source, does not compute | |
1947 | and append a separate @var{dumpbase} per input file. Its auxiliary and | |
1948 | dump outputs go in @file{dir/pfx-main.*}. | |
1949 | ||
1950 | When compiling and then linking from multiple input files, a defaulted | |
1951 | or explicitly specified @var{dumppfx} also undergoes the @var{dumpbase}- | |
1952 | transformation above (e.g. the compilation of @file{foo.c} and | |
1953 | @file{bar.c} above, but without @option{-c}). If neither | |
1954 | @option{-dumpdir} nor @option{-dumpbase} are given, the linker output | |
1955 | base name, minus @var{auxdropsuf}, if specified, or the executable | |
1956 | suffix otherwise, plus a dash is appended to the default @var{dumppfx} | |
1957 | instead. Note, however, that unlike earlier cases of linking: | |
1958 | ||
1959 | @smallexample | |
1960 | gcc foo.c bar.c -dumpdir dir/pfx- -o main ... | |
1961 | @end smallexample | |
1962 | ||
1963 | does not append the output name @file{main} to @var{dumppfx}, because | |
1964 | @option{-dumpdir} is explicitly specified. The goal is that the | |
1965 | explicitly-specified @var{dumppfx} may contain the specified output name | |
1966 | as part of the prefix, if desired; only an explicitly-specified | |
1967 | @option{-dumpbase} would be combined with it, in order to avoid simply | |
1968 | discarding a meaningful option. | |
1969 | ||
1970 | When compiling and then linking from a single input file, the linker | |
1971 | output base name will only be appended to the default @var{dumppfx} as | |
1972 | above if it does not share the base name with the single input file | |
1973 | name. This has been covered in single-input linking cases above, but | |
1974 | not with an explicit @option{-dumpdir} that inhibits the combination, | |
1975 | even if overridden by @option{-save-temps=*}: | |
1976 | ||
1977 | @smallexample | |
1978 | gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ... | |
1979 | @end smallexample | |
1980 | ||
1981 | Auxiliary outputs are named @file{foo.*}, and dump outputs | |
1982 | @file{foo.c.*}, in the current working directory as ultimately requested | |
1983 | by @option{-save-temps=cwd}. | |
1984 | ||
1985 | Summing it all up for an intuitive though slightly imprecise data flow: | |
1986 | the primary output name is broken into a directory part and a basename | |
1987 | part; @var{dumppfx} is set to the former, unless overridden by | |
1988 | @option{-dumpdir} or @option{-save-temps=*}, and @var{dumpbase} is set | |
1989 | to the latter, unless overriden by @option{-dumpbase}. If there are | |
1990 | multiple inputs or linking, this @var{dumpbase} may be combined with | |
1991 | @var{dumppfx} and taken from each input file. Auxiliary output names | |
1992 | for each input are formed by combining @var{dumppfx}, @var{dumpbase} | |
1993 | minus suffix, and the auxiliary output suffix; dump output names are | |
1994 | only different in that the suffix from @var{dumpbase} is retained. | |
1995 | ||
1996 | When it comes to auxiliary and dump outputs created during LTO | |
1997 | recompilation, a combination of @var{dumppfx} and @var{dumpbase}, as | |
1998 | given or as derived from the linker output name but not from inputs, | |
1999 | even in cases in which this combination would not otherwise be used as | |
2000 | such, is passed down with a trailing period replacing the compiler-added | |
2001 | dash, if any, as a @option{-dumpdir} option to @command{lto-wrapper}; | |
2002 | being involved in linking, this program does not normally get any | |
2003 | @option{-dumpbase} and @option{-dumpbase-ext}, and it ignores them. | |
2004 | ||
2005 | When running sub-compilers, @command{lto-wrapper} appends LTO stage | |
2006 | names to the received @var{dumppfx}, ensures it contains a directory | |
2007 | component so that it overrides any @option{-dumpdir}, and passes that as | |
2008 | @option{-dumpbase} to sub-compilers. | |
2009 | ||
d77de738 | 2010 | @opindex v |
ddf6fe37 | 2011 | @item -v |
d77de738 ML |
2012 | Print (on standard error output) the commands executed to run the stages |
2013 | of compilation. Also print the version number of the compiler driver | |
2014 | program and of the preprocessor and the compiler proper. | |
2015 | ||
d77de738 | 2016 | @opindex ### |
ddf6fe37 | 2017 | @item -### |
d77de738 ML |
2018 | Like @option{-v} except the commands are not executed and arguments |
2019 | are quoted unless they contain only alphanumeric characters or @code{./-_}. | |
2020 | This is useful for shell scripts to capture the driver-generated command lines. | |
2021 | ||
d77de738 | 2022 | @opindex help |
ddf6fe37 | 2023 | @item --help |
d77de738 ML |
2024 | Print (on the standard output) a description of the command-line options |
2025 | understood by @command{gcc}. If the @option{-v} option is also specified | |
2026 | then @option{--help} is also passed on to the various processes | |
2027 | invoked by @command{gcc}, so that they can display the command-line options | |
2028 | they accept. If the @option{-Wextra} option has also been specified | |
2029 | (prior to the @option{--help} option), then command-line options that | |
2030 | have no documentation associated with them are also displayed. | |
2031 | ||
d77de738 | 2032 | @opindex target-help |
ddf6fe37 | 2033 | @item --target-help |
d77de738 ML |
2034 | Print (on the standard output) a description of target-specific command-line |
2035 | options for each tool. For some targets extra target-specific | |
2036 | information may also be printed. | |
2037 | ||
2038 | @item --help=@{@var{class}@r{|[}^@r{]}@var{qualifier}@}@r{[},@dots{}@r{]} | |
2039 | Print (on the standard output) a description of the command-line | |
2040 | options understood by the compiler that fit into all specified classes | |
2041 | and qualifiers. These are the supported classes: | |
2042 | ||
2043 | @table @asis | |
2044 | @item @samp{optimizers} | |
2045 | Display all of the optimization options supported by the | |
2046 | compiler. | |
2047 | ||
2048 | @item @samp{warnings} | |
2049 | Display all of the options controlling warning messages | |
2050 | produced by the compiler. | |
2051 | ||
2052 | @item @samp{target} | |
2053 | Display target-specific options. Unlike the | |
2054 | @option{--target-help} option however, target-specific options of the | |
2055 | linker and assembler are not displayed. This is because those | |
2056 | tools do not currently support the extended @option{--help=} syntax. | |
2057 | ||
2058 | @item @samp{params} | |
2059 | Display the values recognized by the @option{--param} | |
2060 | option. | |
2061 | ||
2062 | @item @var{language} | |
2063 | Display the options supported for @var{language}, where | |
2064 | @var{language} is the name of one of the languages supported in this | |
2065 | version of GCC@. If an option is supported by all languages, one needs | |
2066 | to select @samp{common} class. | |
2067 | ||
2068 | @item @samp{common} | |
2069 | Display the options that are common to all languages. | |
2070 | @end table | |
2071 | ||
2072 | These are the supported qualifiers: | |
2073 | ||
2074 | @table @asis | |
2075 | @item @samp{undocumented} | |
2076 | Display only those options that are undocumented. | |
2077 | ||
2078 | @item @samp{joined} | |
2079 | Display options taking an argument that appears after an equal | |
2080 | sign in the same continuous piece of text, such as: | |
2081 | @samp{--help=target}. | |
2082 | ||
2083 | @item @samp{separate} | |
2084 | Display options taking an argument that appears as a separate word | |
2085 | following the original option, such as: @samp{-o output-file}. | |
2086 | @end table | |
2087 | ||
2088 | Thus for example to display all the undocumented target-specific | |
2089 | switches supported by the compiler, use: | |
2090 | ||
2091 | @smallexample | |
2092 | --help=target,undocumented | |
2093 | @end smallexample | |
2094 | ||
2095 | The sense of a qualifier can be inverted by prefixing it with the | |
2096 | @samp{^} character, so for example to display all binary warning | |
2097 | options (i.e., ones that are either on or off and that do not take an | |
2098 | argument) that have a description, use: | |
2099 | ||
2100 | @smallexample | |
2101 | --help=warnings,^joined,^undocumented | |
2102 | @end smallexample | |
2103 | ||
2104 | The argument to @option{--help=} should not consist solely of inverted | |
2105 | qualifiers. | |
2106 | ||
2107 | Combining several classes is possible, although this usually | |
2108 | restricts the output so much that there is nothing to display. One | |
2109 | case where it does work, however, is when one of the classes is | |
2110 | @var{target}. For example, to display all the target-specific | |
2111 | optimization options, use: | |
2112 | ||
2113 | @smallexample | |
2114 | --help=target,optimizers | |
2115 | @end smallexample | |
2116 | ||
2117 | The @option{--help=} option can be repeated on the command line. Each | |
2118 | successive use displays its requested class of options, skipping | |
2119 | those that have already been displayed. If @option{--help} is also | |
2120 | specified anywhere on the command line then this takes precedence | |
2121 | over any @option{--help=} option. | |
2122 | ||
2123 | If the @option{-Q} option appears on the command line before the | |
2124 | @option{--help=} option, then the descriptive text displayed by | |
2125 | @option{--help=} is changed. Instead of describing the displayed | |
2126 | options, an indication is given as to whether the option is enabled, | |
2127 | disabled or set to a specific value (assuming that the compiler | |
2128 | knows this at the point where the @option{--help=} option is used). | |
2129 | ||
2130 | Here is a truncated example from the ARM port of @command{gcc}: | |
2131 | ||
2132 | @smallexample | |
2133 | % gcc -Q -mabi=2 --help=target -c | |
2134 | The following options are target specific: | |
2135 | -mabi= 2 | |
2136 | -mabort-on-noreturn [disabled] | |
2137 | -mapcs [disabled] | |
2138 | @end smallexample | |
2139 | ||
2140 | The output is sensitive to the effects of previous command-line | |
2141 | options, so for example it is possible to find out which optimizations | |
2142 | are enabled at @option{-O2} by using: | |
2143 | ||
2144 | @smallexample | |
2145 | -Q -O2 --help=optimizers | |
2146 | @end smallexample | |
2147 | ||
2148 | Alternatively you can discover which binary optimizations are enabled | |
2149 | by @option{-O3} by using: | |
2150 | ||
2151 | @smallexample | |
2152 | gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts | |
2153 | gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts | |
2154 | diff /tmp/O2-opts /tmp/O3-opts | grep enabled | |
2155 | @end smallexample | |
2156 | ||
d77de738 | 2157 | @opindex version |
ddf6fe37 | 2158 | @item --version |
d77de738 ML |
2159 | Display the version number and copyrights of the invoked GCC@. |
2160 | ||
d77de738 | 2161 | @opindex pass-exit-codes |
ddf6fe37 | 2162 | @item -pass-exit-codes |
d77de738 ML |
2163 | Normally the @command{gcc} program exits with the code of 1 if any |
2164 | phase of the compiler returns a non-success return code. If you specify | |
2165 | @option{-pass-exit-codes}, the @command{gcc} program instead returns with | |
2166 | the numerically highest error produced by any phase returning an error | |
2167 | indication. The C, C++, and Fortran front ends return 4 if an internal | |
2168 | compiler error is encountered. | |
2169 | ||
d77de738 | 2170 | @opindex pipe |
ddf6fe37 | 2171 | @item -pipe |
d77de738 ML |
2172 | Use pipes rather than temporary files for communication between the |
2173 | various stages of compilation. This fails to work on some systems where | |
2174 | the assembler is unable to read from a pipe; but the GNU assembler has | |
2175 | no trouble. | |
2176 | ||
d77de738 | 2177 | @opindex specs |
ddf6fe37 | 2178 | @item -specs=@var{file} |
d77de738 ML |
2179 | Process @var{file} after the compiler reads in the standard @file{specs} |
2180 | file, in order to override the defaults which the @command{gcc} driver | |
2181 | program uses when determining what switches to pass to @command{cc1}, | |
2182 | @command{cc1plus}, @command{as}, @command{ld}, etc. More than one | |
2183 | @option{-specs=@var{file}} can be specified on the command line, and they | |
2184 | are processed in order, from left to right. @xref{Spec Files}, for | |
2185 | information about the format of the @var{file}. | |
2186 | ||
d77de738 | 2187 | @opindex wrapper |
ddf6fe37 | 2188 | @item -wrapper |
d77de738 ML |
2189 | Invoke all subcommands under a wrapper program. The name of the |
2190 | wrapper program and its parameters are passed as a comma separated | |
2191 | list. | |
2192 | ||
2193 | @smallexample | |
2194 | gcc -c t.c -wrapper gdb,--args | |
2195 | @end smallexample | |
2196 | ||
2197 | @noindent | |
2198 | This invokes all subprograms of @command{gcc} under | |
2199 | @samp{gdb --args}, thus the invocation of @command{cc1} is | |
2200 | @samp{gdb --args cc1 @dots{}}. | |
2201 | ||
d77de738 | 2202 | @opindex ffile-prefix-map |
ddf6fe37 | 2203 | @item -ffile-prefix-map=@var{old}=@var{new} |
d77de738 ML |
2204 | When compiling files residing in directory @file{@var{old}}, record |
2205 | any references to them in the result of the compilation as if the | |
2206 | files resided in directory @file{@var{new}} instead. Specifying this | |
2207 | option is equivalent to specifying all the individual | |
2208 | @option{-f*-prefix-map} options. This can be used to make reproducible | |
11543b27 | 2209 | builds that are location independent. Directories referenced by |
2eb0191a JJ |
2210 | directives are not affected by these options. See also |
2211 | @option{-fmacro-prefix-map}, @option{-fdebug-prefix-map}, | |
2212 | @option{-fprofile-prefix-map} and @option{-fcanon-prefix-map}. | |
2213 | ||
2eb0191a | 2214 | @opindex fcanon-prefix-map |
e54b01a1 | 2215 | @item -fcanon-prefix-map |
2eb0191a JJ |
2216 | For the @option{-f*-prefix-map} options normally comparison |
2217 | of @file{@var{old}} prefix against the filename that would be normally | |
2218 | referenced in the result of the compilation is done using textual | |
2219 | comparison of the prefixes, or ignoring character case for case insensitive | |
2220 | filesystems and considering slashes and backslashes as equal on DOS based | |
2221 | filesystems. The @option{-fcanon-prefix-map} causes such comparisons | |
2222 | to be done on canonicalized paths of @file{@var{old}} | |
2223 | and the referenced filename. | |
d77de738 | 2224 | |
d77de738 | 2225 | @opindex fplugin |
ddf6fe37 | 2226 | @item -fplugin=@var{name}.so |
d77de738 ML |
2227 | Load the plugin code in file @var{name}.so, assumed to be a |
2228 | shared object to be dlopen'd by the compiler. The base name of | |
2229 | the shared object file is used to identify the plugin for the | |
2230 | purposes of argument parsing (See | |
2231 | @option{-fplugin-arg-@var{name}-@var{key}=@var{value}} below). | |
2232 | Each plugin should define the callback functions specified in the | |
2233 | Plugins API. | |
2234 | ||
d77de738 | 2235 | @opindex fplugin-arg |
ddf6fe37 | 2236 | @item -fplugin-arg-@var{name}-@var{key}=@var{value} |
d77de738 ML |
2237 | Define an argument called @var{key} with a value of @var{value} |
2238 | for the plugin called @var{name}. | |
2239 | ||
d77de738 | 2240 | @opindex fdump-ada-spec |
ddf6fe37 | 2241 | @item -fdump-ada-spec@r{[}-slim@r{]} |
d77de738 ML |
2242 | For C and C++ source and include files, generate corresponding Ada specs. |
2243 | @xref{Generating Ada Bindings for C and C++ headers,,, gnat_ugn, | |
2244 | GNAT User's Guide}, which provides detailed documentation on this feature. | |
2245 | ||
d77de738 | 2246 | @opindex fada-spec-parent |
ddf6fe37 | 2247 | @item -fada-spec-parent=@var{unit} |
d77de738 ML |
2248 | In conjunction with @option{-fdump-ada-spec@r{[}-slim@r{]}} above, generate |
2249 | Ada specs as child units of parent @var{unit}. | |
2250 | ||
d77de738 | 2251 | @opindex fdump-go-spec |
ddf6fe37 | 2252 | @item -fdump-go-spec=@var{file} |
d77de738 ML |
2253 | For input files in any language, generate corresponding Go |
2254 | declarations in @var{file}. This generates Go @code{const}, | |
2255 | @code{type}, @code{var}, and @code{func} declarations which may be a | |
2256 | useful way to start writing a Go interface to code written in some | |
2257 | other language. | |
2258 | ||
2259 | @include @value{srcdir}/../libiberty/at-file.texi | |
2260 | @end table | |
2261 | ||
2262 | @node Invoking G++ | |
2263 | @section Compiling C++ Programs | |
2264 | ||
2265 | @cindex suffixes for C++ source | |
2266 | @cindex C++ source file suffixes | |
2267 | C++ source files conventionally use one of the suffixes @samp{.C}, | |
2268 | @samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or | |
2269 | @samp{.cxx}; C++ header files often use @samp{.hh}, @samp{.hpp}, | |
2270 | @samp{.H}, or (for shared template code) @samp{.tcc}; and | |
2271 | preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes | |
2272 | files with these names and compiles them as C++ programs even if you | |
2273 | call the compiler the same way as for compiling C programs (usually | |
2274 | with the name @command{gcc}). | |
2275 | ||
2276 | @findex g++ | |
2277 | @findex c++ | |
2278 | However, the use of @command{gcc} does not add the C++ library. | |
2279 | @command{g++} is a program that calls GCC and automatically specifies linking | |
2280 | against the C++ library. It treats @samp{.c}, | |
2281 | @samp{.h} and @samp{.i} files as C++ source files instead of C source | |
2282 | files unless @option{-x} is used. This program is also useful when | |
2283 | precompiling a C header file with a @samp{.h} extension for use in C++ | |
2284 | compilations. On many systems, @command{g++} is also installed with | |
2285 | the name @command{c++}. | |
2286 | ||
2287 | @cindex invoking @command{g++} | |
2288 | When you compile C++ programs, you may specify many of the same | |
2289 | command-line options that you use for compiling programs in any | |
2290 | language; or command-line options meaningful for C and related | |
2291 | languages; or options that are meaningful only for C++ programs. | |
2292 | @xref{C Dialect Options,,Options Controlling C Dialect}, for | |
2293 | explanations of options for languages related to C@. | |
2294 | @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for | |
2295 | explanations of options that are meaningful only for C++ programs. | |
2296 | ||
2297 | @node C Dialect Options | |
2298 | @section Options Controlling C Dialect | |
2299 | @cindex dialect options | |
2300 | @cindex language dialect options | |
2301 | @cindex options, dialect | |
2302 | ||
2303 | The following options control the dialect of C (or languages derived | |
2304 | from C, such as C++, Objective-C and Objective-C++) that the compiler | |
2305 | accepts: | |
2306 | ||
2307 | @table @gcctabopt | |
2308 | @cindex ANSI support | |
2309 | @cindex ISO support | |
d77de738 | 2310 | @opindex ansi |
ddf6fe37 | 2311 | @item -ansi |
d77de738 ML |
2312 | In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is |
2313 | equivalent to @option{-std=c++98}. | |
2314 | ||
2315 | This turns off certain features of GCC that are incompatible with ISO | |
2316 | C90 (when compiling C code), or of standard C++ (when compiling C++ code), | |
2317 | such as the @code{asm} and @code{typeof} keywords, and | |
2318 | predefined macros such as @code{unix} and @code{vax} that identify the | |
2319 | type of system you are using. It also enables the undesirable and | |
2320 | rarely used ISO trigraph feature. For the C compiler, | |
2321 | it disables recognition of C++ style @samp{//} comments as well as | |
2322 | the @code{inline} keyword. | |
2323 | ||
2324 | The alternate keywords @code{__asm__}, @code{__extension__}, | |
2325 | @code{__inline__} and @code{__typeof__} continue to work despite | |
2326 | @option{-ansi}. You would not want to use them in an ISO C program, of | |
2327 | course, but it is useful to put them in header files that might be included | |
2328 | in compilations done with @option{-ansi}. Alternate predefined macros | |
2329 | such as @code{__unix__} and @code{__vax__} are also available, with or | |
2330 | without @option{-ansi}. | |
2331 | ||
2332 | The @option{-ansi} option does not cause non-ISO programs to be | |
2333 | rejected gratuitously. For that, @option{-Wpedantic} is required in | |
2334 | addition to @option{-ansi}. @xref{Warning Options}. | |
2335 | ||
2336 | The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi} | |
2337 | option is used. Some header files may notice this macro and refrain | |
2338 | from declaring certain functions or defining certain macros that the | |
2339 | ISO standard doesn't call for; this is to avoid interfering with any | |
2340 | programs that might use these names for other things. | |
2341 | ||
2342 | Functions that are normally built in but do not have semantics | |
2343 | defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in | |
2344 | functions when @option{-ansi} is used. @xref{Other Builtins,,Other | |
2345 | built-in functions provided by GCC}, for details of the functions | |
2346 | affected. | |
2347 | ||
d77de738 | 2348 | @opindex std |
ddf6fe37 | 2349 | @item -std= |
d77de738 ML |
2350 | Determine the language standard. @xref{Standards,,Language Standards |
2351 | Supported by GCC}, for details of these standard versions. This option | |
2352 | is currently only supported when compiling C or C++. | |
2353 | ||
2354 | The compiler can accept several base standards, such as @samp{c90} or | |
2355 | @samp{c++98}, and GNU dialects of those standards, such as | |
2356 | @samp{gnu90} or @samp{gnu++98}. When a base standard is specified, the | |
2357 | compiler accepts all programs following that standard plus those | |
2358 | using GNU extensions that do not contradict it. For example, | |
2359 | @option{-std=c90} turns off certain features of GCC that are | |
2360 | incompatible with ISO C90, such as the @code{asm} and @code{typeof} | |
2361 | keywords, but not other GNU extensions that do not have a meaning in | |
2362 | ISO C90, such as omitting the middle term of a @code{?:} | |
2363 | expression. On the other hand, when a GNU dialect of a standard is | |
2364 | specified, all features supported by the compiler are enabled, even when | |
2365 | those features change the meaning of the base standard. As a result, some | |
2366 | strict-conforming programs may be rejected. The particular standard | |
2367 | is used by @option{-Wpedantic} to identify which features are GNU | |
2368 | extensions given that version of the standard. For example | |
2369 | @option{-std=gnu90 -Wpedantic} warns about C++ style @samp{//} | |
2370 | comments, while @option{-std=gnu99 -Wpedantic} does not. | |
2371 | ||
2372 | A value for this option must be provided; possible values are | |
2373 | ||
2374 | @table @samp | |
2375 | @item c90 | |
2376 | @itemx c89 | |
2377 | @itemx iso9899:1990 | |
2378 | Support all ISO C90 programs (certain GNU extensions that conflict | |
2379 | with ISO C90 are disabled). Same as @option{-ansi} for C code. | |
2380 | ||
2381 | @item iso9899:199409 | |
2382 | ISO C90 as modified in amendment 1. | |
2383 | ||
2384 | @item c99 | |
2385 | @itemx c9x | |
2386 | @itemx iso9899:1999 | |
2387 | @itemx iso9899:199x | |
2388 | ISO C99. This standard is substantially completely supported, modulo | |
2389 | bugs and floating-point issues | |
2390 | (mainly but not entirely relating to optional C99 features from | |
2391 | Annexes F and G). See | |
2392 | @w{@uref{https://gcc.gnu.org/c99status.html}} for more information. The | |
2393 | names @samp{c9x} and @samp{iso9899:199x} are deprecated. | |
2394 | ||
2395 | @item c11 | |
2396 | @itemx c1x | |
2397 | @itemx iso9899:2011 | |
2398 | ISO C11, the 2011 revision of the ISO C standard. This standard is | |
2399 | substantially completely supported, modulo bugs, floating-point issues | |
2400 | (mainly but not entirely relating to optional C11 features from | |
2401 | Annexes F and G) and the optional Annexes K (Bounds-checking | |
2402 | interfaces) and L (Analyzability). The name @samp{c1x} is deprecated. | |
2403 | ||
2404 | @item c17 | |
2405 | @itemx c18 | |
2406 | @itemx iso9899:2017 | |
2407 | @itemx iso9899:2018 | |
2408 | ISO C17, the 2017 revision of the ISO C standard | |
2409 | (published in 2018). This standard is | |
2410 | same as C11 except for corrections of defects (all of which are also | |
2411 | applied with @option{-std=c11}) and a new value of | |
2412 | @code{__STDC_VERSION__}, and so is supported to the same extent as C11. | |
2413 | ||
2414 | @item c2x | |
2415 | The next version of the ISO C standard, still under development. The | |
2416 | support for this version is experimental and incomplete. | |
2417 | ||
2418 | @item gnu90 | |
2419 | @itemx gnu89 | |
2420 | GNU dialect of ISO C90 (including some C99 features). | |
2421 | ||
2422 | @item gnu99 | |
2423 | @itemx gnu9x | |
2424 | GNU dialect of ISO C99. The name @samp{gnu9x} is deprecated. | |
2425 | ||
2426 | @item gnu11 | |
2427 | @itemx gnu1x | |
2428 | GNU dialect of ISO C11. | |
2429 | The name @samp{gnu1x} is deprecated. | |
2430 | ||
2431 | @item gnu17 | |
2432 | @itemx gnu18 | |
2433 | GNU dialect of ISO C17. This is the default for C code. | |
2434 | ||
2435 | @item gnu2x | |
2436 | The next version of the ISO C standard, still under development, plus | |
2437 | GNU extensions. The support for this version is experimental and | |
2438 | incomplete. | |
2439 | ||
2440 | @item c++98 | |
2441 | @itemx c++03 | |
2442 | The 1998 ISO C++ standard plus the 2003 technical corrigendum and some | |
2443 | additional defect reports. Same as @option{-ansi} for C++ code. | |
2444 | ||
2445 | @item gnu++98 | |
2446 | @itemx gnu++03 | |
2447 | GNU dialect of @option{-std=c++98}. | |
2448 | ||
2449 | @item c++11 | |
2450 | @itemx c++0x | |
2451 | The 2011 ISO C++ standard plus amendments. | |
2452 | The name @samp{c++0x} is deprecated. | |
2453 | ||
2454 | @item gnu++11 | |
2455 | @itemx gnu++0x | |
2456 | GNU dialect of @option{-std=c++11}. | |
2457 | The name @samp{gnu++0x} is deprecated. | |
2458 | ||
2459 | @item c++14 | |
2460 | @itemx c++1y | |
2461 | The 2014 ISO C++ standard plus amendments. | |
2462 | The name @samp{c++1y} is deprecated. | |
2463 | ||
2464 | @item gnu++14 | |
2465 | @itemx gnu++1y | |
2466 | GNU dialect of @option{-std=c++14}. | |
2467 | The name @samp{gnu++1y} is deprecated. | |
2468 | ||
2469 | @item c++17 | |
2470 | @itemx c++1z | |
2471 | The 2017 ISO C++ standard plus amendments. | |
2472 | The name @samp{c++1z} is deprecated. | |
2473 | ||
2474 | @item gnu++17 | |
2475 | @itemx gnu++1z | |
2476 | GNU dialect of @option{-std=c++17}. | |
2477 | This is the default for C++ code. | |
2478 | The name @samp{gnu++1z} is deprecated. | |
2479 | ||
2480 | @item c++20 | |
2481 | @itemx c++2a | |
2482 | The 2020 ISO C++ standard plus amendments. | |
2483 | Support is experimental, and could change in incompatible ways in | |
2484 | future releases. | |
2485 | The name @samp{c++2a} is deprecated. | |
2486 | ||
2487 | @item gnu++20 | |
2488 | @itemx gnu++2a | |
2489 | GNU dialect of @option{-std=c++20}. | |
2490 | Support is experimental, and could change in incompatible ways in | |
2491 | future releases. | |
2492 | The name @samp{gnu++2a} is deprecated. | |
2493 | ||
2494 | @item c++2b | |
2495 | @itemx c++23 | |
2496 | The next revision of the ISO C++ standard, planned for | |
2497 | 2023. Support is highly experimental, and will almost certainly | |
2498 | change in incompatible ways in future releases. | |
2499 | ||
2500 | @item gnu++2b | |
2501 | @itemx gnu++23 | |
2502 | GNU dialect of @option{-std=c++2b}. Support is highly experimental, | |
2503 | and will almost certainly change in incompatible ways in future | |
2504 | releases. | |
2505 | @end table | |
2506 | ||
d77de738 | 2507 | @opindex aux-info |
ddf6fe37 | 2508 | @item -aux-info @var{filename} |
d77de738 ML |
2509 | Output to the given filename prototyped declarations for all functions |
2510 | declared and/or defined in a translation unit, including those in header | |
2511 | files. This option is silently ignored in any language other than C@. | |
2512 | ||
2513 | Besides declarations, the file indicates, in comments, the origin of | |
2514 | each declaration (source file and line), whether the declaration was | |
2515 | implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or | |
2516 | @samp{O} for old, respectively, in the first character after the line | |
2517 | number and the colon), and whether it came from a declaration or a | |
2518 | definition (@samp{C} or @samp{F}, respectively, in the following | |
2519 | character). In the case of function definitions, a K&R-style list of | |
2520 | arguments followed by their declarations is also provided, inside | |
2521 | comments, after the declaration. | |
2522 | ||
d77de738 ML |
2523 | @opindex fno-asm |
2524 | @opindex fasm | |
ddf6fe37 | 2525 | @item -fno-asm |
d77de738 ML |
2526 | Do not recognize @code{asm}, @code{inline} or @code{typeof} as a |
2527 | keyword, so that code can use these words as identifiers. You can use | |
2528 | the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__} | |
2529 | instead. In C, @option{-ansi} implies @option{-fno-asm}. | |
2530 | ||
2531 | In C++, @code{inline} is a standard keyword and is not affected by | |
2532 | this switch. You may want to use the @option{-fno-gnu-keywords} flag | |
2533 | instead, which disables @code{typeof} but not @code{asm} and | |
2534 | @code{inline}. In C99 mode (@option{-std=c99} or @option{-std=gnu99}), | |
2535 | this switch only affects the @code{asm} and @code{typeof} keywords, | |
2536 | since @code{inline} is a standard keyword in ISO C99. In C2X mode | |
2537 | (@option{-std=c2x} or @option{-std=gnu2x}), this switch only affects | |
2538 | the @code{asm} keyword, since @code{typeof} is a standard keyword in | |
2539 | ISO C2X. | |
2540 | ||
d77de738 ML |
2541 | @opindex fno-builtin |
2542 | @opindex fbuiltin | |
f33d7a88 | 2543 | @cindex built-in functions |
ddf6fe37 AA |
2544 | @item -fno-builtin |
2545 | @itemx -fno-builtin-@var{function} | |
d77de738 ML |
2546 | Don't recognize built-in functions that do not begin with |
2547 | @samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in | |
2548 | functions provided by GCC}, for details of the functions affected, | |
2549 | including those which are not built-in functions when @option{-ansi} or | |
2550 | @option{-std} options for strict ISO C conformance are used because they | |
2551 | do not have an ISO standard meaning. | |
2552 | ||
2553 | GCC normally generates special code to handle certain built-in functions | |
2554 | more efficiently; for instance, calls to @code{alloca} may become single | |
2555 | instructions which adjust the stack directly, and calls to @code{memcpy} | |
2556 | may become inline copy loops. The resulting code is often both smaller | |
2557 | and faster, but since the function calls no longer appear as such, you | |
2558 | cannot set a breakpoint on those calls, nor can you change the behavior | |
2559 | of the functions by linking with a different library. In addition, | |
2560 | when a function is recognized as a built-in function, GCC may use | |
2561 | information about that function to warn about problems with calls to | |
2562 | that function, or to generate more efficient code, even if the | |
2563 | resulting code still contains calls to that function. For example, | |
2564 | warnings are given with @option{-Wformat} for bad calls to | |
2565 | @code{printf} when @code{printf} is built in and @code{strlen} is | |
2566 | known not to modify global memory. | |
2567 | ||
2568 | With the @option{-fno-builtin-@var{function}} option | |
2569 | only the built-in function @var{function} is | |
2570 | disabled. @var{function} must not begin with @samp{__builtin_}. If a | |
2571 | function is named that is not built-in in this version of GCC, this | |
2572 | option is ignored. There is no corresponding | |
2573 | @option{-fbuiltin-@var{function}} option; if you wish to enable | |
2574 | built-in functions selectively when using @option{-fno-builtin} or | |
2575 | @option{-ffreestanding}, you may define macros such as: | |
2576 | ||
2577 | @smallexample | |
2578 | #define abs(n) __builtin_abs ((n)) | |
2579 | #define strcpy(d, s) __builtin_strcpy ((d), (s)) | |
2580 | @end smallexample | |
2581 | ||
d77de738 | 2582 | @opindex fcond-mismatch |
ddf6fe37 | 2583 | @item -fcond-mismatch |
d77de738 ML |
2584 | Allow conditional expressions with mismatched types in the second and |
2585 | third arguments. The value of such an expression is void. This option | |
2586 | is not supported for C++. | |
2587 | ||
d77de738 ML |
2588 | @opindex ffreestanding |
2589 | @cindex hosted environment | |
f33d7a88 | 2590 | @item -ffreestanding |
d77de738 ML |
2591 | |
2592 | Assert that compilation targets a freestanding environment. This | |
2593 | implies @option{-fno-builtin}. A freestanding environment | |
2594 | is one in which the standard library may not exist, and program startup may | |
2595 | not necessarily be at @code{main}. The most obvious example is an OS kernel. | |
2596 | This is equivalent to @option{-fno-hosted}. | |
2597 | ||
2598 | @xref{Standards,,Language Standards Supported by GCC}, for details of | |
2599 | freestanding and hosted environments. | |
2600 | ||
d77de738 | 2601 | @opindex fgimple |
ddf6fe37 | 2602 | @item -fgimple |
d77de738 ML |
2603 | |
2604 | Enable parsing of function definitions marked with @code{__GIMPLE}. | |
2605 | This is an experimental feature that allows unit testing of GIMPLE | |
2606 | passes. | |
2607 | ||
d77de738 | 2608 | @opindex fgnu-tm |
ddf6fe37 | 2609 | @item -fgnu-tm |
d77de738 ML |
2610 | When the option @option{-fgnu-tm} is specified, the compiler |
2611 | generates code for the Linux variant of Intel's current Transactional | |
2612 | Memory ABI specification document (Revision 1.1, May 6 2009). This is | |
2613 | an experimental feature whose interface may change in future versions | |
2614 | of GCC, as the official specification changes. Please note that not | |
2615 | all architectures are supported for this feature. | |
2616 | ||
2617 | For more information on GCC's support for transactional memory, | |
2618 | @xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU | |
2619 | Transactional Memory Library}. | |
2620 | ||
2621 | Note that the transactional memory feature is not supported with | |
2622 | non-call exceptions (@option{-fnon-call-exceptions}). | |
2623 | ||
d77de738 | 2624 | @opindex fgnu89-inline |
ddf6fe37 | 2625 | @item -fgnu89-inline |
d77de738 ML |
2626 | The option @option{-fgnu89-inline} tells GCC to use the traditional |
2627 | GNU semantics for @code{inline} functions when in C99 mode. | |
2628 | @xref{Inline,,An Inline Function is As Fast As a Macro}. | |
2629 | Using this option is roughly equivalent to adding the | |
2630 | @code{gnu_inline} function attribute to all inline functions | |
2631 | (@pxref{Function Attributes}). | |
2632 | ||
2633 | The option @option{-fno-gnu89-inline} explicitly tells GCC to use the | |
2634 | C99 semantics for @code{inline} when in C99 or gnu99 mode (i.e., it | |
2635 | specifies the default behavior). | |
2636 | This option is not supported in @option{-std=c90} or | |
2637 | @option{-std=gnu90} mode. | |
2638 | ||
2639 | The preprocessor macros @code{__GNUC_GNU_INLINE__} and | |
2640 | @code{__GNUC_STDC_INLINE__} may be used to check which semantics are | |
2641 | in effect for @code{inline} functions. @xref{Common Predefined | |
2642 | Macros,,,cpp,The C Preprocessor}. | |
2643 | ||
d77de738 ML |
2644 | @opindex fhosted |
2645 | @cindex hosted environment | |
f33d7a88 | 2646 | @item -fhosted |
d77de738 ML |
2647 | |
2648 | Assert that compilation targets a hosted environment. This implies | |
2649 | @option{-fbuiltin}. A hosted environment is one in which the | |
2650 | entire standard library is available, and in which @code{main} has a return | |
2651 | type of @code{int}. Examples are nearly everything except a kernel. | |
2652 | This is equivalent to @option{-fno-freestanding}. | |
2653 | ||
d77de738 | 2654 | @opindex flax-vector-conversions |
ddf6fe37 | 2655 | @item -flax-vector-conversions |
d77de738 ML |
2656 | Allow implicit conversions between vectors with differing numbers of |
2657 | elements and/or incompatible element types. This option should not be | |
2658 | used for new code. | |
2659 | ||
d77de738 | 2660 | @opindex fms-extensions |
ddf6fe37 | 2661 | @item -fms-extensions |
d77de738 ML |
2662 | Accept some non-standard constructs used in Microsoft header files. |
2663 | ||
2664 | In C++ code, this allows member names in structures to be similar | |
2665 | to previous types declarations. | |
2666 | ||
2667 | @smallexample | |
2668 | typedef int UOW; | |
2669 | struct ABC @{ | |
2670 | UOW UOW; | |
2671 | @}; | |
2672 | @end smallexample | |
2673 | ||
2674 | Some cases of unnamed fields in structures and unions are only | |
2675 | accepted with this option. @xref{Unnamed Fields,,Unnamed struct/union | |
2676 | fields within structs/unions}, for details. | |
2677 | ||
2678 | Note that this option is off for all targets except for x86 | |
2679 | targets using ms-abi. | |
2680 | ||
ddf6fe37 | 2681 | @opindex foffload |
d77de738 ML |
2682 | @cindex Offloading targets |
2683 | @cindex OpenACC offloading targets | |
2684 | @cindex OpenMP offloading targets | |
f33d7a88 AA |
2685 | @item -foffload=disable |
2686 | @itemx -foffload=default | |
2687 | @itemx -foffload=@var{target-list} | |
d77de738 ML |
2688 | Specify for which OpenMP and OpenACC offload targets code should be generated. |
2689 | The default behavior, equivalent to @option{-foffload=default}, is to generate | |
2690 | code for all supported offload targets. The @option{-foffload=disable} form | |
2691 | generates code only for the host fallback, while | |
2692 | @option{-foffload=@var{target-list}} generates code only for the specified | |
2693 | comma-separated list of offload targets. | |
2694 | ||
2695 | Offload targets are specified in GCC's internal target-triplet format. You can | |
2696 | run the compiler with @option{-v} to show the list of configured offload targets | |
2697 | under @code{OFFLOAD_TARGET_NAMES}. | |
2698 | ||
ddf6fe37 | 2699 | @opindex foffload-options |
d77de738 ML |
2700 | @cindex Offloading options |
2701 | @cindex OpenACC offloading options | |
2702 | @cindex OpenMP offloading options | |
f33d7a88 AA |
2703 | @item -foffload-options=@var{options} |
2704 | @itemx -foffload-options=@var{target-triplet-list}=@var{options} | |
d77de738 ML |
2705 | |
2706 | With @option{-foffload-options=@var{options}}, GCC passes the specified | |
2707 | @var{options} to the compilers for all enabled offloading targets. You can | |
2708 | specify options that apply only to a specific target or targets by using | |
2709 | the @option{-foffload-options=@var{target-list}=@var{options}} form. The | |
2710 | @var{target-list} is a comma-separated list in the same format as for the | |
2711 | @option{-foffload=} option. | |
2712 | ||
2713 | Typical command lines are | |
2714 | ||
2715 | @smallexample | |
2716 | -foffload-options=-lgfortran -foffload-options=-lm | |
2717 | -foffload-options="-lgfortran -lm" -foffload-options=nvptx-none=-latomic | |
2718 | -foffload-options=amdgcn-amdhsa=-march=gfx906 -foffload-options=-lm | |
2719 | @end smallexample | |
2720 | ||
d77de738 ML |
2721 | @opindex fopenacc |
2722 | @cindex OpenACC accelerator programming | |
f33d7a88 | 2723 | @item -fopenacc |
d77de738 ML |
2724 | Enable handling of OpenACC directives @code{#pragma acc} in C/C++ and |
2725 | @code{!$acc} in Fortran. When @option{-fopenacc} is specified, the | |
2726 | compiler generates accelerated code according to the OpenACC Application | |
2727 | Programming Interface v2.6 @w{@uref{https://www.openacc.org}}. This option | |
2728 | implies @option{-pthread}, and thus is only supported on targets that | |
2729 | have support for @option{-pthread}. | |
2730 | ||
d77de738 ML |
2731 | @opindex fopenacc-dim |
2732 | @cindex OpenACC accelerator programming | |
f33d7a88 | 2733 | @item -fopenacc-dim=@var{geom} |
d77de738 ML |
2734 | Specify default compute dimensions for parallel offload regions that do |
2735 | not explicitly specify. The @var{geom} value is a triple of | |
2736 | ':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size | |
2737 | can be omitted, to use a target-specific default value. | |
2738 | ||
d77de738 ML |
2739 | @opindex fopenmp |
2740 | @cindex OpenMP parallel | |
f33d7a88 | 2741 | @item -fopenmp |
d77de738 ML |
2742 | Enable handling of OpenMP directives @code{#pragma omp} in C/C++, |
2743 | @code{[[omp::directive(...)]]} and @code{[[omp::sequence(...)]]} in C++ and | |
2744 | @code{!$omp} in Fortran. When @option{-fopenmp} is specified, the | |
2745 | compiler generates parallel code according to the OpenMP Application | |
2746 | Program Interface v4.5 @w{@uref{https://www.openmp.org}}. This option | |
2747 | implies @option{-pthread}, and thus is only supported on targets that | |
2748 | have support for @option{-pthread}. @option{-fopenmp} implies | |
2749 | @option{-fopenmp-simd}. | |
2750 | ||
d77de738 ML |
2751 | @opindex fopenmp-simd |
2752 | @cindex OpenMP SIMD | |
2753 | @cindex SIMD | |
f33d7a88 | 2754 | @item -fopenmp-simd |
d77de738 ML |
2755 | Enable handling of OpenMP's @code{simd}, @code{declare simd}, |
2756 | @code{declare reduction}, @code{assume}, @code{ordered}, @code{scan}, | |
2757 | @code{loop} directives and combined or composite directives with | |
2758 | @code{simd} as constituent with @code{#pragma omp} in C/C++, | |
2759 | @code{[[omp::directive(...)]]} and @code{[[omp::sequence(...)]]} in C++ | |
2760 | and @code{!$omp} in Fortran. Other OpenMP directives are ignored. | |
2761 | ||
ddf6fe37 | 2762 | @opindex fopenmp-target-simd-clone |
f33d7a88 | 2763 | @cindex OpenMP target SIMD clone |
309e2d95 SL |
2764 | @item -fopenmp-target-simd-clone |
2765 | @item -fopenmp-target-simd-clone=@var{device-type} | |
309e2d95 SL |
2766 | In addition to generating SIMD clones for functions marked with the |
2767 | @code{declare simd} directive, GCC also generates clones | |
2768 | for functions marked with the OpenMP @code{declare target} directive | |
2769 | that are suitable for vectorization when this option is in effect. The | |
2770 | @var{device-type} may be one of @code{none}, @code{host}, @code{nohost}, | |
2771 | and @code{any}, which correspond to keywords for the @code{device_type} | |
2772 | clause of the @code{declare target} directive; clones are generated for | |
2773 | the intersection of devices specified. | |
2774 | @option{-fopenmp-target-simd-clone} is equivalent to | |
2775 | @option{-fopenmp-target-simd-clone=any} and | |
2776 | @option{-fno-openmp-target-simd-clone} is equivalent to | |
2777 | @option{-fopenmp-target-simd-clone=none}. | |
2778 | ||
2779 | At @option{-O2} and higher (but not @option{-Os} or @option{-Og}) this | |
2780 | optimization defaults to @option{-fopenmp-target-simd-clone=nohost}; otherwise | |
2781 | it is disabled by default. | |
2782 | ||
d77de738 ML |
2783 | @opindex fpermitted-flt-eval-methods |
2784 | @opindex fpermitted-flt-eval-methods=c11 | |
2785 | @opindex fpermitted-flt-eval-methods=ts-18661-3 | |
ddf6fe37 | 2786 | @item -fpermitted-flt-eval-methods=@var{style} |
d77de738 ML |
2787 | ISO/IEC TS 18661-3 defines new permissible values for |
2788 | @code{FLT_EVAL_METHOD} that indicate that operations and constants with | |
2789 | a semantic type that is an interchange or extended format should be | |
2790 | evaluated to the precision and range of that type. These new values are | |
2791 | a superset of those permitted under C99/C11, which does not specify the | |
2792 | meaning of other positive values of @code{FLT_EVAL_METHOD}. As such, code | |
2793 | conforming to C11 may not have been written expecting the possibility of | |
2794 | the new values. | |
2795 | ||
2796 | @option{-fpermitted-flt-eval-methods} specifies whether the compiler | |
2797 | should allow only the values of @code{FLT_EVAL_METHOD} specified in C99/C11, | |
2798 | or the extended set of values specified in ISO/IEC TS 18661-3. | |
2799 | ||
2800 | @var{style} is either @code{c11} or @code{ts-18661-3} as appropriate. | |
2801 | ||
2802 | The default when in a standards compliant mode (@option{-std=c11} or similar) | |
2803 | is @option{-fpermitted-flt-eval-methods=c11}. The default when in a GNU | |
2804 | dialect (@option{-std=gnu11} or similar) is | |
2805 | @option{-fpermitted-flt-eval-methods=ts-18661-3}. | |
2806 | ||
d77de738 | 2807 | @opindex fplan9-extensions |
ddf6fe37 | 2808 | @item -fplan9-extensions |
d77de738 ML |
2809 | Accept some non-standard constructs used in Plan 9 code. |
2810 | ||
2811 | This enables @option{-fms-extensions}, permits passing pointers to | |
2812 | structures with anonymous fields to functions that expect pointers to | |
2813 | elements of the type of the field, and permits referring to anonymous | |
2814 | fields declared using a typedef. @xref{Unnamed Fields,,Unnamed | |
2815 | struct/union fields within structs/unions}, for details. This is only | |
2816 | supported for C, not C++. | |
2817 | ||
d77de738 ML |
2818 | @opindex fsigned-bitfields |
2819 | @opindex funsigned-bitfields | |
2820 | @opindex fno-signed-bitfields | |
2821 | @opindex fno-unsigned-bitfields | |
ddf6fe37 AA |
2822 | @item -fsigned-bitfields |
2823 | @itemx -funsigned-bitfields | |
2824 | @itemx -fno-signed-bitfields | |
2825 | @itemx -fno-unsigned-bitfields | |
d77de738 ML |
2826 | These options control whether a bit-field is signed or unsigned, when the |
2827 | declaration does not use either @code{signed} or @code{unsigned}. By | |
2828 | default, such a bit-field is signed, because this is consistent: the | |
2829 | basic integer types such as @code{int} are signed types. | |
2830 | ||
d77de738 | 2831 | @opindex fsigned-char |
ddf6fe37 | 2832 | @item -fsigned-char |
d77de738 ML |
2833 | Let the type @code{char} be signed, like @code{signed char}. |
2834 | ||
2835 | Note that this is equivalent to @option{-fno-unsigned-char}, which is | |
2836 | the negative form of @option{-funsigned-char}. Likewise, the option | |
2837 | @option{-fno-signed-char} is equivalent to @option{-funsigned-char}. | |
2838 | ||
d77de738 | 2839 | @opindex funsigned-char |
ddf6fe37 | 2840 | @item -funsigned-char |
d77de738 ML |
2841 | Let the type @code{char} be unsigned, like @code{unsigned char}. |
2842 | ||
2843 | Each kind of machine has a default for what @code{char} should | |
2844 | be. It is either like @code{unsigned char} by default or like | |
2845 | @code{signed char} by default. | |
2846 | ||
2847 | Ideally, a portable program should always use @code{signed char} or | |
2848 | @code{unsigned char} when it depends on the signedness of an object. | |
2849 | But many programs have been written to use plain @code{char} and | |
2850 | expect it to be signed, or expect it to be unsigned, depending on the | |
2851 | machines they were written for. This option, and its inverse, let you | |
2852 | make such a program work with the opposite default. | |
2853 | ||
2854 | The type @code{char} is always a distinct type from each of | |
2855 | @code{signed char} or @code{unsigned char}, even though its behavior | |
2856 | is always just like one of those two. | |
2857 | ||
d77de738 ML |
2858 | @opindex fstrict-flex-arrays |
2859 | @opindex fno-strict-flex-arrays | |
ddf6fe37 | 2860 | @item -fstrict-flex-arrays |
d77de738 ML |
2861 | Control when to treat the trailing array of a structure as a flexible array |
2862 | member for the purpose of accessing the elements of such an array. | |
2863 | The positive form is equivalent to @option{-fstrict-flex-arrays=3}, which is the | |
2864 | strictest. A trailing array is treated as a flexible array member only when it | |
2865 | is declared as a flexible array member per C99 standard onwards. | |
2866 | The negative form is equivalent to @option{-fstrict-flex-arrays=0}, which is the | |
2867 | least strict. All trailing arrays of structures are treated as flexible array | |
2868 | members. | |
2869 | ||
d77de738 | 2870 | @opindex fstrict-flex-arrays=@var{level} |
ddf6fe37 | 2871 | @item -fstrict-flex-arrays=@var{level} |
d77de738 ML |
2872 | Control when to treat the trailing array of a structure as a flexible array |
2873 | member for the purpose of accessing the elements of such an array. The value | |
2874 | of @var{level} controls the level of strictness. | |
2875 | ||
2876 | The possible values of @var{level} are the same as for the | |
2877 | @code{strict_flex_array} attribute (@pxref{Variable Attributes}). | |
2878 | ||
2879 | You can control this behavior for a specific trailing array field of a | |
2880 | structure by using the variable attribute @code{strict_flex_array} attribute | |
2881 | (@pxref{Variable Attributes}). | |
2882 | ||
d77de738 | 2883 | @opindex fsso-struct |
ddf6fe37 | 2884 | @item -fsso-struct=@var{endianness} |
d77de738 ML |
2885 | Set the default scalar storage order of structures and unions to the |
2886 | specified endianness. The accepted values are @samp{big-endian}, | |
2887 | @samp{little-endian} and @samp{native} for the native endianness of | |
2888 | the target (the default). This option is not supported for C++. | |
2889 | ||
2890 | @strong{Warning:} the @option{-fsso-struct} switch causes GCC to generate | |
2891 | code that is not binary compatible with code generated without it if the | |
2892 | specified endianness is not the native endianness of the target. | |
2893 | @end table | |
2894 | ||
2895 | @node C++ Dialect Options | |
2896 | @section Options Controlling C++ Dialect | |
2897 | ||
2898 | @cindex compiler options, C++ | |
2899 | @cindex C++ options, command-line | |
2900 | @cindex options, C++ | |
2901 | This section describes the command-line options that are only meaningful | |
2902 | for C++ programs. You can also use most of the GNU compiler options | |
2903 | regardless of what language your program is in. For example, you | |
2904 | might compile a file @file{firstClass.C} like this: | |
2905 | ||
2906 | @smallexample | |
2907 | g++ -g -fstrict-enums -O -c firstClass.C | |
2908 | @end smallexample | |
2909 | ||
2910 | @noindent | |
2911 | In this example, only @option{-fstrict-enums} is an option meant | |
2912 | only for C++ programs; you can use the other options with any | |
2913 | language supported by GCC@. | |
2914 | ||
2915 | Some options for compiling C programs, such as @option{-std}, are also | |
2916 | relevant for C++ programs. | |
2917 | @xref{C Dialect Options,,Options Controlling C Dialect}. | |
2918 | ||
2919 | Here is a list of options that are @emph{only} for compiling C++ programs: | |
2920 | ||
2921 | @table @gcctabopt | |
2922 | ||
d77de738 | 2923 | @opindex fabi-version |
ddf6fe37 | 2924 | @item -fabi-version=@var{n} |
d77de738 ML |
2925 | Use version @var{n} of the C++ ABI@. The default is version 0. |
2926 | ||
2927 | Version 0 refers to the version conforming most closely to | |
2928 | the C++ ABI specification. Therefore, the ABI obtained using version 0 | |
2929 | will change in different versions of G++ as ABI bugs are fixed. | |
2930 | ||
2931 | Version 1 is the version of the C++ ABI that first appeared in G++ 3.2. | |
2932 | ||
2933 | Version 2 is the version of the C++ ABI that first appeared in G++ | |
2934 | 3.4, and was the default through G++ 4.9. | |
2935 | ||
2936 | Version 3 corrects an error in mangling a constant address as a | |
2937 | template argument. | |
2938 | ||
2939 | Version 4, which first appeared in G++ 4.5, implements a standard | |
2940 | mangling for vector types. | |
2941 | ||
2942 | Version 5, which first appeared in G++ 4.6, corrects the mangling of | |
2943 | attribute const/volatile on function pointer types, decltype of a | |
2944 | plain decl, and use of a function parameter in the declaration of | |
2945 | another parameter. | |
2946 | ||
2947 | Version 6, which first appeared in G++ 4.7, corrects the promotion | |
2948 | behavior of C++11 scoped enums and the mangling of template argument | |
2949 | packs, const/static_cast, prefix ++ and --, and a class scope function | |
2950 | used as a template argument. | |
2951 | ||
2952 | Version 7, which first appeared in G++ 4.8, that treats nullptr_t as a | |
2953 | builtin type and corrects the mangling of lambdas in default argument | |
2954 | scope. | |
2955 | ||
2956 | Version 8, which first appeared in G++ 4.9, corrects the substitution | |
2957 | behavior of function types with function-cv-qualifiers. | |
2958 | ||
2959 | Version 9, which first appeared in G++ 5.2, corrects the alignment of | |
2960 | @code{nullptr_t}. | |
2961 | ||
2962 | Version 10, which first appeared in G++ 6.1, adds mangling of | |
2963 | attributes that affect type identity, such as ia32 calling convention | |
2964 | attributes (e.g.@: @samp{stdcall}). | |
2965 | ||
2966 | Version 11, which first appeared in G++ 7, corrects the mangling of | |
2967 | sizeof... expressions and operator names. For multiple entities with | |
2968 | the same name within a function, that are declared in different scopes, | |
2969 | the mangling now changes starting with the twelfth occurrence. It also | |
2970 | implies @option{-fnew-inheriting-ctors}. | |
2971 | ||
2972 | Version 12, which first appeared in G++ 8, corrects the calling | |
2973 | conventions for empty classes on the x86_64 target and for classes | |
2974 | with only deleted copy/move constructors. It accidentally changes the | |
2975 | calling convention for classes with a deleted copy constructor and a | |
2976 | trivial move constructor. | |
2977 | ||
2978 | Version 13, which first appeared in G++ 8.2, fixes the accidental | |
2979 | change in version 12. | |
2980 | ||
2981 | Version 14, which first appeared in G++ 10, corrects the mangling of | |
2982 | the nullptr expression. | |
2983 | ||
2984 | Version 15, which first appeared in G++ 10.3, corrects G++ 10 ABI | |
2985 | tag regression. | |
2986 | ||
2987 | Version 16, which first appeared in G++ 11, changes the mangling of | |
2988 | @code{__alignof__} to be distinct from that of @code{alignof}, and | |
2989 | dependent operator names. | |
2990 | ||
2991 | Version 17, which first appeared in G++ 12, fixes layout of classes | |
2992 | that inherit from aggregate classes with default member initializers | |
2993 | in C++14 and up. | |
2994 | ||
2995 | Version 18, which first appeard in G++ 13, fixes manglings of lambdas | |
2996 | that have additional context. | |
2997 | ||
2998 | See also @option{-Wabi}. | |
2999 | ||
d77de738 | 3000 | @opindex fabi-compat-version |
ddf6fe37 | 3001 | @item -fabi-compat-version=@var{n} |
d77de738 ML |
3002 | On targets that support strong aliases, G++ |
3003 | works around mangling changes by creating an alias with the correct | |
3004 | mangled name when defining a symbol with an incorrect mangled name. | |
3005 | This switch specifies which ABI version to use for the alias. | |
3006 | ||
3007 | With @option{-fabi-version=0} (the default), this defaults to 13 (GCC 8.2 | |
3008 | compatibility). If another ABI version is explicitly selected, this | |
3009 | defaults to 0. For compatibility with GCC versions 3.2 through 4.9, | |
3010 | use @option{-fabi-compat-version=2}. | |
3011 | ||
3012 | If this option is not provided but @option{-Wabi=@var{n}} is, that | |
3013 | version is used for compatibility aliases. If this option is provided | |
3014 | along with @option{-Wabi} (without the version), the version from this | |
3015 | option is used for the warning. | |
3016 | ||
d77de738 ML |
3017 | @opindex fno-access-control |
3018 | @opindex faccess-control | |
ddf6fe37 | 3019 | @item -fno-access-control |
d77de738 ML |
3020 | Turn off all access checking. This switch is mainly useful for working |
3021 | around bugs in the access control code. | |
3022 | ||
d77de738 | 3023 | @opindex faligned-new |
ddf6fe37 | 3024 | @item -faligned-new |
d77de738 ML |
3025 | Enable support for C++17 @code{new} of types that require more |
3026 | alignment than @code{void* ::operator new(std::size_t)} provides. A | |
3027 | numeric argument such as @code{-faligned-new=32} can be used to | |
3028 | specify how much alignment (in bytes) is provided by that function, | |
3029 | but few users will need to override the default of | |
3030 | @code{alignof(std::max_align_t)}. | |
3031 | ||
3032 | This flag is enabled by default for @option{-std=c++17}. | |
3033 | ||
d77de738 ML |
3034 | @opindex fchar8_t |
3035 | @opindex fno-char8_t | |
ddf6fe37 AA |
3036 | @item -fchar8_t |
3037 | @itemx -fno-char8_t | |
d77de738 ML |
3038 | Enable support for @code{char8_t} as adopted for C++20. This includes |
3039 | the addition of a new @code{char8_t} fundamental type, changes to the | |
3040 | types of UTF-8 string and character literals, new signatures for | |
3041 | user-defined literals, associated standard library updates, and new | |
3042 | @code{__cpp_char8_t} and @code{__cpp_lib_char8_t} feature test macros. | |
3043 | ||
3044 | This option enables functions to be overloaded for ordinary and UTF-8 | |
3045 | strings: | |
3046 | ||
3047 | @smallexample | |
3048 | int f(const char *); // #1 | |
3049 | int f(const char8_t *); // #2 | |
3050 | int v1 = f("text"); // Calls #1 | |
3051 | int v2 = f(u8"text"); // Calls #2 | |
3052 | @end smallexample | |
3053 | ||
3054 | @noindent | |
3055 | and introduces new signatures for user-defined literals: | |
3056 | ||
3057 | @smallexample | |
3058 | int operator""_udl1(char8_t); | |
3059 | int v3 = u8'x'_udl1; | |
3060 | int operator""_udl2(const char8_t*, std::size_t); | |
3061 | int v4 = u8"text"_udl2; | |
3062 | template<typename T, T...> int operator""_udl3(); | |
3063 | int v5 = u8"text"_udl3; | |
3064 | @end smallexample | |
3065 | ||
3066 | @noindent | |
3067 | The change to the types of UTF-8 string and character literals introduces | |
3068 | incompatibilities with ISO C++11 and later standards. For example, the | |
3069 | following code is well-formed under ISO C++11, but is ill-formed when | |
3070 | @option{-fchar8_t} is specified. | |
3071 | ||
3072 | @smallexample | |
d77de738 ML |
3073 | const char *cp = u8"xx";// error: invalid conversion from |
3074 | // `const char8_t*' to `const char*' | |
3075 | int f(const char*); | |
3076 | auto v = f(u8"xx"); // error: invalid conversion from | |
3077 | // `const char8_t*' to `const char*' | |
3078 | std::string s@{u8"xx"@}; // error: no matching function for call to | |
3079 | // `std::basic_string<char>::basic_string()' | |
3080 | using namespace std::literals; | |
3081 | s = u8"xx"s; // error: conversion from | |
3082 | // `basic_string<char8_t>' to non-scalar | |
3083 | // type `basic_string<char>' requested | |
3084 | @end smallexample | |
3085 | ||
d77de738 | 3086 | @opindex fcheck-new |
ddf6fe37 | 3087 | @item -fcheck-new |
d77de738 ML |
3088 | Check that the pointer returned by @code{operator new} is non-null |
3089 | before attempting to modify the storage allocated. This check is | |
3090 | normally unnecessary because the C++ standard specifies that | |
3091 | @code{operator new} only returns @code{0} if it is declared | |
3092 | @code{throw()}, in which case the compiler always checks the | |
3093 | return value even without this option. In all other cases, when | |
3094 | @code{operator new} has a non-empty exception specification, memory | |
3095 | exhaustion is signalled by throwing @code{std::bad_alloc}. See also | |
3096 | @samp{new (nothrow)}. | |
3097 | ||
d77de738 ML |
3098 | @opindex fconcepts |
3099 | @opindex fconcepts-ts | |
ddf6fe37 AA |
3100 | @item -fconcepts |
3101 | @itemx -fconcepts-ts | |
d77de738 ML |
3102 | Enable support for the C++ Concepts feature for constraining template |
3103 | arguments. With @option{-std=c++20} and above, Concepts are part of | |
3104 | the language standard, so @option{-fconcepts} defaults to on. | |
3105 | ||
3106 | Some constructs that were allowed by the earlier C++ Extensions for | |
3107 | Concepts Technical Specification, ISO 19217 (2015), but didn't make it | |
3108 | into the standard, can additionally be enabled by | |
3109 | @option{-fconcepts-ts}. | |
3110 | ||
d77de738 | 3111 | @opindex fconstexpr-depth |
ddf6fe37 | 3112 | @item -fconstexpr-depth=@var{n} |
d77de738 ML |
3113 | Set the maximum nested evaluation depth for C++11 constexpr functions |
3114 | to @var{n}. A limit is needed to detect endless recursion during | |
3115 | constant expression evaluation. The minimum specified by the standard | |
3116 | is 512. | |
3117 | ||
d77de738 | 3118 | @opindex fconstexpr-cache-depth |
ddf6fe37 | 3119 | @item -fconstexpr-cache-depth=@var{n} |
d77de738 ML |
3120 | Set the maximum level of nested evaluation depth for C++11 constexpr |
3121 | functions that will be cached to @var{n}. This is a heuristic that | |
3122 | trades off compilation speed (when the cache avoids repeated | |
3123 | calculations) against memory consumption (when the cache grows very | |
3124 | large from highly recursive evaluations). The default is 8. Very few | |
3125 | users are likely to want to adjust it, but if your code does heavy | |
3126 | constexpr calculations you might want to experiment to find which | |
3127 | value works best for you. | |
3128 | ||
d77de738 | 3129 | @opindex fconstexpr-fp-except |
ddf6fe37 | 3130 | @item -fconstexpr-fp-except |
d77de738 ML |
3131 | Annex F of the C standard specifies that IEC559 floating point |
3132 | exceptions encountered at compile time should not stop compilation. | |
3133 | C++ compilers have historically not followed this guidance, instead | |
3134 | treating floating point division by zero as non-constant even though | |
3135 | it has a well defined value. This flag tells the compiler to give | |
3136 | Annex F priority over other rules saying that a particular operation | |
3137 | is undefined. | |
3138 | ||
3139 | @smallexample | |
3140 | constexpr float inf = 1./0.; // OK with -fconstexpr-fp-except | |
3141 | @end smallexample | |
3142 | ||
d77de738 | 3143 | @opindex fconstexpr-loop-limit |
ddf6fe37 | 3144 | @item -fconstexpr-loop-limit=@var{n} |
d77de738 ML |
3145 | Set the maximum number of iterations for a loop in C++14 constexpr functions |
3146 | to @var{n}. A limit is needed to detect infinite loops during | |
3147 | constant expression evaluation. The default is 262144 (1<<18). | |
3148 | ||
d77de738 | 3149 | @opindex fconstexpr-ops-limit |
ddf6fe37 | 3150 | @item -fconstexpr-ops-limit=@var{n} |
d77de738 ML |
3151 | Set the maximum number of operations during a single constexpr evaluation. |
3152 | Even when number of iterations of a single loop is limited with the above limit, | |
3153 | if there are several nested loops and each of them has many iterations but still | |
3154 | smaller than the above limit, or if in a body of some loop or even outside | |
3155 | of a loop too many expressions need to be evaluated, the resulting constexpr | |
3156 | evaluation might take too long. | |
3157 | The default is 33554432 (1<<25). | |
3158 | ||
2efb237f | 3159 | @opindex fcontracts |
ddf6fe37 | 3160 | @item -fcontracts |
2efb237f JCI |
3161 | Enable experimental support for the C++ Contracts feature, as briefly |
3162 | added to and then removed from the C++20 working paper (N4820). The | |
3163 | implementation also includes proposed enhancements from papers P1290, | |
3164 | P1332, and P1429. This functionality is intended mostly for those | |
3165 | interested in experimentation towards refining the feature to get it | |
3166 | into shape for a future C++ standard. | |
3167 | ||
3168 | On violation of a checked contract, the violation handler is called. | |
3169 | Users can replace the violation handler by defining | |
3170 | @smallexample | |
4ace81b6 SL |
3171 | void |
3172 | handle_contract_violation (const std::experimental::contract_violation&); | |
2efb237f JCI |
3173 | @end smallexample |
3174 | ||
3175 | There are different sets of additional flags that can be used together | |
3176 | to specify which contracts will be checked and how, for N4820 | |
3177 | contracts, P1332 contracts, or P1429 contracts; these sets cannot be | |
3178 | used together. | |
3179 | ||
3180 | @table @gcctabopt | |
2efb237f | 3181 | @opindex fcontract-mode |
ddf6fe37 | 3182 | @item -fcontract-mode=[on|off] |
2efb237f JCI |
3183 | Control whether any contracts have any semantics at all. Defaults to on. |
3184 | ||
2efb237f | 3185 | @opindex fcontract-assumption-mode |
ddf6fe37 | 3186 | @item -fcontract-assumption-mode=[on|off] |
2efb237f JCI |
3187 | [N4820] Control whether contracts with level @samp{axiom} |
3188 | should have the assume semantic. Defaults to on. | |
3189 | ||
2efb237f | 3190 | @opindex fcontract-build-level |
ddf6fe37 | 3191 | @item -fcontract-build-level=[off|default|audit] |
2efb237f JCI |
3192 | [N4820] Specify which level of contracts to generate checks |
3193 | for. Defaults to @samp{default}. | |
3194 | ||
2efb237f | 3195 | @opindex fcontract-continuation-mode |
ddf6fe37 | 3196 | @item -fcontract-continuation-mode=[on|off] |
2efb237f JCI |
3197 | [N4820] Control whether to allow the program to continue executing |
3198 | after a contract violation. That is, do checked contracts have the | |
3199 | @samp{maybe} semantic described below rather than the @samp{never} | |
3200 | semantic. Defaults to off. | |
3201 | ||
2efb237f | 3202 | @opindex fcontract-role |
ddf6fe37 | 3203 | @item -fcontract-role=<name>:<default>,<audit>,<axiom> |
2efb237f JCI |
3204 | [P1332] Specify the concrete semantics for each contract level |
3205 | of a particular contract role. | |
3206 | ||
3207 | @item -fcontract-semantic=[default|audit|axiom]:<semantic> | |
3208 | [P1429] Specify the concrete semantic for a particular | |
3209 | contract level. | |
3210 | ||
2efb237f | 3211 | @opindex fcontract-strict-declarations |
ddf6fe37 | 3212 | @item -fcontract-strict-declarations=[on|off] |
2efb237f JCI |
3213 | Control whether to reject adding contracts to a function after its |
3214 | first declaration. Defaults to off. | |
3215 | @end table | |
3216 | ||
3217 | The possible concrete semantics for that can be specified with | |
3218 | @samp{-fcontract-role} or @samp{-fcontract-semantic} are: | |
3219 | ||
3220 | @table @code | |
3221 | @item ignore | |
3222 | This contract has no effect. | |
3223 | ||
3224 | @item assume | |
3225 | This contract is treated like C++23 @code{[[assume]]}. | |
3226 | ||
3227 | @item check_never_continue | |
3228 | @itemx never | |
3229 | @itemx abort | |
3230 | This contract is checked. If it fails, the violation handler is | |
3231 | called. If the handler returns, @code{std::terminate} is called. | |
3232 | ||
3233 | @item check_maybe_continue | |
3234 | @itemx maybe | |
3235 | This contract is checked. If it fails, the violation handler is | |
3236 | called. If the handler returns, execution continues normally. | |
3237 | @end table | |
3238 | ||
d77de738 | 3239 | @opindex fcoroutines |
ddf6fe37 | 3240 | @item -fcoroutines |
d77de738 ML |
3241 | Enable support for the C++ coroutines extension (experimental). |
3242 | ||
d77de738 ML |
3243 | @opindex fno-elide-constructors |
3244 | @opindex felide-constructors | |
ddf6fe37 | 3245 | @item -fno-elide-constructors |
d77de738 ML |
3246 | The C++ standard allows an implementation to omit creating a temporary |
3247 | that is only used to initialize another object of the same type. | |
3248 | Specifying this option disables that optimization, and forces G++ to | |
3249 | call the copy constructor in all cases. This option also causes G++ | |
3250 | to call trivial member functions which otherwise would be expanded inline. | |
3251 | ||
3252 | In C++17, the compiler is required to omit these temporaries, but this | |
3253 | option still affects trivial member functions. | |
3254 | ||
d77de738 ML |
3255 | @opindex fno-enforce-eh-specs |
3256 | @opindex fenforce-eh-specs | |
ddf6fe37 | 3257 | @item -fno-enforce-eh-specs |
d77de738 ML |
3258 | Don't generate code to check for violation of exception specifications |
3259 | at run time. This option violates the C++ standard, but may be useful | |
3260 | for reducing code size in production builds, much like defining | |
3261 | @code{NDEBUG}. This does not give user code permission to throw | |
3262 | exceptions in violation of the exception specifications; the compiler | |
3263 | still optimizes based on the specifications, so throwing an | |
3264 | unexpected exception results in undefined behavior at run time. | |
3265 | ||
d77de738 ML |
3266 | @opindex fextern-tls-init |
3267 | @opindex fno-extern-tls-init | |
ddf6fe37 AA |
3268 | @item -fextern-tls-init |
3269 | @itemx -fno-extern-tls-init | |
d77de738 ML |
3270 | The C++11 and OpenMP standards allow @code{thread_local} and |
3271 | @code{threadprivate} variables to have dynamic (runtime) | |
3272 | initialization. To support this, any use of such a variable goes | |
3273 | through a wrapper function that performs any necessary initialization. | |
3274 | When the use and definition of the variable are in the same | |
3275 | translation unit, this overhead can be optimized away, but when the | |
3276 | use is in a different translation unit there is significant overhead | |
3277 | even if the variable doesn't actually need dynamic initialization. If | |
3278 | the programmer can be sure that no use of the variable in a | |
3279 | non-defining TU needs to trigger dynamic initialization (either | |
3280 | because the variable is statically initialized, or a use of the | |
3281 | variable in the defining TU will be executed before any uses in | |
3282 | another TU), they can avoid this overhead with the | |
3283 | @option{-fno-extern-tls-init} option. | |
3284 | ||
3285 | On targets that support symbol aliases, the default is | |
3286 | @option{-fextern-tls-init}. On targets that do not support symbol | |
3287 | aliases, the default is @option{-fno-extern-tls-init}. | |
3288 | ||
d77de738 ML |
3289 | @opindex ffold-simple-inlines |
3290 | @opindex fno-fold-simple-inlines | |
ddf6fe37 AA |
3291 | @item -ffold-simple-inlines |
3292 | @itemx -fno-fold-simple-inlines | |
d77de738 ML |
3293 | Permit the C++ frontend to fold calls to @code{std::move}, @code{std::forward}, |
3294 | @code{std::addressof} and @code{std::as_const}. In contrast to inlining, this | |
3295 | means no debug information will be generated for such calls. Since these | |
3296 | functions are rarely interesting to debug, this flag is enabled by default | |
3297 | unless @option{-fno-inline} is active. | |
3298 | ||
d77de738 ML |
3299 | @opindex fno-gnu-keywords |
3300 | @opindex fgnu-keywords | |
ddf6fe37 | 3301 | @item -fno-gnu-keywords |
d77de738 ML |
3302 | Do not recognize @code{typeof} as a keyword, so that code can use this |
3303 | word as an identifier. You can use the keyword @code{__typeof__} instead. | |
3304 | This option is implied by the strict ISO C++ dialects: @option{-ansi}, | |
3305 | @option{-std=c++98}, @option{-std=c++11}, etc. | |
3306 | ||
d77de738 | 3307 | @opindex fimplicit-constexpr |
ddf6fe37 | 3308 | @item -fimplicit-constexpr |
d77de738 ML |
3309 | Make inline functions implicitly constexpr, if they satisfy the |
3310 | requirements for a constexpr function. This option can be used in | |
3311 | C++14 mode or later. This can result in initialization changing from | |
3312 | dynamic to static and other optimizations. | |
3313 | ||
d77de738 ML |
3314 | @opindex fno-implicit-templates |
3315 | @opindex fimplicit-templates | |
ddf6fe37 | 3316 | @item -fno-implicit-templates |
d77de738 ML |
3317 | Never emit code for non-inline templates that are instantiated |
3318 | implicitly (i.e.@: by use); only emit code for explicit instantiations. | |
3319 | If you use this option, you must take care to structure your code to | |
3320 | include all the necessary explicit instantiations to avoid getting | |
3321 | undefined symbols at link time. | |
3322 | @xref{Template Instantiation}, for more information. | |
3323 | ||
d77de738 ML |
3324 | @opindex fno-implicit-inline-templates |
3325 | @opindex fimplicit-inline-templates | |
ddf6fe37 | 3326 | @item -fno-implicit-inline-templates |
d77de738 ML |
3327 | Don't emit code for implicit instantiations of inline templates, either. |
3328 | The default is to handle inlines differently so that compiles with and | |
3329 | without optimization need the same set of explicit instantiations. | |
3330 | ||
d77de738 ML |
3331 | @opindex fno-implement-inlines |
3332 | @opindex fimplement-inlines | |
ddf6fe37 | 3333 | @item -fno-implement-inlines |
d77de738 ML |
3334 | To save space, do not emit out-of-line copies of inline functions |
3335 | controlled by @code{#pragma implementation}. This causes linker | |
3336 | errors if these functions are not inlined everywhere they are called. | |
3337 | ||
d77de738 ML |
3338 | @opindex fmodules-ts |
3339 | @opindex fno-modules-ts | |
ddf6fe37 AA |
3340 | @item -fmodules-ts |
3341 | @itemx -fno-modules-ts | |
d77de738 ML |
3342 | Enable support for C++20 modules (@pxref{C++ Modules}). The |
3343 | @option{-fno-modules-ts} is usually not needed, as that is the | |
3344 | default. Even though this is a C++20 feature, it is not currently | |
3345 | implicitly enabled by selecting that standard version. | |
3346 | ||
ddf6fe37 | 3347 | @opindex fmodule-header |
d77de738 ML |
3348 | @item -fmodule-header |
3349 | @itemx -fmodule-header=user | |
3350 | @itemx -fmodule-header=system | |
d77de738 ML |
3351 | Compile a header file to create an importable header unit. |
3352 | ||
d77de738 | 3353 | @opindex fmodule-implicit-inline |
ddf6fe37 | 3354 | @item -fmodule-implicit-inline |
d77de738 ML |
3355 | Member functions defined in their class definitions are not implicitly |
3356 | inline for modular code. This is different to traditional C++ | |
3357 | behavior, for good reasons. However, it may result in a difficulty | |
3358 | during code porting. This option makes such function definitions | |
3359 | implicitly inline. It does however generate an ABI incompatibility, | |
3360 | so you must use it everywhere or nowhere. (Such definitions outside | |
3361 | of a named module remain implicitly inline, regardless.) | |
3362 | ||
d77de738 ML |
3363 | @opindex fno-module-lazy |
3364 | @opindex fmodule-lazy | |
ddf6fe37 | 3365 | @item -fno-module-lazy |
d77de738 ML |
3366 | Disable lazy module importing and module mapper creation. |
3367 | ||
f33d7a88 AA |
3368 | @vindex CXX_MODULE_MAPPER @r{environment variable} |
3369 | @opindex fmodule-mapper | |
d77de738 ML |
3370 | @item -fmodule-mapper=@r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]} |
3371 | @itemx -fmodule-mapper=|@var{program}@r{[}?@var{ident}@r{]} @var{args...} | |
3372 | @itemx -fmodule-mapper==@var{socket}@r{[}?@var{ident}@r{]} | |
3373 | @itemx -fmodule-mapper=<>@r{[}@var{inout}@r{]}@r{[}?@var{ident}@r{]} | |
3374 | @itemx -fmodule-mapper=<@var{in}>@var{out}@r{[}?@var{ident}@r{]} | |
3375 | @itemx -fmodule-mapper=@var{file}@r{[}?@var{ident}@r{]} | |
d77de738 ML |
3376 | An oracle to query for module name to filename mappings. If |
3377 | unspecified the @env{CXX_MODULE_MAPPER} environment variable is used, | |
3378 | and if that is unset, an in-process default is provided. | |
3379 | ||
d77de738 | 3380 | @opindex fmodule-only |
ddf6fe37 | 3381 | @item -fmodule-only |
d77de738 ML |
3382 | Only emit the Compiled Module Interface, inhibiting any object file. |
3383 | ||
d77de738 | 3384 | @opindex fms-extensions |
ddf6fe37 | 3385 | @item -fms-extensions |
d77de738 ML |
3386 | Disable Wpedantic warnings about constructs used in MFC, such as implicit |
3387 | int and getting a pointer to member function via non-standard syntax. | |
3388 | ||
d77de738 | 3389 | @opindex fnew-inheriting-ctors |
ddf6fe37 | 3390 | @item -fnew-inheriting-ctors |
d77de738 ML |
3391 | Enable the P0136 adjustment to the semantics of C++11 constructor |
3392 | inheritance. This is part of C++17 but also considered to be a Defect | |
3393 | Report against C++11 and C++14. This flag is enabled by default | |
3394 | unless @option{-fabi-version=10} or lower is specified. | |
3395 | ||
d77de738 | 3396 | @opindex fnew-ttp-matching |
ddf6fe37 | 3397 | @item -fnew-ttp-matching |
d77de738 ML |
3398 | Enable the P0522 resolution to Core issue 150, template template |
3399 | parameters and default arguments: this allows a template with default | |
3400 | template arguments as an argument for a template template parameter | |
3401 | with fewer template parameters. This flag is enabled by default for | |
3402 | @option{-std=c++17}. | |
3403 | ||
d77de738 ML |
3404 | @opindex fno-nonansi-builtins |
3405 | @opindex fnonansi-builtins | |
ddf6fe37 | 3406 | @item -fno-nonansi-builtins |
d77de738 ML |
3407 | Disable built-in declarations of functions that are not mandated by |
3408 | ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit}, | |
3409 | @code{index}, @code{bzero}, @code{conjf}, and other related functions. | |
3410 | ||
d77de738 | 3411 | @opindex fnothrow-opt |
ddf6fe37 | 3412 | @item -fnothrow-opt |
d77de738 ML |
3413 | Treat a @code{throw()} exception specification as if it were a |
3414 | @code{noexcept} specification to reduce or eliminate the text size | |
3415 | overhead relative to a function with no exception specification. If | |
3416 | the function has local variables of types with non-trivial | |
3417 | destructors, the exception specification actually makes the | |
3418 | function smaller because the EH cleanups for those variables can be | |
3419 | optimized away. The semantic effect is that an exception thrown out of | |
3420 | a function with such an exception specification results in a call | |
3421 | to @code{terminate} rather than @code{unexpected}. | |
3422 | ||
d77de738 ML |
3423 | @opindex fno-operator-names |
3424 | @opindex foperator-names | |
ddf6fe37 | 3425 | @item -fno-operator-names |
d77de738 ML |
3426 | Do not treat the operator name keywords @code{and}, @code{bitand}, |
3427 | @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as | |
3428 | synonyms as keywords. | |
3429 | ||
d77de738 ML |
3430 | @opindex fno-optional-diags |
3431 | @opindex foptional-diags | |
ddf6fe37 | 3432 | @item -fno-optional-diags |
d77de738 ML |
3433 | Disable diagnostics that the standard says a compiler does not need to |
3434 | issue. Currently, the only such diagnostic issued by G++ is the one for | |
3435 | a name having multiple meanings within a class. | |
3436 | ||
d77de738 | 3437 | @opindex fpermissive |
ddf6fe37 | 3438 | @item -fpermissive |
d77de738 ML |
3439 | Downgrade some diagnostics about nonconformant code from errors to |
3440 | warnings. Thus, using @option{-fpermissive} allows some | |
3441 | nonconforming code to compile. | |
3442 | ||
d77de738 ML |
3443 | @opindex fno-pretty-templates |
3444 | @opindex fpretty-templates | |
ddf6fe37 | 3445 | @item -fno-pretty-templates |
d77de738 ML |
3446 | When an error message refers to a specialization of a function |
3447 | template, the compiler normally prints the signature of the | |
3448 | template followed by the template arguments and any typedefs or | |
3449 | typenames in the signature (e.g.@: @code{void f(T) [with T = int]} | |
3450 | rather than @code{void f(int)}) so that it's clear which template is | |
3451 | involved. When an error message refers to a specialization of a class | |
3452 | template, the compiler omits any template arguments that match | |
3453 | the default template arguments for that template. If either of these | |
3454 | behaviors make it harder to understand the error message rather than | |
3455 | easier, you can use @option{-fno-pretty-templates} to disable them. | |
3456 | ||
d77de738 ML |
3457 | @opindex fno-rtti |
3458 | @opindex frtti | |
ddf6fe37 | 3459 | @item -fno-rtti |
d77de738 ML |
3460 | Disable generation of information about every class with virtual |
3461 | functions for use by the C++ run-time type identification features | |
3462 | (@code{dynamic_cast} and @code{typeid}). If you don't use those parts | |
3463 | of the language, you can save some space by using this flag. Note that | |
3464 | exception handling uses the same information, but G++ generates it as | |
3465 | needed. The @code{dynamic_cast} operator can still be used for casts that | |
3466 | do not require run-time type information, i.e.@: casts to @code{void *} or to | |
3467 | unambiguous base classes. | |
3468 | ||
3469 | Mixing code compiled with @option{-frtti} with that compiled with | |
3470 | @option{-fno-rtti} may not work. For example, programs may | |
3471 | fail to link if a class compiled with @option{-fno-rtti} is used as a base | |
3472 | for a class compiled with @option{-frtti}. | |
3473 | ||
d77de738 | 3474 | @opindex fsized-deallocation |
ddf6fe37 | 3475 | @item -fsized-deallocation |
d77de738 ML |
3476 | Enable the built-in global declarations |
3477 | @smallexample | |
3478 | void operator delete (void *, std::size_t) noexcept; | |
3479 | void operator delete[] (void *, std::size_t) noexcept; | |
3480 | @end smallexample | |
3481 | as introduced in C++14. This is useful for user-defined replacement | |
3482 | deallocation functions that, for example, use the size of the object | |
3483 | to make deallocation faster. Enabled by default under | |
3484 | @option{-std=c++14} and above. The flag @option{-Wsized-deallocation} | |
3485 | warns about places that might want to add a definition. | |
3486 | ||
d77de738 | 3487 | @opindex fstrict-enums |
ddf6fe37 | 3488 | @item -fstrict-enums |
d77de738 ML |
3489 | Allow the compiler to optimize using the assumption that a value of |
3490 | enumerated type can only be one of the values of the enumeration (as | |
3491 | defined in the C++ standard; basically, a value that can be | |
3492 | represented in the minimum number of bits needed to represent all the | |
3493 | enumerators). This assumption may not be valid if the program uses a | |
3494 | cast to convert an arbitrary integer value to the enumerated type. | |
3495 | ||
d77de738 | 3496 | @opindex fstrong-eval-order |
ddf6fe37 | 3497 | @item -fstrong-eval-order |
d77de738 ML |
3498 | Evaluate member access, array subscripting, and shift expressions in |
3499 | left-to-right order, and evaluate assignment in right-to-left order, | |
3500 | as adopted for C++17. Enabled by default with @option{-std=c++17}. | |
3501 | @option{-fstrong-eval-order=some} enables just the ordering of member | |
3502 | access and shift expressions, and is the default without | |
3503 | @option{-std=c++17}. | |
3504 | ||
d77de738 | 3505 | @opindex ftemplate-backtrace-limit |
ddf6fe37 | 3506 | @item -ftemplate-backtrace-limit=@var{n} |
d77de738 ML |
3507 | Set the maximum number of template instantiation notes for a single |
3508 | warning or error to @var{n}. The default value is 10. | |
3509 | ||
d77de738 | 3510 | @opindex ftemplate-depth |
ddf6fe37 | 3511 | @item -ftemplate-depth=@var{n} |
d77de738 ML |
3512 | Set the maximum instantiation depth for template classes to @var{n}. |
3513 | A limit on the template instantiation depth is needed to detect | |
3514 | endless recursions during template class instantiation. ANSI/ISO C++ | |
3515 | conforming programs must not rely on a maximum depth greater than 17 | |
3516 | (changed to 1024 in C++11). The default value is 900, as the compiler | |
3517 | can run out of stack space before hitting 1024 in some situations. | |
3518 | ||
d77de738 ML |
3519 | @opindex fno-threadsafe-statics |
3520 | @opindex fthreadsafe-statics | |
ddf6fe37 | 3521 | @item -fno-threadsafe-statics |
d77de738 ML |
3522 | Do not emit the extra code to use the routines specified in the C++ |
3523 | ABI for thread-safe initialization of local statics. You can use this | |
3524 | option to reduce code size slightly in code that doesn't need to be | |
3525 | thread-safe. | |
3526 | ||
d77de738 | 3527 | @opindex fuse-cxa-atexit |
ddf6fe37 | 3528 | @item -fuse-cxa-atexit |
d77de738 ML |
3529 | Register destructors for objects with static storage duration with the |
3530 | @code{__cxa_atexit} function rather than the @code{atexit} function. | |
3531 | This option is required for fully standards-compliant handling of static | |
3532 | destructors, but only works if your C library supports | |
3533 | @code{__cxa_atexit}. | |
3534 | ||
d77de738 ML |
3535 | @opindex fno-use-cxa-get-exception-ptr |
3536 | @opindex fuse-cxa-get-exception-ptr | |
ddf6fe37 | 3537 | @item -fno-use-cxa-get-exception-ptr |
d77de738 ML |
3538 | Don't use the @code{__cxa_get_exception_ptr} runtime routine. This |
3539 | causes @code{std::uncaught_exception} to be incorrect, but is necessary | |
3540 | if the runtime routine is not available. | |
3541 | ||
d77de738 | 3542 | @opindex fvisibility-inlines-hidden |
ddf6fe37 | 3543 | @item -fvisibility-inlines-hidden |
d77de738 ML |
3544 | This switch declares that the user does not attempt to compare |
3545 | pointers to inline functions or methods where the addresses of the two functions | |
3546 | are taken in different shared objects. | |
3547 | ||
3548 | The effect of this is that GCC may, effectively, mark inline methods with | |
3549 | @code{__attribute__ ((visibility ("hidden")))} so that they do not | |
3550 | appear in the export table of a DSO and do not require a PLT indirection | |
3551 | when used within the DSO@. Enabling this option can have a dramatic effect | |
3552 | on load and link times of a DSO as it massively reduces the size of the | |
3553 | dynamic export table when the library makes heavy use of templates. | |
3554 | ||
3555 | The behavior of this switch is not quite the same as marking the | |
3556 | methods as hidden directly, because it does not affect static variables | |
3557 | local to the function or cause the compiler to deduce that | |
3558 | the function is defined in only one shared object. | |
3559 | ||
3560 | You may mark a method as having a visibility explicitly to negate the | |
3561 | effect of the switch for that method. For example, if you do want to | |
3562 | compare pointers to a particular inline method, you might mark it as | |
3563 | having default visibility. Marking the enclosing class with explicit | |
3564 | visibility has no effect. | |
3565 | ||
3566 | Explicitly instantiated inline methods are unaffected by this option | |
3567 | as their linkage might otherwise cross a shared library boundary. | |
3568 | @xref{Template Instantiation}. | |
3569 | ||
d77de738 | 3570 | @opindex fvisibility-ms-compat |
ddf6fe37 | 3571 | @item -fvisibility-ms-compat |
d77de738 ML |
3572 | This flag attempts to use visibility settings to make GCC's C++ |
3573 | linkage model compatible with that of Microsoft Visual Studio. | |
3574 | ||
3575 | The flag makes these changes to GCC's linkage model: | |
3576 | ||
3577 | @enumerate | |
3578 | @item | |
3579 | It sets the default visibility to @code{hidden}, like | |
3580 | @option{-fvisibility=hidden}. | |
3581 | ||
3582 | @item | |
3583 | Types, but not their members, are not hidden by default. | |
3584 | ||
3585 | @item | |
3586 | The One Definition Rule is relaxed for types without explicit | |
3587 | visibility specifications that are defined in more than one | |
3588 | shared object: those declarations are permitted if they are | |
3589 | permitted when this option is not used. | |
3590 | @end enumerate | |
3591 | ||
3592 | In new code it is better to use @option{-fvisibility=hidden} and | |
3593 | export those classes that are intended to be externally visible. | |
3594 | Unfortunately it is possible for code to rely, perhaps accidentally, | |
3595 | on the Visual Studio behavior. | |
3596 | ||
3597 | Among the consequences of these changes are that static data members | |
3598 | of the same type with the same name but defined in different shared | |
3599 | objects are different, so changing one does not change the other; | |
3600 | and that pointers to function members defined in different shared | |
3601 | objects may not compare equal. When this flag is given, it is a | |
3602 | violation of the ODR to define types with the same name differently. | |
3603 | ||
d77de738 ML |
3604 | @opindex fno-weak |
3605 | @opindex fweak | |
ddf6fe37 | 3606 | @item -fno-weak |
d77de738 ML |
3607 | Do not use weak symbol support, even if it is provided by the linker. |
3608 | By default, G++ uses weak symbols if they are available. This | |
3609 | option exists only for testing, and should not be used by end-users; | |
3610 | it results in inferior code and has no benefits. This option may | |
3611 | be removed in a future release of G++. | |
3612 | ||
d77de738 ML |
3613 | @opindex fext-numeric-literals |
3614 | @opindex fno-ext-numeric-literals | |
ddf6fe37 | 3615 | @item -fext-numeric-literals @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3616 | Accept imaginary, fixed-point, or machine-defined |
3617 | literal number suffixes as GNU extensions. | |
3618 | When this option is turned off these suffixes are treated | |
3619 | as C++11 user-defined literal numeric suffixes. | |
3620 | This is on by default for all pre-C++11 dialects and all GNU dialects: | |
3621 | @option{-std=c++98}, @option{-std=gnu++98}, @option{-std=gnu++11}, | |
3622 | @option{-std=gnu++14}. | |
3623 | This option is off by default | |
3624 | for ISO C++11 onwards (@option{-std=c++11}, ...). | |
3625 | ||
d77de738 | 3626 | @opindex nostdinc++ |
ddf6fe37 | 3627 | @item -nostdinc++ |
d77de738 ML |
3628 | Do not search for header files in the standard directories specific to |
3629 | C++, but do still search the other standard directories. (This option | |
3630 | is used when building the C++ library.) | |
3631 | ||
ddf6fe37 AA |
3632 | @opindex flang-info-include-translate |
3633 | @opindex flang-info-include-translate-not | |
d77de738 ML |
3634 | @item -flang-info-include-translate |
3635 | @itemx -flang-info-include-translate-not | |
3636 | @itemx -flang-info-include-translate=@var{header} | |
d77de738 ML |
3637 | Inform of include translation events. The first will note accepted |
3638 | include translations, the second will note declined include | |
3639 | translations. The @var{header} form will inform of include | |
3640 | translations relating to that specific header. If @var{header} is of | |
3641 | the form @code{"user"} or @code{<system>} it will be resolved to a | |
3642 | specific user or system header using the include path. | |
3643 | ||
ddf6fe37 | 3644 | @opindex flang-info-module-cmi |
d77de738 ML |
3645 | @item -flang-info-module-cmi |
3646 | @itemx -flang-info-module-cmi=@var{module} | |
d77de738 ML |
3647 | Inform of Compiled Module Interface pathnames. The first will note |
3648 | all read CMI pathnames. The @var{module} form will not reading a | |
3649 | specific module's CMI. @var{module} may be a named module or a | |
3650 | header-unit (the latter indicated by either being a pathname containing | |
3651 | directory separators or enclosed in @code{<>} or @code{""}). | |
3652 | ||
d77de738 | 3653 | @opindex stdlib |
ddf6fe37 | 3654 | @item -stdlib=@var{libstdc++,libc++} |
d77de738 ML |
3655 | When G++ is configured to support this option, it allows specification of |
3656 | alternate C++ runtime libraries. Two options are available: @var{libstdc++} | |
3657 | (the default, native C++ runtime for G++) and @var{libc++} which is the | |
3658 | C++ runtime installed on some operating systems (e.g. Darwin versions from | |
3659 | Darwin11 onwards). The option switches G++ to use the headers from the | |
3660 | specified library and to emit @code{-lstdc++} or @code{-lc++} respectively, | |
3661 | when a C++ runtime is required for linking. | |
3662 | @end table | |
3663 | ||
3664 | In addition, these warning options have meanings only for C++ programs: | |
3665 | ||
3666 | @table @gcctabopt | |
d77de738 | 3667 | @opindex Wabi-tag |
ddf6fe37 | 3668 | @item -Wabi-tag @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3669 | Warn when a type with an ABI tag is used in a context that does not |
3670 | have that ABI tag. See @ref{C++ Attributes} for more information | |
3671 | about ABI tags. | |
3672 | ||
d77de738 ML |
3673 | @opindex Wcomma-subscript |
3674 | @opindex Wno-comma-subscript | |
ddf6fe37 | 3675 | @item -Wcomma-subscript @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3676 | Warn about uses of a comma expression within a subscripting expression. |
3677 | This usage was deprecated in C++20 and is going to be removed in C++23. | |
3678 | However, a comma expression wrapped in @code{( )} is not deprecated. Example: | |
3679 | ||
3680 | @smallexample | |
3681 | @group | |
3682 | void f(int *a, int b, int c) @{ | |
3683 | a[b,c]; // deprecated in C++20, invalid in C++23 | |
3684 | a[(b,c)]; // OK | |
3685 | @} | |
3686 | @end group | |
3687 | @end smallexample | |
3688 | ||
3689 | In C++23 it is valid to have comma separated expressions in a subscript | |
3690 | when an overloaded subscript operator is found and supports the right | |
3691 | number and types of arguments. G++ will accept the formerly valid syntax | |
3692 | for code that is not valid in C++23 but used to be valid but deprecated | |
3693 | in C++20 with a pedantic warning that can be disabled with | |
3694 | @option{-Wno-comma-subscript}. | |
3695 | ||
3696 | Enabled by default with @option{-std=c++20} unless @option{-Wno-deprecated}, | |
3697 | and with @option{-std=c++23} regardless of @option{-Wno-deprecated}. | |
3698 | ||
d77de738 ML |
3699 | @opindex Wctad-maybe-unsupported |
3700 | @opindex Wno-ctad-maybe-unsupported | |
ddf6fe37 | 3701 | @item -Wctad-maybe-unsupported @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3702 | Warn when performing class template argument deduction (CTAD) on a type with |
3703 | no explicitly written deduction guides. This warning will point out cases | |
3704 | where CTAD succeeded only because the compiler synthesized the implicit | |
3705 | deduction guides, which might not be what the programmer intended. Certain | |
3706 | style guides allow CTAD only on types that specifically "opt-in"; i.e., on | |
3707 | types that are designed to support CTAD. This warning can be suppressed with | |
3708 | the following pattern: | |
3709 | ||
3710 | @smallexample | |
3711 | struct allow_ctad_t; // any name works | |
3712 | template <typename T> struct S @{ | |
3713 | S(T) @{ @} | |
3714 | @}; | |
4ace81b6 SL |
3715 | // Guide with incomplete parameter type will never be considered. |
3716 | S(allow_ctad_t) -> S<void>; | |
d77de738 ML |
3717 | @end smallexample |
3718 | ||
d77de738 ML |
3719 | @opindex Wctor-dtor-privacy |
3720 | @opindex Wno-ctor-dtor-privacy | |
ddf6fe37 | 3721 | @item -Wctor-dtor-privacy @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3722 | Warn when a class seems unusable because all the constructors or |
3723 | destructors in that class are private, and it has neither friends nor | |
3724 | public static member functions. Also warn if there are no non-private | |
3725 | methods, and there's at least one private member function that isn't | |
3726 | a constructor or destructor. | |
3727 | ||
d77de738 ML |
3728 | @opindex Wdangling-reference |
3729 | @opindex Wno-dangling-reference | |
ddf6fe37 | 3730 | @item -Wdangling-reference @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3731 | Warn when a reference is bound to a temporary whose lifetime has ended. |
3732 | For example: | |
3733 | ||
3734 | @smallexample | |
3735 | int n = 1; | |
3736 | const int& r = std::max(n - 1, n + 1); // r is dangling | |
3737 | @end smallexample | |
3738 | ||
3739 | In the example above, two temporaries are created, one for each | |
3740 | argument, and a reference to one of the temporaries is returned. | |
3741 | However, both temporaries are destroyed at the end of the full | |
3742 | expression, so the reference @code{r} is dangling. This warning | |
3743 | also detects dangling references in member initializer lists: | |
3744 | ||
3745 | @smallexample | |
3746 | const int& f(const int& i) @{ return i; @} | |
3747 | struct S @{ | |
3748 | const int &r; // r is dangling | |
3749 | S() : r(f(10)) @{ @} | |
3750 | @}; | |
3751 | @end smallexample | |
3752 | ||
3753 | Member functions are checked as well, but only their object argument: | |
3754 | ||
3755 | @smallexample | |
3756 | struct S @{ | |
3757 | const S& self () @{ return *this; @} | |
3758 | @}; | |
3759 | const S& s = S().self(); // s is dangling | |
3760 | @end smallexample | |
3761 | ||
3762 | Certain functions are safe in this respect, for example @code{std::use_facet}: | |
3763 | they take and return a reference, but they don't return one of its arguments, | |
3764 | which can fool the warning. Such functions can be excluded from the warning | |
3765 | by wrapping them in a @code{#pragma}: | |
3766 | ||
3767 | @smallexample | |
3768 | #pragma GCC diagnostic push | |
3769 | #pragma GCC diagnostic ignored "-Wdangling-reference" | |
3770 | const T& foo (const T&) @{ @dots{} @} | |
3771 | #pragma GCC diagnostic pop | |
3772 | @end smallexample | |
3773 | ||
ce51e843 ML |
3774 | @option{-Wdangling-reference} also warns about code like |
3775 | ||
3776 | @smallexample | |
3777 | auto p = std::minmax(1, 2); | |
3778 | @end smallexample | |
3779 | ||
3780 | where @code{std::minmax} returns @code{std::pair<const int&, const int&>}, and | |
3781 | both references dangle after the end of the full expression that contains | |
3782 | the call to @code{std::minmax}. | |
3783 | ||
d77de738 ML |
3784 | This warning is enabled by @option{-Wall}. |
3785 | ||
d77de738 ML |
3786 | @opindex Wdelete-non-virtual-dtor |
3787 | @opindex Wno-delete-non-virtual-dtor | |
ddf6fe37 | 3788 | @item -Wdelete-non-virtual-dtor @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3789 | Warn when @code{delete} is used to destroy an instance of a class that |
3790 | has virtual functions and non-virtual destructor. It is unsafe to delete | |
3791 | an instance of a derived class through a pointer to a base class if the | |
3792 | base class does not have a virtual destructor. This warning is enabled | |
3793 | by @option{-Wall}. | |
3794 | ||
d77de738 ML |
3795 | @opindex Wdeprecated-copy |
3796 | @opindex Wno-deprecated-copy | |
ddf6fe37 | 3797 | @item -Wdeprecated-copy @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3798 | Warn that the implicit declaration of a copy constructor or copy |
3799 | assignment operator is deprecated if the class has a user-provided | |
3800 | copy constructor or copy assignment operator, in C++11 and up. This | |
3801 | warning is enabled by @option{-Wextra}. With | |
3802 | @option{-Wdeprecated-copy-dtor}, also deprecate if the class has a | |
3803 | user-provided destructor. | |
3804 | ||
d77de738 ML |
3805 | @opindex Wdeprecated-enum-enum-conversion |
3806 | @opindex Wno-deprecated-enum-enum-conversion | |
ddf6fe37 | 3807 | @item -Wno-deprecated-enum-enum-conversion @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3808 | Disable the warning about the case when the usual arithmetic conversions |
3809 | are applied on operands where one is of enumeration type and the other is | |
3810 | of a different enumeration type. This conversion was deprecated in C++20. | |
3811 | For example: | |
3812 | ||
3813 | @smallexample | |
3814 | enum E1 @{ e @}; | |
3815 | enum E2 @{ f @}; | |
3816 | int k = f - e; | |
3817 | @end smallexample | |
3818 | ||
3819 | @option{-Wdeprecated-enum-enum-conversion} is enabled by default with | |
3820 | @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled | |
3821 | by @option{-Wenum-conversion}. | |
3822 | ||
d77de738 ML |
3823 | @opindex Wdeprecated-enum-float-conversion |
3824 | @opindex Wno-deprecated-enum-float-conversion | |
ddf6fe37 | 3825 | @item -Wno-deprecated-enum-float-conversion @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3826 | Disable the warning about the case when the usual arithmetic conversions |
3827 | are applied on operands where one is of enumeration type and the other is | |
3828 | of a floating-point type. This conversion was deprecated in C++20. For | |
3829 | example: | |
3830 | ||
3831 | @smallexample | |
3832 | enum E1 @{ e @}; | |
3833 | enum E2 @{ f @}; | |
3834 | bool b = e <= 3.7; | |
3835 | @end smallexample | |
3836 | ||
3837 | @option{-Wdeprecated-enum-float-conversion} is enabled by default with | |
3838 | @option{-std=c++20}. In pre-C++20 dialects, this warning can be enabled | |
3839 | by @option{-Wenum-conversion}. | |
3840 | ||
d77de738 ML |
3841 | @opindex Winit-list-lifetime |
3842 | @opindex Wno-init-list-lifetime | |
ddf6fe37 | 3843 | @item -Wno-init-list-lifetime @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3844 | Do not warn about uses of @code{std::initializer_list} that are likely |
3845 | to result in dangling pointers. Since the underlying array for an | |
3846 | @code{initializer_list} is handled like a normal C++ temporary object, | |
3847 | it is easy to inadvertently keep a pointer to the array past the end | |
3848 | of the array's lifetime. For example: | |
3849 | ||
3850 | @itemize @bullet | |
3851 | @item | |
3852 | If a function returns a temporary @code{initializer_list}, or a local | |
3853 | @code{initializer_list} variable, the array's lifetime ends at the end | |
3854 | of the return statement, so the value returned has a dangling pointer. | |
3855 | ||
3856 | @item | |
3857 | If a new-expression creates an @code{initializer_list}, the array only | |
3858 | lives until the end of the enclosing full-expression, so the | |
3859 | @code{initializer_list} in the heap has a dangling pointer. | |
3860 | ||
3861 | @item | |
3862 | When an @code{initializer_list} variable is assigned from a | |
3863 | brace-enclosed initializer list, the temporary array created for the | |
3864 | right side of the assignment only lives until the end of the | |
3865 | full-expression, so at the next statement the @code{initializer_list} | |
3866 | variable has a dangling pointer. | |
3867 | ||
3868 | @smallexample | |
3869 | // li's initial underlying array lives as long as li | |
3870 | std::initializer_list<int> li = @{ 1,2,3 @}; | |
3871 | // assignment changes li to point to a temporary array | |
3872 | li = @{ 4, 5 @}; | |
3873 | // now the temporary is gone and li has a dangling pointer | |
3874 | int i = li.begin()[0] // undefined behavior | |
3875 | @end smallexample | |
3876 | ||
3877 | @item | |
3878 | When a list constructor stores the @code{begin} pointer from the | |
3879 | @code{initializer_list} argument, this doesn't extend the lifetime of | |
3880 | the array, so if a class variable is constructed from a temporary | |
3881 | @code{initializer_list}, the pointer is left dangling by the end of | |
3882 | the variable declaration statement. | |
3883 | ||
3884 | @end itemize | |
3885 | ||
c85f8dbb MP |
3886 | @opindex Winvalid-constexpr |
3887 | @opindex Wno-invalid-constexpr | |
ddf6fe37 | 3888 | @item -Winvalid-constexpr |
c85f8dbb MP |
3889 | |
3890 | Warn when a function never produces a constant expression. In C++20 | |
3891 | and earlier, for every @code{constexpr} function and function template, | |
3892 | there must be at least one set of function arguments in at least one | |
3893 | instantiation such that an invocation of the function or constructor | |
3894 | could be an evaluated subexpression of a core constant expression. | |
3895 | C++23 removed this restriction, so it's possible to have a function | |
3896 | or a function template marked @code{constexpr} for which no invocation | |
3897 | satisfies the requirements of a core constant expression. | |
3898 | ||
3899 | This warning is enabled as a pedantic warning by default in C++20 and | |
3900 | earlier. In C++23, @option{-Winvalid-constexpr} can be turned on, in | |
3901 | which case it will be an ordinary warning. For example: | |
3902 | ||
3903 | @smallexample | |
3904 | void f (int& i); | |
3905 | constexpr void | |
3906 | g (int& i) | |
3907 | @{ | |
4ace81b6 SL |
3908 | // Warns by default in C++20, in C++23 only with -Winvalid-constexpr. |
3909 | f(i); | |
c85f8dbb MP |
3910 | @} |
3911 | @end smallexample | |
3912 | ||
d77de738 ML |
3913 | @opindex Winvalid-imported-macros |
3914 | @opindex Wno-invalid-imported-macros | |
ddf6fe37 | 3915 | @item -Winvalid-imported-macros |
d77de738 ML |
3916 | Verify all imported macro definitions are valid at the end of |
3917 | compilation. This is not enabled by default, as it requires | |
3918 | additional processing to determine. It may be useful when preparing | |
3919 | sets of header-units to ensure consistent macros. | |
3920 | ||
d77de738 ML |
3921 | @opindex Wliteral-suffix |
3922 | @opindex Wno-literal-suffix | |
ddf6fe37 | 3923 | @item -Wno-literal-suffix @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3924 | Do not warn when a string or character literal is followed by a |
3925 | ud-suffix which does not begin with an underscore. As a conforming | |
3926 | extension, GCC treats such suffixes as separate preprocessing tokens | |
3927 | in order to maintain backwards compatibility with code that uses | |
3928 | formatting macros from @code{<inttypes.h>}. For example: | |
3929 | ||
3930 | @smallexample | |
3931 | #define __STDC_FORMAT_MACROS | |
3932 | #include <inttypes.h> | |
3933 | #include <stdio.h> | |
3934 | ||
3935 | int main() @{ | |
3936 | int64_t i64 = 123; | |
3937 | printf("My int64: %" PRId64"\n", i64); | |
3938 | @} | |
3939 | @end smallexample | |
3940 | ||
3941 | In this case, @code{PRId64} is treated as a separate preprocessing token. | |
3942 | ||
3943 | This option also controls warnings when a user-defined literal | |
3944 | operator is declared with a literal suffix identifier that doesn't | |
3945 | begin with an underscore. Literal suffix identifiers that don't begin | |
3946 | with an underscore are reserved for future standardization. | |
3947 | ||
3948 | These warnings are enabled by default. | |
3949 | ||
d77de738 ML |
3950 | @opindex Wnarrowing |
3951 | @opindex Wno-narrowing | |
ddf6fe37 | 3952 | @item -Wno-narrowing @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3953 | For C++11 and later standards, narrowing conversions are diagnosed by default, |
3954 | as required by the standard. A narrowing conversion from a constant produces | |
3955 | an error, and a narrowing conversion from a non-constant produces a warning, | |
3956 | but @option{-Wno-narrowing} suppresses the diagnostic. | |
3957 | Note that this does not affect the meaning of well-formed code; | |
3958 | narrowing conversions are still considered ill-formed in SFINAE contexts. | |
3959 | ||
3960 | With @option{-Wnarrowing} in C++98, warn when a narrowing | |
3961 | conversion prohibited by C++11 occurs within | |
3962 | @samp{@{ @}}, e.g. | |
3963 | ||
3964 | @smallexample | |
3965 | int i = @{ 2.2 @}; // error: narrowing from double to int | |
3966 | @end smallexample | |
3967 | ||
3968 | This flag is included in @option{-Wall} and @option{-Wc++11-compat}. | |
3969 | ||
d77de738 ML |
3970 | @opindex Wnoexcept |
3971 | @opindex Wno-noexcept | |
ddf6fe37 | 3972 | @item -Wnoexcept @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3973 | Warn when a noexcept-expression evaluates to false because of a call |
3974 | to a function that does not have a non-throwing exception | |
3975 | specification (i.e. @code{throw()} or @code{noexcept}) but is known by | |
3976 | the compiler to never throw an exception. | |
3977 | ||
d77de738 ML |
3978 | @opindex Wnoexcept-type |
3979 | @opindex Wno-noexcept-type | |
ddf6fe37 | 3980 | @item -Wnoexcept-type @r{(C++ and Objective-C++ only)} |
d77de738 ML |
3981 | Warn if the C++17 feature making @code{noexcept} part of a function |
3982 | type changes the mangled name of a symbol relative to C++14. Enabled | |
3983 | by @option{-Wabi} and @option{-Wc++17-compat}. | |
3984 | ||
3985 | As an example: | |
3986 | ||
3987 | @smallexample | |
3988 | template <class T> void f(T t) @{ t(); @}; | |
3989 | void g() noexcept; | |
3990 | void h() @{ f(g); @} | |
3991 | @end smallexample | |
3992 | ||
3993 | @noindent | |
3994 | In C++14, @code{f} calls @code{f<void(*)()>}, but in | |
3995 | C++17 it calls @code{f<void(*)()noexcept>}. | |
3996 | ||
d77de738 ML |
3997 | @opindex Wclass-memaccess |
3998 | @opindex Wno-class-memaccess | |
ddf6fe37 | 3999 | @item -Wclass-memaccess @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4000 | Warn when the destination of a call to a raw memory function such as |
4001 | @code{memset} or @code{memcpy} is an object of class type, and when writing | |
4002 | into such an object might bypass the class non-trivial or deleted constructor | |
4003 | or copy assignment, violate const-correctness or encapsulation, or corrupt | |
4004 | virtual table pointers. Modifying the representation of such objects may | |
4005 | violate invariants maintained by member functions of the class. For example, | |
4006 | the call to @code{memset} below is undefined because it modifies a non-trivial | |
4007 | class object and is, therefore, diagnosed. The safe way to either initialize | |
4008 | or clear the storage of objects of such types is by using the appropriate | |
4009 | constructor or assignment operator, if one is available. | |
4010 | @smallexample | |
4011 | std::string str = "abc"; | |
4012 | memset (&str, 0, sizeof str); | |
4013 | @end smallexample | |
4014 | The @option{-Wclass-memaccess} option is enabled by @option{-Wall}. | |
4015 | Explicitly casting the pointer to the class object to @code{void *} or | |
4016 | to a type that can be safely accessed by the raw memory function suppresses | |
4017 | the warning. | |
4018 | ||
d77de738 ML |
4019 | @opindex Wnon-virtual-dtor |
4020 | @opindex Wno-non-virtual-dtor | |
ddf6fe37 | 4021 | @item -Wnon-virtual-dtor @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4022 | Warn when a class has virtual functions and an accessible non-virtual |
4023 | destructor itself or in an accessible polymorphic base class, in which | |
4024 | case it is possible but unsafe to delete an instance of a derived | |
4025 | class through a pointer to the class itself or base class. This | |
4026 | warning is automatically enabled if @option{-Weffc++} is specified. | |
51f28e3a JW |
4027 | The @option{-Wdelete-non-virtual-dtor} option (enabled by @option{-Wall}) |
4028 | should be preferred because it warns about the unsafe cases without false | |
4029 | positives. | |
d77de738 | 4030 | |
d77de738 ML |
4031 | @opindex Wregister |
4032 | @opindex Wno-register | |
ddf6fe37 | 4033 | @item -Wregister @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4034 | Warn on uses of the @code{register} storage class specifier, except |
4035 | when it is part of the GNU @ref{Explicit Register Variables} extension. | |
4036 | The use of the @code{register} keyword as storage class specifier has | |
4037 | been deprecated in C++11 and removed in C++17. | |
4038 | Enabled by default with @option{-std=c++17}. | |
4039 | ||
d77de738 ML |
4040 | @opindex Wreorder |
4041 | @opindex Wno-reorder | |
4042 | @cindex reordering, warning | |
4043 | @cindex warning for reordering of member initializers | |
f33d7a88 | 4044 | @item -Wreorder @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4045 | Warn when the order of member initializers given in the code does not |
4046 | match the order in which they must be executed. For instance: | |
4047 | ||
4048 | @smallexample | |
4049 | struct A @{ | |
4050 | int i; | |
4051 | int j; | |
4052 | A(): j (0), i (1) @{ @} | |
4053 | @}; | |
4054 | @end smallexample | |
4055 | ||
4056 | @noindent | |
4057 | The compiler rearranges the member initializers for @code{i} | |
4058 | and @code{j} to match the declaration order of the members, emitting | |
4059 | a warning to that effect. This warning is enabled by @option{-Wall}. | |
4060 | ||
d77de738 ML |
4061 | @opindex Wpessimizing-move |
4062 | @opindex Wno-pessimizing-move | |
ddf6fe37 | 4063 | @item -Wno-pessimizing-move @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4064 | This warning warns when a call to @code{std::move} prevents copy |
4065 | elision. A typical scenario when copy elision can occur is when returning in | |
4066 | a function with a class return type, when the expression being returned is the | |
4067 | name of a non-volatile automatic object, and is not a function parameter, and | |
4068 | has the same type as the function return type. | |
4069 | ||
4070 | @smallexample | |
4071 | struct T @{ | |
4072 | @dots{} | |
4073 | @}; | |
4074 | T fn() | |
4075 | @{ | |
4076 | T t; | |
4077 | @dots{} | |
4078 | return std::move (t); | |
4079 | @} | |
4080 | @end smallexample | |
4081 | ||
4082 | But in this example, the @code{std::move} call prevents copy elision. | |
4083 | ||
4084 | This warning is enabled by @option{-Wall}. | |
4085 | ||
d77de738 ML |
4086 | @opindex Wredundant-move |
4087 | @opindex Wno-redundant-move | |
ddf6fe37 | 4088 | @item -Wno-redundant-move @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4089 | This warning warns about redundant calls to @code{std::move}; that is, when |
4090 | a move operation would have been performed even without the @code{std::move} | |
4091 | call. This happens because the compiler is forced to treat the object as if | |
4092 | it were an rvalue in certain situations such as returning a local variable, | |
4093 | where copy elision isn't applicable. Consider: | |
4094 | ||
4095 | @smallexample | |
4096 | struct T @{ | |
4097 | @dots{} | |
4098 | @}; | |
4099 | T fn(T t) | |
4100 | @{ | |
4101 | @dots{} | |
4102 | return std::move (t); | |
4103 | @} | |
4104 | @end smallexample | |
4105 | ||
4106 | Here, the @code{std::move} call is redundant. Because G++ implements Core | |
4107 | Issue 1579, another example is: | |
4108 | ||
4109 | @smallexample | |
4110 | struct T @{ // convertible to U | |
4111 | @dots{} | |
4112 | @}; | |
4113 | struct U @{ | |
4114 | @dots{} | |
4115 | @}; | |
4116 | U fn() | |
4117 | @{ | |
4118 | T t; | |
4119 | @dots{} | |
4120 | return std::move (t); | |
4121 | @} | |
4122 | @end smallexample | |
4123 | In this example, copy elision isn't applicable because the type of the | |
4124 | expression being returned and the function return type differ, yet G++ | |
4125 | treats the return value as if it were designated by an rvalue. | |
4126 | ||
4127 | This warning is enabled by @option{-Wextra}. | |
4128 | ||
d77de738 ML |
4129 | @opindex Wrange-loop-construct |
4130 | @opindex Wno-range-loop-construct | |
ddf6fe37 | 4131 | @item -Wrange-loop-construct @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4132 | This warning warns when a C++ range-based for-loop is creating an unnecessary |
4133 | copy. This can happen when the range declaration is not a reference, but | |
4134 | probably should be. For example: | |
4135 | ||
4136 | @smallexample | |
4137 | struct S @{ char arr[128]; @}; | |
4138 | void fn () @{ | |
4139 | S arr[5]; | |
4140 | for (const auto x : arr) @{ @dots{} @} | |
4141 | @} | |
4142 | @end smallexample | |
4143 | ||
4144 | It does not warn when the type being copied is a trivially-copyable type whose | |
4145 | size is less than 64 bytes. | |
4146 | ||
4147 | This warning also warns when a loop variable in a range-based for-loop is | |
4148 | initialized with a value of a different type resulting in a copy. For example: | |
4149 | ||
4150 | @smallexample | |
4151 | void fn() @{ | |
4152 | int arr[10]; | |
4153 | for (const double &x : arr) @{ @dots{} @} | |
4154 | @} | |
4155 | @end smallexample | |
4156 | ||
4157 | In the example above, in every iteration of the loop a temporary value of | |
4158 | type @code{double} is created and destroyed, to which the reference | |
4159 | @code{const double &} is bound. | |
4160 | ||
4161 | This warning is enabled by @option{-Wall}. | |
4162 | ||
d77de738 ML |
4163 | @opindex Wredundant-tags |
4164 | @opindex Wno-redundant-tags | |
ddf6fe37 | 4165 | @item -Wredundant-tags @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4166 | Warn about redundant class-key and enum-key in references to class types |
4167 | and enumerated types in contexts where the key can be eliminated without | |
4168 | causing an ambiguity. For example: | |
4169 | ||
4170 | @smallexample | |
4171 | struct foo; | |
4172 | struct foo *p; // warn that keyword struct can be eliminated | |
4173 | @end smallexample | |
4174 | ||
4175 | @noindent | |
4176 | On the other hand, in this example there is no warning: | |
4177 | ||
4178 | @smallexample | |
4179 | struct foo; | |
4180 | void foo (); // "hides" struct foo | |
4181 | void bar (struct foo&); // no warning, keyword struct is necessary | |
4182 | @end smallexample | |
4183 | ||
d77de738 ML |
4184 | @opindex Wsubobject-linkage |
4185 | @opindex Wno-subobject-linkage | |
ddf6fe37 | 4186 | @item -Wno-subobject-linkage @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4187 | Do not warn |
4188 | if a class type has a base or a field whose type uses the anonymous | |
4189 | namespace or depends on a type with no linkage. If a type A depends on | |
4190 | a type B with no or internal linkage, defining it in multiple | |
4191 | translation units would be an ODR violation because the meaning of B | |
4192 | is different in each translation unit. If A only appears in a single | |
4193 | translation unit, the best way to silence the warning is to give it | |
4194 | internal linkage by putting it in an anonymous namespace as well. The | |
4195 | compiler doesn't give this warning for types defined in the main .C | |
4196 | file, as those are unlikely to have multiple definitions. | |
4197 | @option{-Wsubobject-linkage} is enabled by default. | |
4198 | ||
d77de738 ML |
4199 | @opindex Weffc++ |
4200 | @opindex Wno-effc++ | |
ddf6fe37 | 4201 | @item -Weffc++ @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4202 | Warn about violations of the following style guidelines from Scott Meyers' |
4203 | @cite{Effective C++} series of books: | |
4204 | ||
4205 | @itemize @bullet | |
4206 | @item | |
4207 | Define a copy constructor and an assignment operator for classes | |
4208 | with dynamically-allocated memory. | |
4209 | ||
4210 | @item | |
4211 | Prefer initialization to assignment in constructors. | |
4212 | ||
4213 | @item | |
4214 | Have @code{operator=} return a reference to @code{*this}. | |
4215 | ||
4216 | @item | |
4217 | Don't try to return a reference when you must return an object. | |
4218 | ||
4219 | @item | |
4220 | Distinguish between prefix and postfix forms of increment and | |
4221 | decrement operators. | |
4222 | ||
4223 | @item | |
4224 | Never overload @code{&&}, @code{||}, or @code{,}. | |
4225 | ||
4226 | @end itemize | |
4227 | ||
4228 | This option also enables @option{-Wnon-virtual-dtor}, which is also | |
4229 | one of the effective C++ recommendations. However, the check is | |
4230 | extended to warn about the lack of virtual destructor in accessible | |
4231 | non-polymorphic bases classes too. | |
4232 | ||
4233 | When selecting this option, be aware that the standard library | |
4234 | headers do not obey all of these guidelines; use @samp{grep -v} | |
4235 | to filter out those warnings. | |
4236 | ||
d77de738 ML |
4237 | @opindex Wexceptions |
4238 | @opindex Wno-exceptions | |
ddf6fe37 | 4239 | @item -Wno-exceptions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4240 | Disable the warning about the case when an exception handler is shadowed by |
4241 | another handler, which can point out a wrong ordering of exception handlers. | |
4242 | ||
d77de738 ML |
4243 | @opindex Wstrict-null-sentinel |
4244 | @opindex Wno-strict-null-sentinel | |
ddf6fe37 | 4245 | @item -Wstrict-null-sentinel @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4246 | Warn about the use of an uncasted @code{NULL} as sentinel. When |
4247 | compiling only with GCC this is a valid sentinel, as @code{NULL} is defined | |
4248 | to @code{__null}. Although it is a null pointer constant rather than a | |
4249 | null pointer, it is guaranteed to be of the same size as a pointer. | |
4250 | But this use is not portable across different compilers. | |
4251 | ||
d77de738 ML |
4252 | @opindex Wno-non-template-friend |
4253 | @opindex Wnon-template-friend | |
ddf6fe37 | 4254 | @item -Wno-non-template-friend @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4255 | Disable warnings when non-template friend functions are declared |
4256 | within a template. In very old versions of GCC that predate implementation | |
4257 | of the ISO standard, declarations such as | |
4258 | @samp{friend int foo(int)}, where the name of the friend is an unqualified-id, | |
4259 | could be interpreted as a particular specialization of a template | |
4260 | function; the warning exists to diagnose compatibility problems, | |
4261 | and is enabled by default. | |
4262 | ||
d77de738 ML |
4263 | @opindex Wold-style-cast |
4264 | @opindex Wno-old-style-cast | |
ddf6fe37 | 4265 | @item -Wold-style-cast @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4266 | Warn if an old-style (C-style) cast to a non-void type is used within |
4267 | a C++ program. The new-style casts (@code{dynamic_cast}, | |
4268 | @code{static_cast}, @code{reinterpret_cast}, and @code{const_cast}) are | |
4269 | less vulnerable to unintended effects and much easier to search for. | |
4270 | ||
d77de738 ML |
4271 | @opindex Woverloaded-virtual |
4272 | @opindex Wno-overloaded-virtual | |
4273 | @cindex overloaded virtual function, warning | |
4274 | @cindex warning for overloaded virtual function | |
f33d7a88 AA |
4275 | @item -Woverloaded-virtual @r{(C++ and Objective-C++ only)} |
4276 | @itemx -Woverloaded-virtual=@var{n} | |
d77de738 ML |
4277 | Warn when a function declaration hides virtual functions from a |
4278 | base class. For example, in: | |
4279 | ||
4280 | @smallexample | |
4281 | struct A @{ | |
4282 | virtual void f(); | |
4283 | @}; | |
4284 | ||
4285 | struct B: public A @{ | |
4286 | void f(int); // does not override | |
4287 | @}; | |
4288 | @end smallexample | |
4289 | ||
4290 | the @code{A} class version of @code{f} is hidden in @code{B}, and code | |
4291 | like: | |
4292 | ||
4293 | @smallexample | |
4294 | B* b; | |
4295 | b->f(); | |
4296 | @end smallexample | |
4297 | ||
4298 | @noindent | |
4299 | fails to compile. | |
4300 | ||
d82490d5 JW |
4301 | In cases where the different signatures are not an accident, the |
4302 | simplest solution is to add a using-declaration to the derived class | |
4303 | to un-hide the base function, e.g. add @code{using A::f;} to @code{B}. | |
4304 | ||
d77de738 ML |
4305 | The optional level suffix controls the behavior when all the |
4306 | declarations in the derived class override virtual functions in the | |
4307 | base class, even if not all of the base functions are overridden: | |
4308 | ||
4309 | @smallexample | |
4310 | struct C @{ | |
4311 | virtual void f(); | |
4312 | virtual void f(int); | |
4313 | @}; | |
4314 | ||
4315 | struct D: public C @{ | |
4316 | void f(int); // does override | |
4317 | @} | |
4318 | @end smallexample | |
4319 | ||
4320 | This pattern is less likely to be a mistake; if D is only used | |
4321 | virtually, the user might have decided that the base class semantics | |
4322 | for some of the overloads are fine. | |
4323 | ||
4324 | At level 1, this case does not warn; at level 2, it does. | |
4325 | @option{-Woverloaded-virtual} by itself selects level 2. Level 1 is | |
4326 | included in @option{-Wall}. | |
4327 | ||
d77de738 ML |
4328 | @opindex Wno-pmf-conversions |
4329 | @opindex Wpmf-conversions | |
ddf6fe37 | 4330 | @item -Wno-pmf-conversions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4331 | Disable the diagnostic for converting a bound pointer to member function |
4332 | to a plain pointer. | |
4333 | ||
d77de738 ML |
4334 | @opindex Wsign-promo |
4335 | @opindex Wno-sign-promo | |
ddf6fe37 | 4336 | @item -Wsign-promo @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4337 | Warn when overload resolution chooses a promotion from unsigned or |
4338 | enumerated type to a signed type, over a conversion to an unsigned type of | |
4339 | the same size. Previous versions of G++ tried to preserve | |
4340 | unsignedness, but the standard mandates the current behavior. | |
4341 | ||
d77de738 ML |
4342 | @opindex Wtemplates |
4343 | @opindex Wno-templates | |
ddf6fe37 | 4344 | @item -Wtemplates @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4345 | Warn when a primary template declaration is encountered. Some coding |
4346 | rules disallow templates, and this may be used to enforce that rule. | |
4347 | The warning is inactive inside a system header file, such as the STL, so | |
4348 | one can still use the STL. One may also instantiate or specialize | |
4349 | templates. | |
4350 | ||
d77de738 ML |
4351 | @opindex Wmismatched-new-delete |
4352 | @opindex Wno-mismatched-new-delete | |
ddf6fe37 | 4353 | @item -Wmismatched-new-delete @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4354 | Warn for mismatches between calls to @code{operator new} or @code{operator |
4355 | delete} and the corresponding call to the allocation or deallocation function. | |
4356 | This includes invocations of C++ @code{operator delete} with pointers | |
4357 | returned from either mismatched forms of @code{operator new}, or from other | |
4358 | functions that allocate objects for which the @code{operator delete} isn't | |
4359 | a suitable deallocator, as well as calls to other deallocation functions | |
4360 | with pointers returned from @code{operator new} for which the deallocation | |
4361 | function isn't suitable. | |
4362 | ||
4363 | For example, the @code{delete} expression in the function below is diagnosed | |
4364 | because it doesn't match the array form of the @code{new} expression | |
4365 | the pointer argument was returned from. Similarly, the call to @code{free} | |
4366 | is also diagnosed. | |
4367 | ||
4368 | @smallexample | |
4369 | void f () | |
4370 | @{ | |
4371 | int *a = new int[n]; | |
4372 | delete a; // warning: mismatch in array forms of expressions | |
4373 | ||
4374 | char *p = new char[n]; | |
4375 | free (p); // warning: mismatch between new and free | |
4376 | @} | |
4377 | @end smallexample | |
4378 | ||
4379 | The related option @option{-Wmismatched-dealloc} diagnoses mismatches | |
4380 | involving allocation and deallocation functions other than @code{operator | |
4381 | new} and @code{operator delete}. | |
4382 | ||
4383 | @option{-Wmismatched-new-delete} is included in @option{-Wall}. | |
4384 | ||
d77de738 ML |
4385 | @opindex Wmismatched-tags |
4386 | @opindex Wno-mismatched-tags | |
ddf6fe37 | 4387 | @item -Wmismatched-tags @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4388 | Warn for declarations of structs, classes, and class templates and their |
4389 | specializations with a class-key that does not match either the definition | |
4390 | or the first declaration if no definition is provided. | |
4391 | ||
4392 | For example, the declaration of @code{struct Object} in the argument list | |
4393 | of @code{draw} triggers the warning. To avoid it, either remove the redundant | |
4394 | class-key @code{struct} or replace it with @code{class} to match its definition. | |
4395 | @smallexample | |
4396 | class Object @{ | |
4397 | public: | |
4398 | virtual ~Object () = 0; | |
4399 | @}; | |
4400 | void draw (struct Object*); | |
4401 | @end smallexample | |
4402 | ||
4403 | It is not wrong to declare a class with the class-key @code{struct} as | |
4404 | the example above shows. The @option{-Wmismatched-tags} option is intended | |
4405 | to help achieve a consistent style of class declarations. In code that is | |
4406 | intended to be portable to Windows-based compilers the warning helps prevent | |
4407 | unresolved references due to the difference in the mangling of symbols | |
4408 | declared with different class-keys. The option can be used either on its | |
4409 | own or in conjunction with @option{-Wredundant-tags}. | |
4410 | ||
d77de738 ML |
4411 | @opindex Wmultiple-inheritance |
4412 | @opindex Wno-multiple-inheritance | |
ddf6fe37 | 4413 | @item -Wmultiple-inheritance @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4414 | Warn when a class is defined with multiple direct base classes. Some |
4415 | coding rules disallow multiple inheritance, and this may be used to | |
4416 | enforce that rule. The warning is inactive inside a system header file, | |
4417 | such as the STL, so one can still use the STL. One may also define | |
4418 | classes that indirectly use multiple inheritance. | |
4419 | ||
d77de738 ML |
4420 | @opindex Wvirtual-inheritance |
4421 | @opindex Wno-virtual-inheritance | |
ddf6fe37 | 4422 | @item -Wvirtual-inheritance |
d77de738 ML |
4423 | Warn when a class is defined with a virtual direct base class. Some |
4424 | coding rules disallow multiple inheritance, and this may be used to | |
4425 | enforce that rule. The warning is inactive inside a system header file, | |
4426 | such as the STL, so one can still use the STL. One may also define | |
4427 | classes that indirectly use virtual inheritance. | |
4428 | ||
d77de738 ML |
4429 | @opindex Wvirtual-move-assign |
4430 | @opindex Wno-virtual-move-assign | |
ddf6fe37 | 4431 | @item -Wno-virtual-move-assign |
d77de738 ML |
4432 | Suppress warnings about inheriting from a virtual base with a |
4433 | non-trivial C++11 move assignment operator. This is dangerous because | |
4434 | if the virtual base is reachable along more than one path, it is | |
4435 | moved multiple times, which can mean both objects end up in the | |
4436 | moved-from state. If the move assignment operator is written to avoid | |
4437 | moving from a moved-from object, this warning can be disabled. | |
4438 | ||
d77de738 ML |
4439 | @opindex Wnamespaces |
4440 | @opindex Wno-namespaces | |
ddf6fe37 | 4441 | @item -Wnamespaces |
d77de738 ML |
4442 | Warn when a namespace definition is opened. Some coding rules disallow |
4443 | namespaces, and this may be used to enforce that rule. The warning is | |
4444 | inactive inside a system header file, such as the STL, so one can still | |
4445 | use the STL. One may also use using directives and qualified names. | |
4446 | ||
d77de738 ML |
4447 | @opindex Wterminate |
4448 | @opindex Wno-terminate | |
ddf6fe37 | 4449 | @item -Wno-terminate @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4450 | Disable the warning about a throw-expression that will immediately |
4451 | result in a call to @code{terminate}. | |
4452 | ||
d77de738 ML |
4453 | @opindex Wvexing-parse |
4454 | @opindex Wno-vexing-parse | |
ddf6fe37 | 4455 | @item -Wno-vexing-parse @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4456 | Warn about the most vexing parse syntactic ambiguity. This warns about |
4457 | the cases when a declaration looks like a variable definition, but the | |
4458 | C++ language requires it to be interpreted as a function declaration. | |
4459 | For instance: | |
4460 | ||
4461 | @smallexample | |
4462 | void f(double a) @{ | |
4463 | int i(); // extern int i (void); | |
4464 | int n(int(a)); // extern int n (int); | |
4465 | @} | |
4466 | @end smallexample | |
4467 | ||
4468 | Another example: | |
4469 | ||
4470 | @smallexample | |
4471 | struct S @{ S(int); @}; | |
4472 | void f(double a) @{ | |
4473 | S x(int(a)); // extern struct S x (int); | |
4474 | S y(int()); // extern struct S y (int (*) (void)); | |
4475 | S z(); // extern struct S z (void); | |
4476 | @} | |
4477 | @end smallexample | |
4478 | ||
4479 | The warning will suggest options how to deal with such an ambiguity; e.g., | |
4480 | it can suggest removing the parentheses or using braces instead. | |
4481 | ||
4482 | This warning is enabled by default. | |
4483 | ||
d77de738 ML |
4484 | @opindex Wno-class-conversion |
4485 | @opindex Wclass-conversion | |
ddf6fe37 | 4486 | @item -Wno-class-conversion @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4487 | Do not warn when a conversion function converts an |
4488 | object to the same type, to a base class of that type, or to void; such | |
4489 | a conversion function will never be called. | |
4490 | ||
d77de738 ML |
4491 | @opindex Wvolatile |
4492 | @opindex Wno-volatile | |
ddf6fe37 | 4493 | @item -Wvolatile @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4494 | Warn about deprecated uses of the @code{volatile} qualifier. This includes |
4495 | postfix and prefix @code{++} and @code{--} expressions of | |
4496 | @code{volatile}-qualified types, using simple assignments where the left | |
4497 | operand is a @code{volatile}-qualified non-class type for their value, | |
4498 | compound assignments where the left operand is a @code{volatile}-qualified | |
4499 | non-class type, @code{volatile}-qualified function return type, | |
4500 | @code{volatile}-qualified parameter type, and structured bindings of a | |
4501 | @code{volatile}-qualified type. This usage was deprecated in C++20. | |
4502 | ||
4503 | Enabled by default with @option{-std=c++20}. | |
4504 | ||
d77de738 ML |
4505 | @opindex Wzero-as-null-pointer-constant |
4506 | @opindex Wno-zero-as-null-pointer-constant | |
ddf6fe37 | 4507 | @item -Wzero-as-null-pointer-constant @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4508 | Warn when a literal @samp{0} is used as null pointer constant. This can |
4509 | be useful to facilitate the conversion to @code{nullptr} in C++11. | |
4510 | ||
d77de738 ML |
4511 | @opindex Waligned-new |
4512 | @opindex Wno-aligned-new | |
ddf6fe37 | 4513 | @item -Waligned-new |
d77de738 ML |
4514 | Warn about a new-expression of a type that requires greater alignment |
4515 | than the @code{alignof(std::max_align_t)} but uses an allocation | |
4516 | function without an explicit alignment parameter. This option is | |
4517 | enabled by @option{-Wall}. | |
4518 | ||
4519 | Normally this only warns about global allocation functions, but | |
4520 | @option{-Waligned-new=all} also warns about class member allocation | |
4521 | functions. | |
4522 | ||
d77de738 ML |
4523 | @opindex Wplacement-new |
4524 | @opindex Wno-placement-new | |
ddf6fe37 AA |
4525 | @item -Wno-placement-new |
4526 | @itemx -Wplacement-new=@var{n} | |
d77de738 ML |
4527 | Warn about placement new expressions with undefined behavior, such as |
4528 | constructing an object in a buffer that is smaller than the type of | |
4529 | the object. For example, the placement new expression below is diagnosed | |
4530 | because it attempts to construct an array of 64 integers in a buffer only | |
4531 | 64 bytes large. | |
4532 | @smallexample | |
4533 | char buf [64]; | |
4534 | new (buf) int[64]; | |
4535 | @end smallexample | |
4536 | This warning is enabled by default. | |
4537 | ||
4538 | @table @gcctabopt | |
4539 | @item -Wplacement-new=1 | |
4540 | This is the default warning level of @option{-Wplacement-new}. At this | |
4541 | level the warning is not issued for some strictly undefined constructs that | |
4542 | GCC allows as extensions for compatibility with legacy code. For example, | |
4543 | the following @code{new} expression is not diagnosed at this level even | |
4544 | though it has undefined behavior according to the C++ standard because | |
4545 | it writes past the end of the one-element array. | |
4546 | @smallexample | |
4547 | struct S @{ int n, a[1]; @}; | |
4548 | S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]); | |
4549 | new (s->a)int [32](); | |
4550 | @end smallexample | |
4551 | ||
4552 | @item -Wplacement-new=2 | |
4553 | At this level, in addition to diagnosing all the same constructs as at level | |
4554 | 1, a diagnostic is also issued for placement new expressions that construct | |
4555 | an object in the last member of structure whose type is an array of a single | |
4556 | element and whose size is less than the size of the object being constructed. | |
4557 | While the previous example would be diagnosed, the following construct makes | |
4558 | use of the flexible member array extension to avoid the warning at level 2. | |
4559 | @smallexample | |
4560 | struct S @{ int n, a[]; @}; | |
4561 | S *s = (S *)malloc (sizeof *s + 32 * sizeof s->a[0]); | |
4562 | new (s->a)int [32](); | |
4563 | @end smallexample | |
4564 | ||
4565 | @end table | |
4566 | ||
d77de738 ML |
4567 | @opindex Wcatch-value |
4568 | @opindex Wno-catch-value | |
ddf6fe37 AA |
4569 | @item -Wcatch-value |
4570 | @itemx -Wcatch-value=@var{n} @r{(C++ and Objective-C++ only)} | |
d77de738 ML |
4571 | Warn about catch handlers that do not catch via reference. |
4572 | With @option{-Wcatch-value=1} (or @option{-Wcatch-value} for short) | |
4573 | warn about polymorphic class types that are caught by value. | |
4574 | With @option{-Wcatch-value=2} warn about all class types that are caught | |
4575 | by value. With @option{-Wcatch-value=3} warn about all types that are | |
4576 | not caught by reference. @option{-Wcatch-value} is enabled by @option{-Wall}. | |
4577 | ||
d77de738 ML |
4578 | @opindex Wconditionally-supported |
4579 | @opindex Wno-conditionally-supported | |
ddf6fe37 | 4580 | @item -Wconditionally-supported @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4581 | Warn for conditionally-supported (C++11 [intro.defs]) constructs. |
4582 | ||
d77de738 ML |
4583 | @opindex Wdelete-incomplete |
4584 | @opindex Wno-delete-incomplete | |
ddf6fe37 | 4585 | @item -Wno-delete-incomplete @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4586 | Do not warn when deleting a pointer to incomplete type, which may cause |
4587 | undefined behavior at runtime. This warning is enabled by default. | |
4588 | ||
d77de738 ML |
4589 | @opindex Wextra-semi |
4590 | @opindex Wno-extra-semi | |
ddf6fe37 | 4591 | @item -Wextra-semi @r{(C++, Objective-C++ only)} |
d77de738 ML |
4592 | Warn about redundant semicolons after in-class function definitions. |
4593 | ||
d77de738 ML |
4594 | @opindex Winaccessible-base |
4595 | @opindex Wno-inaccessible-base | |
ddf6fe37 | 4596 | @item -Wno-inaccessible-base @r{(C++, Objective-C++ only)} |
d77de738 ML |
4597 | This option controls warnings |
4598 | when a base class is inaccessible in a class derived from it due to | |
4599 | ambiguity. The warning is enabled by default. | |
4600 | Note that the warning for ambiguous virtual | |
4601 | bases is enabled by the @option{-Wextra} option. | |
4602 | @smallexample | |
4603 | @group | |
4604 | struct A @{ int a; @}; | |
4605 | ||
4606 | struct B : A @{ @}; | |
4607 | ||
4608 | struct C : B, A @{ @}; | |
4609 | @end group | |
4610 | @end smallexample | |
4611 | ||
d77de738 ML |
4612 | @opindex Winherited-variadic-ctor |
4613 | @opindex Wno-inherited-variadic-ctor | |
ddf6fe37 | 4614 | @item -Wno-inherited-variadic-ctor |
d77de738 ML |
4615 | Suppress warnings about use of C++11 inheriting constructors when the |
4616 | base class inherited from has a C variadic constructor; the warning is | |
4617 | on by default because the ellipsis is not inherited. | |
4618 | ||
d77de738 ML |
4619 | @opindex Wno-invalid-offsetof |
4620 | @opindex Winvalid-offsetof | |
ddf6fe37 | 4621 | @item -Wno-invalid-offsetof @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4622 | Suppress warnings from applying the @code{offsetof} macro to a non-POD |
4623 | type. According to the 2014 ISO C++ standard, applying @code{offsetof} | |
4624 | to a non-standard-layout type is undefined. In existing C++ implementations, | |
4625 | however, @code{offsetof} typically gives meaningful results. | |
4626 | This flag is for users who are aware that they are | |
4627 | writing nonportable code and who have deliberately chosen to ignore the | |
4628 | warning about it. | |
4629 | ||
4630 | The restrictions on @code{offsetof} may be relaxed in a future version | |
4631 | of the C++ standard. | |
4632 | ||
d77de738 ML |
4633 | @opindex Wsized-deallocation |
4634 | @opindex Wno-sized-deallocation | |
ddf6fe37 | 4635 | @item -Wsized-deallocation @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4636 | Warn about a definition of an unsized deallocation function |
4637 | @smallexample | |
4638 | void operator delete (void *) noexcept; | |
4639 | void operator delete[] (void *) noexcept; | |
4640 | @end smallexample | |
4641 | without a definition of the corresponding sized deallocation function | |
4642 | @smallexample | |
4643 | void operator delete (void *, std::size_t) noexcept; | |
4644 | void operator delete[] (void *, std::size_t) noexcept; | |
4645 | @end smallexample | |
4646 | or vice versa. Enabled by @option{-Wextra} along with | |
4647 | @option{-fsized-deallocation}. | |
4648 | ||
d77de738 ML |
4649 | @opindex Wno-suggest-final-types |
4650 | @opindex Wsuggest-final-types | |
ddf6fe37 | 4651 | @item -Wsuggest-final-types |
d77de738 ML |
4652 | Warn about types with virtual methods where code quality would be improved |
4653 | if the type were declared with the C++11 @code{final} specifier, | |
4654 | or, if possible, | |
4655 | declared in an anonymous namespace. This allows GCC to more aggressively | |
4656 | devirtualize the polymorphic calls. This warning is more effective with | |
4657 | link-time optimization, | |
4658 | where the information about the class hierarchy graph is | |
4659 | more complete. | |
4660 | ||
d77de738 ML |
4661 | @opindex Wno-suggest-final-methods |
4662 | @opindex Wsuggest-final-methods | |
ddf6fe37 | 4663 | @item -Wsuggest-final-methods |
d77de738 ML |
4664 | Warn about virtual methods where code quality would be improved if the method |
4665 | were declared with the C++11 @code{final} specifier, | |
4666 | or, if possible, its type were | |
4667 | declared in an anonymous namespace or with the @code{final} specifier. | |
4668 | This warning is | |
4669 | more effective with link-time optimization, where the information about the | |
4670 | class hierarchy graph is more complete. It is recommended to first consider | |
4671 | suggestions of @option{-Wsuggest-final-types} and then rebuild with new | |
4672 | annotations. | |
4673 | ||
d77de738 ML |
4674 | @opindex Wsuggest-override |
4675 | @opindex Wno-suggest-override | |
ddf6fe37 | 4676 | @item -Wsuggest-override |
d77de738 ML |
4677 | Warn about overriding virtual functions that are not marked with the |
4678 | @code{override} keyword. | |
4679 | ||
d77de738 ML |
4680 | @opindex Wuse-after-free |
4681 | @opindex Wno-use-after-free | |
ddf6fe37 AA |
4682 | @item -Wuse-after-free |
4683 | @itemx -Wuse-after-free=@var{n} | |
d77de738 ML |
4684 | Warn about uses of pointers to dynamically allocated objects that have |
4685 | been rendered indeterminate by a call to a deallocation function. | |
4686 | The warning is enabled at all optimization levels but may yield different | |
4687 | results with optimization than without. | |
4688 | ||
4689 | @table @gcctabopt | |
4690 | @item -Wuse-after-free=1 | |
4691 | At level 1 the warning attempts to diagnose only unconditional uses | |
4692 | of pointers made indeterminate by a deallocation call or a successful | |
4693 | call to @code{realloc}, regardless of whether or not the call resulted | |
4694 | in an actual reallocatio of memory. This includes double-@code{free} | |
4695 | calls as well as uses in arithmetic and relational expressions. Although | |
4696 | undefined, uses of indeterminate pointers in equality (or inequality) | |
4697 | expressions are not diagnosed at this level. | |
4698 | @item -Wuse-after-free=2 | |
4699 | At level 2, in addition to unconditional uses, the warning also diagnoses | |
4700 | conditional uses of pointers made indeterminate by a deallocation call. | |
4701 | As at level 2, uses in equality (or inequality) expressions are not | |
4702 | diagnosed. For example, the second call to @code{free} in the following | |
4703 | function is diagnosed at this level: | |
4704 | @smallexample | |
4705 | struct A @{ int refcount; void *data; @}; | |
4706 | ||
4707 | void release (struct A *p) | |
4708 | @{ | |
4709 | int refcount = --p->refcount; | |
4710 | free (p); | |
4711 | if (refcount == 0) | |
4712 | free (p->data); // warning: p may be used after free | |
4713 | @} | |
4714 | @end smallexample | |
4715 | @item -Wuse-after-free=3 | |
4716 | At level 3, the warning also diagnoses uses of indeterminate pointers in | |
4717 | equality expressions. All uses of indeterminate pointers are undefined | |
4718 | but equality tests sometimes appear after calls to @code{realloc} as | |
4719 | an attempt to determine whether the call resulted in relocating the object | |
4720 | to a different address. They are diagnosed at a separate level to aid | |
4721 | legacy code gradually transition to safe alternatives. For example, | |
4722 | the equality test in the function below is diagnosed at this level: | |
4723 | @smallexample | |
4724 | void adjust_pointers (int**, int); | |
4725 | ||
4726 | void grow (int **p, int n) | |
4727 | @{ | |
4728 | int **q = (int**)realloc (p, n *= 2); | |
4729 | if (q == p) | |
4730 | return; | |
4731 | adjust_pointers ((int**)q, n); | |
4732 | @} | |
4733 | @end smallexample | |
4734 | To avoid the warning at this level, store offsets into allocated memory | |
4735 | instead of pointers. This approach obviates needing to adjust the stored | |
4736 | pointers after reallocation. | |
4737 | @end table | |
4738 | ||
4739 | @option{-Wuse-after-free=2} is included in @option{-Wall}. | |
4740 | ||
d77de738 ML |
4741 | @opindex Wuseless-cast |
4742 | @opindex Wno-useless-cast | |
ddf6fe37 | 4743 | @item -Wuseless-cast @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4744 | Warn when an expression is cast to its own type. This warning does not |
4745 | occur when a class object is converted to a non-reference type as that | |
4746 | is a way to create a temporary: | |
4747 | ||
4748 | @smallexample | |
4749 | struct S @{ @}; | |
4750 | void g (S&&); | |
4751 | void f (S&& arg) | |
4752 | @{ | |
4753 | g (S(arg)); // make arg prvalue so that it can bind to S&& | |
4754 | @} | |
4755 | @end smallexample | |
4756 | ||
d77de738 ML |
4757 | @opindex Wconversion-null |
4758 | @opindex Wno-conversion-null | |
ddf6fe37 | 4759 | @item -Wno-conversion-null @r{(C++ and Objective-C++ only)} |
d77de738 ML |
4760 | Do not warn for conversions between @code{NULL} and non-pointer |
4761 | types. @option{-Wconversion-null} is enabled by default. | |
4762 | ||
4763 | @end table | |
4764 | ||
4765 | @node Objective-C and Objective-C++ Dialect Options | |
4766 | @section Options Controlling Objective-C and Objective-C++ Dialects | |
4767 | ||
4768 | @cindex compiler options, Objective-C and Objective-C++ | |
4769 | @cindex Objective-C and Objective-C++ options, command-line | |
4770 | @cindex options, Objective-C and Objective-C++ | |
4771 | (NOTE: This manual does not describe the Objective-C and Objective-C++ | |
4772 | languages themselves. @xref{Standards,,Language Standards | |
4773 | Supported by GCC}, for references.) | |
4774 | ||
4775 | This section describes the command-line options that are only meaningful | |
4776 | for Objective-C and Objective-C++ programs. You can also use most of | |
4777 | the language-independent GNU compiler options. | |
4778 | For example, you might compile a file @file{some_class.m} like this: | |
4779 | ||
4780 | @smallexample | |
4781 | gcc -g -fgnu-runtime -O -c some_class.m | |
4782 | @end smallexample | |
4783 | ||
4784 | @noindent | |
4785 | In this example, @option{-fgnu-runtime} is an option meant only for | |
4786 | Objective-C and Objective-C++ programs; you can use the other options with | |
4787 | any language supported by GCC@. | |
4788 | ||
4789 | Note that since Objective-C is an extension of the C language, Objective-C | |
4790 | compilations may also use options specific to the C front-end (e.g., | |
4791 | @option{-Wtraditional}). Similarly, Objective-C++ compilations may use | |
4792 | C++-specific options (e.g., @option{-Wabi}). | |
4793 | ||
4794 | Here is a list of options that are @emph{only} for compiling Objective-C | |
4795 | and Objective-C++ programs: | |
4796 | ||
4797 | @table @gcctabopt | |
d77de738 | 4798 | @opindex fconstant-string-class |
ddf6fe37 | 4799 | @item -fconstant-string-class=@var{class-name} |
d77de738 ML |
4800 | Use @var{class-name} as the name of the class to instantiate for each |
4801 | literal string specified with the syntax @code{@@"@dots{}"}. The default | |
4802 | class name is @code{NXConstantString} if the GNU runtime is being used, and | |
4803 | @code{NSConstantString} if the NeXT runtime is being used (see below). The | |
4804 | @option{-fconstant-cfstrings} option, if also present, overrides the | |
4805 | @option{-fconstant-string-class} setting and cause @code{@@"@dots{}"} literals | |
4806 | to be laid out as constant CoreFoundation strings. | |
4807 | ||
d77de738 | 4808 | @opindex fgnu-runtime |
ddf6fe37 | 4809 | @item -fgnu-runtime |
d77de738 ML |
4810 | Generate object code compatible with the standard GNU Objective-C |
4811 | runtime. This is the default for most types of systems. | |
4812 | ||
d77de738 | 4813 | @opindex fnext-runtime |
ddf6fe37 | 4814 | @item -fnext-runtime |
d77de738 ML |
4815 | Generate output compatible with the NeXT runtime. This is the default |
4816 | for NeXT-based systems, including Darwin and Mac OS X@. The macro | |
4817 | @code{__NEXT_RUNTIME__} is predefined if (and only if) this option is | |
4818 | used. | |
4819 | ||
d77de738 ML |
4820 | @opindex fno-nil-receivers |
4821 | @opindex fnil-receivers | |
ddf6fe37 | 4822 | @item -fno-nil-receivers |
d77de738 ML |
4823 | Assume that all Objective-C message dispatches (@code{[receiver |
4824 | message:arg]}) in this translation unit ensure that the receiver is | |
4825 | not @code{nil}. This allows for more efficient entry points in the | |
4826 | runtime to be used. This option is only available in conjunction with | |
4827 | the NeXT runtime and ABI version 0 or 1. | |
4828 | ||
d77de738 | 4829 | @opindex fobjc-abi-version |
ddf6fe37 | 4830 | @item -fobjc-abi-version=@var{n} |
d77de738 ML |
4831 | Use version @var{n} of the Objective-C ABI for the selected runtime. |
4832 | This option is currently supported only for the NeXT runtime. In that | |
4833 | case, Version 0 is the traditional (32-bit) ABI without support for | |
4834 | properties and other Objective-C 2.0 additions. Version 1 is the | |
4835 | traditional (32-bit) ABI with support for properties and other | |
4836 | Objective-C 2.0 additions. Version 2 is the modern (64-bit) ABI. If | |
4837 | nothing is specified, the default is Version 0 on 32-bit target | |
4838 | machines, and Version 2 on 64-bit target machines. | |
4839 | ||
d77de738 | 4840 | @opindex fobjc-call-cxx-cdtors |
ddf6fe37 | 4841 | @item -fobjc-call-cxx-cdtors |
d77de738 ML |
4842 | For each Objective-C class, check if any of its instance variables is a |
4843 | C++ object with a non-trivial default constructor. If so, synthesize a | |
4844 | special @code{- (id) .cxx_construct} instance method which runs | |
4845 | non-trivial default constructors on any such instance variables, in order, | |
4846 | and then return @code{self}. Similarly, check if any instance variable | |
4847 | is a C++ object with a non-trivial destructor, and if so, synthesize a | |
4848 | special @code{- (void) .cxx_destruct} method which runs | |
4849 | all such default destructors, in reverse order. | |
4850 | ||
4851 | The @code{- (id) .cxx_construct} and @code{- (void) .cxx_destruct} | |
4852 | methods thusly generated only operate on instance variables | |
4853 | declared in the current Objective-C class, and not those inherited | |
4854 | from superclasses. It is the responsibility of the Objective-C | |
4855 | runtime to invoke all such methods in an object's inheritance | |
4856 | hierarchy. The @code{- (id) .cxx_construct} methods are invoked | |
4857 | by the runtime immediately after a new object instance is allocated; | |
4858 | the @code{- (void) .cxx_destruct} methods are invoked immediately | |
4859 | before the runtime deallocates an object instance. | |
4860 | ||
4861 | As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has | |
4862 | support for invoking the @code{- (id) .cxx_construct} and | |
4863 | @code{- (void) .cxx_destruct} methods. | |
4864 | ||
d77de738 | 4865 | @opindex fobjc-direct-dispatch |
ddf6fe37 | 4866 | @item -fobjc-direct-dispatch |
d77de738 ML |
4867 | Allow fast jumps to the message dispatcher. On Darwin this is |
4868 | accomplished via the comm page. | |
4869 | ||
d77de738 | 4870 | @opindex fobjc-exceptions |
ddf6fe37 | 4871 | @item -fobjc-exceptions |
d77de738 ML |
4872 | Enable syntactic support for structured exception handling in |
4873 | Objective-C, similar to what is offered by C++. This option | |
4874 | is required to use the Objective-C keywords @code{@@try}, | |
4875 | @code{@@throw}, @code{@@catch}, @code{@@finally} and | |
4876 | @code{@@synchronized}. This option is available with both the GNU | |
4877 | runtime and the NeXT runtime (but not available in conjunction with | |
4878 | the NeXT runtime on Mac OS X 10.2 and earlier). | |
4879 | ||
d77de738 | 4880 | @opindex fobjc-gc |
ddf6fe37 | 4881 | @item -fobjc-gc |
d77de738 ML |
4882 | Enable garbage collection (GC) in Objective-C and Objective-C++ |
4883 | programs. This option is only available with the NeXT runtime; the | |
4884 | GNU runtime has a different garbage collection implementation that | |
4885 | does not require special compiler flags. | |
4886 | ||
d77de738 | 4887 | @opindex fobjc-nilcheck |
ddf6fe37 | 4888 | @item -fobjc-nilcheck |
d77de738 ML |
4889 | For the NeXT runtime with version 2 of the ABI, check for a nil |
4890 | receiver in method invocations before doing the actual method call. | |
4891 | This is the default and can be disabled using | |
4892 | @option{-fno-objc-nilcheck}. Class methods and super calls are never | |
4893 | checked for nil in this way no matter what this flag is set to. | |
4894 | Currently this flag does nothing when the GNU runtime, or an older | |
4895 | version of the NeXT runtime ABI, is used. | |
4896 | ||
d77de738 | 4897 | @opindex fobjc-std |
ddf6fe37 | 4898 | @item -fobjc-std=objc1 |
d77de738 ML |
4899 | Conform to the language syntax of Objective-C 1.0, the language |
4900 | recognized by GCC 4.0. This only affects the Objective-C additions to | |
4901 | the C/C++ language; it does not affect conformance to C/C++ standards, | |
4902 | which is controlled by the separate C/C++ dialect option flags. When | |
4903 | this option is used with the Objective-C or Objective-C++ compiler, | |
4904 | any Objective-C syntax that is not recognized by GCC 4.0 is rejected. | |
4905 | This is useful if you need to make sure that your Objective-C code can | |
4906 | be compiled with older versions of GCC@. | |
4907 | ||
d77de738 | 4908 | @opindex freplace-objc-classes |
ddf6fe37 | 4909 | @item -freplace-objc-classes |
d77de738 ML |
4910 | Emit a special marker instructing @command{ld(1)} not to statically link in |
4911 | the resulting object file, and allow @command{dyld(1)} to load it in at | |
4912 | run time instead. This is used in conjunction with the Fix-and-Continue | |
4913 | debugging mode, where the object file in question may be recompiled and | |
4914 | dynamically reloaded in the course of program execution, without the need | |
4915 | to restart the program itself. Currently, Fix-and-Continue functionality | |
4916 | is only available in conjunction with the NeXT runtime on Mac OS X 10.3 | |
4917 | and later. | |
4918 | ||
d77de738 | 4919 | @opindex fzero-link |
ddf6fe37 | 4920 | @item -fzero-link |
d77de738 ML |
4921 | When compiling for the NeXT runtime, the compiler ordinarily replaces calls |
4922 | to @code{objc_getClass("@dots{}")} (when the name of the class is known at | |
4923 | compile time) with static class references that get initialized at load time, | |
4924 | which improves run-time performance. Specifying the @option{-fzero-link} flag | |
4925 | suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")} | |
4926 | to be retained. This is useful in Zero-Link debugging mode, since it allows | |
4927 | for individual class implementations to be modified during program execution. | |
4928 | The GNU runtime currently always retains calls to @code{objc_get_class("@dots{}")} | |
4929 | regardless of command-line options. | |
4930 | ||
d77de738 ML |
4931 | @opindex fno-local-ivars |
4932 | @opindex flocal-ivars | |
ddf6fe37 | 4933 | @item -fno-local-ivars |
d77de738 ML |
4934 | By default instance variables in Objective-C can be accessed as if |
4935 | they were local variables from within the methods of the class they're | |
4936 | declared in. This can lead to shadowing between instance variables | |
4937 | and other variables declared either locally inside a class method or | |
4938 | globally with the same name. Specifying the @option{-fno-local-ivars} | |
4939 | flag disables this behavior thus avoiding variable shadowing issues. | |
4940 | ||
d77de738 | 4941 | @opindex fivar-visibility |
ddf6fe37 | 4942 | @item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]} |
d77de738 ML |
4943 | Set the default instance variable visibility to the specified option |
4944 | so that instance variables declared outside the scope of any access | |
4945 | modifier directives default to the specified visibility. | |
4946 | ||
d77de738 | 4947 | @opindex gen-decls |
ddf6fe37 | 4948 | @item -gen-decls |
d77de738 ML |
4949 | Dump interface declarations for all classes seen in the source file to a |
4950 | file named @file{@var{sourcename}.decl}. | |
4951 | ||
d77de738 ML |
4952 | @opindex Wassign-intercept |
4953 | @opindex Wno-assign-intercept | |
ddf6fe37 | 4954 | @item -Wassign-intercept @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
4955 | Warn whenever an Objective-C assignment is being intercepted by the |
4956 | garbage collector. | |
4957 | ||
d77de738 ML |
4958 | @opindex Wproperty-assign-default |
4959 | @opindex Wno-property-assign-default | |
ddf6fe37 | 4960 | @item -Wno-property-assign-default @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
4961 | Do not warn if a property for an Objective-C object has no assign |
4962 | semantics specified. | |
4963 | ||
d77de738 ML |
4964 | @opindex Wno-protocol |
4965 | @opindex Wprotocol | |
ddf6fe37 | 4966 | @item -Wno-protocol @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
4967 | If a class is declared to implement a protocol, a warning is issued for |
4968 | every method in the protocol that is not implemented by the class. The | |
4969 | default behavior is to issue a warning for every method not explicitly | |
4970 | implemented in the class, even if a method implementation is inherited | |
4971 | from the superclass. If you use the @option{-Wno-protocol} option, then | |
4972 | methods inherited from the superclass are considered to be implemented, | |
4973 | and no warning is issued for them. | |
4974 | ||
d77de738 | 4975 | @opindex Wobjc-root-class |
ddf6fe37 | 4976 | @item -Wobjc-root-class @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
4977 | Warn if a class interface lacks a superclass. Most classes will inherit |
4978 | from @code{NSObject} (or @code{Object}) for example. When declaring | |
4979 | classes intended to be root classes, the warning can be suppressed by | |
4980 | marking their interfaces with @code{__attribute__((objc_root_class))}. | |
4981 | ||
d77de738 ML |
4982 | @opindex Wselector |
4983 | @opindex Wno-selector | |
ddf6fe37 | 4984 | @item -Wselector @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
4985 | Warn if multiple methods of different types for the same selector are |
4986 | found during compilation. The check is performed on the list of methods | |
4987 | in the final stage of compilation. Additionally, a check is performed | |
4988 | for each selector appearing in a @code{@@selector(@dots{})} | |
4989 | expression, and a corresponding method for that selector has been found | |
4990 | during compilation. Because these checks scan the method table only at | |
4991 | the end of compilation, these warnings are not produced if the final | |
4992 | stage of compilation is not reached, for example because an error is | |
4993 | found during compilation, or because the @option{-fsyntax-only} option is | |
4994 | being used. | |
4995 | ||
d77de738 ML |
4996 | @opindex Wstrict-selector-match |
4997 | @opindex Wno-strict-selector-match | |
ddf6fe37 | 4998 | @item -Wstrict-selector-match @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
4999 | Warn if multiple methods with differing argument and/or return types are |
5000 | found for a given selector when attempting to send a message using this | |
5001 | selector to a receiver of type @code{id} or @code{Class}. When this flag | |
5002 | is off (which is the default behavior), the compiler omits such warnings | |
5003 | if any differences found are confined to types that share the same size | |
5004 | and alignment. | |
5005 | ||
d77de738 ML |
5006 | @opindex Wundeclared-selector |
5007 | @opindex Wno-undeclared-selector | |
ddf6fe37 | 5008 | @item -Wundeclared-selector @r{(Objective-C and Objective-C++ only)} |
d77de738 ML |
5009 | Warn if a @code{@@selector(@dots{})} expression referring to an |
5010 | undeclared selector is found. A selector is considered undeclared if no | |
5011 | method with that name has been declared before the | |
5012 | @code{@@selector(@dots{})} expression, either explicitly in an | |
5013 | @code{@@interface} or @code{@@protocol} declaration, or implicitly in | |
5014 | an @code{@@implementation} section. This option always performs its | |
5015 | checks as soon as a @code{@@selector(@dots{})} expression is found, | |
5016 | while @option{-Wselector} only performs its checks in the final stage of | |
5017 | compilation. This also enforces the coding style convention | |
5018 | that methods and selectors must be declared before being used. | |
5019 | ||
d77de738 | 5020 | @opindex print-objc-runtime-info |
ddf6fe37 | 5021 | @item -print-objc-runtime-info |
d77de738 ML |
5022 | Generate C header describing the largest structure that is passed by |
5023 | value, if any. | |
5024 | ||
5025 | @end table | |
5026 | ||
5027 | @node Diagnostic Message Formatting Options | |
5028 | @section Options to Control Diagnostic Messages Formatting | |
5029 | @cindex options to control diagnostics formatting | |
5030 | @cindex diagnostic messages | |
5031 | @cindex message formatting | |
5032 | ||
5033 | Traditionally, diagnostic messages have been formatted irrespective of | |
5034 | the output device's aspect (e.g.@: its width, @dots{}). You can use the | |
5035 | options described below | |
5036 | to control the formatting algorithm for diagnostic messages, | |
5037 | e.g.@: how many characters per line, how often source location | |
5038 | information should be reported. Note that some language front ends may not | |
5039 | honor these options. | |
5040 | ||
5041 | @table @gcctabopt | |
d77de738 | 5042 | @opindex fmessage-length |
ddf6fe37 | 5043 | @item -fmessage-length=@var{n} |
d77de738 ML |
5044 | Try to format error messages so that they fit on lines of about |
5045 | @var{n} characters. If @var{n} is zero, then no line-wrapping is | |
5046 | done; each error message appears on a single line. This is the | |
5047 | default for all front ends. | |
5048 | ||
5049 | Note - this option also affects the display of the @samp{#error} and | |
5050 | @samp{#warning} pre-processor directives, and the @samp{deprecated} | |
5051 | function/type/variable attribute. It does not however affect the | |
5052 | @samp{pragma GCC warning} and @samp{pragma GCC error} pragmas. | |
5053 | ||
5054 | @item -fdiagnostics-plain-output | |
5055 | This option requests that diagnostic output look as plain as possible, which | |
5056 | may be useful when running @command{dejagnu} or other utilities that need to | |
5057 | parse diagnostics output and prefer that it remain more stable over time. | |
5058 | @option{-fdiagnostics-plain-output} is currently equivalent to the following | |
5059 | options: | |
43b72ede AA |
5060 | @gccoptlist{-fno-diagnostics-show-caret |
5061 | -fno-diagnostics-show-line-numbers | |
5062 | -fdiagnostics-color=never | |
5063 | -fdiagnostics-urls=never | |
d77de738 ML |
5064 | -fdiagnostics-path-format=separate-events} |
5065 | In the future, if GCC changes the default appearance of its diagnostics, the | |
5066 | corresponding option to disable the new behavior will be added to this list. | |
5067 | ||
d77de738 | 5068 | @opindex fdiagnostics-show-location |
ddf6fe37 | 5069 | @item -fdiagnostics-show-location=once |
d77de738 ML |
5070 | Only meaningful in line-wrapping mode. Instructs the diagnostic messages |
5071 | reporter to emit source location information @emph{once}; that is, in | |
5072 | case the message is too long to fit on a single physical line and has to | |
5073 | be wrapped, the source location won't be emitted (as prefix) again, | |
5074 | over and over, in subsequent continuation lines. This is the default | |
5075 | behavior. | |
5076 | ||
5077 | @item -fdiagnostics-show-location=every-line | |
5078 | Only meaningful in line-wrapping mode. Instructs the diagnostic | |
5079 | messages reporter to emit the same source location information (as | |
5080 | prefix) for physical lines that result from the process of breaking | |
5081 | a message which is too long to fit on a single line. | |
5082 | ||
ddf6fe37 | 5083 | @opindex fdiagnostics-color |
d77de738 ML |
5084 | @cindex highlight, color |
5085 | @vindex GCC_COLORS @r{environment variable} | |
f33d7a88 AA |
5086 | @item -fdiagnostics-color[=@var{WHEN}] |
5087 | @itemx -fno-diagnostics-color | |
d77de738 ML |
5088 | Use color in diagnostics. @var{WHEN} is @samp{never}, @samp{always}, |
5089 | or @samp{auto}. The default depends on how the compiler has been configured, | |
5090 | it can be any of the above @var{WHEN} options or also @samp{never} | |
5091 | if @env{GCC_COLORS} environment variable isn't present in the environment, | |
5092 | and @samp{auto} otherwise. | |
5093 | @samp{auto} makes GCC use color only when the standard error is a terminal, | |
5094 | and when not executing in an emacs shell. | |
5095 | The forms @option{-fdiagnostics-color} and @option{-fno-diagnostics-color} are | |
5096 | aliases for @option{-fdiagnostics-color=always} and | |
5097 | @option{-fdiagnostics-color=never}, respectively. | |
5098 | ||
5099 | The colors are defined by the environment variable @env{GCC_COLORS}. | |
5100 | Its value is a colon-separated list of capabilities and Select Graphic | |
5101 | Rendition (SGR) substrings. SGR commands are interpreted by the | |
5102 | terminal or terminal emulator. (See the section in the documentation | |
5103 | of your text terminal for permitted values and their meanings as | |
5104 | character attributes.) These substring values are integers in decimal | |
5105 | representation and can be concatenated with semicolons. | |
5106 | Common values to concatenate include | |
5107 | @samp{1} for bold, | |
5108 | @samp{4} for underline, | |
5109 | @samp{5} for blink, | |
5110 | @samp{7} for inverse, | |
5111 | @samp{39} for default foreground color, | |
5112 | @samp{30} to @samp{37} for foreground colors, | |
5113 | @samp{90} to @samp{97} for 16-color mode foreground colors, | |
5114 | @samp{38;5;0} to @samp{38;5;255} | |
5115 | for 88-color and 256-color modes foreground colors, | |
5116 | @samp{49} for default background color, | |
5117 | @samp{40} to @samp{47} for background colors, | |
5118 | @samp{100} to @samp{107} for 16-color mode background colors, | |
5119 | and @samp{48;5;0} to @samp{48;5;255} | |
5120 | for 88-color and 256-color modes background colors. | |
5121 | ||
5122 | The default @env{GCC_COLORS} is | |
5123 | @smallexample | |
5124 | error=01;31:warning=01;35:note=01;36:range1=32:range2=34:locus=01:\ | |
5125 | quote=01:path=01;36:fixit-insert=32:fixit-delete=31:\ | |
5126 | diff-filename=01:diff-hunk=32:diff-delete=31:diff-insert=32:\ | |
5127 | type-diff=01;32:fnname=01;32:targs=35 | |
5128 | @end smallexample | |
5129 | @noindent | |
5130 | where @samp{01;31} is bold red, @samp{01;35} is bold magenta, | |
5131 | @samp{01;36} is bold cyan, @samp{32} is green, @samp{34} is blue, | |
5132 | @samp{01} is bold, and @samp{31} is red. | |
5133 | Setting @env{GCC_COLORS} to the empty string disables colors. | |
5134 | Supported capabilities are as follows. | |
5135 | ||
5136 | @table @code | |
d77de738 | 5137 | @vindex error GCC_COLORS @r{capability} |
f33d7a88 | 5138 | @item error= |
d77de738 ML |
5139 | SGR substring for error: markers. |
5140 | ||
d77de738 | 5141 | @vindex warning GCC_COLORS @r{capability} |
f33d7a88 | 5142 | @item warning= |
d77de738 ML |
5143 | SGR substring for warning: markers. |
5144 | ||
d77de738 | 5145 | @vindex note GCC_COLORS @r{capability} |
f33d7a88 | 5146 | @item note= |
d77de738 ML |
5147 | SGR substring for note: markers. |
5148 | ||
d77de738 | 5149 | @vindex path GCC_COLORS @r{capability} |
f33d7a88 | 5150 | @item path= |
d77de738 ML |
5151 | SGR substring for colorizing paths of control-flow events as printed |
5152 | via @option{-fdiagnostics-path-format=}, such as the identifiers of | |
5153 | individual events and lines indicating interprocedural calls and returns. | |
5154 | ||
d77de738 | 5155 | @vindex range1 GCC_COLORS @r{capability} |
f33d7a88 | 5156 | @item range1= |
d77de738 ML |
5157 | SGR substring for first additional range. |
5158 | ||
d77de738 | 5159 | @vindex range2 GCC_COLORS @r{capability} |
f33d7a88 | 5160 | @item range2= |
d77de738 ML |
5161 | SGR substring for second additional range. |
5162 | ||
d77de738 | 5163 | @vindex locus GCC_COLORS @r{capability} |
f33d7a88 | 5164 | @item locus= |
d77de738 ML |
5165 | SGR substring for location information, @samp{file:line} or |
5166 | @samp{file:line:column} etc. | |
5167 | ||
d77de738 | 5168 | @vindex quote GCC_COLORS @r{capability} |
f33d7a88 | 5169 | @item quote= |
d77de738 ML |
5170 | SGR substring for information printed within quotes. |
5171 | ||
d77de738 | 5172 | @vindex fnname GCC_COLORS @r{capability} |
f33d7a88 | 5173 | @item fnname= |
d77de738 ML |
5174 | SGR substring for names of C++ functions. |
5175 | ||
d77de738 | 5176 | @vindex targs GCC_COLORS @r{capability} |
f33d7a88 | 5177 | @item targs= |
d77de738 ML |
5178 | SGR substring for C++ function template parameter bindings. |
5179 | ||
d77de738 | 5180 | @vindex fixit-insert GCC_COLORS @r{capability} |
f33d7a88 | 5181 | @item fixit-insert= |
d77de738 ML |
5182 | SGR substring for fix-it hints suggesting text to |
5183 | be inserted or replaced. | |
5184 | ||
d77de738 | 5185 | @vindex fixit-delete GCC_COLORS @r{capability} |
f33d7a88 | 5186 | @item fixit-delete= |
d77de738 ML |
5187 | SGR substring for fix-it hints suggesting text to |
5188 | be deleted. | |
5189 | ||
d77de738 | 5190 | @vindex diff-filename GCC_COLORS @r{capability} |
f33d7a88 | 5191 | @item diff-filename= |
d77de738 ML |
5192 | SGR substring for filename headers within generated patches. |
5193 | ||
d77de738 | 5194 | @vindex diff-hunk GCC_COLORS @r{capability} |
f33d7a88 | 5195 | @item diff-hunk= |
d77de738 ML |
5196 | SGR substring for the starts of hunks within generated patches. |
5197 | ||
d77de738 | 5198 | @vindex diff-delete GCC_COLORS @r{capability} |
f33d7a88 | 5199 | @item diff-delete= |
d77de738 ML |
5200 | SGR substring for deleted lines within generated patches. |
5201 | ||
d77de738 | 5202 | @vindex diff-insert GCC_COLORS @r{capability} |
f33d7a88 | 5203 | @item diff-insert= |
d77de738 ML |
5204 | SGR substring for inserted lines within generated patches. |
5205 | ||
d77de738 | 5206 | @vindex type-diff GCC_COLORS @r{capability} |
f33d7a88 | 5207 | @item type-diff= |
d77de738 ML |
5208 | SGR substring for highlighting mismatching types within template |
5209 | arguments in the C++ frontend. | |
5210 | @end table | |
5211 | ||
d77de738 ML |
5212 | @opindex fdiagnostics-urls |
5213 | @cindex urls | |
5214 | @vindex GCC_URLS @r{environment variable} | |
5215 | @vindex TERM_URLS @r{environment variable} | |
f33d7a88 | 5216 | @item -fdiagnostics-urls[=@var{WHEN}] |
d77de738 ML |
5217 | Use escape sequences to embed URLs in diagnostics. For example, when |
5218 | @option{-fdiagnostics-show-option} emits text showing the command-line | |
5219 | option controlling a diagnostic, embed a URL for documentation of that | |
5220 | option. | |
5221 | ||
5222 | @var{WHEN} is @samp{never}, @samp{always}, or @samp{auto}. | |
5223 | @samp{auto} makes GCC use URL escape sequences only when the standard error | |
5224 | is a terminal, and when not executing in an emacs shell or any graphical | |
5225 | terminal which is known to be incompatible with this feature, see below. | |
5226 | ||
5227 | The default depends on how the compiler has been configured. | |
5228 | It can be any of the above @var{WHEN} options. | |
5229 | ||
5230 | GCC can also be configured (via the | |
5231 | @option{--with-diagnostics-urls=auto-if-env} configure-time option) | |
5232 | so that the default is affected by environment variables. | |
5233 | Under such a configuration, GCC defaults to using @samp{auto} | |
5234 | if either @env{GCC_URLS} or @env{TERM_URLS} environment variables are | |
5235 | present and non-empty in the environment of the compiler, or @samp{never} | |
5236 | if neither are. | |
5237 | ||
5238 | However, even with @option{-fdiagnostics-urls=always} the behavior is | |
5239 | dependent on those environment variables: | |
5240 | If @env{GCC_URLS} is set to empty or @samp{no}, do not embed URLs in | |
5241 | diagnostics. If set to @samp{st}, URLs use ST escape sequences. | |
5242 | If set to @samp{bel}, the default, URLs use BEL escape sequences. | |
5243 | Any other non-empty value enables the feature. | |
5244 | If @env{GCC_URLS} is not set, use @env{TERM_URLS} as a fallback. | |
5245 | Note: ST is an ANSI escape sequence, string terminator @samp{ESC \}, | |
5246 | BEL is an ASCII character, CTRL-G that usually sounds like a beep. | |
5247 | ||
5248 | At this time GCC tries to detect also a few terminals that are known to | |
5249 | not implement the URL feature, and have bugs or at least had bugs in | |
5250 | some versions that are still in use, where the URL escapes are likely | |
5251 | to misbehave, i.e. print garbage on the screen. | |
5252 | That list is currently xfce4-terminal, certain known to be buggy | |
5253 | gnome-terminal versions, the linux console, and mingw. | |
5254 | This check can be skipped with the @option{-fdiagnostics-urls=always}. | |
5255 | ||
d77de738 ML |
5256 | @opindex fno-diagnostics-show-option |
5257 | @opindex fdiagnostics-show-option | |
ddf6fe37 | 5258 | @item -fno-diagnostics-show-option |
d77de738 ML |
5259 | By default, each diagnostic emitted includes text indicating the |
5260 | command-line option that directly controls the diagnostic (if such an | |
5261 | option is known to the diagnostic machinery). Specifying the | |
5262 | @option{-fno-diagnostics-show-option} flag suppresses that behavior. | |
5263 | ||
d77de738 ML |
5264 | @opindex fno-diagnostics-show-caret |
5265 | @opindex fdiagnostics-show-caret | |
ddf6fe37 | 5266 | @item -fno-diagnostics-show-caret |
d77de738 ML |
5267 | By default, each diagnostic emitted includes the original source line |
5268 | and a caret @samp{^} indicating the column. This option suppresses this | |
5269 | information. The source line is truncated to @var{n} characters, if | |
5270 | the @option{-fmessage-length=n} option is given. When the output is done | |
5271 | to the terminal, the width is limited to the width given by the | |
5272 | @env{COLUMNS} environment variable or, if not set, to the terminal width. | |
5273 | ||
d77de738 ML |
5274 | @opindex fno-diagnostics-show-labels |
5275 | @opindex fdiagnostics-show-labels | |
ddf6fe37 | 5276 | @item -fno-diagnostics-show-labels |
d77de738 ML |
5277 | By default, when printing source code (via @option{-fdiagnostics-show-caret}), |
5278 | diagnostics can label ranges of source code with pertinent information, such | |
5279 | as the types of expressions: | |
5280 | ||
5281 | @smallexample | |
5282 | printf ("foo %s bar", long_i + long_j); | |
5283 | ~^ ~~~~~~~~~~~~~~~ | |
5284 | | | | |
5285 | char * long int | |
5286 | @end smallexample | |
5287 | ||
5288 | This option suppresses the printing of these labels (in the example above, | |
5289 | the vertical bars and the ``char *'' and ``long int'' text). | |
5290 | ||
d77de738 ML |
5291 | @opindex fno-diagnostics-show-cwe |
5292 | @opindex fdiagnostics-show-cwe | |
ddf6fe37 | 5293 | @item -fno-diagnostics-show-cwe |
d77de738 ML |
5294 | Diagnostic messages can optionally have an associated |
5295 | @uref{https://cwe.mitre.org/index.html, CWE} identifier. | |
5296 | GCC itself only provides such metadata for some of the @option{-fanalyzer} | |
5297 | diagnostics. GCC plugins may also provide diagnostics with such metadata. | |
5298 | By default, if this information is present, it will be printed with | |
5299 | the diagnostic. This option suppresses the printing of this metadata. | |
5300 | ||
d77de738 ML |
5301 | @opindex fno-diagnostics-show-rules |
5302 | @opindex fdiagnostics-show-rules | |
ddf6fe37 | 5303 | @item -fno-diagnostics-show-rules |
d77de738 ML |
5304 | Diagnostic messages can optionally have rules associated with them, such |
5305 | as from a coding standard, or a specification. | |
5306 | GCC itself does not do this for any of its diagnostics, but plugins may do so. | |
5307 | By default, if this information is present, it will be printed with | |
5308 | the diagnostic. This option suppresses the printing of this metadata. | |
5309 | ||
d77de738 ML |
5310 | @opindex fno-diagnostics-show-line-numbers |
5311 | @opindex fdiagnostics-show-line-numbers | |
ddf6fe37 | 5312 | @item -fno-diagnostics-show-line-numbers |
d77de738 ML |
5313 | By default, when printing source code (via @option{-fdiagnostics-show-caret}), |
5314 | a left margin is printed, showing line numbers. This option suppresses this | |
5315 | left margin. | |
5316 | ||
d77de738 | 5317 | @opindex fdiagnostics-minimum-margin-width |
ddf6fe37 | 5318 | @item -fdiagnostics-minimum-margin-width=@var{width} |
d77de738 ML |
5319 | This option controls the minimum width of the left margin printed by |
5320 | @option{-fdiagnostics-show-line-numbers}. It defaults to 6. | |
5321 | ||
d77de738 | 5322 | @opindex fdiagnostics-parseable-fixits |
ddf6fe37 | 5323 | @item -fdiagnostics-parseable-fixits |
d77de738 ML |
5324 | Emit fix-it hints in a machine-parseable format, suitable for consumption |
5325 | by IDEs. For each fix-it, a line will be printed after the relevant | |
5326 | diagnostic, starting with the string ``fix-it:''. For example: | |
5327 | ||
5328 | @smallexample | |
5329 | fix-it:"test.c":@{45:3-45:21@}:"gtk_widget_show_all" | |
5330 | @end smallexample | |
5331 | ||
5332 | The location is expressed as a half-open range, expressed as a count of | |
5333 | bytes, starting at byte 1 for the initial column. In the above example, | |
5334 | bytes 3 through 20 of line 45 of ``test.c'' are to be replaced with the | |
5335 | given string: | |
5336 | ||
5337 | @smallexample | |
5338 | 00000000011111111112222222222 | |
5339 | 12345678901234567890123456789 | |
5340 | gtk_widget_showall (dlg); | |
5341 | ^^^^^^^^^^^^^^^^^^ | |
5342 | gtk_widget_show_all | |
5343 | @end smallexample | |
5344 | ||
5345 | The filename and replacement string escape backslash as ``\\", tab as ``\t'', | |
5346 | newline as ``\n'', double quotes as ``\"'', non-printable characters as octal | |
5347 | (e.g. vertical tab as ``\013''). | |
5348 | ||
5349 | An empty replacement string indicates that the given range is to be removed. | |
5350 | An empty range (e.g. ``45:3-45:3'') indicates that the string is to | |
5351 | be inserted at the given position. | |
5352 | ||
d77de738 | 5353 | @opindex fdiagnostics-generate-patch |
ddf6fe37 | 5354 | @item -fdiagnostics-generate-patch |
d77de738 ML |
5355 | Print fix-it hints to stderr in unified diff format, after any diagnostics |
5356 | are printed. For example: | |
5357 | ||
5358 | @smallexample | |
5359 | --- test.c | |
5360 | +++ test.c | |
5361 | @@ -42,5 +42,5 @@ | |
5362 | ||
5363 | void show_cb(GtkDialog *dlg) | |
5364 | @{ | |
5365 | - gtk_widget_showall(dlg); | |
5366 | + gtk_widget_show_all(dlg); | |
5367 | @} | |
5368 | ||
5369 | @end smallexample | |
5370 | ||
5371 | The diff may or may not be colorized, following the same rules | |
5372 | as for diagnostics (see @option{-fdiagnostics-color}). | |
5373 | ||
d77de738 | 5374 | @opindex fdiagnostics-show-template-tree |
ddf6fe37 | 5375 | @item -fdiagnostics-show-template-tree |
d77de738 ML |
5376 | |
5377 | In the C++ frontend, when printing diagnostics showing mismatching | |
5378 | template types, such as: | |
5379 | ||
5380 | @smallexample | |
5381 | could not convert 'std::map<int, std::vector<double> >()' | |
5382 | from 'map<[...],vector<double>>' to 'map<[...],vector<float>> | |
5383 | @end smallexample | |
5384 | ||
5385 | the @option{-fdiagnostics-show-template-tree} flag enables printing a | |
5386 | tree-like structure showing the common and differing parts of the types, | |
5387 | such as: | |
5388 | ||
5389 | @smallexample | |
5390 | map< | |
5391 | [...], | |
5392 | vector< | |
5393 | [double != float]>> | |
5394 | @end smallexample | |
5395 | ||
5396 | The parts that differ are highlighted with color (``double'' and | |
5397 | ``float'' in this case). | |
5398 | ||
d77de738 ML |
5399 | @opindex fno-elide-type |
5400 | @opindex felide-type | |
ddf6fe37 | 5401 | @item -fno-elide-type |
d77de738 ML |
5402 | By default when the C++ frontend prints diagnostics showing mismatching |
5403 | template types, common parts of the types are printed as ``[...]'' to | |
5404 | simplify the error message. For example: | |
5405 | ||
5406 | @smallexample | |
5407 | could not convert 'std::map<int, std::vector<double> >()' | |
5408 | from 'map<[...],vector<double>>' to 'map<[...],vector<float>> | |
5409 | @end smallexample | |
5410 | ||
5411 | Specifying the @option{-fno-elide-type} flag suppresses that behavior. | |
5412 | This flag also affects the output of the | |
5413 | @option{-fdiagnostics-show-template-tree} flag. | |
5414 | ||
d77de738 | 5415 | @opindex fdiagnostics-path-format |
ddf6fe37 | 5416 | @item -fdiagnostics-path-format=@var{KIND} |
d77de738 ML |
5417 | Specify how to print paths of control-flow events for diagnostics that |
5418 | have such a path associated with them. | |
5419 | ||
5420 | @var{KIND} is @samp{none}, @samp{separate-events}, or @samp{inline-events}, | |
5421 | the default. | |
5422 | ||
5423 | @samp{none} means to not print diagnostic paths. | |
5424 | ||
5425 | @samp{separate-events} means to print a separate ``note'' diagnostic for | |
5426 | each event within the diagnostic. For example: | |
5427 | ||
5428 | @smallexample | |
5429 | test.c:29:5: error: passing NULL as argument 1 to 'PyList_Append' which requires a non-NULL parameter | |
5430 | test.c:25:10: note: (1) when 'PyList_New' fails, returning NULL | |
5431 | test.c:27:3: note: (2) when 'i < count' | |
5432 | test.c:29:5: note: (3) when calling 'PyList_Append', passing NULL from (1) as argument 1 | |
5433 | @end smallexample | |
5434 | ||
5435 | @samp{inline-events} means to print the events ``inline'' within the source | |
5436 | code. This view attempts to consolidate the events into runs of | |
5437 | sufficiently-close events, printing them as labelled ranges within the source. | |
5438 | ||
5439 | For example, the same events as above might be printed as: | |
5440 | ||
5441 | @smallexample | |
5442 | 'test': events 1-3 | |
5443 | | | |
5444 | | 25 | list = PyList_New(0); | |
5445 | | | ^~~~~~~~~~~~~ | |
5446 | | | | | |
5447 | | | (1) when 'PyList_New' fails, returning NULL | |
5448 | | 26 | | |
5449 | | 27 | for (i = 0; i < count; i++) @{ | |
5450 | | | ~~~ | |
5451 | | | | | |
5452 | | | (2) when 'i < count' | |
5453 | | 28 | item = PyLong_FromLong(random()); | |
5454 | | 29 | PyList_Append(list, item); | |
5455 | | | ~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5456 | | | | | |
5457 | | | (3) when calling 'PyList_Append', passing NULL from (1) as argument 1 | |
5458 | | | |
5459 | @end smallexample | |
5460 | ||
5461 | Interprocedural control flow is shown by grouping the events by stack frame, | |
5462 | and using indentation to show how stack frames are nested, pushed, and popped. | |
5463 | ||
5464 | For example: | |
5465 | ||
5466 | @smallexample | |
5467 | 'test': events 1-2 | |
5468 | | | |
5469 | | 133 | @{ | |
5470 | | | ^ | |
5471 | | | | | |
5472 | | | (1) entering 'test' | |
5473 | | 134 | boxed_int *obj = make_boxed_int (i); | |
5474 | | | ~~~~~~~~~~~~~~~~~~ | |
5475 | | | | | |
5476 | | | (2) calling 'make_boxed_int' | |
5477 | | | |
5478 | +--> 'make_boxed_int': events 3-4 | |
5479 | | | |
5480 | | 120 | @{ | |
5481 | | | ^ | |
5482 | | | | | |
5483 | | | (3) entering 'make_boxed_int' | |
5484 | | 121 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int)); | |
5485 | | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5486 | | | | | |
5487 | | | (4) calling 'wrapped_malloc' | |
5488 | | | |
5489 | +--> 'wrapped_malloc': events 5-6 | |
5490 | | | |
5491 | | 7 | @{ | |
5492 | | | ^ | |
5493 | | | | | |
5494 | | | (5) entering 'wrapped_malloc' | |
5495 | | 8 | return malloc (size); | |
5496 | | | ~~~~~~~~~~~~~ | |
5497 | | | | | |
5498 | | | (6) calling 'malloc' | |
5499 | | | |
5500 | <-------------+ | |
5501 | | | |
5502 | 'test': event 7 | |
5503 | | | |
5504 | | 138 | free_boxed_int (obj); | |
5505 | | | ^~~~~~~~~~~~~~~~~~~~ | |
5506 | | | | | |
5507 | | | (7) calling 'free_boxed_int' | |
5508 | | | |
5509 | (etc) | |
5510 | @end smallexample | |
5511 | ||
d77de738 | 5512 | @opindex fdiagnostics-show-path-depths |
ddf6fe37 | 5513 | @item -fdiagnostics-show-path-depths |
d77de738 ML |
5514 | This option provides additional information when printing control-flow paths |
5515 | associated with a diagnostic. | |
5516 | ||
5517 | If this is option is provided then the stack depth will be printed for | |
5518 | each run of events within @option{-fdiagnostics-path-format=inline-events}. | |
5519 | If provided with @option{-fdiagnostics-path-format=separate-events}, then | |
5520 | the stack depth and function declaration will be appended when printing | |
5521 | each event. | |
5522 | ||
5523 | This is intended for use by GCC developers and plugin developers when | |
5524 | debugging diagnostics that report interprocedural control flow. | |
5525 | ||
d77de738 ML |
5526 | @opindex fno-show-column |
5527 | @opindex fshow-column | |
ddf6fe37 | 5528 | @item -fno-show-column |
d77de738 ML |
5529 | Do not print column numbers in diagnostics. This may be necessary if |
5530 | diagnostics are being scanned by a program that does not understand the | |
5531 | column numbers, such as @command{dejagnu}. | |
5532 | ||
d77de738 | 5533 | @opindex fdiagnostics-column-unit |
ddf6fe37 | 5534 | @item -fdiagnostics-column-unit=@var{UNIT} |
d77de738 ML |
5535 | Select the units for the column number. This affects traditional diagnostics |
5536 | (in the absence of @option{-fno-show-column}), as well as JSON format | |
5537 | diagnostics if requested. | |
5538 | ||
5539 | The default @var{UNIT}, @samp{display}, considers the number of display | |
5540 | columns occupied by each character. This may be larger than the number | |
5541 | of bytes required to encode the character, in the case of tab | |
5542 | characters, or it may be smaller, in the case of multibyte characters. | |
5543 | For example, the character ``GREEK SMALL LETTER PI (U+03C0)'' occupies one | |
5544 | display column, and its UTF-8 encoding requires two bytes; the character | |
5545 | ``SLIGHTLY SMILING FACE (U+1F642)'' occupies two display columns, and | |
5546 | its UTF-8 encoding requires four bytes. | |
5547 | ||
5548 | Setting @var{UNIT} to @samp{byte} changes the column number to the raw byte | |
5549 | count in all cases, as was traditionally output by GCC prior to version 11.1.0. | |
5550 | ||
d77de738 | 5551 | @opindex fdiagnostics-column-origin |
ddf6fe37 | 5552 | @item -fdiagnostics-column-origin=@var{ORIGIN} |
d77de738 ML |
5553 | Select the origin for column numbers, i.e. the column number assigned to the |
5554 | first column. The default value of 1 corresponds to traditional GCC | |
5555 | behavior and to the GNU style guide. Some utilities may perform better with an | |
5556 | origin of 0; any non-negative value may be specified. | |
5557 | ||
d77de738 | 5558 | @opindex fdiagnostics-escape-format |
ddf6fe37 | 5559 | @item -fdiagnostics-escape-format=@var{FORMAT} |
d77de738 ML |
5560 | When GCC prints pertinent source lines for a diagnostic it normally attempts |
5561 | to print the source bytes directly. However, some diagnostics relate to encoding | |
5562 | issues in the source file, such as malformed UTF-8, or issues with Unicode | |
5563 | normalization. These diagnostics are flagged so that GCC will escape bytes | |
5564 | that are not printable ASCII when printing their pertinent source lines. | |
5565 | ||
5566 | This option controls how such bytes should be escaped. | |
5567 | ||
5568 | The default @var{FORMAT}, @samp{unicode} displays Unicode characters that | |
5569 | are not printable ASCII in the form @samp{<U+XXXX>}, and bytes that do not | |
5570 | correspond to a Unicode character validly-encoded in UTF-8-encoded will be | |
5571 | displayed as hexadecimal in the form @samp{<XX>}. | |
5572 | ||
5573 | For example, a source line containing the string @samp{before} followed by the | |
5574 | Unicode character U+03C0 (``GREEK SMALL LETTER PI'', with UTF-8 encoding | |
5575 | 0xCF 0x80) followed by the byte 0xBF (a stray UTF-8 trailing byte), followed by | |
5576 | the string @samp{after} will be printed for such a diagnostic as: | |
5577 | ||
5578 | @smallexample | |
5579 | before<U+03C0><BF>after | |
5580 | @end smallexample | |
5581 | ||
5582 | Setting @var{FORMAT} to @samp{bytes} will display all non-printable-ASCII bytes | |
5583 | in the form @samp{<XX>}, thus showing the underlying encoding of non-ASCII | |
5584 | Unicode characters. For the example above, the following will be printed: | |
5585 | ||
5586 | @smallexample | |
5587 | before<CF><80><BF>after | |
5588 | @end smallexample | |
5589 | ||
d77de738 | 5590 | @opindex fdiagnostics-format |
ddf6fe37 | 5591 | @item -fdiagnostics-format=@var{FORMAT} |
d77de738 ML |
5592 | Select a different format for printing diagnostics. |
5593 | @var{FORMAT} is @samp{text}, @samp{sarif-stderr}, @samp{sarif-file}, | |
5594 | @samp{json}, @samp{json-stderr}, or @samp{json-file}. | |
5595 | ||
5596 | The default is @samp{text}. | |
5597 | ||
5598 | The @samp{sarif-stderr} and @samp{sarif-file} formats both emit | |
5599 | diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a file | |
5600 | named @file{@var{source}.sarif}, respectively. | |
5601 | ||
5602 | The @samp{json} format is a synonym for @samp{json-stderr}. | |
5603 | The @samp{json-stderr} and @samp{json-file} formats are identical, apart from | |
5604 | where the JSON is emitted to - with the former, the JSON is emitted to stderr, | |
5605 | whereas with @samp{json-file} it is written to @file{@var{source}.gcc.json}. | |
5606 | ||
5607 | The emitted JSON consists of a top-level JSON array containing JSON objects | |
5608 | representing the diagnostics. The JSON is emitted as one line, without | |
5609 | formatting; the examples below have been formatted for clarity. | |
5610 | ||
5611 | Diagnostics can have child diagnostics. For example, this error and note: | |
5612 | ||
5613 | @smallexample | |
5614 | misleading-indentation.c:15:3: warning: this 'if' clause does not | |
5615 | guard... [-Wmisleading-indentation] | |
5616 | 15 | if (flag) | |
5617 | | ^~ | |
5618 | misleading-indentation.c:17:5: note: ...this statement, but the latter | |
5619 | is misleadingly indented as if it were guarded by the 'if' | |
5620 | 17 | y = 2; | |
5621 | | ^ | |
5622 | @end smallexample | |
5623 | ||
5624 | @noindent | |
5625 | might be printed in JSON form (after formatting) like this: | |
5626 | ||
5627 | @smallexample | |
5628 | [ | |
5629 | @{ | |
5630 | "kind": "warning", | |
5631 | "locations": [ | |
5632 | @{ | |
5633 | "caret": @{ | |
5634 | "display-column": 3, | |
5635 | "byte-column": 3, | |
5636 | "column": 3, | |
5637 | "file": "misleading-indentation.c", | |
5638 | "line": 15 | |
5639 | @}, | |
5640 | "finish": @{ | |
5641 | "display-column": 4, | |
5642 | "byte-column": 4, | |
5643 | "column": 4, | |
5644 | "file": "misleading-indentation.c", | |
5645 | "line": 15 | |
5646 | @} | |
5647 | @} | |
5648 | ], | |
5649 | "message": "this \u2018if\u2019 clause does not guard...", | |
5650 | "option": "-Wmisleading-indentation", | |
5651 | "option_url": "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmisleading-indentation", | |
5652 | "children": [ | |
5653 | @{ | |
5654 | "kind": "note", | |
5655 | "locations": [ | |
5656 | @{ | |
5657 | "caret": @{ | |
5658 | "display-column": 5, | |
5659 | "byte-column": 5, | |
5660 | "column": 5, | |
5661 | "file": "misleading-indentation.c", | |
5662 | "line": 17 | |
5663 | @} | |
5664 | @} | |
5665 | ], | |
5666 | "escape-source": false, | |
5667 | "message": "...this statement, but the latter is @dots{}" | |
5668 | @} | |
5669 | ] | |
5670 | "escape-source": false, | |
5671 | "column-origin": 1, | |
5672 | @} | |
5673 | ] | |
5674 | @end smallexample | |
5675 | ||
5676 | @noindent | |
5677 | where the @code{note} is a child of the @code{warning}. | |
5678 | ||
5679 | A diagnostic has a @code{kind}. If this is @code{warning}, then there is | |
5680 | an @code{option} key describing the command-line option controlling the | |
5681 | warning. | |
5682 | ||
5683 | A diagnostic can contain zero or more locations. Each location has an | |
5684 | optional @code{label} string and up to three positions within it: a | |
5685 | @code{caret} position and optional @code{start} and @code{finish} positions. | |
5686 | A position is described by a @code{file} name, a @code{line} number, and | |
5687 | three numbers indicating a column position: | |
5688 | @itemize @bullet | |
5689 | ||
5690 | @item | |
5691 | @code{display-column} counts display columns, accounting for tabs and | |
5692 | multibyte characters. | |
5693 | ||
5694 | @item | |
5695 | @code{byte-column} counts raw bytes. | |
5696 | ||
5697 | @item | |
5698 | @code{column} is equal to one of | |
5699 | the previous two, as dictated by the @option{-fdiagnostics-column-unit} | |
5700 | option. | |
5701 | ||
5702 | @end itemize | |
5703 | All three columns are relative to the origin specified by | |
5704 | @option{-fdiagnostics-column-origin}, which is typically equal to 1 but may | |
5705 | be set, for instance, to 0 for compatibility with other utilities that | |
5706 | number columns from 0. The column origin is recorded in the JSON output in | |
5707 | the @code{column-origin} tag. In the remaining examples below, the extra | |
5708 | column number outputs have been omitted for brevity. | |
5709 | ||
5710 | For example, this error: | |
5711 | ||
5712 | @smallexample | |
5713 | bad-binary-ops.c:64:23: error: invalid operands to binary + (have 'S' @{aka | |
5714 | 'struct s'@} and 'T' @{aka 'struct t'@}) | |
5715 | 64 | return callee_4a () + callee_4b (); | |
5716 | | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~ | |
5717 | | | | | |
5718 | | | T @{aka struct t@} | |
5719 | | S @{aka struct s@} | |
5720 | @end smallexample | |
5721 | ||
5722 | @noindent | |
5723 | has three locations. Its primary location is at the ``+'' token at column | |
5724 | 23. It has two secondary locations, describing the left and right-hand sides | |
5725 | of the expression, which have labels. It might be printed in JSON form as: | |
5726 | ||
5727 | @smallexample | |
5728 | @{ | |
5729 | "children": [], | |
5730 | "kind": "error", | |
5731 | "locations": [ | |
5732 | @{ | |
5733 | "caret": @{ | |
5734 | "column": 23, "file": "bad-binary-ops.c", "line": 64 | |
5735 | @} | |
5736 | @}, | |
5737 | @{ | |
5738 | "caret": @{ | |
5739 | "column": 10, "file": "bad-binary-ops.c", "line": 64 | |
5740 | @}, | |
5741 | "finish": @{ | |
5742 | "column": 21, "file": "bad-binary-ops.c", "line": 64 | |
5743 | @}, | |
5744 | "label": "S @{aka struct s@}" | |
5745 | @}, | |
5746 | @{ | |
5747 | "caret": @{ | |
5748 | "column": 25, "file": "bad-binary-ops.c", "line": 64 | |
5749 | @}, | |
5750 | "finish": @{ | |
5751 | "column": 36, "file": "bad-binary-ops.c", "line": 64 | |
5752 | @}, | |
5753 | "label": "T @{aka struct t@}" | |
5754 | @} | |
5755 | ], | |
5756 | "escape-source": false, | |
5757 | "message": "invalid operands to binary + @dots{}" | |
5758 | @} | |
5759 | @end smallexample | |
5760 | ||
5761 | If a diagnostic contains fix-it hints, it has a @code{fixits} array, | |
5762 | consisting of half-open intervals, similar to the output of | |
5763 | @option{-fdiagnostics-parseable-fixits}. For example, this diagnostic | |
5764 | with a replacement fix-it hint: | |
5765 | ||
5766 | @smallexample | |
5767 | demo.c:8:15: error: 'struct s' has no member named 'colour'; did you | |
5768 | mean 'color'? | |
5769 | 8 | return ptr->colour; | |
5770 | | ^~~~~~ | |
5771 | | color | |
5772 | @end smallexample | |
5773 | ||
5774 | @noindent | |
5775 | might be printed in JSON form as: | |
5776 | ||
5777 | @smallexample | |
5778 | @{ | |
5779 | "children": [], | |
5780 | "fixits": [ | |
5781 | @{ | |
5782 | "next": @{ | |
5783 | "column": 21, | |
5784 | "file": "demo.c", | |
5785 | "line": 8 | |
5786 | @}, | |
5787 | "start": @{ | |
5788 | "column": 15, | |
5789 | "file": "demo.c", | |
5790 | "line": 8 | |
5791 | @}, | |
5792 | "string": "color" | |
5793 | @} | |
5794 | ], | |
5795 | "kind": "error", | |
5796 | "locations": [ | |
5797 | @{ | |
5798 | "caret": @{ | |
5799 | "column": 15, | |
5800 | "file": "demo.c", | |
5801 | "line": 8 | |
5802 | @}, | |
5803 | "finish": @{ | |
5804 | "column": 20, | |
5805 | "file": "demo.c", | |
5806 | "line": 8 | |
5807 | @} | |
5808 | @} | |
5809 | ], | |
5810 | "escape-source": false, | |
5811 | "message": "\u2018struct s\u2019 has no member named @dots{}" | |
5812 | @} | |
5813 | @end smallexample | |
5814 | ||
5815 | @noindent | |
5816 | where the fix-it hint suggests replacing the text from @code{start} up | |
5817 | to but not including @code{next} with @code{string}'s value. Deletions | |
5818 | are expressed via an empty value for @code{string}, insertions by | |
5819 | having @code{start} equal @code{next}. | |
5820 | ||
5821 | If the diagnostic has a path of control-flow events associated with it, | |
5822 | it has a @code{path} array of objects representing the events. Each | |
5823 | event object has a @code{description} string, a @code{location} object, | |
5824 | along with a @code{function} string and a @code{depth} number for | |
5825 | representing interprocedural paths. The @code{function} represents the | |
5826 | current function at that event, and the @code{depth} represents the | |
5827 | stack depth relative to some baseline: the higher, the more frames are | |
5828 | within the stack. | |
5829 | ||
5830 | For example, the intraprocedural example shown for | |
5831 | @option{-fdiagnostics-path-format=} might have this JSON for its path: | |
5832 | ||
5833 | @smallexample | |
5834 | "path": [ | |
5835 | @{ | |
5836 | "depth": 0, | |
5837 | "description": "when 'PyList_New' fails, returning NULL", | |
5838 | "function": "test", | |
5839 | "location": @{ | |
5840 | "column": 10, | |
5841 | "file": "test.c", | |
5842 | "line": 25 | |
5843 | @} | |
5844 | @}, | |
5845 | @{ | |
5846 | "depth": 0, | |
5847 | "description": "when 'i < count'", | |
5848 | "function": "test", | |
5849 | "location": @{ | |
5850 | "column": 3, | |
5851 | "file": "test.c", | |
5852 | "line": 27 | |
5853 | @} | |
5854 | @}, | |
5855 | @{ | |
5856 | "depth": 0, | |
5857 | "description": "when calling 'PyList_Append', passing NULL from (1) as argument 1", | |
5858 | "function": "test", | |
5859 | "location": @{ | |
5860 | "column": 5, | |
5861 | "file": "test.c", | |
5862 | "line": 29 | |
5863 | @} | |
5864 | @} | |
5865 | ] | |
5866 | @end smallexample | |
5867 | ||
5868 | Diagnostics have a boolean attribute @code{escape-source}, hinting whether | |
5869 | non-ASCII bytes should be escaped when printing the pertinent lines of | |
5870 | source code (@code{true} for diagnostics involving source encoding issues). | |
5871 | ||
5872 | @end table | |
5873 | ||
5874 | @node Warning Options | |
5875 | @section Options to Request or Suppress Warnings | |
5876 | @cindex options to control warnings | |
5877 | @cindex warning messages | |
5878 | @cindex messages, warning | |
5879 | @cindex suppressing warnings | |
5880 | ||
5881 | Warnings are diagnostic messages that report constructions that | |
5882 | are not inherently erroneous but that are risky or suggest there | |
5883 | may have been an error. | |
5884 | ||
5885 | The following language-independent options do not enable specific | |
5886 | warnings but control the kinds of diagnostics produced by GCC@. | |
5887 | ||
5888 | @table @gcctabopt | |
5889 | @cindex syntax checking | |
d77de738 | 5890 | @opindex fsyntax-only |
ddf6fe37 | 5891 | @item -fsyntax-only |
d77de738 ML |
5892 | Check the code for syntax errors, but don't do anything beyond that. |
5893 | ||
d77de738 | 5894 | @opindex fmax-errors |
ddf6fe37 | 5895 | @item -fmax-errors=@var{n} |
d77de738 ML |
5896 | Limits the maximum number of error messages to @var{n}, at which point |
5897 | GCC bails out rather than attempting to continue processing the source | |
5898 | code. If @var{n} is 0 (the default), there is no limit on the number | |
5899 | of error messages produced. If @option{-Wfatal-errors} is also | |
5900 | specified, then @option{-Wfatal-errors} takes precedence over this | |
5901 | option. | |
5902 | ||
d77de738 | 5903 | @opindex w |
ddf6fe37 | 5904 | @item -w |
d77de738 ML |
5905 | Inhibit all warning messages. |
5906 | ||
d77de738 ML |
5907 | @opindex Werror |
5908 | @opindex Wno-error | |
ddf6fe37 | 5909 | @item -Werror |
d77de738 ML |
5910 | Make all warnings into errors. |
5911 | ||
d77de738 ML |
5912 | @opindex Werror= |
5913 | @opindex Wno-error= | |
ddf6fe37 | 5914 | @item -Werror= |
d77de738 ML |
5915 | Make the specified warning into an error. The specifier for a warning |
5916 | is appended; for example @option{-Werror=switch} turns the warnings | |
5917 | controlled by @option{-Wswitch} into errors. This switch takes a | |
5918 | negative form, to be used to negate @option{-Werror} for specific | |
5919 | warnings; for example @option{-Wno-error=switch} makes | |
5920 | @option{-Wswitch} warnings not be errors, even when @option{-Werror} | |
5921 | is in effect. | |
5922 | ||
5923 | The warning message for each controllable warning includes the | |
5924 | option that controls the warning. That option can then be used with | |
5925 | @option{-Werror=} and @option{-Wno-error=} as described above. | |
5926 | (Printing of the option in the warning message can be disabled using the | |
5927 | @option{-fno-diagnostics-show-option} flag.) | |
5928 | ||
5929 | Note that specifying @option{-Werror=}@var{foo} automatically implies | |
5930 | @option{-W}@var{foo}. However, @option{-Wno-error=}@var{foo} does not | |
5931 | imply anything. | |
5932 | ||
d77de738 ML |
5933 | @opindex Wfatal-errors |
5934 | @opindex Wno-fatal-errors | |
ddf6fe37 | 5935 | @item -Wfatal-errors |
d77de738 ML |
5936 | This option causes the compiler to abort compilation on the first error |
5937 | occurred rather than trying to keep going and printing further error | |
5938 | messages. | |
5939 | ||
5940 | @end table | |
5941 | ||
5942 | You can request many specific warnings with options beginning with | |
5943 | @samp{-W}, for example @option{-Wimplicit} to request warnings on | |
5944 | implicit declarations. Each of these specific warning options also | |
5945 | has a negative form beginning @samp{-Wno-} to turn off warnings; for | |
5946 | example, @option{-Wno-implicit}. This manual lists only one of the | |
5947 | two forms, whichever is not the default. For further | |
5948 | language-specific options also refer to @ref{C++ Dialect Options} and | |
5949 | @ref{Objective-C and Objective-C++ Dialect Options}. | |
5950 | Additional warnings can be produced by enabling the static analyzer; | |
5951 | @xref{Static Analyzer Options}. | |
5952 | ||
5953 | Some options, such as @option{-Wall} and @option{-Wextra}, turn on other | |
5954 | options, such as @option{-Wunused}, which may turn on further options, | |
5955 | such as @option{-Wunused-value}. The combined effect of positive and | |
5956 | negative forms is that more specific options have priority over less | |
5957 | specific ones, independently of their position in the command-line. For | |
5958 | options of the same specificity, the last one takes effect. Options | |
5959 | enabled or disabled via pragmas (@pxref{Diagnostic Pragmas}) take effect | |
5960 | as if they appeared at the end of the command-line. | |
5961 | ||
5962 | When an unrecognized warning option is requested (e.g., | |
5963 | @option{-Wunknown-warning}), GCC emits a diagnostic stating | |
5964 | that the option is not recognized. However, if the @option{-Wno-} form | |
5965 | is used, the behavior is slightly different: no diagnostic is | |
5966 | produced for @option{-Wno-unknown-warning} unless other diagnostics | |
5967 | are being produced. This allows the use of new @option{-Wno-} options | |
5968 | with old compilers, but if something goes wrong, the compiler | |
5969 | warns that an unrecognized option is present. | |
5970 | ||
5971 | The effectiveness of some warnings depends on optimizations also being | |
5972 | enabled. For example @option{-Wsuggest-final-types} is more effective | |
5973 | with link-time optimization and some instances of other warnings may | |
5974 | not be issued at all unless optimization is enabled. While optimization | |
5975 | in general improves the efficacy of control and data flow sensitive | |
5976 | warnings, in some cases it may also cause false positives. | |
5977 | ||
5978 | @table @gcctabopt | |
d77de738 ML |
5979 | @opindex pedantic |
5980 | @opindex Wpedantic | |
5981 | @opindex Wno-pedantic | |
ddf6fe37 AA |
5982 | @item -Wpedantic |
5983 | @itemx -pedantic | |
d77de738 ML |
5984 | Issue all the warnings demanded by strict ISO C and ISO C++; |
5985 | reject all programs that use forbidden extensions, and some other | |
5986 | programs that do not follow ISO C and ISO C++. For ISO C, follows the | |
5987 | version of the ISO C standard specified by any @option{-std} option used. | |
5988 | ||
5989 | Valid ISO C and ISO C++ programs should compile properly with or without | |
5990 | this option (though a rare few require @option{-ansi} or a | |
5991 | @option{-std} option specifying the required version of ISO C)@. However, | |
5992 | without this option, certain GNU extensions and traditional C and C++ | |
5993 | features are supported as well. With this option, they are rejected. | |
5994 | ||
5995 | @option{-Wpedantic} does not cause warning messages for use of the | |
5996 | alternate keywords whose names begin and end with @samp{__}. This alternate | |
5997 | format can also be used to disable warnings for non-ISO @samp{__intN} types, | |
5998 | i.e. @samp{__intN__}. | |
5999 | Pedantic warnings are also disabled in the expression that follows | |
6000 | @code{__extension__}. However, only system header files should use | |
6001 | these escape routes; application programs should avoid them. | |
6002 | @xref{Alternate Keywords}. | |
6003 | ||
6004 | Some users try to use @option{-Wpedantic} to check programs for strict ISO | |
6005 | C conformance. They soon find that it does not do quite what they want: | |
6006 | it finds some non-ISO practices, but not all---only those for which | |
6007 | ISO C @emph{requires} a diagnostic, and some others for which | |
6008 | diagnostics have been added. | |
6009 | ||
6010 | A feature to report any failure to conform to ISO C might be useful in | |
6011 | some instances, but would require considerable additional work and would | |
6012 | be quite different from @option{-Wpedantic}. We don't have plans to | |
6013 | support such a feature in the near future. | |
6014 | ||
6015 | Where the standard specified with @option{-std} represents a GNU | |
6016 | extended dialect of C, such as @samp{gnu90} or @samp{gnu99}, there is a | |
6017 | corresponding @dfn{base standard}, the version of ISO C on which the GNU | |
6018 | extended dialect is based. Warnings from @option{-Wpedantic} are given | |
6019 | where they are required by the base standard. (It does not make sense | |
6020 | for such warnings to be given only for features not in the specified GNU | |
6021 | C dialect, since by definition the GNU dialects of C include all | |
6022 | features the compiler supports with the given option, and there would be | |
6023 | nothing to warn about.) | |
6024 | ||
d77de738 | 6025 | @opindex pedantic-errors |
ddf6fe37 | 6026 | @item -pedantic-errors |
d77de738 ML |
6027 | Give an error whenever the @dfn{base standard} (see @option{-Wpedantic}) |
6028 | requires a diagnostic, in some cases where there is undefined behavior | |
6029 | at compile-time and in some other cases that do not prevent compilation | |
6030 | of programs that are valid according to the standard. This is not | |
6031 | equivalent to @option{-Werror=pedantic}, since there are errors enabled | |
6032 | by this option and not enabled by the latter and vice versa. | |
6033 | ||
d77de738 ML |
6034 | @opindex Wall |
6035 | @opindex Wno-all | |
ddf6fe37 | 6036 | @item -Wall |
d77de738 ML |
6037 | This enables all the warnings about constructions that some users |
6038 | consider questionable, and that are easy to avoid (or modify to | |
6039 | prevent the warning), even in conjunction with macros. This also | |
6040 | enables some language-specific warnings described in @ref{C++ Dialect | |
6041 | Options} and @ref{Objective-C and Objective-C++ Dialect Options}. | |
6042 | ||
6043 | @option{-Wall} turns on the following warning flags: | |
6044 | ||
43b72ede AA |
6045 | @gccoptlist{-Waddress |
6046 | -Warray-bounds=1 @r{(only with} @option{-O2}@r{)} | |
6047 | -Warray-compare | |
6048 | -Warray-parameter=2 @r{(C and Objective-C only)} | |
6049 | -Wbool-compare | |
6050 | -Wbool-operation | |
6051 | -Wc++11-compat -Wc++14-compat | |
6052 | -Wcatch-value @r{(C++ and Objective-C++ only)} | |
6053 | -Wchar-subscripts | |
6054 | -Wcomment | |
6055 | -Wdangling-pointer=2 | |
6056 | -Wduplicate-decl-specifier @r{(C and Objective-C only)} | |
6057 | -Wenum-compare @r{(in C/ObjC; this is on by default in C++)} | |
6058 | -Wenum-int-mismatch @r{(C and Objective-C only)} | |
6059 | -Wformat | |
6060 | -Wformat-overflow | |
6061 | -Wformat-truncation | |
6062 | -Wint-in-bool-context | |
6063 | -Wimplicit @r{(C and Objective-C only)} | |
6064 | -Wimplicit-int @r{(C and Objective-C only)} | |
6065 | -Wimplicit-function-declaration @r{(C and Objective-C only)} | |
6066 | -Winit-self @r{(only for C++)} | |
6067 | -Wlogical-not-parentheses | |
6068 | -Wmain @r{(only for C/ObjC and unless} @option{-ffreestanding}@r{)} | |
6069 | -Wmaybe-uninitialized | |
6070 | -Wmemset-elt-size | |
6071 | -Wmemset-transposed-args | |
6072 | -Wmisleading-indentation @r{(only for C/C++)} | |
6073 | -Wmismatched-dealloc | |
6074 | -Wmismatched-new-delete @r{(only for C/C++)} | |
6075 | -Wmissing-attributes | |
6076 | -Wmissing-braces @r{(only for C/ObjC)} | |
6077 | -Wmultistatement-macros | |
6078 | -Wnarrowing @r{(only for C++)} | |
6079 | -Wnonnull | |
6080 | -Wnonnull-compare | |
6081 | -Wopenmp-simd | |
6082 | -Wparentheses | |
6083 | -Wpessimizing-move @r{(only for C++)} | |
6084 | -Wpointer-sign | |
6085 | -Wrange-loop-construct @r{(only for C++)} | |
6086 | -Wreorder | |
6087 | -Wrestrict | |
6088 | -Wreturn-type | |
6089 | -Wself-move @r{(only for C++)} | |
6090 | -Wsequence-point | |
6091 | -Wsign-compare @r{(only in C++)} | |
6092 | -Wsizeof-array-div | |
6093 | -Wsizeof-pointer-div | |
6094 | -Wsizeof-pointer-memaccess | |
6095 | -Wstrict-aliasing | |
6096 | -Wstrict-overflow=1 | |
6097 | -Wswitch | |
6098 | -Wtautological-compare | |
6099 | -Wtrigraphs | |
6100 | -Wuninitialized | |
6101 | -Wunknown-pragmas | |
6102 | -Wunused-function | |
6103 | -Wunused-label | |
6104 | -Wunused-value | |
6105 | -Wunused-variable | |
6106 | -Wuse-after-free=2 | |
6107 | -Wvla-parameter @r{(C and Objective-C only)} | |
6108 | -Wvolatile-register-var | |
d77de738 ML |
6109 | -Wzero-length-bounds} |
6110 | ||
6111 | Note that some warning flags are not implied by @option{-Wall}. Some of | |
6112 | them warn about constructions that users generally do not consider | |
6113 | questionable, but which occasionally you might wish to check for; | |
6114 | others warn about constructions that are necessary or hard to avoid in | |
6115 | some cases, and there is no simple way to modify the code to suppress | |
6116 | the warning. Some of them are enabled by @option{-Wextra} but many of | |
6117 | them must be enabled individually. | |
6118 | ||
d77de738 ML |
6119 | @opindex W |
6120 | @opindex Wextra | |
6121 | @opindex Wno-extra | |
ddf6fe37 | 6122 | @item -Wextra |
d77de738 ML |
6123 | This enables some extra warning flags that are not enabled by |
6124 | @option{-Wall}. (This option used to be called @option{-W}. The older | |
6125 | name is still supported, but the newer name is more descriptive.) | |
6126 | ||
43b72ede AA |
6127 | @gccoptlist{-Wclobbered |
6128 | -Wcast-function-type | |
6129 | -Wdeprecated-copy @r{(C++ only)} | |
6130 | -Wempty-body | |
6131 | -Wenum-conversion @r{(C only)} | |
6132 | -Wignored-qualifiers | |
6133 | -Wimplicit-fallthrough=3 | |
6134 | -Wmissing-field-initializers | |
6135 | -Wmissing-parameter-type @r{(C only)} | |
6136 | -Wold-style-declaration @r{(C only)} | |
6137 | -Woverride-init | |
6138 | -Wsign-compare @r{(C only)} | |
6139 | -Wstring-compare | |
6140 | -Wredundant-move @r{(only for C++)} | |
6141 | -Wtype-limits | |
6142 | -Wuninitialized | |
6143 | -Wshift-negative-value @r{(in C++11 to C++17 and in C99 and newer)} | |
6144 | -Wunused-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)} | |
d77de738 ML |
6145 | -Wunused-but-set-parameter @r{(only with} @option{-Wunused} @r{or} @option{-Wall}@r{)}} |
6146 | ||
6147 | ||
6148 | The option @option{-Wextra} also prints warning messages for the | |
6149 | following cases: | |
6150 | ||
6151 | @itemize @bullet | |
6152 | ||
6153 | @item | |
6154 | A pointer is compared against integer zero with @code{<}, @code{<=}, | |
6155 | @code{>}, or @code{>=}. | |
6156 | ||
6157 | @item | |
6158 | (C++ only) An enumerator and a non-enumerator both appear in a | |
6159 | conditional expression. | |
6160 | ||
6161 | @item | |
6162 | (C++ only) Ambiguous virtual bases. | |
6163 | ||
6164 | @item | |
6165 | (C++ only) Subscripting an array that has been declared @code{register}. | |
6166 | ||
6167 | @item | |
6168 | (C++ only) Taking the address of a variable that has been declared | |
6169 | @code{register}. | |
6170 | ||
6171 | @item | |
6172 | (C++ only) A base class is not initialized in the copy constructor | |
6173 | of a derived class. | |
6174 | ||
6175 | @end itemize | |
6176 | ||
d77de738 ML |
6177 | @opindex Wabi |
6178 | @opindex Wno-abi | |
ddf6fe37 | 6179 | @item -Wabi @r{(C, Objective-C, C++ and Objective-C++ only)} |
d77de738 ML |
6180 | |
6181 | Warn about code affected by ABI changes. This includes code that may | |
6182 | not be compatible with the vendor-neutral C++ ABI as well as the psABI | |
6183 | for the particular target. | |
6184 | ||
6185 | Since G++ now defaults to updating the ABI with each major release, | |
6186 | normally @option{-Wabi} warns only about C++ ABI compatibility | |
6187 | problems if there is a check added later in a release series for an | |
6188 | ABI issue discovered since the initial release. @option{-Wabi} warns | |
6189 | about more things if an older ABI version is selected (with | |
6190 | @option{-fabi-version=@var{n}}). | |
6191 | ||
6192 | @option{-Wabi} can also be used with an explicit version number to | |
6193 | warn about C++ ABI compatibility with a particular @option{-fabi-version} | |
6194 | level, e.g.@: @option{-Wabi=2} to warn about changes relative to | |
6195 | @option{-fabi-version=2}. | |
6196 | ||
6197 | If an explicit version number is provided and | |
6198 | @option{-fabi-compat-version} is not specified, the version number | |
6199 | from this option is used for compatibility aliases. If no explicit | |
6200 | version number is provided with this option, but | |
6201 | @option{-fabi-compat-version} is specified, that version number is | |
6202 | used for C++ ABI warnings. | |
6203 | ||
6204 | Although an effort has been made to warn about | |
6205 | all such cases, there are probably some cases that are not warned about, | |
6206 | even though G++ is generating incompatible code. There may also be | |
6207 | cases where warnings are emitted even though the code that is generated | |
6208 | is compatible. | |
6209 | ||
6210 | You should rewrite your code to avoid these warnings if you are | |
6211 | concerned about the fact that code generated by G++ may not be binary | |
6212 | compatible with code generated by other compilers. | |
6213 | ||
6214 | Known incompatibilities in @option{-fabi-version=2} (which was the | |
6215 | default from GCC 3.4 to 4.9) include: | |
6216 | ||
6217 | @itemize @bullet | |
6218 | ||
6219 | @item | |
6220 | A template with a non-type template parameter of reference type was | |
6221 | mangled incorrectly: | |
6222 | @smallexample | |
6223 | extern int N; | |
6224 | template <int &> struct S @{@}; | |
6225 | void n (S<N>) @{2@} | |
6226 | @end smallexample | |
6227 | ||
6228 | This was fixed in @option{-fabi-version=3}. | |
6229 | ||
6230 | @item | |
6231 | SIMD vector types declared using @code{__attribute ((vector_size))} were | |
6232 | mangled in a non-standard way that does not allow for overloading of | |
6233 | functions taking vectors of different sizes. | |
6234 | ||
6235 | The mangling was changed in @option{-fabi-version=4}. | |
6236 | ||
6237 | @item | |
6238 | @code{__attribute ((const))} and @code{noreturn} were mangled as type | |
6239 | qualifiers, and @code{decltype} of a plain declaration was folded away. | |
6240 | ||
6241 | These mangling issues were fixed in @option{-fabi-version=5}. | |
6242 | ||
6243 | @item | |
6244 | Scoped enumerators passed as arguments to a variadic function are | |
6245 | promoted like unscoped enumerators, causing @code{va_arg} to complain. | |
6246 | On most targets this does not actually affect the parameter passing | |
6247 | ABI, as there is no way to pass an argument smaller than @code{int}. | |
6248 | ||
6249 | Also, the ABI changed the mangling of template argument packs, | |
6250 | @code{const_cast}, @code{static_cast}, prefix increment/decrement, and | |
6251 | a class scope function used as a template argument. | |
6252 | ||
6253 | These issues were corrected in @option{-fabi-version=6}. | |
6254 | ||
6255 | @item | |
6256 | Lambdas in default argument scope were mangled incorrectly, and the | |
6257 | ABI changed the mangling of @code{nullptr_t}. | |
6258 | ||
6259 | These issues were corrected in @option{-fabi-version=7}. | |
6260 | ||
6261 | @item | |
6262 | When mangling a function type with function-cv-qualifiers, the | |
6263 | un-qualified function type was incorrectly treated as a substitution | |
6264 | candidate. | |
6265 | ||
6266 | This was fixed in @option{-fabi-version=8}, the default for GCC 5.1. | |
6267 | ||
6268 | @item | |
6269 | @code{decltype(nullptr)} incorrectly had an alignment of 1, leading to | |
6270 | unaligned accesses. Note that this did not affect the ABI of a | |
6271 | function with a @code{nullptr_t} parameter, as parameters have a | |
6272 | minimum alignment. | |
6273 | ||
6274 | This was fixed in @option{-fabi-version=9}, the default for GCC 5.2. | |
6275 | ||
6276 | @item | |
6277 | Target-specific attributes that affect the identity of a type, such as | |
6278 | ia32 calling conventions on a function type (stdcall, regparm, etc.), | |
6279 | did not affect the mangled name, leading to name collisions when | |
6280 | function pointers were used as template arguments. | |
6281 | ||
6282 | This was fixed in @option{-fabi-version=10}, the default for GCC 6.1. | |
6283 | ||
6284 | @end itemize | |
6285 | ||
6286 | This option also enables warnings about psABI-related changes. | |
6287 | The known psABI changes at this point include: | |
6288 | ||
6289 | @itemize @bullet | |
6290 | ||
6291 | @item | |
6292 | For SysV/x86-64, unions with @code{long double} members are | |
6293 | passed in memory as specified in psABI. Prior to GCC 4.4, this was not | |
6294 | the case. For example: | |
6295 | ||
6296 | @smallexample | |
6297 | union U @{ | |
6298 | long double ld; | |
6299 | int i; | |
6300 | @}; | |
6301 | @end smallexample | |
6302 | ||
6303 | @noindent | |
6304 | @code{union U} is now always passed in memory. | |
6305 | ||
6306 | @end itemize | |
6307 | ||
e2f939d3 JM |
6308 | @item -Wno-changes-meaning @r{(C++ and Objective-C++ only)} |
6309 | C++ requires that unqualified uses of a name within a class have the | |
6310 | same meaning in the complete scope of the class, so declaring the name | |
6311 | after using it is ill-formed: | |
6312 | @smallexample | |
6313 | struct A; | |
6314 | struct B1 @{ A a; typedef A A; @}; // warning, 'A' changes meaning | |
6315 | struct B2 @{ A a; struct A @{ @}; @}; // error, 'A' changes meaning | |
6316 | @end smallexample | |
6317 | By default, the B1 case is only a warning because the two declarations | |
6318 | have the same type, while the B2 case is an error. Both diagnostics | |
6319 | can be disabled with @option{-Wno-changes-meaning}. Alternately, the | |
6320 | error case can be reduced to a warning with | |
6321 | @option{-Wno-error=changes-meaning} or @option{-fpermissive}. | |
6322 | ||
6323 | Both diagnostics are also suppressed by @option{-fms-extensions}. | |
6324 | ||
d77de738 ML |
6325 | @opindex Wchar-subscripts |
6326 | @opindex Wno-char-subscripts | |
ddf6fe37 | 6327 | @item -Wchar-subscripts |
d77de738 ML |
6328 | Warn if an array subscript has type @code{char}. This is a common cause |
6329 | of error, as programmers often forget that this type is signed on some | |
6330 | machines. | |
6331 | This warning is enabled by @option{-Wall}. | |
6332 | ||
d77de738 ML |
6333 | @opindex Wno-coverage-mismatch |
6334 | @opindex Wcoverage-mismatch | |
ddf6fe37 | 6335 | @item -Wno-coverage-mismatch |
d77de738 ML |
6336 | Warn if feedback profiles do not match when using the |
6337 | @option{-fprofile-use} option. | |
6338 | If a source file is changed between compiling with @option{-fprofile-generate} | |
6339 | and with @option{-fprofile-use}, the files with the profile feedback can fail | |
6340 | to match the source file and GCC cannot use the profile feedback | |
6341 | information. By default, this warning is enabled and is treated as an | |
6342 | error. @option{-Wno-coverage-mismatch} can be used to disable the | |
6343 | warning or @option{-Wno-error=coverage-mismatch} can be used to | |
6344 | disable the error. Disabling the error for this warning can result in | |
6345 | poorly optimized code and is useful only in the | |
6346 | case of very minor changes such as bug fixes to an existing code-base. | |
6347 | Completely disabling the warning is not recommended. | |
6348 | ||
d77de738 ML |
6349 | @opindex Wno-coverage-invalid-line-number |
6350 | @opindex Wcoverage-invalid-line-number | |
ddf6fe37 | 6351 | @item -Wno-coverage-invalid-line-number |
d77de738 ML |
6352 | Warn in case a function ends earlier than it begins due |
6353 | to an invalid linenum macros. The warning is emitted only | |
6354 | with @option{--coverage} enabled. | |
6355 | ||
6356 | By default, this warning is enabled and is treated as an | |
6357 | error. @option{-Wno-coverage-invalid-line-number} can be used to disable the | |
6358 | warning or @option{-Wno-error=coverage-invalid-line-number} can be used to | |
6359 | disable the error. | |
6360 | ||
d77de738 ML |
6361 | @opindex Wno-cpp |
6362 | @opindex Wcpp | |
ddf6fe37 | 6363 | @item -Wno-cpp @r{(C, Objective-C, C++, Objective-C++ and Fortran only)} |
d77de738 ML |
6364 | Suppress warning messages emitted by @code{#warning} directives. |
6365 | ||
d77de738 ML |
6366 | @opindex Wdouble-promotion |
6367 | @opindex Wno-double-promotion | |
ddf6fe37 | 6368 | @item -Wdouble-promotion @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
6369 | Give a warning when a value of type @code{float} is implicitly |
6370 | promoted to @code{double}. CPUs with a 32-bit ``single-precision'' | |
6371 | floating-point unit implement @code{float} in hardware, but emulate | |
6372 | @code{double} in software. On such a machine, doing computations | |
6373 | using @code{double} values is much more expensive because of the | |
6374 | overhead required for software emulation. | |
6375 | ||
6376 | It is easy to accidentally do computations with @code{double} because | |
6377 | floating-point literals are implicitly of type @code{double}. For | |
6378 | example, in: | |
6379 | @smallexample | |
6380 | @group | |
6381 | float area(float radius) | |
6382 | @{ | |
6383 | return 3.14159 * radius * radius; | |
6384 | @} | |
6385 | @end group | |
6386 | @end smallexample | |
6387 | the compiler performs the entire computation with @code{double} | |
6388 | because the floating-point literal is a @code{double}. | |
6389 | ||
d77de738 ML |
6390 | @opindex Wduplicate-decl-specifier |
6391 | @opindex Wno-duplicate-decl-specifier | |
ddf6fe37 | 6392 | @item -Wduplicate-decl-specifier @r{(C and Objective-C only)} |
d77de738 ML |
6393 | Warn if a declaration has duplicate @code{const}, @code{volatile}, |
6394 | @code{restrict} or @code{_Atomic} specifier. This warning is enabled by | |
6395 | @option{-Wall}. | |
6396 | ||
d77de738 ML |
6397 | @opindex Wformat |
6398 | @opindex Wno-format | |
6399 | @opindex ffreestanding | |
6400 | @opindex fno-builtin | |
6401 | @opindex Wformat= | |
ddf6fe37 AA |
6402 | @item -Wformat |
6403 | @itemx -Wformat=@var{n} | |
d77de738 ML |
6404 | Check calls to @code{printf} and @code{scanf}, etc., to make sure that |
6405 | the arguments supplied have types appropriate to the format string | |
6406 | specified, and that the conversions specified in the format string make | |
6407 | sense. This includes standard functions, and others specified by format | |
6408 | attributes (@pxref{Function Attributes}), in the @code{printf}, | |
6409 | @code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension, | |
6410 | not in the C standard) families (or other target-specific families). | |
6411 | Which functions are checked without format attributes having been | |
6412 | specified depends on the standard version selected, and such checks of | |
6413 | functions without the attribute specified are disabled by | |
6414 | @option{-ffreestanding} or @option{-fno-builtin}. | |
6415 | ||
6416 | The formats are checked against the format features supported by GNU | |
6417 | libc version 2.2. These include all ISO C90 and C99 features, as well | |
6418 | as features from the Single Unix Specification and some BSD and GNU | |
6419 | extensions. Other library implementations may not support all these | |
6420 | features; GCC does not support warning about features that go beyond a | |
6421 | particular library's limitations. However, if @option{-Wpedantic} is used | |
6422 | with @option{-Wformat}, warnings are given about format features not | |
6423 | in the selected standard version (but not for @code{strfmon} formats, | |
6424 | since those are not in any version of the C standard). @xref{C Dialect | |
6425 | Options,,Options Controlling C Dialect}. | |
6426 | ||
6427 | @table @gcctabopt | |
d77de738 ML |
6428 | @opindex Wformat |
6429 | @opindex Wformat=1 | |
ddf6fe37 AA |
6430 | @item -Wformat=1 |
6431 | @itemx -Wformat | |
d77de738 ML |
6432 | Option @option{-Wformat} is equivalent to @option{-Wformat=1}, and |
6433 | @option{-Wno-format} is equivalent to @option{-Wformat=0}. Since | |
6434 | @option{-Wformat} also checks for null format arguments for several | |
6435 | functions, @option{-Wformat} also implies @option{-Wnonnull}. Some | |
6436 | aspects of this level of format checking can be disabled by the | |
6437 | options: @option{-Wno-format-contains-nul}, | |
6438 | @option{-Wno-format-extra-args}, and @option{-Wno-format-zero-length}. | |
6439 | @option{-Wformat} is enabled by @option{-Wall}. | |
6440 | ||
d77de738 | 6441 | @opindex Wformat=2 |
ddf6fe37 | 6442 | @item -Wformat=2 |
d77de738 ML |
6443 | Enable @option{-Wformat} plus additional format checks. Currently |
6444 | equivalent to @option{-Wformat -Wformat-nonliteral -Wformat-security | |
6445 | -Wformat-y2k}. | |
6446 | @end table | |
6447 | ||
d77de738 ML |
6448 | @opindex Wno-format-contains-nul |
6449 | @opindex Wformat-contains-nul | |
ddf6fe37 | 6450 | @item -Wno-format-contains-nul |
d77de738 ML |
6451 | If @option{-Wformat} is specified, do not warn about format strings that |
6452 | contain NUL bytes. | |
6453 | ||
d77de738 ML |
6454 | @opindex Wno-format-extra-args |
6455 | @opindex Wformat-extra-args | |
ddf6fe37 | 6456 | @item -Wno-format-extra-args |
d77de738 ML |
6457 | If @option{-Wformat} is specified, do not warn about excess arguments to a |
6458 | @code{printf} or @code{scanf} format function. The C standard specifies | |
6459 | that such arguments are ignored. | |
6460 | ||
6461 | Where the unused arguments lie between used arguments that are | |
6462 | specified with @samp{$} operand number specifications, normally | |
6463 | warnings are still given, since the implementation could not know what | |
6464 | type to pass to @code{va_arg} to skip the unused arguments. However, | |
6465 | in the case of @code{scanf} formats, this option suppresses the | |
6466 | warning if the unused arguments are all pointers, since the Single | |
6467 | Unix Specification says that such unused arguments are allowed. | |
6468 | ||
d77de738 ML |
6469 | @opindex Wformat-overflow |
6470 | @opindex Wno-format-overflow | |
ddf6fe37 AA |
6471 | @item -Wformat-overflow |
6472 | @itemx -Wformat-overflow=@var{level} | |
d77de738 ML |
6473 | Warn about calls to formatted input/output functions such as @code{sprintf} |
6474 | and @code{vsprintf} that might overflow the destination buffer. When the | |
6475 | exact number of bytes written by a format directive cannot be determined | |
6476 | at compile-time it is estimated based on heuristics that depend on the | |
6477 | @var{level} argument and on optimization. While enabling optimization | |
6478 | will in most cases improve the accuracy of the warning, it may also | |
6479 | result in false positives. | |
6480 | ||
6481 | @table @gcctabopt | |
d77de738 ML |
6482 | @opindex Wformat-overflow |
6483 | @opindex Wno-format-overflow | |
ddf6fe37 AA |
6484 | @item -Wformat-overflow |
6485 | @itemx -Wformat-overflow=1 | |
d77de738 ML |
6486 | Level @var{1} of @option{-Wformat-overflow} enabled by @option{-Wformat} |
6487 | employs a conservative approach that warns only about calls that most | |
6488 | likely overflow the buffer. At this level, numeric arguments to format | |
6489 | directives with unknown values are assumed to have the value of one, and | |
6490 | strings of unknown length to be empty. Numeric arguments that are known | |
6491 | to be bounded to a subrange of their type, or string arguments whose output | |
6492 | is bounded either by their directive's precision or by a finite set of | |
6493 | string literals, are assumed to take on the value within the range that | |
6494 | results in the most bytes on output. For example, the call to @code{sprintf} | |
6495 | below is diagnosed because even with both @var{a} and @var{b} equal to zero, | |
6496 | the terminating NUL character (@code{'\0'}) appended by the function | |
6497 | to the destination buffer will be written past its end. Increasing | |
6498 | the size of the buffer by a single byte is sufficient to avoid the | |
6499 | warning, though it may not be sufficient to avoid the overflow. | |
6500 | ||
6501 | @smallexample | |
6502 | void f (int a, int b) | |
6503 | @{ | |
6504 | char buf [13]; | |
6505 | sprintf (buf, "a = %i, b = %i\n", a, b); | |
6506 | @} | |
6507 | @end smallexample | |
6508 | ||
6509 | @item -Wformat-overflow=2 | |
6510 | Level @var{2} warns also about calls that might overflow the destination | |
6511 | buffer given an argument of sufficient length or magnitude. At level | |
6512 | @var{2}, unknown numeric arguments are assumed to have the minimum | |
6513 | representable value for signed types with a precision greater than 1, and | |
6514 | the maximum representable value otherwise. Unknown string arguments whose | |
6515 | length cannot be assumed to be bounded either by the directive's precision, | |
6516 | or by a finite set of string literals they may evaluate to, or the character | |
6517 | array they may point to, are assumed to be 1 character long. | |
6518 | ||
6519 | At level @var{2}, the call in the example above is again diagnosed, but | |
6520 | this time because with @var{a} equal to a 32-bit @code{INT_MIN} the first | |
6521 | @code{%i} directive will write some of its digits beyond the end of | |
6522 | the destination buffer. To make the call safe regardless of the values | |
6523 | of the two variables, the size of the destination buffer must be increased | |
6524 | to at least 34 bytes. GCC includes the minimum size of the buffer in | |
6525 | an informational note following the warning. | |
6526 | ||
6527 | An alternative to increasing the size of the destination buffer is to | |
6528 | constrain the range of formatted values. The maximum length of string | |
6529 | arguments can be bounded by specifying the precision in the format | |
6530 | directive. When numeric arguments of format directives can be assumed | |
6531 | to be bounded by less than the precision of their type, choosing | |
6532 | an appropriate length modifier to the format specifier will reduce | |
6533 | the required buffer size. For example, if @var{a} and @var{b} in the | |
6534 | example above can be assumed to be within the precision of | |
6535 | the @code{short int} type then using either the @code{%hi} format | |
6536 | directive or casting the argument to @code{short} reduces the maximum | |
6537 | required size of the buffer to 24 bytes. | |
6538 | ||
6539 | @smallexample | |
6540 | void f (int a, int b) | |
6541 | @{ | |
6542 | char buf [23]; | |
6543 | sprintf (buf, "a = %hi, b = %i\n", a, (short)b); | |
6544 | @} | |
6545 | @end smallexample | |
6546 | @end table | |
6547 | ||
d77de738 ML |
6548 | @opindex Wno-format-zero-length |
6549 | @opindex Wformat-zero-length | |
ddf6fe37 | 6550 | @item -Wno-format-zero-length |
d77de738 ML |
6551 | If @option{-Wformat} is specified, do not warn about zero-length formats. |
6552 | The C standard specifies that zero-length formats are allowed. | |
6553 | ||
d77de738 ML |
6554 | @opindex Wformat-nonliteral |
6555 | @opindex Wno-format-nonliteral | |
ddf6fe37 | 6556 | @item -Wformat-nonliteral |
d77de738 ML |
6557 | If @option{-Wformat} is specified, also warn if the format string is not a |
6558 | string literal and so cannot be checked, unless the format function | |
6559 | takes its format arguments as a @code{va_list}. | |
6560 | ||
d77de738 ML |
6561 | @opindex Wformat-security |
6562 | @opindex Wno-format-security | |
ddf6fe37 | 6563 | @item -Wformat-security |
d77de738 ML |
6564 | If @option{-Wformat} is specified, also warn about uses of format |
6565 | functions that represent possible security problems. At present, this | |
6566 | warns about calls to @code{printf} and @code{scanf} functions where the | |
6567 | format string is not a string literal and there are no format arguments, | |
6568 | as in @code{printf (foo);}. This may be a security hole if the format | |
6569 | string came from untrusted input and contains @samp{%n}. (This is | |
6570 | currently a subset of what @option{-Wformat-nonliteral} warns about, but | |
6571 | in future warnings may be added to @option{-Wformat-security} that are not | |
6572 | included in @option{-Wformat-nonliteral}.) | |
6573 | ||
d77de738 ML |
6574 | @opindex Wformat-signedness |
6575 | @opindex Wno-format-signedness | |
ddf6fe37 | 6576 | @item -Wformat-signedness |
d77de738 ML |
6577 | If @option{-Wformat} is specified, also warn if the format string |
6578 | requires an unsigned argument and the argument is signed and vice versa. | |
6579 | ||
d77de738 ML |
6580 | @opindex Wformat-truncation |
6581 | @opindex Wno-format-truncation | |
ddf6fe37 AA |
6582 | @item -Wformat-truncation |
6583 | @itemx -Wformat-truncation=@var{level} | |
d77de738 ML |
6584 | Warn about calls to formatted input/output functions such as @code{snprintf} |
6585 | and @code{vsnprintf} that might result in output truncation. When the exact | |
6586 | number of bytes written by a format directive cannot be determined at | |
6587 | compile-time it is estimated based on heuristics that depend on | |
6588 | the @var{level} argument and on optimization. While enabling optimization | |
6589 | will in most cases improve the accuracy of the warning, it may also result | |
6590 | in false positives. Except as noted otherwise, the option uses the same | |
6591 | logic @option{-Wformat-overflow}. | |
6592 | ||
6593 | @table @gcctabopt | |
d77de738 ML |
6594 | @opindex Wformat-truncation |
6595 | @opindex Wno-format-truncation | |
ddf6fe37 AA |
6596 | @item -Wformat-truncation |
6597 | @itemx -Wformat-truncation=1 | |
d77de738 ML |
6598 | Level @var{1} of @option{-Wformat-truncation} enabled by @option{-Wformat} |
6599 | employs a conservative approach that warns only about calls to bounded | |
6600 | functions whose return value is unused and that will most likely result | |
6601 | in output truncation. | |
6602 | ||
6603 | @item -Wformat-truncation=2 | |
6604 | Level @var{2} warns also about calls to bounded functions whose return | |
6605 | value is used and that might result in truncation given an argument of | |
6606 | sufficient length or magnitude. | |
6607 | @end table | |
6608 | ||
d77de738 ML |
6609 | @opindex Wformat-y2k |
6610 | @opindex Wno-format-y2k | |
ddf6fe37 | 6611 | @item -Wformat-y2k |
d77de738 ML |
6612 | If @option{-Wformat} is specified, also warn about @code{strftime} |
6613 | formats that may yield only a two-digit year. | |
6614 | ||
d77de738 ML |
6615 | @opindex Wnonnull |
6616 | @opindex Wno-nonnull | |
ddf6fe37 | 6617 | @item -Wnonnull |
d77de738 ML |
6618 | Warn about passing a null pointer for arguments marked as |
6619 | requiring a non-null value by the @code{nonnull} function attribute. | |
6620 | ||
6621 | @option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It | |
6622 | can be disabled with the @option{-Wno-nonnull} option. | |
6623 | ||
d77de738 ML |
6624 | @opindex Wnonnull-compare |
6625 | @opindex Wno-nonnull-compare | |
ddf6fe37 | 6626 | @item -Wnonnull-compare |
d77de738 ML |
6627 | Warn when comparing an argument marked with the @code{nonnull} |
6628 | function attribute against null inside the function. | |
6629 | ||
6630 | @option{-Wnonnull-compare} is included in @option{-Wall}. It | |
6631 | can be disabled with the @option{-Wno-nonnull-compare} option. | |
6632 | ||
d77de738 ML |
6633 | @opindex Wnull-dereference |
6634 | @opindex Wno-null-dereference | |
ddf6fe37 | 6635 | @item -Wnull-dereference |
d77de738 ML |
6636 | Warn if the compiler detects paths that trigger erroneous or |
6637 | undefined behavior due to dereferencing a null pointer. This option | |
6638 | is only active when @option{-fdelete-null-pointer-checks} is active, | |
6639 | which is enabled by optimizations in most targets. The precision of | |
6640 | the warnings depends on the optimization options used. | |
6641 | ||
d77de738 ML |
6642 | @opindex Winfinite-recursion |
6643 | @opindex Wno-infinite-recursion | |
ddf6fe37 | 6644 | @item -Winfinite-recursion |
d77de738 ML |
6645 | Warn about infinitely recursive calls. The warning is effective at all |
6646 | optimization levels but requires optimization in order to detect infinite | |
6647 | recursion in calls between two or more functions. | |
6648 | @option{-Winfinite-recursion} is included in @option{-Wall}. | |
6649 | ||
ce51e843 ML |
6650 | Compare with @option{-Wanalyzer-infinite-recursion} which provides a |
6651 | similar diagnostic, but is implemented in a different way (as part of | |
6652 | @option{-fanalyzer}). | |
6653 | ||
d77de738 ML |
6654 | @opindex Winit-self |
6655 | @opindex Wno-init-self | |
ddf6fe37 | 6656 | @item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
6657 | Warn about uninitialized variables that are initialized with themselves. |
6658 | Note this option can only be used with the @option{-Wuninitialized} option. | |
6659 | ||
6660 | For example, GCC warns about @code{i} being uninitialized in the | |
6661 | following snippet only when @option{-Winit-self} has been specified: | |
6662 | @smallexample | |
6663 | @group | |
6664 | int f() | |
6665 | @{ | |
6666 | int i = i; | |
6667 | return i; | |
6668 | @} | |
6669 | @end group | |
6670 | @end smallexample | |
6671 | ||
6672 | This warning is enabled by @option{-Wall} in C++. | |
6673 | ||
d77de738 ML |
6674 | @opindex Wimplicit-int |
6675 | @opindex Wno-implicit-int | |
ddf6fe37 | 6676 | @item -Wno-implicit-int @r{(C and Objective-C only)} |
d77de738 ML |
6677 | This option controls warnings when a declaration does not specify a type. |
6678 | This warning is enabled by default in C99 and later dialects of C, | |
6679 | and also by @option{-Wall}. | |
6680 | ||
d77de738 ML |
6681 | @opindex Wimplicit-function-declaration |
6682 | @opindex Wno-implicit-function-declaration | |
ddf6fe37 | 6683 | @item -Wno-implicit-function-declaration @r{(C and Objective-C only)} |
d77de738 ML |
6684 | This option controls warnings when a function is used before being declared. |
6685 | This warning is enabled by default in C99 and later dialects of C, | |
6686 | and also by @option{-Wall}. | |
6687 | The warning is made into an error by @option{-pedantic-errors}. | |
6688 | ||
d77de738 ML |
6689 | @opindex Wimplicit |
6690 | @opindex Wno-implicit | |
ddf6fe37 | 6691 | @item -Wimplicit @r{(C and Objective-C only)} |
d77de738 ML |
6692 | Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}. |
6693 | This warning is enabled by @option{-Wall}. | |
6694 | ||
d77de738 ML |
6695 | @opindex Wimplicit-fallthrough |
6696 | @opindex Wno-implicit-fallthrough | |
ddf6fe37 | 6697 | @item -Wimplicit-fallthrough |
d77de738 ML |
6698 | @option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3} |
6699 | and @option{-Wno-implicit-fallthrough} is the same as | |
6700 | @option{-Wimplicit-fallthrough=0}. | |
6701 | ||
d77de738 | 6702 | @opindex Wimplicit-fallthrough= |
ddf6fe37 | 6703 | @item -Wimplicit-fallthrough=@var{n} |
d77de738 ML |
6704 | Warn when a switch case falls through. For example: |
6705 | ||
6706 | @smallexample | |
6707 | @group | |
6708 | switch (cond) | |
6709 | @{ | |
6710 | case 1: | |
6711 | a = 1; | |
6712 | break; | |
6713 | case 2: | |
6714 | a = 2; | |
6715 | case 3: | |
6716 | a = 3; | |
6717 | break; | |
6718 | @} | |
6719 | @end group | |
6720 | @end smallexample | |
6721 | ||
6722 | This warning does not warn when the last statement of a case cannot | |
6723 | fall through, e.g. when there is a return statement or a call to function | |
6724 | declared with the noreturn attribute. @option{-Wimplicit-fallthrough=} | |
6725 | also takes into account control flow statements, such as ifs, and only | |
6726 | warns when appropriate. E.g.@: | |
6727 | ||
6728 | @smallexample | |
6729 | @group | |
6730 | switch (cond) | |
6731 | @{ | |
6732 | case 1: | |
6733 | if (i > 3) @{ | |
6734 | bar (5); | |
6735 | break; | |
6736 | @} else if (i < 1) @{ | |
6737 | bar (0); | |
6738 | @} else | |
6739 | return; | |
6740 | default: | |
6741 | @dots{} | |
6742 | @} | |
6743 | @end group | |
6744 | @end smallexample | |
6745 | ||
6746 | Since there are occasions where a switch case fall through is desirable, | |
6747 | GCC provides an attribute, @code{__attribute__ ((fallthrough))}, that is | |
6748 | to be used along with a null statement to suppress this warning that | |
6749 | would normally occur: | |
6750 | ||
6751 | @smallexample | |
6752 | @group | |
6753 | switch (cond) | |
6754 | @{ | |
6755 | case 1: | |
6756 | bar (0); | |
6757 | __attribute__ ((fallthrough)); | |
6758 | default: | |
6759 | @dots{} | |
6760 | @} | |
6761 | @end group | |
6762 | @end smallexample | |
6763 | ||
6764 | C++17 provides a standard way to suppress the @option{-Wimplicit-fallthrough} | |
6765 | warning using @code{[[fallthrough]];} instead of the GNU attribute. In C++11 | |
6766 | or C++14 users can use @code{[[gnu::fallthrough]];}, which is a GNU extension. | |
6767 | Instead of these attributes, it is also possible to add a fallthrough comment | |
6768 | to silence the warning. The whole body of the C or C++ style comment should | |
6769 | match the given regular expressions listed below. The option argument @var{n} | |
6770 | specifies what kind of comments are accepted: | |
6771 | ||
6772 | @itemize @bullet | |
6773 | ||
6774 | @item @option{-Wimplicit-fallthrough=0} disables the warning altogether. | |
6775 | ||
6776 | @item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular | |
6777 | expression, any comment is used as fallthrough comment. | |
6778 | ||
6779 | @item @option{-Wimplicit-fallthrough=2} case insensitively matches | |
6780 | @code{.*falls?[ \t-]*thr(ough|u).*} regular expression. | |
6781 | ||
6782 | @item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the | |
6783 | following regular expressions: | |
6784 | ||
6785 | @itemize @bullet | |
6786 | ||
6787 | @item @code{-fallthrough} | |
6788 | ||
6789 | @item @code{@@fallthrough@@} | |
6790 | ||
6791 | @item @code{lint -fallthrough[ \t]*} | |
6792 | ||
6793 | @item @code{[ \t.!]*(ELSE,? |INTENTIONAL(LY)? )?@*FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)?} | |
6794 | ||
6795 | @item @code{[ \t.!]*(Else,? |Intentional(ly)? )?@*Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)?} | |
6796 | ||
6797 | @item @code{[ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )?@*fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)?} | |
6798 | ||
6799 | @end itemize | |
6800 | ||
6801 | @item @option{-Wimplicit-fallthrough=4} case sensitively matches one of the | |
6802 | following regular expressions: | |
6803 | ||
6804 | @itemize @bullet | |
6805 | ||
6806 | @item @code{-fallthrough} | |
6807 | ||
6808 | @item @code{@@fallthrough@@} | |
6809 | ||
6810 | @item @code{lint -fallthrough[ \t]*} | |
6811 | ||
6812 | @item @code{[ \t]*FALLTHR(OUGH|U)[ \t]*} | |
6813 | ||
6814 | @end itemize | |
6815 | ||
6816 | @item @option{-Wimplicit-fallthrough=5} doesn't recognize any comments as | |
6817 | fallthrough comments, only attributes disable the warning. | |
6818 | ||
6819 | @end itemize | |
6820 | ||
6821 | The comment needs to be followed after optional whitespace and other comments | |
6822 | by @code{case} or @code{default} keywords or by a user label that precedes some | |
6823 | @code{case} or @code{default} label. | |
6824 | ||
6825 | @smallexample | |
6826 | @group | |
6827 | switch (cond) | |
6828 | @{ | |
6829 | case 1: | |
6830 | bar (0); | |
6831 | /* FALLTHRU */ | |
6832 | default: | |
6833 | @dots{} | |
6834 | @} | |
6835 | @end group | |
6836 | @end smallexample | |
6837 | ||
6838 | The @option{-Wimplicit-fallthrough=3} warning is enabled by @option{-Wextra}. | |
6839 | ||
d77de738 ML |
6840 | @opindex Wif-not-aligned |
6841 | @opindex Wno-if-not-aligned | |
ddf6fe37 | 6842 | @item -Wno-if-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
6843 | Control if warnings triggered by the @code{warn_if_not_aligned} attribute |
6844 | should be issued. These warnings are enabled by default. | |
6845 | ||
d77de738 ML |
6846 | @opindex Wignored-qualifiers |
6847 | @opindex Wno-ignored-qualifiers | |
ddf6fe37 | 6848 | @item -Wignored-qualifiers @r{(C and C++ only)} |
d77de738 ML |
6849 | Warn if the return type of a function has a type qualifier |
6850 | such as @code{const}. For ISO C such a type qualifier has no effect, | |
6851 | since the value returned by a function is not an lvalue. | |
6852 | For C++, the warning is only emitted for scalar types or @code{void}. | |
6853 | ISO C prohibits qualified @code{void} return types on function | |
6854 | definitions, so such return types always receive a warning | |
6855 | even without this option. | |
6856 | ||
6857 | This warning is also enabled by @option{-Wextra}. | |
6858 | ||
d77de738 ML |
6859 | @opindex Wignored-attributes |
6860 | @opindex Wno-ignored-attributes | |
ddf6fe37 | 6861 | @item -Wno-ignored-attributes @r{(C and C++ only)} |
d77de738 ML |
6862 | This option controls warnings when an attribute is ignored. |
6863 | This is different from the | |
6864 | @option{-Wattributes} option in that it warns whenever the compiler decides | |
6865 | to drop an attribute, not that the attribute is either unknown, used in a | |
6866 | wrong place, etc. This warning is enabled by default. | |
6867 | ||
d77de738 ML |
6868 | @opindex Wmain |
6869 | @opindex Wno-main | |
ddf6fe37 | 6870 | @item -Wmain |
d77de738 ML |
6871 | Warn if the type of @code{main} is suspicious. @code{main} should be |
6872 | a function with external linkage, returning int, taking either zero | |
6873 | arguments, two, or three arguments of appropriate types. This warning | |
6874 | is enabled by default in C++ and is enabled by either @option{-Wall} | |
6875 | or @option{-Wpedantic}. | |
6876 | ||
d77de738 ML |
6877 | @opindex Wmisleading-indentation |
6878 | @opindex Wno-misleading-indentation | |
ddf6fe37 | 6879 | @item -Wmisleading-indentation @r{(C and C++ only)} |
d77de738 ML |
6880 | Warn when the indentation of the code does not reflect the block structure. |
6881 | Specifically, a warning is issued for @code{if}, @code{else}, @code{while}, and | |
6882 | @code{for} clauses with a guarded statement that does not use braces, | |
6883 | followed by an unguarded statement with the same indentation. | |
6884 | ||
6885 | In the following example, the call to ``bar'' is misleadingly indented as | |
6886 | if it were guarded by the ``if'' conditional. | |
6887 | ||
6888 | @smallexample | |
6889 | if (some_condition ()) | |
6890 | foo (); | |
6891 | bar (); /* Gotcha: this is not guarded by the "if". */ | |
6892 | @end smallexample | |
6893 | ||
6894 | In the case of mixed tabs and spaces, the warning uses the | |
6895 | @option{-ftabstop=} option to determine if the statements line up | |
6896 | (defaulting to 8). | |
6897 | ||
6898 | The warning is not issued for code involving multiline preprocessor logic | |
6899 | such as the following example. | |
6900 | ||
6901 | @smallexample | |
6902 | if (flagA) | |
6903 | foo (0); | |
6904 | #if SOME_CONDITION_THAT_DOES_NOT_HOLD | |
6905 | if (flagB) | |
6906 | #endif | |
6907 | foo (1); | |
6908 | @end smallexample | |
6909 | ||
6910 | The warning is not issued after a @code{#line} directive, since this | |
6911 | typically indicates autogenerated code, and no assumptions can be made | |
6912 | about the layout of the file that the directive references. | |
6913 | ||
6914 | This warning is enabled by @option{-Wall} in C and C++. | |
6915 | ||
d77de738 ML |
6916 | @opindex Wmissing-attributes |
6917 | @opindex Wno-missing-attributes | |
ddf6fe37 | 6918 | @item -Wmissing-attributes |
d77de738 ML |
6919 | Warn when a declaration of a function is missing one or more attributes |
6920 | that a related function is declared with and whose absence may adversely | |
6921 | affect the correctness or efficiency of generated code. For example, | |
6922 | the warning is issued for declarations of aliases that use attributes | |
6923 | to specify less restrictive requirements than those of their targets. | |
6924 | This typically represents a potential optimization opportunity. | |
6925 | By contrast, the @option{-Wattribute-alias=2} option controls warnings | |
6926 | issued when the alias is more restrictive than the target, which could | |
6927 | lead to incorrect code generation. | |
6928 | Attributes considered include @code{alloc_align}, @code{alloc_size}, | |
6929 | @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc}, | |
6930 | @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure}, | |
6931 | @code{returns_nonnull}, and @code{returns_twice}. | |
6932 | ||
6933 | In C++, the warning is issued when an explicit specialization of a primary | |
6934 | template declared with attribute @code{alloc_align}, @code{alloc_size}, | |
6935 | @code{assume_aligned}, @code{format}, @code{format_arg}, @code{malloc}, | |
6936 | or @code{nonnull} is declared without it. Attributes @code{deprecated}, | |
6937 | @code{error}, and @code{warning} suppress the warning. | |
6938 | (@pxref{Function Attributes}). | |
6939 | ||
6940 | You can use the @code{copy} attribute to apply the same | |
6941 | set of attributes to a declaration as that on another declaration without | |
6942 | explicitly enumerating the attributes. This attribute can be applied | |
6943 | to declarations of functions (@pxref{Common Function Attributes}), | |
6944 | variables (@pxref{Common Variable Attributes}), or types | |
6945 | (@pxref{Common Type Attributes}). | |
6946 | ||
6947 | @option{-Wmissing-attributes} is enabled by @option{-Wall}. | |
6948 | ||
6949 | For example, since the declaration of the primary function template | |
6950 | below makes use of both attribute @code{malloc} and @code{alloc_size} | |
6951 | the declaration of the explicit specialization of the template is | |
6952 | diagnosed because it is missing one of the attributes. | |
6953 | ||
6954 | @smallexample | |
6955 | template <class T> | |
6956 | T* __attribute__ ((malloc, alloc_size (1))) | |
6957 | allocate (size_t); | |
6958 | ||
6959 | template <> | |
6960 | void* __attribute__ ((malloc)) // missing alloc_size | |
6961 | allocate<void> (size_t); | |
6962 | @end smallexample | |
6963 | ||
d77de738 ML |
6964 | @opindex Wmissing-braces |
6965 | @opindex Wno-missing-braces | |
ddf6fe37 | 6966 | @item -Wmissing-braces |
d77de738 ML |
6967 | Warn if an aggregate or union initializer is not fully bracketed. In |
6968 | the following example, the initializer for @code{a} is not fully | |
6969 | bracketed, but that for @code{b} is fully bracketed. | |
6970 | ||
6971 | @smallexample | |
6972 | int a[2][2] = @{ 0, 1, 2, 3 @}; | |
6973 | int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @}; | |
6974 | @end smallexample | |
6975 | ||
6976 | This warning is enabled by @option{-Wall}. | |
6977 | ||
d77de738 ML |
6978 | @opindex Wmissing-include-dirs |
6979 | @opindex Wno-missing-include-dirs | |
ddf6fe37 | 6980 | @item -Wmissing-include-dirs @r{(C, C++, Objective-C, Objective-C++ and Fortran only)} |
d77de738 ML |
6981 | Warn if a user-supplied include directory does not exist. This opions is disabled |
6982 | by default for C, C++, Objective-C and Objective-C++. For Fortran, it is partially | |
6983 | enabled by default by warning for -I and -J, only. | |
6984 | ||
d77de738 ML |
6985 | @opindex Wmissing-profile |
6986 | @opindex Wno-missing-profile | |
ddf6fe37 | 6987 | @item -Wno-missing-profile |
d77de738 ML |
6988 | This option controls warnings if feedback profiles are missing when using the |
6989 | @option{-fprofile-use} option. | |
6990 | This option diagnoses those cases where a new function or a new file is added | |
6991 | between compiling with @option{-fprofile-generate} and with | |
6992 | @option{-fprofile-use}, without regenerating the profiles. | |
6993 | In these cases, the profile feedback data files do not contain any | |
6994 | profile feedback information for | |
6995 | the newly added function or file respectively. Also, in the case when profile | |
6996 | count data (.gcda) files are removed, GCC cannot use any profile feedback | |
6997 | information. In all these cases, warnings are issued to inform you that a | |
6998 | profile generation step is due. | |
6999 | Ignoring the warning can result in poorly optimized code. | |
7000 | @option{-Wno-missing-profile} can be used to | |
7001 | disable the warning, but this is not recommended and should be done only | |
7002 | when non-existent profile data is justified. | |
7003 | ||
d77de738 ML |
7004 | @opindex Wmismatched-dealloc |
7005 | @opindex Wno-mismatched-dealloc | |
ddf6fe37 | 7006 | @item -Wmismatched-dealloc |
d77de738 ML |
7007 | |
7008 | Warn for calls to deallocation functions with pointer arguments returned | |
7009 | from from allocations functions for which the former isn't a suitable | |
7010 | deallocator. A pair of functions can be associated as matching allocators | |
7011 | and deallocators by use of attribute @code{malloc}. Unless disabled by | |
7012 | the @option{-fno-builtin} option the standard functions @code{calloc}, | |
7013 | @code{malloc}, @code{realloc}, and @code{free}, as well as the corresponding | |
7014 | forms of C++ @code{operator new} and @code{operator delete} are implicitly | |
7015 | associated as matching allocators and deallocators. In the following | |
7016 | example @code{mydealloc} is the deallocator for pointers returned from | |
7017 | @code{myalloc}. | |
7018 | ||
7019 | @smallexample | |
7020 | void mydealloc (void*); | |
7021 | ||
7022 | __attribute__ ((malloc (mydealloc, 1))) void* | |
7023 | myalloc (size_t); | |
7024 | ||
7025 | void f (void) | |
7026 | @{ | |
7027 | void *p = myalloc (32); | |
7028 | // @dots{}use p@dots{} | |
7029 | free (p); // warning: not a matching deallocator for myalloc | |
7030 | mydealloc (p); // ok | |
7031 | @} | |
7032 | @end smallexample | |
7033 | ||
7034 | In C++, the related option @option{-Wmismatched-new-delete} diagnoses | |
7035 | mismatches involving either @code{operator new} or @code{operator delete}. | |
7036 | ||
7037 | Option @option{-Wmismatched-dealloc} is included in @option{-Wall}. | |
7038 | ||
d77de738 ML |
7039 | @opindex Wmultistatement-macros |
7040 | @opindex Wno-multistatement-macros | |
ddf6fe37 | 7041 | @item -Wmultistatement-macros |
d77de738 ML |
7042 | Warn about unsafe multiple statement macros that appear to be guarded |
7043 | by a clause such as @code{if}, @code{else}, @code{for}, @code{switch}, or | |
7044 | @code{while}, in which only the first statement is actually guarded after | |
7045 | the macro is expanded. | |
7046 | ||
7047 | For example: | |
7048 | ||
7049 | @smallexample | |
7050 | #define DOIT x++; y++ | |
7051 | if (c) | |
7052 | DOIT; | |
7053 | @end smallexample | |
7054 | ||
7055 | will increment @code{y} unconditionally, not just when @code{c} holds. | |
7056 | The can usually be fixed by wrapping the macro in a do-while loop: | |
7057 | @smallexample | |
7058 | #define DOIT do @{ x++; y++; @} while (0) | |
7059 | if (c) | |
7060 | DOIT; | |
7061 | @end smallexample | |
7062 | ||
7063 | This warning is enabled by @option{-Wall} in C and C++. | |
7064 | ||
d77de738 ML |
7065 | @opindex Wparentheses |
7066 | @opindex Wno-parentheses | |
ddf6fe37 | 7067 | @item -Wparentheses |
d77de738 ML |
7068 | Warn if parentheses are omitted in certain contexts, such |
7069 | as when there is an assignment in a context where a truth value | |
7070 | is expected, or when operators are nested whose precedence people | |
7071 | often get confused about. | |
7072 | ||
7073 | Also warn if a comparison like @code{x<=y<=z} appears; this is | |
7074 | equivalent to @code{(x<=y ? 1 : 0) <= z}, which is a different | |
7075 | interpretation from that of ordinary mathematical notation. | |
7076 | ||
7077 | Also warn for dangerous uses of the GNU extension to | |
7078 | @code{?:} with omitted middle operand. When the condition | |
7079 | in the @code{?}: operator is a boolean expression, the omitted value is | |
7080 | always 1. Often programmers expect it to be a value computed | |
7081 | inside the conditional expression instead. | |
7082 | ||
7083 | For C++ this also warns for some cases of unnecessary parentheses in | |
7084 | declarations, which can indicate an attempt at a function call instead | |
7085 | of a declaration: | |
7086 | @smallexample | |
7087 | @{ | |
7088 | // Declares a local variable called mymutex. | |
7089 | std::unique_lock<std::mutex> (mymutex); | |
7090 | // User meant std::unique_lock<std::mutex> lock (mymutex); | |
7091 | @} | |
7092 | @end smallexample | |
7093 | ||
7094 | This warning is enabled by @option{-Wall}. | |
7095 | ||
d77de738 ML |
7096 | @opindex Wself-move |
7097 | @opindex Wno-self-move | |
ddf6fe37 | 7098 | @item -Wno-self-move @r{(C++ and Objective-C++ only)} |
d77de738 ML |
7099 | This warning warns when a value is moved to itself with @code{std::move}. |
7100 | Such a @code{std::move} typically has no effect. | |
7101 | ||
7102 | @smallexample | |
7103 | struct T @{ | |
7104 | @dots{} | |
7105 | @}; | |
7106 | void fn() | |
7107 | @{ | |
7108 | T t; | |
7109 | @dots{} | |
7110 | t = std::move (t); | |
7111 | @} | |
7112 | @end smallexample | |
7113 | ||
7114 | This warning is enabled by @option{-Wall}. | |
7115 | ||
d77de738 ML |
7116 | @opindex Wsequence-point |
7117 | @opindex Wno-sequence-point | |
ddf6fe37 | 7118 | @item -Wsequence-point |
d77de738 ML |
7119 | Warn about code that may have undefined semantics because of violations |
7120 | of sequence point rules in the C and C++ standards. | |
7121 | ||
7122 | The C and C++ standards define the order in which expressions in a C/C++ | |
7123 | program are evaluated in terms of @dfn{sequence points}, which represent | |
7124 | a partial ordering between the execution of parts of the program: those | |
7125 | executed before the sequence point, and those executed after it. These | |
7126 | occur after the evaluation of a full expression (one which is not part | |
7127 | of a larger expression), after the evaluation of the first operand of a | |
7128 | @code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a | |
7129 | function is called (but after the evaluation of its arguments and the | |
7130 | expression denoting the called function), and in certain other places. | |
7131 | Other than as expressed by the sequence point rules, the order of | |
7132 | evaluation of subexpressions of an expression is not specified. All | |
7133 | these rules describe only a partial order rather than a total order, | |
7134 | since, for example, if two functions are called within one expression | |
7135 | with no sequence point between them, the order in which the functions | |
7136 | are called is not specified. However, the standards committee have | |
7137 | ruled that function calls do not overlap. | |
7138 | ||
7139 | It is not specified when between sequence points modifications to the | |
7140 | values of objects take effect. Programs whose behavior depends on this | |
7141 | have undefined behavior; the C and C++ standards specify that ``Between | |
7142 | the previous and next sequence point an object shall have its stored | |
7143 | value modified at most once by the evaluation of an expression. | |
7144 | Furthermore, the prior value shall be read only to determine the value | |
7145 | to be stored.''. If a program breaks these rules, the results on any | |
7146 | particular implementation are entirely unpredictable. | |
7147 | ||
7148 | Examples of code with undefined behavior are @code{a = a++;}, @code{a[n] | |
7149 | = b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not | |
7150 | diagnosed by this option, and it may give an occasional false positive | |
7151 | result, but in general it has been found fairly effective at detecting | |
7152 | this sort of problem in programs. | |
7153 | ||
7154 | The C++17 standard will define the order of evaluation of operands in | |
7155 | more cases: in particular it requires that the right-hand side of an | |
7156 | assignment be evaluated before the left-hand side, so the above | |
7157 | examples are no longer undefined. But this option will still warn | |
7158 | about them, to help people avoid writing code that is undefined in C | |
7159 | and earlier revisions of C++. | |
7160 | ||
7161 | The standard is worded confusingly, therefore there is some debate | |
7162 | over the precise meaning of the sequence point rules in subtle cases. | |
7163 | Links to discussions of the problem, including proposed formal | |
7164 | definitions, may be found on the GCC readings page, at | |
7165 | @uref{https://gcc.gnu.org/@/readings.html}. | |
7166 | ||
7167 | This warning is enabled by @option{-Wall} for C and C++. | |
7168 | ||
d77de738 ML |
7169 | @opindex Wno-return-local-addr |
7170 | @opindex Wreturn-local-addr | |
ddf6fe37 | 7171 | @item -Wno-return-local-addr |
d77de738 ML |
7172 | Do not warn about returning a pointer (or in C++, a reference) to a |
7173 | variable that goes out of scope after the function returns. | |
7174 | ||
d77de738 ML |
7175 | @opindex Wreturn-type |
7176 | @opindex Wno-return-type | |
ddf6fe37 | 7177 | @item -Wreturn-type |
d77de738 ML |
7178 | Warn whenever a function is defined with a return type that defaults |
7179 | to @code{int}. Also warn about any @code{return} statement with no | |
7180 | return value in a function whose return type is not @code{void} | |
7181 | (falling off the end of the function body is considered returning | |
7182 | without a value). | |
7183 | ||
7184 | For C only, warn about a @code{return} statement with an expression in a | |
7185 | function whose return type is @code{void}, unless the expression type is | |
7186 | also @code{void}. As a GNU extension, the latter case is accepted | |
7187 | without a warning unless @option{-Wpedantic} is used. Attempting | |
7188 | to use the return value of a non-@code{void} function other than @code{main} | |
7189 | that flows off the end by reaching the closing curly brace that terminates | |
7190 | the function is undefined. | |
7191 | ||
7192 | Unlike in C, in C++, flowing off the end of a non-@code{void} function other | |
7193 | than @code{main} results in undefined behavior even when the value of | |
7194 | the function is not used. | |
7195 | ||
7196 | This warning is enabled by default in C++ and by @option{-Wall} otherwise. | |
7197 | ||
d77de738 ML |
7198 | @opindex Wshift-count-negative |
7199 | @opindex Wno-shift-count-negative | |
ddf6fe37 | 7200 | @item -Wno-shift-count-negative |
d77de738 ML |
7201 | Controls warnings if a shift count is negative. |
7202 | This warning is enabled by default. | |
7203 | ||
d77de738 ML |
7204 | @opindex Wshift-count-overflow |
7205 | @opindex Wno-shift-count-overflow | |
ddf6fe37 | 7206 | @item -Wno-shift-count-overflow |
d77de738 ML |
7207 | Controls warnings if a shift count is greater than or equal to the bit width |
7208 | of the type. This warning is enabled by default. | |
7209 | ||
d77de738 ML |
7210 | @opindex Wshift-negative-value |
7211 | @opindex Wno-shift-negative-value | |
ddf6fe37 | 7212 | @item -Wshift-negative-value |
d77de738 ML |
7213 | Warn if left shifting a negative value. This warning is enabled by |
7214 | @option{-Wextra} in C99 (and newer) and C++11 to C++17 modes. | |
7215 | ||
d77de738 ML |
7216 | @opindex Wshift-overflow |
7217 | @opindex Wno-shift-overflow | |
ddf6fe37 AA |
7218 | @item -Wno-shift-overflow |
7219 | @itemx -Wshift-overflow=@var{n} | |
d77de738 ML |
7220 | These options control warnings about left shift overflows. |
7221 | ||
7222 | @table @gcctabopt | |
7223 | @item -Wshift-overflow=1 | |
7224 | This is the warning level of @option{-Wshift-overflow} and is enabled | |
7225 | by default in C99 and C++11 modes (and newer). This warning level does | |
7226 | not warn about left-shifting 1 into the sign bit. (However, in C, such | |
7227 | an overflow is still rejected in contexts where an integer constant expression | |
7228 | is required.) No warning is emitted in C++20 mode (and newer), as signed left | |
7229 | shifts always wrap. | |
7230 | ||
7231 | @item -Wshift-overflow=2 | |
7232 | This warning level also warns about left-shifting 1 into the sign bit, | |
7233 | unless C++14 mode (or newer) is active. | |
7234 | @end table | |
7235 | ||
d77de738 ML |
7236 | @opindex Wswitch |
7237 | @opindex Wno-switch | |
ddf6fe37 | 7238 | @item -Wswitch |
d77de738 ML |
7239 | Warn whenever a @code{switch} statement has an index of enumerated type |
7240 | and lacks a @code{case} for one or more of the named codes of that | |
7241 | enumeration. (The presence of a @code{default} label prevents this | |
7242 | warning.) @code{case} labels outside the enumeration range also | |
7243 | provoke warnings when this option is used (even if there is a | |
7244 | @code{default} label). | |
7245 | This warning is enabled by @option{-Wall}. | |
7246 | ||
d77de738 ML |
7247 | @opindex Wswitch-default |
7248 | @opindex Wno-switch-default | |
ddf6fe37 | 7249 | @item -Wswitch-default |
d77de738 ML |
7250 | Warn whenever a @code{switch} statement does not have a @code{default} |
7251 | case. | |
7252 | ||
d77de738 ML |
7253 | @opindex Wswitch-enum |
7254 | @opindex Wno-switch-enum | |
ddf6fe37 | 7255 | @item -Wswitch-enum |
d77de738 ML |
7256 | Warn whenever a @code{switch} statement has an index of enumerated type |
7257 | and lacks a @code{case} for one or more of the named codes of that | |
7258 | enumeration. @code{case} labels outside the enumeration range also | |
7259 | provoke warnings when this option is used. The only difference | |
7260 | between @option{-Wswitch} and this option is that this option gives a | |
7261 | warning about an omitted enumeration code even if there is a | |
7262 | @code{default} label. | |
7263 | ||
d77de738 ML |
7264 | @opindex Wswitch-bool |
7265 | @opindex Wno-switch-bool | |
ddf6fe37 | 7266 | @item -Wno-switch-bool |
d77de738 ML |
7267 | Do not warn when a @code{switch} statement has an index of boolean type |
7268 | and the case values are outside the range of a boolean type. | |
7269 | It is possible to suppress this warning by casting the controlling | |
7270 | expression to a type other than @code{bool}. For example: | |
7271 | @smallexample | |
7272 | @group | |
7273 | switch ((int) (a == 4)) | |
7274 | @{ | |
7275 | @dots{} | |
7276 | @} | |
7277 | @end group | |
7278 | @end smallexample | |
7279 | This warning is enabled by default for C and C++ programs. | |
7280 | ||
d77de738 ML |
7281 | @opindex Wswitch-outside-range |
7282 | @opindex Wno-switch-outside-range | |
ddf6fe37 | 7283 | @item -Wno-switch-outside-range |
d77de738 ML |
7284 | This option controls warnings when a @code{switch} case has a value |
7285 | that is outside of its | |
7286 | respective type range. This warning is enabled by default for | |
7287 | C and C++ programs. | |
7288 | ||
d77de738 ML |
7289 | @opindex Wswitch-unreachable |
7290 | @opindex Wno-switch-unreachable | |
ddf6fe37 | 7291 | @item -Wno-switch-unreachable |
d77de738 ML |
7292 | Do not warn when a @code{switch} statement contains statements between the |
7293 | controlling expression and the first case label, which will never be | |
7294 | executed. For example: | |
7295 | @smallexample | |
7296 | @group | |
7297 | switch (cond) | |
7298 | @{ | |
7299 | i = 15; | |
7300 | @dots{} | |
7301 | case 5: | |
7302 | @dots{} | |
7303 | @} | |
7304 | @end group | |
7305 | @end smallexample | |
7306 | @option{-Wswitch-unreachable} does not warn if the statement between the | |
7307 | controlling expression and the first case label is just a declaration: | |
7308 | @smallexample | |
7309 | @group | |
7310 | switch (cond) | |
7311 | @{ | |
7312 | int i; | |
7313 | @dots{} | |
7314 | case 5: | |
7315 | i = 5; | |
7316 | @dots{} | |
7317 | @} | |
7318 | @end group | |
7319 | @end smallexample | |
7320 | This warning is enabled by default for C and C++ programs. | |
7321 | ||
d77de738 ML |
7322 | @opindex Wsync-nand |
7323 | @opindex Wno-sync-nand | |
ddf6fe37 | 7324 | @item -Wsync-nand @r{(C and C++ only)} |
d77de738 ML |
7325 | Warn when @code{__sync_fetch_and_nand} and @code{__sync_nand_and_fetch} |
7326 | built-in functions are used. These functions changed semantics in GCC 4.4. | |
7327 | ||
d77de738 ML |
7328 | @opindex Wtrivial-auto-var-init |
7329 | @opindex Wno-trivial-auto-var-init | |
ddf6fe37 | 7330 | @item -Wtrivial-auto-var-init |
d77de738 ML |
7331 | Warn when @code{-ftrivial-auto-var-init} cannot initialize the automatic |
7332 | variable. A common situation is an automatic variable that is declared | |
7333 | between the controlling expression and the first case label of a @code{switch} | |
7334 | statement. | |
7335 | ||
d77de738 ML |
7336 | @opindex Wunused-but-set-parameter |
7337 | @opindex Wno-unused-but-set-parameter | |
ddf6fe37 | 7338 | @item -Wunused-but-set-parameter |
d77de738 ML |
7339 | Warn whenever a function parameter is assigned to, but otherwise unused |
7340 | (aside from its declaration). | |
7341 | ||
7342 | To suppress this warning use the @code{unused} attribute | |
7343 | (@pxref{Variable Attributes}). | |
7344 | ||
7345 | This warning is also enabled by @option{-Wunused} together with | |
7346 | @option{-Wextra}. | |
7347 | ||
d77de738 ML |
7348 | @opindex Wunused-but-set-variable |
7349 | @opindex Wno-unused-but-set-variable | |
ddf6fe37 | 7350 | @item -Wunused-but-set-variable |
d77de738 ML |
7351 | Warn whenever a local variable is assigned to, but otherwise unused |
7352 | (aside from its declaration). | |
7353 | This warning is enabled by @option{-Wall}. | |
7354 | ||
7355 | To suppress this warning use the @code{unused} attribute | |
7356 | (@pxref{Variable Attributes}). | |
7357 | ||
7358 | This warning is also enabled by @option{-Wunused}, which is enabled | |
7359 | by @option{-Wall}. | |
7360 | ||
d77de738 ML |
7361 | @opindex Wunused-function |
7362 | @opindex Wno-unused-function | |
ddf6fe37 | 7363 | @item -Wunused-function |
d77de738 ML |
7364 | Warn whenever a static function is declared but not defined or a |
7365 | non-inline static function is unused. | |
7366 | This warning is enabled by @option{-Wall}. | |
7367 | ||
d77de738 ML |
7368 | @opindex Wunused-label |
7369 | @opindex Wno-unused-label | |
ddf6fe37 | 7370 | @item -Wunused-label |
d77de738 ML |
7371 | Warn whenever a label is declared but not used. |
7372 | This warning is enabled by @option{-Wall}. | |
7373 | ||
7374 | To suppress this warning use the @code{unused} attribute | |
7375 | (@pxref{Variable Attributes}). | |
7376 | ||
d77de738 ML |
7377 | @opindex Wunused-local-typedefs |
7378 | @opindex Wno-unused-local-typedefs | |
ddf6fe37 | 7379 | @item -Wunused-local-typedefs @r{(C, Objective-C, C++ and Objective-C++ only)} |
d77de738 ML |
7380 | Warn when a typedef locally defined in a function is not used. |
7381 | This warning is enabled by @option{-Wall}. | |
7382 | ||
d77de738 ML |
7383 | @opindex Wunused-parameter |
7384 | @opindex Wno-unused-parameter | |
ddf6fe37 | 7385 | @item -Wunused-parameter |
d77de738 ML |
7386 | Warn whenever a function parameter is unused aside from its declaration. |
7387 | ||
7388 | To suppress this warning use the @code{unused} attribute | |
7389 | (@pxref{Variable Attributes}). | |
7390 | ||
d77de738 ML |
7391 | @opindex Wunused-result |
7392 | @opindex Wno-unused-result | |
ddf6fe37 | 7393 | @item -Wno-unused-result |
d77de738 ML |
7394 | Do not warn if a caller of a function marked with attribute |
7395 | @code{warn_unused_result} (@pxref{Function Attributes}) does not use | |
7396 | its return value. The default is @option{-Wunused-result}. | |
7397 | ||
d77de738 ML |
7398 | @opindex Wunused-variable |
7399 | @opindex Wno-unused-variable | |
ddf6fe37 | 7400 | @item -Wunused-variable |
d77de738 ML |
7401 | Warn whenever a local or static variable is unused aside from its |
7402 | declaration. This option implies @option{-Wunused-const-variable=1} for C, | |
7403 | but not for C++. This warning is enabled by @option{-Wall}. | |
7404 | ||
7405 | To suppress this warning use the @code{unused} attribute | |
7406 | (@pxref{Variable Attributes}). | |
7407 | ||
d77de738 ML |
7408 | @opindex Wunused-const-variable |
7409 | @opindex Wno-unused-const-variable | |
ddf6fe37 AA |
7410 | @item -Wunused-const-variable |
7411 | @itemx -Wunused-const-variable=@var{n} | |
d77de738 ML |
7412 | Warn whenever a constant static variable is unused aside from its declaration. |
7413 | @option{-Wunused-const-variable=1} is enabled by @option{-Wunused-variable} | |
7414 | for C, but not for C++. In C this declares variable storage, but in C++ this | |
7415 | is not an error since const variables take the place of @code{#define}s. | |
7416 | ||
7417 | To suppress this warning use the @code{unused} attribute | |
7418 | (@pxref{Variable Attributes}). | |
7419 | ||
7420 | @table @gcctabopt | |
7421 | @item -Wunused-const-variable=1 | |
7422 | This is the warning level that is enabled by @option{-Wunused-variable} for | |
7423 | C. It warns only about unused static const variables defined in the main | |
7424 | compilation unit, but not about static const variables declared in any | |
7425 | header included. | |
7426 | ||
7427 | @item -Wunused-const-variable=2 | |
7428 | This warning level also warns for unused constant static variables in | |
7429 | headers (excluding system headers). This is the warning level of | |
7430 | @option{-Wunused-const-variable} and must be explicitly requested since | |
7431 | in C++ this isn't an error and in C it might be harder to clean up all | |
7432 | headers included. | |
7433 | @end table | |
7434 | ||
d77de738 ML |
7435 | @opindex Wunused-value |
7436 | @opindex Wno-unused-value | |
ddf6fe37 | 7437 | @item -Wunused-value |
d77de738 ML |
7438 | Warn whenever a statement computes a result that is explicitly not |
7439 | used. To suppress this warning cast the unused expression to | |
7440 | @code{void}. This includes an expression-statement or the left-hand | |
7441 | side of a comma expression that contains no side effects. For example, | |
7442 | an expression such as @code{x[i,j]} causes a warning, while | |
7443 | @code{x[(void)i,j]} does not. | |
7444 | ||
7445 | This warning is enabled by @option{-Wall}. | |
7446 | ||
d77de738 ML |
7447 | @opindex Wunused |
7448 | @opindex Wno-unused | |
ddf6fe37 | 7449 | @item -Wunused |
d77de738 ML |
7450 | All the above @option{-Wunused} options combined. |
7451 | ||
7452 | In order to get a warning about an unused function parameter, you must | |
7453 | either specify @option{-Wextra -Wunused} (note that @option{-Wall} implies | |
7454 | @option{-Wunused}), or separately specify @option{-Wunused-parameter}. | |
7455 | ||
d77de738 ML |
7456 | @opindex Wuninitialized |
7457 | @opindex Wno-uninitialized | |
ddf6fe37 | 7458 | @item -Wuninitialized |
d77de738 ML |
7459 | Warn if an object with automatic or allocated storage duration is used |
7460 | without having been initialized. In C++, also warn if a non-static | |
7461 | reference or non-static @code{const} member appears in a class without | |
7462 | constructors. | |
7463 | ||
7464 | In addition, passing a pointer (or in C++, a reference) to an uninitialized | |
7465 | object to a @code{const}-qualified argument of a built-in function known to | |
7466 | read the object is also diagnosed by this warning. | |
7467 | (@option{-Wmaybe-uninitialized} is issued for ordinary functions.) | |
7468 | ||
7469 | If you want to warn about code that uses the uninitialized value of the | |
7470 | variable in its own initializer, use the @option{-Winit-self} option. | |
7471 | ||
7472 | These warnings occur for individual uninitialized elements of | |
7473 | structure, union or array variables as well as for variables that are | |
7474 | uninitialized as a whole. They do not occur for variables or elements | |
7475 | declared @code{volatile}. Because these warnings depend on | |
7476 | optimization, the exact variables or elements for which there are | |
7477 | warnings depend on the precise optimization options and version of GCC | |
7478 | used. | |
7479 | ||
7480 | Note that there may be no warning about a variable that is used only | |
7481 | to compute a value that itself is never used, because such | |
7482 | computations may be deleted by data flow analysis before the warnings | |
7483 | are printed. | |
7484 | ||
7485 | In C++, this warning also warns about using uninitialized objects in | |
7486 | member-initializer-lists. For example, GCC warns about @code{b} being | |
7487 | uninitialized in the following snippet: | |
7488 | ||
7489 | @smallexample | |
7490 | struct A @{ | |
7491 | int a; | |
7492 | int b; | |
7493 | A() : a(b) @{ @} | |
7494 | @}; | |
7495 | @end smallexample | |
7496 | ||
d77de738 ML |
7497 | @opindex Winvalid-memory-model |
7498 | @opindex Wno-invalid-memory-model | |
ddf6fe37 | 7499 | @item -Wno-invalid-memory-model |
d77de738 ML |
7500 | This option controls warnings |
7501 | for invocations of @ref{__atomic Builtins}, @ref{__sync Builtins}, | |
7502 | and the C11 atomic generic functions with a memory consistency argument | |
7503 | that is either invalid for the operation or outside the range of values | |
7504 | of the @code{memory_order} enumeration. For example, since the | |
7505 | @code{__atomic_store} and @code{__atomic_store_n} built-ins are only | |
7506 | defined for the relaxed, release, and sequentially consistent memory | |
7507 | orders the following code is diagnosed: | |
7508 | ||
7509 | @smallexample | |
7510 | void store (int *i) | |
7511 | @{ | |
7512 | __atomic_store_n (i, 0, memory_order_consume); | |
7513 | @} | |
7514 | @end smallexample | |
7515 | ||
7516 | @option{-Winvalid-memory-model} is enabled by default. | |
7517 | ||
d77de738 ML |
7518 | @opindex Wmaybe-uninitialized |
7519 | @opindex Wno-maybe-uninitialized | |
ddf6fe37 | 7520 | @item -Wmaybe-uninitialized |
d77de738 ML |
7521 | For an object with automatic or allocated storage duration, if there exists |
7522 | a path from the function entry to a use of the object that is initialized, | |
7523 | but there exist some other paths for which the object is not initialized, | |
7524 | the compiler emits a warning if it cannot prove the uninitialized paths | |
7525 | are not executed at run time. | |
7526 | ||
7527 | In addition, passing a pointer (or in C++, a reference) to an uninitialized | |
7528 | object to a @code{const}-qualified function argument is also diagnosed by | |
7529 | this warning. (@option{-Wuninitialized} is issued for built-in functions | |
7530 | known to read the object.) Annotating the function with attribute | |
7531 | @code{access (none)} indicates that the argument isn't used to access | |
7532 | the object and avoids the warning (@pxref{Common Function Attributes}). | |
7533 | ||
7534 | These warnings are only possible in optimizing compilation, because otherwise | |
7535 | GCC does not keep track of the state of variables. | |
7536 | ||
7537 | These warnings are made optional because GCC may not be able to determine when | |
7538 | the code is correct in spite of appearing to have an error. Here is one | |
7539 | example of how this can happen: | |
7540 | ||
7541 | @smallexample | |
7542 | @group | |
7543 | @{ | |
7544 | int x; | |
7545 | switch (y) | |
7546 | @{ | |
7547 | case 1: x = 1; | |
7548 | break; | |
7549 | case 2: x = 4; | |
7550 | break; | |
7551 | case 3: x = 5; | |
7552 | @} | |
7553 | foo (x); | |
7554 | @} | |
7555 | @end group | |
7556 | @end smallexample | |
7557 | ||
7558 | @noindent | |
7559 | If the value of @code{y} is always 1, 2 or 3, then @code{x} is | |
7560 | always initialized, but GCC doesn't know this. To suppress the | |
7561 | warning, you need to provide a default case with assert(0) or | |
7562 | similar code. | |
7563 | ||
7564 | @cindex @code{longjmp} warnings | |
7565 | This option also warns when a non-volatile automatic variable might be | |
7566 | changed by a call to @code{longjmp}. | |
7567 | The compiler sees only the calls to @code{setjmp}. It cannot know | |
7568 | where @code{longjmp} will be called; in fact, a signal handler could | |
7569 | call it at any point in the code. As a result, you may get a warning | |
7570 | even when there is in fact no problem because @code{longjmp} cannot | |
7571 | in fact be called at the place that would cause a problem. | |
7572 | ||
7573 | Some spurious warnings can be avoided if you declare all the functions | |
7574 | you use that never return as @code{noreturn}. @xref{Function | |
7575 | Attributes}. | |
7576 | ||
7577 | This warning is enabled by @option{-Wall} or @option{-Wextra}. | |
7578 | ||
d77de738 ML |
7579 | @opindex Wunknown-pragmas |
7580 | @opindex Wno-unknown-pragmas | |
7581 | @cindex warning for unknown pragmas | |
7582 | @cindex unknown pragmas, warning | |
7583 | @cindex pragmas, warning of unknown | |
f33d7a88 | 7584 | @item -Wunknown-pragmas |
d77de738 ML |
7585 | Warn when a @code{#pragma} directive is encountered that is not understood by |
7586 | GCC@. If this command-line option is used, warnings are even issued | |
7587 | for unknown pragmas in system header files. This is not the case if | |
7588 | the warnings are only enabled by the @option{-Wall} command-line option. | |
7589 | ||
d77de738 ML |
7590 | @opindex Wno-pragmas |
7591 | @opindex Wpragmas | |
ddf6fe37 | 7592 | @item -Wno-pragmas |
d77de738 ML |
7593 | Do not warn about misuses of pragmas, such as incorrect parameters, |
7594 | invalid syntax, or conflicts between pragmas. See also | |
7595 | @option{-Wunknown-pragmas}. | |
7596 | ||
d77de738 ML |
7597 | @opindex Wno-prio-ctor-dtor |
7598 | @opindex Wprio-ctor-dtor | |
ddf6fe37 | 7599 | @item -Wno-prio-ctor-dtor |
d77de738 ML |
7600 | Do not warn if a priority from 0 to 100 is used for constructor or destructor. |
7601 | The use of constructor and destructor attributes allow you to assign a | |
7602 | priority to the constructor/destructor to control its order of execution | |
7603 | before @code{main} is called or after it returns. The priority values must be | |
7604 | greater than 100 as the compiler reserves priority values between 0--100 for | |
7605 | the implementation. | |
7606 | ||
d77de738 ML |
7607 | @opindex Wstrict-aliasing |
7608 | @opindex Wno-strict-aliasing | |
ddf6fe37 | 7609 | @item -Wstrict-aliasing |
d77de738 ML |
7610 | This option is only active when @option{-fstrict-aliasing} is active. |
7611 | It warns about code that might break the strict aliasing rules that the | |
7612 | compiler is using for optimization. The warning does not catch all | |
7613 | cases, but does attempt to catch the more common pitfalls. It is | |
7614 | included in @option{-Wall}. | |
7615 | It is equivalent to @option{-Wstrict-aliasing=3} | |
7616 | ||
d77de738 | 7617 | @opindex Wstrict-aliasing=n |
ddf6fe37 | 7618 | @item -Wstrict-aliasing=n |
d77de738 ML |
7619 | This option is only active when @option{-fstrict-aliasing} is active. |
7620 | It warns about code that might break the strict aliasing rules that the | |
7621 | compiler is using for optimization. | |
7622 | Higher levels correspond to higher accuracy (fewer false positives). | |
7623 | Higher levels also correspond to more effort, similar to the way @option{-O} | |
7624 | works. | |
7625 | @option{-Wstrict-aliasing} is equivalent to @option{-Wstrict-aliasing=3}. | |
7626 | ||
7627 | Level 1: Most aggressive, quick, least accurate. | |
7628 | Possibly useful when higher levels | |
7629 | do not warn but @option{-fstrict-aliasing} still breaks the code, as it has very few | |
7630 | false negatives. However, it has many false positives. | |
7631 | Warns for all pointer conversions between possibly incompatible types, | |
7632 | even if never dereferenced. Runs in the front end only. | |
7633 | ||
7634 | Level 2: Aggressive, quick, not too precise. | |
7635 | May still have many false positives (not as many as level 1 though), | |
7636 | and few false negatives (but possibly more than level 1). | |
7637 | Unlike level 1, it only warns when an address is taken. Warns about | |
7638 | incomplete types. Runs in the front end only. | |
7639 | ||
7640 | Level 3 (default for @option{-Wstrict-aliasing}): | |
7641 | Should have very few false positives and few false | |
7642 | negatives. Slightly slower than levels 1 or 2 when optimization is enabled. | |
7643 | Takes care of the common pun+dereference pattern in the front end: | |
7644 | @code{*(int*)&some_float}. | |
7645 | If optimization is enabled, it also runs in the back end, where it deals | |
7646 | with multiple statement cases using flow-sensitive points-to information. | |
7647 | Only warns when the converted pointer is dereferenced. | |
7648 | Does not warn about incomplete types. | |
7649 | ||
d77de738 ML |
7650 | @opindex Wstrict-overflow |
7651 | @opindex Wno-strict-overflow | |
ddf6fe37 AA |
7652 | @item -Wstrict-overflow |
7653 | @itemx -Wstrict-overflow=@var{n} | |
d77de738 ML |
7654 | This option is only active when signed overflow is undefined. |
7655 | It warns about cases where the compiler optimizes based on the | |
7656 | assumption that signed overflow does not occur. Note that it does not | |
7657 | warn about all cases where the code might overflow: it only warns | |
7658 | about cases where the compiler implements some optimization. Thus | |
7659 | this warning depends on the optimization level. | |
7660 | ||
7661 | An optimization that assumes that signed overflow does not occur is | |
7662 | perfectly safe if the values of the variables involved are such that | |
7663 | overflow never does, in fact, occur. Therefore this warning can | |
7664 | easily give a false positive: a warning about code that is not | |
7665 | actually a problem. To help focus on important issues, several | |
7666 | warning levels are defined. No warnings are issued for the use of | |
7667 | undefined signed overflow when estimating how many iterations a loop | |
7668 | requires, in particular when determining whether a loop will be | |
7669 | executed at all. | |
7670 | ||
7671 | @table @gcctabopt | |
7672 | @item -Wstrict-overflow=1 | |
7673 | Warn about cases that are both questionable and easy to avoid. For | |
7674 | example the compiler simplifies | |
7675 | @code{x + 1 > x} to @code{1}. This level of | |
7676 | @option{-Wstrict-overflow} is enabled by @option{-Wall}; higher levels | |
7677 | are not, and must be explicitly requested. | |
7678 | ||
7679 | @item -Wstrict-overflow=2 | |
7680 | Also warn about other cases where a comparison is simplified to a | |
7681 | constant. For example: @code{abs (x) >= 0}. This can only be | |
7682 | simplified when signed integer overflow is undefined, because | |
7683 | @code{abs (INT_MIN)} overflows to @code{INT_MIN}, which is less than | |
7684 | zero. @option{-Wstrict-overflow} (with no level) is the same as | |
7685 | @option{-Wstrict-overflow=2}. | |
7686 | ||
7687 | @item -Wstrict-overflow=3 | |
7688 | Also warn about other cases where a comparison is simplified. For | |
7689 | example: @code{x + 1 > 1} is simplified to @code{x > 0}. | |
7690 | ||
7691 | @item -Wstrict-overflow=4 | |
7692 | Also warn about other simplifications not covered by the above cases. | |
7693 | For example: @code{(x * 10) / 5} is simplified to @code{x * 2}. | |
7694 | ||
7695 | @item -Wstrict-overflow=5 | |
7696 | Also warn about cases where the compiler reduces the magnitude of a | |
7697 | constant involved in a comparison. For example: @code{x + 2 > y} is | |
7698 | simplified to @code{x + 1 >= y}. This is reported only at the | |
7699 | highest warning level because this simplification applies to many | |
7700 | comparisons, so this warning level gives a very large number of | |
7701 | false positives. | |
7702 | @end table | |
7703 | ||
d77de738 ML |
7704 | @opindex Wstring-compare |
7705 | @opindex Wno-string-compare | |
ddf6fe37 | 7706 | @item -Wstring-compare |
d77de738 ML |
7707 | Warn for calls to @code{strcmp} and @code{strncmp} whose result is |
7708 | determined to be either zero or non-zero in tests for such equality | |
7709 | owing to the length of one argument being greater than the size of | |
7710 | the array the other argument is stored in (or the bound in the case | |
7711 | of @code{strncmp}). Such calls could be mistakes. For example, | |
7712 | the call to @code{strcmp} below is diagnosed because its result is | |
7713 | necessarily non-zero irrespective of the contents of the array @code{a}. | |
7714 | ||
7715 | @smallexample | |
7716 | extern char a[4]; | |
7717 | void f (char *d) | |
7718 | @{ | |
7719 | strcpy (d, "string"); | |
7720 | @dots{} | |
7721 | if (0 == strcmp (a, d)) // cannot be true | |
7722 | puts ("a and d are the same"); | |
7723 | @} | |
7724 | @end smallexample | |
7725 | ||
7726 | @option{-Wstring-compare} is enabled by @option{-Wextra}. | |
7727 | ||
ddf6fe37 AA |
7728 | @opindex Wstringop-overflow |
7729 | @opindex Wno-stringop-overflow | |
d77de738 ML |
7730 | @item -Wno-stringop-overflow |
7731 | @item -Wstringop-overflow | |
7732 | @itemx -Wstringop-overflow=@var{type} | |
d77de738 ML |
7733 | Warn for calls to string manipulation functions such as @code{memcpy} and |
7734 | @code{strcpy} that are determined to overflow the destination buffer. The | |
7735 | optional argument is one greater than the type of Object Size Checking to | |
7736 | perform to determine the size of the destination. @xref{Object Size Checking}. | |
7737 | The argument is meaningful only for functions that operate on character arrays | |
7738 | but not for raw memory functions like @code{memcpy} which always make use | |
7739 | of Object Size type-0. The option also warns for calls that specify a size | |
7740 | in excess of the largest possible object or at most @code{SIZE_MAX / 2} bytes. | |
7741 | The option produces the best results with optimization enabled but can detect | |
7742 | a small subset of simple buffer overflows even without optimization in | |
7743 | calls to the GCC built-in functions like @code{__builtin_memcpy} that | |
7744 | correspond to the standard functions. In any case, the option warns about | |
7745 | just a subset of buffer overflows detected by the corresponding overflow | |
7746 | checking built-ins. For example, the option issues a warning for | |
7747 | the @code{strcpy} call below because it copies at least 5 characters | |
7748 | (the string @code{"blue"} including the terminating NUL) into the buffer | |
7749 | of size 4. | |
7750 | ||
7751 | @smallexample | |
7752 | enum Color @{ blue, purple, yellow @}; | |
7753 | const char* f (enum Color clr) | |
7754 | @{ | |
7755 | static char buf [4]; | |
7756 | const char *str; | |
7757 | switch (clr) | |
7758 | @{ | |
7759 | case blue: str = "blue"; break; | |
7760 | case purple: str = "purple"; break; | |
7761 | case yellow: str = "yellow"; break; | |
7762 | @} | |
7763 | ||
7764 | return strcpy (buf, str); // warning here | |
7765 | @} | |
7766 | @end smallexample | |
7767 | ||
7768 | Option @option{-Wstringop-overflow=2} is enabled by default. | |
7769 | ||
7770 | @table @gcctabopt | |
d77de738 ML |
7771 | @opindex Wstringop-overflow |
7772 | @opindex Wno-stringop-overflow | |
ddf6fe37 AA |
7773 | @item -Wstringop-overflow |
7774 | @itemx -Wstringop-overflow=1 | |
d77de738 ML |
7775 | The @option{-Wstringop-overflow=1} option uses type-zero Object Size Checking |
7776 | to determine the sizes of destination objects. At this setting the option | |
7777 | does not warn for writes past the end of subobjects of larger objects accessed | |
7778 | by pointers unless the size of the largest surrounding object is known. When | |
7779 | the destination may be one of several objects it is assumed to be the largest | |
7780 | one of them. On Linux systems, when optimization is enabled at this setting | |
7781 | the option warns for the same code as when the @code{_FORTIFY_SOURCE} macro | |
7782 | is defined to a non-zero value. | |
7783 | ||
7784 | @item -Wstringop-overflow=2 | |
7785 | The @option{-Wstringop-overflow=2} option uses type-one Object Size Checking | |
7786 | to determine the sizes of destination objects. At this setting the option | |
7787 | warns about overflows when writing to members of the largest complete | |
7788 | objects whose exact size is known. However, it does not warn for excessive | |
7789 | writes to the same members of unknown objects referenced by pointers since | |
7790 | they may point to arrays containing unknown numbers of elements. This is | |
7791 | the default setting of the option. | |
7792 | ||
7793 | @item -Wstringop-overflow=3 | |
7794 | The @option{-Wstringop-overflow=3} option uses type-two Object Size Checking | |
7795 | to determine the sizes of destination objects. At this setting the option | |
7796 | warns about overflowing the smallest object or data member. This is the | |
7797 | most restrictive setting of the option that may result in warnings for safe | |
7798 | code. | |
7799 | ||
7800 | @item -Wstringop-overflow=4 | |
7801 | The @option{-Wstringop-overflow=4} option uses type-three Object Size Checking | |
7802 | to determine the sizes of destination objects. At this setting the option | |
7803 | warns about overflowing any data members, and when the destination is | |
7804 | one of several objects it uses the size of the largest of them to decide | |
7805 | whether to issue a warning. Similarly to @option{-Wstringop-overflow=3} this | |
7806 | setting of the option may result in warnings for benign code. | |
7807 | @end table | |
7808 | ||
d77de738 ML |
7809 | @opindex Wstringop-overread |
7810 | @opindex Wno-stringop-overread | |
ddf6fe37 | 7811 | @item -Wno-stringop-overread |
d77de738 ML |
7812 | Warn for calls to string manipulation functions such as @code{memchr}, or |
7813 | @code{strcpy} that are determined to read past the end of the source | |
7814 | sequence. | |
7815 | ||
7816 | Option @option{-Wstringop-overread} is enabled by default. | |
7817 | ||
d77de738 ML |
7818 | @opindex Wstringop-truncation |
7819 | @opindex Wno-stringop-truncation | |
ddf6fe37 | 7820 | @item -Wno-stringop-truncation |
d77de738 ML |
7821 | Do not warn for calls to bounded string manipulation functions |
7822 | such as @code{strncat}, | |
7823 | @code{strncpy}, and @code{stpncpy} that may either truncate the copied string | |
7824 | or leave the destination unchanged. | |
7825 | ||
7826 | In the following example, the call to @code{strncat} specifies a bound that | |
7827 | is less than the length of the source string. As a result, the copy of | |
7828 | the source will be truncated and so the call is diagnosed. To avoid the | |
7829 | warning use @code{bufsize - strlen (buf) - 1)} as the bound. | |
7830 | ||
7831 | @smallexample | |
7832 | void append (char *buf, size_t bufsize) | |
7833 | @{ | |
7834 | strncat (buf, ".txt", 3); | |
7835 | @} | |
7836 | @end smallexample | |
7837 | ||
7838 | As another example, the following call to @code{strncpy} results in copying | |
7839 | to @code{d} just the characters preceding the terminating NUL, without | |
7840 | appending the NUL to the end. Assuming the result of @code{strncpy} is | |
7841 | necessarily a NUL-terminated string is a common mistake, and so the call | |
7842 | is diagnosed. To avoid the warning when the result is not expected to be | |
7843 | NUL-terminated, call @code{memcpy} instead. | |
7844 | ||
7845 | @smallexample | |
7846 | void copy (char *d, const char *s) | |
7847 | @{ | |
7848 | strncpy (d, s, strlen (s)); | |
7849 | @} | |
7850 | @end smallexample | |
7851 | ||
7852 | In the following example, the call to @code{strncpy} specifies the size | |
7853 | of the destination buffer as the bound. If the length of the source | |
7854 | string is equal to or greater than this size the result of the copy will | |
7855 | not be NUL-terminated. Therefore, the call is also diagnosed. To avoid | |
7856 | the warning, specify @code{sizeof buf - 1} as the bound and set the last | |
7857 | element of the buffer to @code{NUL}. | |
7858 | ||
7859 | @smallexample | |
7860 | void copy (const char *s) | |
7861 | @{ | |
7862 | char buf[80]; | |
7863 | strncpy (buf, s, sizeof buf); | |
7864 | @dots{} | |
7865 | @} | |
7866 | @end smallexample | |
7867 | ||
7868 | In situations where a character array is intended to store a sequence | |
7869 | of bytes with no terminating @code{NUL} such an array may be annotated | |
7870 | with attribute @code{nonstring} to avoid this warning. Such arrays, | |
7871 | however, are not suitable arguments to functions that expect | |
7872 | @code{NUL}-terminated strings. To help detect accidental misuses of | |
7873 | such arrays GCC issues warnings unless it can prove that the use is | |
7874 | safe. @xref{Common Variable Attributes}. | |
7875 | ||
2a27ae32 QZ |
7876 | @opindex Wstrict-flex-arrays |
7877 | @opindex Wno-strict-flex-arrays | |
ddf6fe37 | 7878 | @item -Wstrict-flex-arrays |
2a27ae32 QZ |
7879 | Warn about inproper usages of flexible array members |
7880 | according to the @var{level} of the @code{strict_flex_array (@var{level})} | |
7881 | attribute attached to the trailing array field of a structure if it's | |
7882 | available, otherwise according to the @var{level} of the option | |
7883 | @option{-fstrict-flex-arrays=@var{level}}. | |
7884 | ||
7885 | This option is effective only when @var{level} is bigger than 0. Otherwise, | |
7886 | it will be ignored with a warning. | |
7887 | ||
7888 | when @var{level}=1, warnings will be issued for a trailing array reference | |
7889 | of a structure that have 2 or more elements if the trailing array is referenced | |
7890 | as a flexible array member. | |
7891 | ||
7892 | when @var{level}=2, in addition to @var{level}=1, additional warnings will be | |
7893 | issued for a trailing one-element array reference of a structure | |
7894 | if the array is referenced as a flexible array member. | |
7895 | ||
7896 | when @var{level}=3, in addition to @var{level}=2, additional warnings will be | |
7897 | issued for a trailing zero-length array reference of a structure | |
7898 | if the array is referenced as a flexible array member. | |
7899 | ||
7900 | ||
d77de738 ML |
7901 | @opindex Wsuggest-attribute= |
7902 | @opindex Wno-suggest-attribute= | |
ddf6fe37 | 7903 | @item -Wsuggest-attribute=@r{[}pure@r{|}const@r{|}noreturn@r{|}format@r{|}cold@r{|}malloc@r{]} |
d77de738 ML |
7904 | Warn for cases where adding an attribute may be beneficial. The |
7905 | attributes currently supported are listed below. | |
7906 | ||
7907 | @table @gcctabopt | |
d77de738 ML |
7908 | @opindex Wsuggest-attribute=pure |
7909 | @opindex Wno-suggest-attribute=pure | |
7910 | @opindex Wsuggest-attribute=const | |
7911 | @opindex Wno-suggest-attribute=const | |
7912 | @opindex Wsuggest-attribute=noreturn | |
7913 | @opindex Wno-suggest-attribute=noreturn | |
7914 | @opindex Wmissing-noreturn | |
7915 | @opindex Wno-missing-noreturn | |
7916 | @opindex Wsuggest-attribute=malloc | |
7917 | @opindex Wno-suggest-attribute=malloc | |
ddf6fe37 AA |
7918 | @item -Wsuggest-attribute=pure |
7919 | @itemx -Wsuggest-attribute=const | |
7920 | @itemx -Wsuggest-attribute=noreturn | |
7921 | @itemx -Wmissing-noreturn | |
7922 | @itemx -Wsuggest-attribute=malloc | |
d77de738 ML |
7923 | |
7924 | Warn about functions that might be candidates for attributes | |
7925 | @code{pure}, @code{const} or @code{noreturn} or @code{malloc}. The compiler | |
7926 | only warns for functions visible in other compilation units or (in the case of | |
7927 | @code{pure} and @code{const}) if it cannot prove that the function returns | |
7928 | normally. A function returns normally if it doesn't contain an infinite loop or | |
7929 | return abnormally by throwing, calling @code{abort} or trapping. This analysis | |
7930 | requires option @option{-fipa-pure-const}, which is enabled by default at | |
7931 | @option{-O} and higher. Higher optimization levels improve the accuracy | |
7932 | of the analysis. | |
7933 | ||
d77de738 ML |
7934 | @opindex Wsuggest-attribute=format |
7935 | @opindex Wmissing-format-attribute | |
7936 | @opindex Wno-suggest-attribute=format | |
7937 | @opindex Wno-missing-format-attribute | |
7938 | @opindex Wformat | |
7939 | @opindex Wno-format | |
ddf6fe37 AA |
7940 | @item -Wsuggest-attribute=format |
7941 | @itemx -Wmissing-format-attribute | |
d77de738 ML |
7942 | |
7943 | Warn about function pointers that might be candidates for @code{format} | |
7944 | attributes. Note these are only possible candidates, not absolute ones. | |
7945 | GCC guesses that function pointers with @code{format} attributes that | |
7946 | are used in assignment, initialization, parameter passing or return | |
7947 | statements should have a corresponding @code{format} attribute in the | |
7948 | resulting type. I.e.@: the left-hand side of the assignment or | |
7949 | initialization, the type of the parameter variable, or the return type | |
7950 | of the containing function respectively should also have a @code{format} | |
7951 | attribute to avoid the warning. | |
7952 | ||
7953 | GCC also warns about function definitions that might be | |
7954 | candidates for @code{format} attributes. Again, these are only | |
7955 | possible candidates. GCC guesses that @code{format} attributes | |
7956 | might be appropriate for any function that calls a function like | |
7957 | @code{vprintf} or @code{vscanf}, but this might not always be the | |
7958 | case, and some functions for which @code{format} attributes are | |
7959 | appropriate may not be detected. | |
7960 | ||
d77de738 ML |
7961 | @opindex Wsuggest-attribute=cold |
7962 | @opindex Wno-suggest-attribute=cold | |
ddf6fe37 | 7963 | @item -Wsuggest-attribute=cold |
d77de738 ML |
7964 | |
7965 | Warn about functions that might be candidates for @code{cold} attribute. This | |
7966 | is based on static detection and generally only warns about functions which | |
7967 | always leads to a call to another @code{cold} function such as wrappers of | |
7968 | C++ @code{throw} or fatal error reporting functions leading to @code{abort}. | |
7969 | @end table | |
7970 | ||
d77de738 ML |
7971 | @opindex Wno-alloc-zero |
7972 | @opindex Walloc-zero | |
ddf6fe37 | 7973 | @item -Walloc-zero |
d77de738 ML |
7974 | Warn about calls to allocation functions decorated with attribute |
7975 | @code{alloc_size} that specify zero bytes, including those to the built-in | |
7976 | forms of the functions @code{aligned_alloc}, @code{alloca}, @code{calloc}, | |
7977 | @code{malloc}, and @code{realloc}. Because the behavior of these functions | |
7978 | when called with a zero size differs among implementations (and in the case | |
7979 | of @code{realloc} has been deprecated) relying on it may result in subtle | |
7980 | portability bugs and should be avoided. | |
7981 | ||
d77de738 ML |
7982 | @opindex Walloc-size-larger-than= |
7983 | @opindex Wno-alloc-size-larger-than | |
ddf6fe37 | 7984 | @item -Walloc-size-larger-than=@var{byte-size} |
d77de738 ML |
7985 | Warn about calls to functions decorated with attribute @code{alloc_size} |
7986 | that attempt to allocate objects larger than the specified number of bytes, | |
7987 | or where the result of the size computation in an integer type with infinite | |
7988 | precision would exceed the value of @samp{PTRDIFF_MAX} on the target. | |
7989 | @option{-Walloc-size-larger-than=}@samp{PTRDIFF_MAX} is enabled by default. | |
7990 | Warnings controlled by the option can be disabled either by specifying | |
7991 | @var{byte-size} of @samp{SIZE_MAX} or more or by | |
7992 | @option{-Wno-alloc-size-larger-than}. | |
7993 | @xref{Function Attributes}. | |
7994 | ||
d77de738 | 7995 | @opindex Wno-alloc-size-larger-than |
ddf6fe37 | 7996 | @item -Wno-alloc-size-larger-than |
d77de738 ML |
7997 | Disable @option{-Walloc-size-larger-than=} warnings. The option is |
7998 | equivalent to @option{-Walloc-size-larger-than=}@samp{SIZE_MAX} or | |
7999 | larger. | |
8000 | ||
d77de738 ML |
8001 | @opindex Wno-alloca |
8002 | @opindex Walloca | |
ddf6fe37 | 8003 | @item -Walloca |
d77de738 ML |
8004 | This option warns on all uses of @code{alloca} in the source. |
8005 | ||
d77de738 ML |
8006 | @opindex Walloca-larger-than= |
8007 | @opindex Wno-alloca-larger-than | |
ddf6fe37 | 8008 | @item -Walloca-larger-than=@var{byte-size} |
d77de738 ML |
8009 | This option warns on calls to @code{alloca} with an integer argument whose |
8010 | value is either zero, or that is not bounded by a controlling predicate | |
8011 | that limits its value to at most @var{byte-size}. It also warns for calls | |
8012 | to @code{alloca} where the bound value is unknown. Arguments of non-integer | |
8013 | types are considered unbounded even if they appear to be constrained to | |
8014 | the expected range. | |
8015 | ||
8016 | For example, a bounded case of @code{alloca} could be: | |
8017 | ||
8018 | @smallexample | |
8019 | void func (size_t n) | |
8020 | @{ | |
8021 | void *p; | |
8022 | if (n <= 1000) | |
8023 | p = alloca (n); | |
8024 | else | |
8025 | p = malloc (n); | |
8026 | f (p); | |
8027 | @} | |
8028 | @end smallexample | |
8029 | ||
8030 | In the above example, passing @code{-Walloca-larger-than=1000} would not | |
8031 | issue a warning because the call to @code{alloca} is known to be at most | |
8032 | 1000 bytes. However, if @code{-Walloca-larger-than=500} were passed, | |
8033 | the compiler would emit a warning. | |
8034 | ||
8035 | Unbounded uses, on the other hand, are uses of @code{alloca} with no | |
8036 | controlling predicate constraining its integer argument. For example: | |
8037 | ||
8038 | @smallexample | |
8039 | void func () | |
8040 | @{ | |
8041 | void *p = alloca (n); | |
8042 | f (p); | |
8043 | @} | |
8044 | @end smallexample | |
8045 | ||
8046 | If @code{-Walloca-larger-than=500} were passed, the above would trigger | |
8047 | a warning, but this time because of the lack of bounds checking. | |
8048 | ||
8049 | Note, that even seemingly correct code involving signed integers could | |
8050 | cause a warning: | |
8051 | ||
8052 | @smallexample | |
8053 | void func (signed int n) | |
8054 | @{ | |
8055 | if (n < 500) | |
8056 | @{ | |
8057 | p = alloca (n); | |
8058 | f (p); | |
8059 | @} | |
8060 | @} | |
8061 | @end smallexample | |
8062 | ||
8063 | In the above example, @var{n} could be negative, causing a larger than | |
8064 | expected argument to be implicitly cast into the @code{alloca} call. | |
8065 | ||
8066 | This option also warns when @code{alloca} is used in a loop. | |
8067 | ||
8068 | @option{-Walloca-larger-than=}@samp{PTRDIFF_MAX} is enabled by default | |
8069 | but is usually only effective when @option{-ftree-vrp} is active (default | |
8070 | for @option{-O2} and above). | |
8071 | ||
8072 | See also @option{-Wvla-larger-than=}@samp{byte-size}. | |
8073 | ||
d77de738 | 8074 | @opindex Wno-alloca-larger-than |
ddf6fe37 | 8075 | @item -Wno-alloca-larger-than |
d77de738 ML |
8076 | Disable @option{-Walloca-larger-than=} warnings. The option is |
8077 | equivalent to @option{-Walloca-larger-than=}@samp{SIZE_MAX} or larger. | |
8078 | ||
d77de738 ML |
8079 | @opindex Warith-conversion |
8080 | @opindex Wno-arith-conversion | |
ddf6fe37 | 8081 | @item -Warith-conversion |
d77de738 ML |
8082 | Do warn about implicit conversions from arithmetic operations even |
8083 | when conversion of the operands to the same type cannot change their | |
8084 | values. This affects warnings from @option{-Wconversion}, | |
8085 | @option{-Wfloat-conversion}, and @option{-Wsign-conversion}. | |
8086 | ||
8087 | @smallexample | |
8088 | @group | |
8089 | void f (char c, int i) | |
8090 | @{ | |
8091 | c = c + i; // warns with @option{-Wconversion} | |
8092 | c = c + 1; // only warns with @option{-Warith-conversion} | |
8093 | @} | |
8094 | @end group | |
8095 | @end smallexample | |
8096 | ||
d77de738 ML |
8097 | @opindex Wno-array-bounds |
8098 | @opindex Warray-bounds | |
ddf6fe37 AA |
8099 | @item -Warray-bounds |
8100 | @itemx -Warray-bounds=@var{n} | |
d77de738 ML |
8101 | Warn about out of bounds subscripts or offsets into arrays. This warning |
8102 | is enabled by @option{-Wall}. It is more effective when @option{-ftree-vrp} | |
8103 | is active (the default for @option{-O2} and above) but a subset of instances | |
8104 | are issued even without optimization. | |
8105 | ||
710c9676 QZ |
8106 | By default, the trailing array of a structure will be treated as a flexible |
8107 | array member by @option{-Warray-bounds} or @option{-Warray-bounds=@var{n}} | |
8108 | if it is declared as either a flexible array member per C99 standard onwards | |
8109 | (@samp{[]}), a GCC zero-length array extension (@samp{[0]}), or an one-element | |
8110 | array (@samp{[1]}). As a result, out of bounds subscripts or offsets into | |
8111 | zero-length arrays or one-element arrays are not warned by default. | |
8112 | ||
8113 | You can add the option @option{-fstrict-flex-arrays} or | |
8114 | @option{-fstrict-flex-arrays=@var{level}} to control how this | |
8115 | option treat trailing array of a structure as a flexible array member: | |
8116 | ||
8117 | when @var{level}<=1, no change to the default behavior. | |
8118 | ||
8119 | when @var{level}=2, additional warnings will be issued for out of bounds | |
8120 | subscripts or offsets into one-element arrays; | |
8121 | ||
8122 | when @var{level}=3, in addition to @var{level}=2, additional warnings will be | |
8123 | issued for out of bounds subscripts or offsets into zero-length arrays. | |
8124 | ||
d77de738 ML |
8125 | @table @gcctabopt |
8126 | @item -Warray-bounds=1 | |
8127 | This is the default warning level of @option{-Warray-bounds} and is enabled | |
8128 | by @option{-Wall}; higher levels are not, and must be explicitly requested. | |
8129 | ||
8130 | @item -Warray-bounds=2 | |
710c9676 QZ |
8131 | This warning level also warns about the intermediate results of pointer |
8132 | arithmetic that may yield out of bounds values. This warning level may | |
8133 | give a larger number of false positives and is deactivated by default. | |
d77de738 ML |
8134 | @end table |
8135 | ||
d77de738 ML |
8136 | @opindex Warray-compare |
8137 | @opindex Wno-array-compare | |
ddf6fe37 | 8138 | @item -Warray-compare |
d77de738 ML |
8139 | Warn about equality and relational comparisons between two operands of array |
8140 | type. This comparison was deprecated in C++20. For example: | |
8141 | ||
8142 | @smallexample | |
8143 | int arr1[5]; | |
8144 | int arr2[5]; | |
8145 | bool same = arr1 == arr2; | |
8146 | @end smallexample | |
8147 | ||
8148 | @option{-Warray-compare} is enabled by @option{-Wall}. | |
8149 | ||
ddf6fe37 | 8150 | @opindex Wno-array-parameter |
d77de738 ML |
8151 | @item -Warray-parameter |
8152 | @itemx -Warray-parameter=@var{n} | |
d77de738 ML |
8153 | Warn about redeclarations of functions involving arguments of array or |
8154 | pointer types of inconsistent kinds or forms, and enable the detection | |
8155 | of out-of-bounds accesses to such parameters by warnings such as | |
8156 | @option{-Warray-bounds}. | |
8157 | ||
8158 | If the first function declaration uses the array form the bound specified | |
8159 | in the array is assumed to be the minimum number of elements expected to | |
8160 | be provided in calls to the function and the maximum number of elements | |
8161 | accessed by it. Failing to provide arguments of sufficient size or accessing | |
8162 | more than the maximum number of elements may be diagnosed by warnings such | |
8163 | as @option{-Warray-bounds}. At level 1 the warning diagnoses inconsistencies | |
8164 | involving array parameters declared using the @code{T[static N]} form. | |
8165 | ||
8166 | For example, the warning triggers for the following redeclarations because | |
8167 | the first one allows an array of any size to be passed to @code{f} while | |
8168 | the second one with the keyword @code{static} specifies that the array | |
8169 | argument must have at least four elements. | |
8170 | ||
8171 | @smallexample | |
8172 | void f (int[static 4]); | |
8173 | void f (int[]); // warning (inconsistent array form) | |
8174 | ||
8175 | void g (void) | |
8176 | @{ | |
8177 | int *p = (int *)malloc (4); | |
8178 | f (p); // warning (array too small) | |
8179 | @dots{} | |
8180 | @} | |
8181 | @end smallexample | |
8182 | ||
8183 | At level 2 the warning also triggers for redeclarations involving any other | |
8184 | inconsistency in array or pointer argument forms denoting array sizes. | |
8185 | Pointers and arrays of unspecified bound are considered equivalent and do | |
8186 | not trigger a warning. | |
8187 | ||
8188 | @smallexample | |
8189 | void g (int*); | |
8190 | void g (int[]); // no warning | |
8191 | void g (int[8]); // warning (inconsistent array bound) | |
8192 | @end smallexample | |
8193 | ||
8194 | @option{-Warray-parameter=2} is included in @option{-Wall}. The | |
8195 | @option{-Wvla-parameter} option triggers warnings for similar inconsistencies | |
8196 | involving Variable Length Array arguments. | |
8197 | ||
d77de738 ML |
8198 | @opindex Wattribute-alias |
8199 | @opindex Wno-attribute-alias | |
ddf6fe37 AA |
8200 | @item -Wattribute-alias=@var{n} |
8201 | @itemx -Wno-attribute-alias | |
d77de738 ML |
8202 | Warn about declarations using the @code{alias} and similar attributes whose |
8203 | target is incompatible with the type of the alias. | |
8204 | @xref{Function Attributes,,Declaring Attributes of Functions}. | |
8205 | ||
8206 | @table @gcctabopt | |
8207 | @item -Wattribute-alias=1 | |
8208 | The default warning level of the @option{-Wattribute-alias} option diagnoses | |
8209 | incompatibilities between the type of the alias declaration and that of its | |
8210 | target. Such incompatibilities are typically indicative of bugs. | |
8211 | ||
8212 | @item -Wattribute-alias=2 | |
8213 | ||
8214 | At this level @option{-Wattribute-alias} also diagnoses cases where | |
8215 | the attributes of the alias declaration are more restrictive than the | |
8216 | attributes applied to its target. These mismatches can potentially | |
8217 | result in incorrect code generation. In other cases they may be | |
8218 | benign and could be resolved simply by adding the missing attribute to | |
8219 | the target. For comparison, see the @option{-Wmissing-attributes} | |
8220 | option, which controls diagnostics when the alias declaration is less | |
8221 | restrictive than the target, rather than more restrictive. | |
8222 | ||
8223 | Attributes considered include @code{alloc_align}, @code{alloc_size}, | |
8224 | @code{cold}, @code{const}, @code{hot}, @code{leaf}, @code{malloc}, | |
8225 | @code{nonnull}, @code{noreturn}, @code{nothrow}, @code{pure}, | |
8226 | @code{returns_nonnull}, and @code{returns_twice}. | |
8227 | @end table | |
8228 | ||
8229 | @option{-Wattribute-alias} is equivalent to @option{-Wattribute-alias=1}. | |
8230 | This is the default. You can disable these warnings with either | |
8231 | @option{-Wno-attribute-alias} or @option{-Wattribute-alias=0}. | |
8232 | ||
d77de738 ML |
8233 | @opindex Wbidi-chars= |
8234 | @opindex Wbidi-chars | |
8235 | @opindex Wno-bidi-chars | |
ddf6fe37 | 8236 | @item -Wbidi-chars=@r{[}none@r{|}unpaired@r{|}any@r{|}ucn@r{]} |
d77de738 ML |
8237 | Warn about possibly misleading UTF-8 bidirectional control characters in |
8238 | comments, string literals, character constants, and identifiers. Such | |
8239 | characters can change left-to-right writing direction into right-to-left | |
8240 | (and vice versa), which can cause confusion between the logical order and | |
8241 | visual order. This may be dangerous; for instance, it may seem that a piece | |
8242 | of code is not commented out, whereas it in fact is. | |
8243 | ||
8244 | There are three levels of warning supported by GCC@. The default is | |
8245 | @option{-Wbidi-chars=unpaired}, which warns about improperly terminated | |
8246 | bidi contexts. @option{-Wbidi-chars=none} turns the warning off. | |
8247 | @option{-Wbidi-chars=any} warns about any use of bidirectional control | |
8248 | characters. | |
8249 | ||
8250 | By default, this warning does not warn about UCNs. It is, however, possible | |
8251 | to turn on such checking by using @option{-Wbidi-chars=unpaired,ucn} or | |
8252 | @option{-Wbidi-chars=any,ucn}. Using @option{-Wbidi-chars=ucn} is valid, | |
8253 | and is equivalent to @option{-Wbidi-chars=unpaired,ucn}, if no previous | |
8254 | @option{-Wbidi-chars=any} was specified. | |
8255 | ||
d77de738 ML |
8256 | @opindex Wno-bool-compare |
8257 | @opindex Wbool-compare | |
ddf6fe37 | 8258 | @item -Wbool-compare |
d77de738 ML |
8259 | Warn about boolean expression compared with an integer value different from |
8260 | @code{true}/@code{false}. For instance, the following comparison is | |
8261 | always false: | |
8262 | @smallexample | |
8263 | int n = 5; | |
8264 | @dots{} | |
8265 | if ((n > 1) == 2) @{ @dots{} @} | |
8266 | @end smallexample | |
8267 | This warning is enabled by @option{-Wall}. | |
8268 | ||
d77de738 ML |
8269 | @opindex Wno-bool-operation |
8270 | @opindex Wbool-operation | |
ddf6fe37 | 8271 | @item -Wbool-operation |
d77de738 ML |
8272 | Warn about suspicious operations on expressions of a boolean type. For |
8273 | instance, bitwise negation of a boolean is very likely a bug in the program. | |
8274 | For C, this warning also warns about incrementing or decrementing a boolean, | |
8275 | which rarely makes sense. (In C++, decrementing a boolean is always invalid. | |
8276 | Incrementing a boolean is invalid in C++17, and deprecated otherwise.) | |
8277 | ||
8278 | This warning is enabled by @option{-Wall}. | |
8279 | ||
d77de738 ML |
8280 | @opindex Wno-duplicated-branches |
8281 | @opindex Wduplicated-branches | |
ddf6fe37 | 8282 | @item -Wduplicated-branches |
d77de738 ML |
8283 | Warn when an if-else has identical branches. This warning detects cases like |
8284 | @smallexample | |
8285 | if (p != NULL) | |
8286 | return 0; | |
8287 | else | |
8288 | return 0; | |
8289 | @end smallexample | |
8290 | It doesn't warn when both branches contain just a null statement. This warning | |
8291 | also warn for conditional operators: | |
8292 | @smallexample | |
8293 | int i = x ? *p : *p; | |
8294 | @end smallexample | |
8295 | ||
d77de738 ML |
8296 | @opindex Wno-duplicated-cond |
8297 | @opindex Wduplicated-cond | |
ddf6fe37 | 8298 | @item -Wduplicated-cond |
d77de738 ML |
8299 | Warn about duplicated conditions in an if-else-if chain. For instance, |
8300 | warn for the following code: | |
8301 | @smallexample | |
8302 | if (p->q != NULL) @{ @dots{} @} | |
8303 | else if (p->q != NULL) @{ @dots{} @} | |
8304 | @end smallexample | |
8305 | ||
d77de738 ML |
8306 | @opindex Wno-frame-address |
8307 | @opindex Wframe-address | |
ddf6fe37 | 8308 | @item -Wframe-address |
d77de738 ML |
8309 | Warn when the @samp{__builtin_frame_address} or @samp{__builtin_return_address} |
8310 | is called with an argument greater than 0. Such calls may return indeterminate | |
8311 | values or crash the program. The warning is included in @option{-Wall}. | |
8312 | ||
d77de738 ML |
8313 | @opindex Wno-discarded-qualifiers |
8314 | @opindex Wdiscarded-qualifiers | |
ddf6fe37 | 8315 | @item -Wno-discarded-qualifiers @r{(C and Objective-C only)} |
d77de738 ML |
8316 | Do not warn if type qualifiers on pointers are being discarded. |
8317 | Typically, the compiler warns if a @code{const char *} variable is | |
8318 | passed to a function that takes a @code{char *} parameter. This option | |
8319 | can be used to suppress such a warning. | |
8320 | ||
d77de738 ML |
8321 | @opindex Wno-discarded-array-qualifiers |
8322 | @opindex Wdiscarded-array-qualifiers | |
ddf6fe37 | 8323 | @item -Wno-discarded-array-qualifiers @r{(C and Objective-C only)} |
d77de738 ML |
8324 | Do not warn if type qualifiers on arrays which are pointer targets |
8325 | are being discarded. Typically, the compiler warns if a | |
8326 | @code{const int (*)[]} variable is passed to a function that | |
8327 | takes a @code{int (*)[]} parameter. This option can be used to | |
8328 | suppress such a warning. | |
8329 | ||
d77de738 ML |
8330 | @opindex Wno-incompatible-pointer-types |
8331 | @opindex Wincompatible-pointer-types | |
ddf6fe37 | 8332 | @item -Wno-incompatible-pointer-types @r{(C and Objective-C only)} |
d77de738 ML |
8333 | Do not warn when there is a conversion between pointers that have incompatible |
8334 | types. This warning is for cases not covered by @option{-Wno-pointer-sign}, | |
8335 | which warns for pointer argument passing or assignment with different | |
8336 | signedness. | |
8337 | ||
d77de738 ML |
8338 | @opindex Wno-int-conversion |
8339 | @opindex Wint-conversion | |
ddf6fe37 | 8340 | @item -Wno-int-conversion @r{(C and Objective-C only)} |
d77de738 ML |
8341 | Do not warn about incompatible integer to pointer and pointer to integer |
8342 | conversions. This warning is about implicit conversions; for explicit | |
8343 | conversions the warnings @option{-Wno-int-to-pointer-cast} and | |
8344 | @option{-Wno-pointer-to-int-cast} may be used. | |
8345 | ||
d77de738 ML |
8346 | @opindex Wzero-length-bounds |
8347 | @opindex Wzero-length-bounds | |
ddf6fe37 | 8348 | @item -Wzero-length-bounds |
d77de738 ML |
8349 | Warn about accesses to elements of zero-length array members that might |
8350 | overlap other members of the same object. Declaring interior zero-length | |
8e9c65d3 | 8351 | arrays is discouraged because accesses to them are undefined. |
d77de738 ML |
8352 | @xref{Zero Length}. |
8353 | ||
8354 | For example, the first two stores in function @code{bad} are diagnosed | |
8355 | because the array elements overlap the subsequent members @code{b} and | |
8356 | @code{c}. The third store is diagnosed by @option{-Warray-bounds} | |
8357 | because it is beyond the bounds of the enclosing object. | |
8358 | ||
8359 | @smallexample | |
8360 | struct X @{ int a[0]; int b, c; @}; | |
8361 | struct X x; | |
8362 | ||
8363 | void bad (void) | |
8364 | @{ | |
8365 | x.a[0] = 0; // -Wzero-length-bounds | |
8366 | x.a[1] = 1; // -Wzero-length-bounds | |
8367 | x.a[2] = 2; // -Warray-bounds | |
8368 | @} | |
8369 | @end smallexample | |
8370 | ||
8371 | Option @option{-Wzero-length-bounds} is enabled by @option{-Warray-bounds}. | |
8372 | ||
d77de738 ML |
8373 | @opindex Wno-div-by-zero |
8374 | @opindex Wdiv-by-zero | |
ddf6fe37 | 8375 | @item -Wno-div-by-zero |
d77de738 ML |
8376 | Do not warn about compile-time integer division by zero. Floating-point |
8377 | division by zero is not warned about, as it can be a legitimate way of | |
8378 | obtaining infinities and NaNs. | |
8379 | ||
d77de738 ML |
8380 | @opindex Wsystem-headers |
8381 | @opindex Wno-system-headers | |
8382 | @cindex warnings from system headers | |
8383 | @cindex system headers, warnings from | |
f33d7a88 | 8384 | @item -Wsystem-headers |
d77de738 ML |
8385 | Print warning messages for constructs found in system header files. |
8386 | Warnings from system headers are normally suppressed, on the assumption | |
8387 | that they usually do not indicate real problems and would only make the | |
8388 | compiler output harder to read. Using this command-line option tells | |
8389 | GCC to emit warnings from system headers as if they occurred in user | |
8390 | code. However, note that using @option{-Wall} in conjunction with this | |
8391 | option does @emph{not} warn about unknown pragmas in system | |
8392 | headers---for that, @option{-Wunknown-pragmas} must also be used. | |
8393 | ||
d77de738 ML |
8394 | @opindex Wtautological-compare |
8395 | @opindex Wno-tautological-compare | |
ddf6fe37 | 8396 | @item -Wtautological-compare |
d77de738 ML |
8397 | Warn if a self-comparison always evaluates to true or false. This |
8398 | warning detects various mistakes such as: | |
8399 | @smallexample | |
8400 | int i = 1; | |
8401 | @dots{} | |
8402 | if (i > i) @{ @dots{} @} | |
8403 | @end smallexample | |
8404 | ||
8405 | This warning also warns about bitwise comparisons that always evaluate | |
8406 | to true or false, for instance: | |
8407 | @smallexample | |
8408 | if ((a & 16) == 10) @{ @dots{} @} | |
8409 | @end smallexample | |
8410 | will always be false. | |
8411 | ||
8412 | This warning is enabled by @option{-Wall}. | |
8413 | ||
d77de738 ML |
8414 | @opindex Wtrampolines |
8415 | @opindex Wno-trampolines | |
ddf6fe37 | 8416 | @item -Wtrampolines |
d77de738 ML |
8417 | Warn about trampolines generated for pointers to nested functions. |
8418 | A trampoline is a small piece of data or code that is created at run | |
8419 | time on the stack when the address of a nested function is taken, and is | |
8420 | used to call the nested function indirectly. For some targets, it is | |
8421 | made up of data only and thus requires no special treatment. But, for | |
8422 | most targets, it is made up of code and thus requires the stack to be | |
8423 | made executable in order for the program to work properly. | |
8424 | ||
d77de738 ML |
8425 | @opindex Wfloat-equal |
8426 | @opindex Wno-float-equal | |
ddf6fe37 | 8427 | @item -Wfloat-equal |
d77de738 ML |
8428 | Warn if floating-point values are used in equality comparisons. |
8429 | ||
8430 | The idea behind this is that sometimes it is convenient (for the | |
8431 | programmer) to consider floating-point values as approximations to | |
8432 | infinitely precise real numbers. If you are doing this, then you need | |
8433 | to compute (by analyzing the code, or in some other way) the maximum or | |
8434 | likely maximum error that the computation introduces, and allow for it | |
8435 | when performing comparisons (and when producing output, but that's a | |
8436 | different problem). In particular, instead of testing for equality, you | |
8437 | should check to see whether the two values have ranges that overlap; and | |
8438 | this is done with the relational operators, so equality comparisons are | |
8439 | probably mistaken. | |
8440 | ||
d77de738 ML |
8441 | @opindex Wtraditional |
8442 | @opindex Wno-traditional | |
ddf6fe37 | 8443 | @item -Wtraditional @r{(C and Objective-C only)} |
d77de738 ML |
8444 | Warn about certain constructs that behave differently in traditional and |
8445 | ISO C@. Also warn about ISO C constructs that have no traditional C | |
8446 | equivalent, and/or problematic constructs that should be avoided. | |
8447 | ||
8448 | @itemize @bullet | |
8449 | @item | |
8450 | Macro parameters that appear within string literals in the macro body. | |
8451 | In traditional C macro replacement takes place within string literals, | |
8452 | but in ISO C it does not. | |
8453 | ||
8454 | @item | |
8455 | In traditional C, some preprocessor directives did not exist. | |
8456 | Traditional preprocessors only considered a line to be a directive | |
8457 | if the @samp{#} appeared in column 1 on the line. Therefore | |
8458 | @option{-Wtraditional} warns about directives that traditional C | |
8459 | understands but ignores because the @samp{#} does not appear as the | |
8460 | first character on the line. It also suggests you hide directives like | |
8461 | @code{#pragma} not understood by traditional C by indenting them. Some | |
8462 | traditional implementations do not recognize @code{#elif}, so this option | |
8463 | suggests avoiding it altogether. | |
8464 | ||
8465 | @item | |
8466 | A function-like macro that appears without arguments. | |
8467 | ||
8468 | @item | |
8469 | The unary plus operator. | |
8470 | ||
8471 | @item | |
8472 | The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating-point | |
8473 | constant suffixes. (Traditional C does support the @samp{L} suffix on integer | |
8474 | constants.) Note, these suffixes appear in macros defined in the system | |
8475 | headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}. | |
8476 | Use of these macros in user code might normally lead to spurious | |
8477 | warnings, however GCC's integrated preprocessor has enough context to | |
8478 | avoid warning in these cases. | |
8479 | ||
8480 | @item | |
8481 | A function declared external in one block and then used after the end of | |
8482 | the block. | |
8483 | ||
8484 | @item | |
8485 | A @code{switch} statement has an operand of type @code{long}. | |
8486 | ||
8487 | @item | |
8488 | A non-@code{static} function declaration follows a @code{static} one. | |
8489 | This construct is not accepted by some traditional C compilers. | |
8490 | ||
8491 | @item | |
8492 | The ISO type of an integer constant has a different width or | |
8493 | signedness from its traditional type. This warning is only issued if | |
8494 | the base of the constant is ten. I.e.@: hexadecimal or octal values, which | |
8495 | typically represent bit patterns, are not warned about. | |
8496 | ||
8497 | @item | |
8498 | Usage of ISO string concatenation is detected. | |
8499 | ||
8500 | @item | |
8501 | Initialization of automatic aggregates. | |
8502 | ||
8503 | @item | |
8504 | Identifier conflicts with labels. Traditional C lacks a separate | |
8505 | namespace for labels. | |
8506 | ||
8507 | @item | |
8508 | Initialization of unions. If the initializer is zero, the warning is | |
8509 | omitted. This is done under the assumption that the zero initializer in | |
8510 | user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing | |
8511 | initializer warnings and relies on default initialization to zero in the | |
8512 | traditional C case. | |
8513 | ||
8514 | @item | |
8515 | Conversions by prototypes between fixed/floating-point values and vice | |
8516 | versa. The absence of these prototypes when compiling with traditional | |
8517 | C causes serious problems. This is a subset of the possible | |
8518 | conversion warnings; for the full set use @option{-Wtraditional-conversion}. | |
8519 | ||
8520 | @item | |
8521 | Use of ISO C style function definitions. This warning intentionally is | |
8522 | @emph{not} issued for prototype declarations or variadic functions | |
8523 | because these ISO C features appear in your code when using | |
8524 | libiberty's traditional C compatibility macros, @code{PARAMS} and | |
8525 | @code{VPARAMS}. This warning is also bypassed for nested functions | |
8526 | because that feature is already a GCC extension and thus not relevant to | |
8527 | traditional C compatibility. | |
8528 | @end itemize | |
8529 | ||
d77de738 ML |
8530 | @opindex Wtraditional-conversion |
8531 | @opindex Wno-traditional-conversion | |
ddf6fe37 | 8532 | @item -Wtraditional-conversion @r{(C and Objective-C only)} |
d77de738 ML |
8533 | Warn if a prototype causes a type conversion that is different from what |
8534 | would happen to the same argument in the absence of a prototype. This | |
8535 | includes conversions of fixed point to floating and vice versa, and | |
8536 | conversions changing the width or signedness of a fixed-point argument | |
8537 | except when the same as the default promotion. | |
8538 | ||
d77de738 ML |
8539 | @opindex Wdeclaration-after-statement |
8540 | @opindex Wno-declaration-after-statement | |
ddf6fe37 | 8541 | @item -Wdeclaration-after-statement @r{(C and Objective-C only)} |
d77de738 ML |
8542 | Warn when a declaration is found after a statement in a block. This |
8543 | construct, known from C++, was introduced with ISO C99 and is by default | |
8544 | allowed in GCC@. It is not supported by ISO C90. @xref{Mixed Labels and Declarations}. | |
8545 | ||
d77de738 ML |
8546 | @opindex Wshadow |
8547 | @opindex Wno-shadow | |
ddf6fe37 | 8548 | @item -Wshadow |
d77de738 ML |
8549 | Warn whenever a local variable or type declaration shadows another |
8550 | variable, parameter, type, class member (in C++), or instance variable | |
8551 | (in Objective-C) or whenever a built-in function is shadowed. Note | |
8552 | that in C++, the compiler warns if a local variable shadows an | |
8553 | explicit typedef, but not if it shadows a struct/class/enum. | |
8554 | If this warning is enabled, it includes also all instances of | |
8555 | local shadowing. This means that @option{-Wno-shadow=local} | |
8556 | and @option{-Wno-shadow=compatible-local} are ignored when | |
8557 | @option{-Wshadow} is used. | |
8558 | Same as @option{-Wshadow=global}. | |
8559 | ||
d77de738 ML |
8560 | @opindex Wno-shadow-ivar |
8561 | @opindex Wshadow-ivar | |
ddf6fe37 | 8562 | @item -Wno-shadow-ivar @r{(Objective-C only)} |
d77de738 ML |
8563 | Do not warn whenever a local variable shadows an instance variable in an |
8564 | Objective-C method. | |
8565 | ||
d77de738 | 8566 | @opindex Wshadow=global |
ddf6fe37 | 8567 | @item -Wshadow=global |
d77de738 ML |
8568 | Warn for any shadowing. |
8569 | Same as @option{-Wshadow}. | |
8570 | ||
d77de738 | 8571 | @opindex Wshadow=local |
ddf6fe37 | 8572 | @item -Wshadow=local |
d77de738 ML |
8573 | Warn when a local variable shadows another local variable or parameter. |
8574 | ||
d77de738 | 8575 | @opindex Wshadow=compatible-local |
ddf6fe37 | 8576 | @item -Wshadow=compatible-local |
d77de738 ML |
8577 | Warn when a local variable shadows another local variable or parameter |
8578 | whose type is compatible with that of the shadowing variable. In C++, | |
8579 | type compatibility here means the type of the shadowing variable can be | |
8580 | converted to that of the shadowed variable. The creation of this flag | |
8581 | (in addition to @option{-Wshadow=local}) is based on the idea that when | |
8582 | a local variable shadows another one of incompatible type, it is most | |
8583 | likely intentional, not a bug or typo, as shown in the following example: | |
8584 | ||
8585 | @smallexample | |
8586 | @group | |
8587 | for (SomeIterator i = SomeObj.begin(); i != SomeObj.end(); ++i) | |
8588 | @{ | |
8589 | for (int i = 0; i < N; ++i) | |
8590 | @{ | |
8591 | ... | |
8592 | @} | |
8593 | ... | |
8594 | @} | |
8595 | @end group | |
8596 | @end smallexample | |
8597 | ||
8598 | Since the two variable @code{i} in the example above have incompatible types, | |
8599 | enabling only @option{-Wshadow=compatible-local} does not emit a warning. | |
8600 | Because their types are incompatible, if a programmer accidentally uses one | |
8601 | in place of the other, type checking is expected to catch that and emit an | |
8602 | error or warning. Use of this flag instead of @option{-Wshadow=local} can | |
8603 | possibly reduce the number of warnings triggered by intentional shadowing. | |
8604 | Note that this also means that shadowing @code{const char *i} by | |
8605 | @code{char *i} does not emit a warning. | |
8606 | ||
8607 | This warning is also enabled by @option{-Wshadow=local}. | |
8608 | ||
d77de738 ML |
8609 | @opindex Wlarger-than= |
8610 | @opindex Wlarger-than-@var{byte-size} | |
ddf6fe37 | 8611 | @item -Wlarger-than=@var{byte-size} |
d77de738 ML |
8612 | Warn whenever an object is defined whose size exceeds @var{byte-size}. |
8613 | @option{-Wlarger-than=}@samp{PTRDIFF_MAX} is enabled by default. | |
8614 | Warnings controlled by the option can be disabled either by specifying | |
8615 | @var{byte-size} of @samp{SIZE_MAX} or more or by @option{-Wno-larger-than}. | |
8616 | ||
8617 | Also warn for calls to bounded functions such as @code{memchr} or | |
8618 | @code{strnlen} that specify a bound greater than the largest possible | |
8619 | object, which is @samp{PTRDIFF_MAX} bytes by default. These warnings | |
8620 | can only be disabled by @option{-Wno-larger-than}. | |
8621 | ||
d77de738 | 8622 | @opindex Wno-larger-than |
ddf6fe37 | 8623 | @item -Wno-larger-than |
d77de738 ML |
8624 | Disable @option{-Wlarger-than=} warnings. The option is equivalent |
8625 | to @option{-Wlarger-than=}@samp{SIZE_MAX} or larger. | |
8626 | ||
d77de738 ML |
8627 | @opindex Wframe-larger-than= |
8628 | @opindex Wno-frame-larger-than | |
ddf6fe37 | 8629 | @item -Wframe-larger-than=@var{byte-size} |
d77de738 ML |
8630 | Warn if the size of a function frame exceeds @var{byte-size}. |
8631 | The computation done to determine the stack frame size is approximate | |
8632 | and not conservative. | |
8633 | The actual requirements may be somewhat greater than @var{byte-size} | |
8634 | even if you do not get a warning. In addition, any space allocated | |
8635 | via @code{alloca}, variable-length arrays, or related constructs | |
8636 | is not included by the compiler when determining | |
8637 | whether or not to issue a warning. | |
8638 | @option{-Wframe-larger-than=}@samp{PTRDIFF_MAX} is enabled by default. | |
8639 | Warnings controlled by the option can be disabled either by specifying | |
8640 | @var{byte-size} of @samp{SIZE_MAX} or more or by | |
8641 | @option{-Wno-frame-larger-than}. | |
8642 | ||
d77de738 | 8643 | @opindex Wno-frame-larger-than |
ddf6fe37 | 8644 | @item -Wno-frame-larger-than |
d77de738 ML |
8645 | Disable @option{-Wframe-larger-than=} warnings. The option is equivalent |
8646 | to @option{-Wframe-larger-than=}@samp{SIZE_MAX} or larger. | |
8647 | ||
d77de738 ML |
8648 | @opindex Wfree-nonheap-object |
8649 | @opindex Wno-free-nonheap-object | |
ddf6fe37 | 8650 | @item -Wfree-nonheap-object |
d77de738 ML |
8651 | Warn when attempting to deallocate an object that was either not allocated |
8652 | on the heap, or by using a pointer that was not returned from a prior call | |
8653 | to the corresponding allocation function. For example, because the call | |
8654 | to @code{stpcpy} returns a pointer to the terminating nul character and | |
8655 | not to the beginning of the object, the call to @code{free} below is | |
8656 | diagnosed. | |
8657 | ||
8658 | @smallexample | |
8659 | void f (char *p) | |
8660 | @{ | |
8661 | p = stpcpy (p, "abc"); | |
8662 | // ... | |
8663 | free (p); // warning | |
8664 | @} | |
8665 | @end smallexample | |
8666 | ||
8667 | @option{-Wfree-nonheap-object} is included in @option{-Wall}. | |
8668 | ||
d77de738 ML |
8669 | @opindex Wstack-usage |
8670 | @opindex Wno-stack-usage | |
ddf6fe37 | 8671 | @item -Wstack-usage=@var{byte-size} |
d77de738 ML |
8672 | Warn if the stack usage of a function might exceed @var{byte-size}. |
8673 | The computation done to determine the stack usage is conservative. | |
8674 | Any space allocated via @code{alloca}, variable-length arrays, or related | |
8675 | constructs is included by the compiler when determining whether or not to | |
8676 | issue a warning. | |
8677 | ||
8678 | The message is in keeping with the output of @option{-fstack-usage}. | |
8679 | ||
8680 | @itemize | |
8681 | @item | |
8682 | If the stack usage is fully static but exceeds the specified amount, it's: | |
8683 | ||
8684 | @smallexample | |
8685 | warning: stack usage is 1120 bytes | |
8686 | @end smallexample | |
8687 | @item | |
8688 | If the stack usage is (partly) dynamic but bounded, it's: | |
8689 | ||
8690 | @smallexample | |
8691 | warning: stack usage might be 1648 bytes | |
8692 | @end smallexample | |
8693 | @item | |
8694 | If the stack usage is (partly) dynamic and not bounded, it's: | |
8695 | ||
8696 | @smallexample | |
8697 | warning: stack usage might be unbounded | |
8698 | @end smallexample | |
8699 | @end itemize | |
8700 | ||
8701 | @option{-Wstack-usage=}@samp{PTRDIFF_MAX} is enabled by default. | |
8702 | Warnings controlled by the option can be disabled either by specifying | |
8703 | @var{byte-size} of @samp{SIZE_MAX} or more or by | |
8704 | @option{-Wno-stack-usage}. | |
8705 | ||
d77de738 | 8706 | @opindex Wno-stack-usage |
ddf6fe37 | 8707 | @item -Wno-stack-usage |
d77de738 ML |
8708 | Disable @option{-Wstack-usage=} warnings. The option is equivalent |
8709 | to @option{-Wstack-usage=}@samp{SIZE_MAX} or larger. | |
8710 | ||
d77de738 ML |
8711 | @opindex Wunsafe-loop-optimizations |
8712 | @opindex Wno-unsafe-loop-optimizations | |
ddf6fe37 | 8713 | @item -Wunsafe-loop-optimizations |
d77de738 ML |
8714 | Warn if the loop cannot be optimized because the compiler cannot |
8715 | assume anything on the bounds of the loop indices. With | |
8716 | @option{-funsafe-loop-optimizations} warn if the compiler makes | |
8717 | such assumptions. | |
8718 | ||
d77de738 ML |
8719 | @opindex Wno-pedantic-ms-format |
8720 | @opindex Wpedantic-ms-format | |
ddf6fe37 | 8721 | @item -Wno-pedantic-ms-format @r{(MinGW targets only)} |
d77de738 ML |
8722 | When used in combination with @option{-Wformat} |
8723 | and @option{-pedantic} without GNU extensions, this option | |
8724 | disables the warnings about non-ISO @code{printf} / @code{scanf} format | |
8725 | width specifiers @code{I32}, @code{I64}, and @code{I} used on Windows targets, | |
8726 | which depend on the MS runtime. | |
8727 | ||
d77de738 ML |
8728 | @opindex Wpointer-arith |
8729 | @opindex Wno-pointer-arith | |
ddf6fe37 | 8730 | @item -Wpointer-arith |
d77de738 ML |
8731 | Warn about anything that depends on the ``size of'' a function type or |
8732 | of @code{void}. GNU C assigns these types a size of 1, for | |
8733 | convenience in calculations with @code{void *} pointers and pointers | |
8734 | to functions. In C++, warn also when an arithmetic operation involves | |
8735 | @code{NULL}. This warning is also enabled by @option{-Wpedantic}. | |
8736 | ||
d77de738 ML |
8737 | @opindex Wpointer-compare |
8738 | @opindex Wno-pointer-compare | |
ddf6fe37 | 8739 | @item -Wno-pointer-compare |
d77de738 ML |
8740 | Do not warn if a pointer is compared with a zero character constant. |
8741 | This usually | |
8742 | means that the pointer was meant to be dereferenced. For example: | |
8743 | ||
8744 | @smallexample | |
8745 | const char *p = foo (); | |
8746 | if (p == '\0') | |
8747 | return 42; | |
8748 | @end smallexample | |
8749 | ||
8750 | Note that the code above is invalid in C++11. | |
8751 | ||
8752 | This warning is enabled by default. | |
8753 | ||
d77de738 ML |
8754 | @opindex Wtsan |
8755 | @opindex Wno-tsan | |
ddf6fe37 | 8756 | @item -Wtsan |
d77de738 ML |
8757 | Warn about unsupported features in ThreadSanitizer. |
8758 | ||
8759 | ThreadSanitizer does not support @code{std::atomic_thread_fence} and | |
8760 | can report false positives. | |
8761 | ||
8762 | This warning is enabled by default. | |
8763 | ||
d77de738 ML |
8764 | @opindex Wtype-limits |
8765 | @opindex Wno-type-limits | |
ddf6fe37 | 8766 | @item -Wtype-limits |
d77de738 ML |
8767 | Warn if a comparison is always true or always false due to the limited |
8768 | range of the data type, but do not warn for constant expressions. For | |
8769 | example, warn if an unsigned variable is compared against zero with | |
8770 | @code{<} or @code{>=}. This warning is also enabled by | |
8771 | @option{-Wextra}. | |
8772 | ||
d77de738 ML |
8773 | @opindex Wabsolute-value |
8774 | @opindex Wno-absolute-value | |
ddf6fe37 | 8775 | @item -Wabsolute-value @r{(C and Objective-C only)} |
d77de738 ML |
8776 | Warn for calls to standard functions that compute the absolute value |
8777 | of an argument when a more appropriate standard function is available. | |
8778 | For example, calling @code{abs(3.14)} triggers the warning because the | |
8779 | appropriate function to call to compute the absolute value of a double | |
8780 | argument is @code{fabs}. The option also triggers warnings when the | |
8781 | argument in a call to such a function has an unsigned type. This | |
8782 | warning can be suppressed with an explicit type cast and it is also | |
8783 | enabled by @option{-Wextra}. | |
8784 | ||
8785 | @include cppwarnopts.texi | |
8786 | ||
d77de738 ML |
8787 | @opindex Wbad-function-cast |
8788 | @opindex Wno-bad-function-cast | |
ddf6fe37 | 8789 | @item -Wbad-function-cast @r{(C and Objective-C only)} |
d77de738 ML |
8790 | Warn when a function call is cast to a non-matching type. |
8791 | For example, warn if a call to a function returning an integer type | |
8792 | is cast to a pointer type. | |
8793 | ||
d77de738 ML |
8794 | @opindex Wc90-c99-compat |
8795 | @opindex Wno-c90-c99-compat | |
ddf6fe37 | 8796 | @item -Wc90-c99-compat @r{(C and Objective-C only)} |
d77de738 ML |
8797 | Warn about features not present in ISO C90, but present in ISO C99. |
8798 | For instance, warn about use of variable length arrays, @code{long long} | |
8799 | type, @code{bool} type, compound literals, designated initializers, and so | |
8800 | on. This option is independent of the standards mode. Warnings are disabled | |
8801 | in the expression that follows @code{__extension__}. | |
8802 | ||
d77de738 ML |
8803 | @opindex Wc99-c11-compat |
8804 | @opindex Wno-c99-c11-compat | |
ddf6fe37 | 8805 | @item -Wc99-c11-compat @r{(C and Objective-C only)} |
d77de738 ML |
8806 | Warn about features not present in ISO C99, but present in ISO C11. |
8807 | For instance, warn about use of anonymous structures and unions, | |
8808 | @code{_Atomic} type qualifier, @code{_Thread_local} storage-class specifier, | |
8809 | @code{_Alignas} specifier, @code{Alignof} operator, @code{_Generic} keyword, | |
8810 | and so on. This option is independent of the standards mode. Warnings are | |
8811 | disabled in the expression that follows @code{__extension__}. | |
8812 | ||
d77de738 ML |
8813 | @opindex Wc11-c2x-compat |
8814 | @opindex Wno-c11-c2x-compat | |
ddf6fe37 | 8815 | @item -Wc11-c2x-compat @r{(C and Objective-C only)} |
d77de738 ML |
8816 | Warn about features not present in ISO C11, but present in ISO C2X. |
8817 | For instance, warn about omitting the string in @code{_Static_assert}, | |
8818 | use of @samp{[[]]} syntax for attributes, use of decimal | |
8819 | floating-point types, and so on. This option is independent of the | |
8820 | standards mode. Warnings are disabled in the expression that follows | |
8821 | @code{__extension__}. | |
8822 | ||
d77de738 ML |
8823 | @opindex Wc++-compat |
8824 | @opindex Wno-c++-compat | |
ddf6fe37 | 8825 | @item -Wc++-compat @r{(C and Objective-C only)} |
d77de738 ML |
8826 | Warn about ISO C constructs that are outside of the common subset of |
8827 | ISO C and ISO C++, e.g.@: request for implicit conversion from | |
8828 | @code{void *} to a pointer to non-@code{void} type. | |
8829 | ||
d77de738 ML |
8830 | @opindex Wc++11-compat |
8831 | @opindex Wno-c++11-compat | |
ddf6fe37 | 8832 | @item -Wc++11-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
8833 | Warn about C++ constructs whose meaning differs between ISO C++ 1998 |
8834 | and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that are keywords | |
8835 | in ISO C++ 2011. This warning turns on @option{-Wnarrowing} and is | |
8836 | enabled by @option{-Wall}. | |
8837 | ||
d77de738 ML |
8838 | @opindex Wc++14-compat |
8839 | @opindex Wno-c++14-compat | |
ddf6fe37 | 8840 | @item -Wc++14-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
8841 | Warn about C++ constructs whose meaning differs between ISO C++ 2011 |
8842 | and ISO C++ 2014. This warning is enabled by @option{-Wall}. | |
8843 | ||
d77de738 ML |
8844 | @opindex Wc++17-compat |
8845 | @opindex Wno-c++17-compat | |
ddf6fe37 | 8846 | @item -Wc++17-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
8847 | Warn about C++ constructs whose meaning differs between ISO C++ 2014 |
8848 | and ISO C++ 2017. This warning is enabled by @option{-Wall}. | |
8849 | ||
d77de738 ML |
8850 | @opindex Wc++20-compat |
8851 | @opindex Wno-c++20-compat | |
ddf6fe37 | 8852 | @item -Wc++20-compat @r{(C++ and Objective-C++ only)} |
d77de738 ML |
8853 | Warn about C++ constructs whose meaning differs between ISO C++ 2017 |
8854 | and ISO C++ 2020. This warning is enabled by @option{-Wall}. | |
8855 | ||
d77de738 ML |
8856 | @opindex Wc++11-extensions |
8857 | @opindex Wno-c++11-extensions | |
ddf6fe37 | 8858 | @item -Wno-c++11-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
8859 | Do not warn about C++11 constructs in code being compiled using |
8860 | an older C++ standard. Even without this option, some C++11 constructs | |
8861 | will only be diagnosed if @option{-Wpedantic} is used. | |
8862 | ||
d77de738 ML |
8863 | @opindex Wc++14-extensions |
8864 | @opindex Wno-c++14-extensions | |
ddf6fe37 | 8865 | @item -Wno-c++14-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
8866 | Do not warn about C++14 constructs in code being compiled using |
8867 | an older C++ standard. Even without this option, some C++14 constructs | |
8868 | will only be diagnosed if @option{-Wpedantic} is used. | |
8869 | ||
d77de738 ML |
8870 | @opindex Wc++17-extensions |
8871 | @opindex Wno-c++17-extensions | |
ddf6fe37 | 8872 | @item -Wno-c++17-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
8873 | Do not warn about C++17 constructs in code being compiled using |
8874 | an older C++ standard. Even without this option, some C++17 constructs | |
8875 | will only be diagnosed if @option{-Wpedantic} is used. | |
8876 | ||
d77de738 ML |
8877 | @opindex Wc++20-extensions |
8878 | @opindex Wno-c++20-extensions | |
ddf6fe37 | 8879 | @item -Wno-c++20-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
8880 | Do not warn about C++20 constructs in code being compiled using |
8881 | an older C++ standard. Even without this option, some C++20 constructs | |
8882 | will only be diagnosed if @option{-Wpedantic} is used. | |
8883 | ||
d77de738 ML |
8884 | @opindex Wc++23-extensions |
8885 | @opindex Wno-c++23-extensions | |
ddf6fe37 | 8886 | @item -Wno-c++23-extensions @r{(C++ and Objective-C++ only)} |
d77de738 ML |
8887 | Do not warn about C++23 constructs in code being compiled using |
8888 | an older C++ standard. Even without this option, some C++23 constructs | |
8889 | will only be diagnosed if @option{-Wpedantic} is used. | |
8890 | ||
d77de738 ML |
8891 | @opindex Wcast-qual |
8892 | @opindex Wno-cast-qual | |
ddf6fe37 | 8893 | @item -Wcast-qual |
d77de738 ML |
8894 | Warn whenever a pointer is cast so as to remove a type qualifier from |
8895 | the target type. For example, warn if a @code{const char *} is cast | |
8896 | to an ordinary @code{char *}. | |
8897 | ||
8898 | Also warn when making a cast that introduces a type qualifier in an | |
8899 | unsafe way. For example, casting @code{char **} to @code{const char **} | |
8900 | is unsafe, as in this example: | |
8901 | ||
8902 | @smallexample | |
8903 | /* p is char ** value. */ | |
8904 | const char **q = (const char **) p; | |
8905 | /* Assignment of readonly string to const char * is OK. */ | |
8906 | *q = "string"; | |
8907 | /* Now char** pointer points to read-only memory. */ | |
8908 | **p = 'b'; | |
8909 | @end smallexample | |
8910 | ||
d77de738 ML |
8911 | @opindex Wcast-align |
8912 | @opindex Wno-cast-align | |
ddf6fe37 | 8913 | @item -Wcast-align |
d77de738 ML |
8914 | Warn whenever a pointer is cast such that the required alignment of the |
8915 | target is increased. For example, warn if a @code{char *} is cast to | |
8916 | an @code{int *} on machines where integers can only be accessed at | |
8917 | two- or four-byte boundaries. | |
8918 | ||
d77de738 | 8919 | @opindex Wcast-align=strict |
ddf6fe37 | 8920 | @item -Wcast-align=strict |
d77de738 ML |
8921 | Warn whenever a pointer is cast such that the required alignment of the |
8922 | target is increased. For example, warn if a @code{char *} is cast to | |
8923 | an @code{int *} regardless of the target machine. | |
8924 | ||
d77de738 ML |
8925 | @opindex Wcast-function-type |
8926 | @opindex Wno-cast-function-type | |
ddf6fe37 | 8927 | @item -Wcast-function-type |
d77de738 ML |
8928 | Warn when a function pointer is cast to an incompatible function pointer. |
8929 | In a cast involving function types with a variable argument list only | |
8930 | the types of initial arguments that are provided are considered. | |
8931 | Any parameter of pointer-type matches any other pointer-type. Any benign | |
8932 | differences in integral types are ignored, like @code{int} vs.@: @code{long} | |
8933 | on ILP32 targets. Likewise type qualifiers are ignored. The function | |
8934 | type @code{void (*) (void)} is special and matches everything, which can | |
8935 | be used to suppress this warning. | |
8936 | In a cast involving pointer to member types this warning warns whenever | |
8937 | the type cast is changing the pointer to member type. | |
8938 | This warning is enabled by @option{-Wextra}. | |
8939 | ||
d77de738 ML |
8940 | @opindex Wwrite-strings |
8941 | @opindex Wno-write-strings | |
ddf6fe37 | 8942 | @item -Wwrite-strings |
d77de738 ML |
8943 | When compiling C, give string constants the type @code{const |
8944 | char[@var{length}]} so that copying the address of one into a | |
8945 | non-@code{const} @code{char *} pointer produces a warning. These | |
8946 | warnings help you find at compile time code that can try to write | |
8947 | into a string constant, but only if you have been very careful about | |
8948 | using @code{const} in declarations and prototypes. Otherwise, it is | |
8949 | just a nuisance. This is why we did not make @option{-Wall} request | |
8950 | these warnings. | |
8951 | ||
8952 | When compiling C++, warn about the deprecated conversion from string | |
8953 | literals to @code{char *}. This warning is enabled by default for C++ | |
8954 | programs. | |
8955 | ||
d77de738 ML |
8956 | @opindex Wclobbered |
8957 | @opindex Wno-clobbered | |
f33d7a88 | 8958 | @item -Wclobbered |
d77de738 ML |
8959 | Warn for variables that might be changed by @code{longjmp} or |
8960 | @code{vfork}. This warning is also enabled by @option{-Wextra}. | |
8961 | ||
320dc51c TS |
8962 | @opindex Wcomplain-wrong-lang |
8963 | @opindex Wno-complain-wrong-lang | |
f33d7a88 | 8964 | @item -Wno-complain-wrong-lang |
320dc51c TS |
8965 | By default, language front ends complain when a command-line option is |
8966 | valid, but not applicable to that front end. | |
8967 | This may be disabled with @option{-Wno-complain-wrong-lang}, | |
8968 | which is mostly useful when invoking a single compiler driver for | |
8969 | multiple source files written in different languages, for example: | |
8970 | ||
8971 | @smallexample | |
8972 | $ g++ -fno-rtti a.cc b.f90 | |
8973 | @end smallexample | |
8974 | ||
8975 | The driver @file{g++} invokes the C++ front end to compile @file{a.cc} | |
8976 | and the Fortran front end to compile @file{b.f90}. | |
8977 | The latter front end diagnoses | |
8978 | @samp{f951: Warning: command-line option '-fno-rtti' is valid for C++/D/ObjC++ but not for Fortran}, | |
8979 | which may be disabled with @option{-Wno-complain-wrong-lang}. | |
8980 | ||
d77de738 ML |
8981 | @opindex Wconversion |
8982 | @opindex Wno-conversion | |
f33d7a88 | 8983 | @item -Wconversion |
d77de738 ML |
8984 | Warn for implicit conversions that may alter a value. This includes |
8985 | conversions between real and integer, like @code{abs (x)} when | |
8986 | @code{x} is @code{double}; conversions between signed and unsigned, | |
8987 | like @code{unsigned ui = -1}; and conversions to smaller types, like | |
8988 | @code{sqrtf (M_PI)}. Do not warn for explicit casts like @code{abs | |
8989 | ((int) x)} and @code{ui = (unsigned) -1}, or if the value is not | |
8990 | changed by the conversion like in @code{abs (2.0)}. Warnings about | |
8991 | conversions between signed and unsigned integers can be disabled by | |
8992 | using @option{-Wno-sign-conversion}. | |
8993 | ||
8994 | For C++, also warn for confusing overload resolution for user-defined | |
8995 | conversions; and conversions that never use a type conversion | |
8996 | operator: conversions to @code{void}, the same type, a base class or a | |
8997 | reference to them. Warnings about conversions between signed and | |
8998 | unsigned integers are disabled by default in C++ unless | |
8999 | @option{-Wsign-conversion} is explicitly enabled. | |
9000 | ||
9001 | Warnings about conversion from arithmetic on a small type back to that | |
9002 | type are only given with @option{-Warith-conversion}. | |
9003 | ||
d77de738 ML |
9004 | @opindex Wdangling-else |
9005 | @opindex Wno-dangling-else | |
ddf6fe37 | 9006 | @item -Wdangling-else |
d77de738 ML |
9007 | Warn about constructions where there may be confusion to which |
9008 | @code{if} statement an @code{else} branch belongs. Here is an example of | |
9009 | such a case: | |
9010 | ||
9011 | @smallexample | |
9012 | @group | |
9013 | @{ | |
9014 | if (a) | |
9015 | if (b) | |
9016 | foo (); | |
9017 | else | |
9018 | bar (); | |
9019 | @} | |
9020 | @end group | |
9021 | @end smallexample | |
9022 | ||
9023 | In C/C++, every @code{else} branch belongs to the innermost possible | |
9024 | @code{if} statement, which in this example is @code{if (b)}. This is | |
9025 | often not what the programmer expected, as illustrated in the above | |
9026 | example by indentation the programmer chose. When there is the | |
9027 | potential for this confusion, GCC issues a warning when this flag | |
9028 | is specified. To eliminate the warning, add explicit braces around | |
9029 | the innermost @code{if} statement so there is no way the @code{else} | |
9030 | can belong to the enclosing @code{if}. The resulting code | |
9031 | looks like this: | |
9032 | ||
9033 | @smallexample | |
9034 | @group | |
9035 | @{ | |
9036 | if (a) | |
9037 | @{ | |
9038 | if (b) | |
9039 | foo (); | |
9040 | else | |
9041 | bar (); | |
9042 | @} | |
9043 | @} | |
9044 | @end group | |
9045 | @end smallexample | |
9046 | ||
9047 | This warning is enabled by @option{-Wparentheses}. | |
9048 | ||
d77de738 ML |
9049 | @opindex Wdangling-pointer |
9050 | @opindex Wno-dangling-pointer | |
ddf6fe37 AA |
9051 | @item -Wdangling-pointer |
9052 | @itemx -Wdangling-pointer=@var{n} | |
d77de738 ML |
9053 | Warn about uses of pointers (or C++ references) to objects with automatic |
9054 | storage duration after their lifetime has ended. This includes local | |
9055 | variables declared in nested blocks, compound literals and other unnamed | |
9056 | temporary objects. In addition, warn about storing the address of such | |
9057 | objects in escaped pointers. The warning is enabled at all optimization | |
9058 | levels but may yield different results with optimization than without. | |
9059 | ||
9060 | @table @gcctabopt | |
9061 | @item -Wdangling-pointer=1 | |
9062 | At level 1 the warning diagnoses only unconditional uses of dangling pointers. | |
9063 | For example | |
9064 | @smallexample | |
9065 | int f (int c1, int c2, x) | |
9066 | @{ | |
9067 | char *p = strchr ((char[])@{ c1, c2 @}, c3); | |
4ace81b6 SL |
9068 | // warning: dangling pointer to a compound literal |
9069 | return p ? *p : 'x'; | |
d77de738 ML |
9070 | @} |
9071 | @end smallexample | |
9072 | In the following function the store of the address of the local variable | |
9073 | @code{x} in the escaped pointer @code{*p} also triggers the warning. | |
9074 | @smallexample | |
9075 | void g (int **p) | |
9076 | @{ | |
9077 | int x = 7; | |
4ace81b6 SL |
9078 | // warning: storing the address of a local variable in *p |
9079 | *p = &x; | |
d77de738 ML |
9080 | @} |
9081 | @end smallexample | |
9082 | ||
9083 | @item -Wdangling-pointer=2 | |
9084 | At level 2, in addition to unconditional uses the warning also diagnoses | |
9085 | conditional uses of dangling pointers. | |
9086 | ||
9087 | For example, because the array @var{a} in the following function is out of | |
9088 | scope when the pointer @var{s} that was set to point is used, the warning | |
9089 | triggers at this level. | |
9090 | ||
9091 | @smallexample | |
9092 | void f (char *s) | |
9093 | @{ | |
9094 | if (!s) | |
9095 | @{ | |
9096 | char a[12] = "tmpname"; | |
9097 | s = a; | |
9098 | @} | |
4ace81b6 SL |
9099 | // warning: dangling pointer to a may be used |
9100 | strcat (s, ".tmp"); | |
d77de738 ML |
9101 | ... |
9102 | @} | |
9103 | @end smallexample | |
9104 | @end table | |
9105 | ||
9106 | @option{-Wdangling-pointer=2} is included in @option{-Wall}. | |
9107 | ||
d77de738 ML |
9108 | @opindex Wdate-time |
9109 | @opindex Wno-date-time | |
ddf6fe37 | 9110 | @item -Wdate-time |
d77de738 ML |
9111 | Warn when macros @code{__TIME__}, @code{__DATE__} or @code{__TIMESTAMP__} |
9112 | are encountered as they might prevent bit-wise-identical reproducible | |
9113 | compilations. | |
9114 | ||
d77de738 ML |
9115 | @opindex Wempty-body |
9116 | @opindex Wno-empty-body | |
ddf6fe37 | 9117 | @item -Wempty-body |
d77de738 ML |
9118 | Warn if an empty body occurs in an @code{if}, @code{else} or @code{do |
9119 | while} statement. This warning is also enabled by @option{-Wextra}. | |
9120 | ||
d77de738 ML |
9121 | @opindex Wendif-labels |
9122 | @opindex Wno-endif-labels | |
ddf6fe37 | 9123 | @item -Wno-endif-labels |
d77de738 ML |
9124 | Do not warn about stray tokens after @code{#else} and @code{#endif}. |
9125 | ||
d77de738 ML |
9126 | @opindex Wenum-compare |
9127 | @opindex Wno-enum-compare | |
ddf6fe37 | 9128 | @item -Wenum-compare |
d77de738 ML |
9129 | Warn about a comparison between values of different enumerated types. |
9130 | In C++ enumerated type mismatches in conditional expressions are also | |
9131 | diagnosed and the warning is enabled by default. In C this warning is | |
9132 | enabled by @option{-Wall}. | |
9133 | ||
d77de738 ML |
9134 | @opindex Wenum-conversion |
9135 | @opindex Wno-enum-conversion | |
ddf6fe37 | 9136 | @item -Wenum-conversion |
d77de738 ML |
9137 | Warn when a value of enumerated type is implicitly converted to a |
9138 | different enumerated type. This warning is enabled by @option{-Wextra} | |
9139 | in C@. | |
9140 | ||
d77de738 ML |
9141 | @opindex Wenum-int-mismatch |
9142 | @opindex Wno-enum-int-mismatch | |
ddf6fe37 | 9143 | @item -Wenum-int-mismatch @r{(C and Objective-C only)} |
d77de738 ML |
9144 | Warn about mismatches between an enumerated type and an integer type in |
9145 | declarations. For example: | |
9146 | ||
9147 | @smallexample | |
9148 | enum E @{ l = -1, z = 0, g = 1 @}; | |
9149 | int foo(void); | |
9150 | enum E foo(void); | |
9151 | @end smallexample | |
9152 | ||
9153 | In C, an enumerated type is compatible with @code{char}, a signed | |
9154 | integer type, or an unsigned integer type. However, since the choice | |
9155 | of the underlying type of an enumerated type is implementation-defined, | |
9156 | such mismatches may cause portability issues. In C++, such mismatches | |
9157 | are an error. In C, this warning is enabled by @option{-Wall} and | |
9158 | @option{-Wc++-compat}. | |
9159 | ||
d77de738 ML |
9160 | @opindex Wjump-misses-init |
9161 | @opindex Wno-jump-misses-init | |
ddf6fe37 | 9162 | @item -Wjump-misses-init @r{(C, Objective-C only)} |
d77de738 ML |
9163 | Warn if a @code{goto} statement or a @code{switch} statement jumps |
9164 | forward across the initialization of a variable, or jumps backward to a | |
9165 | label after the variable has been initialized. This only warns about | |
9166 | variables that are initialized when they are declared. This warning is | |
9167 | only supported for C and Objective-C; in C++ this sort of branch is an | |
9168 | error in any case. | |
9169 | ||
9170 | @option{-Wjump-misses-init} is included in @option{-Wc++-compat}. It | |
9171 | can be disabled with the @option{-Wno-jump-misses-init} option. | |
9172 | ||
d77de738 ML |
9173 | @opindex Wsign-compare |
9174 | @opindex Wno-sign-compare | |
9175 | @cindex warning for comparison of signed and unsigned values | |
9176 | @cindex comparison of signed and unsigned values, warning | |
9177 | @cindex signed and unsigned values, comparison warning | |
f33d7a88 | 9178 | @item -Wsign-compare |
d77de738 ML |
9179 | Warn when a comparison between signed and unsigned values could produce |
9180 | an incorrect result when the signed value is converted to unsigned. | |
9181 | In C++, this warning is also enabled by @option{-Wall}. In C, it is | |
9182 | also enabled by @option{-Wextra}. | |
9183 | ||
d77de738 ML |
9184 | @opindex Wsign-conversion |
9185 | @opindex Wno-sign-conversion | |
ddf6fe37 | 9186 | @item -Wsign-conversion |
d77de738 ML |
9187 | Warn for implicit conversions that may change the sign of an integer |
9188 | value, like assigning a signed integer expression to an unsigned | |
9189 | integer variable. An explicit cast silences the warning. In C, this | |
9190 | option is enabled also by @option{-Wconversion}. | |
9191 | ||
d77de738 ML |
9192 | @opindex Wfloat-conversion |
9193 | @opindex Wno-float-conversion | |
ddf6fe37 | 9194 | @item -Wfloat-conversion |
d77de738 ML |
9195 | Warn for implicit conversions that reduce the precision of a real value. |
9196 | This includes conversions from real to integer, and from higher precision | |
9197 | real to lower precision real values. This option is also enabled by | |
9198 | @option{-Wconversion}. | |
9199 | ||
d77de738 ML |
9200 | @opindex Wno-scalar-storage-order |
9201 | @opindex Wscalar-storage-order | |
ddf6fe37 | 9202 | @item -Wno-scalar-storage-order |
d77de738 ML |
9203 | Do not warn on suspicious constructs involving reverse scalar storage order. |
9204 | ||
d77de738 ML |
9205 | @opindex Wsizeof-array-div |
9206 | @opindex Wno-sizeof-array-div | |
ddf6fe37 | 9207 | @item -Wsizeof-array-div |
d77de738 ML |
9208 | Warn about divisions of two sizeof operators when the first one is applied |
9209 | to an array and the divisor does not equal the size of the array element. | |
9210 | In such a case, the computation will not yield the number of elements in the | |
9211 | array, which is likely what the user intended. This warning warns e.g. about | |
9212 | @smallexample | |
9213 | int fn () | |
9214 | @{ | |
9215 | int arr[10]; | |
9216 | return sizeof (arr) / sizeof (short); | |
9217 | @} | |
9218 | @end smallexample | |
9219 | ||
9220 | This warning is enabled by @option{-Wall}. | |
9221 | ||
d77de738 ML |
9222 | @opindex Wsizeof-pointer-div |
9223 | @opindex Wno-sizeof-pointer-div | |
ddf6fe37 | 9224 | @item -Wsizeof-pointer-div |
d77de738 ML |
9225 | Warn for suspicious divisions of two sizeof expressions that divide |
9226 | the pointer size by the element size, which is the usual way to compute | |
9227 | the array size but won't work out correctly with pointers. This warning | |
9228 | warns e.g.@: about @code{sizeof (ptr) / sizeof (ptr[0])} if @code{ptr} is | |
9229 | not an array, but a pointer. This warning is enabled by @option{-Wall}. | |
9230 | ||
d77de738 ML |
9231 | @opindex Wsizeof-pointer-memaccess |
9232 | @opindex Wno-sizeof-pointer-memaccess | |
ddf6fe37 | 9233 | @item -Wsizeof-pointer-memaccess |
d77de738 ML |
9234 | Warn for suspicious length parameters to certain string and memory built-in |
9235 | functions if the argument uses @code{sizeof}. This warning triggers for | |
9236 | example for @code{memset (ptr, 0, sizeof (ptr));} if @code{ptr} is not | |
9237 | an array, but a pointer, and suggests a possible fix, or about | |
9238 | @code{memcpy (&foo, ptr, sizeof (&foo));}. @option{-Wsizeof-pointer-memaccess} | |
9239 | also warns about calls to bounded string copy functions like @code{strncat} | |
9240 | or @code{strncpy} that specify as the bound a @code{sizeof} expression of | |
9241 | the source array. For example, in the following function the call to | |
9242 | @code{strncat} specifies the size of the source string as the bound. That | |
9243 | is almost certainly a mistake and so the call is diagnosed. | |
9244 | @smallexample | |
9245 | void make_file (const char *name) | |
9246 | @{ | |
9247 | char path[PATH_MAX]; | |
9248 | strncpy (path, name, sizeof path - 1); | |
9249 | strncat (path, ".text", sizeof ".text"); | |
9250 | @dots{} | |
9251 | @} | |
9252 | @end smallexample | |
9253 | ||
9254 | The @option{-Wsizeof-pointer-memaccess} option is enabled by @option{-Wall}. | |
9255 | ||
d77de738 ML |
9256 | @opindex Wsizeof-array-argument |
9257 | @opindex Wno-sizeof-array-argument | |
ddf6fe37 | 9258 | @item -Wno-sizeof-array-argument |
d77de738 ML |
9259 | Do not warn when the @code{sizeof} operator is applied to a parameter that is |
9260 | declared as an array in a function definition. This warning is enabled by | |
9261 | default for C and C++ programs. | |
9262 | ||
d77de738 ML |
9263 | @opindex Wmemset-elt-size |
9264 | @opindex Wno-memset-elt-size | |
ddf6fe37 | 9265 | @item -Wmemset-elt-size |
d77de738 ML |
9266 | Warn for suspicious calls to the @code{memset} built-in function, if the |
9267 | first argument references an array, and the third argument is a number | |
9268 | equal to the number of elements, but not equal to the size of the array | |
9269 | in memory. This indicates that the user has omitted a multiplication by | |
9270 | the element size. This warning is enabled by @option{-Wall}. | |
9271 | ||
d77de738 ML |
9272 | @opindex Wmemset-transposed-args |
9273 | @opindex Wno-memset-transposed-args | |
ddf6fe37 | 9274 | @item -Wmemset-transposed-args |
d77de738 ML |
9275 | Warn for suspicious calls to the @code{memset} built-in function where |
9276 | the second argument is not zero and the third argument is zero. For | |
9277 | example, the call @code{memset (buf, sizeof buf, 0)} is diagnosed because | |
9278 | @code{memset (buf, 0, sizeof buf)} was meant instead. The diagnostic | |
9279 | is only emitted if the third argument is a literal zero. Otherwise, if | |
9280 | it is an expression that is folded to zero, or a cast of zero to some | |
9281 | type, it is far less likely that the arguments have been mistakenly | |
9282 | transposed and no warning is emitted. This warning is enabled | |
9283 | by @option{-Wall}. | |
9284 | ||
d77de738 ML |
9285 | @opindex Waddress |
9286 | @opindex Wno-address | |
ddf6fe37 | 9287 | @item -Waddress |
d77de738 ML |
9288 | Warn about suspicious uses of address expressions. These include comparing |
9289 | the address of a function or a declared object to the null pointer constant | |
9290 | such as in | |
9291 | @smallexample | |
9292 | void f (void); | |
9293 | void g (void) | |
9294 | @{ | |
9295 | if (!f) // warning: expression evaluates to false | |
9296 | abort (); | |
9297 | @} | |
9298 | @end smallexample | |
9299 | comparisons of a pointer to a string literal, such as in | |
9300 | @smallexample | |
9301 | void f (const char *x) | |
9302 | @{ | |
9303 | if (x == "abc") // warning: expression evaluates to false | |
9304 | puts ("equal"); | |
9305 | @} | |
9306 | @end smallexample | |
9307 | and tests of the results of pointer addition or subtraction for equality | |
9308 | to null, such as in | |
9309 | @smallexample | |
9310 | void f (const int *p, int i) | |
9311 | @{ | |
9312 | return p + i == NULL; | |
9313 | @} | |
9314 | @end smallexample | |
9315 | Such uses typically indicate a programmer error: the address of most | |
9316 | functions and objects necessarily evaluates to true (the exception are | |
9317 | weak symbols), so their use in a conditional might indicate missing | |
9318 | parentheses in a function call or a missing dereference in an array | |
9319 | expression. The subset of the warning for object pointers can be | |
9320 | suppressed by casting the pointer operand to an integer type such | |
9321 | as @code{intptr_t} or @code{uintptr_t}. | |
9322 | Comparisons against string literals result in unspecified behavior | |
9323 | and are not portable, and suggest the intent was to call @code{strcmp}. | |
9324 | The warning is suppressed if the suspicious expression is the result | |
9325 | of macro expansion. | |
9326 | @option{-Waddress} warning is enabled by @option{-Wall}. | |
9327 | ||
d77de738 ML |
9328 | @opindex Waddress-of-packed-member |
9329 | @opindex Wno-address-of-packed-member | |
ddf6fe37 | 9330 | @item -Wno-address-of-packed-member |
d77de738 ML |
9331 | Do not warn when the address of packed member of struct or union is taken, |
9332 | which usually results in an unaligned pointer value. This is | |
9333 | enabled by default. | |
9334 | ||
d77de738 ML |
9335 | @opindex Wlogical-op |
9336 | @opindex Wno-logical-op | |
ddf6fe37 | 9337 | @item -Wlogical-op |
d77de738 ML |
9338 | Warn about suspicious uses of logical operators in expressions. |
9339 | This includes using logical operators in contexts where a | |
9340 | bit-wise operator is likely to be expected. Also warns when | |
9341 | the operands of a logical operator are the same: | |
9342 | @smallexample | |
9343 | extern int a; | |
9344 | if (a < 0 && a < 0) @{ @dots{} @} | |
9345 | @end smallexample | |
9346 | ||
d77de738 ML |
9347 | @opindex Wlogical-not-parentheses |
9348 | @opindex Wno-logical-not-parentheses | |
ddf6fe37 | 9349 | @item -Wlogical-not-parentheses |
d77de738 ML |
9350 | Warn about logical not used on the left hand side operand of a comparison. |
9351 | This option does not warn if the right operand is considered to be a boolean | |
9352 | expression. Its purpose is to detect suspicious code like the following: | |
9353 | @smallexample | |
9354 | int a; | |
9355 | @dots{} | |
9356 | if (!a > 1) @{ @dots{} @} | |
9357 | @end smallexample | |
9358 | ||
9359 | It is possible to suppress the warning by wrapping the LHS into | |
9360 | parentheses: | |
9361 | @smallexample | |
9362 | if ((!a) > 1) @{ @dots{} @} | |
9363 | @end smallexample | |
9364 | ||
9365 | This warning is enabled by @option{-Wall}. | |
9366 | ||
d77de738 ML |
9367 | @opindex Waggregate-return |
9368 | @opindex Wno-aggregate-return | |
ddf6fe37 | 9369 | @item -Waggregate-return |
d77de738 ML |
9370 | Warn if any functions that return structures or unions are defined or |
9371 | called. (In languages where you can return an array, this also elicits | |
9372 | a warning.) | |
9373 | ||
d77de738 ML |
9374 | @opindex Wno-aggressive-loop-optimizations |
9375 | @opindex Waggressive-loop-optimizations | |
ddf6fe37 | 9376 | @item -Wno-aggressive-loop-optimizations |
d77de738 ML |
9377 | Warn if in a loop with constant number of iterations the compiler detects |
9378 | undefined behavior in some statement during one or more of the iterations. | |
9379 | ||
d77de738 ML |
9380 | @opindex Wno-attributes |
9381 | @opindex Wattributes | |
ddf6fe37 | 9382 | @item -Wno-attributes |
d77de738 ML |
9383 | Do not warn if an unexpected @code{__attribute__} is used, such as |
9384 | unrecognized attributes, function attributes applied to variables, | |
9385 | etc. This does not stop errors for incorrect use of supported | |
9386 | attributes. | |
9387 | ||
9388 | Additionally, using @option{-Wno-attributes=}, it is possible to suppress | |
9389 | warnings about unknown scoped attributes (in C++11 and C2X). For example, | |
9390 | @option{-Wno-attributes=vendor::attr} disables warning about the following | |
9391 | declaration: | |
9392 | ||
9393 | @smallexample | |
9394 | [[vendor::attr]] void f(); | |
9395 | @end smallexample | |
9396 | ||
9397 | It is also possible to disable warning about all attributes in a namespace | |
9398 | using @option{-Wno-attributes=vendor::} which prevents warning about both | |
9399 | of these declarations: | |
9400 | ||
9401 | @smallexample | |
9402 | [[vendor::safe]] void f(); | |
9403 | [[vendor::unsafe]] void f2(); | |
9404 | @end smallexample | |
9405 | ||
9406 | Note that @option{-Wno-attributes=} does not imply @option{-Wno-attributes}. | |
9407 | ||
d77de738 ML |
9408 | @opindex Wno-builtin-declaration-mismatch |
9409 | @opindex Wbuiltin-declaration-mismatch | |
ddf6fe37 | 9410 | @item -Wno-builtin-declaration-mismatch |
d77de738 ML |
9411 | Warn if a built-in function is declared with an incompatible signature |
9412 | or as a non-function, or when a built-in function declared with a type | |
9413 | that does not include a prototype is called with arguments whose promoted | |
9414 | types do not match those expected by the function. When @option{-Wextra} | |
9415 | is specified, also warn when a built-in function that takes arguments is | |
9416 | declared without a prototype. The @option{-Wbuiltin-declaration-mismatch} | |
9417 | warning is enabled by default. To avoid the warning include the appropriate | |
9418 | header to bring the prototypes of built-in functions into scope. | |
9419 | ||
9420 | For example, the call to @code{memset} below is diagnosed by the warning | |
9421 | because the function expects a value of type @code{size_t} as its argument | |
9422 | but the type of @code{32} is @code{int}. With @option{-Wextra}, | |
9423 | the declaration of the function is diagnosed as well. | |
9424 | @smallexample | |
9425 | extern void* memset (); | |
9426 | void f (void *d) | |
9427 | @{ | |
9428 | memset (d, '\0', 32); | |
9429 | @} | |
9430 | @end smallexample | |
9431 | ||
d77de738 ML |
9432 | @opindex Wno-builtin-macro-redefined |
9433 | @opindex Wbuiltin-macro-redefined | |
ddf6fe37 | 9434 | @item -Wno-builtin-macro-redefined |
d77de738 ML |
9435 | Do not warn if certain built-in macros are redefined. This suppresses |
9436 | warnings for redefinition of @code{__TIMESTAMP__}, @code{__TIME__}, | |
9437 | @code{__DATE__}, @code{__FILE__}, and @code{__BASE_FILE__}. | |
9438 | ||
d77de738 ML |
9439 | @opindex Wstrict-prototypes |
9440 | @opindex Wno-strict-prototypes | |
ddf6fe37 | 9441 | @item -Wstrict-prototypes @r{(C and Objective-C only)} |
d77de738 ML |
9442 | Warn if a function is declared or defined without specifying the |
9443 | argument types. (An old-style function definition is permitted without | |
9444 | a warning if preceded by a declaration that specifies the argument | |
9445 | types.) | |
9446 | ||
d77de738 ML |
9447 | @opindex Wold-style-declaration |
9448 | @opindex Wno-old-style-declaration | |
ddf6fe37 | 9449 | @item -Wold-style-declaration @r{(C and Objective-C only)} |
d77de738 ML |
9450 | Warn for obsolescent usages, according to the C Standard, in a |
9451 | declaration. For example, warn if storage-class specifiers like | |
9452 | @code{static} are not the first things in a declaration. This warning | |
9453 | is also enabled by @option{-Wextra}. | |
9454 | ||
d77de738 ML |
9455 | @opindex Wold-style-definition |
9456 | @opindex Wno-old-style-definition | |
ddf6fe37 | 9457 | @item -Wold-style-definition @r{(C and Objective-C only)} |
d77de738 ML |
9458 | Warn if an old-style function definition is used. A warning is given |
9459 | even if there is a previous prototype. A definition using @samp{()} | |
9460 | is not considered an old-style definition in C2X mode, because it is | |
9461 | equivalent to @samp{(void)} in that case, but is considered an | |
9462 | old-style definition for older standards. | |
9463 | ||
d77de738 ML |
9464 | @opindex Wmissing-parameter-type |
9465 | @opindex Wno-missing-parameter-type | |
ddf6fe37 | 9466 | @item -Wmissing-parameter-type @r{(C and Objective-C only)} |
d77de738 ML |
9467 | A function parameter is declared without a type specifier in K&R-style |
9468 | functions: | |
9469 | ||
9470 | @smallexample | |
9471 | void foo(bar) @{ @} | |
9472 | @end smallexample | |
9473 | ||
9474 | This warning is also enabled by @option{-Wextra}. | |
9475 | ||
d77de738 ML |
9476 | @opindex Wmissing-prototypes |
9477 | @opindex Wno-missing-prototypes | |
ddf6fe37 | 9478 | @item -Wmissing-prototypes @r{(C and Objective-C only)} |
d77de738 ML |
9479 | Warn if a global function is defined without a previous prototype |
9480 | declaration. This warning is issued even if the definition itself | |
9481 | provides a prototype. Use this option to detect global functions | |
9482 | that do not have a matching prototype declaration in a header file. | |
9483 | This option is not valid for C++ because all function declarations | |
9484 | provide prototypes and a non-matching declaration declares an | |
9485 | overload rather than conflict with an earlier declaration. | |
9486 | Use @option{-Wmissing-declarations} to detect missing declarations in C++. | |
9487 | ||
d77de738 ML |
9488 | @opindex Wmissing-declarations |
9489 | @opindex Wno-missing-declarations | |
ddf6fe37 | 9490 | @item -Wmissing-declarations |
d77de738 ML |
9491 | Warn if a global function is defined without a previous declaration. |
9492 | Do so even if the definition itself provides a prototype. | |
9493 | Use this option to detect global functions that are not declared in | |
9494 | header files. In C, no warnings are issued for functions with previous | |
9495 | non-prototype declarations; use @option{-Wmissing-prototypes} to detect | |
9496 | missing prototypes. In C++, no warnings are issued for function templates, | |
9497 | or for inline functions, or for functions in anonymous namespaces. | |
9498 | ||
d77de738 ML |
9499 | @opindex Wmissing-field-initializers |
9500 | @opindex Wno-missing-field-initializers | |
9501 | @opindex W | |
9502 | @opindex Wextra | |
9503 | @opindex Wno-extra | |
ddf6fe37 | 9504 | @item -Wmissing-field-initializers |
d77de738 ML |
9505 | Warn if a structure's initializer has some fields missing. For |
9506 | example, the following code causes such a warning, because | |
9507 | @code{x.h} is implicitly zero: | |
9508 | ||
9509 | @smallexample | |
9510 | struct s @{ int f, g, h; @}; | |
9511 | struct s x = @{ 3, 4 @}; | |
9512 | @end smallexample | |
9513 | ||
9514 | This option does not warn about designated initializers, so the following | |
9515 | modification does not trigger a warning: | |
9516 | ||
9517 | @smallexample | |
9518 | struct s @{ int f, g, h; @}; | |
9519 | struct s x = @{ .f = 3, .g = 4 @}; | |
9520 | @end smallexample | |
9521 | ||
9522 | In C this option does not warn about the universal zero initializer | |
9523 | @samp{@{ 0 @}}: | |
9524 | ||
9525 | @smallexample | |
9526 | struct s @{ int f, g, h; @}; | |
9527 | struct s x = @{ 0 @}; | |
9528 | @end smallexample | |
9529 | ||
9530 | Likewise, in C++ this option does not warn about the empty @{ @} | |
9531 | initializer, for example: | |
9532 | ||
9533 | @smallexample | |
9534 | struct s @{ int f, g, h; @}; | |
9535 | s x = @{ @}; | |
9536 | @end smallexample | |
9537 | ||
9538 | This warning is included in @option{-Wextra}. To get other @option{-Wextra} | |
9539 | warnings without this one, use @option{-Wextra -Wno-missing-field-initializers}. | |
9540 | ||
d77de738 ML |
9541 | @opindex Wmissing-requires |
9542 | @opindex Wno-missing-requires | |
ddf6fe37 | 9543 | @item -Wno-missing-requires |
d77de738 ML |
9544 | |
9545 | By default, the compiler warns about a concept-id appearing as a C++20 simple-requirement: | |
9546 | ||
9547 | @smallexample | |
9548 | bool satisfied = requires @{ C<T> @}; | |
9549 | @end smallexample | |
9550 | ||
9551 | Here @samp{satisfied} will be true if @samp{C<T>} is a valid | |
9552 | expression, which it is for all T. Presumably the user meant to write | |
9553 | ||
9554 | @smallexample | |
9555 | bool satisfied = requires @{ requires C<T> @}; | |
9556 | @end smallexample | |
9557 | ||
9558 | so @samp{satisfied} is only true if concept @samp{C} is satisfied for | |
9559 | type @samp{T}. | |
9560 | ||
9561 | This warning can be disabled with @option{-Wno-missing-requires}. | |
9562 | ||
d77de738 ML |
9563 | @opindex Wmissing-template-keyword |
9564 | @opindex Wno-missing-template-keyword | |
ddf6fe37 | 9565 | @item -Wno-missing-template-keyword |
d77de738 ML |
9566 | |
9567 | The member access tokens ., -> and :: must be followed by the @code{template} | |
9568 | keyword if the parent object is dependent and the member being named is a | |
9569 | template. | |
9570 | ||
9571 | @smallexample | |
9572 | template <class X> | |
9573 | void DoStuff (X x) | |
9574 | @{ | |
9575 | x.template DoSomeOtherStuff<X>(); // Good. | |
9576 | x.DoMoreStuff<X>(); // Warning, x is dependent. | |
9577 | @} | |
9578 | @end smallexample | |
9579 | ||
9580 | In rare cases it is possible to get false positives. To silence this, wrap | |
9581 | the expression in parentheses. For example, the following is treated as a | |
9582 | template, even where m and N are integers: | |
9583 | ||
9584 | @smallexample | |
9585 | void NotATemplate (my_class t) | |
9586 | @{ | |
9587 | int N = 5; | |
9588 | ||
9589 | bool test = t.m < N > (0); // Treated as a template. | |
9590 | test = (t.m < N) > (0); // Same meaning, but not treated as a template. | |
9591 | @} | |
9592 | @end smallexample | |
9593 | ||
9594 | This warning can be disabled with @option{-Wno-missing-template-keyword}. | |
9595 | ||
d77de738 ML |
9596 | @opindex Wno-multichar |
9597 | @opindex Wmultichar | |
ddf6fe37 | 9598 | @item -Wno-multichar |
d77de738 ML |
9599 | Do not warn if a multicharacter constant (@samp{'FOOF'}) is used. |
9600 | Usually they indicate a typo in the user's code, as they have | |
9601 | implementation-defined values, and should not be used in portable code. | |
9602 | ||
d77de738 ML |
9603 | @opindex Wnormalized= |
9604 | @opindex Wnormalized | |
9605 | @opindex Wno-normalized | |
9606 | @cindex NFC | |
9607 | @cindex NFKC | |
9608 | @cindex character set, input normalization | |
f33d7a88 | 9609 | @item -Wnormalized=@r{[}none@r{|}id@r{|}nfc@r{|}nfkc@r{]} |
d77de738 ML |
9610 | In ISO C and ISO C++, two identifiers are different if they are |
9611 | different sequences of characters. However, sometimes when characters | |
9612 | outside the basic ASCII character set are used, you can have two | |
9613 | different character sequences that look the same. To avoid confusion, | |
9614 | the ISO 10646 standard sets out some @dfn{normalization rules} which | |
9615 | when applied ensure that two sequences that look the same are turned into | |
9616 | the same sequence. GCC can warn you if you are using identifiers that | |
9617 | have not been normalized; this option controls that warning. | |
9618 | ||
9619 | There are four levels of warning supported by GCC@. The default is | |
9620 | @option{-Wnormalized=nfc}, which warns about any identifier that is | |
9621 | not in the ISO 10646 ``C'' normalized form, @dfn{NFC}. NFC is the | |
9622 | recommended form for most uses. It is equivalent to | |
9623 | @option{-Wnormalized}. | |
9624 | ||
9625 | Unfortunately, there are some characters allowed in identifiers by | |
9626 | ISO C and ISO C++ that, when turned into NFC, are not allowed in | |
9627 | identifiers. That is, there's no way to use these symbols in portable | |
9628 | ISO C or C++ and have all your identifiers in NFC@. | |
9629 | @option{-Wnormalized=id} suppresses the warning for these characters. | |
9630 | It is hoped that future versions of the standards involved will correct | |
9631 | this, which is why this option is not the default. | |
9632 | ||
9633 | You can switch the warning off for all characters by writing | |
9634 | @option{-Wnormalized=none} or @option{-Wno-normalized}. You should | |
9635 | only do this if you are using some other normalization scheme (like | |
9636 | ``D''), because otherwise you can easily create bugs that are | |
9637 | literally impossible to see. | |
9638 | ||
9639 | Some characters in ISO 10646 have distinct meanings but look identical | |
9640 | in some fonts or display methodologies, especially once formatting has | |
9641 | been applied. For instance @code{\u207F}, ``SUPERSCRIPT LATIN SMALL | |
9642 | LETTER N'', displays just like a regular @code{n} that has been | |
9643 | placed in a superscript. ISO 10646 defines the @dfn{NFKC} | |
9644 | normalization scheme to convert all these into a standard form as | |
9645 | well, and GCC warns if your code is not in NFKC if you use | |
9646 | @option{-Wnormalized=nfkc}. This warning is comparable to warning | |
9647 | about every identifier that contains the letter O because it might be | |
9648 | confused with the digit 0, and so is not the default, but may be | |
9649 | useful as a local coding convention if the programming environment | |
9650 | cannot be fixed to display these characters distinctly. | |
9651 | ||
d77de738 ML |
9652 | @opindex Wno-attribute-warning |
9653 | @opindex Wattribute-warning | |
ddf6fe37 | 9654 | @item -Wno-attribute-warning |
d77de738 ML |
9655 | Do not warn about usage of functions (@pxref{Function Attributes}) |
9656 | declared with @code{warning} attribute. By default, this warning is | |
9657 | enabled. @option{-Wno-attribute-warning} can be used to disable the | |
9658 | warning or @option{-Wno-error=attribute-warning} can be used to | |
9659 | disable the error when compiled with @option{-Werror} flag. | |
9660 | ||
d77de738 ML |
9661 | @opindex Wno-deprecated |
9662 | @opindex Wdeprecated | |
ddf6fe37 | 9663 | @item -Wno-deprecated |
d77de738 ML |
9664 | Do not warn about usage of deprecated features. @xref{Deprecated Features}. |
9665 | ||
d77de738 ML |
9666 | @opindex Wno-deprecated-declarations |
9667 | @opindex Wdeprecated-declarations | |
ddf6fe37 | 9668 | @item -Wno-deprecated-declarations |
d77de738 ML |
9669 | Do not warn about uses of functions (@pxref{Function Attributes}), |
9670 | variables (@pxref{Variable Attributes}), and types (@pxref{Type | |
9671 | Attributes}) marked as deprecated by using the @code{deprecated} | |
9672 | attribute. | |
9673 | ||
d77de738 ML |
9674 | @opindex Wno-overflow |
9675 | @opindex Woverflow | |
ddf6fe37 | 9676 | @item -Wno-overflow |
d77de738 ML |
9677 | Do not warn about compile-time overflow in constant expressions. |
9678 | ||
d77de738 ML |
9679 | @opindex Wno-odr |
9680 | @opindex Wodr | |
ddf6fe37 | 9681 | @item -Wno-odr |
d77de738 ML |
9682 | Warn about One Definition Rule violations during link-time optimization. |
9683 | Enabled by default. | |
9684 | ||
d77de738 ML |
9685 | @opindex Wopenacc-parallelism |
9686 | @opindex Wno-openacc-parallelism | |
9687 | @cindex OpenACC accelerator programming | |
f33d7a88 | 9688 | @item -Wopenacc-parallelism |
d77de738 ML |
9689 | Warn about potentially suboptimal choices related to OpenACC parallelism. |
9690 | ||
d77de738 ML |
9691 | @opindex Wopenmp-simd |
9692 | @opindex Wno-openmp-simd | |
ddf6fe37 | 9693 | @item -Wopenmp-simd |
d77de738 ML |
9694 | Warn if the vectorizer cost model overrides the OpenMP |
9695 | simd directive set by user. The @option{-fsimd-cost-model=unlimited} | |
9696 | option can be used to relax the cost model. | |
9697 | ||
d77de738 ML |
9698 | @opindex Woverride-init |
9699 | @opindex Wno-override-init | |
9700 | @opindex W | |
9701 | @opindex Wextra | |
9702 | @opindex Wno-extra | |
ddf6fe37 | 9703 | @item -Woverride-init @r{(C and Objective-C only)} |
d77de738 ML |
9704 | Warn if an initialized field without side effects is overridden when |
9705 | using designated initializers (@pxref{Designated Inits, , Designated | |
9706 | Initializers}). | |
9707 | ||
9708 | This warning is included in @option{-Wextra}. To get other | |
9709 | @option{-Wextra} warnings without this one, use @option{-Wextra | |
9710 | -Wno-override-init}. | |
9711 | ||
d77de738 ML |
9712 | @opindex Woverride-init-side-effects |
9713 | @opindex Wno-override-init-side-effects | |
ddf6fe37 | 9714 | @item -Wno-override-init-side-effects @r{(C and Objective-C only)} |
d77de738 ML |
9715 | Do not warn if an initialized field with side effects is overridden when |
9716 | using designated initializers (@pxref{Designated Inits, , Designated | |
9717 | Initializers}). This warning is enabled by default. | |
9718 | ||
d77de738 ML |
9719 | @opindex Wpacked |
9720 | @opindex Wno-packed | |
ddf6fe37 | 9721 | @item -Wpacked |
d77de738 ML |
9722 | Warn if a structure is given the packed attribute, but the packed |
9723 | attribute has no effect on the layout or size of the structure. | |
9724 | Such structures may be mis-aligned for little benefit. For | |
9725 | instance, in this code, the variable @code{f.x} in @code{struct bar} | |
9726 | is misaligned even though @code{struct bar} does not itself | |
9727 | have the packed attribute: | |
9728 | ||
9729 | @smallexample | |
9730 | @group | |
9731 | struct foo @{ | |
9732 | int x; | |
9733 | char a, b, c, d; | |
9734 | @} __attribute__((packed)); | |
9735 | struct bar @{ | |
9736 | char z; | |
9737 | struct foo f; | |
9738 | @}; | |
9739 | @end group | |
9740 | @end smallexample | |
9741 | ||
d77de738 ML |
9742 | @opindex Wpacked-bitfield-compat |
9743 | @opindex Wno-packed-bitfield-compat | |
ddf6fe37 | 9744 | @item -Wnopacked-bitfield-compat |
d77de738 ML |
9745 | The 4.1, 4.2 and 4.3 series of GCC ignore the @code{packed} attribute |
9746 | on bit-fields of type @code{char}. This was fixed in GCC 4.4 but | |
9747 | the change can lead to differences in the structure layout. GCC | |
9748 | informs you when the offset of such a field has changed in GCC 4.4. | |
9749 | For example there is no longer a 4-bit padding between field @code{a} | |
9750 | and @code{b} in this structure: | |
9751 | ||
9752 | @smallexample | |
9753 | struct foo | |
9754 | @{ | |
9755 | char a:4; | |
9756 | char b:8; | |
9757 | @} __attribute__ ((packed)); | |
9758 | @end smallexample | |
9759 | ||
9760 | This warning is enabled by default. Use | |
9761 | @option{-Wno-packed-bitfield-compat} to disable this warning. | |
9762 | ||
d77de738 ML |
9763 | @opindex Wpacked-not-aligned |
9764 | @opindex Wno-packed-not-aligned | |
ddf6fe37 | 9765 | @item -Wpacked-not-aligned @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
9766 | Warn if a structure field with explicitly specified alignment in a |
9767 | packed struct or union is misaligned. For example, a warning will | |
9768 | be issued on @code{struct S}, like, @code{warning: alignment 1 of | |
9769 | 'struct S' is less than 8}, in this code: | |
9770 | ||
9771 | @smallexample | |
9772 | @group | |
9773 | struct __attribute__ ((aligned (8))) S8 @{ char a[8]; @}; | |
9774 | struct __attribute__ ((packed)) S @{ | |
9775 | struct S8 s8; | |
9776 | @}; | |
9777 | @end group | |
9778 | @end smallexample | |
9779 | ||
9780 | This warning is enabled by @option{-Wall}. | |
9781 | ||
d77de738 ML |
9782 | @opindex Wpadded |
9783 | @opindex Wno-padded | |
ddf6fe37 | 9784 | @item -Wpadded |
d77de738 ML |
9785 | Warn if padding is included in a structure, either to align an element |
9786 | of the structure or to align the whole structure. Sometimes when this | |
9787 | happens it is possible to rearrange the fields of the structure to | |
9788 | reduce the padding and so make the structure smaller. | |
9789 | ||
d77de738 ML |
9790 | @opindex Wredundant-decls |
9791 | @opindex Wno-redundant-decls | |
ddf6fe37 | 9792 | @item -Wredundant-decls |
d77de738 ML |
9793 | Warn if anything is declared more than once in the same scope, even in |
9794 | cases where multiple declaration is valid and changes nothing. | |
9795 | ||
d77de738 ML |
9796 | @opindex Wrestrict |
9797 | @opindex Wno-restrict | |
ddf6fe37 | 9798 | @item -Wrestrict |
d77de738 ML |
9799 | Warn when an object referenced by a @code{restrict}-qualified parameter |
9800 | (or, in C++, a @code{__restrict}-qualified parameter) is aliased by another | |
9801 | argument, or when copies between such objects overlap. For example, | |
9802 | the call to the @code{strcpy} function below attempts to truncate the string | |
9803 | by replacing its initial characters with the last four. However, because | |
9804 | the call writes the terminating NUL into @code{a[4]}, the copies overlap and | |
9805 | the call is diagnosed. | |
9806 | ||
9807 | @smallexample | |
9808 | void foo (void) | |
9809 | @{ | |
9810 | char a[] = "abcd1234"; | |
9811 | strcpy (a, a + 4); | |
9812 | @dots{} | |
9813 | @} | |
9814 | @end smallexample | |
9815 | The @option{-Wrestrict} option detects some instances of simple overlap | |
9816 | even without optimization but works best at @option{-O2} and above. It | |
9817 | is included in @option{-Wall}. | |
9818 | ||
d77de738 ML |
9819 | @opindex Wnested-externs |
9820 | @opindex Wno-nested-externs | |
ddf6fe37 | 9821 | @item -Wnested-externs @r{(C and Objective-C only)} |
d77de738 ML |
9822 | Warn if an @code{extern} declaration is encountered within a function. |
9823 | ||
d77de738 ML |
9824 | @opindex Winline |
9825 | @opindex Wno-inline | |
ddf6fe37 | 9826 | @item -Winline |
d77de738 ML |
9827 | Warn if a function that is declared as inline cannot be inlined. |
9828 | Even with this option, the compiler does not warn about failures to | |
9829 | inline functions declared in system headers. | |
9830 | ||
9831 | The compiler uses a variety of heuristics to determine whether or not | |
9832 | to inline a function. For example, the compiler takes into account | |
9833 | the size of the function being inlined and the amount of inlining | |
9834 | that has already been done in the current function. Therefore, | |
9835 | seemingly insignificant changes in the source program can cause the | |
9836 | warnings produced by @option{-Winline} to appear or disappear. | |
9837 | ||
d77de738 | 9838 | @opindex Winterference-size |
ddf6fe37 | 9839 | @item -Winterference-size |
d77de738 ML |
9840 | Warn about use of C++17 @code{std::hardware_destructive_interference_size} |
9841 | without specifying its value with @option{--param destructive-interference-size}. | |
9842 | Also warn about questionable values for that option. | |
9843 | ||
9844 | This variable is intended to be used for controlling class layout, to | |
9845 | avoid false sharing in concurrent code: | |
9846 | ||
9847 | @smallexample | |
9848 | struct independent_fields @{ | |
4ace81b6 SL |
9849 | alignas(std::hardware_destructive_interference_size) |
9850 | std::atomic<int> one; | |
9851 | alignas(std::hardware_destructive_interference_size) | |
9852 | std::atomic<int> two; | |
d77de738 ML |
9853 | @}; |
9854 | @end smallexample | |
9855 | ||
9856 | Here @samp{one} and @samp{two} are intended to be far enough apart | |
9857 | that stores to one won't require accesses to the other to reload the | |
9858 | cache line. | |
9859 | ||
9860 | By default, @option{--param destructive-interference-size} and | |
9861 | @option{--param constructive-interference-size} are set based on the | |
9862 | current @option{-mtune} option, typically to the L1 cache line size | |
9863 | for the particular target CPU, sometimes to a range if tuning for a | |
9864 | generic target. So all translation units that depend on ABI | |
9865 | compatibility for the use of these variables must be compiled with | |
9866 | the same @option{-mtune} (or @option{-mcpu}). | |
9867 | ||
9868 | If ABI stability is important, such as if the use is in a header for a | |
9869 | library, you should probably not use the hardware interference size | |
9870 | variables at all. Alternatively, you can force a particular value | |
9871 | with @option{--param}. | |
9872 | ||
9873 | If you are confident that your use of the variable does not affect ABI | |
9874 | outside a single build of your project, you can turn off the warning | |
9875 | with @option{-Wno-interference-size}. | |
9876 | ||
d77de738 ML |
9877 | @opindex Wint-in-bool-context |
9878 | @opindex Wno-int-in-bool-context | |
ddf6fe37 | 9879 | @item -Wint-in-bool-context |
d77de738 ML |
9880 | Warn for suspicious use of integer values where boolean values are expected, |
9881 | such as conditional expressions (?:) using non-boolean integer constants in | |
9882 | boolean context, like @code{if (a <= b ? 2 : 3)}. Or left shifting of signed | |
9883 | integers in boolean context, like @code{for (a = 0; 1 << a; a++);}. Likewise | |
9884 | for all kinds of multiplications regardless of the data type. | |
9885 | This warning is enabled by @option{-Wall}. | |
9886 | ||
d77de738 ML |
9887 | @opindex Wno-int-to-pointer-cast |
9888 | @opindex Wint-to-pointer-cast | |
ddf6fe37 | 9889 | @item -Wno-int-to-pointer-cast |
d77de738 ML |
9890 | Suppress warnings from casts to pointer type of an integer of a |
9891 | different size. In C++, casting to a pointer type of smaller size is | |
9892 | an error. @option{Wint-to-pointer-cast} is enabled by default. | |
9893 | ||
9894 | ||
d77de738 ML |
9895 | @opindex Wno-pointer-to-int-cast |
9896 | @opindex Wpointer-to-int-cast | |
ddf6fe37 | 9897 | @item -Wno-pointer-to-int-cast @r{(C and Objective-C only)} |
d77de738 ML |
9898 | Suppress warnings from casts from a pointer to an integer type of a |
9899 | different size. | |
9900 | ||
d77de738 ML |
9901 | @opindex Winvalid-pch |
9902 | @opindex Wno-invalid-pch | |
ddf6fe37 | 9903 | @item -Winvalid-pch |
d77de738 ML |
9904 | Warn if a precompiled header (@pxref{Precompiled Headers}) is found in |
9905 | the search path but cannot be used. | |
9906 | ||
d77de738 ML |
9907 | @opindex Winvalid-utf8 |
9908 | @opindex Wno-invalid-utf8 | |
ddf6fe37 | 9909 | @item -Winvalid-utf8 |
d77de738 ML |
9910 | Warn if an invalid UTF-8 character is found. |
9911 | This warning is on by default for C++23 if @option{-finput-charset=UTF-8} | |
9912 | is used and turned into error with @option{-pedantic-errors}. | |
9913 | ||
d77de738 ML |
9914 | @opindex Wunicode |
9915 | @opindex Wno-unicode | |
ddf6fe37 | 9916 | @item -Wno-unicode |
d77de738 ML |
9917 | Don't diagnose invalid forms of delimited or named escape sequences which are |
9918 | treated as separate tokens. @option{Wunicode} is enabled by default. | |
9919 | ||
d77de738 ML |
9920 | @opindex Wlong-long |
9921 | @opindex Wno-long-long | |
ddf6fe37 | 9922 | @item -Wlong-long |
d77de738 ML |
9923 | Warn if @code{long long} type is used. This is enabled by either |
9924 | @option{-Wpedantic} or @option{-Wtraditional} in ISO C90 and C++98 | |
9925 | modes. To inhibit the warning messages, use @option{-Wno-long-long}. | |
9926 | ||
d77de738 ML |
9927 | @opindex Wvariadic-macros |
9928 | @opindex Wno-variadic-macros | |
ddf6fe37 | 9929 | @item -Wvariadic-macros |
d77de738 ML |
9930 | Warn if variadic macros are used in ISO C90 mode, or if the GNU |
9931 | alternate syntax is used in ISO C99 mode. This is enabled by either | |
9932 | @option{-Wpedantic} or @option{-Wtraditional}. To inhibit the warning | |
9933 | messages, use @option{-Wno-variadic-macros}. | |
9934 | ||
d77de738 ML |
9935 | @opindex Wvarargs |
9936 | @opindex Wno-varargs | |
ddf6fe37 | 9937 | @item -Wno-varargs |
d77de738 ML |
9938 | Do not warn upon questionable usage of the macros used to handle variable |
9939 | arguments like @code{va_start}. These warnings are enabled by default. | |
9940 | ||
d77de738 ML |
9941 | @opindex Wvector-operation-performance |
9942 | @opindex Wno-vector-operation-performance | |
ddf6fe37 | 9943 | @item -Wvector-operation-performance |
d77de738 ML |
9944 | Warn if vector operation is not implemented via SIMD capabilities of the |
9945 | architecture. Mainly useful for the performance tuning. | |
9946 | Vector operation can be implemented @code{piecewise}, which means that the | |
9947 | scalar operation is performed on every vector element; | |
9948 | @code{in parallel}, which means that the vector operation is implemented | |
9949 | using scalars of wider type, which normally is more performance efficient; | |
9950 | and @code{as a single scalar}, which means that vector fits into a | |
9951 | scalar type. | |
9952 | ||
d77de738 ML |
9953 | @opindex Wvla |
9954 | @opindex Wno-vla | |
ddf6fe37 | 9955 | @item -Wvla |
d77de738 ML |
9956 | Warn if a variable-length array is used in the code. |
9957 | @option{-Wno-vla} prevents the @option{-Wpedantic} warning of | |
9958 | the variable-length array. | |
9959 | ||
d77de738 ML |
9960 | @opindex Wvla-larger-than= |
9961 | @opindex Wno-vla-larger-than | |
ddf6fe37 | 9962 | @item -Wvla-larger-than=@var{byte-size} |
d77de738 ML |
9963 | If this option is used, the compiler warns for declarations of |
9964 | variable-length arrays whose size is either unbounded, or bounded | |
9965 | by an argument that allows the array size to exceed @var{byte-size} | |
9966 | bytes. This is similar to how @option{-Walloca-larger-than=}@var{byte-size} | |
9967 | works, but with variable-length arrays. | |
9968 | ||
9969 | Note that GCC may optimize small variable-length arrays of a known | |
9970 | value into plain arrays, so this warning may not get triggered for | |
9971 | such arrays. | |
9972 | ||
9973 | @option{-Wvla-larger-than=}@samp{PTRDIFF_MAX} is enabled by default but | |
9974 | is typically only effective when @option{-ftree-vrp} is active (default | |
9975 | for @option{-O2} and above). | |
9976 | ||
9977 | See also @option{-Walloca-larger-than=@var{byte-size}}. | |
9978 | ||
d77de738 | 9979 | @opindex Wno-vla-larger-than |
ddf6fe37 | 9980 | @item -Wno-vla-larger-than |
d77de738 ML |
9981 | Disable @option{-Wvla-larger-than=} warnings. The option is equivalent |
9982 | to @option{-Wvla-larger-than=}@samp{SIZE_MAX} or larger. | |
9983 | ||
d77de738 | 9984 | @opindex Wno-vla-parameter |
ddf6fe37 | 9985 | @item -Wvla-parameter |
d77de738 ML |
9986 | Warn about redeclarations of functions involving arguments of Variable |
9987 | Length Array types of inconsistent kinds or forms, and enable the detection | |
9988 | of out-of-bounds accesses to such parameters by warnings such as | |
9989 | @option{-Warray-bounds}. | |
9990 | ||
9991 | If the first function declaration uses the VLA form the bound specified | |
9992 | in the array is assumed to be the minimum number of elements expected to | |
9993 | be provided in calls to the function and the maximum number of elements | |
9994 | accessed by it. Failing to provide arguments of sufficient size or | |
9995 | accessing more than the maximum number of elements may be diagnosed. | |
9996 | ||
9997 | For example, the warning triggers for the following redeclarations because | |
9998 | the first one allows an array of any size to be passed to @code{f} while | |
9999 | the second one specifies that the array argument must have at least @code{n} | |
10000 | elements. In addition, calling @code{f} with the associated VLA bound | |
10001 | parameter in excess of the actual VLA bound triggers a warning as well. | |
10002 | ||
10003 | @smallexample | |
10004 | void f (int n, int[n]); | |
4ace81b6 SL |
10005 | // warning: argument 2 previously declared as a VLA |
10006 | void f (int, int[]); | |
d77de738 ML |
10007 | |
10008 | void g (int n) | |
10009 | @{ | |
10010 | if (n > 4) | |
10011 | return; | |
10012 | int a[n]; | |
4ace81b6 SL |
10013 | // warning: access to a by f may be out of bounds |
10014 | f (sizeof a, a); | |
d77de738 ML |
10015 | @dots{} |
10016 | @} | |
10017 | ||
10018 | @end smallexample | |
10019 | ||
10020 | @option{-Wvla-parameter} is included in @option{-Wall}. The | |
10021 | @option{-Warray-parameter} option triggers warnings for similar problems | |
10022 | involving ordinary array arguments. | |
10023 | ||
d77de738 ML |
10024 | @opindex Wvolatile-register-var |
10025 | @opindex Wno-volatile-register-var | |
ddf6fe37 | 10026 | @item -Wvolatile-register-var |
d77de738 ML |
10027 | Warn if a register variable is declared volatile. The volatile |
10028 | modifier does not inhibit all optimizations that may eliminate reads | |
10029 | and/or writes to register variables. This warning is enabled by | |
10030 | @option{-Wall}. | |
10031 | ||
d77de738 ML |
10032 | @opindex Wxor-used-as-pow |
10033 | @opindex Wno-xor-used-as-pow | |
ddf6fe37 | 10034 | @item -Wxor-used-as-pow @r{(C, C++, Objective-C and Objective-C++ only)} |
d77de738 ML |
10035 | Warn about uses of @code{^}, the exclusive or operator, where it appears |
10036 | the user meant exponentiation. Specifically, the warning occurs when the | |
10037 | left-hand side is the decimal constant 2 or 10 and the right-hand side | |
10038 | is also a decimal constant. | |
10039 | ||
10040 | In C and C++, @code{^} means exclusive or, whereas in some other languages | |
10041 | (e.g. TeX and some versions of BASIC) it means exponentiation. | |
10042 | ||
10043 | This warning is enabled by default. It can be silenced by converting one | |
10044 | of the operands to hexadecimal. | |
10045 | ||
d77de738 ML |
10046 | @opindex Wdisabled-optimization |
10047 | @opindex Wno-disabled-optimization | |
ddf6fe37 | 10048 | @item -Wdisabled-optimization |
d77de738 ML |
10049 | Warn if a requested optimization pass is disabled. This warning does |
10050 | not generally indicate that there is anything wrong with your code; it | |
10051 | merely indicates that GCC's optimizers are unable to handle the code | |
10052 | effectively. Often, the problem is that your code is too big or too | |
10053 | complex; GCC refuses to optimize programs when the optimization | |
10054 | itself is likely to take inordinate amounts of time. | |
10055 | ||
d77de738 ML |
10056 | @opindex Wpointer-sign |
10057 | @opindex Wno-pointer-sign | |
ddf6fe37 | 10058 | @item -Wpointer-sign @r{(C and Objective-C only)} |
d77de738 ML |
10059 | Warn for pointer argument passing or assignment with different signedness. |
10060 | This option is only supported for C and Objective-C@. It is implied by | |
10061 | @option{-Wall} and by @option{-Wpedantic}, which can be disabled with | |
10062 | @option{-Wno-pointer-sign}. | |
10063 | ||
d77de738 ML |
10064 | @opindex Wstack-protector |
10065 | @opindex Wno-stack-protector | |
ddf6fe37 | 10066 | @item -Wstack-protector |
d77de738 ML |
10067 | This option is only active when @option{-fstack-protector} is active. It |
10068 | warns about functions that are not protected against stack smashing. | |
10069 | ||
d77de738 ML |
10070 | @opindex Woverlength-strings |
10071 | @opindex Wno-overlength-strings | |
ddf6fe37 | 10072 | @item -Woverlength-strings |
d77de738 ML |
10073 | Warn about string constants that are longer than the ``minimum |
10074 | maximum'' length specified in the C standard. Modern compilers | |
10075 | generally allow string constants that are much longer than the | |
10076 | standard's minimum limit, but very portable programs should avoid | |
10077 | using longer strings. | |
10078 | ||
10079 | The limit applies @emph{after} string constant concatenation, and does | |
10080 | not count the trailing NUL@. In C90, the limit was 509 characters; in | |
10081 | C99, it was raised to 4095. C++98 does not specify a normative | |
10082 | minimum maximum, so we do not diagnose overlength strings in C++@. | |
10083 | ||
10084 | This option is implied by @option{-Wpedantic}, and can be disabled with | |
10085 | @option{-Wno-overlength-strings}. | |
10086 | ||
d77de738 ML |
10087 | @opindex Wunsuffixed-float-constants |
10088 | @opindex Wno-unsuffixed-float-constants | |
ddf6fe37 | 10089 | @item -Wunsuffixed-float-constants @r{(C and Objective-C only)} |
d77de738 ML |
10090 | |
10091 | Issue a warning for any floating constant that does not have | |
10092 | a suffix. When used together with @option{-Wsystem-headers} it | |
10093 | warns about such constants in system header files. This can be useful | |
10094 | when preparing code to use with the @code{FLOAT_CONST_DECIMAL64} pragma | |
10095 | from the decimal floating-point extension to C99. | |
10096 | ||
d77de738 ML |
10097 | @opindex Wlto-type-mismatch |
10098 | @opindex Wno-lto-type-mismatch | |
ddf6fe37 | 10099 | @item -Wno-lto-type-mismatch |
d77de738 ML |
10100 | |
10101 | During the link-time optimization, do not warn about type mismatches in | |
10102 | global declarations from different compilation units. | |
10103 | Requires @option{-flto} to be enabled. Enabled by default. | |
10104 | ||
d77de738 ML |
10105 | @opindex Wdesignated-init |
10106 | @opindex Wno-designated-init | |
ddf6fe37 | 10107 | @item -Wno-designated-init @r{(C and Objective-C only)} |
d77de738 ML |
10108 | Suppress warnings when a positional initializer is used to initialize |
10109 | a structure that has been marked with the @code{designated_init} | |
10110 | attribute. | |
10111 | ||
10112 | @end table | |
10113 | ||
10114 | @node Static Analyzer Options | |
10115 | @section Options That Control Static Analysis | |
10116 | ||
10117 | @table @gcctabopt | |
d77de738 ML |
10118 | @opindex analyzer |
10119 | @opindex fanalyzer | |
10120 | @opindex fno-analyzer | |
ddf6fe37 | 10121 | @item -fanalyzer |
d77de738 ML |
10122 | This option enables an static analysis of program flow which looks |
10123 | for ``interesting'' interprocedural paths through the | |
10124 | code, and issues warnings for problems found on them. | |
10125 | ||
10126 | This analysis is much more expensive than other GCC warnings. | |
10127 | ||
a90316c6 DM |
10128 | In technical terms, it performs coverage-guided symbolic execution of |
10129 | the code being compiled. It is neither sound nor complete: it can | |
10130 | have false positives and false negatives. It is a bug-finding tool, | |
10131 | rather than a tool for proving program correctness. | |
10132 | ||
10133 | The analyzer is only suitable for use on C code in this release. | |
10134 | ||
d77de738 ML |
10135 | Enabling this option effectively enables the following warnings: |
10136 | ||
43b72ede AA |
10137 | @gccoptlist{ |
10138 | -Wanalyzer-allocation-size | |
10139 | -Wanalyzer-deref-before-check | |
10140 | -Wanalyzer-double-fclose | |
10141 | -Wanalyzer-double-free | |
10142 | -Wanalyzer-exposure-through-output-file | |
10143 | -Wanalyzer-exposure-through-uninit-copy | |
10144 | -Wanalyzer-fd-access-mode-mismatch | |
10145 | -Wanalyzer-fd-double-close | |
10146 | -Wanalyzer-fd-leak | |
10147 | -Wanalyzer-fd-phase-mismatch | |
10148 | -Wanalyzer-fd-type-mismatch | |
10149 | -Wanalyzer-fd-use-after-close | |
10150 | -Wanalyzer-fd-use-without-check | |
10151 | -Wanalyzer-file-leak | |
10152 | -Wanalyzer-free-of-non-heap | |
10153 | -Wanalyzer-imprecise-fp-arithmetic | |
10154 | -Wanalyzer-infinite-recursion | |
10155 | -Wanalyzer-jump-through-null | |
10156 | -Wanalyzer-malloc-leak | |
10157 | -Wanalyzer-mismatching-deallocation | |
10158 | -Wanalyzer-null-argument | |
10159 | -Wanalyzer-null-dereference | |
10160 | -Wanalyzer-out-of-bounds | |
10161 | -Wanalyzer-possible-null-argument | |
10162 | -Wanalyzer-possible-null-dereference | |
10163 | -Wanalyzer-putenv-of-auto-var | |
10164 | -Wanalyzer-shift-count-negative | |
10165 | -Wanalyzer-shift-count-overflow | |
10166 | -Wanalyzer-stale-setjmp-buffer | |
10167 | -Wanalyzer-unsafe-call-within-signal-handler | |
10168 | -Wanalyzer-use-after-free | |
10169 | -Wanalyzer-use-of-pointer-in-stale-stack-frame | |
10170 | -Wanalyzer-use-of-uninitialized-value | |
10171 | -Wanalyzer-va-arg-type-mismatch | |
10172 | -Wanalyzer-va-list-exhausted | |
10173 | -Wanalyzer-va-list-leak | |
10174 | -Wanalyzer-va-list-use-after-va-end | |
10175 | -Wanalyzer-write-to-const | |
10176 | -Wanalyzer-write-to-string-literal | |
d77de738 ML |
10177 | } |
10178 | @ignore | |
43b72ede AA |
10179 | -Wanalyzer-tainted-allocation-size |
10180 | -Wanalyzer-tainted-array-index | |
10181 | -Wanalyzer-tainted-divisor | |
10182 | -Wanalyzer-tainted-offset | |
10183 | -Wanalyzer-tainted-size | |
d77de738 ML |
10184 | @end ignore |
10185 | ||
10186 | This option is only available if GCC was configured with analyzer | |
10187 | support enabled. | |
10188 | ||
d77de738 ML |
10189 | @opindex Wanalyzer-too-complex |
10190 | @opindex Wno-analyzer-too-complex | |
ddf6fe37 | 10191 | @item -Wanalyzer-too-complex |
d77de738 ML |
10192 | If @option{-fanalyzer} is enabled, the analyzer uses various heuristics |
10193 | to attempt to explore the control flow and data flow in the program, | |
10194 | but these can be defeated by sufficiently complicated code. | |
10195 | ||
10196 | By default, the analysis silently stops if the code is too | |
10197 | complicated for the analyzer to fully explore and it reaches an internal | |
10198 | limit. The @option{-Wanalyzer-too-complex} option warns if this occurs. | |
10199 | ||
d77de738 ML |
10200 | @opindex Wanalyzer-allocation-size |
10201 | @opindex Wno-analyzer-allocation-size | |
ddf6fe37 | 10202 | @item -Wno-analyzer-allocation-size |
4ace81b6 SL |
10203 | This warning requires @option{-fanalyzer}, which enables it; |
10204 | to disable it, use @option{-Wno-analyzer-allocation-size}. | |
d77de738 ML |
10205 | |
10206 | This diagnostic warns for paths through the code in which a pointer to | |
10207 | a buffer is assigned to point at a buffer with a size that is not a | |
10208 | multiple of @code{sizeof (*pointer)}. | |
10209 | ||
10210 | See @uref{https://cwe.mitre.org/data/definitions/131.html, CWE-131: Incorrect Calculation of Buffer Size}. | |
10211 | ||
ce51e843 ML |
10212 | @opindex Wanalyzer-deref-before-check |
10213 | @opindex Wno-analyzer-deref-before-check | |
ddf6fe37 | 10214 | @item -Wno-analyzer-deref-before-check |
ce51e843 ML |
10215 | This warning requires @option{-fanalyzer}, which enables it; use |
10216 | @option{-Wno-analyzer-deref-before-check} | |
10217 | to disable it. | |
10218 | ||
10219 | This diagnostic warns for paths through the code in which a pointer | |
10220 | is checked for @code{NULL} *after* it has already been | |
10221 | dereferenced, suggesting that the pointer could have been NULL. | |
10222 | Such cases suggest that the check for NULL is either redundant, | |
10223 | or that it needs to be moved to before the pointer is dereferenced. | |
10224 | ||
10225 | This diagnostic also considers values passed to a function argument | |
10226 | marked with @code{__attribute__((nonnull))} as requiring a non-NULL | |
10227 | value, and thus will complain if such values are checked for @code{NULL} | |
10228 | after returning from such a function call. | |
10229 | ||
10230 | This diagnostic is unlikely to be reported when any level of optimization | |
10231 | is enabled, as GCC's optimization logic will typically consider such | |
10232 | checks for NULL as being redundant, and optimize them away before the | |
10233 | analyzer "sees" them. Hence optimization should be disabled when | |
10234 | attempting to trigger this diagnostic. | |
10235 | ||
d77de738 ML |
10236 | @opindex Wanalyzer-double-fclose |
10237 | @opindex Wno-analyzer-double-fclose | |
ddf6fe37 | 10238 | @item -Wno-analyzer-double-fclose |
d77de738 ML |
10239 | This warning requires @option{-fanalyzer}, which enables it; use |
10240 | @option{-Wno-analyzer-double-fclose} to disable it. | |
10241 | ||
10242 | This diagnostic warns for paths through the code in which a @code{FILE *} | |
10243 | can have @code{fclose} called on it more than once. | |
10244 | ||
10245 | See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}. | |
10246 | ||
d77de738 ML |
10247 | @opindex Wanalyzer-double-free |
10248 | @opindex Wno-analyzer-double-free | |
ddf6fe37 | 10249 | @item -Wno-analyzer-double-free |
d77de738 ML |
10250 | This warning requires @option{-fanalyzer}, which enables it; use |
10251 | @option{-Wno-analyzer-double-free} to disable it. | |
10252 | ||
10253 | This diagnostic warns for paths through the code in which a pointer | |
10254 | can have a deallocator called on it more than once, either @code{free}, | |
10255 | or a deallocator referenced by attribute @code{malloc}. | |
10256 | ||
10257 | See @uref{https://cwe.mitre.org/data/definitions/415.html, CWE-415: Double Free}. | |
10258 | ||
d77de738 ML |
10259 | @opindex Wanalyzer-exposure-through-output-file |
10260 | @opindex Wno-analyzer-exposure-through-output-file | |
ddf6fe37 | 10261 | @item -Wno-analyzer-exposure-through-output-file |
d77de738 ML |
10262 | This warning requires @option{-fanalyzer}, which enables it; use |
10263 | @option{-Wno-analyzer-exposure-through-output-file} | |
10264 | to disable it. | |
10265 | ||
10266 | This diagnostic warns for paths through the code in which a | |
10267 | security-sensitive value is written to an output file | |
10268 | (such as writing a password to a log file). | |
10269 | ||
10270 | See @uref{https://cwe.mitre.org/data/definitions/532.html, CWE-532: Information Exposure Through Log Files}. | |
10271 | ||
d77de738 ML |
10272 | @opindex Wanalyzer-exposure-through-uninit-copy |
10273 | @opindex Wno-analyzer-exposure-through-uninit-copy | |
ddf6fe37 | 10274 | @item -Wanalyzer-exposure-through-uninit-copy |
d77de738 ML |
10275 | This warning requires both @option{-fanalyzer} and the use of a plugin |
10276 | to specify a function that copies across a ``trust boundary''. Use | |
10277 | @option{-Wno-analyzer-exposure-through-uninit-copy} to disable it. | |
10278 | ||
10279 | This diagnostic warns for ``infoleaks'' - paths through the code in which | |
10280 | uninitialized values are copied across a security boundary | |
10281 | (such as code within an OS kernel that copies a partially-initialized | |
10282 | struct on the stack to user space). | |
10283 | ||
10284 | See @uref{https://cwe.mitre.org/data/definitions/200.html, CWE-200: Exposure of Sensitive Information to an Unauthorized Actor}. | |
10285 | ||
d77de738 ML |
10286 | @opindex Wanalyzer-fd-access-mode-mismatch |
10287 | @opindex Wno-analyzer-fd-access-mode-mismatch | |
ddf6fe37 | 10288 | @item -Wno-analyzer-fd-access-mode-mismatch |
d77de738 ML |
10289 | This warning requires @option{-fanalyzer}, which enables it; use |
10290 | @option{-Wno-analyzer-fd-access-mode-mismatch} | |
10291 | to disable it. | |
10292 | ||
10293 | This diagnostic warns for paths through code in which a | |
10294 | @code{read} on a write-only file descriptor is attempted, or vice versa. | |
10295 | ||
10296 | This diagnostic also warns for code paths in a which a function with attribute | |
10297 | @code{fd_arg_read (N)} is called with a file descriptor opened with | |
10298 | @code{O_WRONLY} at referenced argument @code{N} or a function with attribute | |
10299 | @code{fd_arg_write (N)} is called with a file descriptor opened with | |
10300 | @code{O_RDONLY} at referenced argument @var{N}. | |
10301 | ||
d77de738 ML |
10302 | @opindex Wanalyzer-fd-double-close |
10303 | @opindex Wno-analyzer-fd-double-close | |
ddf6fe37 | 10304 | @item -Wno-analyzer-fd-double-close |
d77de738 ML |
10305 | This warning requires @option{-fanalyzer}, which enables it; use |
10306 | @option{-Wno-analyzer-fd-double-close} | |
10307 | to disable it. | |
10308 | ||
10309 | This diagnostic warns for paths through code in which a | |
10310 | file descriptor can be closed more than once. | |
10311 | ||
10312 | See @uref{https://cwe.mitre.org/data/definitions/1341.html, CWE-1341: Multiple Releases of Same Resource or Handle}. | |
10313 | ||
d77de738 ML |
10314 | @opindex Wanalyzer-fd-leak |
10315 | @opindex Wno-analyzer-fd-leak | |
ddf6fe37 | 10316 | @item -Wno-analyzer-fd-leak |
d77de738 ML |
10317 | This warning requires @option{-fanalyzer}, which enables it; use |
10318 | @option{-Wno-analyzer-fd-leak} | |
10319 | to disable it. | |
10320 | ||
10321 | This diagnostic warns for paths through code in which an | |
10322 | open file descriptor is leaked. | |
10323 | ||
10324 | See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}. | |
10325 | ||
86a90006 DM |
10326 | @opindex Wanalyzer-fd-phase-mismatch |
10327 | @opindex Wno-analyzer-fd-phase-mismatch | |
ddf6fe37 | 10328 | @item -Wno-analyzer-fd-phase-mismatch |
86a90006 DM |
10329 | This warning requires @option{-fanalyzer}, which enables it; use |
10330 | @option{-Wno-analyzer-fd-phase-mismatch} | |
10331 | to disable it. | |
10332 | ||
10333 | This diagnostic warns for paths through code in which an operation is | |
10334 | attempted in the wrong phase of a file descriptor's lifetime. | |
10335 | For example, it will warn on attempts to call @code{accept} on a stream | |
10336 | socket that has not yet had @code{listen} successfully called on it. | |
10337 | ||
10338 | See @uref{https://cwe.mitre.org/data/definitions/666.html, CWE-666: Operation on Resource in Wrong Phase of Lifetime}. | |
10339 | ||
86a90006 DM |
10340 | @opindex Wanalyzer-fd-type-mismatch |
10341 | @opindex Wno-analyzer-fd-type-mismatch | |
ddf6fe37 | 10342 | @item -Wno-analyzer-fd-type-mismatch |
86a90006 DM |
10343 | This warning requires @option{-fanalyzer}, which enables it; use |
10344 | @option{-Wno-analyzer-fd-type-mismatch} | |
10345 | to disable it. | |
10346 | ||
10347 | This diagnostic warns for paths through code in which an | |
10348 | operation is attempted on the wrong type of file descriptor. | |
10349 | For example, it will warn on attempts to use socket operations | |
10350 | on a file descriptor obtained via @code{open}, or when attempting | |
10351 | to use a stream socket operation on a datagram socket. | |
10352 | ||
d77de738 ML |
10353 | @opindex Wanalyzer-fd-use-after-close |
10354 | @opindex Wno-analyzer-fd-use-after-close | |
ddf6fe37 | 10355 | @item -Wno-analyzer-fd-use-after-close |
d77de738 ML |
10356 | This warning requires @option{-fanalyzer}, which enables it; use |
10357 | @option{-Wno-analyzer-fd-use-after-close} | |
10358 | to disable it. | |
10359 | ||
10360 | This diagnostic warns for paths through code in which a | |
10361 | read or write is called on a closed file descriptor. | |
10362 | ||
10363 | This diagnostic also warns for paths through code in which | |
10364 | a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)} | |
10365 | or @code{fd_arg_write (N)} is called with a closed file descriptor at | |
10366 | referenced argument @code{N}. | |
10367 | ||
d77de738 ML |
10368 | @opindex Wanalyzer-fd-use-without-check |
10369 | @opindex Wno-analyzer-fd-use-without-check | |
ddf6fe37 | 10370 | @item -Wno-analyzer-fd-use-without-check |
d77de738 ML |
10371 | This warning requires @option{-fanalyzer}, which enables it; use |
10372 | @option{-Wno-analyzer-fd-use-without-check} | |
10373 | to disable it. | |
10374 | ||
10375 | This diagnostic warns for paths through code in which a | |
10376 | file descriptor is used without being checked for validity. | |
10377 | ||
10378 | This diagnostic also warns for paths through code in which | |
10379 | a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)} | |
10380 | or @code{fd_arg_write (N)} is called with a file descriptor, at referenced | |
10381 | argument @code{N}, without being checked for validity. | |
10382 | ||
d77de738 ML |
10383 | @opindex Wanalyzer-file-leak |
10384 | @opindex Wno-analyzer-file-leak | |
ddf6fe37 | 10385 | @item -Wno-analyzer-file-leak |
d77de738 ML |
10386 | This warning requires @option{-fanalyzer}, which enables it; use |
10387 | @option{-Wno-analyzer-file-leak} | |
10388 | to disable it. | |
10389 | ||
10390 | This diagnostic warns for paths through the code in which a | |
10391 | @code{<stdio.h>} @code{FILE *} stream object is leaked. | |
10392 | ||
10393 | See @uref{https://cwe.mitre.org/data/definitions/775.html, CWE-775: Missing Release of File Descriptor or Handle after Effective Lifetime}. | |
10394 | ||
d77de738 ML |
10395 | @opindex Wanalyzer-free-of-non-heap |
10396 | @opindex Wno-analyzer-free-of-non-heap | |
ddf6fe37 | 10397 | @item -Wno-analyzer-free-of-non-heap |
d77de738 ML |
10398 | This warning requires @option{-fanalyzer}, which enables it; use |
10399 | @option{-Wno-analyzer-free-of-non-heap} | |
10400 | to disable it. | |
10401 | ||
10402 | This diagnostic warns for paths through the code in which @code{free} | |
10403 | is called on a non-heap pointer (e.g. an on-stack buffer, or a global). | |
10404 | ||
10405 | See @uref{https://cwe.mitre.org/data/definitions/590.html, CWE-590: Free of Memory not on the Heap}. | |
10406 | ||
d77de738 ML |
10407 | @opindex Wanalyzer-imprecise-fp-arithmetic |
10408 | @opindex Wno-analyzer-imprecise-fp-arithmetic | |
ddf6fe37 | 10409 | @item -Wno-analyzer-imprecise-fp-arithmetic |
d77de738 ML |
10410 | This warning requires @option{-fanalyzer}, which enables it; use |
10411 | @option{-Wno-analyzer-imprecise-fp-arithmetic} | |
10412 | to disable it. | |
10413 | ||
10414 | This diagnostic warns for paths through the code in which floating-point | |
10415 | arithmetic is used in locations where precise computation is needed. This | |
10416 | diagnostic only warns on use of floating-point operands inside the | |
10417 | calculation of an allocation size at the moment. | |
10418 | ||
ce51e843 ML |
10419 | @opindex Wanalyzer-infinite-recursion |
10420 | @opindex Wno-analyzer-infinite-recursion | |
ddf6fe37 | 10421 | @item -Wno-analyzer-infinite-recursion |
ce51e843 ML |
10422 | This warning requires @option{-fanalyzer}, which enables it; use |
10423 | @option{-Wno-analyzer-infinite-recursion} to disable it. | |
10424 | ||
10425 | This diagnostics warns for paths through the code which appear to | |
10426 | lead to infinite recursion. | |
10427 | ||
10428 | Specifically, when the analyzer "sees" a recursive call, it will compare | |
10429 | the state of memory at the entry to the new frame with that at the entry | |
10430 | to the previous frame of that function on the stack. The warning is | |
10431 | issued if nothing in memory appears to be changing; any changes observed | |
10432 | to parameters or globals are assumed to lead to termination of the | |
10433 | recursion and thus suppress the warning. | |
10434 | ||
10435 | This diagnostic is likely to miss cases of infinite recursion that | |
10436 | are convered to iteration by the optimizer before the analyzer "sees" | |
10437 | them. Hence optimization should be disabled when attempting to trigger | |
10438 | this diagnostic. | |
10439 | ||
10440 | Compare with @option{-Winfinite-recursion}, which provides a similar | |
10441 | diagnostic, but is implemented in a different way. | |
10442 | ||
d77de738 ML |
10443 | @opindex Wanalyzer-jump-through-null |
10444 | @opindex Wno-analyzer-jump-through-null | |
ddf6fe37 | 10445 | @item -Wno-analyzer-jump-through-null |
d77de738 ML |
10446 | This warning requires @option{-fanalyzer}, which enables it; use |
10447 | @option{-Wno-analyzer-jump-through-null} | |
10448 | to disable it. | |
10449 | ||
10450 | This diagnostic warns for paths through the code in which a @code{NULL} | |
10451 | function pointer is called. | |
10452 | ||
d77de738 ML |
10453 | @opindex Wanalyzer-malloc-leak |
10454 | @opindex Wno-analyzer-malloc-leak | |
ddf6fe37 | 10455 | @item -Wno-analyzer-malloc-leak |
d77de738 ML |
10456 | This warning requires @option{-fanalyzer}, which enables it; use |
10457 | @option{-Wno-analyzer-malloc-leak} | |
10458 | to disable it. | |
10459 | ||
10460 | This diagnostic warns for paths through the code in which a | |
10461 | pointer allocated via an allocator is leaked: either @code{malloc}, | |
10462 | or a function marked with attribute @code{malloc}. | |
10463 | ||
10464 | See @uref{https://cwe.mitre.org/data/definitions/401.html, CWE-401: Missing Release of Memory after Effective Lifetime}. | |
10465 | ||
d77de738 ML |
10466 | @opindex Wanalyzer-mismatching-deallocation |
10467 | @opindex Wno-analyzer-mismatching-deallocation | |
ddf6fe37 | 10468 | @item -Wno-analyzer-mismatching-deallocation |
d77de738 ML |
10469 | This warning requires @option{-fanalyzer}, which enables it; use |
10470 | @option{-Wno-analyzer-mismatching-deallocation} | |
10471 | to disable it. | |
10472 | ||
10473 | This diagnostic warns for paths through the code in which the | |
10474 | wrong deallocation function is called on a pointer value, based on | |
10475 | which function was used to allocate the pointer value. The diagnostic | |
10476 | will warn about mismatches between @code{free}, scalar @code{delete} | |
10477 | and vector @code{delete[]}, and those marked as allocator/deallocator | |
10478 | pairs using attribute @code{malloc}. | |
10479 | ||
10480 | See @uref{https://cwe.mitre.org/data/definitions/762.html, CWE-762: Mismatched Memory Management Routines}. | |
10481 | ||
d77de738 ML |
10482 | @opindex Wanalyzer-out-of-bounds |
10483 | @opindex Wno-analyzer-out-of-bounds | |
ddf6fe37 | 10484 | @item -Wno-analyzer-out-of-bounds |
4ace81b6 | 10485 | This warning requires @option{-fanalyzer}, which enables it; use |
d77de738 ML |
10486 | @option{-Wno-analyzer-out-of-bounds} to disable it. |
10487 | ||
4ace81b6 | 10488 | This diagnostic warns for paths through the code in which a buffer is |
d77de738 ML |
10489 | definitely read or written out-of-bounds. The diagnostic applies for |
10490 | cases where the analyzer is able to determine a constant offset and for | |
10491 | accesses past the end of a buffer, also a constant capacity. Further, | |
10492 | the diagnostic does limited checking for accesses past the end when the | |
10493 | offset as well as the capacity is symbolic. | |
10494 | ||
10495 | See @uref{https://cwe.mitre.org/data/definitions/119.html, CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer}. | |
10496 | ||
d77de738 ML |
10497 | @opindex Wanalyzer-possible-null-argument |
10498 | @opindex Wno-analyzer-possible-null-argument | |
ddf6fe37 | 10499 | @item -Wno-analyzer-possible-null-argument |
d77de738 ML |
10500 | This warning requires @option{-fanalyzer}, which enables it; use |
10501 | @option{-Wno-analyzer-possible-null-argument} to disable it. | |
10502 | ||
10503 | This diagnostic warns for paths through the code in which a | |
10504 | possibly-NULL value is passed to a function argument marked | |
10505 | with @code{__attribute__((nonnull))} as requiring a non-NULL | |
10506 | value. | |
10507 | ||
10508 | See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}. | |
10509 | ||
d77de738 ML |
10510 | @opindex Wanalyzer-possible-null-dereference |
10511 | @opindex Wno-analyzer-possible-null-dereference | |
ddf6fe37 | 10512 | @item -Wno-analyzer-possible-null-dereference |
d77de738 ML |
10513 | This warning requires @option{-fanalyzer}, which enables it; use |
10514 | @option{-Wno-analyzer-possible-null-dereference} to disable it. | |
10515 | ||
10516 | This diagnostic warns for paths through the code in which a | |
10517 | possibly-NULL value is dereferenced. | |
10518 | ||
10519 | See @uref{https://cwe.mitre.org/data/definitions/690.html, CWE-690: Unchecked Return Value to NULL Pointer Dereference}. | |
10520 | ||
d77de738 ML |
10521 | @opindex Wanalyzer-null-argument |
10522 | @opindex Wno-analyzer-null-argument | |
ddf6fe37 | 10523 | @item -Wno-analyzer-null-argument |
d77de738 ML |
10524 | This warning requires @option{-fanalyzer}, which enables it; use |
10525 | @option{-Wno-analyzer-null-argument} to disable it. | |
10526 | ||
10527 | This diagnostic warns for paths through the code in which a | |
10528 | value known to be NULL is passed to a function argument marked | |
10529 | with @code{__attribute__((nonnull))} as requiring a non-NULL | |
10530 | value. | |
10531 | ||
10532 | See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}. | |
10533 | ||
d77de738 ML |
10534 | @opindex Wanalyzer-null-dereference |
10535 | @opindex Wno-analyzer-null-dereference | |
ddf6fe37 | 10536 | @item -Wno-analyzer-null-dereference |
d77de738 ML |
10537 | This warning requires @option{-fanalyzer}, which enables it; use |
10538 | @option{-Wno-analyzer-null-dereference} to disable it. | |
10539 | ||
10540 | This diagnostic warns for paths through the code in which a | |
10541 | value known to be NULL is dereferenced. | |
10542 | ||
10543 | See @uref{https://cwe.mitre.org/data/definitions/476.html, CWE-476: NULL Pointer Dereference}. | |
10544 | ||
d77de738 ML |
10545 | @opindex Wanalyzer-putenv-of-auto-var |
10546 | @opindex Wno-analyzer-putenv-of-auto-var | |
ddf6fe37 | 10547 | @item -Wno-analyzer-putenv-of-auto-var |
d77de738 ML |
10548 | This warning requires @option{-fanalyzer}, which enables it; use |
10549 | @option{-Wno-analyzer-putenv-of-auto-var} to disable it. | |
10550 | ||
10551 | This diagnostic warns for paths through the code in which a | |
10552 | call to @code{putenv} is passed a pointer to an automatic variable | |
10553 | or an on-stack buffer. | |
10554 | ||
10555 | 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}. | |
10556 | ||
d77de738 ML |
10557 | @opindex Wanalyzer-shift-count-negative |
10558 | @opindex Wno-analyzer-shift-count-negative | |
ddf6fe37 | 10559 | @item -Wno-analyzer-shift-count-negative |
d77de738 ML |
10560 | This warning requires @option{-fanalyzer}, which enables it; use |
10561 | @option{-Wno-analyzer-shift-count-negative} to disable it. | |
10562 | ||
10563 | This diagnostic warns for paths through the code in which a | |
10564 | shift is attempted with a negative count. It is analogous to | |
10565 | the @option{-Wshift-count-negative} diagnostic implemented in | |
10566 | the C/C++ front ends, but is implemented based on analyzing | |
10567 | interprocedural paths, rather than merely parsing the syntax tree. | |
10568 | However, the analyzer does not prioritize detection of such paths, so | |
10569 | false negatives are more likely relative to other warnings. | |
10570 | ||
d77de738 ML |
10571 | @opindex Wanalyzer-shift-count-overflow |
10572 | @opindex Wno-analyzer-shift-count-overflow | |
ddf6fe37 | 10573 | @item -Wno-analyzer-shift-count-overflow |
d77de738 ML |
10574 | This warning requires @option{-fanalyzer}, which enables it; use |
10575 | @option{-Wno-analyzer-shift-count-overflow} to disable it. | |
10576 | ||
10577 | This diagnostic warns for paths through the code in which a | |
10578 | shift is attempted with a count greater than or equal to the | |
10579 | precision of the operand's type. It is analogous to | |
10580 | the @option{-Wshift-count-overflow} diagnostic implemented in | |
10581 | the C/C++ front ends, but is implemented based on analyzing | |
10582 | interprocedural paths, rather than merely parsing the syntax tree. | |
10583 | However, the analyzer does not prioritize detection of such paths, so | |
10584 | false negatives are more likely relative to other warnings. | |
10585 | ||
d77de738 ML |
10586 | @opindex Wanalyzer-stale-setjmp-buffer |
10587 | @opindex Wno-analyzer-stale-setjmp-buffer | |
ddf6fe37 | 10588 | @item -Wno-analyzer-stale-setjmp-buffer |
d77de738 ML |
10589 | This warning requires @option{-fanalyzer}, which enables it; use |
10590 | @option{-Wno-analyzer-stale-setjmp-buffer} to disable it. | |
10591 | ||
10592 | This diagnostic warns for paths through the code in which | |
10593 | @code{longjmp} is called to rewind to a @code{jmp_buf} relating | |
10594 | to a @code{setjmp} call in a function that has returned. | |
10595 | ||
10596 | When @code{setjmp} is called on a @code{jmp_buf} to record a rewind | |
10597 | location, it records the stack frame. The stack frame becomes invalid | |
10598 | when the function containing the @code{setjmp} call returns. Attempting | |
10599 | to rewind to it via @code{longjmp} would reference a stack frame that | |
10600 | no longer exists, and likely lead to a crash (or worse). | |
10601 | ||
d77de738 ML |
10602 | @opindex Wanalyzer-tainted-allocation-size |
10603 | @opindex Wno-analyzer-tainted-allocation-size | |
ddf6fe37 | 10604 | @item -Wno-analyzer-tainted-allocation-size |
d77de738 ML |
10605 | This warning requires both @option{-fanalyzer} and |
10606 | @option{-fanalyzer-checker=taint} to enable it; | |
10607 | use @option{-Wno-analyzer-tainted-allocation-size} to disable it. | |
10608 | ||
10609 | This diagnostic warns for paths through the code in which a value | |
10610 | that could be under an attacker's control is used as the size | |
10611 | of an allocation without being sanitized, so that an attacker could | |
10612 | inject an excessively large allocation and potentially cause a denial | |
10613 | of service attack. | |
10614 | ||
10615 | See @uref{https://cwe.mitre.org/data/definitions/789.html, CWE-789: Memory Allocation with Excessive Size Value}. | |
10616 | ||
ce51e843 ML |
10617 | @opindex Wanalyzer-tainted-assertion |
10618 | @opindex Wno-analyzer-tainted-assertion | |
ddf6fe37 | 10619 | @item -Wno-analyzer-tainted-assertion |
ce51e843 ML |
10620 | |
10621 | This warning requires both @option{-fanalyzer} and | |
10622 | @option{-fanalyzer-checker=taint} to enable it; | |
10623 | use @option{-Wno-analyzer-tainted-assertion} to disable it. | |
10624 | ||
10625 | This diagnostic warns for paths through the code in which a value | |
10626 | that could be under an attacker's control is used as part of a | |
10627 | condition without being first sanitized, and that condition guards a | |
10628 | call to a function marked with attribute @code{noreturn} | |
10629 | (such as the function @code{__builtin_unreachable}). Such functions | |
10630 | typically indicate abnormal termination of the program, such as for | |
10631 | assertion failure handlers. For example: | |
10632 | ||
10633 | @smallexample | |
10634 | assert (some_tainted_value < SOME_LIMIT); | |
10635 | @end smallexample | |
10636 | ||
10637 | In such cases: | |
10638 | ||
10639 | @itemize | |
10640 | @item | |
10641 | when assertion-checking is enabled: an attacker could trigger | |
10642 | a denial of service by injecting an assertion failure | |
10643 | ||
10644 | @item | |
10645 | when assertion-checking is disabled, such as by defining @code{NDEBUG}, | |
10646 | an attacker could inject data that subverts the process, since it | |
10647 | presumably violates a precondition that is being assumed by the code. | |
10648 | ||
10649 | @end itemize | |
10650 | ||
10651 | Note that when assertion-checking is disabled, the assertions are | |
10652 | typically removed by the preprocessor before the analyzer has a chance | |
10653 | to "see" them, so this diagnostic can only generate warnings on builds | |
10654 | in which assertion-checking is enabled. | |
10655 | ||
10656 | For the purpose of this warning, any function marked with attribute | |
10657 | @code{noreturn} is considered as a possible assertion failure | |
10658 | handler, including @code{__builtin_unreachable}. Note that these functions | |
10659 | are sometimes removed by the optimizer before the analyzer "sees" them. | |
10660 | Hence optimization should be disabled when attempting to trigger this | |
10661 | diagnostic. | |
10662 | ||
10663 | See @uref{https://cwe.mitre.org/data/definitions/617.html, CWE-617: Reachable Assertion}. | |
10664 | ||
10665 | The warning can also report problematic constructions such as | |
10666 | ||
10667 | @smallexample | |
10668 | switch (some_tainted_value) @{ | |
10669 | case 0: | |
10670 | /* [...etc; various valid cases omitted...] */ | |
10671 | break; | |
10672 | ||
10673 | default: | |
10674 | __builtin_unreachable (); /* BUG: attacker can trigger this */ | |
10675 | @} | |
10676 | @end smallexample | |
10677 | ||
10678 | despite the above not being an assertion failure, strictly speaking. | |
10679 | ||
d77de738 ML |
10680 | @opindex Wanalyzer-tainted-array-index |
10681 | @opindex Wno-analyzer-tainted-array-index | |
ddf6fe37 | 10682 | @item -Wno-analyzer-tainted-array-index |
d77de738 ML |
10683 | This warning requires both @option{-fanalyzer} and |
10684 | @option{-fanalyzer-checker=taint} to enable it; | |
10685 | use @option{-Wno-analyzer-tainted-array-index} to disable it. | |
10686 | ||
10687 | This diagnostic warns for paths through the code in which a value | |
10688 | that could be under an attacker's control is used as the index | |
10689 | of an array access without being sanitized, so that an attacker | |
10690 | could inject an out-of-bounds access. | |
10691 | ||
10692 | See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}. | |
10693 | ||
d77de738 ML |
10694 | @opindex Wanalyzer-tainted-divisor |
10695 | @opindex Wno-analyzer-tainted-divisor | |
ddf6fe37 | 10696 | @item -Wno-analyzer-tainted-divisor |
d77de738 ML |
10697 | This warning requires both @option{-fanalyzer} and |
10698 | @option{-fanalyzer-checker=taint} to enable it; | |
10699 | use @option{-Wno-analyzer-tainted-divisor} to disable it. | |
10700 | ||
10701 | This diagnostic warns for paths through the code in which a value | |
10702 | that could be under an attacker's control is used as the divisor | |
10703 | in a division or modulus operation without being sanitized, so that | |
10704 | an attacker could inject a division-by-zero. | |
10705 | ||
10706 | See @uref{https://cwe.mitre.org/data/definitions/369.html, CWE-369: Divide By Zero}. | |
10707 | ||
d77de738 ML |
10708 | @opindex Wanalyzer-tainted-offset |
10709 | @opindex Wno-analyzer-tainted-offset | |
ddf6fe37 | 10710 | @item -Wno-analyzer-tainted-offset |
d77de738 ML |
10711 | This warning requires both @option{-fanalyzer} and |
10712 | @option{-fanalyzer-checker=taint} to enable it; | |
10713 | use @option{-Wno-analyzer-tainted-offset} to disable it. | |
10714 | ||
10715 | This diagnostic warns for paths through the code in which a value | |
10716 | that could be under an attacker's control is used as a pointer offset | |
10717 | without being sanitized, so that an attacker could inject an out-of-bounds | |
10718 | access. | |
10719 | ||
10720 | See @uref{https://cwe.mitre.org/data/definitions/823.html, CWE-823: Use of Out-of-range Pointer Offset}. | |
10721 | ||
d77de738 ML |
10722 | @opindex Wanalyzer-tainted-size |
10723 | @opindex Wno-analyzer-tainted-size | |
ddf6fe37 | 10724 | @item -Wno-analyzer-tainted-size |
d77de738 ML |
10725 | This warning requires both @option{-fanalyzer} and |
10726 | @option{-fanalyzer-checker=taint} to enable it; | |
10727 | use @option{-Wno-analyzer-tainted-size} to disable it. | |
10728 | ||
10729 | This diagnostic warns for paths through the code in which a value | |
10730 | that could be under an attacker's control is used as the size of | |
10731 | an operation such as @code{memset} without being sanitized, so that an | |
10732 | attacker could inject an out-of-bounds access. | |
10733 | ||
10734 | See @uref{https://cwe.mitre.org/data/definitions/129.html, CWE-129: Improper Validation of Array Index}. | |
10735 | ||
d77de738 ML |
10736 | @opindex Wanalyzer-unsafe-call-within-signal-handler |
10737 | @opindex Wno-analyzer-unsafe-call-within-signal-handler | |
ddf6fe37 | 10738 | @item -Wno-analyzer-unsafe-call-within-signal-handler |
d77de738 ML |
10739 | This warning requires @option{-fanalyzer}, which enables it; use |
10740 | @option{-Wno-analyzer-unsafe-call-within-signal-handler} to disable it. | |
10741 | ||
10742 | This diagnostic warns for paths through the code in which a | |
10743 | function known to be async-signal-unsafe (such as @code{fprintf}) is | |
10744 | called from a signal handler. | |
10745 | ||
10746 | See @uref{https://cwe.mitre.org/data/definitions/479.html, CWE-479: Signal Handler Use of a Non-reentrant Function}. | |
10747 | ||
d77de738 ML |
10748 | @opindex Wanalyzer-use-after-free |
10749 | @opindex Wno-analyzer-use-after-free | |
ddf6fe37 | 10750 | @item -Wno-analyzer-use-after-free |
d77de738 ML |
10751 | This warning requires @option{-fanalyzer}, which enables it; use |
10752 | @option{-Wno-analyzer-use-after-free} to disable it. | |
10753 | ||
10754 | This diagnostic warns for paths through the code in which a | |
10755 | pointer is used after a deallocator is called on it: either @code{free}, | |
10756 | or a deallocator referenced by attribute @code{malloc}. | |
10757 | ||
10758 | See @uref{https://cwe.mitre.org/data/definitions/416.html, CWE-416: Use After Free}. | |
10759 | ||
d77de738 ML |
10760 | @opindex Wanalyzer-use-of-pointer-in-stale-stack-frame |
10761 | @opindex Wno-analyzer-use-of-pointer-in-stale-stack-frame | |
ddf6fe37 | 10762 | @item -Wno-analyzer-use-of-pointer-in-stale-stack-frame |
d77de738 ML |
10763 | This warning requires @option{-fanalyzer}, which enables it; use |
10764 | @option{-Wno-analyzer-use-of-pointer-in-stale-stack-frame} | |
10765 | to disable it. | |
10766 | ||
10767 | This diagnostic warns for paths through the code in which a pointer | |
10768 | is dereferenced that points to a variable in a stale stack frame. | |
10769 | ||
d77de738 ML |
10770 | @opindex Wanalyzer-va-arg-type-mismatch |
10771 | @opindex Wno-analyzer-va-arg-type-mismatch | |
ddf6fe37 | 10772 | @item -Wno-analyzer-va-arg-type-mismatch |
d77de738 ML |
10773 | This warning requires @option{-fanalyzer}, which enables it; use |
10774 | @option{-Wno-analyzer-va-arg-type-mismatch} | |
10775 | to disable it. | |
10776 | ||
10777 | This diagnostic warns for interprocedural paths through the code for which | |
10778 | the analyzer detects an attempt to use @code{va_arg} to extract a value | |
10779 | passed to a variadic call, but uses a type that does not match that of | |
10780 | the expression passed to the call. | |
10781 | ||
10782 | See @uref{https://cwe.mitre.org/data/definitions/686.html, CWE-686: Function Call With Incorrect Argument Type}. | |
10783 | ||
d77de738 ML |
10784 | @opindex Wanalyzer-va-list-exhausted |
10785 | @opindex Wno-analyzer-va-list-exhausted | |
ddf6fe37 | 10786 | @item -Wno-analyzer-va-list-exhausted |
d77de738 ML |
10787 | This warning requires @option{-fanalyzer}, which enables it; use |
10788 | @option{-Wno-analyzer-va-list-exhausted} | |
10789 | to disable it. | |
10790 | ||
10791 | This diagnostic warns for interprocedural paths through the code for which | |
10792 | the analyzer detects an attempt to use @code{va_arg} to access the next | |
10793 | value passed to a variadic call, but all of the values in the | |
10794 | @code{va_list} have already been consumed. | |
10795 | ||
10796 | See @uref{https://cwe.mitre.org/data/definitions/685.html, CWE-685: Function Call With Incorrect Number of Arguments}. | |
10797 | ||
d77de738 ML |
10798 | @opindex Wanalyzer-va-list-leak |
10799 | @opindex Wno-analyzer-va-list-leak | |
ddf6fe37 | 10800 | @item -Wno-analyzer-va-list-leak |
d77de738 ML |
10801 | This warning requires @option{-fanalyzer}, which enables it; use |
10802 | @option{-Wno-analyzer-va-list-leak} | |
10803 | to disable it. | |
10804 | ||
10805 | This diagnostic warns for interprocedural paths through the code for which | |
10806 | the analyzer detects that @code{va_start} or @code{va_copy} has been called | |
10807 | on a @code{va_list} without a corresponding call to @code{va_end}. | |
10808 | ||
d77de738 ML |
10809 | @opindex Wanalyzer-va-list-use-after-va-end |
10810 | @opindex Wno-analyzer-va-list-use-after-va-end | |
ddf6fe37 | 10811 | @item -Wno-analyzer-va-list-use-after-va-end |
d77de738 ML |
10812 | This warning requires @option{-fanalyzer}, which enables it; use |
10813 | @option{-Wno-analyzer-va-list-use-after-va-end} | |
10814 | to disable it. | |
10815 | ||
10816 | This diagnostic warns for interprocedural paths through the code for which | |
10817 | the analyzer detects an attempt to use a @code{va_list} after | |
10818 | @code{va_end} has been called on it. | |
10819 | @code{va_list}. | |
10820 | ||
d77de738 ML |
10821 | @opindex Wanalyzer-write-to-const |
10822 | @opindex Wno-analyzer-write-to-const | |
ddf6fe37 | 10823 | @item -Wno-analyzer-write-to-const |
d77de738 ML |
10824 | This warning requires @option{-fanalyzer}, which enables it; use |
10825 | @option{-Wno-analyzer-write-to-const} | |
10826 | to disable it. | |
10827 | ||
10828 | This diagnostic warns for paths through the code in which the analyzer | |
10829 | detects an attempt to write through a pointer to a @code{const} object. | |
10830 | However, the analyzer does not prioritize detection of such paths, so | |
10831 | false negatives are more likely relative to other warnings. | |
10832 | ||
d77de738 ML |
10833 | @opindex Wanalyzer-write-to-string-literal |
10834 | @opindex Wno-analyzer-write-to-string-literal | |
ddf6fe37 | 10835 | @item -Wno-analyzer-write-to-string-literal |
d77de738 ML |
10836 | This warning requires @option{-fanalyzer}, which enables it; use |
10837 | @option{-Wno-analyzer-write-to-string-literal} | |
10838 | to disable it. | |
10839 | ||
10840 | This diagnostic warns for paths through the code in which the analyzer | |
10841 | detects an attempt to write through a pointer to a string literal. | |
10842 | However, the analyzer does not prioritize detection of such paths, so | |
10843 | false negatives are more likely relative to other warnings. | |
10844 | ||
d77de738 ML |
10845 | @opindex Wanalyzer-use-of-uninitialized-value |
10846 | @opindex Wno-analyzer-use-of-uninitialized-value | |
ddf6fe37 | 10847 | @item -Wno-analyzer-use-of-uninitialized-value |
d77de738 ML |
10848 | This warning requires @option{-fanalyzer}, which enables it; use |
10849 | @option{-Wno-analyzer-use-of-uninitialized-value} to disable it. | |
10850 | ||
10851 | This diagnostic warns for paths through the code in which an uninitialized | |
10852 | value is used. | |
10853 | ||
10854 | See @uref{https://cwe.mitre.org/data/definitions/457.html, CWE-457: Use of Uninitialized Variable}. | |
10855 | ||
10856 | @end table | |
10857 | ||
10858 | The analyzer has hardcoded knowledge about the behavior of the following | |
10859 | memory-management functions: | |
10860 | ||
10861 | @itemize @bullet | |
10862 | @item @code{alloca} | |
10863 | @item The built-in functions @code{__builtin_alloc}, | |
10864 | @code{__builtin_alloc_with_align}, @item @code{__builtin_calloc}, | |
10865 | @code{__builtin_free}, @code{__builtin_malloc}, @code{__builtin_memcpy}, | |
10866 | @code{__builtin_memcpy_chk}, @code{__builtin_memset}, | |
10867 | @code{__builtin_memset_chk}, @code{__builtin_realloc}, | |
10868 | @code{__builtin_stack_restore}, and @code{__builtin_stack_save} | |
10869 | @item @code{calloc} | |
10870 | @item @code{free} | |
10871 | @item @code{malloc} | |
10872 | @item @code{memset} | |
10873 | @item @code{operator delete} | |
10874 | @item @code{operator delete []} | |
10875 | @item @code{operator new} | |
10876 | @item @code{operator new []} | |
10877 | @item @code{realloc} | |
10878 | @item @code{strdup} | |
10879 | @item @code{strndup} | |
10880 | @end itemize | |
10881 | ||
4ace81b6 | 10882 | @noindent |
d77de738 ML |
10883 | of the following functions for working with file descriptors: |
10884 | ||
10885 | @itemize @bullet | |
10886 | @item @code{open} | |
10887 | @item @code{close} | |
10888 | @item @code{creat} | |
10889 | @item @code{dup}, @code{dup2} and @code{dup3} | |
78a17f44 | 10890 | @item @code{isatty} |
d77de738 ML |
10891 | @item @code{pipe}, and @code{pipe2} |
10892 | @item @code{read} | |
10893 | @item @code{write} | |
86a90006 | 10894 | @item @code{socket}, @code{bind}, @code{listen}, @code{accept}, and @code{connect} |
d77de738 ML |
10895 | @end itemize |
10896 | ||
4ace81b6 | 10897 | @noindent |
d77de738 ML |
10898 | of the following functions for working with @code{<stdio.h>} streams: |
10899 | @itemize @bullet | |
10900 | @item The built-in functions @code{__builtin_fprintf}, | |
10901 | @code{__builtin_fprintf_unlocked}, @code{__builtin_fputc}, | |
10902 | @code{__builtin_fputc_unlocked}, @code{__builtin_fputs}, | |
10903 | @code{__builtin_fputs_unlocked}, @code{__builtin_fwrite}, | |
10904 | @code{__builtin_fwrite_unlocked}, @code{__builtin_printf}, | |
10905 | @code{__builtin_printf_unlocked}, @code{__builtin_putc}, | |
10906 | @code{__builtin_putchar}, @code{__builtin_putchar_unlocked}, | |
10907 | @code{__builtin_putc_unlocked}, @code{__builtin_puts}, | |
10908 | @code{__builtin_puts_unlocked}, @code{__builtin_vfprintf}, and | |
10909 | @code{__builtin_vprintf} | |
10910 | @item @code{fopen} | |
10911 | @item @code{fclose} | |
78a17f44 | 10912 | @item @code{ferror} |
d77de738 ML |
10913 | @item @code{fgets} |
10914 | @item @code{fgets_unlocked} | |
78a17f44 | 10915 | @item @code{fileno} |
d77de738 | 10916 | @item @code{fread} |
78a17f44 | 10917 | @item @code{getc} |
d77de738 ML |
10918 | @item @code{getchar} |
10919 | @item @code{fprintf} | |
10920 | @item @code{printf} | |
10921 | @item @code{fwrite} | |
10922 | @end itemize | |
10923 | ||
4ace81b6 | 10924 | @noindent |
d77de738 ML |
10925 | and of the following functions: |
10926 | ||
10927 | @itemize @bullet | |
10928 | @item The built-in functions @code{__builtin_expect}, | |
10929 | @code{__builtin_expect_with_probability}, @code{__builtin_strchr}, | |
10930 | @code{__builtin_strcpy}, @code{__builtin_strcpy_chk}, | |
10931 | @code{__builtin_strlen}, @code{__builtin_va_copy}, and | |
10932 | @code{__builtin_va_start} | |
10933 | @item The GNU extensions @code{error} and @code{error_at_line} | |
10934 | @item @code{getpass} | |
10935 | @item @code{longjmp} | |
10936 | @item @code{putenv} | |
10937 | @item @code{setjmp} | |
10938 | @item @code{siglongjmp} | |
10939 | @item @code{signal} | |
10940 | @item @code{sigsetjmp} | |
10941 | @item @code{strchr} | |
10942 | @item @code{strlen} | |
10943 | @end itemize | |
10944 | ||
10945 | In addition, various functions with an @code{__analyzer_} prefix have | |
10946 | special meaning to the analyzer, described in the GCC Internals manual. | |
10947 | ||
10948 | Pertinent parameters for controlling the exploration are: | |
4ace81b6 SL |
10949 | @itemize @bullet |
10950 | @item @option{--param analyzer-bb-explosion-factor=@var{value}} | |
10951 | @item @option{--param analyzer-max-enodes-per-program-point=@var{value}} | |
10952 | @item @option{--param analyzer-max-recursion-depth=@var{value}} | |
10953 | @item @option{--param analyzer-min-snodes-for-call-summary=@var{value}} | |
10954 | @end itemize | |
d77de738 ML |
10955 | |
10956 | The following options control the analyzer. | |
10957 | ||
10958 | @table @gcctabopt | |
10959 | ||
d77de738 ML |
10960 | @opindex fanalyzer-call-summaries |
10961 | @opindex fno-analyzer-call-summaries | |
ddf6fe37 | 10962 | @item -fanalyzer-call-summaries |
d77de738 ML |
10963 | Simplify interprocedural analysis by computing the effect of certain calls, |
10964 | rather than exploring all paths through the function from callsite to each | |
10965 | possible return. | |
10966 | ||
10967 | If enabled, call summaries are only used for functions with more than one | |
10968 | call site, and that are sufficiently complicated (as per | |
10969 | @option{--param analyzer-min-snodes-for-call-summary=@var{value}}). | |
10970 | ||
d77de738 | 10971 | @opindex fanalyzer-checker |
ddf6fe37 | 10972 | @item -fanalyzer-checker=@var{name} |
d77de738 ML |
10973 | Restrict the analyzer to run just the named checker, and enable it. |
10974 | ||
10975 | Some checkers are disabled by default (even with @option{-fanalyzer}), | |
10976 | such as the @code{taint} checker that implements | |
10977 | @option{-Wanalyzer-tainted-array-index}, and this option is required | |
10978 | to enable them. | |
10979 | ||
10980 | @emph{Note:} currently, @option{-fanalyzer-checker=taint} disables the | |
10981 | following warnings from @option{-fanalyzer}: | |
10982 | ||
43b72ede AA |
10983 | @gccoptlist{ |
10984 | -Wanalyzer-deref-before-check | |
10985 | -Wanalyzer-double-fclose | |
10986 | -Wanalyzer-double-free | |
10987 | -Wanalyzer-exposure-through-output-file | |
10988 | -Wanalyzer-fd-access-mode-mismatch | |
10989 | -Wanalyzer-fd-double-close | |
10990 | -Wanalyzer-fd-leak | |
10991 | -Wanalyzer-fd-use-after-close | |
10992 | -Wanalyzer-fd-use-without-check | |
10993 | -Wanalyzer-file-leak | |
10994 | -Wanalyzer-free-of-non-heap | |
10995 | -Wanalyzer-malloc-leak | |
10996 | -Wanalyzer-mismatching-deallocation | |
10997 | -Wanalyzer-null-argument | |
10998 | -Wanalyzer-null-dereference | |
10999 | -Wanalyzer-possible-null-argument | |
11000 | -Wanalyzer-possible-null-dereference | |
11001 | -Wanalyzer-unsafe-call-within-signal-handler | |
11002 | -Wanalyzer-use-after-free | |
11003 | -Wanalyzer-va-list-leak | |
11004 | -Wanalyzer-va-list-use-after-va-end | |
d77de738 ML |
11005 | } |
11006 | ||
d77de738 ML |
11007 | @opindex fanalyzer-feasibility |
11008 | @opindex fno-analyzer-feasibility | |
ddf6fe37 | 11009 | @item -fno-analyzer-feasibility |
d77de738 ML |
11010 | This option is intended for analyzer developers. |
11011 | ||
11012 | By default the analyzer verifies that there is a feasible control flow path | |
11013 | for each diagnostic it emits: that the conditions that hold are not mutually | |
11014 | exclusive. Diagnostics for which no feasible path can be found are rejected. | |
11015 | This filtering can be suppressed with @option{-fno-analyzer-feasibility}, for | |
11016 | debugging issues in this code. | |
11017 | ||
d77de738 ML |
11018 | @opindex fanalyzer-fine-grained |
11019 | @opindex fno-analyzer-fine-grained | |
ddf6fe37 | 11020 | @item -fanalyzer-fine-grained |
d77de738 ML |
11021 | This option is intended for analyzer developers. |
11022 | ||
11023 | Internally the analyzer builds an ``exploded graph'' that combines | |
11024 | control flow graphs with data flow information. | |
11025 | ||
11026 | By default, an edge in this graph can contain the effects of a run | |
11027 | of multiple statements within a basic block. With | |
11028 | @option{-fanalyzer-fine-grained}, each statement gets its own edge. | |
11029 | ||
d77de738 ML |
11030 | @opindex fanalyzer-show-duplicate-count |
11031 | @opindex fno-analyzer-show-duplicate-count | |
ddf6fe37 | 11032 | @item -fanalyzer-show-duplicate-count |
d77de738 ML |
11033 | This option is intended for analyzer developers: if multiple diagnostics |
11034 | have been detected as being duplicates of each other, it emits a note when | |
11035 | reporting the best diagnostic, giving the number of additional diagnostics | |
11036 | that were suppressed by the deduplication logic. | |
11037 | ||
d77de738 ML |
11038 | @opindex fanalyzer-state-merge |
11039 | @opindex fno-analyzer-state-merge | |
ddf6fe37 | 11040 | @item -fno-analyzer-state-merge |
d77de738 ML |
11041 | This option is intended for analyzer developers. |
11042 | ||
11043 | By default the analyzer attempts to simplify analysis by merging | |
11044 | sufficiently similar states at each program point as it builds its | |
11045 | ``exploded graph''. With @option{-fno-analyzer-state-merge} this | |
11046 | merging can be suppressed, for debugging state-handling issues. | |
11047 | ||
d77de738 ML |
11048 | @opindex fanalyzer-state-purge |
11049 | @opindex fno-analyzer-state-purge | |
ddf6fe37 | 11050 | @item -fno-analyzer-state-purge |
d77de738 ML |
11051 | This option is intended for analyzer developers. |
11052 | ||
11053 | By default the analyzer attempts to simplify analysis by purging | |
11054 | aspects of state at a program point that appear to no longer be relevant | |
11055 | e.g. the values of locals that aren't accessed later in the function | |
11056 | and which aren't relevant to leak analysis. | |
11057 | ||
11058 | With @option{-fno-analyzer-state-purge} this purging of state can | |
11059 | be suppressed, for debugging state-handling issues. | |
11060 | ||
8f636915 DM |
11061 | @opindex fanalyzer-suppress-followups |
11062 | @opindex fno-analyzer-suppress-followups | |
f33d7a88 | 11063 | @item -fno-analyzer-suppress-followups |
8f636915 DM |
11064 | This option is intended for analyzer developers. |
11065 | ||
11066 | By default the analyzer will stop exploring an execution path after | |
11067 | encountering certain diagnostics, in order to avoid potentially issuing a | |
11068 | cascade of follow-up diagnostics. | |
11069 | ||
11070 | The diagnostics that terminate analysis along a path are: | |
11071 | ||
11072 | @itemize | |
11073 | @item @option{-Wanalyzer-null-argument} | |
11074 | @item @option{-Wanalyzer-null-dereference} | |
11075 | @item @option{-Wanalyzer-use-after-free} | |
11076 | @item @option{-Wanalyzer-use-of-pointer-in-stale-stack-frame} | |
11077 | @item @option{-Wanalyzer-use-of-uninitialized-value} | |
11078 | @end itemize | |
11079 | ||
11080 | With @option{-fno-analyzer-suppress-followups} the analyzer will | |
11081 | continue to explore such paths even after such diagnostics, which may | |
11082 | be helpful for debugging issues in the analyzer, or for microbenchmarks | |
11083 | for detecting undefined behavior. | |
11084 | ||
d77de738 ML |
11085 | @opindex fanalyzer-transitivity |
11086 | @opindex fno-analyzer-transitivity | |
ddf6fe37 | 11087 | @item -fanalyzer-transitivity |
d77de738 ML |
11088 | This option enables transitivity of constraints within the analyzer. |
11089 | ||
d77de738 ML |
11090 | @opindex fanalyzer-undo-inlining |
11091 | @opindex fno-analyzer-undo-inlining | |
ddf6fe37 | 11092 | @item -fno-analyzer-undo-inlining |
d77de738 ML |
11093 | This option is intended for analyzer developers. |
11094 | ||
11095 | @option{-fanalyzer} runs relatively late compared to other code analysis | |
11096 | tools, and some optimizations have already been applied to the code. In | |
11097 | particular function inlining may have occurred, leading to the | |
11098 | interprocedural execution paths emitted by the analyzer containing | |
11099 | function frames that don't correspond to those in the original source | |
11100 | code. | |
11101 | ||
11102 | By default the analyzer attempts to reconstruct the original function | |
11103 | frames, and to emit events showing the inlined calls. | |
11104 | ||
11105 | With @option{-fno-analyzer-undo-inlining} this attempt to reconstruct | |
11106 | the original frame information can be be disabled, which may be of help | |
11107 | when debugging issues in the analyzer. | |
11108 | ||
11109 | @item -fanalyzer-verbose-edges | |
11110 | This option is intended for analyzer developers. It enables more | |
11111 | verbose, lower-level detail in the descriptions of control flow | |
11112 | within diagnostic paths. | |
11113 | ||
11114 | @item -fanalyzer-verbose-state-changes | |
11115 | This option is intended for analyzer developers. It enables more | |
11116 | verbose, lower-level detail in the descriptions of events relating | |
11117 | to state machines within diagnostic paths. | |
11118 | ||
11119 | @item -fanalyzer-verbosity=@var{level} | |
11120 | This option controls the complexity of the control flow paths that are | |
11121 | emitted for analyzer diagnostics. | |
11122 | ||
11123 | The @var{level} can be one of: | |
11124 | ||
11125 | @table @samp | |
11126 | @item 0 | |
11127 | At this level, interprocedural call and return events are displayed, | |
11128 | along with the most pertinent state-change events relating to | |
11129 | a diagnostic. For example, for a double-@code{free} diagnostic, | |
11130 | both calls to @code{free} will be shown. | |
11131 | ||
11132 | @item 1 | |
11133 | As per the previous level, but also show events for the entry | |
11134 | to each function. | |
11135 | ||
11136 | @item 2 | |
11137 | As per the previous level, but also show events relating to | |
11138 | control flow that are significant to triggering the issue | |
11139 | (e.g. ``true path taken'' at a conditional). | |
11140 | ||
11141 | This level is the default. | |
11142 | ||
11143 | @item 3 | |
11144 | As per the previous level, but show all control flow events, not | |
11145 | just significant ones. | |
11146 | ||
11147 | @item 4 | |
11148 | This level is intended for analyzer developers; it adds various | |
11149 | other events intended for debugging the analyzer. | |
11150 | ||
11151 | @end table | |
11152 | ||
d77de738 | 11153 | @opindex fdump-analyzer |
ddf6fe37 | 11154 | @item -fdump-analyzer |
d77de738 ML |
11155 | Dump internal details about what the analyzer is doing to |
11156 | @file{@var{file}.analyzer.txt}. | |
4ace81b6 | 11157 | @option{-fdump-analyzer-stderr} overrides this option. |
d77de738 | 11158 | |
d77de738 | 11159 | @opindex fdump-analyzer-stderr |
ddf6fe37 | 11160 | @item -fdump-analyzer-stderr |
d77de738 ML |
11161 | Dump internal details about what the analyzer is doing to stderr. |
11162 | This option overrides @option{-fdump-analyzer}. | |
11163 | ||
d77de738 | 11164 | @opindex fdump-analyzer-callgraph |
ddf6fe37 | 11165 | @item -fdump-analyzer-callgraph |
d77de738 ML |
11166 | Dump a representation of the call graph suitable for viewing with |
11167 | GraphViz to @file{@var{file}.callgraph.dot}. | |
11168 | ||
d77de738 | 11169 | @opindex fdump-analyzer-exploded-graph |
ddf6fe37 | 11170 | @item -fdump-analyzer-exploded-graph |
d77de738 ML |
11171 | Dump a representation of the ``exploded graph'' suitable for viewing with |
11172 | GraphViz to @file{@var{file}.eg.dot}. | |
11173 | Nodes are color-coded based on state-machine states to emphasize | |
11174 | state changes. | |
11175 | ||
d77de738 | 11176 | @opindex dump-analyzer-exploded-nodes |
ddf6fe37 | 11177 | @item -fdump-analyzer-exploded-nodes |
d77de738 ML |
11178 | Emit diagnostics showing where nodes in the ``exploded graph'' are |
11179 | in relation to the program source. | |
11180 | ||
d77de738 | 11181 | @opindex dump-analyzer-exploded-nodes-2 |
ddf6fe37 | 11182 | @item -fdump-analyzer-exploded-nodes-2 |
d77de738 ML |
11183 | Dump a textual representation of the ``exploded graph'' to |
11184 | @file{@var{file}.eg.txt}. | |
11185 | ||
d77de738 | 11186 | @opindex dump-analyzer-exploded-nodes-3 |
ddf6fe37 | 11187 | @item -fdump-analyzer-exploded-nodes-3 |
d77de738 ML |
11188 | Dump a textual representation of the ``exploded graph'' to |
11189 | one dump file per node, to @file{@var{file}.eg-@var{id}.txt}. | |
11190 | This is typically a large number of dump files. | |
11191 | ||
d77de738 | 11192 | @opindex fdump-analyzer-exploded-paths |
ddf6fe37 | 11193 | @item -fdump-analyzer-exploded-paths |
d77de738 ML |
11194 | Dump a textual representation of the ``exploded path'' for each |
11195 | diagnostic to @file{@var{file}.@var{idx}.@var{kind}.epath.txt}. | |
11196 | ||
d77de738 | 11197 | @opindex dump-analyzer-feasibility |
ddf6fe37 | 11198 | @item -fdump-analyzer-feasibility |
d77de738 ML |
11199 | Dump internal details about the analyzer's search for feasible paths. |
11200 | The details are written in a form suitable for viewing with GraphViz | |
11201 | to filenames of the form @file{@var{file}.*.fg.dot}, | |
11202 | @file{@var{file}.*.tg.dot}, and @file{@var{file}.*.fpath.txt}. | |
11203 | ||
d77de738 | 11204 | @opindex fdump-analyzer-json |
ddf6fe37 | 11205 | @item -fdump-analyzer-json |
d77de738 ML |
11206 | Dump a compressed JSON representation of analyzer internals to |
11207 | @file{@var{file}.analyzer.json.gz}. The precise format is subject | |
11208 | to change. | |
11209 | ||
d77de738 | 11210 | @opindex fdump-analyzer-state-purge |
ddf6fe37 | 11211 | @item -fdump-analyzer-state-purge |
d77de738 ML |
11212 | As per @option{-fdump-analyzer-supergraph}, dump a representation of the |
11213 | ``supergraph'' suitable for viewing with GraphViz, but annotate the | |
11214 | graph with information on what state will be purged at each node. | |
11215 | The graph is written to @file{@var{file}.state-purge.dot}. | |
11216 | ||
d77de738 | 11217 | @opindex fdump-analyzer-supergraph |
ddf6fe37 | 11218 | @item -fdump-analyzer-supergraph |
d77de738 ML |
11219 | Dump representations of the ``supergraph'' suitable for viewing with |
11220 | GraphViz to @file{@var{file}.supergraph.dot} and to | |
11221 | @file{@var{file}.supergraph-eg.dot}. These show all of the | |
11222 | control flow graphs in the program, with interprocedural edges for | |
11223 | calls and returns. The second dump contains annotations showing nodes | |
11224 | in the ``exploded graph'' and diagnostics associated with them. | |
11225 | ||
d77de738 | 11226 | @opindex fdump-analyzer-untracked |
ddf6fe37 | 11227 | @item -fdump-analyzer-untracked |
d77de738 ML |
11228 | Emit custom warnings with internal details intended for analyzer developers. |
11229 | ||
11230 | @end table | |
11231 | ||
11232 | @node Debugging Options | |
11233 | @section Options for Debugging Your Program | |
11234 | @cindex options, debugging | |
11235 | @cindex debugging information options | |
11236 | ||
11237 | To tell GCC to emit extra information for use by a debugger, in almost | |
11238 | all cases you need only to add @option{-g} to your other options. Some debug | |
11239 | formats can co-exist (like DWARF with CTF) when each of them is enabled | |
11240 | explicitly by adding the respective command line option to your other options. | |
11241 | ||
11242 | GCC allows you to use @option{-g} with | |
11243 | @option{-O}. The shortcuts taken by optimized code may occasionally | |
11244 | be surprising: some variables you declared may not exist | |
11245 | at all; flow of control may briefly move where you did not expect it; | |
11246 | some statements may not be executed because they compute constant | |
11247 | results or their values are already at hand; some statements may | |
11248 | execute in different places because they have been moved out of loops. | |
11249 | Nevertheless it is possible to debug optimized output. This makes | |
11250 | it reasonable to use the optimizer for programs that might have bugs. | |
11251 | ||
11252 | If you are not using some other optimization option, consider | |
11253 | using @option{-Og} (@pxref{Optimize Options}) with @option{-g}. | |
11254 | With no @option{-O} option at all, some compiler passes that collect | |
11255 | information useful for debugging do not run at all, so that | |
11256 | @option{-Og} may result in a better debugging experience. | |
11257 | ||
11258 | @table @gcctabopt | |
d77de738 | 11259 | @opindex g |
ddf6fe37 | 11260 | @item -g |
d77de738 ML |
11261 | Produce debugging information in the operating system's native format |
11262 | (stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging | |
11263 | information. | |
11264 | ||
11265 | On most systems that use stabs format, @option{-g} enables use of extra | |
11266 | debugging information that only GDB can use; this extra information | |
11267 | makes debugging work better in GDB but probably makes other debuggers | |
11268 | crash or refuse to read the program. If you want to control for certain whether | |
11269 | to generate the extra information, use @option{-gvms} (see below). | |
11270 | ||
d77de738 | 11271 | @opindex ggdb |
ddf6fe37 | 11272 | @item -ggdb |
d77de738 ML |
11273 | Produce debugging information for use by GDB@. This means to use the |
11274 | most expressive format available (DWARF, stabs, or the native format | |
11275 | if neither of those are supported), including GDB extensions if at all | |
11276 | possible. | |
11277 | ||
ddf6fe37 | 11278 | @opindex gdwarf |
d77de738 ML |
11279 | @item -gdwarf |
11280 | @itemx -gdwarf-@var{version} | |
d77de738 ML |
11281 | Produce debugging information in DWARF format (if that is supported). |
11282 | The value of @var{version} may be either 2, 3, 4 or 5; the default | |
11283 | version for most targets is 5 (with the exception of VxWorks, TPF and | |
11284 | Darwin/Mac OS X, which default to version 2, and AIX, which defaults | |
11285 | to version 4). | |
11286 | ||
11287 | Note that with DWARF Version 2, some ports require and always | |
11288 | use some non-conflicting DWARF 3 extensions in the unwind tables. | |
11289 | ||
11290 | Version 4 may require GDB 7.0 and @option{-fvar-tracking-assignments} | |
11291 | for maximum benefit. Version 5 requires GDB 8.0 or higher. | |
11292 | ||
11293 | GCC no longer supports DWARF Version 1, which is substantially | |
11294 | different than Version 2 and later. For historical reasons, some | |
11295 | other DWARF-related options such as | |
11296 | @option{-fno-dwarf2-cfi-asm}) retain a reference to DWARF Version 2 | |
11297 | in their names, but apply to all currently-supported versions of DWARF. | |
11298 | ||
d77de738 | 11299 | @opindex gbtf |
ddf6fe37 | 11300 | @item -gbtf |
d77de738 ML |
11301 | Request BTF debug information. BTF is the default debugging format for the |
11302 | eBPF target. On other targets, like x86, BTF debug information can be | |
11303 | generated along with DWARF debug information when both of the debug formats are | |
11304 | enabled explicitly via their respective command line options. | |
11305 | ||
ddf6fe37 | 11306 | @opindex gctf |
d77de738 ML |
11307 | @item -gctf |
11308 | @itemx -gctf@var{level} | |
d77de738 ML |
11309 | Request CTF debug information and use level to specify how much CTF debug |
11310 | information should be produced. If @option{-gctf} is specified | |
11311 | without a value for level, the default level of CTF debug information is 2. | |
11312 | ||
11313 | CTF debug information can be generated along with DWARF debug information when | |
11314 | both of the debug formats are enabled explicitly via their respective command | |
11315 | line options. | |
11316 | ||
11317 | Level 0 produces no CTF debug information at all. Thus, @option{-gctf0} | |
11318 | negates @option{-gctf}. | |
11319 | ||
11320 | Level 1 produces CTF information for tracebacks only. This includes callsite | |
11321 | information, but does not include type information. | |
11322 | ||
11323 | Level 2 produces type information for entities (functions, data objects etc.) | |
11324 | at file-scope or global-scope only. | |
11325 | ||
d77de738 | 11326 | @opindex gvms |
ddf6fe37 | 11327 | @item -gvms |
d77de738 ML |
11328 | Produce debugging information in Alpha/VMS debug format (if that is |
11329 | supported). This is the format used by DEBUG on Alpha/VMS systems. | |
11330 | ||
11331 | @item -g@var{level} | |
11332 | @itemx -ggdb@var{level} | |
11333 | @itemx -gvms@var{level} | |
11334 | Request debugging information and also use @var{level} to specify how | |
11335 | much information. The default level is 2. | |
11336 | ||
11337 | Level 0 produces no debug information at all. Thus, @option{-g0} negates | |
11338 | @option{-g}. | |
11339 | ||
11340 | Level 1 produces minimal information, enough for making backtraces in | |
11341 | parts of the program that you don't plan to debug. This includes | |
11342 | descriptions of functions and external variables, and line number | |
11343 | tables, but no information about local variables. | |
11344 | ||
11345 | Level 3 includes extra information, such as all the macro definitions | |
11346 | present in the program. Some debuggers support macro expansion when | |
11347 | you use @option{-g3}. | |
11348 | ||
11349 | If you use multiple @option{-g} options, with or without level numbers, | |
11350 | the last such option is the one that is effective. | |
11351 | ||
11352 | @option{-gdwarf} does not accept a concatenated debug level, to avoid | |
11353 | confusion with @option{-gdwarf-@var{level}}. | |
11354 | Instead use an additional @option{-g@var{level}} option to change the | |
11355 | debug level for DWARF. | |
11356 | ||
d77de738 ML |
11357 | @opindex feliminate-unused-debug-symbols |
11358 | @opindex fno-eliminate-unused-debug-symbols | |
ddf6fe37 | 11359 | @item -fno-eliminate-unused-debug-symbols |
d77de738 ML |
11360 | By default, no debug information is produced for symbols that are not actually |
11361 | used. Use this option if you want debug information for all symbols. | |
11362 | ||
d77de738 | 11363 | @opindex femit-class-debug-always |
ddf6fe37 | 11364 | @item -femit-class-debug-always |
d77de738 ML |
11365 | Instead of emitting debugging information for a C++ class in only one |
11366 | object file, emit it in all object files using the class. This option | |
11367 | should be used only with debuggers that are unable to handle the way GCC | |
11368 | normally emits debugging information for classes because using this | |
11369 | option increases the size of debugging information by as much as a | |
11370 | factor of two. | |
11371 | ||
d77de738 ML |
11372 | @opindex fmerge-debug-strings |
11373 | @opindex fno-merge-debug-strings | |
ddf6fe37 | 11374 | @item -fno-merge-debug-strings |
d77de738 ML |
11375 | Direct the linker to not merge together strings in the debugging |
11376 | information that are identical in different object files. Merging is | |
11377 | not supported by all assemblers or linkers. Merging decreases the size | |
11378 | of the debug information in the output file at the cost of increasing | |
11379 | link processing time. Merging is enabled by default. | |
11380 | ||
d77de738 | 11381 | @opindex fdebug-prefix-map |
ddf6fe37 | 11382 | @item -fdebug-prefix-map=@var{old}=@var{new} |
d77de738 ML |
11383 | When compiling files residing in directory @file{@var{old}}, record |
11384 | debugging information describing them as if the files resided in | |
11385 | directory @file{@var{new}} instead. This can be used to replace a | |
11386 | build-time path with an install-time path in the debug info. It can | |
11387 | also be used to change an absolute path to a relative path by using | |
11388 | @file{.} for @var{new}. This can give more reproducible builds, which | |
11389 | are location independent, but may require an extra command to tell GDB | |
2eb0191a JJ |
11390 | where to find the source files. See also @option{-ffile-prefix-map} |
11391 | and @option{-fcanon-prefix-map}. | |
d77de738 | 11392 | |
d77de738 | 11393 | @opindex fvar-tracking |
ddf6fe37 | 11394 | @item -fvar-tracking |
d77de738 ML |
11395 | Run variable tracking pass. It computes where variables are stored at each |
11396 | position in code. Better debugging information is then generated | |
11397 | (if the debugging information format supports this information). | |
11398 | ||
11399 | It is enabled by default when compiling with optimization (@option{-Os}, | |
11400 | @option{-O}, @option{-O2}, @dots{}), debugging information (@option{-g}) and | |
11401 | the debug info format supports it. | |
11402 | ||
d77de738 ML |
11403 | @opindex fvar-tracking-assignments |
11404 | @opindex fno-var-tracking-assignments | |
ddf6fe37 | 11405 | @item -fvar-tracking-assignments |
d77de738 ML |
11406 | Annotate assignments to user variables early in the compilation and |
11407 | attempt to carry the annotations over throughout the compilation all the | |
11408 | way to the end, in an attempt to improve debug information while | |
11409 | optimizing. Use of @option{-gdwarf-4} is recommended along with it. | |
11410 | ||
11411 | It can be enabled even if var-tracking is disabled, in which case | |
11412 | annotations are created and maintained, but discarded at the end. | |
11413 | By default, this flag is enabled together with @option{-fvar-tracking}, | |
11414 | except when selective scheduling is enabled. | |
11415 | ||
d77de738 | 11416 | @opindex gsplit-dwarf |
ddf6fe37 | 11417 | @item -gsplit-dwarf |
d77de738 ML |
11418 | If DWARF debugging information is enabled, separate as much debugging |
11419 | information as possible into a separate output file with the extension | |
11420 | @file{.dwo}. This option allows the build system to avoid linking files with | |
11421 | debug information. To be useful, this option requires a debugger capable of | |
11422 | reading @file{.dwo} files. | |
11423 | ||
d77de738 ML |
11424 | @opindex gdwarf32 |
11425 | @opindex gdwarf64 | |
ddf6fe37 AA |
11426 | @item -gdwarf32 |
11427 | @itemx -gdwarf64 | |
d77de738 ML |
11428 | If DWARF debugging information is enabled, the @option{-gdwarf32} selects |
11429 | the 32-bit DWARF format and the @option{-gdwarf64} selects the 64-bit | |
11430 | DWARF format. The default is target specific, on most targets it is | |
11431 | @option{-gdwarf32} though. The 32-bit DWARF format is smaller, but | |
11432 | can't support more than 2GiB of debug information in any of the DWARF | |
11433 | debug information sections. The 64-bit DWARF format allows larger debug | |
11434 | information and might not be well supported by all consumers yet. | |
11435 | ||
d77de738 | 11436 | @opindex gdescribe-dies |
ddf6fe37 | 11437 | @item -gdescribe-dies |
d77de738 ML |
11438 | Add description attributes to some DWARF DIEs that have no name attribute, |
11439 | such as artificial variables, external references and call site | |
11440 | parameter DIEs. | |
11441 | ||
d77de738 | 11442 | @opindex gpubnames |
ddf6fe37 | 11443 | @item -gpubnames |
d77de738 ML |
11444 | Generate DWARF @code{.debug_pubnames} and @code{.debug_pubtypes} sections. |
11445 | ||
d77de738 | 11446 | @opindex ggnu-pubnames |
ddf6fe37 | 11447 | @item -ggnu-pubnames |
d77de738 ML |
11448 | Generate @code{.debug_pubnames} and @code{.debug_pubtypes} sections in a format |
11449 | suitable for conversion into a GDB@ index. This option is only useful | |
11450 | with a linker that can produce GDB@ index version 7. | |
11451 | ||
d77de738 ML |
11452 | @opindex fdebug-types-section |
11453 | @opindex fno-debug-types-section | |
ddf6fe37 | 11454 | @item -fdebug-types-section |
d77de738 ML |
11455 | When using DWARF Version 4 or higher, type DIEs can be put into |
11456 | their own @code{.debug_types} section instead of making them part of the | |
11457 | @code{.debug_info} section. It is more efficient to put them in a separate | |
11458 | comdat section since the linker can then remove duplicates. | |
11459 | But not all DWARF consumers support @code{.debug_types} sections yet | |
11460 | and on some objects @code{.debug_types} produces larger instead of smaller | |
11461 | debugging information. | |
11462 | ||
d77de738 ML |
11463 | @opindex grecord-gcc-switches |
11464 | @opindex gno-record-gcc-switches | |
ddf6fe37 AA |
11465 | @item -grecord-gcc-switches |
11466 | @itemx -gno-record-gcc-switches | |
d77de738 ML |
11467 | This switch causes the command-line options used to invoke the |
11468 | compiler that may affect code generation to be appended to the | |
11469 | DW_AT_producer attribute in DWARF debugging information. The options | |
11470 | are concatenated with spaces separating them from each other and from | |
11471 | the compiler version. | |
11472 | It is enabled by default. | |
11473 | See also @option{-frecord-gcc-switches} for another | |
11474 | way of storing compiler options into the object file. | |
11475 | ||
d77de738 | 11476 | @opindex gstrict-dwarf |
ddf6fe37 | 11477 | @item -gstrict-dwarf |
d77de738 ML |
11478 | Disallow using extensions of later DWARF standard version than selected |
11479 | with @option{-gdwarf-@var{version}}. On most targets using non-conflicting | |
11480 | DWARF extensions from later standard versions is allowed. | |
11481 | ||
d77de738 | 11482 | @opindex gno-strict-dwarf |
ddf6fe37 | 11483 | @item -gno-strict-dwarf |
d77de738 ML |
11484 | Allow using extensions of later DWARF standard version than selected with |
11485 | @option{-gdwarf-@var{version}}. | |
11486 | ||
d77de738 | 11487 | @opindex gas-loc-support |
ddf6fe37 | 11488 | @item -gas-loc-support |
d77de738 ML |
11489 | Inform the compiler that the assembler supports @code{.loc} directives. |
11490 | It may then use them for the assembler to generate DWARF2+ line number | |
11491 | tables. | |
11492 | ||
11493 | This is generally desirable, because assembler-generated line-number | |
11494 | tables are a lot more compact than those the compiler can generate | |
11495 | itself. | |
11496 | ||
11497 | This option will be enabled by default if, at GCC configure time, the | |
11498 | assembler was found to support such directives. | |
11499 | ||
d77de738 | 11500 | @opindex gno-as-loc-support |
ddf6fe37 | 11501 | @item -gno-as-loc-support |
d77de738 ML |
11502 | Force GCC to generate DWARF2+ line number tables internally, if DWARF2+ |
11503 | line number tables are to be generated. | |
11504 | ||
d77de738 | 11505 | @opindex gas-locview-support |
ddf6fe37 | 11506 | @item -gas-locview-support |
d77de738 ML |
11507 | Inform the compiler that the assembler supports @code{view} assignment |
11508 | and reset assertion checking in @code{.loc} directives. | |
11509 | ||
11510 | This option will be enabled by default if, at GCC configure time, the | |
11511 | assembler was found to support them. | |
11512 | ||
11513 | @item -gno-as-locview-support | |
11514 | Force GCC to assign view numbers internally, if | |
11515 | @option{-gvariable-location-views} are explicitly requested. | |
11516 | ||
d77de738 ML |
11517 | @opindex gcolumn-info |
11518 | @opindex gno-column-info | |
ddf6fe37 AA |
11519 | @item -gcolumn-info |
11520 | @itemx -gno-column-info | |
d77de738 ML |
11521 | Emit location column information into DWARF debugging information, rather |
11522 | than just file and line. | |
11523 | This option is enabled by default. | |
11524 | ||
d77de738 ML |
11525 | @opindex gstatement-frontiers |
11526 | @opindex gno-statement-frontiers | |
ddf6fe37 AA |
11527 | @item -gstatement-frontiers |
11528 | @itemx -gno-statement-frontiers | |
d77de738 ML |
11529 | This option causes GCC to create markers in the internal representation |
11530 | at the beginning of statements, and to keep them roughly in place | |
11531 | throughout compilation, using them to guide the output of @code{is_stmt} | |
11532 | markers in the line number table. This is enabled by default when | |
11533 | compiling with optimization (@option{-Os}, @option{-O1}, @option{-O2}, | |
11534 | @dots{}), and outputting DWARF 2 debug information at the normal level. | |
11535 | ||
d77de738 ML |
11536 | @opindex gvariable-location-views |
11537 | @opindex gvariable-location-views=incompat5 | |
11538 | @opindex gno-variable-location-views | |
ddf6fe37 AA |
11539 | @item -gvariable-location-views |
11540 | @itemx -gvariable-location-views=incompat5 | |
11541 | @itemx -gno-variable-location-views | |
d77de738 ML |
11542 | Augment variable location lists with progressive view numbers implied |
11543 | from the line number table. This enables debug information consumers to | |
11544 | inspect state at certain points of the program, even if no instructions | |
11545 | associated with the corresponding source locations are present at that | |
11546 | point. If the assembler lacks support for view numbers in line number | |
11547 | tables, this will cause the compiler to emit the line number table, | |
11548 | which generally makes them somewhat less compact. The augmented line | |
11549 | number tables and location lists are fully backward-compatible, so they | |
11550 | can be consumed by debug information consumers that are not aware of | |
11551 | these augmentations, but they won't derive any benefit from them either. | |
11552 | ||
11553 | This is enabled by default when outputting DWARF 2 debug information at | |
11554 | the normal level, as long as there is assembler support, | |
11555 | @option{-fvar-tracking-assignments} is enabled and | |
11556 | @option{-gstrict-dwarf} is not. When assembler support is not | |
11557 | available, this may still be enabled, but it will force GCC to output | |
11558 | internal line number tables, and if | |
11559 | @option{-ginternal-reset-location-views} is not enabled, that will most | |
11560 | certainly lead to silently mismatching location views. | |
11561 | ||
11562 | There is a proposed representation for view numbers that is not backward | |
11563 | compatible with the location list format introduced in DWARF 5, that can | |
11564 | be enabled with @option{-gvariable-location-views=incompat5}. This | |
11565 | option may be removed in the future, is only provided as a reference | |
11566 | implementation of the proposed representation. Debug information | |
11567 | consumers are not expected to support this extended format, and they | |
11568 | would be rendered unable to decode location lists using it. | |
11569 | ||
d77de738 ML |
11570 | @opindex ginternal-reset-location-views |
11571 | @opindex gno-internal-reset-location-views | |
ddf6fe37 AA |
11572 | @item -ginternal-reset-location-views |
11573 | @itemx -gno-internal-reset-location-views | |
d77de738 ML |
11574 | Attempt to determine location views that can be omitted from location |
11575 | view lists. This requires the compiler to have very accurate insn | |
11576 | length estimates, which isn't always the case, and it may cause | |
11577 | incorrect view lists to be generated silently when using an assembler | |
11578 | that does not support location view lists. The GNU assembler will flag | |
11579 | any such error as a @code{view number mismatch}. This is only enabled | |
11580 | on ports that define a reliable estimation function. | |
11581 | ||
d77de738 ML |
11582 | @opindex ginline-points |
11583 | @opindex gno-inline-points | |
ddf6fe37 AA |
11584 | @item -ginline-points |
11585 | @itemx -gno-inline-points | |
d77de738 ML |
11586 | Generate extended debug information for inlined functions. Location |
11587 | view tracking markers are inserted at inlined entry points, so that | |
11588 | address and view numbers can be computed and output in debug | |
11589 | information. This can be enabled independently of location views, in | |
11590 | which case the view numbers won't be output, but it can only be enabled | |
11591 | along with statement frontiers, and it is only enabled by default if | |
11592 | location views are enabled. | |
11593 | ||
d77de738 | 11594 | @opindex gz |
ddf6fe37 | 11595 | @item -gz@r{[}=@var{type}@r{]} |
d77de738 ML |
11596 | Produce compressed debug sections in DWARF format, if that is supported. |
11597 | If @var{type} is not given, the default type depends on the capabilities | |
11598 | of the assembler and linker used. @var{type} may be one of | |
11599 | @samp{none} (don't compress debug sections), or @samp{zlib} (use zlib | |
11600 | compression in ELF gABI format). If the linker doesn't support writing | |
11601 | compressed debug sections, the option is rejected. Otherwise, if the | |
11602 | assembler does not support them, @option{-gz} is silently ignored when | |
11603 | producing object files. | |
11604 | ||
d77de738 | 11605 | @opindex femit-struct-debug-baseonly |
ddf6fe37 | 11606 | @item -femit-struct-debug-baseonly |
d77de738 ML |
11607 | Emit debug information for struct-like types |
11608 | only when the base name of the compilation source file | |
11609 | matches the base name of file in which the struct is defined. | |
11610 | ||
11611 | This option substantially reduces the size of debugging information, | |
11612 | but at significant potential loss in type information to the debugger. | |
11613 | See @option{-femit-struct-debug-reduced} for a less aggressive option. | |
11614 | See @option{-femit-struct-debug-detailed} for more detailed control. | |
11615 | ||
11616 | This option works only with DWARF debug output. | |
11617 | ||
d77de738 | 11618 | @opindex femit-struct-debug-reduced |
ddf6fe37 | 11619 | @item -femit-struct-debug-reduced |
d77de738 ML |
11620 | Emit debug information for struct-like types |
11621 | only when the base name of the compilation source file | |
11622 | matches the base name of file in which the type is defined, | |
11623 | unless the struct is a template or defined in a system header. | |
11624 | ||
11625 | This option significantly reduces the size of debugging information, | |
11626 | with some potential loss in type information to the debugger. | |
11627 | See @option{-femit-struct-debug-baseonly} for a more aggressive option. | |
11628 | See @option{-femit-struct-debug-detailed} for more detailed control. | |
11629 | ||
11630 | This option works only with DWARF debug output. | |
11631 | ||
d77de738 | 11632 | @opindex femit-struct-debug-detailed |
ddf6fe37 | 11633 | @item -femit-struct-debug-detailed@r{[}=@var{spec-list}@r{]} |
d77de738 ML |
11634 | Specify the struct-like types |
11635 | for which the compiler generates debug information. | |
11636 | The intent is to reduce duplicate struct debug information | |
11637 | between different object files within the same program. | |
11638 | ||
11639 | This option is a detailed version of | |
11640 | @option{-femit-struct-debug-reduced} and @option{-femit-struct-debug-baseonly}, | |
11641 | which serves for most needs. | |
11642 | ||
11643 | A specification has the syntax@* | |
11644 | [@samp{dir:}|@samp{ind:}][@samp{ord:}|@samp{gen:}](@samp{any}|@samp{sys}|@samp{base}|@samp{none}) | |
11645 | ||
11646 | The optional first word limits the specification to | |
11647 | structs that are used directly (@samp{dir:}) or used indirectly (@samp{ind:}). | |
11648 | A struct type is used directly when it is the type of a variable, member. | |
11649 | Indirect uses arise through pointers to structs. | |
11650 | That is, when use of an incomplete struct is valid, the use is indirect. | |
11651 | An example is | |
11652 | @samp{struct one direct; struct two * indirect;}. | |
11653 | ||
11654 | The optional second word limits the specification to | |
11655 | ordinary structs (@samp{ord:}) or generic structs (@samp{gen:}). | |
11656 | Generic structs are a bit complicated to explain. | |
11657 | For C++, these are non-explicit specializations of template classes, | |
11658 | or non-template classes within the above. | |
11659 | Other programming languages have generics, | |
11660 | but @option{-femit-struct-debug-detailed} does not yet implement them. | |
11661 | ||
11662 | The third word specifies the source files for those | |
11663 | structs for which the compiler should emit debug information. | |
11664 | The values @samp{none} and @samp{any} have the normal meaning. | |
11665 | The value @samp{base} means that | |
11666 | the base of name of the file in which the type declaration appears | |
11667 | must match the base of the name of the main compilation file. | |
11668 | In practice, this means that when compiling @file{foo.c}, debug information | |
11669 | is generated for types declared in that file and @file{foo.h}, | |
11670 | but not other header files. | |
11671 | The value @samp{sys} means those types satisfying @samp{base} | |
11672 | or declared in system or compiler headers. | |
11673 | ||
11674 | You may need to experiment to determine the best settings for your application. | |
11675 | ||
11676 | The default is @option{-femit-struct-debug-detailed=all}. | |
11677 | ||
11678 | This option works only with DWARF debug output. | |
11679 | ||
d77de738 ML |
11680 | @opindex fdwarf2-cfi-asm |
11681 | @opindex fno-dwarf2-cfi-asm | |
ddf6fe37 | 11682 | @item -fno-dwarf2-cfi-asm |
d77de738 ML |
11683 | Emit DWARF unwind info as compiler generated @code{.eh_frame} section |
11684 | instead of using GAS @code{.cfi_*} directives. | |
11685 | ||
d77de738 ML |
11686 | @opindex feliminate-unused-debug-types |
11687 | @opindex fno-eliminate-unused-debug-types | |
ddf6fe37 | 11688 | @item -fno-eliminate-unused-debug-types |
d77de738 ML |
11689 | Normally, when producing DWARF output, GCC avoids producing debug symbol |
11690 | output for types that are nowhere used in the source file being compiled. | |
11691 | Sometimes it is useful to have GCC emit debugging | |
11692 | information for all types declared in a compilation | |
11693 | unit, regardless of whether or not they are actually used | |
11694 | in that compilation unit, for example | |
11695 | if, in the debugger, you want to cast a value to a type that is | |
11696 | not actually used in your program (but is declared). More often, | |
11697 | however, this results in a significant amount of wasted space. | |
11698 | @end table | |
11699 | ||
11700 | @node Optimize Options | |
11701 | @section Options That Control Optimization | |
11702 | @cindex optimize options | |
11703 | @cindex options, optimization | |
11704 | ||
11705 | These options control various sorts of optimizations. | |
11706 | ||
11707 | Without any optimization option, the compiler's goal is to reduce the | |
11708 | cost of compilation and to make debugging produce the expected | |
11709 | results. Statements are independent: if you stop the program with a | |
11710 | breakpoint between statements, you can then assign a new value to any | |
11711 | variable or change the program counter to any other statement in the | |
11712 | function and get exactly the results you expect from the source | |
11713 | code. | |
11714 | ||
11715 | Turning on optimization flags makes the compiler attempt to improve | |
11716 | the performance and/or code size at the expense of compilation time | |
11717 | and possibly the ability to debug the program. | |
11718 | ||
11719 | The compiler performs optimization based on the knowledge it has of the | |
11720 | program. Compiling multiple files at once to a single output file mode allows | |
11721 | the compiler to use information gained from all of the files when compiling | |
11722 | each of them. | |
11723 | ||
11724 | Not all optimizations are controlled directly by a flag. Only | |
11725 | optimizations that have a flag are listed in this section. | |
11726 | ||
11727 | Most optimizations are completely disabled at @option{-O0} or if an | |
11728 | @option{-O} level is not set on the command line, even if individual | |
11729 | optimization flags are specified. Similarly, @option{-Og} suppresses | |
11730 | many optimization passes. | |
11731 | ||
11732 | Depending on the target and how GCC was configured, a slightly different | |
11733 | set of optimizations may be enabled at each @option{-O} level than | |
11734 | those listed here. You can invoke GCC with @option{-Q --help=optimizers} | |
11735 | to find out the exact set of optimizations that are enabled at each level. | |
11736 | @xref{Overall Options}, for examples. | |
11737 | ||
11738 | @table @gcctabopt | |
d77de738 ML |
11739 | @opindex O |
11740 | @opindex O1 | |
ddf6fe37 AA |
11741 | @item -O |
11742 | @itemx -O1 | |
d77de738 ML |
11743 | Optimize. Optimizing compilation takes somewhat more time, and a lot |
11744 | more memory for a large function. | |
11745 | ||
11746 | With @option{-O}, the compiler tries to reduce code size and execution | |
11747 | time, without performing any optimizations that take a great deal of | |
11748 | compilation time. | |
11749 | ||
11750 | @c Note that in addition to the default_options_table list in opts.cc, | |
11751 | @c several optimization flags default to true but control optimization | |
11752 | @c passes that are explicitly disabled at -O0. | |
11753 | ||
11754 | @option{-O} turns on the following optimization flags: | |
11755 | ||
11756 | @c Please keep the following list alphabetized. | |
43b72ede AA |
11757 | @gccoptlist{-fauto-inc-dec |
11758 | -fbranch-count-reg | |
11759 | -fcombine-stack-adjustments | |
11760 | -fcompare-elim | |
11761 | -fcprop-registers | |
11762 | -fdce | |
11763 | -fdefer-pop | |
11764 | -fdelayed-branch | |
11765 | -fdse | |
11766 | -fforward-propagate | |
11767 | -fguess-branch-probability | |
11768 | -fif-conversion | |
11769 | -fif-conversion2 | |
11770 | -finline-functions-called-once | |
11771 | -fipa-modref | |
11772 | -fipa-profile | |
11773 | -fipa-pure-const | |
11774 | -fipa-reference | |
11775 | -fipa-reference-addressable | |
11776 | -fmerge-constants | |
11777 | -fmove-loop-invariants | |
11778 | -fmove-loop-stores | |
11779 | -fomit-frame-pointer | |
11780 | -freorder-blocks | |
11781 | -fshrink-wrap | |
11782 | -fshrink-wrap-separate | |
11783 | -fsplit-wide-types | |
11784 | -fssa-backprop | |
11785 | -fssa-phiopt | |
11786 | -ftree-bit-ccp | |
11787 | -ftree-ccp | |
11788 | -ftree-ch | |
11789 | -ftree-coalesce-vars | |
11790 | -ftree-copy-prop | |
11791 | -ftree-dce | |
11792 | -ftree-dominator-opts | |
11793 | -ftree-dse | |
11794 | -ftree-forwprop | |
11795 | -ftree-fre | |
11796 | -ftree-phiprop | |
11797 | -ftree-pta | |
11798 | -ftree-scev-cprop | |
11799 | -ftree-sink | |
11800 | -ftree-slsr | |
11801 | -ftree-sra | |
11802 | -ftree-ter | |
d77de738 ML |
11803 | -funit-at-a-time} |
11804 | ||
d77de738 | 11805 | @opindex O2 |
ddf6fe37 | 11806 | @item -O2 |
d77de738 ML |
11807 | Optimize even more. GCC performs nearly all supported optimizations |
11808 | that do not involve a space-speed tradeoff. | |
11809 | As compared to @option{-O}, this option increases both compilation time | |
11810 | and the performance of the generated code. | |
11811 | ||
11812 | @option{-O2} turns on all optimization flags specified by @option{-O1}. It | |
11813 | also turns on the following optimization flags: | |
11814 | ||
11815 | @c Please keep the following list alphabetized! | |
43b72ede AA |
11816 | @gccoptlist{-falign-functions -falign-jumps |
11817 | -falign-labels -falign-loops | |
11818 | -fcaller-saves | |
11819 | -fcode-hoisting | |
11820 | -fcrossjumping | |
11821 | -fcse-follow-jumps -fcse-skip-blocks | |
11822 | -fdelete-null-pointer-checks | |
11823 | -fdevirtualize -fdevirtualize-speculatively | |
11824 | -fexpensive-optimizations | |
11825 | -ffinite-loops | |
11826 | -fgcse -fgcse-lm | |
11827 | -fhoist-adjacent-loads | |
11828 | -finline-functions | |
11829 | -finline-small-functions | |
11830 | -findirect-inlining | |
11831 | -fipa-bit-cp -fipa-cp -fipa-icf | |
11832 | -fipa-ra -fipa-sra -fipa-vrp | |
11833 | -fisolate-erroneous-paths-dereference | |
11834 | -flra-remat | |
11835 | -foptimize-sibling-calls | |
11836 | -foptimize-strlen | |
11837 | -fpartial-inlining | |
11838 | -fpeephole2 | |
11839 | -freorder-blocks-algorithm=stc | |
11840 | -freorder-blocks-and-partition -freorder-functions | |
11841 | -frerun-cse-after-loop | |
11842 | -fschedule-insns -fschedule-insns2 | |
11843 | -fsched-interblock -fsched-spec | |
11844 | -fstore-merging | |
11845 | -fstrict-aliasing | |
11846 | -fthread-jumps | |
11847 | -ftree-builtin-call-dce | |
11848 | -ftree-loop-vectorize | |
11849 | -ftree-pre | |
11850 | -ftree-slp-vectorize | |
11851 | -ftree-switch-conversion -ftree-tail-merge | |
11852 | -ftree-vrp | |
d77de738 ML |
11853 | -fvect-cost-model=very-cheap} |
11854 | ||
11855 | Please note the warning under @option{-fgcse} about | |
11856 | invoking @option{-O2} on programs that use computed gotos. | |
11857 | ||
d77de738 | 11858 | @opindex O3 |
ddf6fe37 | 11859 | @item -O3 |
d77de738 ML |
11860 | Optimize yet more. @option{-O3} turns on all optimizations specified |
11861 | by @option{-O2} and also turns on the following optimization flags: | |
11862 | ||
11863 | @c Please keep the following list alphabetized! | |
43b72ede | 11864 | @gccoptlist{-fgcse-after-reload |
d77de738 | 11865 | -fipa-cp-clone |
43b72ede AA |
11866 | -floop-interchange |
11867 | -floop-unroll-and-jam | |
11868 | -fpeel-loops | |
11869 | -fpredictive-commoning | |
11870 | -fsplit-loops | |
11871 | -fsplit-paths | |
11872 | -ftree-loop-distribution | |
11873 | -ftree-partial-pre | |
11874 | -funswitch-loops | |
11875 | -fvect-cost-model=dynamic | |
d77de738 ML |
11876 | -fversion-loops-for-strides} |
11877 | ||
d77de738 | 11878 | @opindex O0 |
ddf6fe37 | 11879 | @item -O0 |
d77de738 ML |
11880 | Reduce compilation time and make debugging produce the expected |
11881 | results. This is the default. | |
11882 | ||
d77de738 | 11883 | @opindex Os |
ddf6fe37 | 11884 | @item -Os |
d77de738 ML |
11885 | Optimize for size. @option{-Os} enables all @option{-O2} optimizations |
11886 | except those that often increase code size: | |
11887 | ||
43b72ede AA |
11888 | @gccoptlist{-falign-functions -falign-jumps |
11889 | -falign-labels -falign-loops | |
d77de738 ML |
11890 | -fprefetch-loop-arrays -freorder-blocks-algorithm=stc} |
11891 | ||
11892 | It also enables @option{-finline-functions}, causes the compiler to tune for | |
11893 | code size rather than execution speed, and performs further optimizations | |
11894 | designed to reduce code size. | |
11895 | ||
d77de738 | 11896 | @opindex Ofast |
ddf6fe37 | 11897 | @item -Ofast |
d77de738 ML |
11898 | Disregard strict standards compliance. @option{-Ofast} enables all |
11899 | @option{-O3} optimizations. It also enables optimizations that are not | |
11900 | valid for all standard-compliant programs. | |
11901 | It turns on @option{-ffast-math}, @option{-fallow-store-data-races} | |
11902 | and the Fortran-specific @option{-fstack-arrays}, unless | |
11903 | @option{-fmax-stack-var-size} is specified, and @option{-fno-protect-parens}. | |
11904 | It turns off @option{-fsemantic-interposition}. | |
11905 | ||
d77de738 | 11906 | @opindex Og |
ddf6fe37 | 11907 | @item -Og |
d77de738 ML |
11908 | Optimize debugging experience. @option{-Og} should be the optimization |
11909 | level of choice for the standard edit-compile-debug cycle, offering | |
11910 | a reasonable level of optimization while maintaining fast compilation | |
11911 | and a good debugging experience. It is a better choice than @option{-O0} | |
11912 | for producing debuggable code because some compiler passes | |
11913 | that collect debug information are disabled at @option{-O0}. | |
11914 | ||
11915 | Like @option{-O0}, @option{-Og} completely disables a number of | |
11916 | optimization passes so that individual options controlling them have | |
11917 | no effect. Otherwise @option{-Og} enables all @option{-O1} | |
11918 | optimization flags except for those that may interfere with debugging: | |
11919 | ||
43b72ede AA |
11920 | @gccoptlist{-fbranch-count-reg -fdelayed-branch |
11921 | -fdse -fif-conversion -fif-conversion2 | |
11922 | -finline-functions-called-once | |
11923 | -fmove-loop-invariants -fmove-loop-stores -fssa-phiopt | |
d77de738 ML |
11924 | -ftree-bit-ccp -ftree-dse -ftree-pta -ftree-sra} |
11925 | ||
d77de738 | 11926 | @opindex Oz |
ddf6fe37 | 11927 | @item -Oz |
d77de738 ML |
11928 | Optimize aggressively for size rather than speed. This may increase |
11929 | the number of instructions executed if those instructions require | |
11930 | fewer bytes to encode. @option{-Oz} behaves similarly to @option{-Os} | |
11931 | including enabling most @option{-O2} optimizations. | |
11932 | ||
11933 | @end table | |
11934 | ||
11935 | If you use multiple @option{-O} options, with or without level numbers, | |
11936 | the last such option is the one that is effective. | |
11937 | ||
11938 | Options of the form @option{-f@var{flag}} specify machine-independent | |
11939 | flags. Most flags have both positive and negative forms; the negative | |
11940 | form of @option{-ffoo} is @option{-fno-foo}. In the table | |
11941 | below, only one of the forms is listed---the one you typically | |
11942 | use. You can figure out the other form by either removing @samp{no-} | |
11943 | or adding it. | |
11944 | ||
11945 | The following options control specific optimizations. They are either | |
11946 | activated by @option{-O} options or are related to ones that are. You | |
11947 | can use the following flags in the rare cases when ``fine-tuning'' of | |
11948 | optimizations to be performed is desired. | |
11949 | ||
11950 | @table @gcctabopt | |
d77de738 ML |
11951 | @opindex fno-defer-pop |
11952 | @opindex fdefer-pop | |
ddf6fe37 | 11953 | @item -fno-defer-pop |
d77de738 ML |
11954 | For machines that must pop arguments after a function call, always pop |
11955 | the arguments as soon as each function returns. | |
11956 | At levels @option{-O1} and higher, @option{-fdefer-pop} is the default; | |
11957 | this allows the compiler to let arguments accumulate on the stack for several | |
11958 | function calls and pop them all at once. | |
11959 | ||
d77de738 | 11960 | @opindex fforward-propagate |
ddf6fe37 | 11961 | @item -fforward-propagate |
d77de738 ML |
11962 | Perform a forward propagation pass on RTL@. The pass tries to combine two |
11963 | instructions and checks if the result can be simplified. If loop unrolling | |
11964 | is active, two passes are performed and the second is scheduled after | |
11965 | loop unrolling. | |
11966 | ||
11967 | This option is enabled by default at optimization levels @option{-O1}, | |
11968 | @option{-O2}, @option{-O3}, @option{-Os}. | |
11969 | ||
d77de738 | 11970 | @opindex ffp-contract |
ddf6fe37 | 11971 | @item -ffp-contract=@var{style} |
d77de738 ML |
11972 | @option{-ffp-contract=off} disables floating-point expression contraction. |
11973 | @option{-ffp-contract=fast} enables floating-point expression contraction | |
11974 | such as forming of fused multiply-add operations if the target has | |
11975 | native support for them. | |
11976 | @option{-ffp-contract=on} enables floating-point expression contraction | |
11977 | if allowed by the language standard. This is currently not implemented | |
11978 | and treated equal to @option{-ffp-contract=off}. | |
11979 | ||
11980 | The default is @option{-ffp-contract=fast}. | |
11981 | ||
d77de738 | 11982 | @opindex fomit-frame-pointer |
ddf6fe37 | 11983 | @item -fomit-frame-pointer |
d77de738 ML |
11984 | Omit the frame pointer in functions that don't need one. This avoids the |
11985 | instructions to save, set up and restore the frame pointer; on many targets | |
11986 | it also makes an extra register available. | |
11987 | ||
11988 | On some targets this flag has no effect because the standard calling sequence | |
11989 | always uses a frame pointer, so it cannot be omitted. | |
11990 | ||
11991 | Note that @option{-fno-omit-frame-pointer} doesn't guarantee the frame pointer | |
11992 | is used in all functions. Several targets always omit the frame pointer in | |
11993 | leaf functions. | |
11994 | ||
11995 | Enabled by default at @option{-O1} and higher. | |
11996 | ||
d77de738 | 11997 | @opindex foptimize-sibling-calls |
ddf6fe37 | 11998 | @item -foptimize-sibling-calls |
d77de738 ML |
11999 | Optimize sibling and tail recursive calls. |
12000 | ||
12001 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12002 | ||
d77de738 | 12003 | @opindex foptimize-strlen |
ddf6fe37 | 12004 | @item -foptimize-strlen |
d77de738 ML |
12005 | Optimize various standard C string functions (e.g.@: @code{strlen}, |
12006 | @code{strchr} or @code{strcpy}) and | |
12007 | their @code{_FORTIFY_SOURCE} counterparts into faster alternatives. | |
12008 | ||
12009 | Enabled at levels @option{-O2}, @option{-O3}. | |
12010 | ||
d77de738 ML |
12011 | @opindex fno-inline |
12012 | @opindex finline | |
ddf6fe37 | 12013 | @item -fno-inline |
d77de738 ML |
12014 | Do not expand any functions inline apart from those marked with |
12015 | the @code{always_inline} attribute. This is the default when not | |
12016 | optimizing. | |
12017 | ||
12018 | Single functions can be exempted from inlining by marking them | |
12019 | with the @code{noinline} attribute. | |
12020 | ||
d77de738 | 12021 | @opindex finline-small-functions |
ddf6fe37 | 12022 | @item -finline-small-functions |
d77de738 ML |
12023 | Integrate functions into their callers when their body is smaller than expected |
12024 | function call code (so overall size of program gets smaller). The compiler | |
12025 | heuristically decides which functions are simple enough to be worth integrating | |
12026 | in this way. This inlining applies to all functions, even those not declared | |
12027 | inline. | |
12028 | ||
12029 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12030 | ||
d77de738 | 12031 | @opindex findirect-inlining |
ddf6fe37 | 12032 | @item -findirect-inlining |
d77de738 ML |
12033 | Inline also indirect calls that are discovered to be known at compile |
12034 | time thanks to previous inlining. This option has any effect only | |
12035 | when inlining itself is turned on by the @option{-finline-functions} | |
12036 | or @option{-finline-small-functions} options. | |
12037 | ||
12038 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12039 | ||
d77de738 | 12040 | @opindex finline-functions |
ddf6fe37 | 12041 | @item -finline-functions |
d77de738 ML |
12042 | Consider all functions for inlining, even if they are not declared inline. |
12043 | The compiler heuristically decides which functions are worth integrating | |
12044 | in this way. | |
12045 | ||
12046 | If all calls to a given function are integrated, and the function is | |
12047 | declared @code{static}, then the function is normally not output as | |
12048 | assembler code in its own right. | |
12049 | ||
12050 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. Also enabled | |
12051 | by @option{-fprofile-use} and @option{-fauto-profile}. | |
12052 | ||
d77de738 | 12053 | @opindex finline-functions-called-once |
ddf6fe37 | 12054 | @item -finline-functions-called-once |
d77de738 ML |
12055 | Consider all @code{static} functions called once for inlining into their |
12056 | caller even if they are not marked @code{inline}. If a call to a given | |
12057 | function is integrated, then the function is not output as assembler code | |
12058 | in its own right. | |
12059 | ||
12060 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3} and @option{-Os}, | |
12061 | but not @option{-Og}. | |
12062 | ||
d77de738 | 12063 | @opindex fearly-inlining |
ddf6fe37 | 12064 | @item -fearly-inlining |
d77de738 ML |
12065 | Inline functions marked by @code{always_inline} and functions whose body seems |
12066 | smaller than the function call overhead early before doing | |
12067 | @option{-fprofile-generate} instrumentation and real inlining pass. Doing so | |
12068 | makes profiling significantly cheaper and usually inlining faster on programs | |
12069 | having large chains of nested wrapper functions. | |
12070 | ||
12071 | Enabled by default. | |
12072 | ||
d77de738 | 12073 | @opindex fipa-sra |
ddf6fe37 | 12074 | @item -fipa-sra |
d77de738 ML |
12075 | Perform interprocedural scalar replacement of aggregates, removal of |
12076 | unused parameters and replacement of parameters passed by reference | |
12077 | by parameters passed by value. | |
12078 | ||
12079 | Enabled at levels @option{-O2}, @option{-O3} and @option{-Os}. | |
12080 | ||
d77de738 | 12081 | @opindex finline-limit |
ddf6fe37 | 12082 | @item -finline-limit=@var{n} |
d77de738 ML |
12083 | By default, GCC limits the size of functions that can be inlined. This flag |
12084 | allows coarse control of this limit. @var{n} is the size of functions that | |
12085 | can be inlined in number of pseudo instructions. | |
12086 | ||
12087 | Inlining is actually controlled by a number of parameters, which may be | |
12088 | specified individually by using @option{--param @var{name}=@var{value}}. | |
12089 | The @option{-finline-limit=@var{n}} option sets some of these parameters | |
12090 | as follows: | |
12091 | ||
12092 | @table @gcctabopt | |
12093 | @item max-inline-insns-single | |
12094 | is set to @var{n}/2. | |
12095 | @item max-inline-insns-auto | |
12096 | is set to @var{n}/2. | |
12097 | @end table | |
12098 | ||
12099 | See below for a documentation of the individual | |
12100 | parameters controlling inlining and for the defaults of these parameters. | |
12101 | ||
12102 | @emph{Note:} there may be no value to @option{-finline-limit} that results | |
12103 | in default behavior. | |
12104 | ||
12105 | @emph{Note:} pseudo instruction represents, in this particular context, an | |
12106 | abstract measurement of function's size. In no way does it represent a count | |
12107 | of assembly instructions and as such its exact meaning might change from one | |
12108 | release to an another. | |
12109 | ||
d77de738 ML |
12110 | @opindex fno-keep-inline-dllexport |
12111 | @opindex fkeep-inline-dllexport | |
ddf6fe37 | 12112 | @item -fno-keep-inline-dllexport |
d77de738 ML |
12113 | This is a more fine-grained version of @option{-fkeep-inline-functions}, |
12114 | which applies only to functions that are declared using the @code{dllexport} | |
12115 | attribute or declspec. @xref{Function Attributes,,Declaring Attributes of | |
12116 | Functions}. | |
12117 | ||
d77de738 | 12118 | @opindex fkeep-inline-functions |
ddf6fe37 | 12119 | @item -fkeep-inline-functions |
d77de738 ML |
12120 | In C, emit @code{static} functions that are declared @code{inline} |
12121 | into the object file, even if the function has been inlined into all | |
12122 | of its callers. This switch does not affect functions using the | |
12123 | @code{extern inline} extension in GNU C90@. In C++, emit any and all | |
12124 | inline functions into the object file. | |
12125 | ||
d77de738 | 12126 | @opindex fkeep-static-functions |
ddf6fe37 | 12127 | @item -fkeep-static-functions |
d77de738 ML |
12128 | Emit @code{static} functions into the object file, even if the function |
12129 | is never used. | |
12130 | ||
d77de738 | 12131 | @opindex fkeep-static-consts |
ddf6fe37 | 12132 | @item -fkeep-static-consts |
d77de738 ML |
12133 | Emit variables declared @code{static const} when optimization isn't turned |
12134 | on, even if the variables aren't referenced. | |
12135 | ||
12136 | GCC enables this option by default. If you want to force the compiler to | |
12137 | check if a variable is referenced, regardless of whether or not | |
12138 | optimization is turned on, use the @option{-fno-keep-static-consts} option. | |
12139 | ||
d77de738 | 12140 | @opindex fmerge-constants |
ddf6fe37 | 12141 | @item -fmerge-constants |
d77de738 ML |
12142 | Attempt to merge identical constants (string constants and floating-point |
12143 | constants) across compilation units. | |
12144 | ||
12145 | This option is the default for optimized compilation if the assembler and | |
12146 | linker support it. Use @option{-fno-merge-constants} to inhibit this | |
12147 | behavior. | |
12148 | ||
12149 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
12150 | ||
d77de738 | 12151 | @opindex fmerge-all-constants |
ddf6fe37 | 12152 | @item -fmerge-all-constants |
d77de738 ML |
12153 | Attempt to merge identical constants and identical variables. |
12154 | ||
12155 | This option implies @option{-fmerge-constants}. In addition to | |
12156 | @option{-fmerge-constants} this considers e.g.@: even constant initialized | |
12157 | arrays or initialized constant variables with integral or floating-point | |
12158 | types. Languages like C or C++ require each variable, including multiple | |
12159 | instances of the same variable in recursive calls, to have distinct locations, | |
12160 | so using this option results in non-conforming | |
12161 | behavior. | |
12162 | ||
d77de738 | 12163 | @opindex fmodulo-sched |
ddf6fe37 | 12164 | @item -fmodulo-sched |
d77de738 ML |
12165 | Perform swing modulo scheduling immediately before the first scheduling |
12166 | pass. This pass looks at innermost loops and reorders their | |
12167 | instructions by overlapping different iterations. | |
12168 | ||
d77de738 | 12169 | @opindex fmodulo-sched-allow-regmoves |
ddf6fe37 | 12170 | @item -fmodulo-sched-allow-regmoves |
d77de738 ML |
12171 | Perform more aggressive SMS-based modulo scheduling with register moves |
12172 | allowed. By setting this flag certain anti-dependences edges are | |
12173 | deleted, which triggers the generation of reg-moves based on the | |
12174 | life-range analysis. This option is effective only with | |
12175 | @option{-fmodulo-sched} enabled. | |
12176 | ||
d77de738 ML |
12177 | @opindex fno-branch-count-reg |
12178 | @opindex fbranch-count-reg | |
ddf6fe37 | 12179 | @item -fno-branch-count-reg |
d77de738 ML |
12180 | Disable the optimization pass that scans for opportunities to use |
12181 | ``decrement and branch'' instructions on a count register instead of | |
12182 | instruction sequences that decrement a register, compare it against zero, and | |
12183 | then branch based upon the result. This option is only meaningful on | |
12184 | architectures that support such instructions, which include x86, PowerPC, | |
12185 | IA-64 and S/390. Note that the @option{-fno-branch-count-reg} option | |
12186 | doesn't remove the decrement and branch instructions from the generated | |
12187 | instruction stream introduced by other optimization passes. | |
12188 | ||
12189 | The default is @option{-fbranch-count-reg} at @option{-O1} and higher, | |
12190 | except for @option{-Og}. | |
12191 | ||
d77de738 ML |
12192 | @opindex fno-function-cse |
12193 | @opindex ffunction-cse | |
ddf6fe37 | 12194 | @item -fno-function-cse |
d77de738 ML |
12195 | Do not put function addresses in registers; make each instruction that |
12196 | calls a constant function contain the function's address explicitly. | |
12197 | ||
12198 | This option results in less efficient code, but some strange hacks | |
12199 | that alter the assembler output may be confused by the optimizations | |
12200 | performed when this option is not used. | |
12201 | ||
12202 | The default is @option{-ffunction-cse} | |
12203 | ||
d77de738 ML |
12204 | @opindex fno-zero-initialized-in-bss |
12205 | @opindex fzero-initialized-in-bss | |
ddf6fe37 | 12206 | @item -fno-zero-initialized-in-bss |
d77de738 ML |
12207 | If the target supports a BSS section, GCC by default puts variables that |
12208 | are initialized to zero into BSS@. This can save space in the resulting | |
12209 | code. | |
12210 | ||
12211 | This option turns off this behavior because some programs explicitly | |
12212 | rely on variables going to the data section---e.g., so that the | |
12213 | resulting executable can find the beginning of that section and/or make | |
12214 | assumptions based on that. | |
12215 | ||
12216 | The default is @option{-fzero-initialized-in-bss}. | |
12217 | ||
d77de738 | 12218 | @opindex fthread-jumps |
ddf6fe37 | 12219 | @item -fthread-jumps |
d77de738 ML |
12220 | Perform optimizations that check to see if a jump branches to a |
12221 | location where another comparison subsumed by the first is found. If | |
12222 | so, the first branch is redirected to either the destination of the | |
12223 | second branch or a point immediately following it, depending on whether | |
12224 | the condition is known to be true or false. | |
12225 | ||
12226 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
12227 | ||
d77de738 | 12228 | @opindex fsplit-wide-types |
ddf6fe37 | 12229 | @item -fsplit-wide-types |
d77de738 ML |
12230 | When using a type that occupies multiple registers, such as @code{long |
12231 | long} on a 32-bit system, split the registers apart and allocate them | |
12232 | independently. This normally generates better code for those types, | |
12233 | but may make debugging more difficult. | |
12234 | ||
12235 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, | |
12236 | @option{-Os}. | |
12237 | ||
d77de738 | 12238 | @opindex fsplit-wide-types-early |
ddf6fe37 | 12239 | @item -fsplit-wide-types-early |
d77de738 ML |
12240 | Fully split wide types early, instead of very late. |
12241 | This option has no effect unless @option{-fsplit-wide-types} is turned on. | |
12242 | ||
12243 | This is the default on some targets. | |
12244 | ||
d77de738 | 12245 | @opindex fcse-follow-jumps |
ddf6fe37 | 12246 | @item -fcse-follow-jumps |
d77de738 ML |
12247 | In common subexpression elimination (CSE), scan through jump instructions |
12248 | when the target of the jump is not reached by any other path. For | |
12249 | example, when CSE encounters an @code{if} statement with an | |
12250 | @code{else} clause, CSE follows the jump when the condition | |
12251 | tested is false. | |
12252 | ||
12253 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12254 | ||
d77de738 | 12255 | @opindex fcse-skip-blocks |
ddf6fe37 | 12256 | @item -fcse-skip-blocks |
d77de738 ML |
12257 | This is similar to @option{-fcse-follow-jumps}, but causes CSE to |
12258 | follow jumps that conditionally skip over blocks. When CSE | |
12259 | encounters a simple @code{if} statement with no else clause, | |
12260 | @option{-fcse-skip-blocks} causes CSE to follow the jump around the | |
12261 | body of the @code{if}. | |
12262 | ||
12263 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12264 | ||
d77de738 | 12265 | @opindex frerun-cse-after-loop |
ddf6fe37 | 12266 | @item -frerun-cse-after-loop |
d77de738 ML |
12267 | Re-run common subexpression elimination after loop optimizations are |
12268 | performed. | |
12269 | ||
12270 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12271 | ||
d77de738 | 12272 | @opindex fgcse |
ddf6fe37 | 12273 | @item -fgcse |
d77de738 ML |
12274 | Perform a global common subexpression elimination pass. |
12275 | This pass also performs global constant and copy propagation. | |
12276 | ||
12277 | @emph{Note:} When compiling a program using computed gotos, a GCC | |
12278 | extension, you may get better run-time performance if you disable | |
12279 | the global common subexpression elimination pass by adding | |
12280 | @option{-fno-gcse} to the command line. | |
12281 | ||
12282 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12283 | ||
d77de738 | 12284 | @opindex fgcse-lm |
ddf6fe37 | 12285 | @item -fgcse-lm |
d77de738 ML |
12286 | When @option{-fgcse-lm} is enabled, global common subexpression elimination |
12287 | attempts to move loads that are only killed by stores into themselves. This | |
12288 | allows a loop containing a load/store sequence to be changed to a load outside | |
12289 | the loop, and a copy/store within the loop. | |
12290 | ||
12291 | Enabled by default when @option{-fgcse} is enabled. | |
12292 | ||
d77de738 | 12293 | @opindex fgcse-sm |
ddf6fe37 | 12294 | @item -fgcse-sm |
d77de738 ML |
12295 | When @option{-fgcse-sm} is enabled, a store motion pass is run after |
12296 | global common subexpression elimination. This pass attempts to move | |
12297 | stores out of loops. When used in conjunction with @option{-fgcse-lm}, | |
12298 | loops containing a load/store sequence can be changed to a load before | |
12299 | the loop and a store after the loop. | |
12300 | ||
12301 | Not enabled at any optimization level. | |
12302 | ||
d77de738 | 12303 | @opindex fgcse-las |
ddf6fe37 | 12304 | @item -fgcse-las |
d77de738 ML |
12305 | When @option{-fgcse-las} is enabled, the global common subexpression |
12306 | elimination pass eliminates redundant loads that come after stores to the | |
12307 | same memory location (both partial and full redundancies). | |
12308 | ||
12309 | Not enabled at any optimization level. | |
12310 | ||
d77de738 | 12311 | @opindex fgcse-after-reload |
ddf6fe37 | 12312 | @item -fgcse-after-reload |
d77de738 ML |
12313 | When @option{-fgcse-after-reload} is enabled, a redundant load elimination |
12314 | pass is performed after reload. The purpose of this pass is to clean up | |
12315 | redundant spilling. | |
12316 | ||
12317 | Enabled by @option{-O3}, @option{-fprofile-use} and @option{-fauto-profile}. | |
12318 | ||
d77de738 | 12319 | @opindex faggressive-loop-optimizations |
ddf6fe37 | 12320 | @item -faggressive-loop-optimizations |
d77de738 ML |
12321 | This option tells the loop optimizer to use language constraints to |
12322 | derive bounds for the number of iterations of a loop. This assumes that | |
12323 | loop code does not invoke undefined behavior by for example causing signed | |
12324 | integer overflows or out-of-bound array accesses. The bounds for the | |
12325 | number of iterations of a loop are used to guide loop unrolling and peeling | |
12326 | and loop exit test optimizations. | |
12327 | This option is enabled by default. | |
12328 | ||
d77de738 | 12329 | @opindex funconstrained-commons |
ddf6fe37 | 12330 | @item -funconstrained-commons |
d77de738 ML |
12331 | This option tells the compiler that variables declared in common blocks |
12332 | (e.g.@: Fortran) may later be overridden with longer trailing arrays. This | |
12333 | prevents certain optimizations that depend on knowing the array bounds. | |
12334 | ||
d77de738 | 12335 | @opindex fcrossjumping |
ddf6fe37 | 12336 | @item -fcrossjumping |
d77de738 ML |
12337 | Perform cross-jumping transformation. |
12338 | This transformation unifies equivalent code and saves code size. The | |
12339 | resulting code may or may not perform better than without cross-jumping. | |
12340 | ||
12341 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12342 | ||
d77de738 | 12343 | @opindex fauto-inc-dec |
ddf6fe37 | 12344 | @item -fauto-inc-dec |
d77de738 ML |
12345 | Combine increments or decrements of addresses with memory accesses. |
12346 | This pass is always skipped on architectures that do not have | |
12347 | instructions to support this. Enabled by default at @option{-O1} and | |
12348 | higher on architectures that support this. | |
12349 | ||
d77de738 | 12350 | @opindex fdce |
ddf6fe37 | 12351 | @item -fdce |
d77de738 ML |
12352 | Perform dead code elimination (DCE) on RTL@. |
12353 | Enabled by default at @option{-O1} and higher. | |
12354 | ||
d77de738 | 12355 | @opindex fdse |
ddf6fe37 | 12356 | @item -fdse |
d77de738 ML |
12357 | Perform dead store elimination (DSE) on RTL@. |
12358 | Enabled by default at @option{-O1} and higher. | |
12359 | ||
d77de738 | 12360 | @opindex fif-conversion |
ddf6fe37 | 12361 | @item -fif-conversion |
d77de738 ML |
12362 | Attempt to transform conditional jumps into branch-less equivalents. This |
12363 | includes use of conditional moves, min, max, set flags and abs instructions, and | |
12364 | some tricks doable by standard arithmetics. The use of conditional execution | |
12365 | on chips where it is available is controlled by @option{-fif-conversion2}. | |
12366 | ||
12367 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but | |
12368 | not with @option{-Og}. | |
12369 | ||
d77de738 | 12370 | @opindex fif-conversion2 |
ddf6fe37 | 12371 | @item -fif-conversion2 |
d77de738 ML |
12372 | Use conditional execution (where available) to transform conditional jumps into |
12373 | branch-less equivalents. | |
12374 | ||
12375 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, but | |
12376 | not with @option{-Og}. | |
12377 | ||
d77de738 | 12378 | @opindex fdeclone-ctor-dtor |
ddf6fe37 | 12379 | @item -fdeclone-ctor-dtor |
d77de738 ML |
12380 | The C++ ABI requires multiple entry points for constructors and |
12381 | destructors: one for a base subobject, one for a complete object, and | |
12382 | one for a virtual destructor that calls operator delete afterwards. | |
12383 | For a hierarchy with virtual bases, the base and complete variants are | |
12384 | clones, which means two copies of the function. With this option, the | |
12385 | base and complete variants are changed to be thunks that call a common | |
12386 | implementation. | |
12387 | ||
12388 | Enabled by @option{-Os}. | |
12389 | ||
d77de738 | 12390 | @opindex fdelete-null-pointer-checks |
ddf6fe37 | 12391 | @item -fdelete-null-pointer-checks |
d77de738 ML |
12392 | Assume that programs cannot safely dereference null pointers, and that |
12393 | no code or data element resides at address zero. | |
12394 | This option enables simple constant | |
12395 | folding optimizations at all optimization levels. In addition, other | |
12396 | optimization passes in GCC use this flag to control global dataflow | |
12397 | analyses that eliminate useless checks for null pointers; these assume | |
12398 | that a memory access to address zero always results in a trap, so | |
12399 | that if a pointer is checked after it has already been dereferenced, | |
12400 | it cannot be null. | |
12401 | ||
12402 | Note however that in some environments this assumption is not true. | |
12403 | Use @option{-fno-delete-null-pointer-checks} to disable this optimization | |
12404 | for programs that depend on that behavior. | |
12405 | ||
12406 | This option is enabled by default on most targets. On Nios II ELF, it | |
12407 | defaults to off. On AVR and MSP430, this option is completely disabled. | |
12408 | ||
12409 | Passes that use the dataflow information | |
12410 | are enabled independently at different optimization levels. | |
12411 | ||
d77de738 | 12412 | @opindex fdevirtualize |
ddf6fe37 | 12413 | @item -fdevirtualize |
d77de738 ML |
12414 | Attempt to convert calls to virtual functions to direct calls. This |
12415 | is done both within a procedure and interprocedurally as part of | |
12416 | indirect inlining (@option{-findirect-inlining}) and interprocedural constant | |
12417 | propagation (@option{-fipa-cp}). | |
12418 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12419 | ||
d77de738 | 12420 | @opindex fdevirtualize-speculatively |
ddf6fe37 | 12421 | @item -fdevirtualize-speculatively |
d77de738 ML |
12422 | Attempt to convert calls to virtual functions to speculative direct calls. |
12423 | Based on the analysis of the type inheritance graph, determine for a given call | |
12424 | the set of likely targets. If the set is small, preferably of size 1, change | |
12425 | the call into a conditional deciding between direct and indirect calls. The | |
12426 | speculative calls enable more optimizations, such as inlining. When they seem | |
12427 | useless after further optimization, they are converted back into original form. | |
12428 | ||
d77de738 | 12429 | @opindex fdevirtualize-at-ltrans |
ddf6fe37 | 12430 | @item -fdevirtualize-at-ltrans |
d77de738 ML |
12431 | Stream extra information needed for aggressive devirtualization when running |
12432 | the link-time optimizer in local transformation mode. | |
12433 | This option enables more devirtualization but | |
12434 | significantly increases the size of streamed data. For this reason it is | |
12435 | disabled by default. | |
12436 | ||
d77de738 | 12437 | @opindex fexpensive-optimizations |
ddf6fe37 | 12438 | @item -fexpensive-optimizations |
d77de738 ML |
12439 | Perform a number of minor optimizations that are relatively expensive. |
12440 | ||
12441 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12442 | ||
d77de738 | 12443 | @opindex free |
ddf6fe37 | 12444 | @item -free |
d77de738 ML |
12445 | Attempt to remove redundant extension instructions. This is especially |
12446 | helpful for the x86-64 architecture, which implicitly zero-extends in 64-bit | |
12447 | registers after writing to their lower 32-bit half. | |
12448 | ||
12449 | Enabled for Alpha, AArch64 and x86 at levels @option{-O2}, | |
12450 | @option{-O3}, @option{-Os}. | |
12451 | ||
d77de738 ML |
12452 | @opindex fno-lifetime-dse |
12453 | @opindex flifetime-dse | |
ddf6fe37 | 12454 | @item -fno-lifetime-dse |
d77de738 ML |
12455 | In C++ the value of an object is only affected by changes within its |
12456 | lifetime: when the constructor begins, the object has an indeterminate | |
12457 | value, and any changes during the lifetime of the object are dead when | |
12458 | the object is destroyed. Normally dead store elimination will take | |
12459 | advantage of this; if your code relies on the value of the object | |
12460 | storage persisting beyond the lifetime of the object, you can use this | |
12461 | flag to disable this optimization. To preserve stores before the | |
12462 | constructor starts (e.g.@: because your operator new clears the object | |
12463 | storage) but still treat the object as dead after the destructor, you | |
12464 | can use @option{-flifetime-dse=1}. The default behavior can be | |
12465 | explicitly selected with @option{-flifetime-dse=2}. | |
12466 | @option{-flifetime-dse=0} is equivalent to @option{-fno-lifetime-dse}. | |
12467 | ||
d77de738 | 12468 | @opindex flive-range-shrinkage |
ddf6fe37 | 12469 | @item -flive-range-shrinkage |
d77de738 ML |
12470 | Attempt to decrease register pressure through register live range |
12471 | shrinkage. This is helpful for fast processors with small or moderate | |
12472 | size register sets. | |
12473 | ||
d77de738 | 12474 | @opindex fira-algorithm |
ddf6fe37 | 12475 | @item -fira-algorithm=@var{algorithm} |
d77de738 ML |
12476 | Use the specified coloring algorithm for the integrated register |
12477 | allocator. The @var{algorithm} argument can be @samp{priority}, which | |
12478 | specifies Chow's priority coloring, or @samp{CB}, which specifies | |
12479 | Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implemented | |
12480 | for all architectures, but for those targets that do support it, it is | |
12481 | the default because it generates better code. | |
12482 | ||
d77de738 | 12483 | @opindex fira-region |
ddf6fe37 | 12484 | @item -fira-region=@var{region} |
d77de738 ML |
12485 | Use specified regions for the integrated register allocator. The |
12486 | @var{region} argument should be one of the following: | |
12487 | ||
12488 | @table @samp | |
12489 | ||
12490 | @item all | |
12491 | Use all loops as register allocation regions. | |
12492 | This can give the best results for machines with a small and/or | |
12493 | irregular register set. | |
12494 | ||
12495 | @item mixed | |
12496 | Use all loops except for loops with small register pressure | |
12497 | as the regions. This value usually gives | |
12498 | the best results in most cases and for most architectures, | |
12499 | and is enabled by default when compiling with optimization for speed | |
12500 | (@option{-O}, @option{-O2}, @dots{}). | |
12501 | ||
12502 | @item one | |
12503 | Use all functions as a single region. | |
12504 | This typically results in the smallest code size, and is enabled by default for | |
12505 | @option{-Os} or @option{-O0}. | |
12506 | ||
12507 | @end table | |
12508 | ||
d77de738 | 12509 | @opindex fira-hoist-pressure |
ddf6fe37 | 12510 | @item -fira-hoist-pressure |
d77de738 ML |
12511 | Use IRA to evaluate register pressure in the code hoisting pass for |
12512 | decisions to hoist expressions. This option usually results in smaller | |
12513 | code, but it can slow the compiler down. | |
12514 | ||
12515 | This option is enabled at level @option{-Os} for all targets. | |
12516 | ||
d77de738 | 12517 | @opindex fira-loop-pressure |
ddf6fe37 | 12518 | @item -fira-loop-pressure |
d77de738 ML |
12519 | Use IRA to evaluate register pressure in loops for decisions to move |
12520 | loop invariants. This option usually results in generation | |
12521 | of faster and smaller code on machines with large register files (>= 32 | |
12522 | registers), but it can slow the compiler down. | |
12523 | ||
12524 | This option is enabled at level @option{-O3} for some targets. | |
12525 | ||
d77de738 ML |
12526 | @opindex fno-ira-share-save-slots |
12527 | @opindex fira-share-save-slots | |
ddf6fe37 | 12528 | @item -fno-ira-share-save-slots |
d77de738 ML |
12529 | Disable sharing of stack slots used for saving call-used hard |
12530 | registers living through a call. Each hard register gets a | |
12531 | separate stack slot, and as a result function stack frames are | |
12532 | larger. | |
12533 | ||
d77de738 ML |
12534 | @opindex fno-ira-share-spill-slots |
12535 | @opindex fira-share-spill-slots | |
ddf6fe37 | 12536 | @item -fno-ira-share-spill-slots |
d77de738 ML |
12537 | Disable sharing of stack slots allocated for pseudo-registers. Each |
12538 | pseudo-register that does not get a hard register gets a separate | |
12539 | stack slot, and as a result function stack frames are larger. | |
12540 | ||
d77de738 | 12541 | @opindex flra-remat |
ddf6fe37 | 12542 | @item -flra-remat |
d77de738 ML |
12543 | Enable CFG-sensitive rematerialization in LRA. Instead of loading |
12544 | values of spilled pseudos, LRA tries to rematerialize (recalculate) | |
12545 | values if it is profitable. | |
12546 | ||
12547 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12548 | ||
d77de738 | 12549 | @opindex fdelayed-branch |
ddf6fe37 | 12550 | @item -fdelayed-branch |
d77de738 ML |
12551 | If supported for the target machine, attempt to reorder instructions |
12552 | to exploit instruction slots available after delayed branch | |
12553 | instructions. | |
12554 | ||
12555 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}, | |
12556 | but not at @option{-Og}. | |
12557 | ||
d77de738 | 12558 | @opindex fschedule-insns |
ddf6fe37 | 12559 | @item -fschedule-insns |
d77de738 ML |
12560 | If supported for the target machine, attempt to reorder instructions to |
12561 | eliminate execution stalls due to required data being unavailable. This | |
12562 | helps machines that have slow floating point or memory load instructions | |
12563 | by allowing other instructions to be issued until the result of the load | |
12564 | or floating-point instruction is required. | |
12565 | ||
12566 | Enabled at levels @option{-O2}, @option{-O3}. | |
12567 | ||
d77de738 | 12568 | @opindex fschedule-insns2 |
ddf6fe37 | 12569 | @item -fschedule-insns2 |
d77de738 ML |
12570 | Similar to @option{-fschedule-insns}, but requests an additional pass of |
12571 | instruction scheduling after register allocation has been done. This is | |
12572 | especially useful on machines with a relatively small number of | |
12573 | registers and where memory load instructions take more than one cycle. | |
12574 | ||
12575 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12576 | ||
d77de738 ML |
12577 | @opindex fno-sched-interblock |
12578 | @opindex fsched-interblock | |
ddf6fe37 | 12579 | @item -fno-sched-interblock |
d77de738 ML |
12580 | Disable instruction scheduling across basic blocks, which |
12581 | is normally enabled when scheduling before register allocation, i.e.@: | |
12582 | with @option{-fschedule-insns} or at @option{-O2} or higher. | |
12583 | ||
d77de738 ML |
12584 | @opindex fno-sched-spec |
12585 | @opindex fsched-spec | |
ddf6fe37 | 12586 | @item -fno-sched-spec |
d77de738 ML |
12587 | Disable speculative motion of non-load instructions, which |
12588 | is normally enabled when scheduling before register allocation, i.e.@: | |
12589 | with @option{-fschedule-insns} or at @option{-O2} or higher. | |
12590 | ||
d77de738 | 12591 | @opindex fsched-pressure |
ddf6fe37 | 12592 | @item -fsched-pressure |
d77de738 ML |
12593 | Enable register pressure sensitive insn scheduling before register |
12594 | allocation. This only makes sense when scheduling before register | |
12595 | allocation is enabled, i.e.@: with @option{-fschedule-insns} or at | |
12596 | @option{-O2} or higher. Usage of this option can improve the | |
12597 | generated code and decrease its size by preventing register pressure | |
12598 | increase above the number of available hard registers and subsequent | |
12599 | spills in register allocation. | |
12600 | ||
d77de738 | 12601 | @opindex fsched-spec-load |
ddf6fe37 | 12602 | @item -fsched-spec-load |
d77de738 ML |
12603 | Allow speculative motion of some load instructions. This only makes |
12604 | sense when scheduling before register allocation, i.e.@: with | |
12605 | @option{-fschedule-insns} or at @option{-O2} or higher. | |
12606 | ||
d77de738 | 12607 | @opindex fsched-spec-load-dangerous |
ddf6fe37 | 12608 | @item -fsched-spec-load-dangerous |
d77de738 ML |
12609 | Allow speculative motion of more load instructions. This only makes |
12610 | sense when scheduling before register allocation, i.e.@: with | |
12611 | @option{-fschedule-insns} or at @option{-O2} or higher. | |
12612 | ||
ddf6fe37 | 12613 | @opindex fsched-stalled-insns |
d77de738 ML |
12614 | @item -fsched-stalled-insns |
12615 | @itemx -fsched-stalled-insns=@var{n} | |
d77de738 ML |
12616 | Define how many insns (if any) can be moved prematurely from the queue |
12617 | of stalled insns into the ready list during the second scheduling pass. | |
12618 | @option{-fno-sched-stalled-insns} means that no insns are moved | |
12619 | prematurely, @option{-fsched-stalled-insns=0} means there is no limit | |
12620 | on how many queued insns can be moved prematurely. | |
12621 | @option{-fsched-stalled-insns} without a value is equivalent to | |
12622 | @option{-fsched-stalled-insns=1}. | |
12623 | ||
ddf6fe37 | 12624 | @opindex fsched-stalled-insns-dep |
d77de738 ML |
12625 | @item -fsched-stalled-insns-dep |
12626 | @itemx -fsched-stalled-insns-dep=@var{n} | |
d77de738 ML |
12627 | Define how many insn groups (cycles) are examined for a dependency |
12628 | on a stalled insn that is a candidate for premature removal from the queue | |
12629 | of stalled insns. This has an effect only during the second scheduling pass, | |
12630 | and only if @option{-fsched-stalled-insns} is used. | |
12631 | @option{-fno-sched-stalled-insns-dep} is equivalent to | |
12632 | @option{-fsched-stalled-insns-dep=0}. | |
12633 | @option{-fsched-stalled-insns-dep} without a value is equivalent to | |
12634 | @option{-fsched-stalled-insns-dep=1}. | |
12635 | ||
d77de738 | 12636 | @opindex fsched2-use-superblocks |
ddf6fe37 | 12637 | @item -fsched2-use-superblocks |
d77de738 ML |
12638 | When scheduling after register allocation, use superblock scheduling. |
12639 | This allows motion across basic block boundaries, | |
12640 | resulting in faster schedules. This option is experimental, as not all machine | |
12641 | descriptions used by GCC model the CPU closely enough to avoid unreliable | |
12642 | results from the algorithm. | |
12643 | ||
12644 | This only makes sense when scheduling after register allocation, i.e.@: with | |
12645 | @option{-fschedule-insns2} or at @option{-O2} or higher. | |
12646 | ||
d77de738 | 12647 | @opindex fsched-group-heuristic |
ddf6fe37 | 12648 | @item -fsched-group-heuristic |
d77de738 ML |
12649 | Enable the group heuristic in the scheduler. This heuristic favors |
12650 | the instruction that belongs to a schedule group. This is enabled | |
12651 | by default when scheduling is enabled, i.e.@: with @option{-fschedule-insns} | |
12652 | or @option{-fschedule-insns2} or at @option{-O2} or higher. | |
12653 | ||
d77de738 | 12654 | @opindex fsched-critical-path-heuristic |
ddf6fe37 | 12655 | @item -fsched-critical-path-heuristic |
d77de738 ML |
12656 | Enable the critical-path heuristic in the scheduler. This heuristic favors |
12657 | instructions on the critical path. This is enabled by default when | |
12658 | scheduling is enabled, i.e.@: with @option{-fschedule-insns} | |
12659 | or @option{-fschedule-insns2} or at @option{-O2} or higher. | |
12660 | ||
d77de738 | 12661 | @opindex fsched-spec-insn-heuristic |
ddf6fe37 | 12662 | @item -fsched-spec-insn-heuristic |
d77de738 ML |
12663 | Enable the speculative instruction heuristic in the scheduler. This |
12664 | heuristic favors speculative instructions with greater dependency weakness. | |
12665 | This is enabled by default when scheduling is enabled, i.e.@: | |
12666 | with @option{-fschedule-insns} or @option{-fschedule-insns2} | |
12667 | or at @option{-O2} or higher. | |
12668 | ||
d77de738 | 12669 | @opindex fsched-rank-heuristic |
ddf6fe37 | 12670 | @item -fsched-rank-heuristic |
d77de738 ML |
12671 | Enable the rank heuristic in the scheduler. This heuristic favors |
12672 | the instruction belonging to a basic block with greater size or frequency. | |
12673 | This is enabled by default when scheduling is enabled, i.e.@: | |
12674 | with @option{-fschedule-insns} or @option{-fschedule-insns2} or | |
12675 | at @option{-O2} or higher. | |
12676 | ||
d77de738 | 12677 | @opindex fsched-last-insn-heuristic |
ddf6fe37 | 12678 | @item -fsched-last-insn-heuristic |
d77de738 ML |
12679 | Enable the last-instruction heuristic in the scheduler. This heuristic |
12680 | favors the instruction that is less dependent on the last instruction | |
12681 | scheduled. This is enabled by default when scheduling is enabled, | |
12682 | i.e.@: with @option{-fschedule-insns} or @option{-fschedule-insns2} or | |
12683 | at @option{-O2} or higher. | |
12684 | ||
d77de738 | 12685 | @opindex fsched-dep-count-heuristic |
ddf6fe37 | 12686 | @item -fsched-dep-count-heuristic |
d77de738 ML |
12687 | Enable the dependent-count heuristic in the scheduler. This heuristic |
12688 | favors the instruction that has more instructions depending on it. | |
12689 | This is enabled by default when scheduling is enabled, i.e.@: | |
12690 | with @option{-fschedule-insns} or @option{-fschedule-insns2} or | |
12691 | at @option{-O2} or higher. | |
12692 | ||
d77de738 | 12693 | @opindex freschedule-modulo-scheduled-loops |
ddf6fe37 | 12694 | @item -freschedule-modulo-scheduled-loops |
d77de738 ML |
12695 | Modulo scheduling is performed before traditional scheduling. If a loop |
12696 | is modulo scheduled, later scheduling passes may change its schedule. | |
12697 | Use this option to control that behavior. | |
12698 | ||
d77de738 | 12699 | @opindex fselective-scheduling |
ddf6fe37 | 12700 | @item -fselective-scheduling |
d77de738 ML |
12701 | Schedule instructions using selective scheduling algorithm. Selective |
12702 | scheduling runs instead of the first scheduler pass. | |
12703 | ||
d77de738 | 12704 | @opindex fselective-scheduling2 |
ddf6fe37 | 12705 | @item -fselective-scheduling2 |
d77de738 ML |
12706 | Schedule instructions using selective scheduling algorithm. Selective |
12707 | scheduling runs instead of the second scheduler pass. | |
12708 | ||
d77de738 | 12709 | @opindex fsel-sched-pipelining |
ddf6fe37 | 12710 | @item -fsel-sched-pipelining |
d77de738 ML |
12711 | Enable software pipelining of innermost loops during selective scheduling. |
12712 | This option has no effect unless one of @option{-fselective-scheduling} or | |
12713 | @option{-fselective-scheduling2} is turned on. | |
12714 | ||
d77de738 | 12715 | @opindex fsel-sched-pipelining-outer-loops |
ddf6fe37 | 12716 | @item -fsel-sched-pipelining-outer-loops |
d77de738 ML |
12717 | When pipelining loops during selective scheduling, also pipeline outer loops. |
12718 | This option has no effect unless @option{-fsel-sched-pipelining} is turned on. | |
12719 | ||
d77de738 | 12720 | @opindex fsemantic-interposition |
ddf6fe37 | 12721 | @item -fsemantic-interposition |
d77de738 ML |
12722 | Some object formats, like ELF, allow interposing of symbols by the |
12723 | dynamic linker. | |
12724 | This means that for symbols exported from the DSO, the compiler cannot perform | |
12725 | interprocedural propagation, inlining and other optimizations in anticipation | |
12726 | that the function or variable in question may change. While this feature is | |
12727 | useful, for example, to rewrite memory allocation functions by a debugging | |
12728 | implementation, it is expensive in the terms of code quality. | |
12729 | With @option{-fno-semantic-interposition} the compiler assumes that | |
12730 | if interposition happens for functions the overwriting function will have | |
12731 | precisely the same semantics (and side effects). | |
12732 | Similarly if interposition happens | |
12733 | for variables, the constructor of the variable will be the same. The flag | |
12734 | has no effect for functions explicitly declared inline | |
12735 | (where it is never allowed for interposition to change semantics) | |
12736 | and for symbols explicitly declared weak. | |
12737 | ||
d77de738 | 12738 | @opindex fshrink-wrap |
ddf6fe37 | 12739 | @item -fshrink-wrap |
d77de738 ML |
12740 | Emit function prologues only before parts of the function that need it, |
12741 | rather than at the top of the function. This flag is enabled by default at | |
12742 | @option{-O} and higher. | |
12743 | ||
d77de738 | 12744 | @opindex fshrink-wrap-separate |
ddf6fe37 | 12745 | @item -fshrink-wrap-separate |
d77de738 ML |
12746 | Shrink-wrap separate parts of the prologue and epilogue separately, so that |
12747 | those parts are only executed when needed. | |
12748 | This option is on by default, but has no effect unless @option{-fshrink-wrap} | |
12749 | is also turned on and the target supports this. | |
12750 | ||
d77de738 | 12751 | @opindex fcaller-saves |
ddf6fe37 | 12752 | @item -fcaller-saves |
d77de738 ML |
12753 | Enable allocation of values to registers that are clobbered by |
12754 | function calls, by emitting extra instructions to save and restore the | |
12755 | registers around such calls. Such allocation is done only when it | |
12756 | seems to result in better code. | |
12757 | ||
12758 | This option is always enabled by default on certain machines, usually | |
12759 | those which have no call-preserved registers to use instead. | |
12760 | ||
12761 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
12762 | ||
d77de738 | 12763 | @opindex fcombine-stack-adjustments |
ddf6fe37 | 12764 | @item -fcombine-stack-adjustments |
d77de738 ML |
12765 | Tracks stack adjustments (pushes and pops) and stack memory references |
12766 | and then tries to find ways to combine them. | |
12767 | ||
12768 | Enabled by default at @option{-O1} and higher. | |
12769 | ||
d77de738 | 12770 | @opindex fipa-ra |
ddf6fe37 | 12771 | @item -fipa-ra |
d77de738 ML |
12772 | Use caller save registers for allocation if those registers are not used by |
12773 | any called function. In that case it is not necessary to save and restore | |
12774 | them around calls. This is only possible if called functions are part of | |
12775 | same compilation unit as current function and they are compiled before it. | |
12776 | ||
12777 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}, however the option | |
12778 | is disabled if generated code will be instrumented for profiling | |
12779 | (@option{-p}, or @option{-pg}) or if callee's register usage cannot be known | |
12780 | exactly (this happens on targets that do not expose prologues | |
12781 | and epilogues in RTL). | |
12782 | ||
d77de738 | 12783 | @opindex fconserve-stack |
ddf6fe37 | 12784 | @item -fconserve-stack |
d77de738 ML |
12785 | Attempt to minimize stack usage. The compiler attempts to use less |
12786 | stack space, even if that makes the program slower. This option | |
12787 | implies setting the @option{large-stack-frame} parameter to 100 | |
12788 | and the @option{large-stack-frame-growth} parameter to 400. | |
12789 | ||
d77de738 | 12790 | @opindex ftree-reassoc |
ddf6fe37 | 12791 | @item -ftree-reassoc |
d77de738 ML |
12792 | Perform reassociation on trees. This flag is enabled by default |
12793 | at @option{-O1} and higher. | |
12794 | ||
d77de738 | 12795 | @opindex fcode-hoisting |
ddf6fe37 | 12796 | @item -fcode-hoisting |
d77de738 ML |
12797 | Perform code hoisting. Code hoisting tries to move the |
12798 | evaluation of expressions executed on all paths to the function exit | |
12799 | as early as possible. This is especially useful as a code size | |
12800 | optimization, but it often helps for code speed as well. | |
12801 | This flag is enabled by default at @option{-O2} and higher. | |
12802 | ||
d77de738 | 12803 | @opindex ftree-pre |
ddf6fe37 | 12804 | @item -ftree-pre |
d77de738 ML |
12805 | Perform partial redundancy elimination (PRE) on trees. This flag is |
12806 | enabled by default at @option{-O2} and @option{-O3}. | |
12807 | ||
d77de738 | 12808 | @opindex ftree-partial-pre |
ddf6fe37 | 12809 | @item -ftree-partial-pre |
d77de738 ML |
12810 | Make partial redundancy elimination (PRE) more aggressive. This flag is |
12811 | enabled by default at @option{-O3}. | |
12812 | ||
d77de738 | 12813 | @opindex ftree-forwprop |
ddf6fe37 | 12814 | @item -ftree-forwprop |
d77de738 ML |
12815 | Perform forward propagation on trees. This flag is enabled by default |
12816 | at @option{-O1} and higher. | |
12817 | ||
d77de738 | 12818 | @opindex ftree-fre |
ddf6fe37 | 12819 | @item -ftree-fre |
d77de738 ML |
12820 | Perform full redundancy elimination (FRE) on trees. The difference |
12821 | between FRE and PRE is that FRE only considers expressions | |
12822 | that are computed on all paths leading to the redundant computation. | |
12823 | This analysis is faster than PRE, though it exposes fewer redundancies. | |
12824 | This flag is enabled by default at @option{-O1} and higher. | |
12825 | ||
d77de738 | 12826 | @opindex ftree-phiprop |
ddf6fe37 | 12827 | @item -ftree-phiprop |
d77de738 ML |
12828 | Perform hoisting of loads from conditional pointers on trees. This |
12829 | pass is enabled by default at @option{-O1} and higher. | |
12830 | ||
d77de738 | 12831 | @opindex fhoist-adjacent-loads |
ddf6fe37 | 12832 | @item -fhoist-adjacent-loads |
d77de738 ML |
12833 | Speculatively hoist loads from both branches of an if-then-else if the |
12834 | loads are from adjacent locations in the same structure and the target | |
12835 | architecture has a conditional move instruction. This flag is enabled | |
12836 | by default at @option{-O2} and higher. | |
12837 | ||
d77de738 | 12838 | @opindex ftree-copy-prop |
ddf6fe37 | 12839 | @item -ftree-copy-prop |
d77de738 ML |
12840 | Perform copy propagation on trees. This pass eliminates unnecessary |
12841 | copy operations. This flag is enabled by default at @option{-O1} and | |
12842 | higher. | |
12843 | ||
d77de738 | 12844 | @opindex fipa-pure-const |
ddf6fe37 | 12845 | @item -fipa-pure-const |
d77de738 ML |
12846 | Discover which functions are pure or constant. |
12847 | Enabled by default at @option{-O1} and higher. | |
12848 | ||
d77de738 | 12849 | @opindex fipa-reference |
ddf6fe37 | 12850 | @item -fipa-reference |
d77de738 ML |
12851 | Discover which static variables do not escape the |
12852 | compilation unit. | |
12853 | Enabled by default at @option{-O1} and higher. | |
12854 | ||
d77de738 | 12855 | @opindex fipa-reference-addressable |
ddf6fe37 | 12856 | @item -fipa-reference-addressable |
d77de738 ML |
12857 | Discover read-only, write-only and non-addressable static variables. |
12858 | Enabled by default at @option{-O1} and higher. | |
12859 | ||
d77de738 | 12860 | @opindex fipa-stack-alignment |
ddf6fe37 | 12861 | @item -fipa-stack-alignment |
d77de738 ML |
12862 | Reduce stack alignment on call sites if possible. |
12863 | Enabled by default. | |
12864 | ||
d77de738 | 12865 | @opindex fipa-pta |
ddf6fe37 | 12866 | @item -fipa-pta |
d77de738 ML |
12867 | Perform interprocedural pointer analysis and interprocedural modification |
12868 | and reference analysis. This option can cause excessive memory and | |
12869 | compile-time usage on large compilation units. It is not enabled by | |
12870 | default at any optimization level. | |
12871 | ||
d77de738 | 12872 | @opindex fipa-profile |
ddf6fe37 | 12873 | @item -fipa-profile |
d77de738 ML |
12874 | Perform interprocedural profile propagation. The functions called only from |
12875 | cold functions are marked as cold. Also functions executed once (such as | |
12876 | @code{cold}, @code{noreturn}, static constructors or destructors) are | |
12877 | identified. Cold functions and loop less parts of functions executed once are | |
12878 | then optimized for size. | |
12879 | Enabled by default at @option{-O1} and higher. | |
12880 | ||
d77de738 | 12881 | @opindex fipa-modref |
ddf6fe37 | 12882 | @item -fipa-modref |
d77de738 ML |
12883 | Perform interprocedural mod/ref analysis. This optimization analyzes the side |
12884 | effects of functions (memory locations that are modified or referenced) and | |
12885 | enables better optimization across the function call boundary. This flag is | |
12886 | enabled by default at @option{-O1} and higher. | |
12887 | ||
d77de738 | 12888 | @opindex fipa-cp |
ddf6fe37 | 12889 | @item -fipa-cp |
d77de738 ML |
12890 | Perform interprocedural constant propagation. |
12891 | This optimization analyzes the program to determine when values passed | |
12892 | to functions are constants and then optimizes accordingly. | |
12893 | This optimization can substantially increase performance | |
12894 | if the application has constants passed to functions. | |
12895 | This flag is enabled by default at @option{-O2}, @option{-Os} and @option{-O3}. | |
12896 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
12897 | ||
d77de738 | 12898 | @opindex fipa-cp-clone |
ddf6fe37 | 12899 | @item -fipa-cp-clone |
d77de738 ML |
12900 | Perform function cloning to make interprocedural constant propagation stronger. |
12901 | When enabled, interprocedural constant propagation performs function cloning | |
12902 | when externally visible function can be called with constant arguments. | |
12903 | Because this optimization can create multiple copies of functions, | |
12904 | it may significantly increase code size | |
12905 | (see @option{--param ipa-cp-unit-growth=@var{value}}). | |
12906 | This flag is enabled by default at @option{-O3}. | |
12907 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
12908 | ||
d77de738 | 12909 | @opindex fipa-bit-cp |
ddf6fe37 | 12910 | @item -fipa-bit-cp |
d77de738 ML |
12911 | When enabled, perform interprocedural bitwise constant |
12912 | propagation. This flag is enabled by default at @option{-O2} and | |
12913 | by @option{-fprofile-use} and @option{-fauto-profile}. | |
12914 | It requires that @option{-fipa-cp} is enabled. | |
12915 | ||
d77de738 | 12916 | @opindex fipa-vrp |
ddf6fe37 | 12917 | @item -fipa-vrp |
d77de738 ML |
12918 | When enabled, perform interprocedural propagation of value |
12919 | ranges. This flag is enabled by default at @option{-O2}. It requires | |
12920 | that @option{-fipa-cp} is enabled. | |
12921 | ||
d77de738 | 12922 | @opindex fipa-icf |
ddf6fe37 | 12923 | @item -fipa-icf |
d77de738 ML |
12924 | Perform Identical Code Folding for functions and read-only variables. |
12925 | The optimization reduces code size and may disturb unwind stacks by replacing | |
12926 | a function by equivalent one with a different name. The optimization works | |
12927 | more effectively with link-time optimization enabled. | |
12928 | ||
12929 | Although the behavior is similar to the Gold Linker's ICF optimization, GCC ICF | |
12930 | works on different levels and thus the optimizations are not same - there are | |
12931 | equivalences that are found only by GCC and equivalences found only by Gold. | |
12932 | ||
12933 | This flag is enabled by default at @option{-O2} and @option{-Os}. | |
12934 | ||
d77de738 | 12935 | @opindex flive-patching |
ddf6fe37 | 12936 | @item -flive-patching=@var{level} |
d77de738 ML |
12937 | Control GCC's optimizations to produce output suitable for live-patching. |
12938 | ||
12939 | If the compiler's optimization uses a function's body or information extracted | |
12940 | from its body to optimize/change another function, the latter is called an | |
12941 | impacted function of the former. If a function is patched, its impacted | |
12942 | functions should be patched too. | |
12943 | ||
12944 | The impacted functions are determined by the compiler's interprocedural | |
12945 | optimizations. For example, a caller is impacted when inlining a function | |
12946 | into its caller, | |
12947 | cloning a function and changing its caller to call this new clone, | |
12948 | or extracting a function's pureness/constness information to optimize | |
12949 | its direct or indirect callers, etc. | |
12950 | ||
12951 | Usually, the more IPA optimizations enabled, the larger the number of | |
12952 | impacted functions for each function. In order to control the number of | |
12953 | impacted functions and more easily compute the list of impacted function, | |
12954 | IPA optimizations can be partially enabled at two different levels. | |
12955 | ||
12956 | The @var{level} argument should be one of the following: | |
12957 | ||
12958 | @table @samp | |
12959 | ||
12960 | @item inline-clone | |
12961 | ||
12962 | Only enable inlining and cloning optimizations, which includes inlining, | |
12963 | cloning, interprocedural scalar replacement of aggregates and partial inlining. | |
12964 | As a result, when patching a function, all its callers and its clones' | |
12965 | callers are impacted, therefore need to be patched as well. | |
12966 | ||
12967 | @option{-flive-patching=inline-clone} disables the following optimization flags: | |
43b72ede AA |
12968 | @gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra |
12969 | -fipa-icf -fipa-icf-functions -fipa-icf-variables | |
12970 | -fipa-bit-cp -fipa-vrp -fipa-pure-const | |
12971 | -fipa-reference-addressable | |
d77de738 ML |
12972 | -fipa-stack-alignment -fipa-modref} |
12973 | ||
12974 | @item inline-only-static | |
12975 | ||
12976 | Only enable inlining of static functions. | |
12977 | As a result, when patching a static function, all its callers are impacted | |
12978 | and so need to be patched as well. | |
12979 | ||
12980 | In addition to all the flags that @option{-flive-patching=inline-clone} | |
12981 | disables, | |
12982 | @option{-flive-patching=inline-only-static} disables the following additional | |
12983 | optimization flags: | |
12984 | @gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp} | |
12985 | ||
12986 | @end table | |
12987 | ||
12988 | When @option{-flive-patching} is specified without any value, the default value | |
12989 | is @var{inline-clone}. | |
12990 | ||
12991 | This flag is disabled by default. | |
12992 | ||
12993 | Note that @option{-flive-patching} is not supported with link-time optimization | |
12994 | (@option{-flto}). | |
12995 | ||
d77de738 | 12996 | @opindex fisolate-erroneous-paths-dereference |
ddf6fe37 | 12997 | @item -fisolate-erroneous-paths-dereference |
d77de738 ML |
12998 | Detect paths that trigger erroneous or undefined behavior due to |
12999 | dereferencing a null pointer. Isolate those paths from the main control | |
13000 | flow and turn the statement with erroneous or undefined behavior into a trap. | |
13001 | This flag is enabled by default at @option{-O2} and higher and depends on | |
13002 | @option{-fdelete-null-pointer-checks} also being enabled. | |
13003 | ||
d77de738 | 13004 | @opindex fisolate-erroneous-paths-attribute |
ddf6fe37 | 13005 | @item -fisolate-erroneous-paths-attribute |
d77de738 ML |
13006 | Detect paths that trigger erroneous or undefined behavior due to a null value |
13007 | being used in a way forbidden by a @code{returns_nonnull} or @code{nonnull} | |
13008 | attribute. Isolate those paths from the main control flow and turn the | |
13009 | statement with erroneous or undefined behavior into a trap. This is not | |
13010 | currently enabled, but may be enabled by @option{-O2} in the future. | |
13011 | ||
d77de738 | 13012 | @opindex ftree-sink |
ddf6fe37 | 13013 | @item -ftree-sink |
d77de738 ML |
13014 | Perform forward store motion on trees. This flag is |
13015 | enabled by default at @option{-O1} and higher. | |
13016 | ||
d77de738 | 13017 | @opindex ftree-bit-ccp |
ddf6fe37 | 13018 | @item -ftree-bit-ccp |
d77de738 ML |
13019 | Perform sparse conditional bit constant propagation on trees and propagate |
13020 | pointer alignment information. | |
13021 | This pass only operates on local scalar variables and is enabled by default | |
13022 | at @option{-O1} and higher, except for @option{-Og}. | |
13023 | It requires that @option{-ftree-ccp} is enabled. | |
13024 | ||
d77de738 | 13025 | @opindex ftree-ccp |
ddf6fe37 | 13026 | @item -ftree-ccp |
d77de738 ML |
13027 | Perform sparse conditional constant propagation (CCP) on trees. This |
13028 | pass only operates on local scalar variables and is enabled by default | |
13029 | at @option{-O1} and higher. | |
13030 | ||
d77de738 | 13031 | @opindex fssa-backprop |
ddf6fe37 | 13032 | @item -fssa-backprop |
d77de738 ML |
13033 | Propagate information about uses of a value up the definition chain |
13034 | in order to simplify the definitions. For example, this pass strips | |
13035 | sign operations if the sign of a value never matters. The flag is | |
13036 | enabled by default at @option{-O1} and higher. | |
13037 | ||
d77de738 | 13038 | @opindex fssa-phiopt |
ddf6fe37 | 13039 | @item -fssa-phiopt |
d77de738 ML |
13040 | Perform pattern matching on SSA PHI nodes to optimize conditional |
13041 | code. This pass is enabled by default at @option{-O1} and higher, | |
13042 | except for @option{-Og}. | |
13043 | ||
d77de738 | 13044 | @opindex ftree-switch-conversion |
ddf6fe37 | 13045 | @item -ftree-switch-conversion |
d77de738 ML |
13046 | Perform conversion of simple initializations in a switch to |
13047 | initializations from a scalar array. This flag is enabled by default | |
13048 | at @option{-O2} and higher. | |
13049 | ||
d77de738 | 13050 | @opindex ftree-tail-merge |
ddf6fe37 | 13051 | @item -ftree-tail-merge |
d77de738 ML |
13052 | Look for identical code sequences. When found, replace one with a jump to the |
13053 | other. This optimization is known as tail merging or cross jumping. This flag | |
13054 | is enabled by default at @option{-O2} and higher. The compilation time | |
13055 | in this pass can | |
13056 | be limited using @option{max-tail-merge-comparisons} parameter and | |
13057 | @option{max-tail-merge-iterations} parameter. | |
13058 | ||
d77de738 | 13059 | @opindex ftree-dce |
ddf6fe37 | 13060 | @item -ftree-dce |
d77de738 ML |
13061 | Perform dead code elimination (DCE) on trees. This flag is enabled by |
13062 | default at @option{-O1} and higher. | |
13063 | ||
d77de738 | 13064 | @opindex ftree-builtin-call-dce |
ddf6fe37 | 13065 | @item -ftree-builtin-call-dce |
d77de738 ML |
13066 | Perform conditional dead code elimination (DCE) for calls to built-in functions |
13067 | that may set @code{errno} but are otherwise free of side effects. This flag is | |
13068 | enabled by default at @option{-O2} and higher if @option{-Os} is not also | |
13069 | specified. | |
13070 | ||
d77de738 ML |
13071 | @opindex ffinite-loops |
13072 | @opindex fno-finite-loops | |
ddf6fe37 | 13073 | @item -ffinite-loops |
d77de738 ML |
13074 | Assume that a loop with an exit will eventually take the exit and not loop |
13075 | indefinitely. This allows the compiler to remove loops that otherwise have | |
13076 | no side-effects, not considering eventual endless looping as such. | |
13077 | ||
13078 | This option is enabled by default at @option{-O2} for C++ with -std=c++11 | |
13079 | or higher. | |
13080 | ||
d77de738 | 13081 | @opindex ftree-dominator-opts |
ddf6fe37 | 13082 | @item -ftree-dominator-opts |
d77de738 ML |
13083 | Perform a variety of simple scalar cleanups (constant/copy |
13084 | propagation, redundancy elimination, range propagation and expression | |
13085 | simplification) based on a dominator tree traversal. This also | |
13086 | performs jump threading (to reduce jumps to jumps). This flag is | |
13087 | enabled by default at @option{-O1} and higher. | |
13088 | ||
d77de738 | 13089 | @opindex ftree-dse |
ddf6fe37 | 13090 | @item -ftree-dse |
d77de738 ML |
13091 | Perform dead store elimination (DSE) on trees. A dead store is a store into |
13092 | a memory location that is later overwritten by another store without | |
13093 | any intervening loads. In this case the earlier store can be deleted. This | |
13094 | flag is enabled by default at @option{-O1} and higher. | |
13095 | ||
d77de738 | 13096 | @opindex ftree-ch |
ddf6fe37 | 13097 | @item -ftree-ch |
d77de738 ML |
13098 | Perform loop header copying on trees. This is beneficial since it increases |
13099 | effectiveness of code motion optimizations. It also saves one jump. This flag | |
13100 | is enabled by default at @option{-O1} and higher. It is not enabled | |
13101 | for @option{-Os}, since it usually increases code size. | |
13102 | ||
d77de738 | 13103 | @opindex ftree-loop-optimize |
ddf6fe37 | 13104 | @item -ftree-loop-optimize |
d77de738 ML |
13105 | Perform loop optimizations on trees. This flag is enabled by default |
13106 | at @option{-O1} and higher. | |
13107 | ||
d77de738 ML |
13108 | @opindex ftree-loop-linear |
13109 | @opindex floop-strip-mine | |
13110 | @opindex floop-block | |
ddf6fe37 AA |
13111 | @item -ftree-loop-linear |
13112 | @itemx -floop-strip-mine | |
13113 | @itemx -floop-block | |
d77de738 ML |
13114 | Perform loop nest optimizations. Same as |
13115 | @option{-floop-nest-optimize}. To use this code transformation, GCC has | |
13116 | to be configured with @option{--with-isl} to enable the Graphite loop | |
13117 | transformation infrastructure. | |
13118 | ||
d77de738 | 13119 | @opindex fgraphite-identity |
ddf6fe37 | 13120 | @item -fgraphite-identity |
d77de738 ML |
13121 | Enable the identity transformation for graphite. For every SCoP we generate |
13122 | the polyhedral representation and transform it back to gimple. Using | |
13123 | @option{-fgraphite-identity} we can check the costs or benefits of the | |
13124 | GIMPLE -> GRAPHITE -> GIMPLE transformation. Some minimal optimizations | |
13125 | are also performed by the code generator isl, like index splitting and | |
13126 | dead code elimination in loops. | |
13127 | ||
d77de738 | 13128 | @opindex floop-nest-optimize |
ddf6fe37 | 13129 | @item -floop-nest-optimize |
d77de738 ML |
13130 | Enable the isl based loop nest optimizer. This is a generic loop nest |
13131 | optimizer based on the Pluto optimization algorithms. It calculates a loop | |
13132 | structure optimized for data-locality and parallelism. This option | |
13133 | is experimental. | |
13134 | ||
d77de738 | 13135 | @opindex floop-parallelize-all |
ddf6fe37 | 13136 | @item -floop-parallelize-all |
d77de738 ML |
13137 | Use the Graphite data dependence analysis to identify loops that can |
13138 | be parallelized. Parallelize all the loops that can be analyzed to | |
13139 | not contain loop carried dependences without checking that it is | |
13140 | profitable to parallelize the loops. | |
13141 | ||
d77de738 | 13142 | @opindex ftree-coalesce-vars |
ddf6fe37 | 13143 | @item -ftree-coalesce-vars |
d77de738 ML |
13144 | While transforming the program out of the SSA representation, attempt to |
13145 | reduce copying by coalescing versions of different user-defined | |
13146 | variables, instead of just compiler temporaries. This may severely | |
13147 | limit the ability to debug an optimized program compiled with | |
13148 | @option{-fno-var-tracking-assignments}. In the negated form, this flag | |
13149 | prevents SSA coalescing of user variables. This option is enabled by | |
13150 | default if optimization is enabled, and it does very little otherwise. | |
13151 | ||
d77de738 | 13152 | @opindex ftree-loop-if-convert |
ddf6fe37 | 13153 | @item -ftree-loop-if-convert |
d77de738 ML |
13154 | Attempt to transform conditional jumps in the innermost loops to |
13155 | branch-less equivalents. The intent is to remove control-flow from | |
13156 | the innermost loops in order to improve the ability of the | |
13157 | vectorization pass to handle these loops. This is enabled by default | |
13158 | if vectorization is enabled. | |
13159 | ||
d77de738 | 13160 | @opindex ftree-loop-distribution |
ddf6fe37 | 13161 | @item -ftree-loop-distribution |
d77de738 ML |
13162 | Perform loop distribution. This flag can improve cache performance on |
13163 | big loop bodies and allow further loop optimizations, like | |
13164 | parallelization or vectorization, to take place. For example, the loop | |
13165 | @smallexample | |
13166 | DO I = 1, N | |
13167 | A(I) = B(I) + C | |
13168 | D(I) = E(I) * F | |
13169 | ENDDO | |
13170 | @end smallexample | |
13171 | is transformed to | |
13172 | @smallexample | |
13173 | DO I = 1, N | |
13174 | A(I) = B(I) + C | |
13175 | ENDDO | |
13176 | DO I = 1, N | |
13177 | D(I) = E(I) * F | |
13178 | ENDDO | |
13179 | @end smallexample | |
13180 | This flag is enabled by default at @option{-O3}. | |
13181 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13182 | ||
d77de738 | 13183 | @opindex ftree-loop-distribute-patterns |
ddf6fe37 | 13184 | @item -ftree-loop-distribute-patterns |
d77de738 ML |
13185 | Perform loop distribution of patterns that can be code generated with |
13186 | calls to a library. This flag is enabled by default at @option{-O2} and | |
13187 | higher, and by @option{-fprofile-use} and @option{-fauto-profile}. | |
13188 | ||
13189 | This pass distributes the initialization loops and generates a call to | |
13190 | memset zero. For example, the loop | |
13191 | @smallexample | |
13192 | DO I = 1, N | |
13193 | A(I) = 0 | |
13194 | B(I) = A(I) + I | |
13195 | ENDDO | |
13196 | @end smallexample | |
13197 | is transformed to | |
13198 | @smallexample | |
13199 | DO I = 1, N | |
13200 | A(I) = 0 | |
13201 | ENDDO | |
13202 | DO I = 1, N | |
13203 | B(I) = A(I) + I | |
13204 | ENDDO | |
13205 | @end smallexample | |
13206 | and the initialization loop is transformed into a call to memset zero. | |
13207 | This flag is enabled by default at @option{-O3}. | |
13208 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13209 | ||
d77de738 | 13210 | @opindex floop-interchange |
ddf6fe37 | 13211 | @item -floop-interchange |
d77de738 ML |
13212 | Perform loop interchange outside of graphite. This flag can improve cache |
13213 | performance on loop nest and allow further loop optimizations, like | |
13214 | vectorization, to take place. For example, the loop | |
13215 | @smallexample | |
13216 | for (int i = 0; i < N; i++) | |
13217 | for (int j = 0; j < N; j++) | |
13218 | for (int k = 0; k < N; k++) | |
13219 | c[i][j] = c[i][j] + a[i][k]*b[k][j]; | |
13220 | @end smallexample | |
13221 | is transformed to | |
13222 | @smallexample | |
13223 | for (int i = 0; i < N; i++) | |
13224 | for (int k = 0; k < N; k++) | |
13225 | for (int j = 0; j < N; j++) | |
13226 | c[i][j] = c[i][j] + a[i][k]*b[k][j]; | |
13227 | @end smallexample | |
13228 | This flag is enabled by default at @option{-O3}. | |
13229 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13230 | ||
d77de738 | 13231 | @opindex floop-unroll-and-jam |
ddf6fe37 | 13232 | @item -floop-unroll-and-jam |
d77de738 ML |
13233 | Apply unroll and jam transformations on feasible loops. In a loop |
13234 | nest this unrolls the outer loop by some factor and fuses the resulting | |
13235 | multiple inner loops. This flag is enabled by default at @option{-O3}. | |
13236 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13237 | ||
d77de738 | 13238 | @opindex ftree-loop-im |
ddf6fe37 | 13239 | @item -ftree-loop-im |
d77de738 ML |
13240 | Perform loop invariant motion on trees. This pass moves only invariants that |
13241 | are hard to handle at RTL level (function calls, operations that expand to | |
13242 | nontrivial sequences of insns). With @option{-funswitch-loops} it also moves | |
13243 | operands of conditions that are invariant out of the loop, so that we can use | |
13244 | just trivial invariantness analysis in loop unswitching. The pass also includes | |
13245 | store motion. | |
13246 | ||
d77de738 | 13247 | @opindex ftree-loop-ivcanon |
ddf6fe37 | 13248 | @item -ftree-loop-ivcanon |
d77de738 ML |
13249 | Create a canonical counter for number of iterations in loops for which |
13250 | determining number of iterations requires complicated analysis. Later | |
13251 | optimizations then may determine the number easily. Useful especially | |
13252 | in connection with unrolling. | |
13253 | ||
d77de738 | 13254 | @opindex ftree-scev-cprop |
ddf6fe37 | 13255 | @item -ftree-scev-cprop |
d77de738 ML |
13256 | Perform final value replacement. If a variable is modified in a loop |
13257 | in such a way that its value when exiting the loop can be determined using | |
13258 | only its initial value and the number of loop iterations, replace uses of | |
13259 | the final value by such a computation, provided it is sufficiently cheap. | |
13260 | This reduces data dependencies and may allow further simplifications. | |
13261 | Enabled by default at @option{-O1} and higher. | |
13262 | ||
d77de738 | 13263 | @opindex fivopts |
ddf6fe37 | 13264 | @item -fivopts |
d77de738 ML |
13265 | Perform induction variable optimizations (strength reduction, induction |
13266 | variable merging and induction variable elimination) on trees. | |
13267 | ||
d77de738 | 13268 | @opindex ftree-parallelize-loops |
ddf6fe37 | 13269 | @item -ftree-parallelize-loops=n |
d77de738 ML |
13270 | Parallelize loops, i.e., split their iteration space to run in n threads. |
13271 | This is only possible for loops whose iterations are independent | |
13272 | and can be arbitrarily reordered. The optimization is only | |
13273 | profitable on multiprocessor machines, for loops that are CPU-intensive, | |
13274 | rather than constrained e.g.@: by memory bandwidth. This option | |
13275 | implies @option{-pthread}, and thus is only supported on targets | |
13276 | that have support for @option{-pthread}. | |
13277 | ||
d77de738 | 13278 | @opindex ftree-pta |
ddf6fe37 | 13279 | @item -ftree-pta |
d77de738 ML |
13280 | Perform function-local points-to analysis on trees. This flag is |
13281 | enabled by default at @option{-O1} and higher, except for @option{-Og}. | |
13282 | ||
d77de738 | 13283 | @opindex ftree-sra |
ddf6fe37 | 13284 | @item -ftree-sra |
d77de738 ML |
13285 | Perform scalar replacement of aggregates. This pass replaces structure |
13286 | references with scalars to prevent committing structures to memory too | |
13287 | early. This flag is enabled by default at @option{-O1} and higher, | |
13288 | except for @option{-Og}. | |
13289 | ||
d77de738 | 13290 | @opindex fstore-merging |
ddf6fe37 | 13291 | @item -fstore-merging |
d77de738 ML |
13292 | Perform merging of narrow stores to consecutive memory addresses. This pass |
13293 | merges contiguous stores of immediate values narrower than a word into fewer | |
13294 | wider stores to reduce the number of instructions. This is enabled by default | |
13295 | at @option{-O2} and higher as well as @option{-Os}. | |
13296 | ||
d77de738 | 13297 | @opindex ftree-ter |
ddf6fe37 | 13298 | @item -ftree-ter |
d77de738 ML |
13299 | Perform temporary expression replacement during the SSA->normal phase. Single |
13300 | use/single def temporaries are replaced at their use location with their | |
13301 | defining expression. This results in non-GIMPLE code, but gives the expanders | |
13302 | much more complex trees to work on resulting in better RTL generation. This is | |
13303 | enabled by default at @option{-O1} and higher. | |
13304 | ||
d77de738 | 13305 | @opindex ftree-slsr |
ddf6fe37 | 13306 | @item -ftree-slsr |
d77de738 ML |
13307 | Perform straight-line strength reduction on trees. This recognizes related |
13308 | expressions involving multiplications and replaces them by less expensive | |
13309 | calculations when possible. This is enabled by default at @option{-O1} and | |
13310 | higher. | |
13311 | ||
d77de738 | 13312 | @opindex ftree-vectorize |
ddf6fe37 | 13313 | @item -ftree-vectorize |
d77de738 ML |
13314 | Perform vectorization on trees. This flag enables @option{-ftree-loop-vectorize} |
13315 | and @option{-ftree-slp-vectorize} if not explicitly specified. | |
13316 | ||
d77de738 | 13317 | @opindex ftree-loop-vectorize |
ddf6fe37 | 13318 | @item -ftree-loop-vectorize |
d77de738 ML |
13319 | Perform loop vectorization on trees. This flag is enabled by default at |
13320 | @option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use}, | |
13321 | and @option{-fauto-profile}. | |
13322 | ||
d77de738 | 13323 | @opindex ftree-slp-vectorize |
ddf6fe37 | 13324 | @item -ftree-slp-vectorize |
d77de738 ML |
13325 | Perform basic block vectorization on trees. This flag is enabled by default at |
13326 | @option{-O2} and by @option{-ftree-vectorize}, @option{-fprofile-use}, | |
13327 | and @option{-fauto-profile}. | |
13328 | ||
d77de738 | 13329 | @opindex ftrivial-auto-var-init |
ddf6fe37 | 13330 | @item -ftrivial-auto-var-init=@var{choice} |
d77de738 ML |
13331 | Initialize automatic variables with either a pattern or with zeroes to increase |
13332 | the security and predictability of a program by preventing uninitialized memory | |
13333 | disclosure and use. | |
13334 | GCC still considers an automatic variable that doesn't have an explicit | |
13335 | initializer as uninitialized, @option{-Wuninitialized} and | |
13336 | @option{-Wanalyzer-use-of-uninitialized-value} will still report | |
8f4634fb RB |
13337 | warning messages on such automatic variables and the compiler will |
13338 | perform optimization as if the variable were uninitialized. | |
d77de738 ML |
13339 | With this option, GCC will also initialize any padding of automatic variables |
13340 | that have structure or union types to zeroes. | |
13341 | However, the current implementation cannot initialize automatic variables that | |
13342 | are declared between the controlling expression and the first case of a | |
13343 | @code{switch} statement. Using @option{-Wtrivial-auto-var-init} to report all | |
13344 | such cases. | |
13345 | ||
13346 | The three values of @var{choice} are: | |
13347 | ||
13348 | @itemize @bullet | |
13349 | @item | |
13350 | @samp{uninitialized} doesn't initialize any automatic variables. | |
13351 | This is C and C++'s default. | |
13352 | ||
13353 | @item | |
13354 | @samp{pattern} Initialize automatic variables with values which will likely | |
13355 | transform logic bugs into crashes down the line, are easily recognized in a | |
13356 | crash dump and without being values that programmers can rely on for useful | |
13357 | program semantics. | |
13358 | The current value is byte-repeatable pattern with byte "0xFE". | |
13359 | The values used for pattern initialization might be changed in the future. | |
13360 | ||
13361 | @item | |
13362 | @samp{zero} Initialize automatic variables with zeroes. | |
13363 | @end itemize | |
13364 | ||
13365 | The default is @samp{uninitialized}. | |
13366 | ||
13367 | You can control this behavior for a specific variable by using the variable | |
13368 | attribute @code{uninitialized} (@pxref{Variable Attributes}). | |
13369 | ||
d77de738 | 13370 | @opindex fvect-cost-model |
ddf6fe37 | 13371 | @item -fvect-cost-model=@var{model} |
d77de738 ML |
13372 | Alter the cost model used for vectorization. The @var{model} argument |
13373 | should be one of @samp{unlimited}, @samp{dynamic}, @samp{cheap} or | |
13374 | @samp{very-cheap}. | |
13375 | With the @samp{unlimited} model the vectorized code-path is assumed | |
13376 | to be profitable while with the @samp{dynamic} model a runtime check | |
13377 | guards the vectorized code-path to enable it only for iteration | |
13378 | counts that will likely execute faster than when executing the original | |
13379 | scalar loop. The @samp{cheap} model disables vectorization of | |
13380 | loops where doing so would be cost prohibitive for example due to | |
13381 | required runtime checks for data dependence or alignment but otherwise | |
13382 | is equal to the @samp{dynamic} model. The @samp{very-cheap} model only | |
13383 | allows vectorization if the vector code would entirely replace the | |
13384 | scalar code that is being vectorized. For example, if each iteration | |
13385 | of a vectorized loop would only be able to handle exactly four iterations | |
13386 | of the scalar loop, the @samp{very-cheap} model would only allow | |
13387 | vectorization if the scalar iteration count is known to be a multiple | |
13388 | of four. | |
13389 | ||
13390 | The default cost model depends on other optimization flags and is | |
13391 | either @samp{dynamic} or @samp{cheap}. | |
13392 | ||
d77de738 | 13393 | @opindex fsimd-cost-model |
ddf6fe37 | 13394 | @item -fsimd-cost-model=@var{model} |
d77de738 ML |
13395 | Alter the cost model used for vectorization of loops marked with the OpenMP |
13396 | simd directive. The @var{model} argument should be one of | |
13397 | @samp{unlimited}, @samp{dynamic}, @samp{cheap}. All values of @var{model} | |
13398 | have the same meaning as described in @option{-fvect-cost-model} and by | |
13399 | default a cost model defined with @option{-fvect-cost-model} is used. | |
13400 | ||
d77de738 | 13401 | @opindex ftree-vrp |
ddf6fe37 | 13402 | @item -ftree-vrp |
d77de738 ML |
13403 | Perform Value Range Propagation on trees. This is similar to the |
13404 | constant propagation pass, but instead of values, ranges of values are | |
13405 | propagated. This allows the optimizers to remove unnecessary range | |
13406 | checks like array bound checks and null pointer checks. This is | |
13407 | enabled by default at @option{-O2} and higher. Null pointer check | |
13408 | elimination is only done if @option{-fdelete-null-pointer-checks} is | |
13409 | enabled. | |
13410 | ||
d77de738 | 13411 | @opindex fsplit-paths |
ddf6fe37 | 13412 | @item -fsplit-paths |
d77de738 ML |
13413 | Split paths leading to loop backedges. This can improve dead code |
13414 | elimination and common subexpression elimination. This is enabled by | |
13415 | default at @option{-O3} and above. | |
13416 | ||
d77de738 | 13417 | @opindex fsplit-ivs-in-unroller |
ddf6fe37 | 13418 | @item -fsplit-ivs-in-unroller |
d77de738 ML |
13419 | Enables expression of values of induction variables in later iterations |
13420 | of the unrolled loop using the value in the first iteration. This breaks | |
13421 | long dependency chains, thus improving efficiency of the scheduling passes. | |
13422 | ||
13423 | A combination of @option{-fweb} and CSE is often sufficient to obtain the | |
13424 | same effect. However, that is not reliable in cases where the loop body | |
13425 | is more complicated than a single basic block. It also does not work at all | |
13426 | on some architectures due to restrictions in the CSE pass. | |
13427 | ||
13428 | This optimization is enabled by default. | |
13429 | ||
d77de738 | 13430 | @opindex fvariable-expansion-in-unroller |
ddf6fe37 | 13431 | @item -fvariable-expansion-in-unroller |
d77de738 ML |
13432 | With this option, the compiler creates multiple copies of some |
13433 | local variables when unrolling a loop, which can result in superior code. | |
13434 | ||
13435 | This optimization is enabled by default for PowerPC targets, but disabled | |
13436 | by default otherwise. | |
13437 | ||
d77de738 | 13438 | @opindex fpartial-inlining |
ddf6fe37 | 13439 | @item -fpartial-inlining |
d77de738 ML |
13440 | Inline parts of functions. This option has any effect only |
13441 | when inlining itself is turned on by the @option{-finline-functions} | |
13442 | or @option{-finline-small-functions} options. | |
13443 | ||
13444 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13445 | ||
d77de738 | 13446 | @opindex fpredictive-commoning |
ddf6fe37 | 13447 | @item -fpredictive-commoning |
d77de738 ML |
13448 | Perform predictive commoning optimization, i.e., reusing computations |
13449 | (especially memory loads and stores) performed in previous | |
13450 | iterations of loops. | |
13451 | ||
13452 | This option is enabled at level @option{-O3}. | |
13453 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
13454 | ||
d77de738 | 13455 | @opindex fprefetch-loop-arrays |
ddf6fe37 | 13456 | @item -fprefetch-loop-arrays |
d77de738 ML |
13457 | If supported by the target machine, generate instructions to prefetch |
13458 | memory to improve the performance of loops that access large arrays. | |
13459 | ||
13460 | This option may generate better or worse code; results are highly | |
13461 | dependent on the structure of loops within the source code. | |
13462 | ||
13463 | Disabled at level @option{-Os}. | |
13464 | ||
d77de738 ML |
13465 | @opindex fno-printf-return-value |
13466 | @opindex fprintf-return-value | |
ddf6fe37 | 13467 | @item -fno-printf-return-value |
d77de738 ML |
13468 | Do not substitute constants for known return value of formatted output |
13469 | functions such as @code{sprintf}, @code{snprintf}, @code{vsprintf}, and | |
13470 | @code{vsnprintf} (but not @code{printf} of @code{fprintf}). This | |
13471 | transformation allows GCC to optimize or even eliminate branches based | |
13472 | on the known return value of these functions called with arguments that | |
13473 | are either constant, or whose values are known to be in a range that | |
13474 | makes determining the exact return value possible. For example, when | |
13475 | @option{-fprintf-return-value} is in effect, both the branch and the | |
13476 | body of the @code{if} statement (but not the call to @code{snprint}) | |
13477 | can be optimized away when @code{i} is a 32-bit or smaller integer | |
13478 | because the return value is guaranteed to be at most 8. | |
13479 | ||
13480 | @smallexample | |
13481 | char buf[9]; | |
13482 | if (snprintf (buf, "%08x", i) >= sizeof buf) | |
13483 | @dots{} | |
13484 | @end smallexample | |
13485 | ||
13486 | The @option{-fprintf-return-value} option relies on other optimizations | |
13487 | and yields best results with @option{-O2} and above. It works in tandem | |
13488 | with the @option{-Wformat-overflow} and @option{-Wformat-truncation} | |
13489 | options. The @option{-fprintf-return-value} option is enabled by default. | |
13490 | ||
d77de738 ML |
13491 | @opindex fno-peephole |
13492 | @opindex fpeephole | |
13493 | @opindex fno-peephole2 | |
13494 | @opindex fpeephole2 | |
ddf6fe37 AA |
13495 | @item -fno-peephole |
13496 | @itemx -fno-peephole2 | |
d77de738 ML |
13497 | Disable any machine-specific peephole optimizations. The difference |
13498 | between @option{-fno-peephole} and @option{-fno-peephole2} is in how they | |
13499 | are implemented in the compiler; some targets use one, some use the | |
13500 | other, a few use both. | |
13501 | ||
13502 | @option{-fpeephole} is enabled by default. | |
13503 | @option{-fpeephole2} enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13504 | ||
d77de738 ML |
13505 | @opindex fno-guess-branch-probability |
13506 | @opindex fguess-branch-probability | |
ddf6fe37 | 13507 | @item -fno-guess-branch-probability |
d77de738 ML |
13508 | Do not guess branch probabilities using heuristics. |
13509 | ||
13510 | GCC uses heuristics to guess branch probabilities if they are | |
13511 | not provided by profiling feedback (@option{-fprofile-arcs}). These | |
13512 | heuristics are based on the control flow graph. If some branch probabilities | |
13513 | are specified by @code{__builtin_expect}, then the heuristics are | |
13514 | used to guess branch probabilities for the rest of the control flow graph, | |
13515 | taking the @code{__builtin_expect} info into account. The interactions | |
13516 | between the heuristics and @code{__builtin_expect} can be complex, and in | |
13517 | some cases, it may be useful to disable the heuristics so that the effects | |
13518 | of @code{__builtin_expect} are easier to understand. | |
13519 | ||
13520 | It is also possible to specify expected probability of the expression | |
13521 | with @code{__builtin_expect_with_probability} built-in function. | |
13522 | ||
13523 | The default is @option{-fguess-branch-probability} at levels | |
13524 | @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}. | |
13525 | ||
d77de738 | 13526 | @opindex freorder-blocks |
ddf6fe37 | 13527 | @item -freorder-blocks |
d77de738 ML |
13528 | Reorder basic blocks in the compiled function in order to reduce number of |
13529 | taken branches and improve code locality. | |
13530 | ||
13531 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
13532 | ||
d77de738 | 13533 | @opindex freorder-blocks-algorithm |
ddf6fe37 | 13534 | @item -freorder-blocks-algorithm=@var{algorithm} |
d77de738 ML |
13535 | Use the specified algorithm for basic block reordering. The |
13536 | @var{algorithm} argument can be @samp{simple}, which does not increase | |
13537 | code size (except sometimes due to secondary effects like alignment), | |
13538 | or @samp{stc}, the ``software trace cache'' algorithm, which tries to | |
13539 | put all often executed code together, minimizing the number of branches | |
13540 | executed by making extra copies of code. | |
13541 | ||
13542 | The default is @samp{simple} at levels @option{-O1}, @option{-Os}, and | |
13543 | @samp{stc} at levels @option{-O2}, @option{-O3}. | |
13544 | ||
d77de738 | 13545 | @opindex freorder-blocks-and-partition |
ddf6fe37 | 13546 | @item -freorder-blocks-and-partition |
d77de738 ML |
13547 | In addition to reordering basic blocks in the compiled function, in order |
13548 | to reduce number of taken branches, partitions hot and cold basic blocks | |
13549 | into separate sections of the assembly and @file{.o} files, to improve | |
13550 | paging and cache locality performance. | |
13551 | ||
13552 | This optimization is automatically turned off in the presence of | |
13553 | exception handling or unwind tables (on targets using setjump/longjump or target specific scheme), for linkonce sections, for functions with a user-defined | |
13554 | section attribute and on any architecture that does not support named | |
13555 | sections. When @option{-fsplit-stack} is used this option is not | |
13556 | enabled by default (to avoid linker errors), but may be enabled | |
13557 | explicitly (if using a working linker). | |
13558 | ||
13559 | Enabled for x86 at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13560 | ||
d77de738 | 13561 | @opindex freorder-functions |
ddf6fe37 | 13562 | @item -freorder-functions |
d77de738 ML |
13563 | Reorder functions in the object file in order to |
13564 | improve code locality. This is implemented by using special | |
13565 | subsections @code{.text.hot} for most frequently executed functions and | |
13566 | @code{.text.unlikely} for unlikely executed functions. Reordering is done by | |
13567 | the linker so object file format must support named sections and linker must | |
13568 | place them in a reasonable way. | |
13569 | ||
13570 | This option isn't effective unless you either provide profile feedback | |
13571 | (see @option{-fprofile-arcs} for details) or manually annotate functions with | |
13572 | @code{hot} or @code{cold} attributes (@pxref{Common Function Attributes}). | |
13573 | ||
13574 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
13575 | ||
d77de738 | 13576 | @opindex fstrict-aliasing |
ddf6fe37 | 13577 | @item -fstrict-aliasing |
d77de738 ML |
13578 | Allow the compiler to assume the strictest aliasing rules applicable to |
13579 | the language being compiled. For C (and C++), this activates | |
13580 | optimizations based on the type of expressions. In particular, an | |
13581 | object of one type is assumed never to reside at the same address as an | |
13582 | object of a different type, unless the types are almost the same. For | |
13583 | example, an @code{unsigned int} can alias an @code{int}, but not a | |
13584 | @code{void*} or a @code{double}. A character type may alias any other | |
13585 | type. | |
13586 | ||
13587 | @anchor{Type-punning}Pay special attention to code like this: | |
13588 | @smallexample | |
13589 | union a_union @{ | |
13590 | int i; | |
13591 | double d; | |
13592 | @}; | |
13593 | ||
13594 | int f() @{ | |
13595 | union a_union t; | |
13596 | t.d = 3.0; | |
13597 | return t.i; | |
13598 | @} | |
13599 | @end smallexample | |
13600 | The practice of reading from a different union member than the one most | |
13601 | recently written to (called ``type-punning'') is common. Even with | |
13602 | @option{-fstrict-aliasing}, type-punning is allowed, provided the memory | |
13603 | is accessed through the union type. So, the code above works as | |
13604 | expected. @xref{Structures unions enumerations and bit-fields | |
13605 | implementation}. However, this code might not: | |
13606 | @smallexample | |
13607 | int f() @{ | |
13608 | union a_union t; | |
13609 | int* ip; | |
13610 | t.d = 3.0; | |
13611 | ip = &t.i; | |
13612 | return *ip; | |
13613 | @} | |
13614 | @end smallexample | |
13615 | ||
13616 | Similarly, access by taking the address, casting the resulting pointer | |
13617 | and dereferencing the result has undefined behavior, even if the cast | |
13618 | uses a union type, e.g.: | |
13619 | @smallexample | |
13620 | int f() @{ | |
13621 | double d = 3.0; | |
13622 | return ((union a_union *) &d)->i; | |
13623 | @} | |
13624 | @end smallexample | |
13625 | ||
13626 | The @option{-fstrict-aliasing} option is enabled at levels | |
13627 | @option{-O2}, @option{-O3}, @option{-Os}. | |
13628 | ||
d77de738 | 13629 | @opindex fipa-strict-aliasing |
ddf6fe37 | 13630 | @item -fipa-strict-aliasing |
d77de738 ML |
13631 | Controls whether rules of @option{-fstrict-aliasing} are applied across |
13632 | function boundaries. Note that if multiple functions gets inlined into a | |
13633 | single function the memory accesses are no longer considered to be crossing a | |
13634 | function boundary. | |
13635 | ||
13636 | The @option{-fipa-strict-aliasing} option is enabled by default and is | |
13637 | effective only in combination with @option{-fstrict-aliasing}. | |
13638 | ||
ddf6fe37 | 13639 | @opindex falign-functions |
d77de738 ML |
13640 | @item -falign-functions |
13641 | @itemx -falign-functions=@var{n} | |
13642 | @itemx -falign-functions=@var{n}:@var{m} | |
13643 | @itemx -falign-functions=@var{n}:@var{m}:@var{n2} | |
13644 | @itemx -falign-functions=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
13645 | Align the start of functions to the next power-of-two greater than or |
13646 | equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at | |
13647 | least the first @var{m} bytes of the function can be fetched by the CPU | |
13648 | without crossing an @var{n}-byte alignment boundary. | |
13649 | ||
13650 | If @var{m} is not specified, it defaults to @var{n}. | |
13651 | ||
13652 | Examples: @option{-falign-functions=32} aligns functions to the next | |
13653 | 32-byte boundary, @option{-falign-functions=24} aligns to the next | |
13654 | 32-byte boundary only if this can be done by skipping 23 bytes or less, | |
13655 | @option{-falign-functions=32:7} aligns to the next | |
13656 | 32-byte boundary only if this can be done by skipping 6 bytes or less. | |
13657 | ||
13658 | The second pair of @var{n2}:@var{m2} values allows you to specify | |
13659 | a secondary alignment: @option{-falign-functions=64:7:32:3} aligns to | |
13660 | the next 64-byte boundary if this can be done by skipping 6 bytes or less, | |
13661 | otherwise aligns to the next 32-byte boundary if this can be done | |
13662 | by skipping 2 bytes or less. | |
13663 | If @var{m2} is not specified, it defaults to @var{n2}. | |
13664 | ||
13665 | Some assemblers only support this flag when @var{n} is a power of two; | |
13666 | in that case, it is rounded up. | |
13667 | ||
13668 | @option{-fno-align-functions} and @option{-falign-functions=1} are | |
13669 | equivalent and mean that functions are not aligned. | |
13670 | ||
13671 | If @var{n} is not specified or is zero, use a machine-dependent default. | |
13672 | The maximum allowed @var{n} option value is 65536. | |
13673 | ||
13674 | Enabled at levels @option{-O2}, @option{-O3}. | |
13675 | ||
13676 | @item -flimit-function-alignment | |
13677 | If this option is enabled, the compiler tries to avoid unnecessarily | |
13678 | overaligning functions. It attempts to instruct the assembler to align | |
13679 | by the amount specified by @option{-falign-functions}, but not to | |
13680 | skip more bytes than the size of the function. | |
13681 | ||
ddf6fe37 | 13682 | @opindex falign-labels |
d77de738 ML |
13683 | @item -falign-labels |
13684 | @itemx -falign-labels=@var{n} | |
13685 | @itemx -falign-labels=@var{n}:@var{m} | |
13686 | @itemx -falign-labels=@var{n}:@var{m}:@var{n2} | |
13687 | @itemx -falign-labels=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
13688 | Align all branch targets to a power-of-two boundary. |
13689 | ||
13690 | Parameters of this option are analogous to the @option{-falign-functions} option. | |
13691 | @option{-fno-align-labels} and @option{-falign-labels=1} are | |
13692 | equivalent and mean that labels are not aligned. | |
13693 | ||
13694 | If @option{-falign-loops} or @option{-falign-jumps} are applicable and | |
13695 | are greater than this value, then their values are used instead. | |
13696 | ||
13697 | If @var{n} is not specified or is zero, use a machine-dependent default | |
13698 | which is very likely to be @samp{1}, meaning no alignment. | |
13699 | The maximum allowed @var{n} option value is 65536. | |
13700 | ||
13701 | Enabled at levels @option{-O2}, @option{-O3}. | |
13702 | ||
ddf6fe37 | 13703 | @opindex falign-loops |
d77de738 ML |
13704 | @item -falign-loops |
13705 | @itemx -falign-loops=@var{n} | |
13706 | @itemx -falign-loops=@var{n}:@var{m} | |
13707 | @itemx -falign-loops=@var{n}:@var{m}:@var{n2} | |
13708 | @itemx -falign-loops=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
13709 | Align loops to a power-of-two boundary. If the loops are executed |
13710 | many times, this makes up for any execution of the dummy padding | |
13711 | instructions. | |
13712 | ||
13713 | If @option{-falign-labels} is greater than this value, then its value | |
13714 | is used instead. | |
13715 | ||
13716 | Parameters of this option are analogous to the @option{-falign-functions} option. | |
13717 | @option{-fno-align-loops} and @option{-falign-loops=1} are | |
13718 | equivalent and mean that loops are not aligned. | |
13719 | The maximum allowed @var{n} option value is 65536. | |
13720 | ||
13721 | If @var{n} is not specified or is zero, use a machine-dependent default. | |
13722 | ||
13723 | Enabled at levels @option{-O2}, @option{-O3}. | |
13724 | ||
ddf6fe37 | 13725 | @opindex falign-jumps |
d77de738 ML |
13726 | @item -falign-jumps |
13727 | @itemx -falign-jumps=@var{n} | |
13728 | @itemx -falign-jumps=@var{n}:@var{m} | |
13729 | @itemx -falign-jumps=@var{n}:@var{m}:@var{n2} | |
13730 | @itemx -falign-jumps=@var{n}:@var{m}:@var{n2}:@var{m2} | |
d77de738 ML |
13731 | Align branch targets to a power-of-two boundary, for branch targets |
13732 | where the targets can only be reached by jumping. In this case, | |
13733 | no dummy operations need be executed. | |
13734 | ||
13735 | If @option{-falign-labels} is greater than this value, then its value | |
13736 | is used instead. | |
13737 | ||
13738 | Parameters of this option are analogous to the @option{-falign-functions} option. | |
13739 | @option{-fno-align-jumps} and @option{-falign-jumps=1} are | |
13740 | equivalent and mean that loops are not aligned. | |
13741 | ||
13742 | If @var{n} is not specified or is zero, use a machine-dependent default. | |
13743 | The maximum allowed @var{n} option value is 65536. | |
13744 | ||
13745 | Enabled at levels @option{-O2}, @option{-O3}. | |
13746 | ||
d77de738 | 13747 | @opindex fno-allocation-dce |
ddf6fe37 | 13748 | @item -fno-allocation-dce |
d77de738 ML |
13749 | Do not remove unused C++ allocations in dead code elimination. |
13750 | ||
d77de738 | 13751 | @opindex fallow-store-data-races |
ddf6fe37 | 13752 | @item -fallow-store-data-races |
d77de738 ML |
13753 | Allow the compiler to perform optimizations that may introduce new data races |
13754 | on stores, without proving that the variable cannot be concurrently accessed | |
13755 | by other threads. Does not affect optimization of local data. It is safe to | |
13756 | use this option if it is known that global data will not be accessed by | |
13757 | multiple threads. | |
13758 | ||
13759 | Examples of optimizations enabled by @option{-fallow-store-data-races} include | |
13760 | hoisting or if-conversions that may cause a value that was already in memory | |
13761 | to be re-written with that same value. Such re-writing is safe in a single | |
13762 | threaded context but may be unsafe in a multi-threaded context. Note that on | |
13763 | some processors, if-conversions may be required in order to enable | |
13764 | vectorization. | |
13765 | ||
13766 | Enabled at level @option{-Ofast}. | |
13767 | ||
d77de738 | 13768 | @opindex funit-at-a-time |
ddf6fe37 | 13769 | @item -funit-at-a-time |
d77de738 ML |
13770 | This option is left for compatibility reasons. @option{-funit-at-a-time} |
13771 | has no effect, while @option{-fno-unit-at-a-time} implies | |
13772 | @option{-fno-toplevel-reorder} and @option{-fno-section-anchors}. | |
13773 | ||
13774 | Enabled by default. | |
13775 | ||
d77de738 ML |
13776 | @opindex fno-toplevel-reorder |
13777 | @opindex ftoplevel-reorder | |
ddf6fe37 | 13778 | @item -fno-toplevel-reorder |
d77de738 ML |
13779 | Do not reorder top-level functions, variables, and @code{asm} |
13780 | statements. Output them in the same order that they appear in the | |
13781 | input file. When this option is used, unreferenced static variables | |
13782 | are not removed. This option is intended to support existing code | |
13783 | that relies on a particular ordering. For new code, it is better to | |
13784 | use attributes when possible. | |
13785 | ||
13786 | @option{-ftoplevel-reorder} is the default at @option{-O1} and higher, and | |
13787 | also at @option{-O0} if @option{-fsection-anchors} is explicitly requested. | |
13788 | Additionally @option{-fno-toplevel-reorder} implies | |
13789 | @option{-fno-section-anchors}. | |
13790 | ||
d77de738 | 13791 | @opindex funreachable-traps |
ddf6fe37 | 13792 | @item -funreachable-traps |
d77de738 ML |
13793 | With this option, the compiler turns calls to |
13794 | @code{__builtin_unreachable} into traps, instead of using them for | |
13795 | optimization. This also affects any such calls implicitly generated | |
13796 | by the compiler. | |
13797 | ||
13798 | This option has the same effect as @option{-fsanitize=unreachable | |
13799 | -fsanitize-trap=unreachable}, but does not affect the values of those | |
13800 | options. If @option{-fsanitize=unreachable} is enabled, that option | |
13801 | takes priority over this one. | |
13802 | ||
13803 | This option is enabled by default at @option{-O0} and @option{-Og}. | |
13804 | ||
d77de738 | 13805 | @opindex fweb |
ddf6fe37 | 13806 | @item -fweb |
d77de738 ML |
13807 | Constructs webs as commonly used for register allocation purposes and assign |
13808 | each web individual pseudo register. This allows the register allocation pass | |
13809 | to operate on pseudos directly, but also strengthens several other optimization | |
13810 | passes, such as CSE, loop optimizer and trivial dead code remover. It can, | |
13811 | however, make debugging impossible, since variables no longer stay in a | |
13812 | ``home register''. | |
13813 | ||
13814 | Enabled by default with @option{-funroll-loops}. | |
13815 | ||
d77de738 | 13816 | @opindex fwhole-program |
ddf6fe37 | 13817 | @item -fwhole-program |
d77de738 ML |
13818 | Assume that the current compilation unit represents the whole program being |
13819 | compiled. All public functions and variables with the exception of @code{main} | |
13820 | and those merged by attribute @code{externally_visible} become static functions | |
13821 | and in effect are optimized more aggressively by interprocedural optimizers. | |
13822 | ||
39ebd3a9 JH |
13823 | With @option{-flto} this option has a limited use. In most cases the |
13824 | precise list of symbols used or exported from the binary is known the | |
13825 | resolution info passed to the link-time optimizer by the linker plugin. It is | |
13826 | still useful if no linker plugin is used or during incremental link step when | |
13827 | final code is produced (with @option{-flto} | |
13828 | @option{-flinker-output=nolto-rel}). | |
d77de738 | 13829 | |
d77de738 | 13830 | @opindex flto |
ddf6fe37 | 13831 | @item -flto[=@var{n}] |
d77de738 ML |
13832 | This option runs the standard link-time optimizer. When invoked |
13833 | with source code, it generates GIMPLE (one of GCC's internal | |
13834 | representations) and writes it to special ELF sections in the object | |
13835 | file. When the object files are linked together, all the function | |
13836 | bodies are read from these ELF sections and instantiated as if they | |
13837 | had been part of the same translation unit. | |
13838 | ||
13839 | To use the link-time optimizer, @option{-flto} and optimization | |
13840 | options should be specified at compile time and during the final link. | |
13841 | It is recommended that you compile all the files participating in the | |
13842 | same link with the same options and also specify those options at | |
13843 | link time. | |
13844 | For example: | |
13845 | ||
13846 | @smallexample | |
13847 | gcc -c -O2 -flto foo.c | |
13848 | gcc -c -O2 -flto bar.c | |
13849 | gcc -o myprog -flto -O2 foo.o bar.o | |
13850 | @end smallexample | |
13851 | ||
13852 | The first two invocations to GCC save a bytecode representation | |
13853 | of GIMPLE into special ELF sections inside @file{foo.o} and | |
13854 | @file{bar.o}. The final invocation reads the GIMPLE bytecode from | |
13855 | @file{foo.o} and @file{bar.o}, merges the two files into a single | |
13856 | internal image, and compiles the result as usual. Since both | |
13857 | @file{foo.o} and @file{bar.o} are merged into a single image, this | |
13858 | causes all the interprocedural analyses and optimizations in GCC to | |
13859 | work across the two files as if they were a single one. This means, | |
13860 | for example, that the inliner is able to inline functions in | |
13861 | @file{bar.o} into functions in @file{foo.o} and vice-versa. | |
13862 | ||
13863 | Another (simpler) way to enable link-time optimization is: | |
13864 | ||
13865 | @smallexample | |
13866 | gcc -o myprog -flto -O2 foo.c bar.c | |
13867 | @end smallexample | |
13868 | ||
13869 | The above generates bytecode for @file{foo.c} and @file{bar.c}, | |
13870 | merges them together into a single GIMPLE representation and optimizes | |
13871 | them as usual to produce @file{myprog}. | |
13872 | ||
13873 | The important thing to keep in mind is that to enable link-time | |
13874 | optimizations you need to use the GCC driver to perform the link step. | |
13875 | GCC automatically performs link-time optimization if any of the | |
13876 | objects involved were compiled with the @option{-flto} command-line option. | |
13877 | You can always override | |
13878 | the automatic decision to do link-time optimization | |
13879 | by passing @option{-fno-lto} to the link command. | |
13880 | ||
13881 | To make whole program optimization effective, it is necessary to make | |
13882 | certain whole program assumptions. The compiler needs to know | |
13883 | what functions and variables can be accessed by libraries and runtime | |
13884 | outside of the link-time optimized unit. When supported by the linker, | |
13885 | the linker plugin (see @option{-fuse-linker-plugin}) passes information | |
13886 | to the compiler about used and externally visible symbols. When | |
13887 | the linker plugin is not available, @option{-fwhole-program} should be | |
13888 | used to allow the compiler to make these assumptions, which leads | |
13889 | to more aggressive optimization decisions. | |
13890 | ||
13891 | When a file is compiled with @option{-flto} without | |
13892 | @option{-fuse-linker-plugin}, the generated object file is larger than | |
13893 | a regular object file because it contains GIMPLE bytecodes and the usual | |
13894 | final code (see @option{-ffat-lto-objects}). This means that | |
13895 | object files with LTO information can be linked as normal object | |
13896 | files; if @option{-fno-lto} is passed to the linker, no | |
13897 | interprocedural optimizations are applied. Note that when | |
13898 | @option{-fno-fat-lto-objects} is enabled the compile stage is faster | |
13899 | but you cannot perform a regular, non-LTO link on them. | |
13900 | ||
13901 | When producing the final binary, GCC only | |
13902 | applies link-time optimizations to those files that contain bytecode. | |
13903 | Therefore, you can mix and match object files and libraries with | |
13904 | GIMPLE bytecodes and final object code. GCC automatically selects | |
13905 | which files to optimize in LTO mode and which files to link without | |
13906 | further processing. | |
13907 | ||
13908 | Generally, options specified at link time override those | |
13909 | specified at compile time, although in some cases GCC attempts to infer | |
13910 | link-time options from the settings used to compile the input files. | |
13911 | ||
13912 | If you do not specify an optimization level option @option{-O} at | |
13913 | link time, then GCC uses the highest optimization level | |
13914 | used when compiling the object files. Note that it is generally | |
13915 | ineffective to specify an optimization level option only at link time and | |
13916 | not at compile time, for two reasons. First, compiling without | |
13917 | optimization suppresses compiler passes that gather information | |
13918 | needed for effective optimization at link time. Second, some early | |
13919 | optimization passes can be performed only at compile time and | |
13920 | not at link time. | |
13921 | ||
13922 | There are some code generation flags preserved by GCC when | |
13923 | generating bytecodes, as they need to be used during the final link. | |
13924 | Currently, the following options and their settings are taken from | |
13925 | the first object file that explicitly specifies them: | |
13926 | @option{-fcommon}, @option{-fexceptions}, @option{-fnon-call-exceptions}, | |
13927 | @option{-fgnu-tm} and all the @option{-m} target flags. | |
13928 | ||
13929 | The following options @option{-fPIC}, @option{-fpic}, @option{-fpie} and | |
13930 | @option{-fPIE} are combined based on the following scheme: | |
13931 | ||
13932 | @smallexample | |
13933 | @option{-fPIC} + @option{-fpic} = @option{-fpic} | |
13934 | @option{-fPIC} + @option{-fno-pic} = @option{-fno-pic} | |
13935 | @option{-fpic/-fPIC} + (no option) = (no option) | |
13936 | @option{-fPIC} + @option{-fPIE} = @option{-fPIE} | |
13937 | @option{-fpic} + @option{-fPIE} = @option{-fpie} | |
13938 | @option{-fPIC/-fpic} + @option{-fpie} = @option{-fpie} | |
13939 | @end smallexample | |
13940 | ||
13941 | Certain ABI-changing flags are required to match in all compilation units, | |
13942 | and trying to override this at link time with a conflicting value | |
13943 | is ignored. This includes options such as @option{-freg-struct-return} | |
13944 | and @option{-fpcc-struct-return}. | |
13945 | ||
13946 | Other options such as @option{-ffp-contract}, @option{-fno-strict-overflow}, | |
13947 | @option{-fwrapv}, @option{-fno-trapv} or @option{-fno-strict-aliasing} | |
13948 | are passed through to the link stage and merged conservatively for | |
13949 | conflicting translation units. Specifically | |
13950 | @option{-fno-strict-overflow}, @option{-fwrapv} and @option{-fno-trapv} take | |
13951 | precedence; and for example @option{-ffp-contract=off} takes precedence | |
13952 | over @option{-ffp-contract=fast}. You can override them at link time. | |
13953 | ||
13954 | Diagnostic options such as @option{-Wstringop-overflow} are passed | |
13955 | through to the link stage and their setting matches that of the | |
13956 | compile-step at function granularity. Note that this matters only | |
13957 | for diagnostics emitted during optimization. Note that code | |
13958 | transforms such as inlining can lead to warnings being enabled | |
13959 | or disabled for regions if code not consistent with the setting | |
13960 | at compile time. | |
13961 | ||
13962 | When you need to pass options to the assembler via @option{-Wa} or | |
13963 | @option{-Xassembler} make sure to either compile such translation | |
13964 | units with @option{-fno-lto} or consistently use the same assembler | |
13965 | options on all translation units. You can alternatively also | |
13966 | specify assembler options at LTO link time. | |
13967 | ||
13968 | To enable debug info generation you need to supply @option{-g} at | |
13969 | compile time. If any of the input files at link time were built | |
13970 | with debug info generation enabled the link will enable debug info | |
13971 | generation as well. Any elaborate debug info settings | |
13972 | like the dwarf level @option{-gdwarf-5} need to be explicitly repeated | |
13973 | at the linker command line and mixing different settings in different | |
13974 | translation units is discouraged. | |
13975 | ||
13976 | If LTO encounters objects with C linkage declared with incompatible | |
13977 | types in separate translation units to be linked together (undefined | |
13978 | behavior according to ISO C99 6.2.7), a non-fatal diagnostic may be | |
13979 | issued. The behavior is still undefined at run time. Similar | |
13980 | diagnostics may be raised for other languages. | |
13981 | ||
13982 | Another feature of LTO is that it is possible to apply interprocedural | |
13983 | optimizations on files written in different languages: | |
13984 | ||
13985 | @smallexample | |
13986 | gcc -c -flto foo.c | |
13987 | g++ -c -flto bar.cc | |
13988 | gfortran -c -flto baz.f90 | |
13989 | g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran | |
13990 | @end smallexample | |
13991 | ||
13992 | Notice that the final link is done with @command{g++} to get the C++ | |
13993 | runtime libraries and @option{-lgfortran} is added to get the Fortran | |
13994 | runtime libraries. In general, when mixing languages in LTO mode, you | |
13995 | should use the same link command options as when mixing languages in a | |
13996 | regular (non-LTO) compilation. | |
13997 | ||
13998 | If object files containing GIMPLE bytecode are stored in a library archive, say | |
13999 | @file{libfoo.a}, it is possible to extract and use them in an LTO link if you | |
14000 | are using a linker with plugin support. To create static libraries suitable | |
14001 | for LTO, use @command{gcc-ar} and @command{gcc-ranlib} instead of @command{ar} | |
14002 | and @command{ranlib}; | |
14003 | to show the symbols of object files with GIMPLE bytecode, use | |
14004 | @command{gcc-nm}. Those commands require that @command{ar}, @command{ranlib} | |
14005 | and @command{nm} have been compiled with plugin support. At link time, use the | |
14006 | flag @option{-fuse-linker-plugin} to ensure that the library participates in | |
14007 | the LTO optimization process: | |
14008 | ||
14009 | @smallexample | |
14010 | gcc -o myprog -O2 -flto -fuse-linker-plugin a.o b.o -lfoo | |
14011 | @end smallexample | |
14012 | ||
14013 | With the linker plugin enabled, the linker extracts the needed | |
14014 | GIMPLE files from @file{libfoo.a} and passes them on to the running GCC | |
14015 | to make them part of the aggregated GIMPLE image to be optimized. | |
14016 | ||
14017 | If you are not using a linker with plugin support and/or do not | |
14018 | enable the linker plugin, then the objects inside @file{libfoo.a} | |
14019 | are extracted and linked as usual, but they do not participate | |
14020 | in the LTO optimization process. In order to make a static library suitable | |
14021 | for both LTO optimization and usual linkage, compile its object files with | |
14022 | @option{-flto} @option{-ffat-lto-objects}. | |
14023 | ||
14024 | Link-time optimizations do not require the presence of the whole program to | |
14025 | operate. If the program does not require any symbols to be exported, it is | |
14026 | possible to combine @option{-flto} and @option{-fwhole-program} to allow | |
14027 | the interprocedural optimizers to use more aggressive assumptions which may | |
14028 | lead to improved optimization opportunities. | |
14029 | Use of @option{-fwhole-program} is not needed when linker plugin is | |
14030 | active (see @option{-fuse-linker-plugin}). | |
14031 | ||
14032 | The current implementation of LTO makes no | |
14033 | attempt to generate bytecode that is portable between different | |
14034 | types of hosts. The bytecode files are versioned and there is a | |
14035 | strict version check, so bytecode files generated in one version of | |
14036 | GCC do not work with an older or newer version of GCC. | |
14037 | ||
14038 | Link-time optimization does not work well with generation of debugging | |
14039 | information on systems other than those using a combination of ELF and | |
14040 | DWARF. | |
14041 | ||
14042 | If you specify the optional @var{n}, the optimization and code | |
14043 | generation done at link time is executed in parallel using @var{n} | |
14044 | parallel jobs by utilizing an installed @command{make} program. The | |
14045 | environment variable @env{MAKE} may be used to override the program | |
14046 | used. | |
14047 | ||
14048 | You can also specify @option{-flto=jobserver} to use GNU make's | |
14049 | job server mode to determine the number of parallel jobs. This | |
14050 | is useful when the Makefile calling GCC is already executing in parallel. | |
14051 | You must prepend a @samp{+} to the command recipe in the parent Makefile | |
14052 | for this to work. This option likely only works if @env{MAKE} is | |
14053 | GNU make. Even without the option value, GCC tries to automatically | |
14054 | detect a running GNU make's job server. | |
14055 | ||
14056 | Use @option{-flto=auto} to use GNU make's job server, if available, | |
14057 | or otherwise fall back to autodetection of the number of CPU threads | |
14058 | present in your system. | |
14059 | ||
d77de738 | 14060 | @opindex flto-partition |
ddf6fe37 | 14061 | @item -flto-partition=@var{alg} |
d77de738 ML |
14062 | Specify the partitioning algorithm used by the link-time optimizer. |
14063 | The value is either @samp{1to1} to specify a partitioning mirroring | |
14064 | the original source files or @samp{balanced} to specify partitioning | |
14065 | into equally sized chunks (whenever possible) or @samp{max} to create | |
14066 | new partition for every symbol where possible. Specifying @samp{none} | |
14067 | as an algorithm disables partitioning and streaming completely. | |
14068 | The default value is @samp{balanced}. While @samp{1to1} can be used | |
14069 | as an workaround for various code ordering issues, the @samp{max} | |
14070 | partitioning is intended for internal testing only. | |
14071 | The value @samp{one} specifies that exactly one partition should be | |
14072 | used while the value @samp{none} bypasses partitioning and executes | |
14073 | the link-time optimization step directly from the WPA phase. | |
14074 | ||
d77de738 | 14075 | @opindex flto-compression-level |
ddf6fe37 | 14076 | @item -flto-compression-level=@var{n} |
d77de738 ML |
14077 | This option specifies the level of compression used for intermediate |
14078 | language written to LTO object files, and is only meaningful in | |
14079 | conjunction with LTO mode (@option{-flto}). GCC currently supports two | |
14080 | LTO compression algorithms. For zstd, valid values are 0 (no compression) | |
14081 | to 19 (maximum compression), while zlib supports values from 0 to 9. | |
14082 | Values outside this range are clamped to either minimum or maximum | |
14083 | of the supported values. If the option is not given, | |
14084 | a default balanced compression setting is used. | |
14085 | ||
d77de738 | 14086 | @opindex fuse-linker-plugin |
ddf6fe37 | 14087 | @item -fuse-linker-plugin |
d77de738 ML |
14088 | Enables the use of a linker plugin during link-time optimization. This |
14089 | option relies on plugin support in the linker, which is available in gold | |
14090 | or in GNU ld 2.21 or newer. | |
14091 | ||
14092 | This option enables the extraction of object files with GIMPLE bytecode out | |
14093 | of library archives. This improves the quality of optimization by exposing | |
14094 | more code to the link-time optimizer. This information specifies what | |
14095 | symbols can be accessed externally (by non-LTO object or during dynamic | |
14096 | linking). Resulting code quality improvements on binaries (and shared | |
14097 | libraries that use hidden visibility) are similar to @option{-fwhole-program}. | |
14098 | See @option{-flto} for a description of the effect of this flag and how to | |
14099 | use it. | |
14100 | ||
14101 | This option is enabled by default when LTO support in GCC is enabled | |
14102 | and GCC was configured for use with | |
14103 | a linker supporting plugins (GNU ld 2.21 or newer or gold). | |
14104 | ||
d77de738 | 14105 | @opindex ffat-lto-objects |
ddf6fe37 | 14106 | @item -ffat-lto-objects |
d77de738 ML |
14107 | Fat LTO objects are object files that contain both the intermediate language |
14108 | and the object code. This makes them usable for both LTO linking and normal | |
14109 | linking. This option is effective only when compiling with @option{-flto} | |
14110 | and is ignored at link time. | |
14111 | ||
14112 | @option{-fno-fat-lto-objects} improves compilation time over plain LTO, but | |
14113 | requires the complete toolchain to be aware of LTO. It requires a linker with | |
14114 | linker plugin support for basic functionality. Additionally, | |
14115 | @command{nm}, @command{ar} and @command{ranlib} | |
14116 | need to support linker plugins to allow a full-featured build environment | |
14117 | (capable of building static libraries etc). GCC provides the @command{gcc-ar}, | |
14118 | @command{gcc-nm}, @command{gcc-ranlib} wrappers to pass the right options | |
14119 | to these tools. With non fat LTO makefiles need to be modified to use them. | |
14120 | ||
14121 | Note that modern binutils provide plugin auto-load mechanism. | |
14122 | Installing the linker plugin into @file{$libdir/bfd-plugins} has the same | |
14123 | effect as usage of the command wrappers (@command{gcc-ar}, @command{gcc-nm} and | |
14124 | @command{gcc-ranlib}). | |
14125 | ||
14126 | The default is @option{-fno-fat-lto-objects} on targets with linker plugin | |
14127 | support. | |
14128 | ||
d77de738 | 14129 | @opindex fcompare-elim |
ddf6fe37 | 14130 | @item -fcompare-elim |
d77de738 ML |
14131 | After register allocation and post-register allocation instruction splitting, |
14132 | identify arithmetic instructions that compute processor flags similar to a | |
14133 | comparison operation based on that arithmetic. If possible, eliminate the | |
14134 | explicit comparison operation. | |
14135 | ||
14136 | This pass only applies to certain targets that cannot explicitly represent | |
14137 | the comparison operation before register allocation is complete. | |
14138 | ||
14139 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
14140 | ||
d77de738 | 14141 | @opindex fcprop-registers |
ddf6fe37 | 14142 | @item -fcprop-registers |
d77de738 ML |
14143 | After register allocation and post-register allocation instruction splitting, |
14144 | perform a copy-propagation pass to try to reduce scheduling dependencies | |
14145 | and occasionally eliminate the copy. | |
14146 | ||
14147 | Enabled at levels @option{-O1}, @option{-O2}, @option{-O3}, @option{-Os}. | |
14148 | ||
d77de738 | 14149 | @opindex fprofile-correction |
ddf6fe37 | 14150 | @item -fprofile-correction |
d77de738 ML |
14151 | Profiles collected using an instrumented binary for multi-threaded programs may |
14152 | be inconsistent due to missed counter updates. When this option is specified, | |
14153 | GCC uses heuristics to correct or smooth out such inconsistencies. By | |
14154 | default, GCC emits an error message when an inconsistent profile is detected. | |
14155 | ||
14156 | This option is enabled by @option{-fauto-profile}. | |
14157 | ||
d77de738 | 14158 | @opindex fprofile-partial-training |
ddf6fe37 | 14159 | @item -fprofile-partial-training |
d77de738 ML |
14160 | With @code{-fprofile-use} all portions of programs not executed during train |
14161 | run are optimized agressively for size rather than speed. In some cases it is | |
14162 | not practical to train all possible hot paths in the program. (For | |
14163 | example, program may contain functions specific for a given hardware and | |
14164 | trianing may not cover all hardware configurations program is run on.) With | |
14165 | @code{-fprofile-partial-training} profile feedback will be ignored for all | |
14166 | functions not executed during the train run leading them to be optimized as if | |
14167 | they were compiled without profile feedback. This leads to better performance | |
14168 | when train run is not representative but also leads to significantly bigger | |
14169 | code. | |
14170 | ||
ddf6fe37 | 14171 | @opindex fprofile-use |
d77de738 ML |
14172 | @item -fprofile-use |
14173 | @itemx -fprofile-use=@var{path} | |
d77de738 ML |
14174 | Enable profile feedback-directed optimizations, |
14175 | and the following optimizations, many of which | |
14176 | are generally profitable only with profile feedback available: | |
14177 | ||
43b72ede AA |
14178 | @gccoptlist{-fbranch-probabilities -fprofile-values |
14179 | -funroll-loops -fpeel-loops -ftracer -fvpt | |
14180 | -finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp | |
14181 | -fpredictive-commoning -fsplit-loops -funswitch-loops | |
14182 | -fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize | |
14183 | -fvect-cost-model=dynamic -ftree-loop-distribute-patterns | |
d77de738 ML |
14184 | -fprofile-reorder-functions} |
14185 | ||
14186 | Before you can use this option, you must first generate profiling information. | |
14187 | @xref{Instrumentation Options}, for information about the | |
14188 | @option{-fprofile-generate} option. | |
14189 | ||
14190 | By default, GCC emits an error message if the feedback profiles do not | |
14191 | match the source code. This error can be turned into a warning by using | |
14192 | @option{-Wno-error=coverage-mismatch}. Note this may result in poorly | |
14193 | optimized code. Additionally, by default, GCC also emits a warning message if | |
14194 | the feedback profiles do not exist (see @option{-Wmissing-profile}). | |
14195 | ||
14196 | If @var{path} is specified, GCC looks at the @var{path} to find | |
14197 | the profile feedback data files. See @option{-fprofile-dir}. | |
14198 | ||
ddf6fe37 | 14199 | @opindex fauto-profile |
d77de738 ML |
14200 | @item -fauto-profile |
14201 | @itemx -fauto-profile=@var{path} | |
d77de738 ML |
14202 | Enable sampling-based feedback-directed optimizations, |
14203 | and the following optimizations, | |
14204 | many of which are generally profitable only with profile feedback available: | |
14205 | ||
43b72ede AA |
14206 | @gccoptlist{-fbranch-probabilities -fprofile-values |
14207 | -funroll-loops -fpeel-loops -ftracer -fvpt | |
14208 | -finline-functions -fipa-cp -fipa-cp-clone -fipa-bit-cp | |
14209 | -fpredictive-commoning -fsplit-loops -funswitch-loops | |
14210 | -fgcse-after-reload -ftree-loop-vectorize -ftree-slp-vectorize | |
14211 | -fvect-cost-model=dynamic -ftree-loop-distribute-patterns | |
d77de738 ML |
14212 | -fprofile-correction} |
14213 | ||
14214 | @var{path} is the name of a file containing AutoFDO profile information. | |
14215 | If omitted, it defaults to @file{fbdata.afdo} in the current directory. | |
14216 | ||
14217 | Producing an AutoFDO profile data file requires running your program | |
14218 | with the @command{perf} utility on a supported GNU/Linux target system. | |
14219 | For more information, see @uref{https://perf.wiki.kernel.org/}. | |
14220 | ||
14221 | E.g. | |
14222 | @smallexample | |
14223 | perf record -e br_inst_retired:near_taken -b -o perf.data \ | |
14224 | -- your_program | |
14225 | @end smallexample | |
14226 | ||
14227 | Then use the @command{create_gcov} tool to convert the raw profile data | |
14228 | to a format that can be used by GCC.@ You must also supply the | |
14229 | unstripped binary for your program to this tool. | |
14230 | See @uref{https://github.com/google/autofdo}. | |
14231 | ||
14232 | E.g. | |
14233 | @smallexample | |
14234 | create_gcov --binary=your_program.unstripped --profile=perf.data \ | |
14235 | --gcov=profile.afdo | |
14236 | @end smallexample | |
14237 | @end table | |
14238 | ||
14239 | The following options control compiler behavior regarding floating-point | |
14240 | arithmetic. These options trade off between speed and | |
14241 | correctness. All must be specifically enabled. | |
14242 | ||
14243 | @table @gcctabopt | |
d77de738 | 14244 | @opindex ffloat-store |
ddf6fe37 | 14245 | @item -ffloat-store |
d77de738 ML |
14246 | Do not store floating-point variables in registers, and inhibit other |
14247 | options that might change whether a floating-point value is taken from a | |
14248 | register or memory. | |
14249 | ||
14250 | @cindex floating-point precision | |
14251 | This option prevents undesirable excess precision on machines such as | |
14252 | the 68000 where the floating registers (of the 68881) keep more | |
14253 | precision than a @code{double} is supposed to have. Similarly for the | |
14254 | x86 architecture. For most programs, the excess precision does only | |
14255 | good, but a few programs rely on the precise definition of IEEE floating | |
14256 | point. Use @option{-ffloat-store} for such programs, after modifying | |
14257 | them to store all pertinent intermediate computations into variables. | |
14258 | ||
d77de738 | 14259 | @opindex fexcess-precision |
ddf6fe37 | 14260 | @item -fexcess-precision=@var{style} |
d77de738 ML |
14261 | This option allows further control over excess precision on machines |
14262 | where floating-point operations occur in a format with more precision or | |
14263 | range than the IEEE standard and interchange floating-point types. By | |
14264 | default, @option{-fexcess-precision=fast} is in effect; this means that | |
14265 | operations may be carried out in a wider precision than the types specified | |
14266 | in the source if that would result in faster code, and it is unpredictable | |
14267 | when rounding to the types specified in the source code takes place. | |
14268 | When compiling C or C++, if @option{-fexcess-precision=standard} is specified | |
14269 | then excess precision follows the rules specified in ISO C99 or C++; in particular, | |
14270 | both casts and assignments cause values to be rounded to their | |
14271 | semantic types (whereas @option{-ffloat-store} only affects | |
14272 | assignments). This option is enabled by default for C or C++ if a strict | |
14273 | conformance option such as @option{-std=c99} or @option{-std=c++17} is used. | |
14274 | @option{-ffast-math} enables @option{-fexcess-precision=fast} by default | |
14275 | regardless of whether a strict conformance option is used. | |
14276 | ||
14277 | @opindex mfpmath | |
14278 | @option{-fexcess-precision=standard} is not implemented for languages | |
14279 | other than C or C++. On the x86, it has no effect if @option{-mfpmath=sse} | |
14280 | or @option{-mfpmath=sse+387} is specified; in the former case, IEEE | |
14281 | semantics apply without excess precision, and in the latter, rounding | |
14282 | is unpredictable. | |
14283 | ||
d77de738 | 14284 | @opindex ffast-math |
ddf6fe37 | 14285 | @item -ffast-math |
d77de738 ML |
14286 | Sets the options @option{-fno-math-errno}, @option{-funsafe-math-optimizations}, |
14287 | @option{-ffinite-math-only}, @option{-fno-rounding-math}, | |
14288 | @option{-fno-signaling-nans}, @option{-fcx-limited-range} and | |
14289 | @option{-fexcess-precision=fast}. | |
14290 | ||
14291 | This option causes the preprocessor macro @code{__FAST_MATH__} to be defined. | |
14292 | ||
14293 | This option is not turned on by any @option{-O} option besides | |
14294 | @option{-Ofast} since it can result in incorrect output for programs | |
14295 | that depend on an exact implementation of IEEE or ISO rules/specifications | |
14296 | for math functions. It may, however, yield faster code for programs | |
14297 | that do not require the guarantees of these specifications. | |
14298 | ||
d77de738 ML |
14299 | @opindex fno-math-errno |
14300 | @opindex fmath-errno | |
ddf6fe37 | 14301 | @item -fno-math-errno |
d77de738 ML |
14302 | Do not set @code{errno} after calling math functions that are executed |
14303 | with a single instruction, e.g., @code{sqrt}. A program that relies on | |
14304 | IEEE exceptions for math error handling may want to use this flag | |
14305 | for speed while maintaining IEEE arithmetic compatibility. | |
14306 | ||
14307 | This option is not turned on by any @option{-O} option since | |
14308 | it can result in incorrect output for programs that depend on | |
14309 | an exact implementation of IEEE or ISO rules/specifications for | |
14310 | math functions. It may, however, yield faster code for programs | |
14311 | that do not require the guarantees of these specifications. | |
14312 | ||
14313 | The default is @option{-fmath-errno}. | |
14314 | ||
14315 | On Darwin systems, the math library never sets @code{errno}. There is | |
14316 | therefore no reason for the compiler to consider the possibility that | |
14317 | it might, and @option{-fno-math-errno} is the default. | |
14318 | ||
d77de738 | 14319 | @opindex funsafe-math-optimizations |
ddf6fe37 | 14320 | @item -funsafe-math-optimizations |
d77de738 ML |
14321 | |
14322 | Allow optimizations for floating-point arithmetic that (a) assume | |
14323 | that arguments and results are valid and (b) may violate IEEE or | |
14324 | ANSI standards. When used at link time, it may include libraries | |
14325 | or startup files that change the default FPU control word or other | |
14326 | similar optimizations. | |
14327 | ||
14328 | This option is not turned on by any @option{-O} option since | |
14329 | it can result in incorrect output for programs that depend on | |
14330 | an exact implementation of IEEE or ISO rules/specifications for | |
14331 | math functions. It may, however, yield faster code for programs | |
14332 | that do not require the guarantees of these specifications. | |
14333 | Enables @option{-fno-signed-zeros}, @option{-fno-trapping-math}, | |
14334 | @option{-fassociative-math} and @option{-freciprocal-math}. | |
14335 | ||
14336 | The default is @option{-fno-unsafe-math-optimizations}. | |
14337 | ||
d77de738 | 14338 | @opindex fassociative-math |
ddf6fe37 | 14339 | @item -fassociative-math |
d77de738 ML |
14340 | |
14341 | Allow re-association of operands in series of floating-point operations. | |
14342 | This violates the ISO C and C++ language standard by possibly changing | |
14343 | computation result. NOTE: re-ordering may change the sign of zero as | |
14344 | well as ignore NaNs and inhibit or create underflow or overflow (and | |
14345 | thus cannot be used on code that relies on rounding behavior like | |
14346 | @code{(x + 2**52) - 2**52}. May also reorder floating-point comparisons | |
14347 | and thus may not be used when ordered comparisons are required. | |
14348 | This option requires that both @option{-fno-signed-zeros} and | |
14349 | @option{-fno-trapping-math} be in effect. Moreover, it doesn't make | |
14350 | much sense with @option{-frounding-math}. For Fortran the option | |
14351 | is automatically enabled when both @option{-fno-signed-zeros} and | |
14352 | @option{-fno-trapping-math} are in effect. | |
14353 | ||
14354 | The default is @option{-fno-associative-math}. | |
14355 | ||
d77de738 | 14356 | @opindex freciprocal-math |
ddf6fe37 | 14357 | @item -freciprocal-math |
d77de738 ML |
14358 | |
14359 | Allow the reciprocal of a value to be used instead of dividing by | |
14360 | the value if this enables optimizations. For example @code{x / y} | |
14361 | can be replaced with @code{x * (1/y)}, which is useful if @code{(1/y)} | |
14362 | is subject to common subexpression elimination. Note that this loses | |
14363 | precision and increases the number of flops operating on the value. | |
14364 | ||
14365 | The default is @option{-fno-reciprocal-math}. | |
14366 | ||
d77de738 | 14367 | @opindex ffinite-math-only |
ddf6fe37 | 14368 | @item -ffinite-math-only |
d77de738 ML |
14369 | Allow optimizations for floating-point arithmetic that assume |
14370 | that arguments and results are not NaNs or +-Infs. | |
14371 | ||
14372 | This option is not turned on by any @option{-O} option since | |
14373 | it can result in incorrect output for programs that depend on | |
14374 | an exact implementation of IEEE or ISO rules/specifications for | |
14375 | math functions. It may, however, yield faster code for programs | |
14376 | that do not require the guarantees of these specifications. | |
14377 | ||
14378 | The default is @option{-fno-finite-math-only}. | |
14379 | ||
d77de738 ML |
14380 | @opindex fno-signed-zeros |
14381 | @opindex fsigned-zeros | |
ddf6fe37 | 14382 | @item -fno-signed-zeros |
d77de738 ML |
14383 | Allow optimizations for floating-point arithmetic that ignore the |
14384 | signedness of zero. IEEE arithmetic specifies the behavior of | |
14385 | distinct +0.0 and @minus{}0.0 values, which then prohibits simplification | |
14386 | of expressions such as x+0.0 or 0.0*x (even with @option{-ffinite-math-only}). | |
14387 | This option implies that the sign of a zero result isn't significant. | |
14388 | ||
14389 | The default is @option{-fsigned-zeros}. | |
14390 | ||
d77de738 ML |
14391 | @opindex fno-trapping-math |
14392 | @opindex ftrapping-math | |
ddf6fe37 | 14393 | @item -fno-trapping-math |
d77de738 ML |
14394 | Compile code assuming that floating-point operations cannot generate |
14395 | user-visible traps. These traps include division by zero, overflow, | |
14396 | underflow, inexact result and invalid operation. This option requires | |
14397 | that @option{-fno-signaling-nans} be in effect. Setting this option may | |
14398 | allow faster code if one relies on ``non-stop'' IEEE arithmetic, for example. | |
14399 | ||
14400 | This option should never be turned on by any @option{-O} option since | |
14401 | it can result in incorrect output for programs that depend on | |
14402 | an exact implementation of IEEE or ISO rules/specifications for | |
14403 | math functions. | |
14404 | ||
14405 | The default is @option{-ftrapping-math}. | |
14406 | ||
14407 | Future versions of GCC may provide finer control of this setting | |
14408 | using C99's @code{FENV_ACCESS} pragma. This command-line option | |
14409 | will be used along with @option{-frounding-math} to specify the | |
14410 | default state for @code{FENV_ACCESS}. | |
14411 | ||
d77de738 | 14412 | @opindex frounding-math |
ddf6fe37 | 14413 | @item -frounding-math |
d77de738 ML |
14414 | Disable transformations and optimizations that assume default floating-point |
14415 | rounding behavior. This is round-to-zero for all floating point | |
14416 | to integer conversions, and round-to-nearest for all other arithmetic | |
14417 | truncations. This option should be specified for programs that change | |
14418 | the FP rounding mode dynamically, or that may be executed with a | |
14419 | non-default rounding mode. This option disables constant folding of | |
14420 | floating-point expressions at compile time (which may be affected by | |
14421 | rounding mode) and arithmetic transformations that are unsafe in the | |
14422 | presence of sign-dependent rounding modes. | |
14423 | ||
14424 | The default is @option{-fno-rounding-math}. | |
14425 | ||
14426 | This option is experimental and does not currently guarantee to | |
14427 | disable all GCC optimizations that are affected by rounding mode. | |
14428 | Future versions of GCC may provide finer control of this setting | |
14429 | using C99's @code{FENV_ACCESS} pragma. This command-line option | |
14430 | will be used along with @option{-ftrapping-math} to specify the | |
14431 | default state for @code{FENV_ACCESS}. | |
14432 | ||
d77de738 | 14433 | @opindex fsignaling-nans |
ddf6fe37 | 14434 | @item -fsignaling-nans |
d77de738 ML |
14435 | Compile code assuming that IEEE signaling NaNs may generate user-visible |
14436 | traps during floating-point operations. Setting this option disables | |
14437 | optimizations that may change the number of exceptions visible with | |
14438 | signaling NaNs. This option implies @option{-ftrapping-math}. | |
14439 | ||
14440 | This option causes the preprocessor macro @code{__SUPPORT_SNAN__} to | |
14441 | be defined. | |
14442 | ||
14443 | The default is @option{-fno-signaling-nans}. | |
14444 | ||
14445 | This option is experimental and does not currently guarantee to | |
14446 | disable all GCC optimizations that affect signaling NaN behavior. | |
14447 | ||
d77de738 ML |
14448 | @opindex fno-fp-int-builtin-inexact |
14449 | @opindex ffp-int-builtin-inexact | |
ddf6fe37 | 14450 | @item -fno-fp-int-builtin-inexact |
d77de738 ML |
14451 | Do not allow the built-in functions @code{ceil}, @code{floor}, |
14452 | @code{round} and @code{trunc}, and their @code{float} and @code{long | |
14453 | double} variants, to generate code that raises the ``inexact'' | |
14454 | floating-point exception for noninteger arguments. ISO C99 and C11 | |
14455 | allow these functions to raise the ``inexact'' exception, but ISO/IEC | |
14456 | TS 18661-1:2014, the C bindings to IEEE 754-2008, as integrated into | |
14457 | ISO C2X, does not allow these functions to do so. | |
14458 | ||
14459 | The default is @option{-ffp-int-builtin-inexact}, allowing the | |
14460 | exception to be raised, unless C2X or a later C standard is selected. | |
14461 | This option does nothing unless @option{-ftrapping-math} is in effect. | |
14462 | ||
14463 | Even if @option{-fno-fp-int-builtin-inexact} is used, if the functions | |
14464 | generate a call to a library function then the ``inexact'' exception | |
14465 | may be raised if the library implementation does not follow TS 18661. | |
14466 | ||
d77de738 | 14467 | @opindex fsingle-precision-constant |
ddf6fe37 | 14468 | @item -fsingle-precision-constant |
d77de738 ML |
14469 | Treat floating-point constants as single precision instead of |
14470 | implicitly converting them to double-precision constants. | |
14471 | ||
d77de738 | 14472 | @opindex fcx-limited-range |
ddf6fe37 | 14473 | @item -fcx-limited-range |
d77de738 ML |
14474 | When enabled, this option states that a range reduction step is not |
14475 | needed when performing complex division. Also, there is no checking | |
14476 | whether the result of a complex multiplication or division is @code{NaN | |
14477 | + I*NaN}, with an attempt to rescue the situation in that case. The | |
14478 | default is @option{-fno-cx-limited-range}, but is enabled by | |
14479 | @option{-ffast-math}. | |
14480 | ||
14481 | This option controls the default setting of the ISO C99 | |
14482 | @code{CX_LIMITED_RANGE} pragma. Nevertheless, the option applies to | |
14483 | all languages. | |
14484 | ||
d77de738 | 14485 | @opindex fcx-fortran-rules |
ddf6fe37 | 14486 | @item -fcx-fortran-rules |
d77de738 ML |
14487 | Complex multiplication and division follow Fortran rules. Range |
14488 | reduction is done as part of complex division, but there is no checking | |
14489 | whether the result of a complex multiplication or division is @code{NaN | |
14490 | + I*NaN}, with an attempt to rescue the situation in that case. | |
14491 | ||
14492 | The default is @option{-fno-cx-fortran-rules}. | |
14493 | ||
14494 | @end table | |
14495 | ||
14496 | The following options control optimizations that may improve | |
14497 | performance, but are not enabled by any @option{-O} options. This | |
14498 | section includes experimental options that may produce broken code. | |
14499 | ||
14500 | @table @gcctabopt | |
d77de738 | 14501 | @opindex fbranch-probabilities |
ddf6fe37 | 14502 | @item -fbranch-probabilities |
d77de738 ML |
14503 | After running a program compiled with @option{-fprofile-arcs} |
14504 | (@pxref{Instrumentation Options}), | |
14505 | you can compile it a second time using | |
14506 | @option{-fbranch-probabilities}, to improve optimizations based on | |
14507 | the number of times each branch was taken. When a program | |
14508 | compiled with @option{-fprofile-arcs} exits, it saves arc execution | |
14509 | counts to a file called @file{@var{sourcename}.gcda} for each source | |
14510 | file. The information in this data file is very dependent on the | |
14511 | structure of the generated code, so you must use the same source code | |
14512 | and the same optimization options for both compilations. | |
14513 | See details about the file naming in @option{-fprofile-arcs}. | |
14514 | ||
14515 | With @option{-fbranch-probabilities}, GCC puts a | |
14516 | @samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}. | |
14517 | These can be used to improve optimization. Currently, they are only | |
14518 | used in one place: in @file{reorg.cc}, instead of guessing which path a | |
14519 | branch is most likely to take, the @samp{REG_BR_PROB} values are used to | |
14520 | exactly determine which path is taken more often. | |
14521 | ||
14522 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14523 | ||
d77de738 | 14524 | @opindex fprofile-values |
ddf6fe37 | 14525 | @item -fprofile-values |
d77de738 ML |
14526 | If combined with @option{-fprofile-arcs}, it adds code so that some |
14527 | data about values of expressions in the program is gathered. | |
14528 | ||
14529 | With @option{-fbranch-probabilities}, it reads back the data gathered | |
14530 | from profiling values of expressions for usage in optimizations. | |
14531 | ||
14532 | Enabled by @option{-fprofile-generate}, @option{-fprofile-use}, and | |
14533 | @option{-fauto-profile}. | |
14534 | ||
d77de738 | 14535 | @opindex fprofile-reorder-functions |
ddf6fe37 | 14536 | @item -fprofile-reorder-functions |
d77de738 ML |
14537 | Function reordering based on profile instrumentation collects |
14538 | first time of execution of a function and orders these functions | |
14539 | in ascending order. | |
14540 | ||
14541 | Enabled with @option{-fprofile-use}. | |
14542 | ||
d77de738 | 14543 | @opindex fvpt |
ddf6fe37 | 14544 | @item -fvpt |
d77de738 ML |
14545 | If combined with @option{-fprofile-arcs}, this option instructs the compiler |
14546 | to add code to gather information about values of expressions. | |
14547 | ||
14548 | With @option{-fbranch-probabilities}, it reads back the data gathered | |
14549 | and actually performs the optimizations based on them. | |
14550 | Currently the optimizations include specialization of division operations | |
14551 | using the knowledge about the value of the denominator. | |
14552 | ||
14553 | Enabled with @option{-fprofile-use} and @option{-fauto-profile}. | |
14554 | ||
d77de738 | 14555 | @opindex frename-registers |
ddf6fe37 | 14556 | @item -frename-registers |
d77de738 ML |
14557 | Attempt to avoid false dependencies in scheduled code by making use |
14558 | of registers left over after register allocation. This optimization | |
14559 | most benefits processors with lots of registers. Depending on the | |
14560 | debug information format adopted by the target, however, it can | |
14561 | make debugging impossible, since variables no longer stay in | |
14562 | a ``home register''. | |
14563 | ||
14564 | Enabled by default with @option{-funroll-loops}. | |
14565 | ||
d77de738 | 14566 | @opindex fschedule-fusion |
ddf6fe37 | 14567 | @item -fschedule-fusion |
d77de738 ML |
14568 | Performs a target dependent pass over the instruction stream to schedule |
14569 | instructions of same type together because target machine can execute them | |
14570 | more efficiently if they are adjacent to each other in the instruction flow. | |
14571 | ||
14572 | Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}. | |
14573 | ||
d77de738 | 14574 | @opindex ftracer |
ddf6fe37 | 14575 | @item -ftracer |
d77de738 ML |
14576 | Perform tail duplication to enlarge superblock size. This transformation |
14577 | simplifies the control flow of the function allowing other optimizations to do | |
14578 | a better job. | |
14579 | ||
14580 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14581 | ||
d77de738 | 14582 | @opindex funroll-loops |
ddf6fe37 | 14583 | @item -funroll-loops |
d77de738 ML |
14584 | Unroll loops whose number of iterations can be determined at compile time or |
14585 | upon entry to the loop. @option{-funroll-loops} implies | |
14586 | @option{-frerun-cse-after-loop}, @option{-fweb} and @option{-frename-registers}. | |
14587 | It also turns on complete loop peeling (i.e.@: complete removal of loops with | |
14588 | a small constant number of iterations). This option makes code larger, and may | |
14589 | or may not make it run faster. | |
14590 | ||
14591 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14592 | ||
d77de738 | 14593 | @opindex funroll-all-loops |
ddf6fe37 | 14594 | @item -funroll-all-loops |
d77de738 ML |
14595 | Unroll all loops, even if their number of iterations is uncertain when |
14596 | the loop is entered. This usually makes programs run more slowly. | |
14597 | @option{-funroll-all-loops} implies the same options as | |
14598 | @option{-funroll-loops}. | |
14599 | ||
d77de738 | 14600 | @opindex fpeel-loops |
ddf6fe37 | 14601 | @item -fpeel-loops |
d77de738 ML |
14602 | Peels loops for which there is enough information that they do not |
14603 | roll much (from profile feedback or static analysis). It also turns on | |
14604 | complete loop peeling (i.e.@: complete removal of loops with small constant | |
14605 | number of iterations). | |
14606 | ||
14607 | Enabled by @option{-O3}, @option{-fprofile-use}, and @option{-fauto-profile}. | |
14608 | ||
d77de738 | 14609 | @opindex fmove-loop-invariants |
ddf6fe37 | 14610 | @item -fmove-loop-invariants |
d77de738 ML |
14611 | Enables the loop invariant motion pass in the RTL loop optimizer. Enabled |
14612 | at level @option{-O1} and higher, except for @option{-Og}. | |
14613 | ||
d77de738 | 14614 | @opindex fmove-loop-stores |
ddf6fe37 | 14615 | @item -fmove-loop-stores |
d77de738 ML |
14616 | Enables the loop store motion pass in the GIMPLE loop optimizer. This |
14617 | moves invariant stores to after the end of the loop in exchange for | |
14618 | carrying the stored value in a register across the iteration. | |
14619 | Note for this option to have an effect @option{-ftree-loop-im} has to | |
14620 | be enabled as well. Enabled at level @option{-O1} and higher, except | |
14621 | for @option{-Og}. | |
14622 | ||
d77de738 | 14623 | @opindex fsplit-loops |
ddf6fe37 | 14624 | @item -fsplit-loops |
d77de738 ML |
14625 | Split a loop into two if it contains a condition that's always true |
14626 | for one side of the iteration space and false for the other. | |
14627 | ||
14628 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14629 | ||
d77de738 | 14630 | @opindex funswitch-loops |
ddf6fe37 | 14631 | @item -funswitch-loops |
d77de738 ML |
14632 | Move branches with loop invariant conditions out of the loop, with duplicates |
14633 | of the loop on both branches (modified according to result of the condition). | |
14634 | ||
14635 | Enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14636 | ||
d77de738 | 14637 | @opindex fversion-loops-for-strides |
ddf6fe37 | 14638 | @item -fversion-loops-for-strides |
d77de738 ML |
14639 | If a loop iterates over an array with a variable stride, create another |
14640 | version of the loop that assumes the stride is always one. For example: | |
14641 | ||
14642 | @smallexample | |
14643 | for (int i = 0; i < n; ++i) | |
14644 | x[i * stride] = @dots{}; | |
14645 | @end smallexample | |
14646 | ||
14647 | becomes: | |
14648 | ||
14649 | @smallexample | |
14650 | if (stride == 1) | |
14651 | for (int i = 0; i < n; ++i) | |
14652 | x[i] = @dots{}; | |
14653 | else | |
14654 | for (int i = 0; i < n; ++i) | |
14655 | x[i * stride] = @dots{}; | |
14656 | @end smallexample | |
14657 | ||
14658 | This is particularly useful for assumed-shape arrays in Fortran where | |
14659 | (for example) it allows better vectorization assuming contiguous accesses. | |
14660 | This flag is enabled by default at @option{-O3}. | |
14661 | It is also enabled by @option{-fprofile-use} and @option{-fauto-profile}. | |
14662 | ||
d77de738 ML |
14663 | @opindex ffunction-sections |
14664 | @opindex fdata-sections | |
ddf6fe37 AA |
14665 | @item -ffunction-sections |
14666 | @itemx -fdata-sections | |
d77de738 ML |
14667 | Place each function or data item into its own section in the output |
14668 | file if the target supports arbitrary sections. The name of the | |
14669 | function or the name of the data item determines the section's name | |
14670 | in the output file. | |
14671 | ||
14672 | Use these options on systems where the linker can perform optimizations to | |
14673 | improve locality of reference in the instruction space. Most systems using the | |
14674 | ELF object format have linkers with such optimizations. On AIX, the linker | |
14675 | rearranges sections (CSECTs) based on the call graph. The performance impact | |
14676 | varies. | |
14677 | ||
14678 | Together with a linker garbage collection (linker @option{--gc-sections} | |
14679 | option) these options may lead to smaller statically-linked executables (after | |
14680 | stripping). | |
14681 | ||
14682 | On ELF/DWARF systems these options do not degenerate the quality of the debug | |
14683 | information. There could be issues with other object files/debug info formats. | |
14684 | ||
14685 | Only use these options when there are significant benefits from doing so. When | |
14686 | you specify these options, the assembler and linker create larger object and | |
14687 | executable files and are also slower. These options affect code generation. | |
14688 | They prevent optimizations by the compiler and assembler using relative | |
14689 | locations inside a translation unit since the locations are unknown until | |
14690 | link time. An example of such an optimization is relaxing calls to short call | |
14691 | instructions. | |
14692 | ||
d77de738 | 14693 | @opindex fstdarg-opt |
ddf6fe37 | 14694 | @item -fstdarg-opt |
d77de738 ML |
14695 | Optimize the prologue of variadic argument functions with respect to usage of |
14696 | those arguments. | |
14697 | ||
d77de738 | 14698 | @opindex fsection-anchors |
ddf6fe37 | 14699 | @item -fsection-anchors |
d77de738 ML |
14700 | Try to reduce the number of symbolic address calculations by using |
14701 | shared ``anchor'' symbols to address nearby objects. This transformation | |
14702 | can help to reduce the number of GOT entries and GOT accesses on some | |
14703 | targets. | |
14704 | ||
14705 | For example, the implementation of the following function @code{foo}: | |
14706 | ||
14707 | @smallexample | |
14708 | static int a, b, c; | |
14709 | int foo (void) @{ return a + b + c; @} | |
14710 | @end smallexample | |
14711 | ||
14712 | @noindent | |
14713 | usually calculates the addresses of all three variables, but if you | |
14714 | compile it with @option{-fsection-anchors}, it accesses the variables | |
14715 | from a common anchor point instead. The effect is similar to the | |
14716 | following pseudocode (which isn't valid C): | |
14717 | ||
14718 | @smallexample | |
14719 | int foo (void) | |
14720 | @{ | |
14721 | register int *xr = &x; | |
14722 | return xr[&a - &x] + xr[&b - &x] + xr[&c - &x]; | |
14723 | @} | |
14724 | @end smallexample | |
14725 | ||
14726 | Not all targets support this option. | |
14727 | ||
d77de738 | 14728 | @opindex fzero-call-used-regs |
ddf6fe37 | 14729 | @item -fzero-call-used-regs=@var{choice} |
d77de738 ML |
14730 | Zero call-used registers at function return to increase program |
14731 | security by either mitigating Return-Oriented Programming (ROP) | |
14732 | attacks or preventing information leakage through registers. | |
14733 | ||
14734 | The possible values of @var{choice} are the same as for the | |
14735 | @code{zero_call_used_regs} attribute (@pxref{Function Attributes}). | |
14736 | The default is @samp{skip}. | |
14737 | ||
14738 | You can control this behavior for a specific function by using the function | |
14739 | attribute @code{zero_call_used_regs} (@pxref{Function Attributes}). | |
14740 | ||
d77de738 | 14741 | @opindex param |
ddf6fe37 | 14742 | @item --param @var{name}=@var{value} |
d77de738 ML |
14743 | In some places, GCC uses various constants to control the amount of |
14744 | optimization that is done. For example, GCC does not inline functions | |
14745 | that contain more than a certain number of instructions. You can | |
14746 | control some of these constants on the command line using the | |
14747 | @option{--param} option. | |
14748 | ||
14749 | The names of specific parameters, and the meaning of the values, are | |
14750 | tied to the internals of the compiler, and are subject to change | |
14751 | without notice in future releases. | |
14752 | ||
c381327d GP |
14753 | In order to get the minimal, maximal and default values of a parameter, |
14754 | use the @option{--help=param -Q} options. | |
d77de738 ML |
14755 | |
14756 | In each case, the @var{value} is an integer. The following choices | |
14757 | of @var{name} are recognized for all targets: | |
14758 | ||
14759 | @table @gcctabopt | |
14760 | @item predictable-branch-outcome | |
14761 | When branch is predicted to be taken with probability lower than this threshold | |
14762 | (in percent), then it is considered well predictable. | |
14763 | ||
14764 | @item max-rtl-if-conversion-insns | |
14765 | RTL if-conversion tries to remove conditional branches around a block and | |
14766 | replace them with conditionally executed instructions. This parameter | |
14767 | gives the maximum number of instructions in a block which should be | |
14768 | considered for if-conversion. The compiler will | |
14769 | also use other heuristics to decide whether if-conversion is likely to be | |
14770 | profitable. | |
14771 | ||
14772 | @item max-rtl-if-conversion-predictable-cost | |
14773 | RTL if-conversion will try to remove conditional branches around a block | |
14774 | and replace them with conditionally executed instructions. These parameters | |
14775 | give the maximum permissible cost for the sequence that would be generated | |
14776 | by if-conversion depending on whether the branch is statically determined | |
14777 | to be predictable or not. The units for this parameter are the same as | |
14778 | those for the GCC internal seq_cost metric. The compiler will try to | |
14779 | provide a reasonable default for this parameter using the BRANCH_COST | |
14780 | target macro. | |
14781 | ||
14782 | @item max-crossjump-edges | |
14783 | The maximum number of incoming edges to consider for cross-jumping. | |
14784 | The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in | |
14785 | the number of edges incoming to each block. Increasing values mean | |
14786 | more aggressive optimization, making the compilation time increase with | |
14787 | probably small improvement in executable size. | |
14788 | ||
14789 | @item min-crossjump-insns | |
14790 | The minimum number of instructions that must be matched at the end | |
14791 | of two blocks before cross-jumping is performed on them. This | |
14792 | value is ignored in the case where all instructions in the block being | |
14793 | cross-jumped from are matched. | |
14794 | ||
14795 | @item max-grow-copy-bb-insns | |
14796 | The maximum code size expansion factor when copying basic blocks | |
14797 | instead of jumping. The expansion is relative to a jump instruction. | |
14798 | ||
14799 | @item max-goto-duplication-insns | |
14800 | The maximum number of instructions to duplicate to a block that jumps | |
14801 | to a computed goto. To avoid @math{O(N^2)} behavior in a number of | |
14802 | passes, GCC factors computed gotos early in the compilation process, | |
14803 | and unfactors them as late as possible. Only computed jumps at the | |
14804 | end of a basic blocks with no more than max-goto-duplication-insns are | |
14805 | unfactored. | |
14806 | ||
14807 | @item max-delay-slot-insn-search | |
14808 | The maximum number of instructions to consider when looking for an | |
14809 | instruction to fill a delay slot. If more than this arbitrary number of | |
14810 | instructions are searched, the time savings from filling the delay slot | |
14811 | are minimal, so stop searching. Increasing values mean more | |
14812 | aggressive optimization, making the compilation time increase with probably | |
14813 | small improvement in execution time. | |
14814 | ||
14815 | @item max-delay-slot-live-search | |
14816 | When trying to fill delay slots, the maximum number of instructions to | |
14817 | consider when searching for a block with valid live register | |
14818 | information. Increasing this arbitrarily chosen value means more | |
14819 | aggressive optimization, increasing the compilation time. This parameter | |
14820 | should be removed when the delay slot code is rewritten to maintain the | |
14821 | control-flow graph. | |
14822 | ||
14823 | @item max-gcse-memory | |
14824 | The approximate maximum amount of memory in @code{kB} that can be allocated in | |
14825 | order to perform the global common subexpression elimination | |
14826 | optimization. If more memory than specified is required, the | |
14827 | optimization is not done. | |
14828 | ||
14829 | @item max-gcse-insertion-ratio | |
14830 | If the ratio of expression insertions to deletions is larger than this value | |
14831 | for any expression, then RTL PRE inserts or removes the expression and thus | |
14832 | leaves partially redundant computations in the instruction stream. | |
14833 | ||
14834 | @item max-pending-list-length | |
14835 | The maximum number of pending dependencies scheduling allows | |
14836 | before flushing the current state and starting over. Large functions | |
14837 | with few branches or calls can create excessively large lists which | |
14838 | needlessly consume memory and resources. | |
14839 | ||
14840 | @item max-modulo-backtrack-attempts | |
14841 | The maximum number of backtrack attempts the scheduler should make | |
14842 | when modulo scheduling a loop. Larger values can exponentially increase | |
14843 | compilation time. | |
14844 | ||
14845 | @item max-inline-functions-called-once-loop-depth | |
14846 | Maximal loop depth of a call considered by inline heuristics that tries to | |
14847 | inline all functions called once. | |
14848 | ||
14849 | @item max-inline-functions-called-once-insns | |
14850 | Maximal estimated size of functions produced while inlining functions called | |
14851 | once. | |
14852 | ||
14853 | @item max-inline-insns-single | |
14854 | Several parameters control the tree inliner used in GCC@. This number sets the | |
14855 | maximum number of instructions (counted in GCC's internal representation) in a | |
14856 | single function that the tree inliner considers for inlining. This only | |
14857 | affects functions declared inline and methods implemented in a class | |
14858 | declaration (C++). | |
14859 | ||
14860 | ||
14861 | @item max-inline-insns-auto | |
14862 | When you use @option{-finline-functions} (included in @option{-O3}), | |
14863 | a lot of functions that would otherwise not be considered for inlining | |
14864 | by the compiler are investigated. To those functions, a different | |
14865 | (more restrictive) limit compared to functions declared inline can | |
14866 | be applied (@option{--param max-inline-insns-auto}). | |
14867 | ||
14868 | @item max-inline-insns-small | |
14869 | This is bound applied to calls which are considered relevant with | |
14870 | @option{-finline-small-functions}. | |
14871 | ||
14872 | @item max-inline-insns-size | |
14873 | This is bound applied to calls which are optimized for size. Small growth | |
14874 | may be desirable to anticipate optimization oppurtunities exposed by inlining. | |
14875 | ||
14876 | @item uninlined-function-insns | |
14877 | Number of instructions accounted by inliner for function overhead such as | |
14878 | function prologue and epilogue. | |
14879 | ||
14880 | @item uninlined-function-time | |
14881 | Extra time accounted by inliner for function overhead such as time needed to | |
14882 | execute function prologue and epilogue. | |
14883 | ||
14884 | @item inline-heuristics-hint-percent | |
14885 | The scale (in percents) applied to @option{inline-insns-single}, | |
14886 | @option{inline-insns-single-O2}, @option{inline-insns-auto} | |
14887 | when inline heuristics hints that inlining is | |
14888 | very profitable (will enable later optimizations). | |
14889 | ||
14890 | @item uninlined-thunk-insns | |
14891 | @item uninlined-thunk-time | |
14892 | Same as @option{--param uninlined-function-insns} and | |
14893 | @option{--param uninlined-function-time} but applied to function thunks. | |
14894 | ||
14895 | @item inline-min-speedup | |
14896 | When estimated performance improvement of caller + callee runtime exceeds this | |
14897 | threshold (in percent), the function can be inlined regardless of the limit on | |
14898 | @option{--param max-inline-insns-single} and @option{--param | |
14899 | max-inline-insns-auto}. | |
14900 | ||
14901 | @item large-function-insns | |
14902 | The limit specifying really large functions. For functions larger than this | |
14903 | limit after inlining, inlining is constrained by | |
14904 | @option{--param large-function-growth}. This parameter is useful primarily | |
14905 | to avoid extreme compilation time caused by non-linear algorithms used by the | |
14906 | back end. | |
14907 | ||
14908 | @item large-function-growth | |
14909 | Specifies maximal growth of large function caused by inlining in percents. | |
14910 | For example, parameter value 100 limits large function growth to 2.0 times | |
14911 | the original size. | |
14912 | ||
14913 | @item large-unit-insns | |
14914 | The limit specifying large translation unit. Growth caused by inlining of | |
14915 | units larger than this limit is limited by @option{--param inline-unit-growth}. | |
14916 | For small units this might be too tight. | |
14917 | For example, consider a unit consisting of function A | |
14918 | that is inline and B that just calls A three times. If B is small relative to | |
14919 | A, the growth of unit is 300\% and yet such inlining is very sane. For very | |
14920 | large units consisting of small inlineable functions, however, the overall unit | |
14921 | growth limit is needed to avoid exponential explosion of code size. Thus for | |
14922 | smaller units, the size is increased to @option{--param large-unit-insns} | |
14923 | before applying @option{--param inline-unit-growth}. | |
14924 | ||
14925 | @item lazy-modules | |
14926 | Maximum number of concurrently open C++ module files when lazy loading. | |
14927 | ||
14928 | @item inline-unit-growth | |
14929 | Specifies maximal overall growth of the compilation unit caused by inlining. | |
14930 | For example, parameter value 20 limits unit growth to 1.2 times the original | |
14931 | size. Cold functions (either marked cold via an attribute or by profile | |
14932 | feedback) are not accounted into the unit size. | |
14933 | ||
14934 | @item ipa-cp-unit-growth | |
14935 | Specifies maximal overall growth of the compilation unit caused by | |
14936 | interprocedural constant propagation. For example, parameter value 10 limits | |
14937 | unit growth to 1.1 times the original size. | |
14938 | ||
14939 | @item ipa-cp-large-unit-insns | |
14940 | The size of translation unit that IPA-CP pass considers large. | |
14941 | ||
14942 | @item large-stack-frame | |
14943 | The limit specifying large stack frames. While inlining the algorithm is trying | |
14944 | to not grow past this limit too much. | |
14945 | ||
14946 | @item large-stack-frame-growth | |
14947 | Specifies maximal growth of large stack frames caused by inlining in percents. | |
14948 | For example, parameter value 1000 limits large stack frame growth to 11 times | |
14949 | the original size. | |
14950 | ||
14951 | @item max-inline-insns-recursive | |
14952 | @itemx max-inline-insns-recursive-auto | |
14953 | Specifies the maximum number of instructions an out-of-line copy of a | |
14954 | self-recursive inline | |
14955 | function can grow into by performing recursive inlining. | |
14956 | ||
14957 | @option{--param max-inline-insns-recursive} applies to functions | |
14958 | declared inline. | |
14959 | For functions not declared inline, recursive inlining | |
14960 | happens only when @option{-finline-functions} (included in @option{-O3}) is | |
14961 | enabled; @option{--param max-inline-insns-recursive-auto} applies instead. | |
14962 | ||
14963 | @item max-inline-recursive-depth | |
14964 | @itemx max-inline-recursive-depth-auto | |
14965 | Specifies the maximum recursion depth used for recursive inlining. | |
14966 | ||
14967 | @option{--param max-inline-recursive-depth} applies to functions | |
14968 | declared inline. For functions not declared inline, recursive inlining | |
14969 | happens only when @option{-finline-functions} (included in @option{-O3}) is | |
14970 | enabled; @option{--param max-inline-recursive-depth-auto} applies instead. | |
14971 | ||
14972 | @item min-inline-recursive-probability | |
14973 | Recursive inlining is profitable only for function having deep recursion | |
14974 | in average and can hurt for function having little recursion depth by | |
14975 | increasing the prologue size or complexity of function body to other | |
14976 | optimizers. | |
14977 | ||
14978 | When profile feedback is available (see @option{-fprofile-generate}) the actual | |
14979 | recursion depth can be guessed from the probability that function recurses | |
14980 | via a given call expression. This parameter limits inlining only to call | |
14981 | expressions whose probability exceeds the given threshold (in percents). | |
14982 | ||
14983 | @item early-inlining-insns | |
14984 | Specify growth that the early inliner can make. In effect it increases | |
14985 | the amount of inlining for code having a large abstraction penalty. | |
14986 | ||
14987 | @item max-early-inliner-iterations | |
14988 | Limit of iterations of the early inliner. This basically bounds | |
14989 | the number of nested indirect calls the early inliner can resolve. | |
14990 | Deeper chains are still handled by late inlining. | |
14991 | ||
14992 | @item comdat-sharing-probability | |
14993 | Probability (in percent) that C++ inline function with comdat visibility | |
14994 | are shared across multiple compilation units. | |
14995 | ||
14996 | @item modref-max-bases | |
14997 | @item modref-max-refs | |
14998 | @item modref-max-accesses | |
14999 | Specifies the maximal number of base pointers, references and accesses stored | |
15000 | for a single function by mod/ref analysis. | |
15001 | ||
15002 | @item modref-max-tests | |
15003 | Specifies the maxmal number of tests alias oracle can perform to disambiguate | |
15004 | memory locations using the mod/ref information. This parameter ought to be | |
15005 | bigger than @option{--param modref-max-bases} and @option{--param | |
15006 | modref-max-refs}. | |
15007 | ||
15008 | @item modref-max-depth | |
15009 | Specifies the maximum depth of DFS walk used by modref escape analysis. | |
15010 | Setting to 0 disables the analysis completely. | |
15011 | ||
15012 | @item modref-max-escape-points | |
15013 | Specifies the maximum number of escape points tracked by modref per SSA-name. | |
15014 | ||
15015 | @item modref-max-adjustments | |
15016 | Specifies the maximum number the access range is enlarged during modref dataflow | |
15017 | analysis. | |
15018 | ||
15019 | @item profile-func-internal-id | |
15020 | A parameter to control whether to use function internal id in profile | |
15021 | database lookup. If the value is 0, the compiler uses an id that | |
15022 | is based on function assembler name and filename, which makes old profile | |
15023 | data more tolerant to source changes such as function reordering etc. | |
15024 | ||
15025 | @item min-vect-loop-bound | |
15026 | The minimum number of iterations under which loops are not vectorized | |
15027 | when @option{-ftree-vectorize} is used. The number of iterations after | |
15028 | vectorization needs to be greater than the value specified by this option | |
15029 | to allow vectorization. | |
15030 | ||
15031 | @item gcse-cost-distance-ratio | |
15032 | Scaling factor in calculation of maximum distance an expression | |
15033 | can be moved by GCSE optimizations. This is currently supported only in the | |
15034 | code hoisting pass. The bigger the ratio, the more aggressive code hoisting | |
15035 | is with simple expressions, i.e., the expressions that have cost | |
15036 | less than @option{gcse-unrestricted-cost}. Specifying 0 disables | |
15037 | hoisting of simple expressions. | |
15038 | ||
15039 | @item gcse-unrestricted-cost | |
15040 | Cost, roughly measured as the cost of a single typical machine | |
15041 | instruction, at which GCSE optimizations do not constrain | |
15042 | the distance an expression can travel. This is currently | |
15043 | supported only in the code hoisting pass. The lesser the cost, | |
15044 | the more aggressive code hoisting is. Specifying 0 | |
15045 | allows all expressions to travel unrestricted distances. | |
15046 | ||
15047 | @item max-hoist-depth | |
15048 | The depth of search in the dominator tree for expressions to hoist. | |
15049 | This is used to avoid quadratic behavior in hoisting algorithm. | |
15050 | The value of 0 does not limit on the search, but may slow down compilation | |
15051 | of huge functions. | |
15052 | ||
15053 | @item max-tail-merge-comparisons | |
15054 | The maximum amount of similar bbs to compare a bb with. This is used to | |
15055 | avoid quadratic behavior in tree tail merging. | |
15056 | ||
15057 | @item max-tail-merge-iterations | |
15058 | The maximum amount of iterations of the pass over the function. This is used to | |
15059 | limit compilation time in tree tail merging. | |
15060 | ||
15061 | @item store-merging-allow-unaligned | |
15062 | Allow the store merging pass to introduce unaligned stores if it is legal to | |
15063 | do so. | |
15064 | ||
15065 | @item max-stores-to-merge | |
15066 | The maximum number of stores to attempt to merge into wider stores in the store | |
15067 | merging pass. | |
15068 | ||
15069 | @item max-store-chains-to-track | |
15070 | The maximum number of store chains to track at the same time in the attempt | |
15071 | to merge them into wider stores in the store merging pass. | |
15072 | ||
15073 | @item max-stores-to-track | |
15074 | The maximum number of stores to track at the same time in the attemt to | |
15075 | to merge them into wider stores in the store merging pass. | |
15076 | ||
15077 | @item max-unrolled-insns | |
15078 | The maximum number of instructions that a loop may have to be unrolled. | |
15079 | If a loop is unrolled, this parameter also determines how many times | |
15080 | the loop code is unrolled. | |
15081 | ||
15082 | @item max-average-unrolled-insns | |
15083 | The maximum number of instructions biased by probabilities of their execution | |
15084 | that a loop may have to be unrolled. If a loop is unrolled, | |
15085 | this parameter also determines how many times the loop code is unrolled. | |
15086 | ||
15087 | @item max-unroll-times | |
15088 | The maximum number of unrollings of a single loop. | |
15089 | ||
15090 | @item max-peeled-insns | |
15091 | The maximum number of instructions that a loop may have to be peeled. | |
15092 | If a loop is peeled, this parameter also determines how many times | |
15093 | the loop code is peeled. | |
15094 | ||
15095 | @item max-peel-times | |
15096 | The maximum number of peelings of a single loop. | |
15097 | ||
15098 | @item max-peel-branches | |
15099 | The maximum number of branches on the hot path through the peeled sequence. | |
15100 | ||
15101 | @item max-completely-peeled-insns | |
15102 | The maximum number of insns of a completely peeled loop. | |
15103 | ||
15104 | @item max-completely-peel-times | |
15105 | The maximum number of iterations of a loop to be suitable for complete peeling. | |
15106 | ||
15107 | @item max-completely-peel-loop-nest-depth | |
15108 | The maximum depth of a loop nest suitable for complete peeling. | |
15109 | ||
15110 | @item max-unswitch-insns | |
15111 | The maximum number of insns of an unswitched loop. | |
15112 | ||
5b50850c RB |
15113 | @item max-unswitch-depth |
15114 | The maximum depth of a loop nest to be unswitched. | |
15115 | ||
d77de738 ML |
15116 | @item lim-expensive |
15117 | The minimum cost of an expensive expression in the loop invariant motion. | |
15118 | ||
15119 | @item min-loop-cond-split-prob | |
15120 | When FDO profile information is available, @option{min-loop-cond-split-prob} | |
15121 | specifies minimum threshold for probability of semi-invariant condition | |
15122 | statement to trigger loop split. | |
15123 | ||
15124 | @item iv-consider-all-candidates-bound | |
15125 | Bound on number of candidates for induction variables, below which | |
15126 | all candidates are considered for each use in induction variable | |
15127 | optimizations. If there are more candidates than this, | |
15128 | only the most relevant ones are considered to avoid quadratic time complexity. | |
15129 | ||
15130 | @item iv-max-considered-uses | |
15131 | The induction variable optimizations give up on loops that contain more | |
15132 | induction variable uses. | |
15133 | ||
15134 | @item iv-always-prune-cand-set-bound | |
15135 | If the number of candidates in the set is smaller than this value, | |
15136 | always try to remove unnecessary ivs from the set | |
15137 | when adding a new one. | |
15138 | ||
15139 | @item avg-loop-niter | |
15140 | Average number of iterations of a loop. | |
15141 | ||
15142 | @item dse-max-object-size | |
15143 | Maximum size (in bytes) of objects tracked bytewise by dead store elimination. | |
15144 | Larger values may result in larger compilation times. | |
15145 | ||
15146 | @item dse-max-alias-queries-per-store | |
15147 | Maximum number of queries into the alias oracle per store. | |
15148 | Larger values result in larger compilation times and may result in more | |
15149 | removed dead stores. | |
15150 | ||
15151 | @item scev-max-expr-size | |
15152 | Bound on size of expressions used in the scalar evolutions analyzer. | |
15153 | Large expressions slow the analyzer. | |
15154 | ||
15155 | @item scev-max-expr-complexity | |
15156 | Bound on the complexity of the expressions in the scalar evolutions analyzer. | |
15157 | Complex expressions slow the analyzer. | |
15158 | ||
15159 | @item max-tree-if-conversion-phi-args | |
15160 | Maximum number of arguments in a PHI supported by TREE if conversion | |
15161 | unless the loop is marked with simd pragma. | |
15162 | ||
15163 | @item vect-max-layout-candidates | |
15164 | The maximum number of possible vector layouts (such as permutations) | |
15165 | to consider when optimizing to-be-vectorized code. | |
15166 | ||
15167 | @item vect-max-version-for-alignment-checks | |
15168 | The maximum number of run-time checks that can be performed when | |
15169 | doing loop versioning for alignment in the vectorizer. | |
15170 | ||
15171 | @item vect-max-version-for-alias-checks | |
15172 | The maximum number of run-time checks that can be performed when | |
15173 | doing loop versioning for alias in the vectorizer. | |
15174 | ||
15175 | @item vect-max-peeling-for-alignment | |
15176 | The maximum number of loop peels to enhance access alignment | |
15177 | for vectorizer. Value -1 means no limit. | |
15178 | ||
15179 | @item max-iterations-to-track | |
15180 | The maximum number of iterations of a loop the brute-force algorithm | |
15181 | for analysis of the number of iterations of the loop tries to evaluate. | |
15182 | ||
15183 | @item hot-bb-count-fraction | |
15184 | The denominator n of fraction 1/n of the maximal execution count of a | |
15185 | basic block in the entire program that a basic block needs to at least | |
15186 | have in order to be considered hot. The default is 10000, which means | |
15187 | that a basic block is considered hot if its execution count is greater | |
15188 | than 1/10000 of the maximal execution count. 0 means that it is never | |
15189 | considered hot. Used in non-LTO mode. | |
15190 | ||
15191 | @item hot-bb-count-ws-permille | |
15192 | The number of most executed permilles, ranging from 0 to 1000, of the | |
15193 | profiled execution of the entire program to which the execution count | |
15194 | of a basic block must be part of in order to be considered hot. The | |
15195 | default is 990, which means that a basic block is considered hot if | |
15196 | its execution count contributes to the upper 990 permilles, or 99.0%, | |
15197 | of the profiled execution of the entire program. 0 means that it is | |
15198 | never considered hot. Used in LTO mode. | |
15199 | ||
15200 | @item hot-bb-frequency-fraction | |
15201 | The denominator n of fraction 1/n of the execution frequency of the | |
15202 | entry block of a function that a basic block of this function needs | |
15203 | to at least have in order to be considered hot. The default is 1000, | |
15204 | which means that a basic block is considered hot in a function if it | |
15205 | is executed more frequently than 1/1000 of the frequency of the entry | |
15206 | block of the function. 0 means that it is never considered hot. | |
15207 | ||
15208 | @item unlikely-bb-count-fraction | |
15209 | The denominator n of fraction 1/n of the number of profiled runs of | |
15210 | the entire program below which the execution count of a basic block | |
15211 | must be in order for the basic block to be considered unlikely executed. | |
15212 | The default is 20, which means that a basic block is considered unlikely | |
15213 | executed if it is executed in fewer than 1/20, or 5%, of the runs of | |
15214 | the program. 0 means that it is always considered unlikely executed. | |
15215 | ||
15216 | @item max-predicted-iterations | |
15217 | The maximum number of loop iterations we predict statically. This is useful | |
15218 | in cases where a function contains a single loop with known bound and | |
15219 | another loop with unknown bound. | |
15220 | The known number of iterations is predicted correctly, while | |
15221 | the unknown number of iterations average to roughly 10. This means that the | |
15222 | loop without bounds appears artificially cold relative to the other one. | |
15223 | ||
15224 | @item builtin-expect-probability | |
15225 | Control the probability of the expression having the specified value. This | |
15226 | parameter takes a percentage (i.e.@: 0 ... 100) as input. | |
15227 | ||
15228 | @item builtin-string-cmp-inline-length | |
15229 | The maximum length of a constant string for a builtin string cmp call | |
15230 | eligible for inlining. | |
15231 | ||
15232 | @item align-threshold | |
15233 | ||
15234 | Select fraction of the maximal frequency of executions of a basic block in | |
15235 | a function to align the basic block. | |
15236 | ||
15237 | @item align-loop-iterations | |
15238 | ||
15239 | A loop expected to iterate at least the selected number of iterations is | |
15240 | aligned. | |
15241 | ||
15242 | @item tracer-dynamic-coverage | |
15243 | @itemx tracer-dynamic-coverage-feedback | |
15244 | ||
15245 | This value is used to limit superblock formation once the given percentage of | |
15246 | executed instructions is covered. This limits unnecessary code size | |
15247 | expansion. | |
15248 | ||
15249 | The @option{tracer-dynamic-coverage-feedback} parameter | |
15250 | is used only when profile | |
15251 | feedback is available. The real profiles (as opposed to statically estimated | |
15252 | ones) are much less balanced allowing the threshold to be larger value. | |
15253 | ||
15254 | @item tracer-max-code-growth | |
15255 | Stop tail duplication once code growth has reached given percentage. This is | |
15256 | a rather artificial limit, as most of the duplicates are eliminated later in | |
15257 | cross jumping, so it may be set to much higher values than is the desired code | |
15258 | growth. | |
15259 | ||
15260 | @item tracer-min-branch-ratio | |
15261 | ||
15262 | Stop reverse growth when the reverse probability of best edge is less than this | |
15263 | threshold (in percent). | |
15264 | ||
15265 | @item tracer-min-branch-probability | |
15266 | @itemx tracer-min-branch-probability-feedback | |
15267 | ||
15268 | Stop forward growth if the best edge has probability lower than this | |
15269 | threshold. | |
15270 | ||
15271 | Similarly to @option{tracer-dynamic-coverage} two parameters are | |
15272 | provided. @option{tracer-min-branch-probability-feedback} is used for | |
15273 | compilation with profile feedback and @option{tracer-min-branch-probability} | |
15274 | compilation without. The value for compilation with profile feedback | |
15275 | needs to be more conservative (higher) in order to make tracer | |
15276 | effective. | |
15277 | ||
15278 | @item stack-clash-protection-guard-size | |
15279 | Specify the size of the operating system provided stack guard as | |
15280 | 2 raised to @var{num} bytes. Higher values may reduce the | |
15281 | number of explicit probes, but a value larger than the operating system | |
15282 | provided guard will leave code vulnerable to stack clash style attacks. | |
15283 | ||
15284 | @item stack-clash-protection-probe-interval | |
15285 | Stack clash protection involves probing stack space as it is allocated. This | |
15286 | param controls the maximum distance between probes into the stack as 2 raised | |
15287 | to @var{num} bytes. Higher values may reduce the number of explicit probes, but a value | |
15288 | larger than the operating system provided guard will leave code vulnerable to | |
15289 | stack clash style attacks. | |
15290 | ||
15291 | @item max-cse-path-length | |
15292 | ||
15293 | The maximum number of basic blocks on path that CSE considers. | |
15294 | ||
15295 | @item max-cse-insns | |
15296 | The maximum number of instructions CSE processes before flushing. | |
15297 | ||
15298 | @item ggc-min-expand | |
15299 | ||
15300 | GCC uses a garbage collector to manage its own memory allocation. This | |
15301 | parameter specifies the minimum percentage by which the garbage | |
15302 | collector's heap should be allowed to expand between collections. | |
15303 | Tuning this may improve compilation speed; it has no effect on code | |
15304 | generation. | |
15305 | ||
15306 | The default is 30% + 70% * (RAM/1GB) with an upper bound of 100% when | |
15307 | RAM >= 1GB@. If @code{getrlimit} is available, the notion of ``RAM'' is | |
15308 | the smallest of actual RAM and @code{RLIMIT_DATA} or @code{RLIMIT_AS}. If | |
15309 | GCC is not able to calculate RAM on a particular platform, the lower | |
15310 | bound of 30% is used. Setting this parameter and | |
15311 | @option{ggc-min-heapsize} to zero causes a full collection to occur at | |
15312 | every opportunity. This is extremely slow, but can be useful for | |
15313 | debugging. | |
15314 | ||
15315 | @item ggc-min-heapsize | |
15316 | ||
15317 | Minimum size of the garbage collector's heap before it begins bothering | |
15318 | to collect garbage. The first collection occurs after the heap expands | |
15319 | by @option{ggc-min-expand}% beyond @option{ggc-min-heapsize}. Again, | |
15320 | tuning this may improve compilation speed, and has no effect on code | |
15321 | generation. | |
15322 | ||
15323 | The default is the smaller of RAM/8, RLIMIT_RSS, or a limit that | |
15324 | tries to ensure that RLIMIT_DATA or RLIMIT_AS are not exceeded, but | |
15325 | with a lower bound of 4096 (four megabytes) and an upper bound of | |
15326 | 131072 (128 megabytes). If GCC is not able to calculate RAM on a | |
15327 | particular platform, the lower bound is used. Setting this parameter | |
15328 | very large effectively disables garbage collection. Setting this | |
15329 | parameter and @option{ggc-min-expand} to zero causes a full collection | |
15330 | to occur at every opportunity. | |
15331 | ||
15332 | @item max-reload-search-insns | |
15333 | The maximum number of instruction reload should look backward for equivalent | |
15334 | register. Increasing values mean more aggressive optimization, making the | |
15335 | compilation time increase with probably slightly better performance. | |
15336 | ||
15337 | @item max-cselib-memory-locations | |
15338 | The maximum number of memory locations cselib should take into account. | |
15339 | Increasing values mean more aggressive optimization, making the compilation time | |
15340 | increase with probably slightly better performance. | |
15341 | ||
15342 | @item max-sched-ready-insns | |
15343 | The maximum number of instructions ready to be issued the scheduler should | |
15344 | consider at any given time during the first scheduling pass. Increasing | |
15345 | values mean more thorough searches, making the compilation time increase | |
15346 | with probably little benefit. | |
15347 | ||
15348 | @item max-sched-region-blocks | |
15349 | The maximum number of blocks in a region to be considered for | |
15350 | interblock scheduling. | |
15351 | ||
15352 | @item max-pipeline-region-blocks | |
15353 | The maximum number of blocks in a region to be considered for | |
15354 | pipelining in the selective scheduler. | |
15355 | ||
15356 | @item max-sched-region-insns | |
15357 | The maximum number of insns in a region to be considered for | |
15358 | interblock scheduling. | |
15359 | ||
15360 | @item max-pipeline-region-insns | |
15361 | The maximum number of insns in a region to be considered for | |
15362 | pipelining in the selective scheduler. | |
15363 | ||
15364 | @item min-spec-prob | |
15365 | The minimum probability (in percents) of reaching a source block | |
15366 | for interblock speculative scheduling. | |
15367 | ||
15368 | @item max-sched-extend-regions-iters | |
15369 | The maximum number of iterations through CFG to extend regions. | |
15370 | A value of 0 disables region extensions. | |
15371 | ||
15372 | @item max-sched-insn-conflict-delay | |
15373 | The maximum conflict delay for an insn to be considered for speculative motion. | |
15374 | ||
15375 | @item sched-spec-prob-cutoff | |
15376 | The minimal probability of speculation success (in percents), so that | |
15377 | speculative insns are scheduled. | |
15378 | ||
15379 | @item sched-state-edge-prob-cutoff | |
15380 | The minimum probability an edge must have for the scheduler to save its | |
15381 | state across it. | |
15382 | ||
15383 | @item sched-mem-true-dep-cost | |
15384 | Minimal distance (in CPU cycles) between store and load targeting same | |
15385 | memory locations. | |
15386 | ||
15387 | @item selsched-max-lookahead | |
15388 | The maximum size of the lookahead window of selective scheduling. It is a | |
15389 | depth of search for available instructions. | |
15390 | ||
15391 | @item selsched-max-sched-times | |
15392 | The maximum number of times that an instruction is scheduled during | |
15393 | selective scheduling. This is the limit on the number of iterations | |
15394 | through which the instruction may be pipelined. | |
15395 | ||
15396 | @item selsched-insns-to-rename | |
15397 | The maximum number of best instructions in the ready list that are considered | |
15398 | for renaming in the selective scheduler. | |
15399 | ||
15400 | @item sms-min-sc | |
15401 | The minimum value of stage count that swing modulo scheduler | |
15402 | generates. | |
15403 | ||
15404 | @item max-last-value-rtl | |
15405 | The maximum size measured as number of RTLs that can be recorded in an expression | |
15406 | in combiner for a pseudo register as last known value of that register. | |
15407 | ||
15408 | @item max-combine-insns | |
15409 | The maximum number of instructions the RTL combiner tries to combine. | |
15410 | ||
15411 | @item integer-share-limit | |
15412 | Small integer constants can use a shared data structure, reducing the | |
15413 | compiler's memory usage and increasing its speed. This sets the maximum | |
15414 | value of a shared integer constant. | |
15415 | ||
15416 | @item ssp-buffer-size | |
15417 | The minimum size of buffers (i.e.@: arrays) that receive stack smashing | |
15418 | protection when @option{-fstack-protector} is used. | |
15419 | ||
15420 | @item min-size-for-stack-sharing | |
15421 | The minimum size of variables taking part in stack slot sharing when not | |
15422 | optimizing. | |
15423 | ||
15424 | @item max-jump-thread-duplication-stmts | |
15425 | Maximum number of statements allowed in a block that needs to be | |
15426 | duplicated when threading jumps. | |
15427 | ||
15428 | @item max-jump-thread-paths | |
15429 | The maximum number of paths to consider when searching for jump threading | |
15430 | opportunities. When arriving at a block, incoming edges are only considered | |
15431 | if the number of paths to be searched so far multiplied by the number of | |
15432 | incoming edges does not exhaust the specified maximum number of paths to | |
15433 | consider. | |
15434 | ||
15435 | @item max-fields-for-field-sensitive | |
15436 | Maximum number of fields in a structure treated in | |
15437 | a field sensitive manner during pointer analysis. | |
15438 | ||
15439 | @item prefetch-latency | |
15440 | Estimate on average number of instructions that are executed before | |
15441 | prefetch finishes. The distance prefetched ahead is proportional | |
15442 | to this constant. Increasing this number may also lead to less | |
15443 | streams being prefetched (see @option{simultaneous-prefetches}). | |
15444 | ||
15445 | @item simultaneous-prefetches | |
15446 | Maximum number of prefetches that can run at the same time. | |
15447 | ||
15448 | @item l1-cache-line-size | |
15449 | The size of cache line in L1 data cache, in bytes. | |
15450 | ||
15451 | @item l1-cache-size | |
15452 | The size of L1 data cache, in kilobytes. | |
15453 | ||
15454 | @item l2-cache-size | |
15455 | The size of L2 data cache, in kilobytes. | |
15456 | ||
15457 | @item prefetch-dynamic-strides | |
15458 | Whether the loop array prefetch pass should issue software prefetch hints | |
15459 | for strides that are non-constant. In some cases this may be | |
15460 | beneficial, though the fact the stride is non-constant may make it | |
15461 | hard to predict when there is clear benefit to issuing these hints. | |
15462 | ||
15463 | Set to 1 if the prefetch hints should be issued for non-constant | |
15464 | strides. Set to 0 if prefetch hints should be issued only for strides that | |
15465 | are known to be constant and below @option{prefetch-minimum-stride}. | |
15466 | ||
15467 | @item prefetch-minimum-stride | |
15468 | Minimum constant stride, in bytes, to start using prefetch hints for. If | |
15469 | the stride is less than this threshold, prefetch hints will not be issued. | |
15470 | ||
15471 | This setting is useful for processors that have hardware prefetchers, in | |
15472 | which case there may be conflicts between the hardware prefetchers and | |
15473 | the software prefetchers. If the hardware prefetchers have a maximum | |
15474 | stride they can handle, it should be used here to improve the use of | |
15475 | software prefetchers. | |
15476 | ||
15477 | A value of -1 means we don't have a threshold and therefore | |
15478 | prefetch hints can be issued for any constant stride. | |
15479 | ||
15480 | This setting is only useful for strides that are known and constant. | |
15481 | ||
15482 | @item destructive-interference-size | |
15483 | @item constructive-interference-size | |
15484 | The values for the C++17 variables | |
15485 | @code{std::hardware_destructive_interference_size} and | |
15486 | @code{std::hardware_constructive_interference_size}. The destructive | |
15487 | interference size is the minimum recommended offset between two | |
15488 | independent concurrently-accessed objects; the constructive | |
15489 | interference size is the maximum recommended size of contiguous memory | |
15490 | accessed together. Typically both will be the size of an L1 cache | |
15491 | line for the target, in bytes. For a generic target covering a range of L1 | |
15492 | cache line sizes, typically the constructive interference size will be | |
15493 | the small end of the range and the destructive size will be the large | |
15494 | end. | |
15495 | ||
15496 | The destructive interference size is intended to be used for layout, | |
15497 | and thus has ABI impact. The default value is not expected to be | |
15498 | stable, and on some targets varies with @option{-mtune}, so use of | |
15499 | this variable in a context where ABI stability is important, such as | |
15500 | the public interface of a library, is strongly discouraged; if it is | |
15501 | used in that context, users can stabilize the value using this | |
15502 | option. | |
15503 | ||
15504 | The constructive interference size is less sensitive, as it is | |
15505 | typically only used in a @samp{static_assert} to make sure that a type | |
15506 | fits within a cache line. | |
15507 | ||
15508 | See also @option{-Winterference-size}. | |
15509 | ||
15510 | @item loop-interchange-max-num-stmts | |
15511 | The maximum number of stmts in a loop to be interchanged. | |
15512 | ||
15513 | @item loop-interchange-stride-ratio | |
15514 | The minimum ratio between stride of two loops for interchange to be profitable. | |
15515 | ||
15516 | @item min-insn-to-prefetch-ratio | |
15517 | The minimum ratio between the number of instructions and the | |
15518 | number of prefetches to enable prefetching in a loop. | |
15519 | ||
15520 | @item prefetch-min-insn-to-mem-ratio | |
15521 | The minimum ratio between the number of instructions and the | |
15522 | number of memory references to enable prefetching in a loop. | |
15523 | ||
15524 | @item use-canonical-types | |
15525 | Whether the compiler should use the ``canonical'' type system. | |
15526 | Should always be 1, which uses a more efficient internal | |
15527 | mechanism for comparing types in C++ and Objective-C++. However, if | |
15528 | bugs in the canonical type system are causing compilation failures, | |
15529 | set this value to 0 to disable canonical types. | |
15530 | ||
15531 | @item switch-conversion-max-branch-ratio | |
15532 | Switch initialization conversion refuses to create arrays that are | |
15533 | bigger than @option{switch-conversion-max-branch-ratio} times the number of | |
15534 | branches in the switch. | |
15535 | ||
15536 | @item max-partial-antic-length | |
15537 | Maximum length of the partial antic set computed during the tree | |
15538 | partial redundancy elimination optimization (@option{-ftree-pre}) when | |
15539 | optimizing at @option{-O3} and above. For some sorts of source code | |
15540 | the enhanced partial redundancy elimination optimization can run away, | |
15541 | consuming all of the memory available on the host machine. This | |
15542 | parameter sets a limit on the length of the sets that are computed, | |
15543 | which prevents the runaway behavior. Setting a value of 0 for | |
15544 | this parameter allows an unlimited set length. | |
15545 | ||
15546 | @item rpo-vn-max-loop-depth | |
15547 | Maximum loop depth that is value-numbered optimistically. | |
15548 | When the limit hits the innermost | |
15549 | @var{rpo-vn-max-loop-depth} loops and the outermost loop in the | |
15550 | loop nest are value-numbered optimistically and the remaining ones not. | |
15551 | ||
15552 | @item sccvn-max-alias-queries-per-access | |
15553 | Maximum number of alias-oracle queries we perform when looking for | |
15554 | redundancies for loads and stores. If this limit is hit the search | |
15555 | is aborted and the load or store is not considered redundant. The | |
15556 | number of queries is algorithmically limited to the number of | |
15557 | stores on all paths from the load to the function entry. | |
15558 | ||
15559 | @item ira-max-loops-num | |
15560 | IRA uses regional register allocation by default. If a function | |
15561 | contains more loops than the number given by this parameter, only at most | |
15562 | the given number of the most frequently-executed loops form regions | |
15563 | for regional register allocation. | |
15564 | ||
15565 | @item ira-max-conflict-table-size | |
15566 | Although IRA uses a sophisticated algorithm to compress the conflict | |
15567 | table, the table can still require excessive amounts of memory for | |
15568 | huge functions. If the conflict table for a function could be more | |
15569 | than the size in MB given by this parameter, the register allocator | |
15570 | instead uses a faster, simpler, and lower-quality | |
15571 | algorithm that does not require building a pseudo-register conflict table. | |
15572 | ||
15573 | @item ira-loop-reserved-regs | |
15574 | IRA can be used to evaluate more accurate register pressure in loops | |
15575 | for decisions to move loop invariants (see @option{-O3}). The number | |
15576 | of available registers reserved for some other purposes is given | |
15577 | by this parameter. Default of the parameter | |
15578 | is the best found from numerous experiments. | |
15579 | ||
15580 | @item ira-consider-dup-in-all-alts | |
15581 | Make IRA to consider matching constraint (duplicated operand number) | |
15582 | heavily in all available alternatives for preferred register class. | |
15583 | If it is set as zero, it means IRA only respects the matching | |
15584 | constraint when it's in the only available alternative with an | |
15585 | appropriate register class. Otherwise, it means IRA will check all | |
15586 | available alternatives for preferred register class even if it has | |
15587 | found some choice with an appropriate register class and respect the | |
15588 | found qualified matching constraint. | |
15589 | ||
9847c753 ML |
15590 | @item ira-simple-lra-insn-threshold |
15591 | Approximate function insn number in 1K units triggering simple local RA. | |
15592 | ||
d77de738 ML |
15593 | @item lra-inheritance-ebb-probability-cutoff |
15594 | LRA tries to reuse values reloaded in registers in subsequent insns. | |
15595 | This optimization is called inheritance. EBB is used as a region to | |
15596 | do this optimization. The parameter defines a minimal fall-through | |
15597 | edge probability in percentage used to add BB to inheritance EBB in | |
15598 | LRA. The default value was chosen | |
15599 | from numerous runs of SPEC2000 on x86-64. | |
15600 | ||
15601 | @item loop-invariant-max-bbs-in-loop | |
15602 | Loop invariant motion can be very expensive, both in compilation time and | |
15603 | in amount of needed compile-time memory, with very large loops. Loops | |
15604 | with more basic blocks than this parameter won't have loop invariant | |
15605 | motion optimization performed on them. | |
15606 | ||
15607 | @item loop-max-datarefs-for-datadeps | |
15608 | Building data dependencies is expensive for very large loops. This | |
15609 | parameter limits the number of data references in loops that are | |
15610 | considered for data dependence analysis. These large loops are no | |
15611 | handled by the optimizations using loop data dependencies. | |
15612 | ||
15613 | @item max-vartrack-size | |
15614 | Sets a maximum number of hash table slots to use during variable | |
15615 | tracking dataflow analysis of any function. If this limit is exceeded | |
15616 | with variable tracking at assignments enabled, analysis for that | |
15617 | function is retried without it, after removing all debug insns from | |
15618 | the function. If the limit is exceeded even without debug insns, var | |
15619 | tracking analysis is completely disabled for the function. Setting | |
15620 | the parameter to zero makes it unlimited. | |
15621 | ||
15622 | @item max-vartrack-expr-depth | |
15623 | Sets a maximum number of recursion levels when attempting to map | |
15624 | variable names or debug temporaries to value expressions. This trades | |
15625 | compilation time for more complete debug information. If this is set too | |
15626 | low, value expressions that are available and could be represented in | |
15627 | debug information may end up not being used; setting this higher may | |
15628 | enable the compiler to find more complex debug expressions, but compile | |
15629 | time and memory use may grow. | |
15630 | ||
15631 | @item max-debug-marker-count | |
15632 | Sets a threshold on the number of debug markers (e.g.@: begin stmt | |
15633 | markers) to avoid complexity explosion at inlining or expanding to RTL. | |
15634 | If a function has more such gimple stmts than the set limit, such stmts | |
15635 | will be dropped from the inlined copy of a function, and from its RTL | |
15636 | expansion. | |
15637 | ||
15638 | @item min-nondebug-insn-uid | |
15639 | Use uids starting at this parameter for nondebug insns. The range below | |
15640 | the parameter is reserved exclusively for debug insns created by | |
15641 | @option{-fvar-tracking-assignments}, but debug insns may get | |
15642 | (non-overlapping) uids above it if the reserved range is exhausted. | |
15643 | ||
10478270 MJ |
15644 | @item ipa-sra-deref-prob-threshold |
15645 | IPA-SRA replaces a pointer which is known not be NULL with one or more | |
15646 | new parameters only when the probability (in percent, relative to | |
15647 | function entry) of it being dereferenced is higher than this parameter. | |
15648 | ||
d77de738 ML |
15649 | @item ipa-sra-ptr-growth-factor |
15650 | IPA-SRA replaces a pointer to an aggregate with one or more new | |
15651 | parameters only when their cumulative size is less or equal to | |
15652 | @option{ipa-sra-ptr-growth-factor} times the size of the original | |
15653 | pointer parameter. | |
15654 | ||
69363825 ML |
15655 | @item ipa-sra-ptrwrap-growth-factor |
15656 | Additional maximum allowed growth of total size of new parameters | |
15657 | that ipa-sra replaces a pointer to an aggregate with, | |
049dccd0 MJ |
15658 | if it points to a local variable that the caller only writes to and |
15659 | passes it as an argument to other functions. | |
69363825 | 15660 | |
d77de738 ML |
15661 | @item ipa-sra-max-replacements |
15662 | Maximum pieces of an aggregate that IPA-SRA tracks. As a | |
15663 | consequence, it is also the maximum number of replacements of a formal | |
15664 | parameter. | |
15665 | ||
15666 | @item sra-max-scalarization-size-Ospeed | |
15667 | @itemx sra-max-scalarization-size-Osize | |
15668 | The two Scalar Reduction of Aggregates passes (SRA and IPA-SRA) aim to | |
15669 | replace scalar parts of aggregates with uses of independent scalar | |
15670 | variables. These parameters control the maximum size, in storage units, | |
15671 | of aggregate which is considered for replacement when compiling for | |
15672 | speed | |
15673 | (@option{sra-max-scalarization-size-Ospeed}) or size | |
15674 | (@option{sra-max-scalarization-size-Osize}) respectively. | |
15675 | ||
15676 | @item sra-max-propagations | |
15677 | The maximum number of artificial accesses that Scalar Replacement of | |
15678 | Aggregates (SRA) will track, per one local variable, in order to | |
15679 | facilitate copy propagation. | |
15680 | ||
15681 | @item tm-max-aggregate-size | |
15682 | When making copies of thread-local variables in a transaction, this | |
15683 | parameter specifies the size in bytes after which variables are | |
15684 | saved with the logging functions as opposed to save/restore code | |
15685 | sequence pairs. This option only applies when using | |
15686 | @option{-fgnu-tm}. | |
15687 | ||
15688 | @item graphite-max-nb-scop-params | |
15689 | To avoid exponential effects in the Graphite loop transforms, the | |
15690 | number of parameters in a Static Control Part (SCoP) is bounded. | |
15691 | A value of zero can be used to lift | |
15692 | the bound. A variable whose value is unknown at compilation time and | |
15693 | defined outside a SCoP is a parameter of the SCoP. | |
15694 | ||
15695 | @item loop-block-tile-size | |
15696 | Loop blocking or strip mining transforms, enabled with | |
15697 | @option{-floop-block} or @option{-floop-strip-mine}, strip mine each | |
15698 | loop in the loop nest by a given number of iterations. The strip | |
15699 | length can be changed using the @option{loop-block-tile-size} | |
15700 | parameter. | |
15701 | ||
15702 | @item ipa-jump-function-lookups | |
15703 | Specifies number of statements visited during jump function offset discovery. | |
15704 | ||
15705 | @item ipa-cp-value-list-size | |
15706 | IPA-CP attempts to track all possible values and types passed to a function's | |
15707 | parameter in order to propagate them and perform devirtualization. | |
15708 | @option{ipa-cp-value-list-size} is the maximum number of values and types it | |
15709 | stores per one formal parameter of a function. | |
15710 | ||
15711 | @item ipa-cp-eval-threshold | |
15712 | IPA-CP calculates its own score of cloning profitability heuristics | |
15713 | and performs those cloning opportunities with scores that exceed | |
15714 | @option{ipa-cp-eval-threshold}. | |
15715 | ||
15716 | @item ipa-cp-max-recursive-depth | |
15717 | Maximum depth of recursive cloning for self-recursive function. | |
15718 | ||
15719 | @item ipa-cp-min-recursive-probability | |
15720 | Recursive cloning only when the probability of call being executed exceeds | |
15721 | the parameter. | |
15722 | ||
15723 | @item ipa-cp-profile-count-base | |
15724 | When using @option{-fprofile-use} option, IPA-CP will consider the measured | |
15725 | execution count of a call graph edge at this percentage position in their | |
15726 | histogram as the basis for its heuristics calculation. | |
15727 | ||
15728 | @item ipa-cp-recursive-freq-factor | |
15729 | The number of times interprocedural copy propagation expects recursive | |
15730 | functions to call themselves. | |
15731 | ||
15732 | @item ipa-cp-recursion-penalty | |
15733 | Percentage penalty the recursive functions will receive when they | |
15734 | are evaluated for cloning. | |
15735 | ||
15736 | @item ipa-cp-single-call-penalty | |
15737 | Percentage penalty functions containing a single call to another | |
15738 | function will receive when they are evaluated for cloning. | |
15739 | ||
15740 | @item ipa-max-agg-items | |
15741 | IPA-CP is also capable to propagate a number of scalar values passed | |
15742 | in an aggregate. @option{ipa-max-agg-items} controls the maximum | |
15743 | number of such values per one parameter. | |
15744 | ||
15745 | @item ipa-cp-loop-hint-bonus | |
15746 | When IPA-CP determines that a cloning candidate would make the number | |
15747 | of iterations of a loop known, it adds a bonus of | |
15748 | @option{ipa-cp-loop-hint-bonus} to the profitability score of | |
15749 | the candidate. | |
15750 | ||
15751 | @item ipa-max-loop-predicates | |
15752 | The maximum number of different predicates IPA will use to describe when | |
15753 | loops in a function have known properties. | |
15754 | ||
15755 | @item ipa-max-aa-steps | |
15756 | During its analysis of function bodies, IPA-CP employs alias analysis | |
15757 | in order to track values pointed to by function parameters. In order | |
15758 | not spend too much time analyzing huge functions, it gives up and | |
15759 | consider all memory clobbered after examining | |
15760 | @option{ipa-max-aa-steps} statements modifying memory. | |
15761 | ||
15762 | @item ipa-max-switch-predicate-bounds | |
15763 | Maximal number of boundary endpoints of case ranges of switch statement. | |
15764 | For switch exceeding this limit, IPA-CP will not construct cloning cost | |
15765 | predicate, which is used to estimate cloning benefit, for default case | |
15766 | of the switch statement. | |
15767 | ||
15768 | @item ipa-max-param-expr-ops | |
15769 | IPA-CP will analyze conditional statement that references some function | |
15770 | parameter to estimate benefit for cloning upon certain constant value. | |
15771 | But if number of operations in a parameter expression exceeds | |
15772 | @option{ipa-max-param-expr-ops}, the expression is treated as complicated | |
15773 | one, and is not handled by IPA analysis. | |
15774 | ||
15775 | @item lto-partitions | |
15776 | Specify desired number of partitions produced during WHOPR compilation. | |
15777 | The number of partitions should exceed the number of CPUs used for compilation. | |
15778 | ||
15779 | @item lto-min-partition | |
15780 | Size of minimal partition for WHOPR (in estimated instructions). | |
15781 | This prevents expenses of splitting very small programs into too many | |
15782 | partitions. | |
15783 | ||
15784 | @item lto-max-partition | |
15785 | Size of max partition for WHOPR (in estimated instructions). | |
15786 | to provide an upper bound for individual size of partition. | |
15787 | Meant to be used only with balanced partitioning. | |
15788 | ||
15789 | @item lto-max-streaming-parallelism | |
15790 | Maximal number of parallel processes used for LTO streaming. | |
15791 | ||
15792 | @item cxx-max-namespaces-for-diagnostic-help | |
15793 | The maximum number of namespaces to consult for suggestions when C++ | |
15794 | name lookup fails for an identifier. | |
15795 | ||
15796 | @item sink-frequency-threshold | |
15797 | The maximum relative execution frequency (in percents) of the target block | |
15798 | relative to a statement's original block to allow statement sinking of a | |
15799 | statement. Larger numbers result in more aggressive statement sinking. | |
15800 | A small positive adjustment is applied for | |
15801 | statements with memory operands as those are even more profitable so sink. | |
15802 | ||
15803 | @item max-stores-to-sink | |
15804 | The maximum number of conditional store pairs that can be sunk. Set to 0 | |
15805 | if either vectorization (@option{-ftree-vectorize}) or if-conversion | |
15806 | (@option{-ftree-loop-if-convert}) is disabled. | |
15807 | ||
15808 | @item case-values-threshold | |
15809 | The smallest number of different values for which it is best to use a | |
15810 | jump-table instead of a tree of conditional branches. If the value is | |
15811 | 0, use the default for the machine. | |
15812 | ||
15813 | @item jump-table-max-growth-ratio-for-size | |
15814 | The maximum code size growth ratio when expanding | |
15815 | into a jump table (in percent). The parameter is used when | |
15816 | optimizing for size. | |
15817 | ||
15818 | @item jump-table-max-growth-ratio-for-speed | |
15819 | The maximum code size growth ratio when expanding | |
15820 | into a jump table (in percent). The parameter is used when | |
15821 | optimizing for speed. | |
15822 | ||
15823 | @item tree-reassoc-width | |
15824 | Set the maximum number of instructions executed in parallel in | |
15825 | reassociated tree. This parameter overrides target dependent | |
15826 | heuristics used by default if has non zero value. | |
15827 | ||
15828 | @item sched-pressure-algorithm | |
15829 | Choose between the two available implementations of | |
15830 | @option{-fsched-pressure}. Algorithm 1 is the original implementation | |
15831 | and is the more likely to prevent instructions from being reordered. | |
15832 | Algorithm 2 was designed to be a compromise between the relatively | |
15833 | conservative approach taken by algorithm 1 and the rather aggressive | |
15834 | approach taken by the default scheduler. It relies more heavily on | |
15835 | having a regular register file and accurate register pressure classes. | |
15836 | See @file{haifa-sched.cc} in the GCC sources for more details. | |
15837 | ||
15838 | The default choice depends on the target. | |
15839 | ||
15840 | @item max-slsr-cand-scan | |
15841 | Set the maximum number of existing candidates that are considered when | |
15842 | seeking a basis for a new straight-line strength reduction candidate. | |
15843 | ||
15844 | @item asan-globals | |
15845 | Enable buffer overflow detection for global objects. This kind | |
15846 | of protection is enabled by default if you are using | |
15847 | @option{-fsanitize=address} option. | |
15848 | To disable global objects protection use @option{--param asan-globals=0}. | |
15849 | ||
15850 | @item asan-stack | |
15851 | Enable buffer overflow detection for stack objects. This kind of | |
15852 | protection is enabled by default when using @option{-fsanitize=address}. | |
15853 | To disable stack protection use @option{--param asan-stack=0} option. | |
15854 | ||
15855 | @item asan-instrument-reads | |
15856 | Enable buffer overflow detection for memory reads. This kind of | |
15857 | protection is enabled by default when using @option{-fsanitize=address}. | |
15858 | To disable memory reads protection use | |
15859 | @option{--param asan-instrument-reads=0}. | |
15860 | ||
15861 | @item asan-instrument-writes | |
15862 | Enable buffer overflow detection for memory writes. This kind of | |
15863 | protection is enabled by default when using @option{-fsanitize=address}. | |
15864 | To disable memory writes protection use | |
15865 | @option{--param asan-instrument-writes=0} option. | |
15866 | ||
15867 | @item asan-memintrin | |
15868 | Enable detection for built-in functions. This kind of protection | |
15869 | is enabled by default when using @option{-fsanitize=address}. | |
15870 | To disable built-in functions protection use | |
15871 | @option{--param asan-memintrin=0}. | |
15872 | ||
15873 | @item asan-use-after-return | |
15874 | Enable detection of use-after-return. This kind of protection | |
15875 | is enabled by default when using the @option{-fsanitize=address} option. | |
15876 | To disable it use @option{--param asan-use-after-return=0}. | |
15877 | ||
15878 | Note: By default the check is disabled at run time. To enable it, | |
15879 | add @code{detect_stack_use_after_return=1} to the environment variable | |
15880 | @env{ASAN_OPTIONS}. | |
15881 | ||
15882 | @item asan-instrumentation-with-call-threshold | |
15883 | If number of memory accesses in function being instrumented | |
15884 | is greater or equal to this number, use callbacks instead of inline checks. | |
15885 | E.g. to disable inline code use | |
15886 | @option{--param asan-instrumentation-with-call-threshold=0}. | |
15887 | ||
545c9f8b | 15888 | @item asan-kernel-mem-intrinsic-prefix |
f56ed5b3 SL |
15889 | If nonzero, prefix calls to @code{memcpy}, @code{memset} and @code{memmove} |
15890 | with @samp{__asan_} or @samp{__hwasan_} | |
15891 | for @option{-fsanitize=kernel-address} or @samp{-fsanitize=kernel-hwaddress}, | |
15892 | respectively. | |
545c9f8b | 15893 | |
d77de738 ML |
15894 | @item hwasan-instrument-stack |
15895 | Enable hwasan instrumentation of statically sized stack-allocated variables. | |
15896 | This kind of instrumentation is enabled by default when using | |
15897 | @option{-fsanitize=hwaddress} and disabled by default when using | |
15898 | @option{-fsanitize=kernel-hwaddress}. | |
15899 | To disable stack instrumentation use | |
15900 | @option{--param hwasan-instrument-stack=0}, and to enable it use | |
15901 | @option{--param hwasan-instrument-stack=1}. | |
15902 | ||
15903 | @item hwasan-random-frame-tag | |
15904 | When using stack instrumentation, decide tags for stack variables using a | |
15905 | deterministic sequence beginning at a random tag for each frame. With this | |
15906 | parameter unset tags are chosen using the same sequence but beginning from 1. | |
15907 | This is enabled by default for @option{-fsanitize=hwaddress} and unavailable | |
15908 | for @option{-fsanitize=kernel-hwaddress}. | |
15909 | To disable it use @option{--param hwasan-random-frame-tag=0}. | |
15910 | ||
15911 | @item hwasan-instrument-allocas | |
15912 | Enable hwasan instrumentation of dynamically sized stack-allocated variables. | |
15913 | This kind of instrumentation is enabled by default when using | |
15914 | @option{-fsanitize=hwaddress} and disabled by default when using | |
15915 | @option{-fsanitize=kernel-hwaddress}. | |
15916 | To disable instrumentation of such variables use | |
15917 | @option{--param hwasan-instrument-allocas=0}, and to enable it use | |
15918 | @option{--param hwasan-instrument-allocas=1}. | |
15919 | ||
15920 | @item hwasan-instrument-reads | |
15921 | Enable hwasan checks on memory reads. Instrumentation of reads is enabled by | |
15922 | default for both @option{-fsanitize=hwaddress} and | |
15923 | @option{-fsanitize=kernel-hwaddress}. | |
15924 | To disable checking memory reads use | |
15925 | @option{--param hwasan-instrument-reads=0}. | |
15926 | ||
15927 | @item hwasan-instrument-writes | |
15928 | Enable hwasan checks on memory writes. Instrumentation of writes is enabled by | |
15929 | default for both @option{-fsanitize=hwaddress} and | |
15930 | @option{-fsanitize=kernel-hwaddress}. | |
15931 | To disable checking memory writes use | |
15932 | @option{--param hwasan-instrument-writes=0}. | |
15933 | ||
15934 | @item hwasan-instrument-mem-intrinsics | |
15935 | Enable hwasan instrumentation of builtin functions. Instrumentation of these | |
15936 | builtin functions is enabled by default for both @option{-fsanitize=hwaddress} | |
15937 | and @option{-fsanitize=kernel-hwaddress}. | |
15938 | To disable instrumentation of builtin functions use | |
15939 | @option{--param hwasan-instrument-mem-intrinsics=0}. | |
15940 | ||
15941 | @item use-after-scope-direct-emission-threshold | |
15942 | If the size of a local variable in bytes is smaller or equal to this | |
15943 | number, directly poison (or unpoison) shadow memory instead of using | |
15944 | run-time callbacks. | |
15945 | ||
15946 | @item tsan-distinguish-volatile | |
15947 | Emit special instrumentation for accesses to volatiles. | |
15948 | ||
15949 | @item tsan-instrument-func-entry-exit | |
15950 | Emit instrumentation calls to __tsan_func_entry() and __tsan_func_exit(). | |
15951 | ||
15952 | @item max-fsm-thread-path-insns | |
15953 | Maximum number of instructions to copy when duplicating blocks on a | |
15954 | finite state automaton jump thread path. | |
15955 | ||
15956 | @item threader-debug | |
15957 | threader-debug=[none|all] Enables verbose dumping of the threader solver. | |
15958 | ||
15959 | @item parloops-chunk-size | |
15960 | Chunk size of omp schedule for loops parallelized by parloops. | |
15961 | ||
15962 | @item parloops-schedule | |
15963 | Schedule type of omp schedule for loops parallelized by parloops (static, | |
15964 | dynamic, guided, auto, runtime). | |
15965 | ||
15966 | @item parloops-min-per-thread | |
15967 | The minimum number of iterations per thread of an innermost parallelized | |
15968 | loop for which the parallelized variant is preferred over the single threaded | |
15969 | one. Note that for a parallelized loop nest the | |
15970 | minimum number of iterations of the outermost loop per thread is two. | |
15971 | ||
15972 | @item max-ssa-name-query-depth | |
15973 | Maximum depth of recursion when querying properties of SSA names in things | |
15974 | like fold routines. One level of recursion corresponds to following a | |
15975 | use-def chain. | |
15976 | ||
15977 | @item max-speculative-devirt-maydefs | |
15978 | The maximum number of may-defs we analyze when looking for a must-def | |
15979 | specifying the dynamic type of an object that invokes a virtual call | |
15980 | we may be able to devirtualize speculatively. | |
15981 | ||
d77de738 ML |
15982 | @item evrp-sparse-threshold |
15983 | Maximum number of basic blocks before EVRP uses a sparse cache. | |
15984 | ||
d77de738 ML |
15985 | @item ranger-debug |
15986 | Specifies the type of debug output to be issued for ranges. | |
15987 | ||
15988 | @item evrp-switch-limit | |
15989 | Specifies the maximum number of switch cases before EVRP ignores a switch. | |
15990 | ||
15991 | @item unroll-jam-min-percent | |
15992 | The minimum percentage of memory references that must be optimized | |
15993 | away for the unroll-and-jam transformation to be considered profitable. | |
15994 | ||
15995 | @item unroll-jam-max-unroll | |
15996 | The maximum number of times the outer loop should be unrolled by | |
15997 | the unroll-and-jam transformation. | |
15998 | ||
15999 | @item max-rtl-if-conversion-unpredictable-cost | |
16000 | Maximum permissible cost for the sequence that would be generated | |
16001 | by the RTL if-conversion pass for a branch that is considered unpredictable. | |
16002 | ||
16003 | @item max-variable-expansions-in-unroller | |
16004 | If @option{-fvariable-expansion-in-unroller} is used, the maximum number | |
16005 | of times that an individual variable will be expanded during loop unrolling. | |
16006 | ||
16007 | @item partial-inlining-entry-probability | |
16008 | Maximum probability of the entry BB of split region | |
16009 | (in percent relative to entry BB of the function) | |
16010 | to make partial inlining happen. | |
16011 | ||
16012 | @item max-tracked-strlens | |
16013 | Maximum number of strings for which strlen optimization pass will | |
16014 | track string lengths. | |
16015 | ||
16016 | @item gcse-after-reload-partial-fraction | |
16017 | The threshold ratio for performing partial redundancy | |
16018 | elimination after reload. | |
16019 | ||
16020 | @item gcse-after-reload-critical-fraction | |
16021 | The threshold ratio of critical edges execution count that | |
16022 | permit performing redundancy elimination after reload. | |
16023 | ||
16024 | @item max-loop-header-insns | |
16025 | The maximum number of insns in loop header duplicated | |
16026 | by the copy loop headers pass. | |
16027 | ||
16028 | @item vect-epilogues-nomask | |
16029 | Enable loop epilogue vectorization using smaller vector size. | |
16030 | ||
16031 | @item vect-partial-vector-usage | |
16032 | Controls when the loop vectorizer considers using partial vector loads | |
16033 | and stores as an alternative to falling back to scalar code. 0 stops | |
16034 | the vectorizer from ever using partial vector loads and stores. 1 allows | |
16035 | partial vector loads and stores if vectorization removes the need for the | |
16036 | code to iterate. 2 allows partial vector loads and stores in all loops. | |
16037 | The parameter only has an effect on targets that support partial | |
16038 | vector loads and stores. | |
16039 | ||
16040 | @item vect-inner-loop-cost-factor | |
16041 | The maximum factor which the loop vectorizer applies to the cost of statements | |
16042 | in an inner loop relative to the loop being vectorized. The factor applied | |
16043 | is the maximum of the estimated number of iterations of the inner loop and | |
16044 | this parameter. The default value of this parameter is 50. | |
16045 | ||
16046 | @item vect-induction-float | |
16047 | Enable loop vectorization of floating point inductions. | |
16048 | ||
16049 | @item avoid-fma-max-bits | |
16050 | Maximum number of bits for which we avoid creating FMAs. | |
16051 | ||
16052 | @item sms-loop-average-count-threshold | |
16053 | A threshold on the average loop count considered by the swing modulo scheduler. | |
16054 | ||
16055 | @item sms-dfa-history | |
16056 | The number of cycles the swing modulo scheduler considers when checking | |
16057 | conflicts using DFA. | |
16058 | ||
16059 | @item graphite-allow-codegen-errors | |
16060 | Whether codegen errors should be ICEs when @option{-fchecking}. | |
16061 | ||
16062 | @item sms-max-ii-factor | |
16063 | A factor for tuning the upper bound that swing modulo scheduler | |
16064 | uses for scheduling a loop. | |
16065 | ||
16066 | @item lra-max-considered-reload-pseudos | |
16067 | The max number of reload pseudos which are considered during | |
16068 | spilling a non-reload pseudo. | |
16069 | ||
16070 | @item max-pow-sqrt-depth | |
16071 | Maximum depth of sqrt chains to use when synthesizing exponentiation | |
16072 | by a real constant. | |
16073 | ||
16074 | @item max-dse-active-local-stores | |
16075 | Maximum number of active local stores in RTL dead store elimination. | |
16076 | ||
16077 | @item asan-instrument-allocas | |
16078 | Enable asan allocas/VLAs protection. | |
16079 | ||
16080 | @item max-iterations-computation-cost | |
16081 | Bound on the cost of an expression to compute the number of iterations. | |
16082 | ||
16083 | @item max-isl-operations | |
16084 | Maximum number of isl operations, 0 means unlimited. | |
16085 | ||
16086 | @item graphite-max-arrays-per-scop | |
16087 | Maximum number of arrays per scop. | |
16088 | ||
16089 | @item max-vartrack-reverse-op-size | |
16090 | Max. size of loc list for which reverse ops should be added. | |
16091 | ||
16092 | @item fsm-scale-path-stmts | |
16093 | Scale factor to apply to the number of statements in a threading path | |
7c9f20fc RB |
16094 | crossing a loop backedge when comparing to |
16095 | @option{--param=max-jump-thread-duplication-stmts}. | |
d77de738 ML |
16096 | |
16097 | @item uninit-control-dep-attempts | |
16098 | Maximum number of nested calls to search for control dependencies | |
16099 | during uninitialized variable analysis. | |
16100 | ||
d77de738 ML |
16101 | @item sched-autopref-queue-depth |
16102 | Hardware autoprefetcher scheduler model control flag. | |
16103 | Number of lookahead cycles the model looks into; at ' | |
16104 | ' only enable instruction sorting heuristic. | |
16105 | ||
16106 | @item loop-versioning-max-inner-insns | |
16107 | The maximum number of instructions that an inner loop can have | |
16108 | before the loop versioning pass considers it too big to copy. | |
16109 | ||
16110 | @item loop-versioning-max-outer-insns | |
16111 | The maximum number of instructions that an outer loop can have | |
16112 | before the loop versioning pass considers it too big to copy, | |
16113 | discounting any instructions in inner loops that directly benefit | |
16114 | from versioning. | |
16115 | ||
16116 | @item ssa-name-def-chain-limit | |
16117 | The maximum number of SSA_NAME assignments to follow in determining | |
16118 | a property of a variable such as its value. This limits the number | |
16119 | of iterations or recursive calls GCC performs when optimizing certain | |
16120 | statements or when determining their validity prior to issuing | |
16121 | diagnostics. | |
16122 | ||
16123 | @item store-merging-max-size | |
16124 | Maximum size of a single store merging region in bytes. | |
16125 | ||
16126 | @item hash-table-verification-limit | |
16127 | The number of elements for which hash table verification is done | |
16128 | for each searched element. | |
16129 | ||
16130 | @item max-find-base-term-values | |
16131 | Maximum number of VALUEs handled during a single find_base_term call. | |
16132 | ||
16133 | @item analyzer-max-enodes-per-program-point | |
16134 | The maximum number of exploded nodes per program point within | |
16135 | the analyzer, before terminating analysis of that point. | |
16136 | ||
16137 | @item analyzer-max-constraints | |
16138 | The maximum number of constraints per state. | |
16139 | ||
16140 | @item analyzer-min-snodes-for-call-summary | |
16141 | The minimum number of supernodes within a function for the | |
16142 | analyzer to consider summarizing its effects at call sites. | |
16143 | ||
16144 | @item analyzer-max-enodes-for-full-dump | |
16145 | The maximum depth of exploded nodes that should appear in a dot dump | |
16146 | before switching to a less verbose format. | |
16147 | ||
16148 | @item analyzer-max-recursion-depth | |
16149 | The maximum number of times a callsite can appear in a call stack | |
16150 | within the analyzer, before terminating analysis of a call that would | |
16151 | recurse deeper. | |
16152 | ||
16153 | @item analyzer-max-svalue-depth | |
16154 | The maximum depth of a symbolic value, before approximating | |
16155 | the value as unknown. | |
16156 | ||
16157 | @item analyzer-max-infeasible-edges | |
16158 | The maximum number of infeasible edges to reject before declaring | |
16159 | a diagnostic as infeasible. | |
16160 | ||
16161 | @item gimple-fe-computed-hot-bb-threshold | |
16162 | The number of executions of a basic block which is considered hot. | |
16163 | The parameter is used only in GIMPLE FE. | |
16164 | ||
16165 | @item analyzer-bb-explosion-factor | |
16166 | The maximum number of 'after supernode' exploded nodes within the analyzer | |
16167 | per supernode, before terminating analysis. | |
16168 | ||
16169 | @item ranger-logical-depth | |
16170 | Maximum depth of logical expression evaluation ranger will look through | |
16171 | when evaluating outgoing edge ranges. | |
16172 | ||
16173 | @item relation-block-limit | |
16174 | Maximum number of relations the oracle will register in a basic block. | |
16175 | ||
16176 | @item min-pagesize | |
16177 | Minimum page size for warning purposes. | |
16178 | ||
16179 | @item openacc-kernels | |
16180 | Specify mode of OpenACC `kernels' constructs handling. | |
16181 | With @option{--param=openacc-kernels=decompose}, OpenACC `kernels' | |
16182 | constructs are decomposed into parts, a sequence of compute | |
16183 | constructs, each then handled individually. | |
16184 | This is work in progress. | |
16185 | With @option{--param=openacc-kernels=parloops}, OpenACC `kernels' | |
16186 | constructs are handled by the @samp{parloops} pass, en bloc. | |
16187 | This is the current default. | |
16188 | ||
16189 | @item openacc-privatization | |
4ace81b6 SL |
16190 | Control whether the @option{-fopt-info-omp-note} and applicable |
16191 | @option{-fdump-tree-*-details} options emit OpenACC privatization diagnostics. | |
d77de738 ML |
16192 | With @option{--param=openacc-privatization=quiet}, don't diagnose. |
16193 | This is the current default. | |
16194 | With @option{--param=openacc-privatization=noisy}, do diagnose. | |
16195 | ||
16196 | @end table | |
16197 | ||
16198 | The following choices of @var{name} are available on AArch64 targets: | |
16199 | ||
16200 | @table @gcctabopt | |
16201 | @item aarch64-sve-compare-costs | |
16202 | When vectorizing for SVE, consider using ``unpacked'' vectors for | |
16203 | smaller elements and use the cost model to pick the cheapest approach. | |
16204 | Also use the cost model to choose between SVE and Advanced SIMD vectorization. | |
16205 | ||
16206 | Using unpacked vectors includes storing smaller elements in larger | |
16207 | containers and accessing elements with extending loads and truncating | |
16208 | stores. | |
16209 | ||
16210 | @item aarch64-float-recp-precision | |
16211 | The number of Newton iterations for calculating the reciprocal for float type. | |
16212 | The precision of division is proportional to this param when division | |
16213 | approximation is enabled. The default value is 1. | |
16214 | ||
16215 | @item aarch64-double-recp-precision | |
16216 | The number of Newton iterations for calculating the reciprocal for double type. | |
16217 | The precision of division is propotional to this param when division | |
16218 | approximation is enabled. The default value is 2. | |
16219 | ||
16220 | @item aarch64-autovec-preference | |
16221 | Force an ISA selection strategy for auto-vectorization. Accepts values from | |
16222 | 0 to 4, inclusive. | |
16223 | @table @samp | |
16224 | @item 0 | |
16225 | Use the default heuristics. | |
16226 | @item 1 | |
16227 | Use only Advanced SIMD for auto-vectorization. | |
16228 | @item 2 | |
16229 | Use only SVE for auto-vectorization. | |
16230 | @item 3 | |
16231 | Use both Advanced SIMD and SVE. Prefer Advanced SIMD when the costs are | |
16232 | deemed equal. | |
16233 | @item 4 | |
16234 | Use both Advanced SIMD and SVE. Prefer SVE when the costs are deemed equal. | |
16235 | @end table | |
16236 | The default value is 0. | |
16237 | ||
16238 | @item aarch64-loop-vect-issue-rate-niters | |
16239 | The tuning for some AArch64 CPUs tries to take both latencies and issue | |
16240 | rates into account when deciding whether a loop should be vectorized | |
16241 | using SVE, vectorized using Advanced SIMD, or not vectorized at all. | |
16242 | If this parameter is set to @var{n}, GCC will not use this heuristic | |
16243 | for loops that are known to execute in fewer than @var{n} Advanced | |
16244 | SIMD iterations. | |
16245 | ||
16246 | @item aarch64-vect-unroll-limit | |
16247 | The vectorizer will use available tuning information to determine whether it | |
16248 | would be beneficial to unroll the main vectorized loop and by how much. This | |
16249 | parameter set's the upper bound of how much the vectorizer will unroll the main | |
16250 | loop. The default value is four. | |
16251 | ||
16252 | @end table | |
16253 | ||
16254 | The following choices of @var{name} are available on i386 and x86_64 targets: | |
16255 | ||
16256 | @table @gcctabopt | |
16257 | @item x86-stlf-window-ninsns | |
16258 | Instructions number above which STFL stall penalty can be compensated. | |
16259 | ||
60101899 RB |
16260 | @item x86-stv-max-visits |
16261 | The maximum number of use and def visits when discovering a STV chain before | |
16262 | the discovery is aborted. | |
16263 | ||
d77de738 ML |
16264 | @end table |
16265 | ||
16266 | @end table | |
16267 | ||
16268 | @node Instrumentation Options | |
16269 | @section Program Instrumentation Options | |
16270 | @cindex instrumentation options | |
16271 | @cindex program instrumentation options | |
16272 | @cindex run-time error checking options | |
16273 | @cindex profiling options | |
16274 | @cindex options, program instrumentation | |
16275 | @cindex options, run-time error checking | |
16276 | @cindex options, profiling | |
16277 | ||
16278 | GCC supports a number of command-line options that control adding | |
16279 | run-time instrumentation to the code it normally generates. | |
16280 | For example, one purpose of instrumentation is collect profiling | |
16281 | statistics for use in finding program hot spots, code coverage | |
16282 | analysis, or profile-guided optimizations. | |
16283 | Another class of program instrumentation is adding run-time checking | |
16284 | to detect programming errors like invalid pointer | |
16285 | dereferences or out-of-bounds array accesses, as well as deliberately | |
16286 | hostile attacks such as stack smashing or C++ vtable hijacking. | |
16287 | There is also a general hook which can be used to implement other | |
16288 | forms of tracing or function-level instrumentation for debug or | |
16289 | program analysis purposes. | |
16290 | ||
16291 | @table @gcctabopt | |
16292 | @cindex @command{prof} | |
16293 | @cindex @command{gprof} | |
d77de738 ML |
16294 | @opindex p |
16295 | @opindex pg | |
ddf6fe37 AA |
16296 | @item -p |
16297 | @itemx -pg | |
d77de738 ML |
16298 | Generate extra code to write profile information suitable for the |
16299 | analysis program @command{prof} (for @option{-p}) or @command{gprof} | |
16300 | (for @option{-pg}). You must use this option when compiling | |
16301 | the source files you want data about, and you must also use it when | |
16302 | linking. | |
16303 | ||
16304 | You can use the function attribute @code{no_instrument_function} to | |
16305 | suppress profiling of individual functions when compiling with these options. | |
16306 | @xref{Common Function Attributes}. | |
16307 | ||
d77de738 | 16308 | @opindex fprofile-arcs |
ddf6fe37 | 16309 | @item -fprofile-arcs |
d77de738 ML |
16310 | Add code so that program flow @dfn{arcs} are instrumented. During |
16311 | execution the program records how many times each branch and call is | |
16312 | executed and how many times it is taken or returns. On targets that support | |
16313 | constructors with priority support, profiling properly handles constructors, | |
16314 | destructors and C++ constructors (and destructors) of classes which are used | |
16315 | as a type of a global variable. | |
16316 | ||
16317 | When the compiled | |
16318 | program exits it saves this data to a file called | |
16319 | @file{@var{auxname}.gcda} for each source file. The data may be used for | |
16320 | profile-directed optimizations (@option{-fbranch-probabilities}), or for | |
16321 | test coverage analysis (@option{-ftest-coverage}). Each object file's | |
16322 | @var{auxname} is generated from the name of the output file, if | |
16323 | explicitly specified and it is not the final executable, otherwise it is | |
16324 | the basename of the source file. In both cases any suffix is removed | |
16325 | (e.g.@: @file{foo.gcda} for input file @file{dir/foo.c}, or | |
16326 | @file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}). | |
16327 | ||
16328 | Note that if a command line directly links source files, the corresponding | |
16329 | @var{.gcda} files will be prefixed with the unsuffixed name of the output file. | |
16330 | E.g. @code{gcc a.c b.c -o binary} would generate @file{binary-a.gcda} and | |
16331 | @file{binary-b.gcda} files. | |
16332 | ||
16333 | @xref{Cross-profiling}. | |
16334 | ||
16335 | @cindex @command{gcov} | |
d77de738 | 16336 | @opindex coverage |
ddf6fe37 | 16337 | @item --coverage |
d77de738 ML |
16338 | |
16339 | This option is used to compile and link code instrumented for coverage | |
16340 | analysis. The option is a synonym for @option{-fprofile-arcs} | |
16341 | @option{-ftest-coverage} (when compiling) and @option{-lgcov} (when | |
16342 | linking). See the documentation for those options for more details. | |
16343 | ||
16344 | @itemize | |
16345 | ||
16346 | @item | |
16347 | Compile the source files with @option{-fprofile-arcs} plus optimization | |
16348 | and code generation options. For test coverage analysis, use the | |
16349 | additional @option{-ftest-coverage} option. You do not need to profile | |
16350 | every source file in a program. | |
16351 | ||
16352 | @item | |
16353 | Compile the source files additionally with @option{-fprofile-abs-path} | |
16354 | to create absolute path names in the @file{.gcno} files. This allows | |
16355 | @command{gcov} to find the correct sources in projects where compilations | |
16356 | occur with different working directories. | |
16357 | ||
16358 | @item | |
16359 | Link your object files with @option{-lgcov} or @option{-fprofile-arcs} | |
16360 | (the latter implies the former). | |
16361 | ||
16362 | @item | |
16363 | Run the program on a representative workload to generate the arc profile | |
16364 | information. This may be repeated any number of times. You can run | |
16365 | concurrent instances of your program, and provided that the file system | |
16366 | supports locking, the data files will be correctly updated. Unless | |
16367 | a strict ISO C dialect option is in effect, @code{fork} calls are | |
16368 | detected and correctly handled without double counting. | |
16369 | ||
16370 | Moreover, an object file can be recompiled multiple times | |
16371 | and the corresponding @file{.gcda} file merges as long as | |
16372 | the source file and the compiler options are unchanged. | |
16373 | ||
16374 | @item | |
16375 | For profile-directed optimizations, compile the source files again with | |
16376 | the same optimization and code generation options plus | |
16377 | @option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that | |
16378 | Control Optimization}). | |
16379 | ||
16380 | @item | |
16381 | For test coverage analysis, use @command{gcov} to produce human readable | |
16382 | information from the @file{.gcno} and @file{.gcda} files. Refer to the | |
16383 | @command{gcov} documentation for further information. | |
16384 | ||
16385 | @end itemize | |
16386 | ||
16387 | With @option{-fprofile-arcs}, for each function of your program GCC | |
16388 | creates a program flow graph, then finds a spanning tree for the graph. | |
16389 | Only arcs that are not on the spanning tree have to be instrumented: the | |
16390 | compiler adds code to count the number of times that these arcs are | |
16391 | executed. When an arc is the only exit or only entrance to a block, the | |
16392 | instrumentation code can be added to the block; otherwise, a new basic | |
16393 | block must be created to hold the instrumentation code. | |
16394 | ||
16395 | @need 2000 | |
d77de738 | 16396 | @opindex ftest-coverage |
ddf6fe37 | 16397 | @item -ftest-coverage |
d77de738 ML |
16398 | Produce a notes file that the @command{gcov} code-coverage utility |
16399 | (@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to | |
16400 | show program coverage. Each source file's note file is called | |
16401 | @file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option | |
16402 | above for a description of @var{auxname} and instructions on how to | |
16403 | generate test coverage data. Coverage data matches the source files | |
16404 | more closely if you do not optimize. | |
16405 | ||
d77de738 | 16406 | @opindex fprofile-abs-path |
ddf6fe37 | 16407 | @item -fprofile-abs-path |
d77de738 ML |
16408 | Automatically convert relative source file names to absolute path names |
16409 | in the @file{.gcno} files. This allows @command{gcov} to find the correct | |
16410 | sources in projects where compilations occur with different working | |
16411 | directories. | |
16412 | ||
d77de738 | 16413 | @opindex fprofile-dir |
ddf6fe37 | 16414 | @item -fprofile-dir=@var{path} |
d77de738 ML |
16415 | |
16416 | Set the directory to search for the profile data files in to @var{path}. | |
16417 | This option affects only the profile data generated by | |
16418 | @option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs} | |
16419 | and used by @option{-fprofile-use} and @option{-fbranch-probabilities} | |
16420 | and its related options. Both absolute and relative paths can be used. | |
16421 | By default, GCC uses the current directory as @var{path}, thus the | |
16422 | profile data file appears in the same directory as the object file. | |
16423 | In order to prevent the file name clashing, if the object file name is | |
16424 | not an absolute path, we mangle the absolute path of the | |
16425 | @file{@var{sourcename}.gcda} file and use it as the file name of a | |
16426 | @file{.gcda} file. See details about the file naming in @option{-fprofile-arcs}. | |
16427 | See similar option @option{-fprofile-note}. | |
16428 | ||
16429 | When an executable is run in a massive parallel environment, it is recommended | |
16430 | to save profile to different folders. That can be done with variables | |
16431 | in @var{path} that are exported during run-time: | |
16432 | ||
16433 | @table @gcctabopt | |
16434 | ||
16435 | @item %p | |
16436 | process ID. | |
16437 | ||
16438 | @item %q@{VAR@} | |
16439 | value of environment variable @var{VAR} | |
16440 | ||
16441 | @end table | |
16442 | ||
ddf6fe37 | 16443 | @opindex fprofile-generate |
d77de738 ML |
16444 | @item -fprofile-generate |
16445 | @itemx -fprofile-generate=@var{path} | |
d77de738 ML |
16446 | |
16447 | Enable options usually used for instrumenting application to produce | |
16448 | profile useful for later recompilation with profile feedback based | |
16449 | optimization. You must use @option{-fprofile-generate} both when | |
16450 | compiling and when linking your program. | |
16451 | ||
16452 | The following options are enabled: | |
16453 | @option{-fprofile-arcs}, @option{-fprofile-values}, | |
16454 | @option{-finline-functions}, and @option{-fipa-bit-cp}. | |
16455 | ||
16456 | If @var{path} is specified, GCC looks at the @var{path} to find | |
16457 | the profile feedback data files. See @option{-fprofile-dir}. | |
16458 | ||
16459 | To optimize the program based on the collected profile information, use | |
16460 | @option{-fprofile-use}. @xref{Optimize Options}, for more information. | |
16461 | ||
ddf6fe37 | 16462 | @opindex fprofile-info-section |
d77de738 ML |
16463 | @item -fprofile-info-section |
16464 | @itemx -fprofile-info-section=@var{name} | |
d77de738 ML |
16465 | |
16466 | Register the profile information in the specified section instead of using a | |
16467 | constructor/destructor. The section name is @var{name} if it is specified, | |
16468 | otherwise the section name defaults to @code{.gcov_info}. A pointer to the | |
16469 | profile information generated by @option{-fprofile-arcs} is placed in the | |
16470 | specified section for each translation unit. This option disables the profile | |
16471 | information registration through a constructor and it disables the profile | |
16472 | information processing through a destructor. This option is not intended to be | |
16473 | used in hosted environments such as GNU/Linux. It targets freestanding | |
16474 | environments (for example embedded systems) with limited resources which do not | |
16475 | support constructors/destructors or the C library file I/O. | |
16476 | ||
16477 | The linker could collect the input sections in a continuous memory block and | |
16478 | define start and end symbols. A GNU linker script example which defines a | |
16479 | linker output section follows: | |
16480 | ||
16481 | @smallexample | |
16482 | .gcov_info : | |
16483 | @{ | |
16484 | PROVIDE (__gcov_info_start = .); | |
16485 | KEEP (*(.gcov_info)) | |
16486 | PROVIDE (__gcov_info_end = .); | |
16487 | @} | |
16488 | @end smallexample | |
16489 | ||
16490 | The program could dump the profiling information registered in this linker set | |
16491 | for example like this: | |
16492 | ||
16493 | @smallexample | |
16494 | #include <gcov.h> | |
16495 | #include <stdio.h> | |
16496 | #include <stdlib.h> | |
16497 | ||
16498 | extern const struct gcov_info *const __gcov_info_start[]; | |
16499 | extern const struct gcov_info *const __gcov_info_end[]; | |
16500 | ||
16501 | static void | |
16502 | dump (const void *d, unsigned n, void *arg) | |
16503 | @{ | |
16504 | const unsigned char *c = d; | |
16505 | ||
16506 | for (unsigned i = 0; i < n; ++i) | |
16507 | printf ("%02x", c[i]); | |
16508 | @} | |
16509 | ||
16510 | static void | |
16511 | filename (const char *f, void *arg) | |
16512 | @{ | |
16513 | __gcov_filename_to_gcfn (f, dump, arg ); | |
16514 | @} | |
16515 | ||
16516 | static void * | |
16517 | allocate (unsigned length, void *arg) | |
16518 | @{ | |
16519 | return malloc (length); | |
16520 | @} | |
16521 | ||
16522 | static void | |
16523 | dump_gcov_info (void) | |
16524 | @{ | |
16525 | const struct gcov_info *const *info = __gcov_info_start; | |
16526 | const struct gcov_info *const *end = __gcov_info_end; | |
16527 | ||
16528 | /* Obfuscate variable to prevent compiler optimizations. */ | |
16529 | __asm__ ("" : "+r" (info)); | |
16530 | ||
16531 | while (info != end) | |
16532 | @{ | |
16533 | void *arg = NULL; | |
16534 | __gcov_info_to_gcda (*info, filename, dump, allocate, arg); | |
16535 | putchar ('\n'); | |
16536 | ++info; | |
16537 | @} | |
16538 | @} | |
16539 | ||
16540 | int | |
16541 | main (void) | |
16542 | @{ | |
16543 | dump_gcov_info (); | |
16544 | return 0; | |
16545 | @} | |
16546 | @end smallexample | |
16547 | ||
16548 | The @command{merge-stream} subcommand of @command{gcov-tool} may be used to | |
16549 | deserialize the data stream generated by the @code{__gcov_filename_to_gcfn} and | |
16550 | @code{__gcov_info_to_gcda} functions and merge the profile information into | |
16551 | @file{.gcda} files on the host filesystem. | |
16552 | ||
d77de738 | 16553 | @opindex fprofile-note |
ddf6fe37 | 16554 | @item -fprofile-note=@var{path} |
d77de738 ML |
16555 | |
16556 | If @var{path} is specified, GCC saves @file{.gcno} file into @var{path} | |
16557 | location. If you combine the option with multiple source files, | |
16558 | the @file{.gcno} file will be overwritten. | |
16559 | ||
d77de738 | 16560 | @opindex fprofile-prefix-path |
ddf6fe37 | 16561 | @item -fprofile-prefix-path=@var{path} |
d77de738 ML |
16562 | |
16563 | This option can be used in combination with | |
16564 | @option{profile-generate=}@var{profile_dir} and | |
16565 | @option{profile-use=}@var{profile_dir} to inform GCC where is the base | |
16566 | directory of built source tree. By default @var{profile_dir} will contain | |
16567 | files with mangled absolute paths of all object files in the built project. | |
16568 | This is not desirable when directory used to build the instrumented binary | |
16569 | differs from the directory used to build the binary optimized with profile | |
16570 | feedback because the profile data will not be found during the optimized build. | |
16571 | In such setups @option{-fprofile-prefix-path=}@var{path} with @var{path} | |
16572 | pointing to the base directory of the build can be used to strip the irrelevant | |
16573 | part of the path and keep all file names relative to the main build directory. | |
16574 | ||
d77de738 | 16575 | @opindex fprofile-prefix-map |
ddf6fe37 | 16576 | @item -fprofile-prefix-map=@var{old}=@var{new} |
d77de738 ML |
16577 | When compiling files residing in directory @file{@var{old}}, record |
16578 | profiling information (with @option{--coverage}) | |
16579 | describing them as if the files resided in | |
16580 | directory @file{@var{new}} instead. | |
2eb0191a | 16581 | See also @option{-ffile-prefix-map} and @option{-fcanon-prefix-map}. |
d77de738 | 16582 | |
d77de738 | 16583 | @opindex fprofile-update |
ddf6fe37 | 16584 | @item -fprofile-update=@var{method} |
d77de738 ML |
16585 | |
16586 | Alter the update method for an application instrumented for profile | |
16587 | feedback based optimization. The @var{method} argument should be one of | |
16588 | @samp{single}, @samp{atomic} or @samp{prefer-atomic}. | |
16589 | The first one is useful for single-threaded applications, | |
16590 | while the second one prevents profile corruption by emitting thread-safe code. | |
16591 | ||
16592 | @strong{Warning:} When an application does not properly join all threads | |
16593 | (or creates an detached thread), a profile file can be still corrupted. | |
16594 | ||
16595 | Using @samp{prefer-atomic} would be transformed either to @samp{atomic}, | |
16596 | when supported by a target, or to @samp{single} otherwise. The GCC driver | |
16597 | automatically selects @samp{prefer-atomic} when @option{-pthread} | |
16598 | is present in the command line. | |
16599 | ||
d77de738 | 16600 | @opindex fprofile-filter-files |
ddf6fe37 | 16601 | @item -fprofile-filter-files=@var{regex} |
d77de738 ML |
16602 | |
16603 | Instrument only functions from files whose name matches | |
16604 | any of the regular expressions (separated by semi-colons). | |
16605 | ||
16606 | For example, @option{-fprofile-filter-files=main\.c;module.*\.c} will instrument | |
16607 | only @file{main.c} and all C files starting with 'module'. | |
16608 | ||
d77de738 | 16609 | @opindex fprofile-exclude-files |
ddf6fe37 | 16610 | @item -fprofile-exclude-files=@var{regex} |
d77de738 ML |
16611 | |
16612 | Instrument only functions from files whose name does not match | |
16613 | any of the regular expressions (separated by semi-colons). | |
16614 | ||
16615 | For example, @option{-fprofile-exclude-files=/usr/.*} will prevent instrumentation | |
16616 | of all files that are located in the @file{/usr/} folder. | |
16617 | ||
d77de738 | 16618 | @opindex fprofile-reproducible |
ddf6fe37 | 16619 | @item -fprofile-reproducible=@r{[}multithreaded@r{|}parallel-runs@r{|}serial@r{]} |
d77de738 ML |
16620 | Control level of reproducibility of profile gathered by |
16621 | @code{-fprofile-generate}. This makes it possible to rebuild program | |
16622 | with same outcome which is useful, for example, for distribution | |
16623 | packages. | |
16624 | ||
16625 | With @option{-fprofile-reproducible=serial} the profile gathered by | |
16626 | @option{-fprofile-generate} is reproducible provided the trained program | |
16627 | behaves the same at each invocation of the train run, it is not | |
16628 | multi-threaded and profile data streaming is always done in the same | |
16629 | order. Note that profile streaming happens at the end of program run but | |
16630 | also before @code{fork} function is invoked. | |
16631 | ||
16632 | Note that it is quite common that execution counts of some part of | |
16633 | programs depends, for example, on length of temporary file names or | |
16634 | memory space randomization (that may affect hash-table collision rate). | |
16635 | Such non-reproducible part of programs may be annotated by | |
16636 | @code{no_instrument_function} function attribute. @command{gcov-dump} with | |
16637 | @option{-l} can be used to dump gathered data and verify that they are | |
16638 | indeed reproducible. | |
16639 | ||
16640 | With @option{-fprofile-reproducible=parallel-runs} collected profile | |
16641 | stays reproducible regardless the order of streaming of the data into | |
16642 | gcda files. This setting makes it possible to run multiple instances of | |
16643 | instrumented program in parallel (such as with @code{make -j}). This | |
16644 | reduces quality of gathered data, in particular of indirect call | |
16645 | profiling. | |
16646 | ||
d77de738 | 16647 | @opindex fsanitize=address |
ddf6fe37 | 16648 | @item -fsanitize=address |
d77de738 ML |
16649 | Enable AddressSanitizer, a fast memory error detector. |
16650 | Memory access instructions are instrumented to detect | |
16651 | out-of-bounds and use-after-free bugs. | |
16652 | The option enables @option{-fsanitize-address-use-after-scope}. | |
16653 | See @uref{https://github.com/google/sanitizers/wiki/AddressSanitizer} for | |
16654 | more details. The run-time behavior can be influenced using the | |
16655 | @env{ASAN_OPTIONS} environment variable. When set to @code{help=1}, | |
16656 | the available options are shown at startup of the instrumented program. See | |
16657 | @url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags} | |
16658 | for a list of supported options. | |
16659 | The option cannot be combined with @option{-fsanitize=thread} or | |
16660 | @option{-fsanitize=hwaddress}. Note that the only target | |
16661 | @option{-fsanitize=hwaddress} is currently supported on is AArch64. | |
16662 | ||
6a07798c MP |
16663 | To get more accurate stack traces, it is possible to use options such as |
16664 | @option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent | |
16665 | most function inlining), @option{-fno-optimize-sibling-calls} (which prevents | |
16666 | optimizing sibling and tail recursive calls; this option is implicit for | |
16667 | @option{-O0}, @option{-O1}, or @option{-Og}), or @option{-fno-ipa-icf} (which | |
16668 | disables Identical Code Folding for functions). Since multiple runs of the | |
16669 | program may yield backtraces with different addresses due to ASLR (Address | |
16670 | Space Layout Randomization), it may be desirable to turn ASLR off. On Linux, | |
16671 | this can be achieved with @samp{setarch `uname -m` -R ./prog}. | |
16672 | ||
d77de738 | 16673 | @opindex fsanitize=kernel-address |
f33d7a88 | 16674 | @item -fsanitize=kernel-address |
d77de738 | 16675 | Enable AddressSanitizer for Linux kernel. |
a0bf71be | 16676 | See @uref{https://github.com/google/kernel-sanitizers} for more details. |
d77de738 | 16677 | |
d77de738 | 16678 | @opindex fsanitize=hwaddress |
f33d7a88 | 16679 | @item -fsanitize=hwaddress |
d77de738 ML |
16680 | Enable Hardware-assisted AddressSanitizer, which uses a hardware ability to |
16681 | ignore the top byte of a pointer to allow the detection of memory errors with | |
16682 | a low memory overhead. | |
16683 | Memory access instructions are instrumented to detect out-of-bounds and | |
16684 | use-after-free bugs. | |
16685 | The option enables @option{-fsanitize-address-use-after-scope}. | |
16686 | See | |
16687 | @uref{https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html} | |
16688 | for more details. The run-time behavior can be influenced using the | |
16689 | @env{HWASAN_OPTIONS} environment variable. When set to @code{help=1}, | |
16690 | the available options are shown at startup of the instrumented program. | |
16691 | The option cannot be combined with @option{-fsanitize=thread} or | |
16692 | @option{-fsanitize=address}, and is currently only available on AArch64. | |
16693 | ||
d77de738 | 16694 | @opindex fsanitize=kernel-hwaddress |
ddf6fe37 | 16695 | @item -fsanitize=kernel-hwaddress |
d77de738 ML |
16696 | Enable Hardware-assisted AddressSanitizer for compilation of the Linux kernel. |
16697 | Similar to @option{-fsanitize=kernel-address} but using an alternate | |
16698 | instrumentation method, and similar to @option{-fsanitize=hwaddress} but with | |
16699 | instrumentation differences necessary for compiling the Linux kernel. | |
16700 | These differences are to avoid hwasan library initialization calls and to | |
16701 | account for the stack pointer having a different value in its top byte. | |
16702 | ||
16703 | @emph{Note:} This option has different defaults to the @option{-fsanitize=hwaddress}. | |
16704 | Instrumenting the stack and alloca calls are not on by default but are still | |
16705 | possible by specifying the command-line options | |
16706 | @option{--param hwasan-instrument-stack=1} and | |
16707 | @option{--param hwasan-instrument-allocas=1} respectively. Using a random frame | |
16708 | tag is not implemented for kernel instrumentation. | |
16709 | ||
d77de738 | 16710 | @opindex fsanitize=pointer-compare |
ddf6fe37 | 16711 | @item -fsanitize=pointer-compare |
d77de738 ML |
16712 | Instrument comparison operation (<, <=, >, >=) with pointer operands. |
16713 | The option must be combined with either @option{-fsanitize=kernel-address} or | |
16714 | @option{-fsanitize=address} | |
16715 | The option cannot be combined with @option{-fsanitize=thread}. | |
16716 | Note: By default the check is disabled at run time. To enable it, | |
16717 | add @code{detect_invalid_pointer_pairs=2} to the environment variable | |
16718 | @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects | |
16719 | invalid operation only when both pointers are non-null. | |
16720 | ||
d77de738 | 16721 | @opindex fsanitize=pointer-subtract |
ddf6fe37 | 16722 | @item -fsanitize=pointer-subtract |
d77de738 ML |
16723 | Instrument subtraction with pointer operands. |
16724 | The option must be combined with either @option{-fsanitize=kernel-address} or | |
16725 | @option{-fsanitize=address} | |
16726 | The option cannot be combined with @option{-fsanitize=thread}. | |
16727 | Note: By default the check is disabled at run time. To enable it, | |
16728 | add @code{detect_invalid_pointer_pairs=2} to the environment variable | |
16729 | @env{ASAN_OPTIONS}. Using @code{detect_invalid_pointer_pairs=1} detects | |
16730 | invalid operation only when both pointers are non-null. | |
16731 | ||
d77de738 | 16732 | @opindex fsanitize=shadow-call-stack |
ddf6fe37 | 16733 | @item -fsanitize=shadow-call-stack |
d77de738 ML |
16734 | Enable ShadowCallStack, a security enhancement mechanism used to protect |
16735 | programs against return address overwrites (e.g. stack buffer overflows.) | |
16736 | It works by saving a function's return address to a separately allocated | |
16737 | shadow call stack in the function prologue and restoring the return address | |
16738 | from the shadow call stack in the function epilogue. Instrumentation only | |
16739 | occurs in functions that need to save the return address to the stack. | |
16740 | ||
16741 | Currently it only supports the aarch64 platform. It is specifically | |
16742 | designed for linux kernels that enable the CONFIG_SHADOW_CALL_STACK option. | |
16743 | For the user space programs, runtime support is not currently provided | |
16744 | in libc and libgcc. Users who want to use this feature in user space need | |
16745 | to provide their own support for the runtime. It should be noted that | |
16746 | this may cause the ABI rules to be broken. | |
16747 | ||
16748 | On aarch64, the instrumentation makes use of the platform register @code{x18}. | |
16749 | This generally means that any code that may run on the same thread as code | |
16750 | compiled with ShadowCallStack must be compiled with the flag | |
16751 | @option{-ffixed-x18}, otherwise functions compiled without | |
16752 | @option{-ffixed-x18} might clobber @code{x18} and so corrupt the shadow | |
16753 | stack pointer. | |
16754 | ||
16755 | Also, because there is no userspace runtime support, code compiled with | |
16756 | ShadowCallStack cannot use exception handling. Use @option{-fno-exceptions} | |
16757 | to turn off exceptions. | |
16758 | ||
16759 | See @uref{https://clang.llvm.org/docs/ShadowCallStack.html} for more | |
16760 | details. | |
16761 | ||
d77de738 | 16762 | @opindex fsanitize=thread |
ddf6fe37 | 16763 | @item -fsanitize=thread |
d77de738 ML |
16764 | Enable ThreadSanitizer, a fast data race detector. |
16765 | Memory access instructions are instrumented to detect | |
16766 | data race bugs. See @uref{https://github.com/google/sanitizers/wiki#threadsanitizer} for more | |
16767 | details. The run-time behavior can be influenced using the @env{TSAN_OPTIONS} | |
16768 | environment variable; see | |
16769 | @url{https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags} for a list of | |
16770 | supported options. | |
16771 | The option cannot be combined with @option{-fsanitize=address}, | |
16772 | @option{-fsanitize=leak}. | |
16773 | ||
16774 | Note that sanitized atomic builtins cannot throw exceptions when | |
16775 | operating on invalid memory addresses with non-call exceptions | |
16776 | (@option{-fnon-call-exceptions}). | |
16777 | ||
d77de738 | 16778 | @opindex fsanitize=leak |
ddf6fe37 | 16779 | @item -fsanitize=leak |
d77de738 | 16780 | Enable LeakSanitizer, a memory leak detector. |
c5c4fdac JG |
16781 | This option only matters for linking of executables. |
16782 | The executable is linked against a library that overrides @code{malloc} | |
d77de738 ML |
16783 | and other allocator functions. See |
16784 | @uref{https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer} for more | |
16785 | details. The run-time behavior can be influenced using the | |
16786 | @env{LSAN_OPTIONS} environment variable. | |
16787 | The option cannot be combined with @option{-fsanitize=thread}. | |
16788 | ||
d77de738 | 16789 | @opindex fsanitize=undefined |
ddf6fe37 | 16790 | @item -fsanitize=undefined |
d77de738 ML |
16791 | Enable UndefinedBehaviorSanitizer, a fast undefined behavior detector. |
16792 | Various computations are instrumented to detect undefined behavior | |
16793 | at runtime. See @uref{https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html} for more details. The run-time behavior can be influenced using the | |
16794 | @env{UBSAN_OPTIONS} environment variable. Current suboptions are: | |
16795 | ||
16796 | @table @gcctabopt | |
16797 | ||
d77de738 | 16798 | @opindex fsanitize=shift |
ddf6fe37 | 16799 | @item -fsanitize=shift |
d77de738 ML |
16800 | This option enables checking that the result of a shift operation is |
16801 | not undefined. Note that what exactly is considered undefined differs | |
16802 | slightly between C and C++, as well as between ISO C90 and C99, etc. | |
16803 | This option has two suboptions, @option{-fsanitize=shift-base} and | |
16804 | @option{-fsanitize=shift-exponent}. | |
16805 | ||
d77de738 | 16806 | @opindex fsanitize=shift-exponent |
ddf6fe37 | 16807 | @item -fsanitize=shift-exponent |
d77de738 ML |
16808 | This option enables checking that the second argument of a shift operation |
16809 | is not negative and is smaller than the precision of the promoted first | |
16810 | argument. | |
16811 | ||
d77de738 | 16812 | @opindex fsanitize=shift-base |
ddf6fe37 | 16813 | @item -fsanitize=shift-base |
d77de738 ML |
16814 | If the second argument of a shift operation is within range, check that the |
16815 | result of a shift operation is not undefined. Note that what exactly is | |
16816 | considered undefined differs slightly between C and C++, as well as between | |
16817 | ISO C90 and C99, etc. | |
16818 | ||
d77de738 | 16819 | @opindex fsanitize=integer-divide-by-zero |
ddf6fe37 | 16820 | @item -fsanitize=integer-divide-by-zero |
d77de738 ML |
16821 | Detect integer division by zero. |
16822 | ||
d77de738 | 16823 | @opindex fsanitize=unreachable |
ddf6fe37 | 16824 | @item -fsanitize=unreachable |
d77de738 ML |
16825 | With this option, the compiler turns the @code{__builtin_unreachable} |
16826 | call into a diagnostics message call instead. When reaching the | |
16827 | @code{__builtin_unreachable} call, the behavior is undefined. | |
16828 | ||
d77de738 | 16829 | @opindex fsanitize=vla-bound |
ddf6fe37 | 16830 | @item -fsanitize=vla-bound |
d77de738 ML |
16831 | This option instructs the compiler to check that the size of a variable |
16832 | length array is positive. | |
16833 | ||
d77de738 | 16834 | @opindex fsanitize=null |
ddf6fe37 | 16835 | @item -fsanitize=null |
d77de738 ML |
16836 | This option enables pointer checking. Particularly, the application |
16837 | built with this option turned on will issue an error message when it | |
16838 | tries to dereference a NULL pointer, or if a reference (possibly an | |
16839 | rvalue reference) is bound to a NULL pointer, or if a method is invoked | |
16840 | on an object pointed by a NULL pointer. | |
16841 | ||
d77de738 | 16842 | @opindex fsanitize=return |
ddf6fe37 | 16843 | @item -fsanitize=return |
d77de738 ML |
16844 | This option enables return statement checking. Programs |
16845 | built with this option turned on will issue an error message | |
16846 | when the end of a non-void function is reached without actually | |
16847 | returning a value. This option works in C++ only. | |
16848 | ||
d77de738 | 16849 | @opindex fsanitize=signed-integer-overflow |
ddf6fe37 | 16850 | @item -fsanitize=signed-integer-overflow |
d77de738 ML |
16851 | This option enables signed integer overflow checking. We check that |
16852 | the result of @code{+}, @code{*}, and both unary and binary @code{-} | |
16853 | does not overflow in the signed arithmetics. This also detects | |
16854 | @code{INT_MIN / -1} signed division. Note, integer promotion | |
16855 | rules must be taken into account. That is, the following is not an | |
16856 | overflow: | |
16857 | @smallexample | |
16858 | signed char a = SCHAR_MAX; | |
16859 | a++; | |
16860 | @end smallexample | |
16861 | ||
d77de738 | 16862 | @opindex fsanitize=bounds |
ddf6fe37 | 16863 | @item -fsanitize=bounds |
d77de738 ML |
16864 | This option enables instrumentation of array bounds. Various out of bounds |
16865 | accesses are detected. Flexible array members, flexible array member-like | |
c7728805 JJ |
16866 | arrays, and initializers of variables with static storage are not |
16867 | instrumented, with the exception of flexible array member-like arrays | |
16868 | for which @code{-fstrict-flex-arrays} or @code{-fstrict-flex-arrays=} | |
16869 | options or @code{strict_flex_array} attributes say they shouldn't be treated | |
16870 | like flexible array member-like arrays. | |
d77de738 | 16871 | |
d77de738 | 16872 | @opindex fsanitize=bounds-strict |
ddf6fe37 | 16873 | @item -fsanitize=bounds-strict |
d77de738 | 16874 | This option enables strict instrumentation of array bounds. Most out of bounds |
c7728805 JJ |
16875 | accesses are detected, including flexible array member-like arrays. |
16876 | Initializers of variables with static storage are not instrumented. | |
d77de738 | 16877 | |
d77de738 | 16878 | @opindex fsanitize=alignment |
ddf6fe37 | 16879 | @item -fsanitize=alignment |
d77de738 ML |
16880 | |
16881 | This option enables checking of alignment of pointers when they are | |
16882 | dereferenced, or when a reference is bound to insufficiently aligned target, | |
16883 | or when a method or constructor is invoked on insufficiently aligned object. | |
16884 | ||
d77de738 | 16885 | @opindex fsanitize=object-size |
ddf6fe37 | 16886 | @item -fsanitize=object-size |
d77de738 | 16887 | This option enables instrumentation of memory references using the |
7283380a SP |
16888 | @code{__builtin_dynamic_object_size} function. Various out of bounds |
16889 | pointer accesses are detected. | |
d77de738 | 16890 | |
d77de738 | 16891 | @opindex fsanitize=float-divide-by-zero |
ddf6fe37 | 16892 | @item -fsanitize=float-divide-by-zero |
d77de738 ML |
16893 | Detect floating-point division by zero. Unlike other similar options, |
16894 | @option{-fsanitize=float-divide-by-zero} is not enabled by | |
16895 | @option{-fsanitize=undefined}, since floating-point division by zero can | |
16896 | be a legitimate way of obtaining infinities and NaNs. | |
16897 | ||
d77de738 | 16898 | @opindex fsanitize=float-cast-overflow |
ddf6fe37 | 16899 | @item -fsanitize=float-cast-overflow |
d77de738 ML |
16900 | This option enables floating-point type to integer conversion checking. |
16901 | We check that the result of the conversion does not overflow. | |
16902 | Unlike other similar options, @option{-fsanitize=float-cast-overflow} is | |
16903 | not enabled by @option{-fsanitize=undefined}. | |
16904 | This option does not work well with @code{FE_INVALID} exceptions enabled. | |
16905 | ||
d77de738 | 16906 | @opindex fsanitize=nonnull-attribute |
ddf6fe37 | 16907 | @item -fsanitize=nonnull-attribute |
d77de738 ML |
16908 | |
16909 | This option enables instrumentation of calls, checking whether null values | |
16910 | are not passed to arguments marked as requiring a non-null value by the | |
16911 | @code{nonnull} function attribute. | |
16912 | ||
d77de738 | 16913 | @opindex fsanitize=returns-nonnull-attribute |
ddf6fe37 | 16914 | @item -fsanitize=returns-nonnull-attribute |
d77de738 ML |
16915 | |
16916 | This option enables instrumentation of return statements in functions | |
16917 | marked with @code{returns_nonnull} function attribute, to detect returning | |
16918 | of null values from such functions. | |
16919 | ||
d77de738 | 16920 | @opindex fsanitize=bool |
ddf6fe37 | 16921 | @item -fsanitize=bool |
d77de738 ML |
16922 | |
16923 | This option enables instrumentation of loads from bool. If a value other | |
16924 | than 0/1 is loaded, a run-time error is issued. | |
16925 | ||
d77de738 | 16926 | @opindex fsanitize=enum |
ddf6fe37 | 16927 | @item -fsanitize=enum |
d77de738 ML |
16928 | |
16929 | This option enables instrumentation of loads from an enum type. If | |
16930 | a value outside the range of values for the enum type is loaded, | |
16931 | a run-time error is issued. | |
16932 | ||
d77de738 | 16933 | @opindex fsanitize=vptr |
ddf6fe37 | 16934 | @item -fsanitize=vptr |
d77de738 ML |
16935 | |
16936 | This option enables instrumentation of C++ member function calls, member | |
16937 | accesses and some conversions between pointers to base and derived classes, | |
16938 | to verify the referenced object has the correct dynamic type. | |
16939 | ||
d77de738 | 16940 | @opindex fsanitize=pointer-overflow |
ddf6fe37 | 16941 | @item -fsanitize=pointer-overflow |
d77de738 ML |
16942 | |
16943 | This option enables instrumentation of pointer arithmetics. If the pointer | |
16944 | arithmetics overflows, a run-time error is issued. | |
16945 | ||
d77de738 | 16946 | @opindex fsanitize=builtin |
ddf6fe37 | 16947 | @item -fsanitize=builtin |
d77de738 ML |
16948 | |
16949 | This option enables instrumentation of arguments to selected builtin | |
16950 | functions. If an invalid value is passed to such arguments, a run-time | |
16951 | error is issued. E.g.@ passing 0 as the argument to @code{__builtin_ctz} | |
16952 | or @code{__builtin_clz} invokes undefined behavior and is diagnosed | |
16953 | by this option. | |
16954 | ||
16955 | @end table | |
16956 | ||
16957 | Note that sanitizers tend to increase the rate of false positive | |
16958 | warnings, most notably those around @option{-Wmaybe-uninitialized}. | |
16959 | We recommend against combining @option{-Werror} and [the use of] | |
16960 | sanitizers. | |
16961 | ||
16962 | While @option{-ftrapv} causes traps for signed overflows to be emitted, | |
16963 | @option{-fsanitize=undefined} gives a diagnostic message. | |
16964 | This currently works only for the C family of languages. | |
16965 | ||
d77de738 | 16966 | @opindex fno-sanitize=all |
ddf6fe37 | 16967 | @item -fno-sanitize=all |
d77de738 ML |
16968 | |
16969 | This option disables all previously enabled sanitizers. | |
16970 | @option{-fsanitize=all} is not allowed, as some sanitizers cannot be used | |
16971 | together. | |
16972 | ||
d77de738 | 16973 | @opindex fasan-shadow-offset |
ddf6fe37 | 16974 | @item -fasan-shadow-offset=@var{number} |
d77de738 ML |
16975 | This option forces GCC to use custom shadow offset in AddressSanitizer checks. |
16976 | It is useful for experimenting with different shadow memory layouts in | |
16977 | Kernel AddressSanitizer. | |
16978 | ||
d77de738 | 16979 | @opindex fsanitize-sections |
ddf6fe37 | 16980 | @item -fsanitize-sections=@var{s1},@var{s2},... |
d77de738 ML |
16981 | Sanitize global variables in selected user-defined sections. @var{si} may |
16982 | contain wildcards. | |
16983 | ||
d77de738 ML |
16984 | @opindex fsanitize-recover |
16985 | @opindex fno-sanitize-recover | |
ddf6fe37 | 16986 | @item -fsanitize-recover@r{[}=@var{opts}@r{]} |
d77de738 ML |
16987 | @option{-fsanitize-recover=} controls error recovery mode for sanitizers |
16988 | mentioned in comma-separated list of @var{opts}. Enabling this option | |
16989 | for a sanitizer component causes it to attempt to continue | |
16990 | running the program as if no error happened. This means multiple | |
16991 | runtime errors can be reported in a single program run, and the exit | |
16992 | code of the program may indicate success even when errors | |
16993 | have been reported. The @option{-fno-sanitize-recover=} option | |
16994 | can be used to alter | |
16995 | this behavior: only the first detected error is reported | |
16996 | and program then exits with a non-zero exit code. | |
16997 | ||
16998 | Currently this feature only works for @option{-fsanitize=undefined} (and its suboptions | |
16999 | except for @option{-fsanitize=unreachable} and @option{-fsanitize=return}), | |
17000 | @option{-fsanitize=float-cast-overflow}, @option{-fsanitize=float-divide-by-zero}, | |
17001 | @option{-fsanitize=bounds-strict}, | |
17002 | @option{-fsanitize=kernel-address} and @option{-fsanitize=address}. | |
17003 | For these sanitizers error recovery is turned on by default, | |
17004 | except @option{-fsanitize=address}, for which this feature is experimental. | |
17005 | @option{-fsanitize-recover=all} and @option{-fno-sanitize-recover=all} is also | |
17006 | accepted, the former enables recovery for all sanitizers that support it, | |
17007 | the latter disables recovery for all sanitizers that support it. | |
17008 | ||
17009 | Even if a recovery mode is turned on the compiler side, it needs to be also | |
17010 | enabled on the runtime library side, otherwise the failures are still fatal. | |
17011 | The runtime library defaults to @code{halt_on_error=0} for | |
17012 | ThreadSanitizer and UndefinedBehaviorSanitizer, while default value for | |
17013 | AddressSanitizer is @code{halt_on_error=1}. This can be overridden through | |
17014 | setting the @code{halt_on_error} flag in the corresponding environment variable. | |
17015 | ||
17016 | Syntax without an explicit @var{opts} parameter is deprecated. It is | |
17017 | equivalent to specifying an @var{opts} list of: | |
17018 | ||
17019 | @smallexample | |
17020 | undefined,float-cast-overflow,float-divide-by-zero,bounds-strict | |
17021 | @end smallexample | |
17022 | ||
d77de738 | 17023 | @opindex fsanitize-address-use-after-scope |
ddf6fe37 | 17024 | @item -fsanitize-address-use-after-scope |
d77de738 ML |
17025 | Enable sanitization of local variables to detect use-after-scope bugs. |
17026 | The option sets @option{-fstack-reuse} to @samp{none}. | |
17027 | ||
d77de738 ML |
17028 | @opindex fsanitize-trap |
17029 | @opindex fno-sanitize-trap | |
ddf6fe37 | 17030 | @item -fsanitize-trap@r{[}=@var{opts}@r{]} |
d77de738 ML |
17031 | The @option{-fsanitize-trap=} option instructs the compiler to |
17032 | report for sanitizers mentioned in comma-separated list of @var{opts} | |
17033 | undefined behavior using @code{__builtin_trap} rather than a @code{libubsan} | |
17034 | library routine. If this option is enabled for certain sanitizer, | |
17035 | it takes precedence over the @option{-fsanitizer-recover=} for that | |
17036 | sanitizer, @code{__builtin_trap} will be emitted and be fatal regardless | |
17037 | of whether recovery is enabled or disabled using @option{-fsanitize-recover=}. | |
17038 | ||
17039 | The advantage of this is that the @code{libubsan} library is not needed | |
17040 | and is not linked in, so this is usable even in freestanding environments. | |
17041 | ||
17042 | Currently this feature works with @option{-fsanitize=undefined} (and its suboptions | |
17043 | except for @option{-fsanitize=vptr}), @option{-fsanitize=float-cast-overflow}, | |
17044 | @option{-fsanitize=float-divide-by-zero} and | |
17045 | @option{-fsanitize=bounds-strict}. @code{-fsanitize-trap=all} can be also | |
17046 | specified, which enables it for @code{undefined} suboptions, | |
17047 | @option{-fsanitize=float-cast-overflow}, | |
17048 | @option{-fsanitize=float-divide-by-zero} and | |
17049 | @option{-fsanitize=bounds-strict}. | |
17050 | If @code{-fsanitize-trap=undefined} or @code{-fsanitize-trap=all} is used | |
17051 | and @code{-fsanitize=vptr} is enabled on the command line, the | |
17052 | instrumentation is silently ignored as the instrumentation always needs | |
17053 | @code{libubsan} support, @option{-fsanitize-trap=vptr} is not allowed. | |
17054 | ||
d77de738 | 17055 | @opindex fsanitize-undefined-trap-on-error |
ddf6fe37 | 17056 | @item -fsanitize-undefined-trap-on-error |
d77de738 ML |
17057 | The @option{-fsanitize-undefined-trap-on-error} option is deprecated |
17058 | equivalent of @option{-fsanitize-trap=all}. | |
17059 | ||
d77de738 | 17060 | @opindex fsanitize-coverage=trace-pc |
ddf6fe37 | 17061 | @item -fsanitize-coverage=trace-pc |
d77de738 ML |
17062 | Enable coverage-guided fuzzing code instrumentation. |
17063 | Inserts a call to @code{__sanitizer_cov_trace_pc} into every basic block. | |
17064 | ||
d77de738 | 17065 | @opindex fsanitize-coverage=trace-cmp |
ddf6fe37 | 17066 | @item -fsanitize-coverage=trace-cmp |
d77de738 ML |
17067 | Enable dataflow guided fuzzing code instrumentation. |
17068 | Inserts a call to @code{__sanitizer_cov_trace_cmp1}, | |
17069 | @code{__sanitizer_cov_trace_cmp2}, @code{__sanitizer_cov_trace_cmp4} or | |
17070 | @code{__sanitizer_cov_trace_cmp8} for integral comparison with both operands | |
17071 | variable or @code{__sanitizer_cov_trace_const_cmp1}, | |
17072 | @code{__sanitizer_cov_trace_const_cmp2}, | |
17073 | @code{__sanitizer_cov_trace_const_cmp4} or | |
17074 | @code{__sanitizer_cov_trace_const_cmp8} for integral comparison with one | |
17075 | operand constant, @code{__sanitizer_cov_trace_cmpf} or | |
17076 | @code{__sanitizer_cov_trace_cmpd} for float or double comparisons and | |
17077 | @code{__sanitizer_cov_trace_switch} for switch statements. | |
17078 | ||
d77de738 | 17079 | @opindex fcf-protection |
ddf6fe37 | 17080 | @item -fcf-protection=@r{[}full@r{|}branch@r{|}return@r{|}none@r{|}check@r{]} |
d77de738 ML |
17081 | Enable code instrumentation of control-flow transfers to increase |
17082 | program security by checking that target addresses of control-flow | |
17083 | transfer instructions (such as indirect function call, function return, | |
17084 | indirect jump) are valid. This prevents diverting the flow of control | |
17085 | to an unexpected target. This is intended to protect against such | |
17086 | threats as Return-oriented Programming (ROP), and similarly | |
17087 | call/jmp-oriented programming (COP/JOP). | |
17088 | ||
17089 | The value @code{branch} tells the compiler to implement checking of | |
17090 | validity of control-flow transfer at the point of indirect branch | |
17091 | instructions, i.e.@: call/jmp instructions. The value @code{return} | |
17092 | implements checking of validity at the point of returning from a | |
17093 | function. The value @code{full} is an alias for specifying both | |
17094 | @code{branch} and @code{return}. The value @code{none} turns off | |
17095 | instrumentation. | |
17096 | ||
17097 | The value @code{check} is used for the final link with link-time | |
17098 | optimization (LTO). An error is issued if LTO object files are | |
17099 | compiled with different @option{-fcf-protection} values. The | |
17100 | value @code{check} is ignored at the compile time. | |
17101 | ||
17102 | The macro @code{__CET__} is defined when @option{-fcf-protection} is | |
17103 | used. The first bit of @code{__CET__} is set to 1 for the value | |
17104 | @code{branch} and the second bit of @code{__CET__} is set to 1 for | |
17105 | the @code{return}. | |
17106 | ||
17107 | You can also use the @code{nocf_check} attribute to identify | |
17108 | which functions and calls should be skipped from instrumentation | |
17109 | (@pxref{Function Attributes}). | |
17110 | ||
17111 | Currently the x86 GNU/Linux target provides an implementation based | |
17112 | on Intel Control-flow Enforcement Technology (CET) which works for | |
17113 | i686 processor or newer. | |
17114 | ||
d77de738 | 17115 | @opindex fharden-compares |
ddf6fe37 | 17116 | @item -fharden-compares |
d77de738 ML |
17117 | For every logical test that survives gimple optimizations and is |
17118 | @emph{not} the condition in a conditional branch (for example, | |
17119 | conditions tested for conditional moves, or to store in boolean | |
17120 | variables), emit extra code to compute and verify the reversed | |
17121 | condition, and to call @code{__builtin_trap} if the results do not | |
17122 | match. Use with @samp{-fharden-conditional-branches} to cover all | |
17123 | conditionals. | |
17124 | ||
d77de738 | 17125 | @opindex fharden-conditional-branches |
ddf6fe37 | 17126 | @item -fharden-conditional-branches |
d77de738 ML |
17127 | For every non-vectorized conditional branch that survives gimple |
17128 | optimizations, emit extra code to compute and verify the reversed | |
17129 | condition, and to call @code{__builtin_trap} if the result is | |
17130 | unexpected. Use with @samp{-fharden-compares} to cover all | |
17131 | conditionals. | |
17132 | ||
d77de738 | 17133 | @opindex fstack-protector |
ddf6fe37 | 17134 | @item -fstack-protector |
d77de738 ML |
17135 | Emit extra code to check for buffer overflows, such as stack smashing |
17136 | attacks. This is done by adding a guard variable to functions with | |
17137 | vulnerable objects. This includes functions that call @code{alloca}, and | |
17138 | functions with buffers larger than or equal to 8 bytes. The guards are | |
17139 | initialized when a function is entered and then checked when the function | |
17140 | exits. If a guard check fails, an error message is printed and the program | |
17141 | exits. Only variables that are actually allocated on the stack are | |
17142 | considered, optimized away variables or variables allocated in registers | |
17143 | don't count. | |
17144 | ||
d77de738 | 17145 | @opindex fstack-protector-all |
ddf6fe37 | 17146 | @item -fstack-protector-all |
d77de738 ML |
17147 | Like @option{-fstack-protector} except that all functions are protected. |
17148 | ||
d77de738 | 17149 | @opindex fstack-protector-strong |
ddf6fe37 | 17150 | @item -fstack-protector-strong |
d77de738 ML |
17151 | Like @option{-fstack-protector} but includes additional functions to |
17152 | be protected --- those that have local array definitions, or have | |
17153 | references to local frame addresses. Only variables that are actually | |
17154 | allocated on the stack are considered, optimized away variables or variables | |
17155 | allocated in registers don't count. | |
17156 | ||
d77de738 | 17157 | @opindex fstack-protector-explicit |
ddf6fe37 | 17158 | @item -fstack-protector-explicit |
d77de738 ML |
17159 | Like @option{-fstack-protector} but only protects those functions which |
17160 | have the @code{stack_protect} attribute. | |
17161 | ||
d77de738 | 17162 | @opindex fstack-check |
ddf6fe37 | 17163 | @item -fstack-check |
d77de738 ML |
17164 | Generate code to verify that you do not go beyond the boundary of the |
17165 | stack. You should specify this flag if you are running in an | |
17166 | environment with multiple threads, but you only rarely need to specify it in | |
17167 | a single-threaded environment since stack overflow is automatically | |
17168 | detected on nearly all systems if there is only one stack. | |
17169 | ||
17170 | Note that this switch does not actually cause checking to be done; the | |
17171 | operating system or the language runtime must do that. The switch causes | |
17172 | generation of code to ensure that they see the stack being extended. | |
17173 | ||
17174 | You can additionally specify a string parameter: @samp{no} means no | |
17175 | checking, @samp{generic} means force the use of old-style checking, | |
17176 | @samp{specific} means use the best checking method and is equivalent | |
17177 | to bare @option{-fstack-check}. | |
17178 | ||
17179 | Old-style checking is a generic mechanism that requires no specific | |
17180 | target support in the compiler but comes with the following drawbacks: | |
17181 | ||
17182 | @enumerate | |
17183 | @item | |
17184 | Modified allocation strategy for large objects: they are always | |
17185 | allocated dynamically if their size exceeds a fixed threshold. Note this | |
17186 | may change the semantics of some code. | |
17187 | ||
17188 | @item | |
17189 | Fixed limit on the size of the static frame of functions: when it is | |
17190 | topped by a particular function, stack checking is not reliable and | |
17191 | a warning is issued by the compiler. | |
17192 | ||
17193 | @item | |
17194 | Inefficiency: because of both the modified allocation strategy and the | |
17195 | generic implementation, code performance is hampered. | |
17196 | @end enumerate | |
17197 | ||
17198 | Note that old-style stack checking is also the fallback method for | |
17199 | @samp{specific} if no target support has been added in the compiler. | |
17200 | ||
17201 | @samp{-fstack-check=} is designed for Ada's needs to detect infinite recursion | |
17202 | and stack overflows. @samp{specific} is an excellent choice when compiling | |
17203 | Ada code. It is not generally sufficient to protect against stack-clash | |
17204 | attacks. To protect against those you want @samp{-fstack-clash-protection}. | |
17205 | ||
d77de738 | 17206 | @opindex fstack-clash-protection |
ddf6fe37 | 17207 | @item -fstack-clash-protection |
d77de738 ML |
17208 | Generate code to prevent stack clash style attacks. When this option is |
17209 | enabled, the compiler will only allocate one page of stack space at a time | |
17210 | and each page is accessed immediately after allocation. Thus, it prevents | |
17211 | allocations from jumping over any stack guard page provided by the | |
17212 | operating system. | |
17213 | ||
17214 | Most targets do not fully support stack clash protection. However, on | |
17215 | those targets @option{-fstack-clash-protection} will protect dynamic stack | |
17216 | allocations. @option{-fstack-clash-protection} may also provide limited | |
17217 | protection for static stack allocations if the target supports | |
17218 | @option{-fstack-check=specific}. | |
17219 | ||
d77de738 ML |
17220 | @opindex fstack-limit-register |
17221 | @opindex fstack-limit-symbol | |
17222 | @opindex fno-stack-limit | |
ddf6fe37 AA |
17223 | @item -fstack-limit-register=@var{reg} |
17224 | @itemx -fstack-limit-symbol=@var{sym} | |
17225 | @itemx -fno-stack-limit | |
d77de738 ML |
17226 | Generate code to ensure that the stack does not grow beyond a certain value, |
17227 | either the value of a register or the address of a symbol. If a larger | |
17228 | stack is required, a signal is raised at run time. For most targets, | |
17229 | the signal is raised before the stack overruns the boundary, so | |
17230 | it is possible to catch the signal without taking special precautions. | |
17231 | ||
17232 | For instance, if the stack starts at absolute address @samp{0x80000000} | |
17233 | and grows downwards, you can use the flags | |
17234 | @option{-fstack-limit-symbol=__stack_limit} and | |
17235 | @option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit | |
17236 | of 128KB@. Note that this may only work with the GNU linker. | |
17237 | ||
17238 | You can locally override stack limit checking by using the | |
17239 | @code{no_stack_limit} function attribute (@pxref{Function Attributes}). | |
17240 | ||
d77de738 | 17241 | @opindex fsplit-stack |
ddf6fe37 | 17242 | @item -fsplit-stack |
d77de738 ML |
17243 | Generate code to automatically split the stack before it overflows. |
17244 | The resulting program has a discontiguous stack which can only | |
17245 | overflow if the program is unable to allocate any more memory. This | |
17246 | is most useful when running threaded programs, as it is no longer | |
17247 | necessary to calculate a good stack size to use for each thread. This | |
17248 | is currently only implemented for the x86 targets running | |
17249 | GNU/Linux. | |
17250 | ||
17251 | When code compiled with @option{-fsplit-stack} calls code compiled | |
17252 | without @option{-fsplit-stack}, there may not be much stack space | |
17253 | available for the latter code to run. If compiling all code, | |
17254 | including library code, with @option{-fsplit-stack} is not an option, | |
17255 | then the linker can fix up these calls so that the code compiled | |
17256 | without @option{-fsplit-stack} always has a large stack. Support for | |
17257 | this is implemented in the gold linker in GNU binutils release 2.21 | |
17258 | and later. | |
17259 | ||
d77de738 | 17260 | @opindex fvtable-verify |
ddf6fe37 | 17261 | @item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} |
d77de738 ML |
17262 | This option is only available when compiling C++ code. |
17263 | It turns on (or off, if using @option{-fvtable-verify=none}) the security | |
17264 | feature that verifies at run time, for every virtual call, that | |
17265 | the vtable pointer through which the call is made is valid for the type of | |
17266 | the object, and has not been corrupted or overwritten. If an invalid vtable | |
17267 | pointer is detected at run time, an error is reported and execution of the | |
17268 | program is immediately halted. | |
17269 | ||
17270 | This option causes run-time data structures to be built at program startup, | |
17271 | which are used for verifying the vtable pointers. | |
17272 | The options @samp{std} and @samp{preinit} | |
17273 | control the timing of when these data structures are built. In both cases the | |
17274 | data structures are built before execution reaches @code{main}. Using | |
17275 | @option{-fvtable-verify=std} causes the data structures to be built after | |
17276 | shared libraries have been loaded and initialized. | |
17277 | @option{-fvtable-verify=preinit} causes them to be built before shared | |
17278 | libraries have been loaded and initialized. | |
17279 | ||
17280 | If this option appears multiple times in the command line with different | |
17281 | values specified, @samp{none} takes highest priority over both @samp{std} and | |
17282 | @samp{preinit}; @samp{preinit} takes priority over @samp{std}. | |
17283 | ||
d77de738 | 17284 | @opindex fvtv-debug |
ddf6fe37 | 17285 | @item -fvtv-debug |
d77de738 ML |
17286 | When used in conjunction with @option{-fvtable-verify=std} or |
17287 | @option{-fvtable-verify=preinit}, causes debug versions of the | |
17288 | runtime functions for the vtable verification feature to be called. | |
17289 | This flag also causes the compiler to log information about which | |
17290 | vtable pointers it finds for each class. | |
17291 | This information is written to a file named @file{vtv_set_ptr_data.log} | |
17292 | in the directory named by the environment variable @env{VTV_LOGS_DIR} | |
17293 | if that is defined or the current working directory otherwise. | |
17294 | ||
17295 | Note: This feature @emph{appends} data to the log file. If you want a fresh log | |
17296 | file, be sure to delete any existing one. | |
17297 | ||
d77de738 | 17298 | @opindex fvtv-counts |
ddf6fe37 | 17299 | @item -fvtv-counts |
d77de738 ML |
17300 | This is a debugging flag. When used in conjunction with |
17301 | @option{-fvtable-verify=std} or @option{-fvtable-verify=preinit}, this | |
17302 | causes the compiler to keep track of the total number of virtual calls | |
17303 | it encounters and the number of verifications it inserts. It also | |
17304 | counts the number of calls to certain run-time library functions | |
17305 | that it inserts and logs this information for each compilation unit. | |
17306 | The compiler writes this information to a file named | |
17307 | @file{vtv_count_data.log} in the directory named by the environment | |
17308 | variable @env{VTV_LOGS_DIR} if that is defined or the current working | |
17309 | directory otherwise. It also counts the size of the vtable pointer sets | |
17310 | for each class, and writes this information to @file{vtv_class_set_sizes.log} | |
17311 | in the same directory. | |
17312 | ||
17313 | Note: This feature @emph{appends} data to the log files. To get fresh log | |
17314 | files, be sure to delete any existing ones. | |
17315 | ||
d77de738 | 17316 | @opindex finstrument-functions |
ddf6fe37 | 17317 | @item -finstrument-functions |
d77de738 ML |
17318 | Generate instrumentation calls for entry and exit to functions. Just |
17319 | after function entry and just before function exit, the following | |
17320 | profiling functions are called with the address of the current | |
17321 | function and its call site. (On some platforms, | |
17322 | @code{__builtin_return_address} does not work beyond the current | |
17323 | function, so the call site information may not be available to the | |
17324 | profiling functions otherwise.) | |
17325 | ||
17326 | @smallexample | |
17327 | void __cyg_profile_func_enter (void *this_fn, | |
17328 | void *call_site); | |
17329 | void __cyg_profile_func_exit (void *this_fn, | |
17330 | void *call_site); | |
17331 | @end smallexample | |
17332 | ||
17333 | The first argument is the address of the start of the current function, | |
17334 | which may be looked up exactly in the symbol table. | |
17335 | ||
17336 | This instrumentation is also done for functions expanded inline in other | |
17337 | functions. The profiling calls indicate where, conceptually, the | |
17338 | inline function is entered and exited. This means that addressable | |
17339 | versions of such functions must be available. If all your uses of a | |
17340 | function are expanded inline, this may mean an additional expansion of | |
17341 | code size. If you use @code{extern inline} in your C code, an | |
17342 | addressable version of such functions must be provided. (This is | |
17343 | normally the case anyway, but if you get lucky and the optimizer always | |
17344 | expands the functions inline, you might have gotten away without | |
17345 | providing static copies.) | |
17346 | ||
17347 | A function may be given the attribute @code{no_instrument_function}, in | |
17348 | which case this instrumentation is not done. This can be used, for | |
17349 | example, for the profiling functions listed above, high-priority | |
17350 | interrupt routines, and any functions from which the profiling functions | |
17351 | cannot safely be called (perhaps signal handlers, if the profiling | |
17352 | routines generate output or allocate memory). | |
17353 | @xref{Common Function Attributes}. | |
17354 | ||
9c19597c | 17355 | @opindex finstrument-functions-once |
ddf6fe37 | 17356 | @item -finstrument-functions-once |
d77de738 ML |
17357 | This is similar to @option{-finstrument-functions}, but the profiling |
17358 | functions are called only once per instrumented function, i.e. the first | |
17359 | profiling function is called after the first entry into the instrumented | |
17360 | function and the second profiling function is called before the exit | |
17361 | corresponding to this first entry. | |
17362 | ||
17363 | The definition of @code{once} for the purpose of this option is a little | |
17364 | vague because the implementation is not protected against data races. | |
17365 | As a result, the implementation only guarantees that the profiling | |
17366 | functions are called at @emph{least} once per process and at @emph{most} | |
17367 | once per thread, but the calls are always paired, that is to say, if a | |
17368 | thread calls the first function, then it will call the second function, | |
17369 | unless it never reaches the exit of the instrumented function. | |
17370 | ||
d77de738 | 17371 | @opindex finstrument-functions-exclude-file-list |
ddf6fe37 | 17372 | @item -finstrument-functions-exclude-file-list=@var{file},@var{file},@dots{} |
d77de738 ML |
17373 | |
17374 | Set the list of functions that are excluded from instrumentation (see | |
17375 | the description of @option{-finstrument-functions}). If the file that | |
17376 | contains a function definition matches with one of @var{file}, then | |
17377 | that function is not instrumented. The match is done on substrings: | |
17378 | if the @var{file} parameter is a substring of the file name, it is | |
17379 | considered to be a match. | |
17380 | ||
17381 | For example: | |
17382 | ||
17383 | @smallexample | |
17384 | -finstrument-functions-exclude-file-list=/bits/stl,include/sys | |
17385 | @end smallexample | |
17386 | ||
17387 | @noindent | |
17388 | excludes any inline function defined in files whose pathnames | |
17389 | contain @file{/bits/stl} or @file{include/sys}. | |
17390 | ||
17391 | If, for some reason, you want to include letter @samp{,} in one of | |
17392 | @var{sym}, write @samp{\,}. For example, | |
17393 | @option{-finstrument-functions-exclude-file-list='\,\,tmp'} | |
17394 | (note the single quote surrounding the option). | |
17395 | ||
d77de738 | 17396 | @opindex finstrument-functions-exclude-function-list |
ddf6fe37 | 17397 | @item -finstrument-functions-exclude-function-list=@var{sym},@var{sym},@dots{} |
d77de738 ML |
17398 | |
17399 | This is similar to @option{-finstrument-functions-exclude-file-list}, | |
17400 | but this option sets the list of function names to be excluded from | |
17401 | instrumentation. The function name to be matched is its user-visible | |
17402 | name, such as @code{vector<int> blah(const vector<int> &)}, not the | |
17403 | internal mangled name (e.g., @code{_Z4blahRSt6vectorIiSaIiEE}). The | |
17404 | match is done on substrings: if the @var{sym} parameter is a substring | |
17405 | of the function name, it is considered to be a match. For C99 and C++ | |
17406 | extended identifiers, the function name must be given in UTF-8, not | |
17407 | using universal character names. | |
17408 | ||
d77de738 | 17409 | @opindex fpatchable-function-entry |
ddf6fe37 | 17410 | @item -fpatchable-function-entry=@var{N}[,@var{M}] |
d77de738 ML |
17411 | Generate @var{N} NOPs right at the beginning |
17412 | of each function, with the function entry point before the @var{M}th NOP. | |
17413 | If @var{M} is omitted, it defaults to @code{0} so the | |
17414 | function entry points to the address just at the first NOP. | |
17415 | The NOP instructions reserve extra space which can be used to patch in | |
17416 | any desired instrumentation at run time, provided that the code segment | |
17417 | is writable. The amount of space is controllable indirectly via | |
17418 | the number of NOPs; the NOP instruction used corresponds to the instruction | |
17419 | emitted by the internal GCC back-end interface @code{gen_nop}. This behavior | |
17420 | is target-specific and may also depend on the architecture variant and/or | |
17421 | other compilation options. | |
17422 | ||
17423 | For run-time identification, the starting addresses of these areas, | |
17424 | which correspond to their respective function entries minus @var{M}, | |
17425 | are additionally collected in the @code{__patchable_function_entries} | |
17426 | section of the resulting binary. | |
17427 | ||
17428 | Note that the value of @code{__attribute__ ((patchable_function_entry | |
17429 | (N,M)))} takes precedence over command-line option | |
17430 | @option{-fpatchable-function-entry=N,M}. This can be used to increase | |
17431 | the area size or to remove it completely on a single function. | |
17432 | If @code{N=0}, no pad location is recorded. | |
17433 | ||
17434 | The NOP instructions are inserted at---and maybe before, depending on | |
17435 | @var{M}---the function entry address, even before the prologue. On | |
17436 | PowerPC with the ELFv2 ABI, for a function with dual entry points, | |
17437 | the local entry point is this function entry address. | |
17438 | ||
17439 | The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the | |
17440 | ELFv2 ABI, for a function with dual entry points, the supported values | |
17441 | for @var{M} are 0, 2, 6 and 14. | |
17442 | @end table | |
17443 | ||
17444 | ||
17445 | @node Preprocessor Options | |
17446 | @section Options Controlling the Preprocessor | |
17447 | @cindex preprocessor options | |
17448 | @cindex options, preprocessor | |
17449 | ||
17450 | These options control the C preprocessor, which is run on each C source | |
17451 | file before actual compilation. | |
17452 | ||
17453 | If you use the @option{-E} option, nothing is done except preprocessing. | |
17454 | Some of these options make sense only together with @option{-E} because | |
17455 | they cause the preprocessor output to be unsuitable for actual | |
17456 | compilation. | |
17457 | ||
17458 | In addition to the options listed here, there are a number of options | |
17459 | to control search paths for include files documented in | |
17460 | @ref{Directory Options}. | |
17461 | Options to control preprocessor diagnostics are listed in | |
17462 | @ref{Warning Options}. | |
17463 | ||
17464 | @table @gcctabopt | |
17465 | @include cppopts.texi | |
17466 | ||
d77de738 | 17467 | @opindex Wp |
ddf6fe37 | 17468 | @item -Wp,@var{option} |
d77de738 ML |
17469 | You can use @option{-Wp,@var{option}} to bypass the compiler driver |
17470 | and pass @var{option} directly through to the preprocessor. If | |
17471 | @var{option} contains commas, it is split into multiple options at the | |
17472 | commas. However, many options are modified, translated or interpreted | |
17473 | by the compiler driver before being passed to the preprocessor, and | |
17474 | @option{-Wp} forcibly bypasses this phase. The preprocessor's direct | |
17475 | interface is undocumented and subject to change, so whenever possible | |
17476 | you should avoid using @option{-Wp} and let the driver handle the | |
17477 | options instead. | |
17478 | ||
d77de738 | 17479 | @opindex Xpreprocessor |
ddf6fe37 | 17480 | @item -Xpreprocessor @var{option} |
d77de738 ML |
17481 | Pass @var{option} as an option to the preprocessor. You can use this to |
17482 | supply system-specific preprocessor options that GCC does not | |
17483 | recognize. | |
17484 | ||
17485 | If you want to pass an option that takes an argument, you must use | |
17486 | @option{-Xpreprocessor} twice, once for the option and once for the argument. | |
17487 | ||
d77de738 | 17488 | @opindex no-integrated-cpp |
ddf6fe37 | 17489 | @item -no-integrated-cpp |
d77de738 ML |
17490 | Perform preprocessing as a separate pass before compilation. |
17491 | By default, GCC performs preprocessing as an integrated part of | |
17492 | input tokenization and parsing. | |
17493 | If this option is provided, the appropriate language front end | |
17494 | (@command{cc1}, @command{cc1plus}, or @command{cc1obj} for C, C++, | |
17495 | and Objective-C, respectively) is instead invoked twice, | |
17496 | once for preprocessing only and once for actual compilation | |
17497 | of the preprocessed input. | |
17498 | This option may be useful in conjunction with the @option{-B} or | |
17499 | @option{-wrapper} options to specify an alternate preprocessor or | |
17500 | perform additional processing of the program source between | |
17501 | normal preprocessing and compilation. | |
17502 | ||
d77de738 | 17503 | @opindex flarge-source-files |
ddf6fe37 | 17504 | @item -flarge-source-files |
d77de738 ML |
17505 | Adjust GCC to expect large source files, at the expense of slower |
17506 | compilation and higher memory usage. | |
17507 | ||
17508 | Specifically, GCC normally tracks both column numbers and line numbers | |
17509 | within source files and it normally prints both of these numbers in | |
17510 | diagnostics. However, once it has processed a certain number of source | |
17511 | lines, it stops tracking column numbers and only tracks line numbers. | |
17512 | This means that diagnostics for later lines do not include column numbers. | |
17513 | It also means that options like @option{-Wmisleading-indentation} cease to work | |
17514 | at that point, although the compiler prints a note if this happens. | |
17515 | Passing @option{-flarge-source-files} significantly increases the number | |
17516 | of source lines that GCC can process before it stops tracking columns. | |
17517 | ||
17518 | @end table | |
17519 | ||
17520 | @node Assembler Options | |
17521 | @section Passing Options to the Assembler | |
17522 | ||
17523 | @c prevent bad page break with this line | |
17524 | You can pass options to the assembler. | |
17525 | ||
17526 | @table @gcctabopt | |
d77de738 | 17527 | @opindex Wa |
ddf6fe37 | 17528 | @item -Wa,@var{option} |
d77de738 ML |
17529 | Pass @var{option} as an option to the assembler. If @var{option} |
17530 | contains commas, it is split into multiple options at the commas. | |
17531 | ||
d77de738 | 17532 | @opindex Xassembler |
ddf6fe37 | 17533 | @item -Xassembler @var{option} |
d77de738 ML |
17534 | Pass @var{option} as an option to the assembler. You can use this to |
17535 | supply system-specific assembler options that GCC does not | |
17536 | recognize. | |
17537 | ||
17538 | If you want to pass an option that takes an argument, you must use | |
17539 | @option{-Xassembler} twice, once for the option and once for the argument. | |
17540 | ||
17541 | @end table | |
17542 | ||
17543 | @node Link Options | |
17544 | @section Options for Linking | |
17545 | @cindex link options | |
17546 | @cindex options, linking | |
17547 | ||
17548 | These options come into play when the compiler links object files into | |
17549 | an executable output file. They are meaningless if the compiler is | |
17550 | not doing a link step. | |
17551 | ||
17552 | @table @gcctabopt | |
17553 | @cindex file names | |
17554 | @item @var{object-file-name} | |
17555 | A file name that does not end in a special recognized suffix is | |
17556 | considered to name an object file or library. (Object files are | |
17557 | distinguished from libraries by the linker according to the file | |
17558 | contents.) If linking is done, these object files are used as input | |
17559 | to the linker. | |
17560 | ||
d77de738 ML |
17561 | @opindex c |
17562 | @opindex S | |
17563 | @opindex E | |
ddf6fe37 AA |
17564 | @item -c |
17565 | @itemx -S | |
17566 | @itemx -E | |
d77de738 ML |
17567 | If any of these options is used, then the linker is not run, and |
17568 | object file names should not be used as arguments. @xref{Overall | |
17569 | Options}. | |
17570 | ||
d77de738 | 17571 | @opindex flinker-output |
ddf6fe37 | 17572 | @item -flinker-output=@var{type} |
d77de738 ML |
17573 | This option controls code generation of the link-time optimizer. By |
17574 | default the linker output is automatically determined by the linker | |
17575 | plugin. For debugging the compiler and if incremental linking with a | |
17576 | non-LTO object file is desired, it may be useful to control the type | |
17577 | manually. | |
17578 | ||
17579 | If @var{type} is @samp{exec}, code generation produces a static | |
17580 | binary. In this case @option{-fpic} and @option{-fpie} are both | |
17581 | disabled. | |
17582 | ||
17583 | If @var{type} is @samp{dyn}, code generation produces a shared | |
17584 | library. In this case @option{-fpic} or @option{-fPIC} is preserved, | |
17585 | but not enabled automatically. This allows to build shared libraries | |
17586 | without position-independent code on architectures where this is | |
17587 | possible, i.e.@: on x86. | |
17588 | ||
17589 | If @var{type} is @samp{pie}, code generation produces an @option{-fpie} | |
17590 | executable. This results in similar optimizations as @samp{exec} | |
17591 | except that @option{-fpie} is not disabled if specified at compilation | |
17592 | time. | |
17593 | ||
17594 | If @var{type} is @samp{rel}, the compiler assumes that incremental linking is | |
17595 | done. The sections containing intermediate code for link-time optimization are | |
17596 | merged, pre-optimized, and output to the resulting object file. In addition, if | |
17597 | @option{-ffat-lto-objects} is specified, binary code is produced for future | |
17598 | non-LTO linking. The object file produced by incremental linking is smaller | |
17599 | than a static library produced from the same object files. At link time the | |
17600 | result of incremental linking also loads faster than a static | |
17601 | library assuming that the majority of objects in the library are used. | |
17602 | ||
17603 | Finally @samp{nolto-rel} configures the compiler for incremental linking where | |
17604 | code generation is forced, a final binary is produced, and the intermediate | |
17605 | code for later link-time optimization is stripped. When multiple object files | |
17606 | are linked together the resulting code is better optimized than with | |
17607 | link-time optimizations disabled (for example, cross-module inlining | |
17608 | happens), but most of benefits of whole program optimizations are lost. | |
17609 | ||
17610 | During the incremental link (by @option{-r}) the linker plugin defaults to | |
17611 | @option{rel}. With current interfaces to GNU Binutils it is however not | |
17612 | possible to incrementally link LTO objects and non-LTO objects into a single | |
17613 | mixed object file. If any of object files in incremental link cannot | |
17614 | be used for link-time optimization, the linker plugin issues a warning and | |
17615 | uses @samp{nolto-rel}. To maintain whole program optimization, it is | |
17616 | recommended to link such objects into static library instead. Alternatively it | |
17617 | is possible to use H.J. Lu's binutils with support for mixed objects. | |
17618 | ||
d77de738 | 17619 | @opindex fuse-ld=bfd |
ddf6fe37 | 17620 | @item -fuse-ld=bfd |
d77de738 ML |
17621 | Use the @command{bfd} linker instead of the default linker. |
17622 | ||
d77de738 | 17623 | @opindex fuse-ld=gold |
ddf6fe37 | 17624 | @item -fuse-ld=gold |
d77de738 ML |
17625 | Use the @command{gold} linker instead of the default linker. |
17626 | ||
d77de738 | 17627 | @opindex fuse-ld=lld |
ddf6fe37 | 17628 | @item -fuse-ld=lld |
d77de738 ML |
17629 | Use the LLVM @command{lld} linker instead of the default linker. |
17630 | ||
d77de738 | 17631 | @opindex fuse-ld=mold |
ddf6fe37 | 17632 | @item -fuse-ld=mold |
d77de738 ML |
17633 | Use the Modern Linker (@command{mold}) instead of the default linker. |
17634 | ||
17635 | @cindex Libraries | |
ddf6fe37 | 17636 | @opindex l |
d77de738 ML |
17637 | @item -l@var{library} |
17638 | @itemx -l @var{library} | |
d77de738 ML |
17639 | Search the library named @var{library} when linking. (The second |
17640 | alternative with the library as a separate argument is only for | |
17641 | POSIX compliance and is not recommended.) | |
17642 | ||
17643 | The @option{-l} option is passed directly to the linker by GCC. Refer | |
17644 | to your linker documentation for exact details. The general | |
17645 | description below applies to the GNU linker. | |
17646 | ||
17647 | The linker searches a standard list of directories for the library. | |
17648 | The directories searched include several standard system directories | |
17649 | plus any that you specify with @option{-L}. | |
17650 | ||
17651 | Static libraries are archives of object files, and have file names | |
17652 | like @file{lib@var{library}.a}. Some targets also support shared | |
17653 | libraries, which typically have names like @file{lib@var{library}.so}. | |
17654 | If both static and shared libraries are found, the linker gives | |
17655 | preference to linking with the shared library unless the | |
17656 | @option{-static} option is used. | |
17657 | ||
17658 | It makes a difference where in the command you write this option; the | |
17659 | linker searches and processes libraries and object files in the order they | |
17660 | are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z} | |
17661 | after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers | |
17662 | to functions in @samp{z}, those functions may not be loaded. | |
17663 | ||
d77de738 | 17664 | @opindex lobjc |
ddf6fe37 | 17665 | @item -lobjc |
d77de738 ML |
17666 | You need this special case of the @option{-l} option in order to |
17667 | link an Objective-C or Objective-C++ program. | |
17668 | ||
d77de738 | 17669 | @opindex nostartfiles |
ddf6fe37 | 17670 | @item -nostartfiles |
d77de738 ML |
17671 | Do not use the standard system startup files when linking. |
17672 | The standard system libraries are used normally, unless @option{-nostdlib}, | |
17673 | @option{-nolibc}, or @option{-nodefaultlibs} is used. | |
17674 | ||
d77de738 | 17675 | @opindex nodefaultlibs |
ddf6fe37 | 17676 | @item -nodefaultlibs |
d77de738 ML |
17677 | Do not use the standard system libraries when linking. |
17678 | Only the libraries you specify are passed to the linker, and options | |
17679 | specifying linkage of the system libraries, such as @option{-static-libgcc} | |
17680 | or @option{-shared-libgcc}, are ignored. | |
17681 | The standard startup files are used normally, unless @option{-nostartfiles} | |
17682 | is used. | |
17683 | ||
17684 | The compiler may generate calls to @code{memcmp}, | |
17685 | @code{memset}, @code{memcpy} and @code{memmove}. | |
17686 | These entries are usually resolved by entries in | |
17687 | libc. These entry points should be supplied through some other | |
17688 | mechanism when this option is specified. | |
17689 | ||
d77de738 | 17690 | @opindex nolibc |
ddf6fe37 | 17691 | @item -nolibc |
d77de738 ML |
17692 | Do not use the C library or system libraries tightly coupled with it when |
17693 | linking. Still link with the startup files, @file{libgcc} or toolchain | |
17694 | provided language support libraries such as @file{libgnat}, @file{libgfortran} | |
17695 | or @file{libstdc++} unless options preventing their inclusion are used as | |
17696 | well. This typically removes @option{-lc} from the link command line, as well | |
17697 | as system libraries that normally go with it and become meaningless when | |
17698 | absence of a C library is assumed, for example @option{-lpthread} or | |
17699 | @option{-lm} in some configurations. This is intended for bare-board | |
17700 | targets when there is indeed no C library available. | |
17701 | ||
d77de738 | 17702 | @opindex nostdlib |
ddf6fe37 | 17703 | @item -nostdlib |
d77de738 ML |
17704 | Do not use the standard system startup files or libraries when linking. |
17705 | No startup files and only the libraries you specify are passed to | |
17706 | the linker, and options specifying linkage of the system libraries, such as | |
17707 | @option{-static-libgcc} or @option{-shared-libgcc}, are ignored. | |
17708 | ||
17709 | The compiler may generate calls to @code{memcmp}, @code{memset}, | |
17710 | @code{memcpy} and @code{memmove}. | |
17711 | These entries are usually resolved by entries in | |
17712 | libc. These entry points should be supplied through some other | |
17713 | mechanism when this option is specified. | |
17714 | ||
17715 | @cindex @option{-lgcc}, use with @option{-nostdlib} | |
17716 | @cindex @option{-nostdlib} and unresolved references | |
17717 | @cindex unresolved references and @option{-nostdlib} | |
17718 | @cindex @option{-lgcc}, use with @option{-nodefaultlibs} | |
17719 | @cindex @option{-nodefaultlibs} and unresolved references | |
17720 | @cindex unresolved references and @option{-nodefaultlibs} | |
17721 | One of the standard libraries bypassed by @option{-nostdlib} and | |
17722 | @option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines | |
17723 | which GCC uses to overcome shortcomings of particular machines, or special | |
17724 | needs for some languages. | |
17725 | (@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler | |
17726 | Collection (GCC) Internals}, | |
17727 | for more discussion of @file{libgcc.a}.) | |
17728 | In most cases, you need @file{libgcc.a} even when you want to avoid | |
17729 | other standard libraries. In other words, when you specify @option{-nostdlib} | |
17730 | or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well. | |
17731 | This ensures that you have no unresolved references to internal GCC | |
17732 | library subroutines. | |
17733 | (An example of such an internal subroutine is @code{__main}, used to ensure C++ | |
17734 | constructors are called; @pxref{Collect2,,@code{collect2}, gccint, | |
17735 | GNU Compiler Collection (GCC) Internals}.) | |
17736 | ||
d77de738 | 17737 | @opindex nostdlib++ |
ddf6fe37 | 17738 | @item -nostdlib++ |
d77de738 ML |
17739 | Do not implicitly link with standard C++ libraries. |
17740 | ||
d77de738 ML |
17741 | @opindex e |
17742 | @opindex entry | |
ddf6fe37 AA |
17743 | @item -e @var{entry} |
17744 | @itemx --entry=@var{entry} | |
d77de738 ML |
17745 | |
17746 | Specify that the program entry point is @var{entry}. The argument is | |
17747 | interpreted by the linker; the GNU linker accepts either a symbol name | |
17748 | or an address. | |
17749 | ||
d77de738 | 17750 | @opindex pie |
ddf6fe37 | 17751 | @item -pie |
d77de738 ML |
17752 | Produce a dynamically linked position independent executable on targets |
17753 | that support it. For predictable results, you must also specify the same | |
17754 | set of options used for compilation (@option{-fpie}, @option{-fPIE}, | |
17755 | or model suboptions) when you specify this linker option. | |
17756 | ||
d77de738 | 17757 | @opindex no-pie |
ddf6fe37 | 17758 | @item -no-pie |
d77de738 ML |
17759 | Don't produce a dynamically linked position independent executable. |
17760 | ||
d77de738 | 17761 | @opindex static-pie |
ddf6fe37 | 17762 | @item -static-pie |
d77de738 ML |
17763 | Produce a static position independent executable on targets that support |
17764 | it. A static position independent executable is similar to a static | |
17765 | executable, but can be loaded at any address without a dynamic linker. | |
17766 | For predictable results, you must also specify the same set of options | |
17767 | used for compilation (@option{-fpie}, @option{-fPIE}, or model | |
17768 | suboptions) when you specify this linker option. | |
17769 | ||
d77de738 | 17770 | @opindex pthread |
ddf6fe37 | 17771 | @item -pthread |
d77de738 ML |
17772 | Link with the POSIX threads library. This option is supported on |
17773 | GNU/Linux targets, most other Unix derivatives, and also on | |
17774 | x86 Cygwin and MinGW targets. On some targets this option also sets | |
17775 | flags for the preprocessor, so it should be used consistently for both | |
17776 | compilation and linking. | |
17777 | ||
d77de738 | 17778 | @opindex r |
ddf6fe37 | 17779 | @item -r |
d77de738 ML |
17780 | Produce a relocatable object as output. This is also known as partial |
17781 | linking. | |
17782 | ||
d77de738 | 17783 | @opindex rdynamic |
ddf6fe37 | 17784 | @item -rdynamic |
d77de738 ML |
17785 | Pass the flag @option{-export-dynamic} to the ELF linker, on targets |
17786 | that support it. This instructs the linker to add all symbols, not | |
17787 | only used ones, to the dynamic symbol table. This option is needed | |
17788 | for some uses of @code{dlopen} or to allow obtaining backtraces | |
17789 | from within a program. | |
17790 | ||
d77de738 | 17791 | @opindex s |
ddf6fe37 | 17792 | @item -s |
d77de738 ML |
17793 | Remove all symbol table and relocation information from the executable. |
17794 | ||
d77de738 | 17795 | @opindex static |
ddf6fe37 | 17796 | @item -static |
d77de738 ML |
17797 | On systems that support dynamic linking, this overrides @option{-pie} |
17798 | and prevents linking with the shared libraries. On other systems, this | |
17799 | option has no effect. | |
17800 | ||
d77de738 | 17801 | @opindex shared |
ddf6fe37 | 17802 | @item -shared |
d77de738 ML |
17803 | Produce a shared object which can then be linked with other objects to |
17804 | form an executable. Not all systems support this option. For predictable | |
17805 | results, you must also specify the same set of options used for compilation | |
17806 | (@option{-fpic}, @option{-fPIC}, or model suboptions) when | |
17807 | you specify this linker option.@footnote{On some systems, @samp{gcc -shared} | |
17808 | needs to build supplementary stub code for constructors to work. On | |
17809 | multi-libbed systems, @samp{gcc -shared} must select the correct support | |
17810 | libraries to link against. Failing to supply the correct flags may lead | |
17811 | to subtle defects. Supplying them in cases where they are not necessary | |
b799acef RB |
17812 | is innocuous. @option{-shared} suppresses the addition of startup code |
17813 | to alter the floating-point environment as done with @option{-ffast-math}, | |
17814 | @option{-Ofast} or @option{-funsafe-math-optimizations} on some targets.} | |
d77de738 | 17815 | |
d77de738 ML |
17816 | @opindex shared-libgcc |
17817 | @opindex static-libgcc | |
ddf6fe37 AA |
17818 | @item -shared-libgcc |
17819 | @itemx -static-libgcc | |
d77de738 ML |
17820 | On systems that provide @file{libgcc} as a shared library, these options |
17821 | force the use of either the shared or static version, respectively. | |
17822 | If no shared version of @file{libgcc} was built when the compiler was | |
17823 | configured, these options have no effect. | |
17824 | ||
17825 | There are several situations in which an application should use the | |
17826 | shared @file{libgcc} instead of the static version. The most common | |
17827 | of these is when the application wishes to throw and catch exceptions | |
17828 | across different shared libraries. In that case, each of the libraries | |
17829 | as well as the application itself should use the shared @file{libgcc}. | |
17830 | ||
17831 | Therefore, the G++ driver automatically adds @option{-shared-libgcc} | |
17832 | whenever you build a shared library or a main executable, because C++ | |
17833 | programs typically use exceptions, so this is the right thing to do. | |
17834 | ||
17835 | If, instead, you use the GCC driver to create shared libraries, you may | |
17836 | find that they are not always linked with the shared @file{libgcc}. | |
17837 | If GCC finds, at its configuration time, that you have a non-GNU linker | |
17838 | or a GNU linker that does not support option @option{--eh-frame-hdr}, | |
17839 | it links the shared version of @file{libgcc} into shared libraries | |
17840 | by default. Otherwise, it takes advantage of the linker and optimizes | |
17841 | away the linking with the shared version of @file{libgcc}, linking with | |
17842 | the static version of libgcc by default. This allows exceptions to | |
17843 | propagate through such shared libraries, without incurring relocation | |
17844 | costs at library load time. | |
17845 | ||
17846 | However, if a library or main executable is supposed to throw or catch | |
17847 | exceptions, you must link it using the G++ driver, or using the option | |
17848 | @option{-shared-libgcc}, such that it is linked with the shared | |
17849 | @file{libgcc}. | |
17850 | ||
d77de738 | 17851 | @opindex static-libasan |
ddf6fe37 | 17852 | @item -static-libasan |
d77de738 ML |
17853 | When the @option{-fsanitize=address} option is used to link a program, |
17854 | the GCC driver automatically links against @option{libasan}. If | |
17855 | @file{libasan} is available as a shared library, and the @option{-static} | |
17856 | option is not used, then this links against the shared version of | |
17857 | @file{libasan}. The @option{-static-libasan} option directs the GCC | |
17858 | driver to link @file{libasan} statically, without necessarily linking | |
17859 | other libraries statically. | |
17860 | ||
d77de738 | 17861 | @opindex static-libtsan |
ddf6fe37 | 17862 | @item -static-libtsan |
d77de738 ML |
17863 | When the @option{-fsanitize=thread} option is used to link a program, |
17864 | the GCC driver automatically links against @option{libtsan}. If | |
17865 | @file{libtsan} is available as a shared library, and the @option{-static} | |
17866 | option is not used, then this links against the shared version of | |
17867 | @file{libtsan}. The @option{-static-libtsan} option directs the GCC | |
17868 | driver to link @file{libtsan} statically, without necessarily linking | |
17869 | other libraries statically. | |
17870 | ||
d77de738 | 17871 | @opindex static-liblsan |
ddf6fe37 | 17872 | @item -static-liblsan |
d77de738 ML |
17873 | When the @option{-fsanitize=leak} option is used to link a program, |
17874 | the GCC driver automatically links against @option{liblsan}. If | |
17875 | @file{liblsan} is available as a shared library, and the @option{-static} | |
17876 | option is not used, then this links against the shared version of | |
17877 | @file{liblsan}. The @option{-static-liblsan} option directs the GCC | |
17878 | driver to link @file{liblsan} statically, without necessarily linking | |
17879 | other libraries statically. | |
17880 | ||
d77de738 | 17881 | @opindex static-libubsan |
ddf6fe37 | 17882 | @item -static-libubsan |
d77de738 ML |
17883 | When the @option{-fsanitize=undefined} option is used to link a program, |
17884 | the GCC driver automatically links against @option{libubsan}. If | |
17885 | @file{libubsan} is available as a shared library, and the @option{-static} | |
17886 | option is not used, then this links against the shared version of | |
17887 | @file{libubsan}. The @option{-static-libubsan} option directs the GCC | |
17888 | driver to link @file{libubsan} statically, without necessarily linking | |
17889 | other libraries statically. | |
17890 | ||
d77de738 | 17891 | @opindex static-libstdc++ |
ddf6fe37 | 17892 | @item -static-libstdc++ |
d77de738 ML |
17893 | When the @command{g++} program is used to link a C++ program, it |
17894 | normally automatically links against @option{libstdc++}. If | |
17895 | @file{libstdc++} is available as a shared library, and the | |
17896 | @option{-static} option is not used, then this links against the | |
17897 | shared version of @file{libstdc++}. That is normally fine. However, it | |
17898 | is sometimes useful to freeze the version of @file{libstdc++} used by | |
17899 | the program without going all the way to a fully static link. The | |
17900 | @option{-static-libstdc++} option directs the @command{g++} driver to | |
17901 | link @file{libstdc++} statically, without necessarily linking other | |
17902 | libraries statically. | |
17903 | ||
d77de738 | 17904 | @opindex symbolic |
ddf6fe37 | 17905 | @item -symbolic |
d77de738 ML |
17906 | Bind references to global symbols when building a shared object. Warn |
17907 | about any unresolved references (unless overridden by the link editor | |
17908 | option @option{-Xlinker -z -Xlinker defs}). Only a few systems support | |
17909 | this option. | |
17910 | ||
d77de738 ML |
17911 | @opindex T |
17912 | @cindex linker script | |
f33d7a88 | 17913 | @item -T @var{script} |
d77de738 ML |
17914 | Use @var{script} as the linker script. This option is supported by most |
17915 | systems using the GNU linker. On some targets, such as bare-board | |
17916 | targets without an operating system, the @option{-T} option may be required | |
17917 | when linking to avoid references to undefined symbols. | |
17918 | ||
d77de738 | 17919 | @opindex Xlinker |
ddf6fe37 | 17920 | @item -Xlinker @var{option} |
d77de738 ML |
17921 | Pass @var{option} as an option to the linker. You can use this to |
17922 | supply system-specific linker options that GCC does not recognize. | |
17923 | ||
17924 | If you want to pass an option that takes a separate argument, you must use | |
17925 | @option{-Xlinker} twice, once for the option and once for the argument. | |
17926 | For example, to pass @option{-assert definitions}, you must write | |
17927 | @option{-Xlinker -assert -Xlinker definitions}. It does not work to write | |
17928 | @option{-Xlinker "-assert definitions"}, because this passes the entire | |
17929 | string as a single argument, which is not what the linker expects. | |
17930 | ||
17931 | When using the GNU linker, it is usually more convenient to pass | |
17932 | arguments to linker options using the @option{@var{option}=@var{value}} | |
17933 | syntax than as separate arguments. For example, you can specify | |
17934 | @option{-Xlinker -Map=output.map} rather than | |
17935 | @option{-Xlinker -Map -Xlinker output.map}. Other linkers may not support | |
17936 | this syntax for command-line options. | |
17937 | ||
d77de738 | 17938 | @opindex Wl |
ddf6fe37 | 17939 | @item -Wl,@var{option} |
d77de738 ML |
17940 | Pass @var{option} as an option to the linker. If @var{option} contains |
17941 | commas, it is split into multiple options at the commas. You can use this | |
17942 | syntax to pass an argument to the option. | |
17943 | For example, @option{-Wl,-Map,output.map} passes @option{-Map output.map} to the | |
17944 | linker. When using the GNU linker, you can also get the same effect with | |
17945 | @option{-Wl,-Map=output.map}. | |
17946 | ||
d77de738 | 17947 | @opindex u |
ddf6fe37 | 17948 | @item -u @var{symbol} |
d77de738 ML |
17949 | Pretend the symbol @var{symbol} is undefined, to force linking of |
17950 | library modules to define it. You can use @option{-u} multiple times with | |
17951 | different symbols to force loading of additional library modules. | |
17952 | ||
d77de738 | 17953 | @opindex z |
ddf6fe37 | 17954 | @item -z @var{keyword} |
d77de738 ML |
17955 | @option{-z} is passed directly on to the linker along with the keyword |
17956 | @var{keyword}. See the section in the documentation of your linker for | |
17957 | permitted values and their meanings. | |
17958 | @end table | |
17959 | ||
17960 | @node Directory Options | |
17961 | @section Options for Directory Search | |
17962 | @cindex directory options | |
17963 | @cindex options, directory search | |
17964 | @cindex search path | |
17965 | ||
17966 | These options specify directories to search for header files, for | |
17967 | libraries and for parts of the compiler: | |
17968 | ||
17969 | @table @gcctabopt | |
17970 | @include cppdiropts.texi | |
17971 | ||
d77de738 | 17972 | @opindex iplugindir= |
ddf6fe37 | 17973 | @item -iplugindir=@var{dir} |
d77de738 ML |
17974 | Set the directory to search for plugins that are passed |
17975 | by @option{-fplugin=@var{name}} instead of | |
17976 | @option{-fplugin=@var{path}/@var{name}.so}. This option is not meant | |
17977 | to be used by the user, but only passed by the driver. | |
17978 | ||
d77de738 | 17979 | @opindex L |
ddf6fe37 | 17980 | @item -L@var{dir} |
d77de738 ML |
17981 | Add directory @var{dir} to the list of directories to be searched |
17982 | for @option{-l}. | |
17983 | ||
d77de738 | 17984 | @opindex B |
ddf6fe37 | 17985 | @item -B@var{prefix} |
d77de738 ML |
17986 | This option specifies where to find the executables, libraries, |
17987 | include files, and data files of the compiler itself. | |
17988 | ||
17989 | The compiler driver program runs one or more of the subprograms | |
17990 | @command{cpp}, @command{cc1}, @command{as} and @command{ld}. It tries | |
17991 | @var{prefix} as a prefix for each program it tries to run, both with and | |
17992 | without @samp{@var{machine}/@var{version}/} for the corresponding target | |
17993 | machine and compiler version. | |
17994 | ||
17995 | For each subprogram to be run, the compiler driver first tries the | |
17996 | @option{-B} prefix, if any. If that name is not found, or if @option{-B} | |
17997 | is not specified, the driver tries two standard prefixes, | |
17998 | @file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc/}. If neither of | |
17999 | those results in a file name that is found, the unmodified program | |
18000 | name is searched for using the directories specified in your | |
18001 | @env{PATH} environment variable. | |
18002 | ||
18003 | The compiler checks to see if the path provided by @option{-B} | |
18004 | refers to a directory, and if necessary it adds a directory | |
18005 | separator character at the end of the path. | |
18006 | ||
18007 | @option{-B} prefixes that effectively specify directory names also apply | |
18008 | to libraries in the linker, because the compiler translates these | |
18009 | options into @option{-L} options for the linker. They also apply to | |
18010 | include files in the preprocessor, because the compiler translates these | |
18011 | options into @option{-isystem} options for the preprocessor. In this case, | |
18012 | the compiler appends @samp{include} to the prefix. | |
18013 | ||
18014 | The runtime support file @file{libgcc.a} can also be searched for using | |
18015 | the @option{-B} prefix, if needed. If it is not found there, the two | |
18016 | standard prefixes above are tried, and that is all. The file is left | |
18017 | out of the link if it is not found by those means. | |
18018 | ||
18019 | Another way to specify a prefix much like the @option{-B} prefix is to use | |
18020 | the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment | |
18021 | Variables}. | |
18022 | ||
18023 | As a special kludge, if the path provided by @option{-B} is | |
18024 | @file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to | |
18025 | 9, then it is replaced by @file{[dir/]include}. This is to help | |
18026 | with boot-strapping the compiler. | |
18027 | ||
d77de738 | 18028 | @opindex no-canonical-prefixes |
ddf6fe37 | 18029 | @item -no-canonical-prefixes |
d77de738 ML |
18030 | Do not expand any symbolic links, resolve references to @samp{/../} |
18031 | or @samp{/./}, or make the path absolute when generating a relative | |
18032 | prefix. | |
18033 | ||
d77de738 | 18034 | @opindex sysroot |
ddf6fe37 | 18035 | @item --sysroot=@var{dir} |
d77de738 ML |
18036 | Use @var{dir} as the logical root directory for headers and libraries. |
18037 | For example, if the compiler normally searches for headers in | |
18038 | @file{/usr/include} and libraries in @file{/usr/lib}, it instead | |
18039 | searches @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}. | |
18040 | ||
18041 | If you use both this option and the @option{-isysroot} option, then | |
18042 | the @option{--sysroot} option applies to libraries, but the | |
18043 | @option{-isysroot} option applies to header files. | |
18044 | ||
18045 | The GNU linker (beginning with version 2.16) has the necessary support | |
18046 | for this option. If your linker does not support this option, the | |
18047 | header file aspect of @option{--sysroot} still works, but the | |
18048 | library aspect does not. | |
18049 | ||
d77de738 | 18050 | @opindex no-sysroot-suffix |
ddf6fe37 | 18051 | @item --no-sysroot-suffix |
d77de738 ML |
18052 | For some targets, a suffix is added to the root directory specified |
18053 | with @option{--sysroot}, depending on the other options used, so that | |
18054 | headers may for example be found in | |
18055 | @file{@var{dir}/@var{suffix}/usr/include} instead of | |
18056 | @file{@var{dir}/usr/include}. This option disables the addition of | |
18057 | such a suffix. | |
18058 | ||
18059 | @end table | |
18060 | ||
18061 | @node Code Gen Options | |
18062 | @section Options for Code Generation Conventions | |
18063 | @cindex code generation conventions | |
18064 | @cindex options, code generation | |
18065 | @cindex run-time options | |
18066 | ||
18067 | These machine-independent options control the interface conventions | |
18068 | used in code generation. | |
18069 | ||
18070 | Most of them have both positive and negative forms; the negative form | |
18071 | of @option{-ffoo} is @option{-fno-foo}. In the table below, only | |
18072 | one of the forms is listed---the one that is not the default. You | |
18073 | can figure out the other form by either removing @samp{no-} or adding | |
18074 | it. | |
18075 | ||
18076 | @table @gcctabopt | |
d77de738 | 18077 | @opindex fstack_reuse |
ddf6fe37 | 18078 | @item -fstack-reuse=@var{reuse-level} |
d77de738 ML |
18079 | This option controls stack space reuse for user declared local/auto variables |
18080 | and compiler generated temporaries. @var{reuse_level} can be @samp{all}, | |
18081 | @samp{named_vars}, or @samp{none}. @samp{all} enables stack reuse for all | |
18082 | local variables and temporaries, @samp{named_vars} enables the reuse only for | |
18083 | user defined local variables with names, and @samp{none} disables stack reuse | |
18084 | completely. The default value is @samp{all}. The option is needed when the | |
18085 | program extends the lifetime of a scoped local variable or a compiler generated | |
18086 | temporary beyond the end point defined by the language. When a lifetime of | |
18087 | a variable ends, and if the variable lives in memory, the optimizing compiler | |
18088 | has the freedom to reuse its stack space with other temporaries or scoped | |
18089 | local variables whose live range does not overlap with it. Legacy code extending | |
18090 | local lifetime is likely to break with the stack reuse optimization. | |
18091 | ||
18092 | For example, | |
18093 | ||
18094 | @smallexample | |
18095 | int *p; | |
18096 | @{ | |
18097 | int local1; | |
18098 | ||
18099 | p = &local1; | |
18100 | local1 = 10; | |
18101 | .... | |
18102 | @} | |
18103 | @{ | |
18104 | int local2; | |
18105 | local2 = 20; | |
18106 | ... | |
18107 | @} | |
18108 | ||
18109 | if (*p == 10) // out of scope use of local1 | |
18110 | @{ | |
18111 | ||
18112 | @} | |
18113 | @end smallexample | |
18114 | ||
18115 | Another example: | |
18116 | @smallexample | |
18117 | ||
18118 | struct A | |
18119 | @{ | |
18120 | A(int k) : i(k), j(k) @{ @} | |
18121 | int i; | |
18122 | int j; | |
18123 | @}; | |
18124 | ||
18125 | A *ap; | |
18126 | ||
18127 | void foo(const A& ar) | |
18128 | @{ | |
18129 | ap = &ar; | |
18130 | @} | |
18131 | ||
18132 | void bar() | |
18133 | @{ | |
18134 | foo(A(10)); // temp object's lifetime ends when foo returns | |
18135 | ||
18136 | @{ | |
18137 | A a(20); | |
18138 | .... | |
18139 | @} | |
18140 | ap->i+= 10; // ap references out of scope temp whose space | |
18141 | // is reused with a. What is the value of ap->i? | |
18142 | @} | |
18143 | ||
18144 | @end smallexample | |
18145 | ||
18146 | The lifetime of a compiler generated temporary is well defined by the C++ | |
18147 | standard. When a lifetime of a temporary ends, and if the temporary lives | |
18148 | in memory, the optimizing compiler has the freedom to reuse its stack | |
18149 | space with other temporaries or scoped local variables whose live range | |
18150 | does not overlap with it. However some of the legacy code relies on | |
18151 | the behavior of older compilers in which temporaries' stack space is | |
18152 | not reused, the aggressive stack reuse can lead to runtime errors. This | |
18153 | option is used to control the temporary stack reuse optimization. | |
18154 | ||
d77de738 | 18155 | @opindex ftrapv |
ddf6fe37 | 18156 | @item -ftrapv |
d77de738 ML |
18157 | This option generates traps for signed overflow on addition, subtraction, |
18158 | multiplication operations. | |
18159 | The options @option{-ftrapv} and @option{-fwrapv} override each other, so using | |
18160 | @option{-ftrapv} @option{-fwrapv} on the command-line results in | |
18161 | @option{-fwrapv} being effective. Note that only active options override, so | |
18162 | using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line | |
18163 | results in @option{-ftrapv} being effective. | |
18164 | ||
d77de738 | 18165 | @opindex fwrapv |
ddf6fe37 | 18166 | @item -fwrapv |
d77de738 ML |
18167 | This option instructs the compiler to assume that signed arithmetic |
18168 | overflow of addition, subtraction and multiplication wraps around | |
18169 | using twos-complement representation. This flag enables some optimizations | |
18170 | and disables others. | |
18171 | The options @option{-ftrapv} and @option{-fwrapv} override each other, so using | |
18172 | @option{-ftrapv} @option{-fwrapv} on the command-line results in | |
18173 | @option{-fwrapv} being effective. Note that only active options override, so | |
18174 | using @option{-ftrapv} @option{-fwrapv} @option{-fno-wrapv} on the command-line | |
18175 | results in @option{-ftrapv} being effective. | |
18176 | ||
d77de738 | 18177 | @opindex fwrapv-pointer |
ddf6fe37 | 18178 | @item -fwrapv-pointer |
d77de738 ML |
18179 | This option instructs the compiler to assume that pointer arithmetic |
18180 | overflow on addition and subtraction wraps around using twos-complement | |
18181 | representation. This flag disables some optimizations which assume | |
18182 | pointer overflow is invalid. | |
18183 | ||
d77de738 | 18184 | @opindex fstrict-overflow |
ddf6fe37 | 18185 | @item -fstrict-overflow |
d77de738 ML |
18186 | This option implies @option{-fno-wrapv} @option{-fno-wrapv-pointer} and when |
18187 | negated implies @option{-fwrapv} @option{-fwrapv-pointer}. | |
18188 | ||
d77de738 | 18189 | @opindex fexceptions |
ddf6fe37 | 18190 | @item -fexceptions |
d77de738 ML |
18191 | Enable exception handling. Generates extra code needed to propagate |
18192 | exceptions. For some targets, this implies GCC generates frame | |
18193 | unwind information for all functions, which can produce significant data | |
18194 | size overhead, although it does not affect execution. If you do not | |
18195 | specify this option, GCC enables it by default for languages like | |
18196 | C++ that normally require exception handling, and disables it for | |
18197 | languages like C that do not normally require it. However, you may need | |
18198 | to enable this option when compiling C code that needs to interoperate | |
18199 | properly with exception handlers written in C++. You may also wish to | |
18200 | disable this option if you are compiling older C++ programs that don't | |
18201 | use exception handling. | |
18202 | ||
d77de738 | 18203 | @opindex fnon-call-exceptions |
ddf6fe37 | 18204 | @item -fnon-call-exceptions |
d77de738 ML |
18205 | Generate code that allows trapping instructions to throw exceptions. |
18206 | Note that this requires platform-specific runtime support that does | |
18207 | not exist everywhere. Moreover, it only allows @emph{trapping} | |
18208 | instructions to throw exceptions, i.e.@: memory references or floating-point | |
18209 | instructions. It does not allow exceptions to be thrown from | |
18210 | arbitrary signal handlers such as @code{SIGALRM}. This enables | |
18211 | @option{-fexceptions}. | |
18212 | ||
d77de738 | 18213 | @opindex fdelete-dead-exceptions |
ddf6fe37 | 18214 | @item -fdelete-dead-exceptions |
d77de738 ML |
18215 | Consider that instructions that may throw exceptions but don't otherwise |
18216 | contribute to the execution of the program can be optimized away. | |
18217 | This does not affect calls to functions except those with the | |
18218 | @code{pure} or @code{const} attributes. | |
18219 | This option is enabled by default for the Ada and C++ compilers, as permitted by | |
18220 | the language specifications. | |
18221 | Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels. | |
18222 | ||
d77de738 | 18223 | @opindex funwind-tables |
ddf6fe37 | 18224 | @item -funwind-tables |
d77de738 ML |
18225 | Similar to @option{-fexceptions}, except that it just generates any needed |
18226 | static data, but does not affect the generated code in any other way. | |
18227 | You normally do not need to enable this option; instead, a language processor | |
18228 | that needs this handling enables it on your behalf. | |
18229 | ||
d77de738 | 18230 | @opindex fasynchronous-unwind-tables |
ddf6fe37 | 18231 | @item -fasynchronous-unwind-tables |
d77de738 ML |
18232 | Generate unwind table in DWARF format, if supported by target machine. The |
18233 | table is exact at each instruction boundary, so it can be used for stack | |
18234 | unwinding from asynchronous events (such as debugger or garbage collector). | |
18235 | ||
d77de738 ML |
18236 | @opindex fno-gnu-unique |
18237 | @opindex fgnu-unique | |
ddf6fe37 | 18238 | @item -fno-gnu-unique |
d77de738 ML |
18239 | On systems with recent GNU assembler and C library, the C++ compiler |
18240 | uses the @code{STB_GNU_UNIQUE} binding to make sure that definitions | |
18241 | of template static data members and static local variables in inline | |
18242 | functions are unique even in the presence of @code{RTLD_LOCAL}; this | |
18243 | is necessary to avoid problems with a library used by two different | |
18244 | @code{RTLD_LOCAL} plugins depending on a definition in one of them and | |
18245 | therefore disagreeing with the other one about the binding of the | |
18246 | symbol. But this causes @code{dlclose} to be ignored for affected | |
18247 | DSOs; if your program relies on reinitialization of a DSO via | |
18248 | @code{dlclose} and @code{dlopen}, you can use | |
18249 | @option{-fno-gnu-unique}. | |
18250 | ||
d77de738 | 18251 | @opindex fpcc-struct-return |
ddf6fe37 | 18252 | @item -fpcc-struct-return |
d77de738 ML |
18253 | Return ``short'' @code{struct} and @code{union} values in memory like |
18254 | longer ones, rather than in registers. This convention is less | |
18255 | efficient, but it has the advantage of allowing intercallability between | |
18256 | GCC-compiled files and files compiled with other compilers, particularly | |
18257 | the Portable C Compiler (pcc). | |
18258 | ||
18259 | The precise convention for returning structures in memory depends | |
18260 | on the target configuration macros. | |
18261 | ||
18262 | Short structures and unions are those whose size and alignment match | |
18263 | that of some integer type. | |
18264 | ||
18265 | @strong{Warning:} code compiled with the @option{-fpcc-struct-return} | |
18266 | switch is not binary compatible with code compiled with the | |
18267 | @option{-freg-struct-return} switch. | |
18268 | Use it to conform to a non-default application binary interface. | |
18269 | ||
d77de738 | 18270 | @opindex freg-struct-return |
ddf6fe37 | 18271 | @item -freg-struct-return |
d77de738 ML |
18272 | Return @code{struct} and @code{union} values in registers when possible. |
18273 | This is more efficient for small structures than | |
18274 | @option{-fpcc-struct-return}. | |
18275 | ||
18276 | If you specify neither @option{-fpcc-struct-return} nor | |
18277 | @option{-freg-struct-return}, GCC defaults to whichever convention is | |
18278 | standard for the target. If there is no standard convention, GCC | |
18279 | defaults to @option{-fpcc-struct-return}, except on targets where GCC is | |
18280 | the principal compiler. In those cases, we can choose the standard, and | |
18281 | we chose the more efficient register return alternative. | |
18282 | ||
18283 | @strong{Warning:} code compiled with the @option{-freg-struct-return} | |
18284 | switch is not binary compatible with code compiled with the | |
18285 | @option{-fpcc-struct-return} switch. | |
18286 | Use it to conform to a non-default application binary interface. | |
18287 | ||
d77de738 | 18288 | @opindex fshort-enums |
ddf6fe37 | 18289 | @item -fshort-enums |
d77de738 ML |
18290 | Allocate to an @code{enum} type only as many bytes as it needs for the |
18291 | declared range of possible values. Specifically, the @code{enum} type | |
18292 | is equivalent to the smallest integer type that has enough room. | |
18293 | ||
18294 | @strong{Warning:} the @option{-fshort-enums} switch causes GCC to generate | |
18295 | code that is not binary compatible with code generated without that switch. | |
18296 | Use it to conform to a non-default application binary interface. | |
18297 | ||
d77de738 | 18298 | @opindex fshort-wchar |
ddf6fe37 | 18299 | @item -fshort-wchar |
d77de738 ML |
18300 | Override the underlying type for @code{wchar_t} to be @code{short |
18301 | unsigned int} instead of the default for the target. This option is | |
18302 | useful for building programs to run under WINE@. | |
18303 | ||
18304 | @strong{Warning:} the @option{-fshort-wchar} switch causes GCC to generate | |
18305 | code that is not binary compatible with code generated without that switch. | |
18306 | Use it to conform to a non-default application binary interface. | |
18307 | ||
d77de738 ML |
18308 | @opindex fcommon |
18309 | @opindex fno-common | |
18310 | @cindex tentative definitions | |
f33d7a88 | 18311 | @item -fcommon |
d77de738 ML |
18312 | In C code, this option controls the placement of global variables |
18313 | defined without an initializer, known as @dfn{tentative definitions} | |
18314 | in the C standard. Tentative definitions are distinct from declarations | |
18315 | of a variable with the @code{extern} keyword, which do not allocate storage. | |
18316 | ||
18317 | The default is @option{-fno-common}, which specifies that the compiler places | |
18318 | uninitialized global variables in the BSS section of the object file. | |
18319 | This inhibits the merging of tentative definitions by the linker so you get a | |
18320 | multiple-definition error if the same variable is accidentally defined in more | |
18321 | than one compilation unit. | |
18322 | ||
18323 | The @option{-fcommon} places uninitialized global variables in a common block. | |
18324 | This allows the linker to resolve all tentative definitions of the same variable | |
18325 | in different compilation units to the same object, or to a non-tentative | |
18326 | definition. This behavior is inconsistent with C++, and on many targets implies | |
18327 | a speed and code size penalty on global variable references. It is mainly | |
18328 | useful to enable legacy code to link without errors. | |
18329 | ||
d77de738 ML |
18330 | @opindex fno-ident |
18331 | @opindex fident | |
ddf6fe37 | 18332 | @item -fno-ident |
d77de738 ML |
18333 | Ignore the @code{#ident} directive. |
18334 | ||
d77de738 | 18335 | @opindex finhibit-size-directive |
ddf6fe37 | 18336 | @item -finhibit-size-directive |
d77de738 ML |
18337 | Don't output a @code{.size} assembler directive, or anything else that |
18338 | would cause trouble if the function is split in the middle, and the | |
18339 | two halves are placed at locations far apart in memory. This option is | |
18340 | used when compiling @file{crtstuff.c}; you should not need to use it | |
18341 | for anything else. | |
18342 | ||
d77de738 | 18343 | @opindex fverbose-asm |
ddf6fe37 | 18344 | @item -fverbose-asm |
d77de738 ML |
18345 | Put extra commentary information in the generated assembly code to |
18346 | make it more readable. This option is generally only of use to those | |
18347 | who actually need to read the generated assembly code (perhaps while | |
18348 | debugging the compiler itself). | |
18349 | ||
18350 | @option{-fno-verbose-asm}, the default, causes the | |
18351 | extra information to be omitted and is useful when comparing two assembler | |
18352 | files. | |
18353 | ||
18354 | The added comments include: | |
18355 | ||
18356 | @itemize @bullet | |
18357 | ||
18358 | @item | |
18359 | information on the compiler version and command-line options, | |
18360 | ||
18361 | @item | |
18362 | the source code lines associated with the assembly instructions, | |
18363 | in the form FILENAME:LINENUMBER:CONTENT OF LINE, | |
18364 | ||
18365 | @item | |
18366 | hints on which high-level expressions correspond to | |
18367 | the various assembly instruction operands. | |
18368 | ||
18369 | @end itemize | |
18370 | ||
18371 | For example, given this C source file: | |
18372 | ||
18373 | @smallexample | |
18374 | int test (int n) | |
18375 | @{ | |
18376 | int i; | |
18377 | int total = 0; | |
18378 | ||
18379 | for (i = 0; i < n; i++) | |
18380 | total += i * i; | |
18381 | ||
18382 | return total; | |
18383 | @} | |
18384 | @end smallexample | |
18385 | ||
18386 | compiling to (x86_64) assembly via @option{-S} and emitting the result | |
18387 | direct to stdout via @option{-o} @option{-} | |
18388 | ||
18389 | @smallexample | |
18390 | gcc -S test.c -fverbose-asm -Os -o - | |
18391 | @end smallexample | |
18392 | ||
18393 | gives output similar to this: | |
18394 | ||
18395 | @smallexample | |
18396 | .file "test.c" | |
18397 | # GNU C11 (GCC) version 7.0.0 20160809 (experimental) (x86_64-pc-linux-gnu) | |
18398 | [...snip...] | |
18399 | # options passed: | |
18400 | [...snip...] | |
18401 | ||
18402 | .text | |
18403 | .globl test | |
18404 | .type test, @@function | |
18405 | test: | |
18406 | .LFB0: | |
18407 | .cfi_startproc | |
18408 | # test.c:4: int total = 0; | |
18409 | xorl %eax, %eax # <retval> | |
18410 | # test.c:6: for (i = 0; i < n; i++) | |
18411 | xorl %edx, %edx # i | |
18412 | .L2: | |
18413 | # test.c:6: for (i = 0; i < n; i++) | |
18414 | cmpl %edi, %edx # n, i | |
18415 | jge .L5 #, | |
18416 | # test.c:7: total += i * i; | |
18417 | movl %edx, %ecx # i, tmp92 | |
18418 | imull %edx, %ecx # i, tmp92 | |
18419 | # test.c:6: for (i = 0; i < n; i++) | |
18420 | incl %edx # i | |
18421 | # test.c:7: total += i * i; | |
18422 | addl %ecx, %eax # tmp92, <retval> | |
18423 | jmp .L2 # | |
18424 | .L5: | |
18425 | # test.c:10: @} | |
18426 | ret | |
18427 | .cfi_endproc | |
18428 | .LFE0: | |
18429 | .size test, .-test | |
18430 | .ident "GCC: (GNU) 7.0.0 20160809 (experimental)" | |
18431 | .section .note.GNU-stack,"",@@progbits | |
18432 | @end smallexample | |
18433 | ||
18434 | The comments are intended for humans rather than machines and hence the | |
18435 | precise format of the comments is subject to change. | |
18436 | ||
d77de738 | 18437 | @opindex frecord-gcc-switches |
ddf6fe37 | 18438 | @item -frecord-gcc-switches |
d77de738 ML |
18439 | This switch causes the command line used to invoke the |
18440 | compiler to be recorded into the object file that is being created. | |
18441 | This switch is only implemented on some targets and the exact format | |
18442 | of the recording is target and binary file format dependent, but it | |
18443 | usually takes the form of a section containing ASCII text. This | |
18444 | switch is related to the @option{-fverbose-asm} switch, but that | |
18445 | switch only records information in the assembler output file as | |
18446 | comments, so it never reaches the object file. | |
18447 | See also @option{-grecord-gcc-switches} for another | |
18448 | way of storing compiler options into the object file. | |
18449 | ||
d77de738 ML |
18450 | @opindex fpic |
18451 | @cindex global offset table | |
18452 | @cindex PIC | |
f33d7a88 | 18453 | @item -fpic |
d77de738 ML |
18454 | Generate position-independent code (PIC) suitable for use in a shared |
18455 | library, if supported for the target machine. Such code accesses all | |
18456 | constant addresses through a global offset table (GOT)@. The dynamic | |
18457 | loader resolves the GOT entries when the program starts (the dynamic | |
18458 | loader is not part of GCC; it is part of the operating system). If | |
18459 | the GOT size for the linked executable exceeds a machine-specific | |
18460 | maximum size, you get an error message from the linker indicating that | |
18461 | @option{-fpic} does not work; in that case, recompile with @option{-fPIC} | |
18462 | instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k | |
18463 | on the m68k and RS/6000. The x86 has no such limit.) | |
18464 | ||
18465 | Position-independent code requires special support, and therefore works | |
18466 | only on certain machines. For the x86, GCC supports PIC for System V | |
18467 | but not for the Sun 386i. Code generated for the IBM RS/6000 is always | |
18468 | position-independent. | |
18469 | ||
18470 | When this flag is set, the macros @code{__pic__} and @code{__PIC__} | |
18471 | are defined to 1. | |
18472 | ||
d77de738 | 18473 | @opindex fPIC |
ddf6fe37 | 18474 | @item -fPIC |
d77de738 ML |
18475 | If supported for the target machine, emit position-independent code, |
18476 | suitable for dynamic linking and avoiding any limit on the size of the | |
18477 | global offset table. This option makes a difference on AArch64, m68k, | |
18478 | PowerPC and SPARC@. | |
18479 | ||
18480 | Position-independent code requires special support, and therefore works | |
18481 | only on certain machines. | |
18482 | ||
18483 | When this flag is set, the macros @code{__pic__} and @code{__PIC__} | |
18484 | are defined to 2. | |
18485 | ||
d77de738 ML |
18486 | @opindex fpie |
18487 | @opindex fPIE | |
ddf6fe37 AA |
18488 | @item -fpie |
18489 | @itemx -fPIE | |
d77de738 ML |
18490 | These options are similar to @option{-fpic} and @option{-fPIC}, but the |
18491 | generated position-independent code can be only linked into executables. | |
18492 | Usually these options are used to compile code that will be linked using | |
18493 | the @option{-pie} GCC option. | |
18494 | ||
18495 | @option{-fpie} and @option{-fPIE} both define the macros | |
18496 | @code{__pie__} and @code{__PIE__}. The macros have the value 1 | |
18497 | for @option{-fpie} and 2 for @option{-fPIE}. | |
18498 | ||
d77de738 ML |
18499 | @opindex fno-plt |
18500 | @opindex fplt | |
ddf6fe37 | 18501 | @item -fno-plt |
d77de738 ML |
18502 | Do not use the PLT for external function calls in position-independent code. |
18503 | Instead, load the callee address at call sites from the GOT and branch to it. | |
18504 | This leads to more efficient code by eliminating PLT stubs and exposing | |
18505 | GOT loads to optimizations. On architectures such as 32-bit x86 where | |
18506 | PLT stubs expect the GOT pointer in a specific register, this gives more | |
18507 | register allocation freedom to the compiler. | |
18508 | Lazy binding requires use of the PLT; | |
18509 | with @option{-fno-plt} all external symbols are resolved at load time. | |
18510 | ||
18511 | Alternatively, the function attribute @code{noplt} can be used to avoid calls | |
18512 | through the PLT for specific external functions. | |
18513 | ||
18514 | In position-dependent code, a few targets also convert calls to | |
18515 | functions that are marked to not use the PLT to use the GOT instead. | |
18516 | ||
d77de738 ML |
18517 | @opindex fno-jump-tables |
18518 | @opindex fjump-tables | |
ddf6fe37 | 18519 | @item -fno-jump-tables |
d77de738 ML |
18520 | Do not use jump tables for switch statements even where it would be |
18521 | more efficient than other code generation strategies. This option is | |
18522 | of use in conjunction with @option{-fpic} or @option{-fPIC} for | |
18523 | building code that forms part of a dynamic linker and cannot | |
18524 | reference the address of a jump table. On some targets, jump tables | |
18525 | do not require a GOT and this option is not needed. | |
18526 | ||
d77de738 ML |
18527 | @opindex fno-bit-tests |
18528 | @opindex fbit-tests | |
ddf6fe37 | 18529 | @item -fno-bit-tests |
d77de738 ML |
18530 | Do not use bit tests for switch statements even where it would be |
18531 | more efficient than other code generation strategies. | |
18532 | ||
d77de738 | 18533 | @opindex ffixed |
ddf6fe37 | 18534 | @item -ffixed-@var{reg} |
d77de738 ML |
18535 | Treat the register named @var{reg} as a fixed register; generated code |
18536 | should never refer to it (except perhaps as a stack pointer, frame | |
18537 | pointer or in some other fixed role). | |
18538 | ||
18539 | @var{reg} must be the name of a register. The register names accepted | |
18540 | are machine-specific and are defined in the @code{REGISTER_NAMES} | |
18541 | macro in the machine description macro file. | |
18542 | ||
18543 | This flag does not have a negative form, because it specifies a | |
18544 | three-way choice. | |
18545 | ||
d77de738 | 18546 | @opindex fcall-used |
ddf6fe37 | 18547 | @item -fcall-used-@var{reg} |
d77de738 ML |
18548 | Treat the register named @var{reg} as an allocable register that is |
18549 | clobbered by function calls. It may be allocated for temporaries or | |
18550 | variables that do not live across a call. Functions compiled this way | |
18551 | do not save and restore the register @var{reg}. | |
18552 | ||
18553 | It is an error to use this flag with the frame pointer or stack pointer. | |
18554 | Use of this flag for other registers that have fixed pervasive roles in | |
18555 | the machine's execution model produces disastrous results. | |
18556 | ||
18557 | This flag does not have a negative form, because it specifies a | |
18558 | three-way choice. | |
18559 | ||
d77de738 | 18560 | @opindex fcall-saved |
ddf6fe37 | 18561 | @item -fcall-saved-@var{reg} |
d77de738 ML |
18562 | Treat the register named @var{reg} as an allocable register saved by |
18563 | functions. It may be allocated even for temporaries or variables that | |
18564 | live across a call. Functions compiled this way save and restore | |
18565 | the register @var{reg} if they use it. | |
18566 | ||
18567 | It is an error to use this flag with the frame pointer or stack pointer. | |
18568 | Use of this flag for other registers that have fixed pervasive roles in | |
18569 | the machine's execution model produces disastrous results. | |
18570 | ||
18571 | A different sort of disaster results from the use of this flag for | |
18572 | a register in which function values may be returned. | |
18573 | ||
18574 | This flag does not have a negative form, because it specifies a | |
18575 | three-way choice. | |
18576 | ||
d77de738 | 18577 | @opindex fpack-struct |
ddf6fe37 | 18578 | @item -fpack-struct[=@var{n}] |
d77de738 ML |
18579 | Without a value specified, pack all structure members together without |
18580 | holes. When a value is specified (which must be a small power of two), pack | |
18581 | structure members according to this value, representing the maximum | |
18582 | alignment (that is, objects with default alignment requirements larger than | |
18583 | this are output potentially unaligned at the next fitting location. | |
18584 | ||
18585 | @strong{Warning:} the @option{-fpack-struct} switch causes GCC to generate | |
18586 | code that is not binary compatible with code generated without that switch. | |
18587 | Additionally, it makes the code suboptimal. | |
18588 | Use it to conform to a non-default application binary interface. | |
18589 | ||
d77de738 | 18590 | @opindex fleading-underscore |
ddf6fe37 | 18591 | @item -fleading-underscore |
d77de738 ML |
18592 | This option and its counterpart, @option{-fno-leading-underscore}, forcibly |
18593 | change the way C symbols are represented in the object file. One use | |
18594 | is to help link with legacy assembly code. | |
18595 | ||
18596 | @strong{Warning:} the @option{-fleading-underscore} switch causes GCC to | |
18597 | generate code that is not binary compatible with code generated without that | |
18598 | switch. Use it to conform to a non-default application binary interface. | |
18599 | Not all targets provide complete support for this switch. | |
18600 | ||
d77de738 | 18601 | @opindex ftls-model |
ddf6fe37 | 18602 | @item -ftls-model=@var{model} |
d77de738 ML |
18603 | Alter the thread-local storage model to be used (@pxref{Thread-Local}). |
18604 | The @var{model} argument should be one of @samp{global-dynamic}, | |
18605 | @samp{local-dynamic}, @samp{initial-exec} or @samp{local-exec}. | |
18606 | Note that the choice is subject to optimization: the compiler may use | |
18607 | a more efficient model for symbols not visible outside of the translation | |
18608 | unit, or if @option{-fpic} is not given on the command line. | |
18609 | ||
18610 | The default without @option{-fpic} is @samp{initial-exec}; with | |
18611 | @option{-fpic} the default is @samp{global-dynamic}. | |
18612 | ||
d77de738 | 18613 | @opindex ftrampolines |
ddf6fe37 | 18614 | @item -ftrampolines |
d77de738 ML |
18615 | For targets that normally need trampolines for nested functions, always |
18616 | generate them instead of using descriptors. Otherwise, for targets that | |
18617 | do not need them, like for example HP-PA or IA-64, do nothing. | |
18618 | ||
18619 | A trampoline is a small piece of code that is created at run time on the | |
18620 | stack when the address of a nested function is taken, and is used to call | |
18621 | the nested function indirectly. Therefore, it requires the stack to be | |
18622 | made executable in order for the program to work properly. | |
18623 | ||
18624 | @option{-fno-trampolines} is enabled by default on a language by language | |
18625 | basis to let the compiler avoid generating them, if it computes that this | |
18626 | is safe, and replace them with descriptors. Descriptors are made up of data | |
18627 | only, but the generated code must be prepared to deal with them. As of this | |
18628 | writing, @option{-fno-trampolines} is enabled by default only for Ada. | |
18629 | ||
18630 | Moreover, code compiled with @option{-ftrampolines} and code compiled with | |
18631 | @option{-fno-trampolines} are not binary compatible if nested functions are | |
18632 | present. This option must therefore be used on a program-wide basis and be | |
18633 | manipulated with extreme care. | |
18634 | ||
18635 | For languages other than Ada, the @code{-ftrampolines} and | |
18636 | @code{-fno-trampolines} options currently have no effect, and | |
18637 | trampolines are always generated on platforms that need them | |
18638 | for nested functions. | |
18639 | ||
d77de738 | 18640 | @opindex fvisibility |
ddf6fe37 | 18641 | @item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} |
d77de738 ML |
18642 | Set the default ELF image symbol visibility to the specified option---all |
18643 | symbols are marked with this unless overridden within the code. | |
18644 | Using this feature can very substantially improve linking and | |
18645 | load times of shared object libraries, produce more optimized | |
18646 | code, provide near-perfect API export and prevent symbol clashes. | |
18647 | It is @strong{strongly} recommended that you use this in any shared objects | |
18648 | you distribute. | |
18649 | ||
18650 | Despite the nomenclature, @samp{default} always means public; i.e., | |
18651 | available to be linked against from outside the shared object. | |
18652 | @samp{protected} and @samp{internal} are pretty useless in real-world | |
18653 | usage so the only other commonly used option is @samp{hidden}. | |
18654 | The default if @option{-fvisibility} isn't specified is | |
18655 | @samp{default}, i.e., make every symbol public. | |
18656 | ||
18657 | A good explanation of the benefits offered by ensuring ELF | |
18658 | symbols have the correct visibility is given by ``How To Write | |
18659 | Shared Libraries'' by Ulrich Drepper (which can be found at | |
18660 | @w{@uref{https://www.akkadia.org/drepper/}})---however a superior | |
18661 | solution made possible by this option to marking things hidden when | |
18662 | the default is public is to make the default hidden and mark things | |
18663 | public. This is the norm with DLLs on Windows and with @option{-fvisibility=hidden} | |
18664 | and @code{__attribute__ ((visibility("default")))} instead of | |
18665 | @code{__declspec(dllexport)} you get almost identical semantics with | |
18666 | identical syntax. This is a great boon to those working with | |
18667 | cross-platform projects. | |
18668 | ||
18669 | For those adding visibility support to existing code, you may find | |
18670 | @code{#pragma GCC visibility} of use. This works by you enclosing | |
18671 | the declarations you wish to set visibility for with (for example) | |
18672 | @code{#pragma GCC visibility push(hidden)} and | |
18673 | @code{#pragma GCC visibility pop}. | |
18674 | Bear in mind that symbol visibility should be viewed @strong{as | |
18675 | part of the API interface contract} and thus all new code should | |
18676 | always specify visibility when it is not the default; i.e., declarations | |
18677 | only for use within the local DSO should @strong{always} be marked explicitly | |
18678 | as hidden as so to avoid PLT indirection overheads---making this | |
18679 | abundantly clear also aids readability and self-documentation of the code. | |
18680 | Note that due to ISO C++ specification requirements, @code{operator new} and | |
18681 | @code{operator delete} must always be of default visibility. | |
18682 | ||
18683 | Be aware that headers from outside your project, in particular system | |
18684 | headers and headers from any other library you use, may not be | |
18685 | expecting to be compiled with visibility other than the default. You | |
18686 | may need to explicitly say @code{#pragma GCC visibility push(default)} | |
18687 | before including any such headers. | |
18688 | ||
18689 | @code{extern} declarations are not affected by @option{-fvisibility}, so | |
18690 | a lot of code can be recompiled with @option{-fvisibility=hidden} with | |
18691 | no modifications. However, this means that calls to @code{extern} | |
18692 | functions with no explicit visibility use the PLT, so it is more | |
18693 | effective to use @code{__attribute ((visibility))} and/or | |
18694 | @code{#pragma GCC visibility} to tell the compiler which @code{extern} | |
18695 | declarations should be treated as hidden. | |
18696 | ||
18697 | Note that @option{-fvisibility} does affect C++ vague linkage | |
18698 | entities. This means that, for instance, an exception class that is | |
18699 | be thrown between DSOs must be explicitly marked with default | |
18700 | visibility so that the @samp{type_info} nodes are unified between | |
18701 | the DSOs. | |
18702 | ||
18703 | An overview of these techniques, their benefits and how to use them | |
18704 | is at @uref{https://gcc.gnu.org/@/wiki/@/Visibility}. | |
18705 | ||
d77de738 | 18706 | @opindex fstrict-volatile-bitfields |
ddf6fe37 | 18707 | @item -fstrict-volatile-bitfields |
d77de738 ML |
18708 | This option should be used if accesses to volatile bit-fields (or other |
18709 | structure fields, although the compiler usually honors those types | |
18710 | anyway) should use a single access of the width of the | |
18711 | field's type, aligned to a natural alignment if possible. For | |
18712 | example, targets with memory-mapped peripheral registers might require | |
18713 | all such accesses to be 16 bits wide; with this flag you can | |
18714 | declare all peripheral bit-fields as @code{unsigned short} (assuming short | |
18715 | is 16 bits on these targets) to force GCC to use 16-bit accesses | |
18716 | instead of, perhaps, a more efficient 32-bit access. | |
18717 | ||
18718 | If this option is disabled, the compiler uses the most efficient | |
18719 | instruction. In the previous example, that might be a 32-bit load | |
18720 | instruction, even though that accesses bytes that do not contain | |
18721 | any portion of the bit-field, or memory-mapped registers unrelated to | |
18722 | the one being updated. | |
18723 | ||
18724 | In some cases, such as when the @code{packed} attribute is applied to a | |
18725 | structure field, it may not be possible to access the field with a single | |
18726 | read or write that is correctly aligned for the target machine. In this | |
18727 | case GCC falls back to generating multiple accesses rather than code that | |
18728 | will fault or truncate the result at run time. | |
18729 | ||
18730 | Note: Due to restrictions of the C/C++11 memory model, write accesses are | |
18731 | not allowed to touch non bit-field members. It is therefore recommended | |
18732 | to define all bits of the field's type as bit-field members. | |
18733 | ||
18734 | The default value of this option is determined by the application binary | |
18735 | interface for the target processor. | |
18736 | ||
d77de738 | 18737 | @opindex fsync-libcalls |
ddf6fe37 | 18738 | @item -fsync-libcalls |
d77de738 ML |
18739 | This option controls whether any out-of-line instance of the @code{__sync} |
18740 | family of functions may be used to implement the C++11 @code{__atomic} | |
18741 | family of functions. | |
18742 | ||
18743 | The default value of this option is enabled, thus the only useful form | |
18744 | of the option is @option{-fno-sync-libcalls}. This option is used in | |
18745 | the implementation of the @file{libatomic} runtime library. | |
18746 | ||
18747 | @end table | |
18748 | ||
18749 | @node Developer Options | |
18750 | @section GCC Developer Options | |
18751 | @cindex developer options | |
18752 | @cindex debugging GCC | |
18753 | @cindex debug dump options | |
18754 | @cindex dump options | |
18755 | @cindex compilation statistics | |
18756 | ||
18757 | This section describes command-line options that are primarily of | |
18758 | interest to GCC developers, including options to support compiler | |
18759 | testing and investigation of compiler bugs and compile-time | |
18760 | performance problems. This includes options that produce debug dumps | |
18761 | at various points in the compilation; that print statistics such as | |
18762 | memory use and execution time; and that print information about GCC's | |
18763 | configuration, such as where it searches for libraries. You should | |
18764 | rarely need to use any of these options for ordinary compilation and | |
18765 | linking tasks. | |
18766 | ||
18767 | Many developer options that cause GCC to dump output to a file take an | |
18768 | optional @samp{=@var{filename}} suffix. You can specify @samp{stdout} | |
18769 | or @samp{-} to dump to standard output, and @samp{stderr} for standard | |
18770 | error. | |
18771 | ||
18772 | If @samp{=@var{filename}} is omitted, a default dump file name is | |
18773 | constructed by concatenating the base dump file name, a pass number, | |
18774 | phase letter, and pass name. The base dump file name is the name of | |
18775 | output file produced by the compiler if explicitly specified and not | |
18776 | an executable; otherwise it is the source file name. | |
18777 | The pass number is determined by the order passes are registered with | |
18778 | the compiler's pass manager. | |
18779 | This is generally the same as the order of execution, but passes | |
18780 | registered by plugins, target-specific passes, or passes that are | |
18781 | otherwise registered late are numbered higher than the pass named | |
18782 | @samp{final}, even if they are executed earlier. The phase letter is | |
18783 | one of @samp{i} (inter-procedural analysis), @samp{l} | |
18784 | (language-specific), @samp{r} (RTL), or @samp{t} (tree). | |
18785 | The files are created in the directory of the output file. | |
18786 | ||
18787 | @table @gcctabopt | |
18788 | ||
ddf6fe37 | 18789 | @opindex fcallgraph-info |
d77de738 ML |
18790 | @item -fcallgraph-info |
18791 | @itemx -fcallgraph-info=@var{MARKERS} | |
d77de738 ML |
18792 | Makes the compiler output callgraph information for the program, on a |
18793 | per-object-file basis. The information is generated in the common VCG | |
18794 | format. It can be decorated with additional, per-node and/or per-edge | |
18795 | information, if a list of comma-separated markers is additionally | |
18796 | specified. When the @code{su} marker is specified, the callgraph is | |
18797 | decorated with stack usage information; it is equivalent to | |
18798 | @option{-fstack-usage}. When the @code{da} marker is specified, the | |
18799 | callgraph is decorated with information about dynamically allocated | |
18800 | objects. | |
18801 | ||
18802 | When compiling with @option{-flto}, no callgraph information is output | |
18803 | along with the object file. At LTO link time, @option{-fcallgraph-info} | |
18804 | may generate multiple callgraph information files next to intermediate | |
18805 | LTO output files. | |
18806 | ||
ddf6fe37 AA |
18807 | @opindex d |
18808 | @opindex fdump-rtl-@var{pass} | |
d77de738 ML |
18809 | @item -d@var{letters} |
18810 | @itemx -fdump-rtl-@var{pass} | |
18811 | @itemx -fdump-rtl-@var{pass}=@var{filename} | |
d77de738 ML |
18812 | Says to make debugging dumps during compilation at times specified by |
18813 | @var{letters}. This is used for debugging the RTL-based passes of the | |
18814 | compiler. | |
18815 | ||
18816 | Some @option{-d@var{letters}} switches have different meaning when | |
18817 | @option{-E} is used for preprocessing. @xref{Preprocessor Options}, | |
18818 | for information about preprocessor-specific dump options. | |
18819 | ||
18820 | Debug dumps can be enabled with a @option{-fdump-rtl} switch or some | |
18821 | @option{-d} option @var{letters}. Here are the possible | |
18822 | letters for use in @var{pass} and @var{letters}, and their meanings: | |
18823 | ||
18824 | @table @gcctabopt | |
18825 | ||
d77de738 | 18826 | @opindex fdump-rtl-alignments |
ddf6fe37 | 18827 | @item -fdump-rtl-alignments |
d77de738 ML |
18828 | Dump after branch alignments have been computed. |
18829 | ||
d77de738 | 18830 | @opindex fdump-rtl-asmcons |
ddf6fe37 | 18831 | @item -fdump-rtl-asmcons |
d77de738 ML |
18832 | Dump after fixing rtl statements that have unsatisfied in/out constraints. |
18833 | ||
d77de738 | 18834 | @opindex fdump-rtl-auto_inc_dec |
ddf6fe37 | 18835 | @item -fdump-rtl-auto_inc_dec |
d77de738 ML |
18836 | Dump after auto-inc-dec discovery. This pass is only run on |
18837 | architectures that have auto inc or auto dec instructions. | |
18838 | ||
d77de738 | 18839 | @opindex fdump-rtl-barriers |
ddf6fe37 | 18840 | @item -fdump-rtl-barriers |
d77de738 ML |
18841 | Dump after cleaning up the barrier instructions. |
18842 | ||
d77de738 | 18843 | @opindex fdump-rtl-bbpart |
ddf6fe37 | 18844 | @item -fdump-rtl-bbpart |
d77de738 ML |
18845 | Dump after partitioning hot and cold basic blocks. |
18846 | ||
d77de738 | 18847 | @opindex fdump-rtl-bbro |
ddf6fe37 | 18848 | @item -fdump-rtl-bbro |
d77de738 ML |
18849 | Dump after block reordering. |
18850 | ||
d77de738 ML |
18851 | @opindex fdump-rtl-btl2 |
18852 | @opindex fdump-rtl-btl2 | |
ddf6fe37 AA |
18853 | @item -fdump-rtl-btl1 |
18854 | @itemx -fdump-rtl-btl2 | |
d77de738 ML |
18855 | @option{-fdump-rtl-btl1} and @option{-fdump-rtl-btl2} enable dumping |
18856 | after the two branch | |
18857 | target load optimization passes. | |
18858 | ||
d77de738 | 18859 | @opindex fdump-rtl-bypass |
ddf6fe37 | 18860 | @item -fdump-rtl-bypass |
d77de738 ML |
18861 | Dump after jump bypassing and control flow optimizations. |
18862 | ||
d77de738 | 18863 | @opindex fdump-rtl-combine |
ddf6fe37 | 18864 | @item -fdump-rtl-combine |
d77de738 ML |
18865 | Dump after the RTL instruction combination pass. |
18866 | ||
d77de738 | 18867 | @opindex fdump-rtl-compgotos |
ddf6fe37 | 18868 | @item -fdump-rtl-compgotos |
d77de738 ML |
18869 | Dump after duplicating the computed gotos. |
18870 | ||
d77de738 ML |
18871 | @opindex fdump-rtl-ce1 |
18872 | @opindex fdump-rtl-ce2 | |
18873 | @opindex fdump-rtl-ce3 | |
ddf6fe37 AA |
18874 | @item -fdump-rtl-ce1 |
18875 | @itemx -fdump-rtl-ce2 | |
18876 | @itemx -fdump-rtl-ce3 | |
d77de738 ML |
18877 | @option{-fdump-rtl-ce1}, @option{-fdump-rtl-ce2}, and |
18878 | @option{-fdump-rtl-ce3} enable dumping after the three | |
18879 | if conversion passes. | |
18880 | ||
d77de738 | 18881 | @opindex fdump-rtl-cprop_hardreg |
ddf6fe37 | 18882 | @item -fdump-rtl-cprop_hardreg |
d77de738 ML |
18883 | Dump after hard register copy propagation. |
18884 | ||
d77de738 | 18885 | @opindex fdump-rtl-csa |
ddf6fe37 | 18886 | @item -fdump-rtl-csa |
d77de738 ML |
18887 | Dump after combining stack adjustments. |
18888 | ||
d77de738 ML |
18889 | @opindex fdump-rtl-cse1 |
18890 | @opindex fdump-rtl-cse2 | |
ddf6fe37 AA |
18891 | @item -fdump-rtl-cse1 |
18892 | @itemx -fdump-rtl-cse2 | |
d77de738 ML |
18893 | @option{-fdump-rtl-cse1} and @option{-fdump-rtl-cse2} enable dumping after |
18894 | the two common subexpression elimination passes. | |
18895 | ||
d77de738 | 18896 | @opindex fdump-rtl-dce |
ddf6fe37 | 18897 | @item -fdump-rtl-dce |
d77de738 ML |
18898 | Dump after the standalone dead code elimination passes. |
18899 | ||
d77de738 | 18900 | @opindex fdump-rtl-dbr |
ddf6fe37 | 18901 | @item -fdump-rtl-dbr |
d77de738 ML |
18902 | Dump after delayed branch scheduling. |
18903 | ||
d77de738 ML |
18904 | @opindex fdump-rtl-dce1 |
18905 | @opindex fdump-rtl-dce2 | |
ddf6fe37 AA |
18906 | @item -fdump-rtl-dce1 |
18907 | @itemx -fdump-rtl-dce2 | |
d77de738 ML |
18908 | @option{-fdump-rtl-dce1} and @option{-fdump-rtl-dce2} enable dumping after |
18909 | the two dead store elimination passes. | |
18910 | ||
d77de738 | 18911 | @opindex fdump-rtl-eh |
ddf6fe37 | 18912 | @item -fdump-rtl-eh |
d77de738 ML |
18913 | Dump after finalization of EH handling code. |
18914 | ||
d77de738 | 18915 | @opindex fdump-rtl-eh_ranges |
ddf6fe37 | 18916 | @item -fdump-rtl-eh_ranges |
d77de738 ML |
18917 | Dump after conversion of EH handling range regions. |
18918 | ||
d77de738 | 18919 | @opindex fdump-rtl-expand |
ddf6fe37 | 18920 | @item -fdump-rtl-expand |
d77de738 ML |
18921 | Dump after RTL generation. |
18922 | ||
d77de738 ML |
18923 | @opindex fdump-rtl-fwprop1 |
18924 | @opindex fdump-rtl-fwprop2 | |
ddf6fe37 AA |
18925 | @item -fdump-rtl-fwprop1 |
18926 | @itemx -fdump-rtl-fwprop2 | |
d77de738 ML |
18927 | @option{-fdump-rtl-fwprop1} and @option{-fdump-rtl-fwprop2} enable |
18928 | dumping after the two forward propagation passes. | |
18929 | ||
d77de738 ML |
18930 | @opindex fdump-rtl-gcse1 |
18931 | @opindex fdump-rtl-gcse2 | |
ddf6fe37 AA |
18932 | @item -fdump-rtl-gcse1 |
18933 | @itemx -fdump-rtl-gcse2 | |
d77de738 ML |
18934 | @option{-fdump-rtl-gcse1} and @option{-fdump-rtl-gcse2} enable dumping |
18935 | after global common subexpression elimination. | |
18936 | ||
d77de738 | 18937 | @opindex fdump-rtl-init-regs |
ddf6fe37 | 18938 | @item -fdump-rtl-init-regs |
d77de738 ML |
18939 | Dump after the initialization of the registers. |
18940 | ||
d77de738 | 18941 | @opindex fdump-rtl-initvals |
ddf6fe37 | 18942 | @item -fdump-rtl-initvals |
d77de738 ML |
18943 | Dump after the computation of the initial value sets. |
18944 | ||
d77de738 | 18945 | @opindex fdump-rtl-into_cfglayout |
ddf6fe37 | 18946 | @item -fdump-rtl-into_cfglayout |
d77de738 ML |
18947 | Dump after converting to cfglayout mode. |
18948 | ||
d77de738 | 18949 | @opindex fdump-rtl-ira |
ddf6fe37 | 18950 | @item -fdump-rtl-ira |
d77de738 ML |
18951 | Dump after iterated register allocation. |
18952 | ||
d77de738 | 18953 | @opindex fdump-rtl-jump |
ddf6fe37 | 18954 | @item -fdump-rtl-jump |
d77de738 ML |
18955 | Dump after the second jump optimization. |
18956 | ||
d77de738 | 18957 | @opindex fdump-rtl-loop2 |
ddf6fe37 | 18958 | @item -fdump-rtl-loop2 |
d77de738 ML |
18959 | @option{-fdump-rtl-loop2} enables dumping after the rtl |
18960 | loop optimization passes. | |
18961 | ||
d77de738 | 18962 | @opindex fdump-rtl-mach |
ddf6fe37 | 18963 | @item -fdump-rtl-mach |
d77de738 ML |
18964 | Dump after performing the machine dependent reorganization pass, if that |
18965 | pass exists. | |
18966 | ||
d77de738 | 18967 | @opindex fdump-rtl-mode_sw |
ddf6fe37 | 18968 | @item -fdump-rtl-mode_sw |
d77de738 ML |
18969 | Dump after removing redundant mode switches. |
18970 | ||
d77de738 | 18971 | @opindex fdump-rtl-rnreg |
ddf6fe37 | 18972 | @item -fdump-rtl-rnreg |
d77de738 ML |
18973 | Dump after register renumbering. |
18974 | ||
d77de738 | 18975 | @opindex fdump-rtl-outof_cfglayout |
ddf6fe37 | 18976 | @item -fdump-rtl-outof_cfglayout |
d77de738 ML |
18977 | Dump after converting from cfglayout mode. |
18978 | ||
d77de738 | 18979 | @opindex fdump-rtl-peephole2 |
ddf6fe37 | 18980 | @item -fdump-rtl-peephole2 |
d77de738 ML |
18981 | Dump after the peephole pass. |
18982 | ||
d77de738 | 18983 | @opindex fdump-rtl-postreload |
ddf6fe37 | 18984 | @item -fdump-rtl-postreload |
d77de738 ML |
18985 | Dump after post-reload optimizations. |
18986 | ||
d77de738 | 18987 | @opindex fdump-rtl-pro_and_epilogue |
ddf6fe37 | 18988 | @item -fdump-rtl-pro_and_epilogue |
d77de738 ML |
18989 | Dump after generating the function prologues and epilogues. |
18990 | ||
d77de738 ML |
18991 | @opindex fdump-rtl-sched1 |
18992 | @opindex fdump-rtl-sched2 | |
ddf6fe37 AA |
18993 | @item -fdump-rtl-sched1 |
18994 | @itemx -fdump-rtl-sched2 | |
d77de738 ML |
18995 | @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2} enable dumping |
18996 | after the basic block scheduling passes. | |
18997 | ||
d77de738 | 18998 | @opindex fdump-rtl-ree |
ddf6fe37 | 18999 | @item -fdump-rtl-ree |
d77de738 ML |
19000 | Dump after sign/zero extension elimination. |
19001 | ||
d77de738 | 19002 | @opindex fdump-rtl-seqabstr |
ddf6fe37 | 19003 | @item -fdump-rtl-seqabstr |
d77de738 ML |
19004 | Dump after common sequence discovery. |
19005 | ||
d77de738 | 19006 | @opindex fdump-rtl-shorten |
ddf6fe37 | 19007 | @item -fdump-rtl-shorten |
d77de738 ML |
19008 | Dump after shortening branches. |
19009 | ||
d77de738 | 19010 | @opindex fdump-rtl-sibling |
ddf6fe37 | 19011 | @item -fdump-rtl-sibling |
d77de738 ML |
19012 | Dump after sibling call optimizations. |
19013 | ||
d77de738 ML |
19014 | @opindex fdump-rtl-split1 |
19015 | @opindex fdump-rtl-split2 | |
19016 | @opindex fdump-rtl-split3 | |
19017 | @opindex fdump-rtl-split4 | |
19018 | @opindex fdump-rtl-split5 | |
ddf6fe37 AA |
19019 | @item -fdump-rtl-split1 |
19020 | @itemx -fdump-rtl-split2 | |
19021 | @itemx -fdump-rtl-split3 | |
19022 | @itemx -fdump-rtl-split4 | |
19023 | @itemx -fdump-rtl-split5 | |
d77de738 ML |
19024 | These options enable dumping after five rounds of |
19025 | instruction splitting. | |
19026 | ||
d77de738 | 19027 | @opindex fdump-rtl-sms |
ddf6fe37 | 19028 | @item -fdump-rtl-sms |
d77de738 ML |
19029 | Dump after modulo scheduling. This pass is only run on some |
19030 | architectures. | |
19031 | ||
d77de738 | 19032 | @opindex fdump-rtl-stack |
ddf6fe37 | 19033 | @item -fdump-rtl-stack |
d77de738 ML |
19034 | Dump after conversion from GCC's ``flat register file'' registers to the |
19035 | x87's stack-like registers. This pass is only run on x86 variants. | |
19036 | ||
d77de738 ML |
19037 | @opindex fdump-rtl-subreg1 |
19038 | @opindex fdump-rtl-subreg2 | |
ddf6fe37 AA |
19039 | @item -fdump-rtl-subreg1 |
19040 | @itemx -fdump-rtl-subreg2 | |
d77de738 ML |
19041 | @option{-fdump-rtl-subreg1} and @option{-fdump-rtl-subreg2} enable dumping after |
19042 | the two subreg expansion passes. | |
19043 | ||
d77de738 | 19044 | @opindex fdump-rtl-unshare |
ddf6fe37 | 19045 | @item -fdump-rtl-unshare |
d77de738 ML |
19046 | Dump after all rtl has been unshared. |
19047 | ||
d77de738 | 19048 | @opindex fdump-rtl-vartrack |
ddf6fe37 | 19049 | @item -fdump-rtl-vartrack |
d77de738 ML |
19050 | Dump after variable tracking. |
19051 | ||
d77de738 | 19052 | @opindex fdump-rtl-vregs |
ddf6fe37 | 19053 | @item -fdump-rtl-vregs |
d77de738 ML |
19054 | Dump after converting virtual registers to hard registers. |
19055 | ||
d77de738 | 19056 | @opindex fdump-rtl-web |
ddf6fe37 | 19057 | @item -fdump-rtl-web |
d77de738 ML |
19058 | Dump after live range splitting. |
19059 | ||
d77de738 ML |
19060 | @opindex fdump-rtl-regclass |
19061 | @opindex fdump-rtl-subregs_of_mode_init | |
19062 | @opindex fdump-rtl-subregs_of_mode_finish | |
19063 | @opindex fdump-rtl-dfinit | |
19064 | @opindex fdump-rtl-dfinish | |
ddf6fe37 AA |
19065 | @item -fdump-rtl-regclass |
19066 | @itemx -fdump-rtl-subregs_of_mode_init | |
19067 | @itemx -fdump-rtl-subregs_of_mode_finish | |
19068 | @itemx -fdump-rtl-dfinit | |
19069 | @itemx -fdump-rtl-dfinish | |
d77de738 ML |
19070 | These dumps are defined but always produce empty files. |
19071 | ||
d77de738 ML |
19072 | @opindex da |
19073 | @opindex fdump-rtl-all | |
ddf6fe37 AA |
19074 | @item -da |
19075 | @itemx -fdump-rtl-all | |
d77de738 ML |
19076 | Produce all the dumps listed above. |
19077 | ||
d77de738 | 19078 | @opindex dA |
ddf6fe37 | 19079 | @item -dA |
d77de738 ML |
19080 | Annotate the assembler output with miscellaneous debugging information. |
19081 | ||
d77de738 | 19082 | @opindex dD |
ddf6fe37 | 19083 | @item -dD |
d77de738 ML |
19084 | Dump all macro definitions, at the end of preprocessing, in addition to |
19085 | normal output. | |
19086 | ||
d77de738 | 19087 | @opindex dH |
ddf6fe37 | 19088 | @item -dH |
d77de738 ML |
19089 | Produce a core dump whenever an error occurs. |
19090 | ||
d77de738 | 19091 | @opindex dp |
ddf6fe37 | 19092 | @item -dp |
d77de738 ML |
19093 | Annotate the assembler output with a comment indicating which |
19094 | pattern and alternative is used. The length and cost of each instruction are | |
19095 | also printed. | |
19096 | ||
d77de738 | 19097 | @opindex dP |
ddf6fe37 | 19098 | @item -dP |
d77de738 ML |
19099 | Dump the RTL in the assembler output as a comment before each instruction. |
19100 | Also turns on @option{-dp} annotation. | |
19101 | ||
d77de738 | 19102 | @opindex dx |
ddf6fe37 | 19103 | @item -dx |
d77de738 ML |
19104 | Just generate RTL for a function instead of compiling it. Usually used |
19105 | with @option{-fdump-rtl-expand}. | |
19106 | @end table | |
19107 | ||
d77de738 | 19108 | @opindex fdump-debug |
ddf6fe37 | 19109 | @item -fdump-debug |
d77de738 ML |
19110 | Dump debugging information generated during the debug |
19111 | generation phase. | |
19112 | ||
d77de738 | 19113 | @opindex fdump-earlydebug |
ddf6fe37 | 19114 | @item -fdump-earlydebug |
d77de738 ML |
19115 | Dump debugging information generated during the early debug |
19116 | generation phase. | |
19117 | ||
d77de738 | 19118 | @opindex fdump-noaddr |
ddf6fe37 | 19119 | @item -fdump-noaddr |
d77de738 ML |
19120 | When doing debugging dumps, suppress address output. This makes it more |
19121 | feasible to use diff on debugging dumps for compiler invocations with | |
19122 | different compiler binaries and/or different | |
19123 | text / bss / data / heap / stack / dso start locations. | |
19124 | ||
d77de738 | 19125 | @opindex freport-bug |
ddf6fe37 | 19126 | @item -freport-bug |
d77de738 ML |
19127 | Collect and dump debug information into a temporary file if an |
19128 | internal compiler error (ICE) occurs. | |
19129 | ||
d77de738 | 19130 | @opindex fdump-unnumbered |
ddf6fe37 | 19131 | @item -fdump-unnumbered |
d77de738 ML |
19132 | When doing debugging dumps, suppress instruction numbers and address output. |
19133 | This makes it more feasible to use diff on debugging dumps for compiler | |
19134 | invocations with different options, in particular with and without | |
19135 | @option{-g}. | |
19136 | ||
d77de738 | 19137 | @opindex fdump-unnumbered-links |
ddf6fe37 | 19138 | @item -fdump-unnumbered-links |
d77de738 ML |
19139 | When doing debugging dumps (see @option{-d} option above), suppress |
19140 | instruction numbers for the links to the previous and next instructions | |
19141 | in a sequence. | |
19142 | ||
ddf6fe37 | 19143 | @opindex fdump-ipa |
d77de738 ML |
19144 | @item -fdump-ipa-@var{switch} |
19145 | @itemx -fdump-ipa-@var{switch}-@var{options} | |
d77de738 ML |
19146 | Control the dumping at various stages of inter-procedural analysis |
19147 | language tree to a file. The file name is generated by appending a | |
19148 | switch specific suffix to the source file name, and the file is created | |
19149 | in the same directory as the output file. The following dumps are | |
19150 | possible: | |
19151 | ||
19152 | @table @samp | |
19153 | @item all | |
19154 | Enables all inter-procedural analysis dumps. | |
19155 | ||
19156 | @item cgraph | |
19157 | Dumps information about call-graph optimization, unused function removal, | |
19158 | and inlining decisions. | |
19159 | ||
19160 | @item inline | |
19161 | Dump after function inlining. | |
19162 | ||
19163 | @end table | |
19164 | ||
19165 | Additionally, the options @option{-optimized}, @option{-missed}, | |
19166 | @option{-note}, and @option{-all} can be provided, with the same meaning | |
19167 | as for @option{-fopt-info}, defaulting to @option{-optimized}. | |
19168 | ||
19169 | For example, @option{-fdump-ipa-inline-optimized-missed} will emit | |
19170 | information on callsites that were inlined, along with callsites | |
19171 | that were not inlined. | |
19172 | ||
19173 | By default, the dump will contain messages about successful | |
19174 | optimizations (equivalent to @option{-optimized}) together with | |
19175 | low-level details about the analysis. | |
19176 | ||
d77de738 | 19177 | @opindex fdump-lang |
ddf6fe37 | 19178 | @item -fdump-lang |
d77de738 ML |
19179 | Dump language-specific information. The file name is made by appending |
19180 | @file{.lang} to the source file name. | |
19181 | ||
ddf6fe37 AA |
19182 | @opindex fdump-lang-all |
19183 | @opindex fdump-lang | |
d77de738 ML |
19184 | @item -fdump-lang-all |
19185 | @itemx -fdump-lang-@var{switch} | |
19186 | @itemx -fdump-lang-@var{switch}-@var{options} | |
19187 | @itemx -fdump-lang-@var{switch}-@var{options}=@var{filename} | |
d77de738 ML |
19188 | Control the dumping of language-specific information. The @var{options} |
19189 | and @var{filename} portions behave as described in the | |
19190 | @option{-fdump-tree} option. The following @var{switch} values are | |
19191 | accepted: | |
19192 | ||
19193 | @table @samp | |
19194 | @item all | |
19195 | ||
19196 | Enable all language-specific dumps. | |
19197 | ||
19198 | @item class | |
19199 | Dump class hierarchy information. Virtual table information is emitted | |
19200 | unless '@option{slim}' is specified. This option is applicable to C++ only. | |
19201 | ||
19202 | @item module | |
19203 | Dump module information. Options @option{lineno} (locations), | |
19204 | @option{graph} (reachability), @option{blocks} (clusters), | |
19205 | @option{uid} (serialization), @option{alias} (mergeable), | |
19206 | @option{asmname} (Elrond), @option{eh} (mapper) & @option{vops} | |
19207 | (macros) may provide additional information. This option is | |
19208 | applicable to C++ only. | |
19209 | ||
19210 | @item raw | |
19211 | Dump the raw internal tree data. This option is applicable to C++ only. | |
19212 | ||
19213 | @end table | |
19214 | ||
d77de738 | 19215 | @opindex fdump-passes |
ddf6fe37 | 19216 | @item -fdump-passes |
d77de738 ML |
19217 | Print on @file{stderr} the list of optimization passes that are turned |
19218 | on and off by the current command-line options. | |
19219 | ||
d77de738 | 19220 | @opindex fdump-statistics |
ddf6fe37 | 19221 | @item -fdump-statistics-@var{option} |
d77de738 ML |
19222 | Enable and control dumping of pass statistics in a separate file. The |
19223 | file name is generated by appending a suffix ending in | |
19224 | @samp{.statistics} to the source file name, and the file is created in | |
19225 | the same directory as the output file. If the @samp{-@var{option}} | |
19226 | form is used, @samp{-stats} causes counters to be summed over the | |
19227 | whole compilation unit while @samp{-details} dumps every event as | |
19228 | the passes generate them. The default with no option is to sum | |
19229 | counters for each function compiled. | |
19230 | ||
ddf6fe37 AA |
19231 | @opindex fdump-tree-all |
19232 | @opindex fdump-tree | |
d77de738 ML |
19233 | @item -fdump-tree-all |
19234 | @itemx -fdump-tree-@var{switch} | |
19235 | @itemx -fdump-tree-@var{switch}-@var{options} | |
19236 | @itemx -fdump-tree-@var{switch}-@var{options}=@var{filename} | |
d77de738 ML |
19237 | Control the dumping at various stages of processing the intermediate |
19238 | language tree to a file. If the @samp{-@var{options}} | |
19239 | form is used, @var{options} is a list of @samp{-} separated options | |
19240 | which control the details of the dump. Not all options are applicable | |
19241 | to all dumps; those that are not meaningful are ignored. The | |
19242 | following options are available | |
19243 | ||
19244 | @table @samp | |
19245 | @item address | |
19246 | Print the address of each node. Usually this is not meaningful as it | |
19247 | changes according to the environment and source file. Its primary use | |
19248 | is for tying up a dump file with a debug environment. | |
19249 | @item asmname | |
19250 | If @code{DECL_ASSEMBLER_NAME} has been set for a given decl, use that | |
19251 | in the dump instead of @code{DECL_NAME}. Its primary use is ease of | |
19252 | use working backward from mangled names in the assembly file. | |
19253 | @item slim | |
19254 | When dumping front-end intermediate representations, inhibit dumping | |
19255 | of members of a scope or body of a function merely because that scope | |
19256 | has been reached. Only dump such items when they are directly reachable | |
19257 | by some other path. | |
19258 | ||
19259 | When dumping pretty-printed trees, this option inhibits dumping the | |
19260 | bodies of control structures. | |
19261 | ||
19262 | When dumping RTL, print the RTL in slim (condensed) form instead of | |
19263 | the default LISP-like representation. | |
19264 | @item raw | |
19265 | Print a raw representation of the tree. By default, trees are | |
19266 | pretty-printed into a C-like representation. | |
19267 | @item details | |
19268 | Enable more detailed dumps (not honored by every dump option). Also | |
19269 | include information from the optimization passes. | |
19270 | @item stats | |
19271 | Enable dumping various statistics about the pass (not honored by every dump | |
19272 | option). | |
19273 | @item blocks | |
19274 | Enable showing basic block boundaries (disabled in raw dumps). | |
19275 | @item graph | |
19276 | For each of the other indicated dump files (@option{-fdump-rtl-@var{pass}}), | |
19277 | dump a representation of the control flow graph suitable for viewing with | |
19278 | GraphViz to @file{@var{file}.@var{passid}.@var{pass}.dot}. Each function in | |
19279 | the file is pretty-printed as a subgraph, so that GraphViz can render them | |
19280 | all in a single plot. | |
19281 | ||
19282 | This option currently only works for RTL dumps, and the RTL is always | |
19283 | dumped in slim form. | |
19284 | @item vops | |
19285 | Enable showing virtual operands for every statement. | |
19286 | @item lineno | |
19287 | Enable showing line numbers for statements. | |
19288 | @item uid | |
19289 | Enable showing the unique ID (@code{DECL_UID}) for each variable. | |
19290 | @item verbose | |
19291 | Enable showing the tree dump for each statement. | |
19292 | @item eh | |
19293 | Enable showing the EH region number holding each statement. | |
19294 | @item scev | |
19295 | Enable showing scalar evolution analysis details. | |
19296 | @item optimized | |
19297 | Enable showing optimization information (only available in certain | |
19298 | passes). | |
19299 | @item missed | |
19300 | Enable showing missed optimization information (only available in certain | |
19301 | passes). | |
19302 | @item note | |
19303 | Enable other detailed optimization information (only available in | |
19304 | certain passes). | |
19305 | @item all | |
19306 | Turn on all options, except @option{raw}, @option{slim}, @option{verbose} | |
19307 | and @option{lineno}. | |
19308 | @item optall | |
19309 | Turn on all optimization options, i.e., @option{optimized}, | |
19310 | @option{missed}, and @option{note}. | |
19311 | @end table | |
19312 | ||
19313 | To determine what tree dumps are available or find the dump for a pass | |
19314 | of interest follow the steps below. | |
19315 | ||
19316 | @enumerate | |
19317 | @item | |
19318 | Invoke GCC with @option{-fdump-passes} and in the @file{stderr} output | |
19319 | look for a code that corresponds to the pass you are interested in. | |
19320 | For example, the codes @code{tree-evrp}, @code{tree-vrp1}, and | |
19321 | @code{tree-vrp2} correspond to the three Value Range Propagation passes. | |
19322 | The number at the end distinguishes distinct invocations of the same pass. | |
19323 | @item | |
19324 | To enable the creation of the dump file, append the pass code to | |
19325 | the @option{-fdump-} option prefix and invoke GCC with it. For example, | |
19326 | to enable the dump from the Early Value Range Propagation pass, invoke | |
19327 | GCC with the @option{-fdump-tree-evrp} option. Optionally, you may | |
19328 | specify the name of the dump file. If you don't specify one, GCC | |
19329 | creates as described below. | |
19330 | @item | |
19331 | Find the pass dump in a file whose name is composed of three components | |
19332 | separated by a period: the name of the source file GCC was invoked to | |
19333 | compile, a numeric suffix indicating the pass number followed by the | |
19334 | letter @samp{t} for tree passes (and the letter @samp{r} for RTL passes), | |
19335 | and finally the pass code. For example, the Early VRP pass dump might | |
19336 | be in a file named @file{myfile.c.038t.evrp} in the current working | |
19337 | directory. Note that the numeric codes are not stable and may change | |
19338 | from one version of GCC to another. | |
19339 | @end enumerate | |
19340 | ||
ddf6fe37 | 19341 | @opindex fopt-info |
d77de738 ML |
19342 | @item -fopt-info |
19343 | @itemx -fopt-info-@var{options} | |
19344 | @itemx -fopt-info-@var{options}=@var{filename} | |
d77de738 ML |
19345 | Controls optimization dumps from various optimization passes. If the |
19346 | @samp{-@var{options}} form is used, @var{options} is a list of | |
19347 | @samp{-} separated option keywords to select the dump details and | |
19348 | optimizations. | |
19349 | ||
19350 | The @var{options} can be divided into three groups: | |
19351 | @enumerate | |
19352 | @item | |
19353 | options describing what kinds of messages should be emitted, | |
19354 | @item | |
19355 | options describing the verbosity of the dump, and | |
19356 | @item | |
19357 | options describing which optimizations should be included. | |
19358 | @end enumerate | |
19359 | The options from each group can be freely mixed as they are | |
19360 | non-overlapping. However, in case of any conflicts, | |
19361 | the later options override the earlier options on the command | |
19362 | line. | |
19363 | ||
19364 | The following options control which kinds of messages should be emitted: | |
19365 | ||
19366 | @table @samp | |
19367 | @item optimized | |
19368 | Print information when an optimization is successfully applied. It is | |
19369 | up to a pass to decide which information is relevant. For example, the | |
19370 | vectorizer passes print the source location of loops which are | |
19371 | successfully vectorized. | |
19372 | @item missed | |
19373 | Print information about missed optimizations. Individual passes | |
19374 | control which information to include in the output. | |
19375 | @item note | |
19376 | Print verbose information about optimizations, such as certain | |
19377 | transformations, more detailed messages about decisions etc. | |
19378 | @item all | |
19379 | Print detailed optimization information. This includes | |
19380 | @samp{optimized}, @samp{missed}, and @samp{note}. | |
19381 | @end table | |
19382 | ||
19383 | The following option controls the dump verbosity: | |
19384 | ||
19385 | @table @samp | |
19386 | @item internals | |
19387 | By default, only ``high-level'' messages are emitted. This option enables | |
19388 | additional, more detailed, messages, which are likely to only be of interest | |
19389 | to GCC developers. | |
19390 | @end table | |
19391 | ||
19392 | One or more of the following option keywords can be used to describe a | |
19393 | group of optimizations: | |
19394 | ||
19395 | @table @samp | |
19396 | @item ipa | |
19397 | Enable dumps from all interprocedural optimizations. | |
19398 | @item loop | |
19399 | Enable dumps from all loop optimizations. | |
19400 | @item inline | |
19401 | Enable dumps from all inlining optimizations. | |
19402 | @item omp | |
19403 | Enable dumps from all OMP (Offloading and Multi Processing) optimizations. | |
19404 | @item vec | |
19405 | Enable dumps from all vectorization optimizations. | |
19406 | @item optall | |
19407 | Enable dumps from all optimizations. This is a superset of | |
19408 | the optimization groups listed above. | |
19409 | @end table | |
19410 | ||
19411 | If @var{options} is | |
19412 | omitted, it defaults to @samp{optimized-optall}, which means to dump messages | |
19413 | about successful optimizations from all the passes, omitting messages | |
19414 | that are treated as ``internals''. | |
19415 | ||
19416 | If the @var{filename} is provided, then the dumps from all the | |
19417 | applicable optimizations are concatenated into the @var{filename}. | |
19418 | Otherwise the dump is output onto @file{stderr}. Though multiple | |
19419 | @option{-fopt-info} options are accepted, only one of them can include | |
19420 | a @var{filename}. If other filenames are provided then all but the | |
19421 | first such option are ignored. | |
19422 | ||
19423 | Note that the output @var{filename} is overwritten | |
19424 | in case of multiple translation units. If a combined output from | |
19425 | multiple translation units is desired, @file{stderr} should be used | |
19426 | instead. | |
19427 | ||
19428 | In the following example, the optimization info is output to | |
19429 | @file{stderr}: | |
19430 | ||
19431 | @smallexample | |
19432 | gcc -O3 -fopt-info | |
19433 | @end smallexample | |
19434 | ||
19435 | This example: | |
19436 | @smallexample | |
19437 | gcc -O3 -fopt-info-missed=missed.all | |
19438 | @end smallexample | |
19439 | ||
19440 | @noindent | |
19441 | outputs missed optimization report from all the passes into | |
19442 | @file{missed.all}, and this one: | |
19443 | ||
19444 | @smallexample | |
19445 | gcc -O2 -ftree-vectorize -fopt-info-vec-missed | |
19446 | @end smallexample | |
19447 | ||
19448 | @noindent | |
19449 | prints information about missed optimization opportunities from | |
19450 | vectorization passes on @file{stderr}. | |
19451 | Note that @option{-fopt-info-vec-missed} is equivalent to | |
19452 | @option{-fopt-info-missed-vec}. The order of the optimization group | |
19453 | names and message types listed after @option{-fopt-info} does not matter. | |
19454 | ||
19455 | As another example, | |
19456 | @smallexample | |
19457 | gcc -O3 -fopt-info-inline-optimized-missed=inline.txt | |
19458 | @end smallexample | |
19459 | ||
19460 | @noindent | |
19461 | outputs information about missed optimizations as well as | |
19462 | optimized locations from all the inlining passes into | |
19463 | @file{inline.txt}. | |
19464 | ||
19465 | Finally, consider: | |
19466 | ||
19467 | @smallexample | |
19468 | gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt | |
19469 | @end smallexample | |
19470 | ||
19471 | @noindent | |
19472 | Here the two output filenames @file{vec.miss} and @file{loop.opt} are | |
19473 | in conflict since only one output file is allowed. In this case, only | |
19474 | the first option takes effect and the subsequent options are | |
19475 | ignored. Thus only @file{vec.miss} is produced which contains | |
19476 | dumps from the vectorizer about missed opportunities. | |
19477 | ||
d77de738 | 19478 | @opindex fsave-optimization-record |
ddf6fe37 | 19479 | @item -fsave-optimization-record |
d77de738 ML |
19480 | Write a SRCFILE.opt-record.json.gz file detailing what optimizations |
19481 | were performed, for those optimizations that support @option{-fopt-info}. | |
19482 | ||
19483 | This option is experimental and the format of the data within the | |
19484 | compressed JSON file is subject to change. | |
19485 | ||
19486 | It is roughly equivalent to a machine-readable version of | |
19487 | @option{-fopt-info-all}, as a collection of messages with source file, | |
19488 | line number and column number, with the following additional data for | |
19489 | each message: | |
19490 | ||
19491 | @itemize @bullet | |
19492 | ||
19493 | @item | |
19494 | the execution count of the code being optimized, along with metadata about | |
19495 | whether this was from actual profile data, or just an estimate, allowing | |
19496 | consumers to prioritize messages by code hotness, | |
19497 | ||
19498 | @item | |
19499 | the function name of the code being optimized, where applicable, | |
19500 | ||
19501 | @item | |
19502 | the ``inlining chain'' for the code being optimized, so that when | |
19503 | a function is inlined into several different places (which might | |
19504 | themselves be inlined), the reader can distinguish between the copies, | |
19505 | ||
19506 | @item | |
19507 | objects identifying those parts of the message that refer to expressions, | |
19508 | statements or symbol-table nodes, which of these categories they are, and, | |
19509 | when available, their source code location, | |
19510 | ||
19511 | @item | |
19512 | the GCC pass that emitted the message, and | |
19513 | ||
19514 | @item | |
19515 | the location in GCC's own code from which the message was emitted | |
19516 | ||
19517 | @end itemize | |
19518 | ||
19519 | Additionally, some messages are logically nested within other | |
19520 | messages, reflecting implementation details of the optimization | |
19521 | passes. | |
19522 | ||
d77de738 | 19523 | @opindex fsched-verbose |
ddf6fe37 | 19524 | @item -fsched-verbose=@var{n} |
d77de738 ML |
19525 | On targets that use instruction scheduling, this option controls the |
19526 | amount of debugging output the scheduler prints to the dump files. | |
19527 | ||
19528 | For @var{n} greater than zero, @option{-fsched-verbose} outputs the | |
19529 | same information as @option{-fdump-rtl-sched1} and @option{-fdump-rtl-sched2}. | |
19530 | For @var{n} greater than one, it also output basic block probabilities, | |
19531 | detailed ready list information and unit/insn info. For @var{n} greater | |
19532 | than two, it includes RTL at abort point, control-flow and regions info. | |
19533 | And for @var{n} over four, @option{-fsched-verbose} also includes | |
19534 | dependence info. | |
19535 | ||
19536 | ||
19537 | ||
d77de738 ML |
19538 | @opindex fdisable- |
19539 | @opindex fenable- | |
ddf6fe37 AA |
19540 | @item -fenable-@var{kind}-@var{pass} |
19541 | @itemx -fdisable-@var{kind}-@var{pass}=@var{range-list} | |
d77de738 ML |
19542 | |
19543 | This is a set of options that are used to explicitly disable/enable | |
19544 | optimization passes. These options are intended for use for debugging GCC. | |
19545 | Compiler users should use regular options for enabling/disabling | |
19546 | passes instead. | |
19547 | ||
19548 | @table @gcctabopt | |
19549 | ||
19550 | @item -fdisable-ipa-@var{pass} | |
19551 | Disable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is | |
19552 | statically invoked in the compiler multiple times, the pass name should be | |
19553 | appended with a sequential number starting from 1. | |
19554 | ||
19555 | @item -fdisable-rtl-@var{pass} | |
19556 | @itemx -fdisable-rtl-@var{pass}=@var{range-list} | |
19557 | Disable RTL pass @var{pass}. @var{pass} is the pass name. If the same pass is | |
19558 | statically invoked in the compiler multiple times, the pass name should be | |
19559 | appended with a sequential number starting from 1. @var{range-list} is a | |
19560 | comma-separated list of function ranges or assembler names. Each range is a number | |
19561 | pair separated by a colon. The range is inclusive in both ends. If the range | |
19562 | is trivial, the number pair can be simplified as a single number. If the | |
19563 | function's call graph node's @var{uid} falls within one of the specified ranges, | |
19564 | the @var{pass} is disabled for that function. The @var{uid} is shown in the | |
19565 | function header of a dump file, and the pass names can be dumped by using | |
19566 | option @option{-fdump-passes}. | |
19567 | ||
19568 | @item -fdisable-tree-@var{pass} | |
19569 | @itemx -fdisable-tree-@var{pass}=@var{range-list} | |
19570 | Disable tree pass @var{pass}. See @option{-fdisable-rtl} for the description of | |
19571 | option arguments. | |
19572 | ||
19573 | @item -fenable-ipa-@var{pass} | |
19574 | Enable IPA pass @var{pass}. @var{pass} is the pass name. If the same pass is | |
19575 | statically invoked in the compiler multiple times, the pass name should be | |
19576 | appended with a sequential number starting from 1. | |
19577 | ||
19578 | @item -fenable-rtl-@var{pass} | |
19579 | @itemx -fenable-rtl-@var{pass}=@var{range-list} | |
19580 | Enable RTL pass @var{pass}. See @option{-fdisable-rtl} for option argument | |
19581 | description and examples. | |
19582 | ||
19583 | @item -fenable-tree-@var{pass} | |
19584 | @itemx -fenable-tree-@var{pass}=@var{range-list} | |
19585 | Enable tree pass @var{pass}. See @option{-fdisable-rtl} for the description | |
19586 | of option arguments. | |
19587 | ||
19588 | @end table | |
19589 | ||
19590 | Here are some examples showing uses of these options. | |
19591 | ||
19592 | @smallexample | |
19593 | ||
19594 | # disable ccp1 for all functions | |
19595 | -fdisable-tree-ccp1 | |
19596 | # disable complete unroll for function whose cgraph node uid is 1 | |
19597 | -fenable-tree-cunroll=1 | |
19598 | # disable gcse2 for functions at the following ranges [1,1], | |
19599 | # [300,400], and [400,1000] | |
19600 | # disable gcse2 for functions foo and foo2 | |
19601 | -fdisable-rtl-gcse2=foo,foo2 | |
19602 | # disable early inlining | |
19603 | -fdisable-tree-einline | |
19604 | # disable ipa inlining | |
19605 | -fdisable-ipa-inline | |
19606 | # enable tree full unroll | |
19607 | -fenable-tree-unroll | |
19608 | ||
19609 | @end smallexample | |
19610 | ||
d77de738 ML |
19611 | @opindex fchecking |
19612 | @opindex fno-checking | |
ddf6fe37 AA |
19613 | @item -fchecking |
19614 | @itemx -fchecking=@var{n} | |
d77de738 ML |
19615 | Enable internal consistency checking. The default depends on |
19616 | the compiler configuration. @option{-fchecking=2} enables further | |
19617 | internal consistency checking that might affect code generation. | |
19618 | ||
d77de738 | 19619 | @opindex frandom-seed |
ddf6fe37 | 19620 | @item -frandom-seed=@var{string} |
d77de738 ML |
19621 | This option provides a seed that GCC uses in place of |
19622 | random numbers in generating certain symbol names | |
19623 | that have to be different in every compiled file. It is also used to | |
19624 | place unique stamps in coverage data files and the object files that | |
19625 | produce them. You can use the @option{-frandom-seed} option to produce | |
19626 | reproducibly identical object files. | |
19627 | ||
19628 | The @var{string} can either be a number (decimal, octal or hex) or an | |
19629 | arbitrary string (in which case it's converted to a number by | |
19630 | computing CRC32). | |
19631 | ||
19632 | The @var{string} should be different for every file you compile. | |
19633 | ||
d77de738 | 19634 | @opindex save-temps |
ddf6fe37 | 19635 | @item -save-temps |
d77de738 ML |
19636 | Store the usual ``temporary'' intermediate files permanently; name them |
19637 | as auxiliary output files, as specified described under | |
19638 | @option{-dumpbase} and @option{-dumpdir}. | |
19639 | ||
19640 | When used in combination with the @option{-x} command-line option, | |
19641 | @option{-save-temps} is sensible enough to avoid overwriting an | |
19642 | input source file with the same extension as an intermediate file. | |
19643 | The corresponding intermediate file may be obtained by renaming the | |
19644 | source file before using @option{-save-temps}. | |
19645 | ||
d77de738 | 19646 | @opindex save-temps=cwd |
ddf6fe37 | 19647 | @item -save-temps=cwd |
d77de738 ML |
19648 | Equivalent to @option{-save-temps -dumpdir ./}. |
19649 | ||
d77de738 | 19650 | @opindex save-temps=obj |
ddf6fe37 | 19651 | @item -save-temps=obj |
d77de738 ML |
19652 | Equivalent to @option{-save-temps -dumpdir @file{outdir/}}, where |
19653 | @file{outdir/} is the directory of the output file specified after the | |
19654 | @option{-o} option, including any directory separators. If the | |
19655 | @option{-o} option is not used, the @option{-save-temps=obj} switch | |
19656 | behaves like @option{-save-temps=cwd}. | |
19657 | ||
d77de738 | 19658 | @opindex time |
ddf6fe37 | 19659 | @item -time@r{[}=@var{file}@r{]} |
d77de738 ML |
19660 | Report the CPU time taken by each subprocess in the compilation |
19661 | sequence. For C source files, this is the compiler proper and assembler | |
19662 | (plus the linker if linking is done). | |
19663 | ||
19664 | Without the specification of an output file, the output looks like this: | |
19665 | ||
19666 | @smallexample | |
19667 | # cc1 0.12 0.01 | |
19668 | # as 0.00 0.01 | |
19669 | @end smallexample | |
19670 | ||
19671 | The first number on each line is the ``user time'', that is time spent | |
19672 | executing the program itself. The second number is ``system time'', | |
19673 | time spent executing operating system routines on behalf of the program. | |
19674 | Both numbers are in seconds. | |
19675 | ||
19676 | With the specification of an output file, the output is appended to the | |
19677 | named file, and it looks like this: | |
19678 | ||
19679 | @smallexample | |
19680 | 0.12 0.01 cc1 @var{options} | |
19681 | 0.00 0.01 as @var{options} | |
19682 | @end smallexample | |
19683 | ||
19684 | The ``user time'' and the ``system time'' are moved before the program | |
19685 | name, and the options passed to the program are displayed, so that one | |
19686 | can later tell what file was being compiled, and with which options. | |
19687 | ||
d77de738 | 19688 | @opindex fdump-final-insns |
ddf6fe37 | 19689 | @item -fdump-final-insns@r{[}=@var{file}@r{]} |
d77de738 ML |
19690 | Dump the final internal representation (RTL) to @var{file}. If the |
19691 | optional argument is omitted (or if @var{file} is @code{.}), the name | |
19692 | of the dump file is determined by appending @code{.gkd} to the | |
19693 | dump base name, see @option{-dumpbase}. | |
19694 | ||
d77de738 ML |
19695 | @opindex fcompare-debug |
19696 | @opindex fno-compare-debug | |
ddf6fe37 | 19697 | @item -fcompare-debug@r{[}=@var{opts}@r{]} |
d77de738 ML |
19698 | If no error occurs during compilation, run the compiler a second time, |
19699 | adding @var{opts} and @option{-fcompare-debug-second} to the arguments | |
19700 | passed to the second compilation. Dump the final internal | |
19701 | representation in both compilations, and print an error if they differ. | |
19702 | ||
19703 | If the equal sign is omitted, the default @option{-gtoggle} is used. | |
19704 | ||
19705 | The environment variable @env{GCC_COMPARE_DEBUG}, if defined, non-empty | |
19706 | and nonzero, implicitly enables @option{-fcompare-debug}. If | |
19707 | @env{GCC_COMPARE_DEBUG} is defined to a string starting with a dash, | |
19708 | then it is used for @var{opts}, otherwise the default @option{-gtoggle} | |
19709 | is used. | |
19710 | ||
19711 | @option{-fcompare-debug=}, with the equal sign but without @var{opts}, | |
19712 | is equivalent to @option{-fno-compare-debug}, which disables the dumping | |
19713 | of the final representation and the second compilation, preventing even | |
19714 | @env{GCC_COMPARE_DEBUG} from taking effect. | |
19715 | ||
19716 | To verify full coverage during @option{-fcompare-debug} testing, set | |
19717 | @env{GCC_COMPARE_DEBUG} to say @option{-fcompare-debug-not-overridden}, | |
19718 | which GCC rejects as an invalid option in any actual compilation | |
19719 | (rather than preprocessing, assembly or linking). To get just a | |
19720 | warning, setting @env{GCC_COMPARE_DEBUG} to @samp{-w%n-fcompare-debug | |
19721 | not overridden} will do. | |
19722 | ||
d77de738 | 19723 | @opindex fcompare-debug-second |
ddf6fe37 | 19724 | @item -fcompare-debug-second |
d77de738 ML |
19725 | This option is implicitly passed to the compiler for the second |
19726 | compilation requested by @option{-fcompare-debug}, along with options to | |
19727 | silence warnings, and omitting other options that would cause the compiler | |
19728 | to produce output to files or to standard output as a side effect. Dump | |
19729 | files and preserved temporary files are renamed so as to contain the | |
19730 | @code{.gk} additional extension during the second compilation, to avoid | |
19731 | overwriting those generated by the first. | |
19732 | ||
19733 | When this option is passed to the compiler driver, it causes the | |
19734 | @emph{first} compilation to be skipped, which makes it useful for little | |
19735 | other than debugging the compiler proper. | |
19736 | ||
d77de738 | 19737 | @opindex gtoggle |
ddf6fe37 | 19738 | @item -gtoggle |
d77de738 ML |
19739 | Turn off generation of debug info, if leaving out this option |
19740 | generates it, or turn it on at level 2 otherwise. The position of this | |
19741 | argument in the command line does not matter; it takes effect after all | |
19742 | other options are processed, and it does so only once, no matter how | |
19743 | many times it is given. This is mainly intended to be used with | |
19744 | @option{-fcompare-debug}. | |
19745 | ||
d77de738 ML |
19746 | @opindex fvar-tracking-assignments-toggle |
19747 | @opindex fno-var-tracking-assignments-toggle | |
ddf6fe37 | 19748 | @item -fvar-tracking-assignments-toggle |
d77de738 ML |
19749 | Toggle @option{-fvar-tracking-assignments}, in the same way that |
19750 | @option{-gtoggle} toggles @option{-g}. | |
19751 | ||
d77de738 | 19752 | @opindex Q |
ddf6fe37 | 19753 | @item -Q |
d77de738 ML |
19754 | Makes the compiler print out each function name as it is compiled, and |
19755 | print some statistics about each pass when it finishes. | |
19756 | ||
d77de738 | 19757 | @opindex ftime-report |
ddf6fe37 | 19758 | @item -ftime-report |
d77de738 ML |
19759 | Makes the compiler print some statistics about the time consumed by each |
19760 | pass when it finishes. | |
19761 | ||
d77de738 | 19762 | @opindex ftime-report-details |
ddf6fe37 | 19763 | @item -ftime-report-details |
d77de738 ML |
19764 | Record the time consumed by infrastructure parts separately for each pass. |
19765 | ||
d77de738 | 19766 | @opindex fira-verbose |
ddf6fe37 | 19767 | @item -fira-verbose=@var{n} |
d77de738 ML |
19768 | Control the verbosity of the dump file for the integrated register allocator. |
19769 | The default value is 5. If the value @var{n} is greater or equal to 10, | |
19770 | the dump output is sent to stderr using the same format as @var{n} minus 10. | |
19771 | ||
d77de738 | 19772 | @opindex flto-report |
ddf6fe37 | 19773 | @item -flto-report |
d77de738 ML |
19774 | Prints a report with internal details on the workings of the link-time |
19775 | optimizer. The contents of this report vary from version to version. | |
19776 | It is meant to be useful to GCC developers when processing object | |
19777 | files in LTO mode (via @option{-flto}). | |
19778 | ||
19779 | Disabled by default. | |
19780 | ||
d77de738 | 19781 | @opindex flto-report-wpa |
ddf6fe37 | 19782 | @item -flto-report-wpa |
d77de738 ML |
19783 | Like @option{-flto-report}, but only print for the WPA phase of link-time |
19784 | optimization. | |
19785 | ||
d77de738 | 19786 | @opindex fmem-report |
ddf6fe37 | 19787 | @item -fmem-report |
d77de738 ML |
19788 | Makes the compiler print some statistics about permanent memory |
19789 | allocation when it finishes. | |
19790 | ||
d77de738 | 19791 | @opindex fmem-report-wpa |
ddf6fe37 | 19792 | @item -fmem-report-wpa |
d77de738 ML |
19793 | Makes the compiler print some statistics about permanent memory |
19794 | allocation for the WPA phase only. | |
19795 | ||
d77de738 | 19796 | @opindex fpre-ipa-mem-report |
d77de738 | 19797 | @opindex fpost-ipa-mem-report |
ddf6fe37 AA |
19798 | @item -fpre-ipa-mem-report |
19799 | @item -fpost-ipa-mem-report | |
d77de738 ML |
19800 | Makes the compiler print some statistics about permanent memory |
19801 | allocation before or after interprocedural optimization. | |
19802 | ||
d77de738 | 19803 | @opindex fmultiflags |
ddf6fe37 | 19804 | @item -fmultiflags |
d77de738 ML |
19805 | This option enables multilib-aware @code{TFLAGS} to be used to build |
19806 | target libraries with options different from those the compiler is | |
19807 | configured to use by default, through the use of specs (@xref{Spec | |
19808 | Files}) set up by compiler internals, by the target, or by builders at | |
19809 | configure time. | |
19810 | ||
19811 | Like @code{TFLAGS}, this allows the target libraries to be built for | |
19812 | portable baseline environments, while the compiler defaults to more | |
19813 | demanding ones. That's useful because users can easily override the | |
19814 | defaults the compiler is configured to use to build their own programs, | |
19815 | if the defaults are not ideal for their target environment, whereas | |
19816 | rebuilding the runtime libraries is usually not as easy or desirable. | |
19817 | ||
19818 | Unlike @code{TFLAGS}, the use of specs enables different flags to be | |
19819 | selected for different multilibs. The way to accomplish that is to | |
19820 | build with @samp{make TFLAGS=-fmultiflags}, after configuring | |
19821 | @samp{--with-specs=%@{fmultiflags:...@}}. | |
19822 | ||
19823 | This option is discarded by the driver once it's done processing driver | |
19824 | self spec. | |
19825 | ||
19826 | It is also useful to check that @code{TFLAGS} are being used to build | |
19827 | all target libraries, by configuring a non-bootstrap compiler | |
19828 | @samp{--with-specs='%@{!fmultiflags:%emissing TFLAGS@}'} and building | |
19829 | the compiler and target libraries. | |
19830 | ||
d77de738 | 19831 | @opindex fprofile-report |
ddf6fe37 | 19832 | @item -fprofile-report |
d77de738 ML |
19833 | Makes the compiler print some statistics about consistency of the |
19834 | (estimated) profile and effect of individual passes. | |
19835 | ||
d77de738 | 19836 | @opindex fstack-usage |
ddf6fe37 | 19837 | @item -fstack-usage |
d77de738 ML |
19838 | Makes the compiler output stack usage information for the program, on a |
19839 | per-function basis. The filename for the dump is made by appending | |
19840 | @file{.su} to the @var{auxname}. @var{auxname} is generated from the name of | |
19841 | the output file, if explicitly specified and it is not an executable, | |
19842 | otherwise it is the basename of the source file. An entry is made up | |
19843 | of three fields: | |
19844 | ||
19845 | @itemize | |
19846 | @item | |
19847 | The name of the function. | |
19848 | @item | |
19849 | A number of bytes. | |
19850 | @item | |
19851 | One or more qualifiers: @code{static}, @code{dynamic}, @code{bounded}. | |
19852 | @end itemize | |
19853 | ||
19854 | The qualifier @code{static} means that the function manipulates the stack | |
19855 | statically: a fixed number of bytes are allocated for the frame on function | |
19856 | entry and released on function exit; no stack adjustments are otherwise made | |
19857 | in the function. The second field is this fixed number of bytes. | |
19858 | ||
19859 | The qualifier @code{dynamic} means that the function manipulates the stack | |
19860 | dynamically: in addition to the static allocation described above, stack | |
19861 | adjustments are made in the body of the function, for example to push/pop | |
19862 | arguments around function calls. If the qualifier @code{bounded} is also | |
19863 | present, the amount of these adjustments is bounded at compile time and | |
19864 | the second field is an upper bound of the total amount of stack used by | |
19865 | the function. If it is not present, the amount of these adjustments is | |
19866 | not bounded at compile time and the second field only represents the | |
19867 | bounded part. | |
19868 | ||
d77de738 | 19869 | @opindex fstats |
ddf6fe37 | 19870 | @item -fstats |
d77de738 ML |
19871 | Emit statistics about front-end processing at the end of the compilation. |
19872 | This option is supported only by the C++ front end, and | |
19873 | the information is generally only useful to the G++ development team. | |
19874 | ||
d77de738 | 19875 | @opindex fdbg-cnt-list |
ddf6fe37 | 19876 | @item -fdbg-cnt-list |
d77de738 ML |
19877 | Print the name and the counter upper bound for all debug counters. |
19878 | ||
19879 | ||
d77de738 | 19880 | @opindex fdbg-cnt |
ddf6fe37 | 19881 | @item -fdbg-cnt=@var{counter-value-list} |
d77de738 ML |
19882 | Set the internal debug counter lower and upper bound. @var{counter-value-list} |
19883 | is a comma-separated list of @var{name}:@var{lower_bound1}-@var{upper_bound1} | |
19884 | [:@var{lower_bound2}-@var{upper_bound2}...] tuples which sets | |
19885 | the name of the counter and list of closed intervals. | |
19886 | The @var{lower_bound} is optional and is zero | |
19887 | initialized if not set. | |
19888 | For example, with @option{-fdbg-cnt=dce:2-4:10-11,tail_call:10}, | |
19889 | @code{dbg_cnt(dce)} returns true only for second, third, fourth, tenth and | |
19890 | eleventh invocation. | |
19891 | For @code{dbg_cnt(tail_call)} true is returned for first 10 invocations. | |
19892 | ||
d77de738 | 19893 | @opindex print-file-name |
ddf6fe37 | 19894 | @item -print-file-name=@var{library} |
d77de738 ML |
19895 | Print the full absolute name of the library file @var{library} that |
19896 | would be used when linking---and don't do anything else. With this | |
19897 | option, GCC does not compile or link anything; it just prints the | |
19898 | file name. | |
19899 | ||
d77de738 | 19900 | @opindex print-multi-directory |
ddf6fe37 | 19901 | @item -print-multi-directory |
d77de738 ML |
19902 | Print the directory name corresponding to the multilib selected by any |
19903 | other switches present in the command line. This directory is supposed | |
19904 | to exist in @env{GCC_EXEC_PREFIX}. | |
19905 | ||
d77de738 | 19906 | @opindex print-multi-lib |
ddf6fe37 | 19907 | @item -print-multi-lib |
d77de738 ML |
19908 | Print the mapping from multilib directory names to compiler switches |
19909 | that enable them. The directory name is separated from the switches by | |
19910 | @samp{;}, and each switch starts with an @samp{@@} instead of the | |
19911 | @samp{-}, without spaces between multiple switches. This is supposed to | |
19912 | ease shell processing. | |
19913 | ||
d77de738 | 19914 | @opindex print-multi-os-directory |
ddf6fe37 | 19915 | @item -print-multi-os-directory |
d77de738 ML |
19916 | Print the path to OS libraries for the selected |
19917 | multilib, relative to some @file{lib} subdirectory. If OS libraries are | |
19918 | present in the @file{lib} subdirectory and no multilibs are used, this is | |
19919 | usually just @file{.}, if OS libraries are present in @file{lib@var{suffix}} | |
19920 | sibling directories this prints e.g.@: @file{../lib64}, @file{../lib} or | |
19921 | @file{../lib32}, or if OS libraries are present in @file{lib/@var{subdir}} | |
19922 | subdirectories it prints e.g.@: @file{amd64}, @file{sparcv9} or @file{ev6}. | |
19923 | ||
d77de738 | 19924 | @opindex print-multiarch |
ddf6fe37 | 19925 | @item -print-multiarch |
d77de738 ML |
19926 | Print the path to OS libraries for the selected multiarch, |
19927 | relative to some @file{lib} subdirectory. | |
19928 | ||
d77de738 | 19929 | @opindex print-prog-name |
ddf6fe37 | 19930 | @item -print-prog-name=@var{program} |
d77de738 ML |
19931 | Like @option{-print-file-name}, but searches for a program such as @command{cpp}. |
19932 | ||
d77de738 | 19933 | @opindex print-libgcc-file-name |
ddf6fe37 | 19934 | @item -print-libgcc-file-name |
d77de738 ML |
19935 | Same as @option{-print-file-name=libgcc.a}. |
19936 | ||
19937 | This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs} | |
19938 | but you do want to link with @file{libgcc.a}. You can do: | |
19939 | ||
19940 | @smallexample | |
19941 | gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name` | |
19942 | @end smallexample | |
19943 | ||
d77de738 | 19944 | @opindex print-search-dirs |
ddf6fe37 | 19945 | @item -print-search-dirs |
d77de738 ML |
19946 | Print the name of the configured installation directory and a list of |
19947 | program and library directories @command{gcc} searches---and don't do anything else. | |
19948 | ||
19949 | This is useful when @command{gcc} prints the error message | |
19950 | @samp{installation problem, cannot exec cpp0: No such file or directory}. | |
19951 | To resolve this you either need to put @file{cpp0} and the other compiler | |
19952 | components where @command{gcc} expects to find them, or you can set the environment | |
19953 | variable @env{GCC_EXEC_PREFIX} to the directory where you installed them. | |
19954 | Don't forget the trailing @samp{/}. | |
19955 | @xref{Environment Variables}. | |
19956 | ||
d77de738 | 19957 | @opindex print-sysroot |
ddf6fe37 | 19958 | @item -print-sysroot |
d77de738 ML |
19959 | Print the target sysroot directory that is used during |
19960 | compilation. This is the target sysroot specified either at configure | |
19961 | time or using the @option{--sysroot} option, possibly with an extra | |
19962 | suffix that depends on compilation options. If no target sysroot is | |
19963 | specified, the option prints nothing. | |
19964 | ||
d77de738 | 19965 | @opindex print-sysroot-headers-suffix |
ddf6fe37 | 19966 | @item -print-sysroot-headers-suffix |
d77de738 ML |
19967 | Print the suffix added to the target sysroot when searching for |
19968 | headers, or give an error if the compiler is not configured with such | |
19969 | a suffix---and don't do anything else. | |
19970 | ||
d77de738 | 19971 | @opindex dumpmachine |
ddf6fe37 | 19972 | @item -dumpmachine |
d77de738 ML |
19973 | Print the compiler's target machine (for example, |
19974 | @samp{i686-pc-linux-gnu})---and don't do anything else. | |
19975 | ||
d77de738 | 19976 | @opindex dumpversion |
ddf6fe37 | 19977 | @item -dumpversion |
d77de738 ML |
19978 | Print the compiler version (for example, @code{3.0}, @code{6.3.0} or @code{7})---and don't do |
19979 | anything else. This is the compiler version used in filesystem paths and | |
19980 | specs. Depending on how the compiler has been configured it can be just | |
19981 | a single number (major version), two numbers separated by a dot (major and | |
19982 | minor version) or three numbers separated by dots (major, minor and patchlevel | |
19983 | version). | |
19984 | ||
d77de738 | 19985 | @opindex dumpfullversion |
ddf6fe37 | 19986 | @item -dumpfullversion |
d77de738 ML |
19987 | Print the full compiler version---and don't do anything else. The output is |
19988 | always three numbers separated by dots, major, minor and patchlevel version. | |
19989 | ||
d77de738 | 19990 | @opindex dumpspecs |
ddf6fe37 | 19991 | @item -dumpspecs |
d77de738 ML |
19992 | Print the compiler's built-in specs---and don't do anything else. (This |
19993 | is used when GCC itself is being built.) @xref{Spec Files}. | |
19994 | @end table | |
19995 | ||
19996 | @node Submodel Options | |
19997 | @section Machine-Dependent Options | |
19998 | @cindex submodel options | |
19999 | @cindex specifying hardware config | |
20000 | @cindex hardware models and configurations, specifying | |
20001 | @cindex target-dependent options | |
20002 | @cindex machine-dependent options | |
20003 | ||
20004 | Each target machine supported by GCC can have its own options---for | |
20005 | example, to allow you to compile for a particular processor variant or | |
20006 | ABI, or to control optimizations specific to that machine. By | |
20007 | convention, the names of machine-specific options start with | |
20008 | @samp{-m}. | |
20009 | ||
20010 | Some configurations of the compiler also support additional target-specific | |
20011 | options, usually for compatibility with other compilers on the same | |
20012 | platform. | |
20013 | ||
20014 | @c This list is ordered alphanumerically by subsection name. | |
20015 | @c It should be the same order and spelling as these options are listed | |
20016 | @c in Machine Dependent Options | |
20017 | ||
20018 | @menu | |
20019 | * AArch64 Options:: | |
20020 | * Adapteva Epiphany Options:: | |
20021 | * AMD GCN Options:: | |
20022 | * ARC Options:: | |
20023 | * ARM Options:: | |
20024 | * AVR Options:: | |
20025 | * Blackfin Options:: | |
20026 | * C6X Options:: | |
20027 | * CRIS Options:: | |
20028 | * C-SKY Options:: | |
20029 | * Darwin Options:: | |
20030 | * DEC Alpha Options:: | |
20031 | * eBPF Options:: | |
20032 | * FR30 Options:: | |
20033 | * FT32 Options:: | |
20034 | * FRV Options:: | |
20035 | * GNU/Linux Options:: | |
20036 | * H8/300 Options:: | |
20037 | * HPPA Options:: | |
20038 | * IA-64 Options:: | |
20039 | * LM32 Options:: | |
20040 | * LoongArch Options:: | |
20041 | * M32C Options:: | |
20042 | * M32R/D Options:: | |
20043 | * M680x0 Options:: | |
20044 | * MCore Options:: | |
d77de738 ML |
20045 | * MicroBlaze Options:: |
20046 | * MIPS Options:: | |
20047 | * MMIX Options:: | |
20048 | * MN10300 Options:: | |
20049 | * Moxie Options:: | |
20050 | * MSP430 Options:: | |
20051 | * NDS32 Options:: | |
20052 | * Nios II Options:: | |
20053 | * Nvidia PTX Options:: | |
20054 | * OpenRISC Options:: | |
20055 | * PDP-11 Options:: | |
d77de738 ML |
20056 | * PowerPC Options:: |
20057 | * PRU Options:: | |
20058 | * RISC-V Options:: | |
20059 | * RL78 Options:: | |
20060 | * RS/6000 and PowerPC Options:: | |
20061 | * RX Options:: | |
20062 | * S/390 and zSeries Options:: | |
d77de738 ML |
20063 | * SH Options:: |
20064 | * Solaris 2 Options:: | |
20065 | * SPARC Options:: | |
20066 | * System V Options:: | |
20067 | * V850 Options:: | |
20068 | * VAX Options:: | |
20069 | * Visium Options:: | |
20070 | * VMS Options:: | |
20071 | * VxWorks Options:: | |
20072 | * x86 Options:: | |
20073 | * x86 Windows Options:: | |
20074 | * Xstormy16 Options:: | |
20075 | * Xtensa Options:: | |
20076 | * zSeries Options:: | |
20077 | @end menu | |
20078 | ||
20079 | @node AArch64 Options | |
20080 | @subsection AArch64 Options | |
20081 | @cindex AArch64 Options | |
20082 | ||
20083 | These options are defined for AArch64 implementations: | |
20084 | ||
20085 | @table @gcctabopt | |
20086 | ||
d77de738 | 20087 | @opindex mabi |
ddf6fe37 | 20088 | @item -mabi=@var{name} |
d77de738 ML |
20089 | Generate code for the specified data model. Permissible values |
20090 | are @samp{ilp32} for SysV-like data model where int, long int and pointers | |
20091 | are 32 bits, and @samp{lp64} for SysV-like data model where int is 32 bits, | |
20092 | but long int and pointers are 64 bits. | |
20093 | ||
20094 | The default depends on the specific target configuration. Note that | |
20095 | the LP64 and ILP32 ABIs are not link-compatible; you must compile your | |
20096 | entire program with the same ABI, and link with a compatible set of libraries. | |
20097 | ||
d77de738 | 20098 | @opindex mbig-endian |
ddf6fe37 | 20099 | @item -mbig-endian |
d77de738 ML |
20100 | Generate big-endian code. This is the default when GCC is configured for an |
20101 | @samp{aarch64_be-*-*} target. | |
20102 | ||
d77de738 | 20103 | @opindex mgeneral-regs-only |
ddf6fe37 | 20104 | @item -mgeneral-regs-only |
d77de738 ML |
20105 | Generate code which uses only the general-purpose registers. This will prevent |
20106 | the compiler from using floating-point and Advanced SIMD registers but will not | |
20107 | impose any restrictions on the assembler. | |
20108 | ||
d77de738 | 20109 | @opindex mlittle-endian |
ddf6fe37 | 20110 | @item -mlittle-endian |
d77de738 ML |
20111 | Generate little-endian code. This is the default when GCC is configured for an |
20112 | @samp{aarch64-*-*} but not an @samp{aarch64_be-*-*} target. | |
20113 | ||
d77de738 | 20114 | @opindex mcmodel=tiny |
ddf6fe37 | 20115 | @item -mcmodel=tiny |
d77de738 ML |
20116 | Generate code for the tiny code model. The program and its statically defined |
20117 | symbols must be within 1MB of each other. Programs can be statically or | |
20118 | dynamically linked. | |
20119 | ||
d77de738 | 20120 | @opindex mcmodel=small |
ddf6fe37 | 20121 | @item -mcmodel=small |
d77de738 ML |
20122 | Generate code for the small code model. The program and its statically defined |
20123 | symbols must be within 4GB of each other. Programs can be statically or | |
20124 | dynamically linked. This is the default code model. | |
20125 | ||
d77de738 | 20126 | @opindex mcmodel=large |
ddf6fe37 | 20127 | @item -mcmodel=large |
d77de738 ML |
20128 | Generate code for the large code model. This makes no assumptions about |
20129 | addresses and sizes of sections. Programs can be statically linked only. The | |
20130 | @option{-mcmodel=large} option is incompatible with @option{-mabi=ilp32}, | |
20131 | @option{-fpic} and @option{-fPIC}. | |
20132 | ||
d77de738 ML |
20133 | @opindex mstrict-align |
20134 | @opindex mno-strict-align | |
ddf6fe37 AA |
20135 | @item -mstrict-align |
20136 | @itemx -mno-strict-align | |
d77de738 ML |
20137 | Avoid or allow generating memory accesses that may not be aligned on a natural |
20138 | object boundary as described in the architecture specification. | |
20139 | ||
d77de738 ML |
20140 | @opindex momit-leaf-frame-pointer |
20141 | @opindex mno-omit-leaf-frame-pointer | |
ddf6fe37 AA |
20142 | @item -momit-leaf-frame-pointer |
20143 | @itemx -mno-omit-leaf-frame-pointer | |
d77de738 ML |
20144 | Omit or keep the frame pointer in leaf functions. The former behavior is the |
20145 | default. | |
20146 | ||
d77de738 ML |
20147 | @opindex mstack-protector-guard |
20148 | @opindex mstack-protector-guard-reg | |
20149 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
20150 | @item -mstack-protector-guard=@var{guard} |
20151 | @itemx -mstack-protector-guard-reg=@var{reg} | |
20152 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
20153 | Generate stack protection code using canary at @var{guard}. Supported |
20154 | locations are @samp{global} for a global canary or @samp{sysreg} for a | |
20155 | canary in an appropriate system register. | |
20156 | ||
20157 | With the latter choice the options | |
20158 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
20159 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
20160 | which system register to use as base register for reading the canary, | |
20161 | and from what offset from that base register. There is no default | |
20162 | register or offset as this is entirely for use within the Linux | |
20163 | kernel. | |
20164 | ||
d77de738 | 20165 | @opindex mtls-dialect=desc |
ddf6fe37 | 20166 | @item -mtls-dialect=desc |
d77de738 ML |
20167 | Use TLS descriptors as the thread-local storage mechanism for dynamic accesses |
20168 | of TLS variables. This is the default. | |
20169 | ||
d77de738 | 20170 | @opindex mtls-dialect=traditional |
ddf6fe37 | 20171 | @item -mtls-dialect=traditional |
d77de738 ML |
20172 | Use traditional TLS as the thread-local storage mechanism for dynamic accesses |
20173 | of TLS variables. | |
20174 | ||
d77de738 | 20175 | @opindex mtls-size |
ddf6fe37 | 20176 | @item -mtls-size=@var{size} |
d77de738 ML |
20177 | Specify bit size of immediate TLS offsets. Valid values are 12, 24, 32, 48. |
20178 | This option requires binutils 2.26 or newer. | |
20179 | ||
d77de738 ML |
20180 | @opindex mfix-cortex-a53-835769 |
20181 | @opindex mno-fix-cortex-a53-835769 | |
ddf6fe37 AA |
20182 | @item -mfix-cortex-a53-835769 |
20183 | @itemx -mno-fix-cortex-a53-835769 | |
d77de738 ML |
20184 | Enable or disable the workaround for the ARM Cortex-A53 erratum number 835769. |
20185 | This involves inserting a NOP instruction between memory instructions and | |
20186 | 64-bit integer multiply-accumulate instructions. | |
20187 | ||
d77de738 ML |
20188 | @opindex mfix-cortex-a53-843419 |
20189 | @opindex mno-fix-cortex-a53-843419 | |
ddf6fe37 AA |
20190 | @item -mfix-cortex-a53-843419 |
20191 | @itemx -mno-fix-cortex-a53-843419 | |
d77de738 ML |
20192 | Enable or disable the workaround for the ARM Cortex-A53 erratum number 843419. |
20193 | This erratum workaround is made at link time and this will only pass the | |
20194 | corresponding flag to the linker. | |
20195 | ||
d77de738 ML |
20196 | @opindex mlow-precision-recip-sqrt |
20197 | @opindex mno-low-precision-recip-sqrt | |
ddf6fe37 AA |
20198 | @item -mlow-precision-recip-sqrt |
20199 | @itemx -mno-low-precision-recip-sqrt | |
d77de738 ML |
20200 | Enable or disable the reciprocal square root approximation. |
20201 | This option only has an effect if @option{-ffast-math} or | |
20202 | @option{-funsafe-math-optimizations} is used as well. Enabling this reduces | |
20203 | precision of reciprocal square root results to about 16 bits for | |
20204 | single precision and to 32 bits for double precision. | |
20205 | ||
d77de738 ML |
20206 | @opindex mlow-precision-sqrt |
20207 | @opindex mno-low-precision-sqrt | |
ddf6fe37 AA |
20208 | @item -mlow-precision-sqrt |
20209 | @itemx -mno-low-precision-sqrt | |
d77de738 ML |
20210 | Enable or disable the square root approximation. |
20211 | This option only has an effect if @option{-ffast-math} or | |
20212 | @option{-funsafe-math-optimizations} is used as well. Enabling this reduces | |
20213 | precision of square root results to about 16 bits for | |
20214 | single precision and to 32 bits for double precision. | |
20215 | If enabled, it implies @option{-mlow-precision-recip-sqrt}. | |
20216 | ||
d77de738 ML |
20217 | @opindex mlow-precision-div |
20218 | @opindex mno-low-precision-div | |
ddf6fe37 AA |
20219 | @item -mlow-precision-div |
20220 | @itemx -mno-low-precision-div | |
d77de738 ML |
20221 | Enable or disable the division approximation. |
20222 | This option only has an effect if @option{-ffast-math} or | |
20223 | @option{-funsafe-math-optimizations} is used as well. Enabling this reduces | |
20224 | precision of division results to about 16 bits for | |
20225 | single precision and to 32 bits for double precision. | |
20226 | ||
20227 | @item -mtrack-speculation | |
20228 | @itemx -mno-track-speculation | |
20229 | Enable or disable generation of additional code to track speculative | |
20230 | execution through conditional branches. The tracking state can then | |
20231 | be used by the compiler when expanding calls to | |
20232 | @code{__builtin_speculation_safe_copy} to permit a more efficient code | |
20233 | sequence to be generated. | |
20234 | ||
20235 | @item -moutline-atomics | |
20236 | @itemx -mno-outline-atomics | |
20237 | Enable or disable calls to out-of-line helpers to implement atomic operations. | |
20238 | These helpers will, at runtime, determine if the LSE instructions from | |
20239 | ARMv8.1-A can be used; if not, they will use the load/store-exclusive | |
20240 | instructions that are present in the base ARMv8.0 ISA. | |
20241 | ||
20242 | This option is only applicable when compiling for the base ARMv8.0 | |
20243 | instruction set. If using a later revision, e.g. @option{-march=armv8.1-a} | |
20244 | or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be | |
20245 | used directly. The same applies when using @option{-mcpu=} when the | |
20246 | selected cpu supports the @samp{lse} feature. | |
20247 | This option is on by default. | |
20248 | ||
d77de738 | 20249 | @opindex march |
ddf6fe37 | 20250 | @item -march=@var{name} |
d77de738 ML |
20251 | Specify the name of the target architecture and, optionally, one or |
20252 | more feature modifiers. This option has the form | |
20253 | @option{-march=@var{arch}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}. | |
20254 | ||
20255 | The table below summarizes the permissible values for @var{arch} | |
20256 | and the features that they enable by default: | |
20257 | ||
20258 | @multitable @columnfractions 0.20 0.20 0.60 | |
20259 | @headitem @var{arch} value @tab Architecture @tab Includes by default | |
20260 | @item @samp{armv8-a} @tab Armv8-A @tab @samp{+fp}, @samp{+simd} | |
20261 | @item @samp{armv8.1-a} @tab Armv8.1-A @tab @samp{armv8-a}, @samp{+crc}, @samp{+lse}, @samp{+rdma} | |
20262 | @item @samp{armv8.2-a} @tab Armv8.2-A @tab @samp{armv8.1-a} | |
20263 | @item @samp{armv8.3-a} @tab Armv8.3-A @tab @samp{armv8.2-a}, @samp{+pauth} | |
20264 | @item @samp{armv8.4-a} @tab Armv8.4-A @tab @samp{armv8.3-a}, @samp{+flagm}, @samp{+fp16fml}, @samp{+dotprod} | |
20265 | @item @samp{armv8.5-a} @tab Armv8.5-A @tab @samp{armv8.4-a}, @samp{+sb}, @samp{+ssbs}, @samp{+predres} | |
20266 | @item @samp{armv8.6-a} @tab Armv8.6-A @tab @samp{armv8.5-a}, @samp{+bf16}, @samp{+i8mm} | |
20267 | @item @samp{armv8.7-a} @tab Armv8.7-A @tab @samp{armv8.6-a}, @samp{+ls64} | |
20268 | @item @samp{armv8.8-a} @tab Armv8.8-a @tab @samp{armv8.7-a}, @samp{+mops} | |
20269 | @item @samp{armv9-a} @tab Armv9-A @tab @samp{armv8.5-a}, @samp{+sve}, @samp{+sve2} | |
20270 | @item @samp{armv9.1-a} @tab Armv9.1-A @tab @samp{armv9-a}, @samp{+bf16}, @samp{+i8mm} | |
20271 | @item @samp{armv9.2-a} @tab Armv9.2-A @tab @samp{armv9.1-a}, @samp{+ls64} | |
20272 | @item @samp{armv9.3-a} @tab Armv9.3-A @tab @samp{armv9.2-a}, @samp{+mops} | |
20273 | @item @samp{armv8-r} @tab Armv8-R @tab @samp{armv8-r} | |
20274 | @end multitable | |
20275 | ||
20276 | The value @samp{native} is available on native AArch64 GNU/Linux and | |
20277 | causes the compiler to pick the architecture of the host system. This | |
20278 | option has no effect if the compiler is unable to recognize the | |
20279 | architecture of the host system, | |
20280 | ||
20281 | The permissible values for @var{feature} are listed in the sub-section | |
20282 | on @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu} | |
20283 | Feature Modifiers}. Where conflicting feature modifiers are | |
20284 | specified, the right-most feature is used. | |
20285 | ||
20286 | GCC uses @var{name} to determine what kind of instructions it can emit | |
20287 | when generating assembly code. If @option{-march} is specified | |
20288 | without either of @option{-mtune} or @option{-mcpu} also being | |
20289 | specified, the code is tuned to perform well across a range of target | |
20290 | processors implementing the target architecture. | |
20291 | ||
d77de738 | 20292 | @opindex mtune |
ddf6fe37 | 20293 | @item -mtune=@var{name} |
d77de738 ML |
20294 | Specify the name of the target processor for which GCC should tune the |
20295 | performance of the code. Permissible values for this option are: | |
20296 | @samp{generic}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, | |
20297 | @samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, | |
20298 | @samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77}, | |
20299 | @samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34}, | |
20300 | @samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, | |
20301 | @samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor}, | |
20302 | @samp{neoverse-512tvb}, @samp{neoverse-e1}, @samp{neoverse-n1}, | |
20303 | @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{neoverse-v2}, @samp{qdf24xx}, | |
20304 | @samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan}, | |
20305 | @samp{octeontx}, @samp{octeontx81}, @samp{octeontx83}, | |
20306 | @samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96} | |
20307 | @samp{octeontx2t93}, @samp{octeontx2f95}, @samp{octeontx2f95n}, | |
20308 | @samp{octeontx2f95mm}, | |
20309 | @samp{a64fx}, | |
20310 | @samp{thunderx}, @samp{thunderxt88}, | |
20311 | @samp{thunderxt88p1}, @samp{thunderxt81}, @samp{tsv110}, | |
20312 | @samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus}, | |
20313 | @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
20314 | @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53}, | |
20315 | @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}, | |
ce51e843 | 20316 | @samp{cortex-r82}, @samp{cortex-x1}, @samp{cortex-x1c}, @samp{cortex-x2}, |
e07556a8 SP |
20317 | @samp{cortex-x3}, @samp{cortex-a510}, @samp{cortex-a710}, @samp{cortex-a715}, |
20318 | @samp{ampere1}, @samp{ampere1a}, and @samp{native}. | |
d77de738 ML |
20319 | |
20320 | The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
20321 | @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53}, | |
20322 | @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55} specify that GCC | |
20323 | should tune for a big.LITTLE system. | |
20324 | ||
20325 | The value @samp{neoverse-512tvb} specifies that GCC should tune | |
20326 | for Neoverse cores that (a) implement SVE and (b) have a total vector | |
20327 | bandwidth of 512 bits per cycle. In other words, the option tells GCC to | |
20328 | tune for Neoverse cores that can execute 4 128-bit Advanced SIMD arithmetic | |
20329 | instructions a cycle and that can execute an equivalent number of SVE | |
20330 | arithmetic instructions per cycle (2 for 256-bit SVE, 4 for 128-bit SVE). | |
20331 | This is more general than tuning for a specific core like Neoverse V1 | |
20332 | but is more specific than the default tuning described below. | |
20333 | ||
20334 | Additionally on native AArch64 GNU/Linux systems the value | |
20335 | @samp{native} tunes performance to the host system. This option has no effect | |
20336 | if the compiler is unable to recognize the processor of the host system. | |
20337 | ||
20338 | Where none of @option{-mtune=}, @option{-mcpu=} or @option{-march=} | |
20339 | are specified, the code is tuned to perform well across a range | |
20340 | of target processors. | |
20341 | ||
20342 | This option cannot be suffixed by feature modifiers. | |
20343 | ||
d77de738 | 20344 | @opindex mcpu |
ddf6fe37 | 20345 | @item -mcpu=@var{name} |
d77de738 ML |
20346 | Specify the name of the target processor, optionally suffixed by one |
20347 | or more feature modifiers. This option has the form | |
20348 | @option{-mcpu=@var{cpu}@r{@{}+@r{[}no@r{]}@var{feature}@r{@}*}}, where | |
20349 | the permissible values for @var{cpu} are the same as those available | |
20350 | for @option{-mtune}. The permissible values for @var{feature} are | |
20351 | documented in the sub-section on | |
20352 | @ref{aarch64-feature-modifiers,,@option{-march} and @option{-mcpu} | |
20353 | Feature Modifiers}. Where conflicting feature modifiers are | |
20354 | specified, the right-most feature is used. | |
20355 | ||
20356 | GCC uses @var{name} to determine what kind of instructions it can emit when | |
20357 | generating assembly code (as if by @option{-march}) and to determine | |
20358 | the target processor for which to tune for performance (as if | |
20359 | by @option{-mtune}). Where this option is used in conjunction | |
20360 | with @option{-march} or @option{-mtune}, those options take precedence | |
20361 | over the appropriate part of this option. | |
20362 | ||
20363 | @option{-mcpu=neoverse-512tvb} is special in that it does not refer | |
20364 | to a specific core, but instead refers to all Neoverse cores that | |
20365 | (a) implement SVE and (b) have a total vector bandwidth of 512 bits | |
20366 | a cycle. Unless overridden by @option{-march}, | |
20367 | @option{-mcpu=neoverse-512tvb} generates code that can run on a | |
20368 | Neoverse V1 core, since Neoverse V1 is the first Neoverse core with | |
20369 | these properties. Unless overridden by @option{-mtune}, | |
20370 | @option{-mcpu=neoverse-512tvb} tunes code in the same way as for | |
20371 | @option{-mtune=neoverse-512tvb}. | |
20372 | ||
d77de738 | 20373 | @opindex moverride |
ddf6fe37 | 20374 | @item -moverride=@var{string} |
d77de738 ML |
20375 | Override tuning decisions made by the back-end in response to a |
20376 | @option{-mtune=} switch. The syntax, semantics, and accepted values | |
20377 | for @var{string} in this option are not guaranteed to be consistent | |
20378 | across releases. | |
20379 | ||
20380 | This option is only intended to be useful when developing GCC. | |
20381 | ||
d77de738 | 20382 | @opindex mverbose-cost-dump |
ddf6fe37 | 20383 | @item -mverbose-cost-dump |
d77de738 ML |
20384 | Enable verbose cost model dumping in the debug dump files. This option is |
20385 | provided for use in debugging the compiler. | |
20386 | ||
d77de738 ML |
20387 | @opindex mpc-relative-literal-loads |
20388 | @opindex mno-pc-relative-literal-loads | |
ddf6fe37 AA |
20389 | @item -mpc-relative-literal-loads |
20390 | @itemx -mno-pc-relative-literal-loads | |
d77de738 ML |
20391 | Enable or disable PC-relative literal loads. With this option literal pools are |
20392 | accessed using a single instruction and emitted after each function. This | |
20393 | limits the maximum size of functions to 1MB. This is enabled by default for | |
20394 | @option{-mcmodel=tiny}. | |
20395 | ||
d77de738 | 20396 | @opindex msign-return-address |
ddf6fe37 | 20397 | @item -msign-return-address=@var{scope} |
d77de738 ML |
20398 | Select the function scope on which return address signing will be applied. |
20399 | Permissible values are @samp{none}, which disables return address signing, | |
20400 | @samp{non-leaf}, which enables pointer signing for functions which are not leaf | |
20401 | functions, and @samp{all}, which enables pointer signing for all functions. The | |
20402 | default value is @samp{none}. This option has been deprecated by | |
20403 | -mbranch-protection. | |
20404 | ||
d77de738 | 20405 | @opindex mbranch-protection |
ddf6fe37 | 20406 | @item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}+@var{b-key}]|@var{bti} |
d77de738 ML |
20407 | Select the branch protection features to use. |
20408 | @samp{none} is the default and turns off all types of branch protection. | |
20409 | @samp{standard} turns on all types of branch protection features. If a feature | |
20410 | has additional tuning options, then @samp{standard} sets it to its standard | |
20411 | level. | |
20412 | @samp{pac-ret[+@var{leaf}]} turns on return address signing to its standard | |
20413 | level: signing functions that save the return address to memory (non-leaf | |
20414 | functions will practically always do this) using the a-key. The optional | |
20415 | argument @samp{leaf} can be used to extend the signing to include leaf | |
20416 | functions. The optional argument @samp{b-key} can be used to sign the functions | |
20417 | with the B-key instead of the A-key. | |
20418 | @samp{bti} turns on branch target identification mechanism. | |
20419 | ||
d77de738 | 20420 | @opindex mharden-sls |
ddf6fe37 | 20421 | @item -mharden-sls=@var{opts} |
d77de738 ML |
20422 | Enable compiler hardening against straight line speculation (SLS). |
20423 | @var{opts} is a comma-separated list of the following options: | |
20424 | @table @samp | |
20425 | @item retbr | |
20426 | @item blr | |
20427 | @end table | |
20428 | In addition, @samp{-mharden-sls=all} enables all SLS hardening while | |
20429 | @samp{-mharden-sls=none} disables all SLS hardening. | |
20430 | ||
d77de738 | 20431 | @opindex msve-vector-bits |
ddf6fe37 | 20432 | @item -msve-vector-bits=@var{bits} |
d77de738 ML |
20433 | Specify the number of bits in an SVE vector register. This option only has |
20434 | an effect when SVE is enabled. | |
20435 | ||
20436 | GCC supports two forms of SVE code generation: ``vector-length | |
20437 | agnostic'' output that works with any size of vector register and | |
20438 | ``vector-length specific'' output that allows GCC to make assumptions | |
20439 | about the vector length when it is useful for optimization reasons. | |
20440 | The possible values of @samp{bits} are: @samp{scalable}, @samp{128}, | |
20441 | @samp{256}, @samp{512}, @samp{1024} and @samp{2048}. | |
20442 | Specifying @samp{scalable} selects vector-length agnostic | |
20443 | output. At present @samp{-msve-vector-bits=128} also generates vector-length | |
20444 | agnostic output for big-endian targets. All other values generate | |
20445 | vector-length specific code. The behavior of these values may change | |
20446 | in future releases and no value except @samp{scalable} should be | |
20447 | relied on for producing code that is portable across different | |
20448 | hardware SVE vector lengths. | |
20449 | ||
20450 | The default is @samp{-msve-vector-bits=scalable}, which produces | |
20451 | vector-length agnostic code. | |
20452 | @end table | |
20453 | ||
20454 | @subsubsection @option{-march} and @option{-mcpu} Feature Modifiers | |
20455 | @anchor{aarch64-feature-modifiers} | |
20456 | @cindex @option{-march} feature modifiers | |
20457 | @cindex @option{-mcpu} feature modifiers | |
20458 | Feature modifiers used with @option{-march} and @option{-mcpu} can be any of | |
20459 | the following and their inverses @option{no@var{feature}}: | |
20460 | ||
20461 | @table @samp | |
20462 | @item crc | |
20463 | Enable CRC extension. This is on by default for | |
20464 | @option{-march=armv8.1-a}. | |
20465 | @item crypto | |
20466 | Enable Crypto extension. This also enables Advanced SIMD and floating-point | |
20467 | instructions. | |
20468 | @item fp | |
20469 | Enable floating-point instructions. This is on by default for all possible | |
20470 | values for options @option{-march} and @option{-mcpu}. | |
20471 | @item simd | |
20472 | Enable Advanced SIMD instructions. This also enables floating-point | |
20473 | instructions. This is on by default for all possible values for options | |
20474 | @option{-march} and @option{-mcpu}. | |
20475 | @item sve | |
20476 | Enable Scalable Vector Extension instructions. This also enables Advanced | |
20477 | SIMD and floating-point instructions. | |
20478 | @item lse | |
20479 | Enable Large System Extension instructions. This is on by default for | |
20480 | @option{-march=armv8.1-a}. | |
20481 | @item rdma | |
20482 | Enable Round Double Multiply Accumulate instructions. This is on by default | |
20483 | for @option{-march=armv8.1-a}. | |
20484 | @item fp16 | |
20485 | Enable FP16 extension. This also enables floating-point instructions. | |
20486 | @item fp16fml | |
20487 | Enable FP16 fmla extension. This also enables FP16 extensions and | |
20488 | 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. | |
20489 | ||
20490 | @item rcpc | |
0431e8ae AV |
20491 | Enable the RCpc extension. This enables the use of the LDAPR instructions for |
20492 | load-acquire atomic semantics, and passes it on to the assembler, enabling | |
20493 | inline asm statements to use instructions from the RCpc extension. | |
d77de738 ML |
20494 | @item dotprod |
20495 | Enable the Dot Product extension. This also enables Advanced SIMD instructions. | |
20496 | @item aes | |
20497 | Enable the Armv8-a aes and pmull crypto extension. This also enables Advanced | |
20498 | SIMD instructions. | |
20499 | @item sha2 | |
20500 | Enable the Armv8-a sha2 crypto extension. This also enables Advanced SIMD instructions. | |
20501 | @item sha3 | |
20502 | Enable the sha512 and sha3 crypto extension. This also enables Advanced SIMD | |
20503 | instructions. Use of this option with architectures prior to Armv8.2-A is not supported. | |
20504 | @item sm4 | |
20505 | Enable the sm3 and sm4 crypto extension. This also enables Advanced SIMD instructions. | |
20506 | Use of this option with architectures prior to Armv8.2-A is not supported. | |
20507 | @item profile | |
20508 | Enable the Statistical Profiling extension. This option is only to enable the | |
20509 | extension at the assembler level and does not affect code generation. | |
20510 | @item rng | |
20511 | Enable the Armv8.5-a Random Number instructions. This option is only to | |
20512 | enable the extension at the assembler level and does not affect code | |
20513 | generation. | |
20514 | @item memtag | |
20515 | Enable the Armv8.5-a Memory Tagging Extensions. | |
20516 | Use of this option with architectures prior to Armv8.5-A is not supported. | |
20517 | @item sb | |
20518 | Enable the Armv8-a Speculation Barrier instruction. This option is only to | |
20519 | enable the extension at the assembler level and does not affect code | |
20520 | generation. This option is enabled by default for @option{-march=armv8.5-a}. | |
20521 | @item ssbs | |
20522 | Enable the Armv8-a Speculative Store Bypass Safe instruction. This option | |
20523 | is only to enable the extension at the assembler level and does not affect code | |
20524 | generation. This option is enabled by default for @option{-march=armv8.5-a}. | |
20525 | @item predres | |
20526 | Enable the Armv8-a Execution and Data Prediction Restriction instructions. | |
20527 | This option is only to enable the extension at the assembler level and does | |
20528 | not affect code generation. This option is enabled by default for | |
20529 | @option{-march=armv8.5-a}. | |
20530 | @item sve2 | |
20531 | Enable the Armv8-a Scalable Vector Extension 2. This also enables SVE | |
20532 | instructions. | |
20533 | @item sve2-bitperm | |
20534 | Enable SVE2 bitperm instructions. This also enables SVE2 instructions. | |
20535 | @item sve2-sm4 | |
20536 | Enable SVE2 sm4 instructions. This also enables SVE2 instructions. | |
20537 | @item sve2-aes | |
20538 | Enable SVE2 aes instructions. This also enables SVE2 instructions. | |
20539 | @item sve2-sha3 | |
20540 | Enable SVE2 sha3 instructions. This also enables SVE2 instructions. | |
20541 | @item tme | |
20542 | Enable the Transactional Memory Extension. | |
20543 | @item i8mm | |
20544 | Enable 8-bit Integer Matrix Multiply instructions. This also enables | |
20545 | Advanced SIMD and floating-point instructions. This option is enabled by | |
20546 | default for @option{-march=armv8.6-a}. Use of this option with architectures | |
20547 | prior to Armv8.2-A is not supported. | |
20548 | @item f32mm | |
20549 | Enable 32-bit Floating point Matrix Multiply instructions. This also enables | |
20550 | SVE instructions. Use of this option with architectures prior to Armv8.2-A is | |
20551 | not supported. | |
20552 | @item f64mm | |
20553 | Enable 64-bit Floating point Matrix Multiply instructions. This also enables | |
20554 | SVE instructions. Use of this option with architectures prior to Armv8.2-A is | |
20555 | not supported. | |
20556 | @item bf16 | |
20557 | Enable brain half-precision floating-point instructions. This also enables | |
20558 | Advanced SIMD and floating-point instructions. This option is enabled by | |
20559 | default for @option{-march=armv8.6-a}. Use of this option with architectures | |
20560 | prior to Armv8.2-A is not supported. | |
20561 | @item ls64 | |
20562 | Enable the 64-byte atomic load and store instructions for accelerators. | |
20563 | This option is enabled by default for @option{-march=armv8.7-a}. | |
20564 | @item mops | |
20565 | Enable the instructions to accelerate memory operations like @code{memcpy}, | |
20566 | @code{memmove}, @code{memset}. This option is enabled by default for | |
20567 | @option{-march=armv8.8-a} | |
20568 | @item flagm | |
20569 | Enable the Flag Manipulation instructions Extension. | |
20570 | @item pauth | |
20571 | Enable the Pointer Authentication Extension. | |
d758d190 KT |
20572 | @item cssc |
20573 | Enable the Common Short Sequence Compression instructions. | |
d77de738 ML |
20574 | |
20575 | @end table | |
20576 | ||
20577 | Feature @option{crypto} implies @option{aes}, @option{sha2}, and @option{simd}, | |
20578 | which implies @option{fp}. | |
20579 | Conversely, @option{nofp} implies @option{nosimd}, which implies | |
20580 | @option{nocrypto}, @option{noaes} and @option{nosha2}. | |
20581 | ||
20582 | @node Adapteva Epiphany Options | |
20583 | @subsection Adapteva Epiphany Options | |
20584 | ||
20585 | These @samp{-m} options are defined for Adapteva Epiphany: | |
20586 | ||
20587 | @table @gcctabopt | |
d77de738 | 20588 | @opindex mhalf-reg-file |
ddf6fe37 | 20589 | @item -mhalf-reg-file |
d77de738 ML |
20590 | Don't allocate any register in the range @code{r32}@dots{}@code{r63}. |
20591 | That allows code to run on hardware variants that lack these registers. | |
20592 | ||
d77de738 | 20593 | @opindex mprefer-short-insn-regs |
ddf6fe37 | 20594 | @item -mprefer-short-insn-regs |
d77de738 ML |
20595 | Preferentially allocate registers that allow short instruction generation. |
20596 | This can result in increased instruction count, so this may either reduce or | |
20597 | increase overall code size. | |
20598 | ||
d77de738 | 20599 | @opindex mbranch-cost |
ddf6fe37 | 20600 | @item -mbranch-cost=@var{num} |
d77de738 ML |
20601 | Set the cost of branches to roughly @var{num} ``simple'' instructions. |
20602 | This cost is only a heuristic and is not guaranteed to produce | |
20603 | consistent results across releases. | |
20604 | ||
d77de738 | 20605 | @opindex mcmove |
ddf6fe37 | 20606 | @item -mcmove |
d77de738 ML |
20607 | Enable the generation of conditional moves. |
20608 | ||
d77de738 | 20609 | @opindex mnops |
ddf6fe37 | 20610 | @item -mnops=@var{num} |
d77de738 ML |
20611 | Emit @var{num} NOPs before every other generated instruction. |
20612 | ||
d77de738 ML |
20613 | @opindex mno-soft-cmpsf |
20614 | @opindex msoft-cmpsf | |
ddf6fe37 | 20615 | @item -mno-soft-cmpsf |
d77de738 ML |
20616 | For single-precision floating-point comparisons, emit an @code{fsub} instruction |
20617 | and test the flags. This is faster than a software comparison, but can | |
20618 | get incorrect results in the presence of NaNs, or when two different small | |
20619 | numbers are compared such that their difference is calculated as zero. | |
20620 | The default is @option{-msoft-cmpsf}, which uses slower, but IEEE-compliant, | |
20621 | software comparisons. | |
20622 | ||
d77de738 | 20623 | @opindex mstack-offset |
ddf6fe37 | 20624 | @item -mstack-offset=@var{num} |
d77de738 ML |
20625 | Set the offset between the top of the stack and the stack pointer. |
20626 | E.g., a value of 8 means that the eight bytes in the range @code{sp+0@dots{}sp+7} | |
20627 | can be used by leaf functions without stack allocation. | |
20628 | Values other than @samp{8} or @samp{16} are untested and unlikely to work. | |
20629 | Note also that this option changes the ABI; compiling a program with a | |
20630 | different stack offset than the libraries have been compiled with | |
20631 | generally does not work. | |
20632 | This option can be useful if you want to evaluate if a different stack | |
20633 | offset would give you better code, but to actually use a different stack | |
20634 | offset to build working programs, it is recommended to configure the | |
20635 | toolchain with the appropriate @option{--with-stack-offset=@var{num}} option. | |
20636 | ||
d77de738 ML |
20637 | @opindex mno-round-nearest |
20638 | @opindex mround-nearest | |
ddf6fe37 | 20639 | @item -mno-round-nearest |
d77de738 ML |
20640 | Make the scheduler assume that the rounding mode has been set to |
20641 | truncating. The default is @option{-mround-nearest}. | |
20642 | ||
d77de738 | 20643 | @opindex mlong-calls |
ddf6fe37 | 20644 | @item -mlong-calls |
d77de738 ML |
20645 | If not otherwise specified by an attribute, assume all calls might be beyond |
20646 | the offset range of the @code{b} / @code{bl} instructions, and therefore load the | |
20647 | function address into a register before performing a (otherwise direct) call. | |
20648 | This is the default. | |
20649 | ||
d77de738 | 20650 | @opindex short-calls |
ddf6fe37 | 20651 | @item -mshort-calls |
d77de738 ML |
20652 | If not otherwise specified by an attribute, assume all direct calls are |
20653 | in the range of the @code{b} / @code{bl} instructions, so use these instructions | |
20654 | for direct calls. The default is @option{-mlong-calls}. | |
20655 | ||
d77de738 | 20656 | @opindex msmall16 |
ddf6fe37 | 20657 | @item -msmall16 |
d77de738 ML |
20658 | Assume addresses can be loaded as 16-bit unsigned values. This does not |
20659 | apply to function addresses for which @option{-mlong-calls} semantics | |
20660 | are in effect. | |
20661 | ||
d77de738 | 20662 | @opindex mfp-mode |
ddf6fe37 | 20663 | @item -mfp-mode=@var{mode} |
d77de738 ML |
20664 | Set the prevailing mode of the floating-point unit. |
20665 | This determines the floating-point mode that is provided and expected | |
20666 | at function call and return time. Making this mode match the mode you | |
20667 | predominantly need at function start can make your programs smaller and | |
20668 | faster by avoiding unnecessary mode switches. | |
20669 | ||
20670 | @var{mode} can be set to one the following values: | |
20671 | ||
20672 | @table @samp | |
20673 | @item caller | |
20674 | Any mode at function entry is valid, and retained or restored when | |
20675 | the function returns, and when it calls other functions. | |
20676 | This mode is useful for compiling libraries or other compilation units | |
20677 | you might want to incorporate into different programs with different | |
20678 | prevailing FPU modes, and the convenience of being able to use a single | |
20679 | object file outweighs the size and speed overhead for any extra | |
20680 | mode switching that might be needed, compared with what would be needed | |
20681 | with a more specific choice of prevailing FPU mode. | |
20682 | ||
20683 | @item truncate | |
20684 | This is the mode used for floating-point calculations with | |
20685 | truncating (i.e.@: round towards zero) rounding mode. That includes | |
20686 | conversion from floating point to integer. | |
20687 | ||
20688 | @item round-nearest | |
20689 | This is the mode used for floating-point calculations with | |
20690 | round-to-nearest-or-even rounding mode. | |
20691 | ||
20692 | @item int | |
20693 | This is the mode used to perform integer calculations in the FPU, e.g.@: | |
20694 | integer multiply, or integer multiply-and-accumulate. | |
20695 | @end table | |
20696 | ||
20697 | The default is @option{-mfp-mode=caller} | |
20698 | ||
d77de738 ML |
20699 | @opindex mno-split-lohi |
20700 | @opindex msplit-lohi | |
20701 | @opindex mno-postinc | |
20702 | @opindex mpostinc | |
20703 | @opindex mno-postmodify | |
20704 | @opindex mpostmodify | |
ddf6fe37 AA |
20705 | @item -mno-split-lohi |
20706 | @itemx -mno-postinc | |
20707 | @itemx -mno-postmodify | |
d77de738 ML |
20708 | Code generation tweaks that disable, respectively, splitting of 32-bit |
20709 | loads, generation of post-increment addresses, and generation of | |
20710 | post-modify addresses. The defaults are @option{msplit-lohi}, | |
20711 | @option{-mpost-inc}, and @option{-mpost-modify}. | |
20712 | ||
d77de738 ML |
20713 | @opindex mno-vect-double |
20714 | @opindex mvect-double | |
ddf6fe37 | 20715 | @item -mnovect-double |
d77de738 ML |
20716 | Change the preferred SIMD mode to SImode. The default is |
20717 | @option{-mvect-double}, which uses DImode as preferred SIMD mode. | |
20718 | ||
d77de738 | 20719 | @opindex max-vect-align |
ddf6fe37 | 20720 | @item -max-vect-align=@var{num} |
d77de738 ML |
20721 | The maximum alignment for SIMD vector mode types. |
20722 | @var{num} may be 4 or 8. The default is 8. | |
20723 | Note that this is an ABI change, even though many library function | |
20724 | interfaces are unaffected if they don't use SIMD vector modes | |
20725 | in places that affect size and/or alignment of relevant types. | |
20726 | ||
d77de738 | 20727 | @opindex msplit-vecmove-early |
ddf6fe37 | 20728 | @item -msplit-vecmove-early |
d77de738 ML |
20729 | Split vector moves into single word moves before reload. In theory this |
20730 | can give better register allocation, but so far the reverse seems to be | |
20731 | generally the case. | |
20732 | ||
d77de738 | 20733 | @opindex m1reg- |
ddf6fe37 | 20734 | @item -m1reg-@var{reg} |
d77de738 ML |
20735 | Specify a register to hold the constant @minus{}1, which makes loading small negative |
20736 | constants and certain bitmasks faster. | |
20737 | Allowable values for @var{reg} are @samp{r43} and @samp{r63}, | |
20738 | which specify use of that register as a fixed register, | |
20739 | and @samp{none}, which means that no register is used for this | |
20740 | purpose. The default is @option{-m1reg-none}. | |
20741 | ||
20742 | @end table | |
20743 | ||
20744 | @node AMD GCN Options | |
20745 | @subsection AMD GCN Options | |
20746 | @cindex AMD GCN Options | |
20747 | ||
20748 | These options are defined specifically for the AMD GCN port. | |
20749 | ||
20750 | @table @gcctabopt | |
20751 | ||
d77de738 | 20752 | @opindex march |
d77de738 | 20753 | @opindex mtune |
ddf6fe37 AA |
20754 | @item -march=@var{gpu} |
20755 | @itemx -mtune=@var{gpu} | |
d77de738 ML |
20756 | Set architecture type or tuning for @var{gpu}. Supported values for @var{gpu} |
20757 | are | |
20758 | ||
20759 | @table @samp | |
20760 | @item fiji | |
20761 | Compile for GCN3 Fiji devices (gfx803). | |
20762 | ||
20763 | @item gfx900 | |
20764 | Compile for GCN5 Vega 10 devices (gfx900). | |
20765 | ||
20766 | @item gfx906 | |
20767 | Compile for GCN5 Vega 20 devices (gfx906). | |
20768 | ||
20769 | @item gfx908 | |
20770 | Compile for CDNA1 Instinct MI100 series devices (gfx908). | |
20771 | ||
20772 | @item gfx90a | |
20773 | Compile for CDNA2 Instinct MI200 series devices (gfx90a). | |
20774 | ||
20775 | @end table | |
20776 | ||
ddf6fe37 | 20777 | @opindex msram-ecc |
d77de738 ML |
20778 | @item -msram-ecc=on |
20779 | @itemx -msram-ecc=off | |
20780 | @itemx -msram-ecc=any | |
d77de738 ML |
20781 | Compile binaries suitable for devices with the SRAM-ECC feature enabled, |
20782 | disabled, or either mode. This feature can be enabled per-process on some | |
20783 | devices. The compiled code must match the device mode. The default is | |
20784 | @samp{any}, for devices that support it. | |
20785 | ||
d77de738 | 20786 | @opindex mstack-size |
ddf6fe37 | 20787 | @item -mstack-size=@var{bytes} |
d77de738 ML |
20788 | Specify how many @var{bytes} of stack space will be requested for each GPU |
20789 | thread (wave-front). Beware that there may be many threads and limited memory | |
20790 | available. The size of the stack allocation may also have an impact on | |
20791 | run-time performance. The default is 32KB when using OpenACC or OpenMP, and | |
20792 | 1MB otherwise. | |
20793 | ||
d77de738 | 20794 | @opindex mxnack |
ddf6fe37 | 20795 | @item -mxnack |
d77de738 ML |
20796 | Compile binaries suitable for devices with the XNACK feature enabled. Some |
20797 | devices always require XNACK and some allow the user to configure XNACK. The | |
20798 | compiled code must match the device mode. The default is @samp{-mno-xnack}. | |
20799 | At present this option is a placeholder for support that is not yet | |
20800 | implemented. | |
20801 | ||
20802 | @end table | |
20803 | ||
20804 | @node ARC Options | |
20805 | @subsection ARC Options | |
20806 | @cindex ARC options | |
20807 | ||
20808 | The following options control the architecture variant for which code | |
20809 | is being compiled: | |
20810 | ||
20811 | @c architecture variants | |
20812 | @table @gcctabopt | |
20813 | ||
d77de738 | 20814 | @opindex mbarrel-shifter |
ddf6fe37 | 20815 | @item -mbarrel-shifter |
d77de738 ML |
20816 | Generate instructions supported by barrel shifter. This is the default |
20817 | unless @option{-mcpu=ARC601} or @samp{-mcpu=ARCEM} is in effect. | |
20818 | ||
d77de738 | 20819 | @opindex mjli-always |
ddf6fe37 | 20820 | @item -mjli-always |
d77de738 ML |
20821 | Force to call a function using jli_s instruction. This option is |
20822 | valid only for ARCv2 architecture. | |
20823 | ||
d77de738 | 20824 | @opindex mcpu |
ddf6fe37 | 20825 | @item -mcpu=@var{cpu} |
d77de738 ML |
20826 | Set architecture type, register usage, and instruction scheduling |
20827 | parameters for @var{cpu}. There are also shortcut alias options | |
20828 | available for backward compatibility and convenience. Supported | |
20829 | values for @var{cpu} are | |
20830 | ||
20831 | @table @samp | |
20832 | @opindex mA6 | |
20833 | @opindex mARC600 | |
20834 | @item arc600 | |
20835 | Compile for ARC600. Aliases: @option{-mA6}, @option{-mARC600}. | |
20836 | ||
d77de738 | 20837 | @opindex mARC601 |
ddf6fe37 | 20838 | @item arc601 |
d77de738 ML |
20839 | Compile for ARC601. Alias: @option{-mARC601}. |
20840 | ||
d77de738 ML |
20841 | @opindex mA7 |
20842 | @opindex mARC700 | |
ddf6fe37 | 20843 | @item arc700 |
d77de738 ML |
20844 | Compile for ARC700. Aliases: @option{-mA7}, @option{-mARC700}. |
20845 | This is the default when configured with @option{--with-cpu=arc700}@. | |
20846 | ||
20847 | @item arcem | |
20848 | Compile for ARC EM. | |
20849 | ||
20850 | @item archs | |
20851 | Compile for ARC HS. | |
20852 | ||
20853 | @item em | |
20854 | Compile for ARC EM CPU with no hardware extensions. | |
20855 | ||
20856 | @item em4 | |
20857 | Compile for ARC EM4 CPU. | |
20858 | ||
20859 | @item em4_dmips | |
20860 | Compile for ARC EM4 DMIPS CPU. | |
20861 | ||
20862 | @item em4_fpus | |
20863 | Compile for ARC EM4 DMIPS CPU with the single-precision floating-point | |
20864 | extension. | |
20865 | ||
20866 | @item em4_fpuda | |
20867 | Compile for ARC EM4 DMIPS CPU with single-precision floating-point and | |
20868 | double assist instructions. | |
20869 | ||
20870 | @item hs | |
20871 | Compile for ARC HS CPU with no hardware extensions except the atomic | |
20872 | instructions. | |
20873 | ||
20874 | @item hs34 | |
20875 | Compile for ARC HS34 CPU. | |
20876 | ||
20877 | @item hs38 | |
20878 | Compile for ARC HS38 CPU. | |
20879 | ||
20880 | @item hs38_linux | |
20881 | Compile for ARC HS38 CPU with all hardware extensions on. | |
20882 | ||
20883 | @item hs4x | |
20884 | Compile for ARC HS4x CPU. | |
20885 | ||
20886 | @item hs4xd | |
20887 | Compile for ARC HS4xD CPU. | |
20888 | ||
20889 | @item hs4x_rel31 | |
20890 | Compile for ARC HS4x CPU release 3.10a. | |
20891 | ||
20892 | @item arc600_norm | |
20893 | Compile for ARC 600 CPU with @code{norm} instructions enabled. | |
20894 | ||
20895 | @item arc600_mul32x16 | |
20896 | Compile for ARC 600 CPU with @code{norm} and 32x16-bit multiply | |
20897 | instructions enabled. | |
20898 | ||
20899 | @item arc600_mul64 | |
20900 | Compile for ARC 600 CPU with @code{norm} and @code{mul64}-family | |
20901 | instructions enabled. | |
20902 | ||
20903 | @item arc601_norm | |
20904 | Compile for ARC 601 CPU with @code{norm} instructions enabled. | |
20905 | ||
20906 | @item arc601_mul32x16 | |
20907 | Compile for ARC 601 CPU with @code{norm} and 32x16-bit multiply | |
20908 | instructions enabled. | |
20909 | ||
20910 | @item arc601_mul64 | |
20911 | Compile for ARC 601 CPU with @code{norm} and @code{mul64}-family | |
20912 | instructions enabled. | |
20913 | ||
20914 | @item nps400 | |
20915 | Compile for ARC 700 on NPS400 chip. | |
20916 | ||
20917 | @item em_mini | |
20918 | Compile for ARC EM minimalist configuration featuring reduced register | |
20919 | set. | |
20920 | ||
20921 | @end table | |
20922 | ||
d77de738 | 20923 | @opindex mdpfp |
d77de738 | 20924 | @opindex mdpfp-compact |
ddf6fe37 AA |
20925 | @item -mdpfp |
20926 | @itemx -mdpfp-compact | |
d77de738 ML |
20927 | Generate double-precision FPX instructions, tuned for the compact |
20928 | implementation. | |
20929 | ||
d77de738 | 20930 | @opindex mdpfp-fast |
ddf6fe37 | 20931 | @item -mdpfp-fast |
d77de738 ML |
20932 | Generate double-precision FPX instructions, tuned for the fast |
20933 | implementation. | |
20934 | ||
d77de738 | 20935 | @opindex mno-dpfp-lrsr |
ddf6fe37 | 20936 | @item -mno-dpfp-lrsr |
d77de738 ML |
20937 | Disable @code{lr} and @code{sr} instructions from using FPX extension |
20938 | aux registers. | |
20939 | ||
d77de738 | 20940 | @opindex mea |
ddf6fe37 | 20941 | @item -mea |
d77de738 ML |
20942 | Generate extended arithmetic instructions. Currently only |
20943 | @code{divaw}, @code{adds}, @code{subs}, and @code{sat16} are | |
20944 | supported. Only valid for @option{-mcpu=ARC700}. | |
20945 | ||
d77de738 ML |
20946 | @opindex mno-mpy |
20947 | @opindex mmpy | |
ddf6fe37 | 20948 | @item -mno-mpy |
d77de738 ML |
20949 | Do not generate @code{mpy}-family instructions for ARC700. This option is |
20950 | deprecated. | |
20951 | ||
d77de738 | 20952 | @opindex mmul32x16 |
ddf6fe37 | 20953 | @item -mmul32x16 |
d77de738 ML |
20954 | Generate 32x16-bit multiply and multiply-accumulate instructions. |
20955 | ||
d77de738 | 20956 | @opindex mmul64 |
ddf6fe37 | 20957 | @item -mmul64 |
d77de738 ML |
20958 | Generate @code{mul64} and @code{mulu64} instructions. |
20959 | Only valid for @option{-mcpu=ARC600}. | |
20960 | ||
d77de738 | 20961 | @opindex mnorm |
ddf6fe37 | 20962 | @item -mnorm |
d77de738 ML |
20963 | Generate @code{norm} instructions. This is the default if @option{-mcpu=ARC700} |
20964 | is in effect. | |
20965 | ||
d77de738 | 20966 | @opindex mspfp |
d77de738 | 20967 | @opindex mspfp-compact |
ddf6fe37 AA |
20968 | @item -mspfp |
20969 | @itemx -mspfp-compact | |
d77de738 ML |
20970 | Generate single-precision FPX instructions, tuned for the compact |
20971 | implementation. | |
20972 | ||
d77de738 | 20973 | @opindex mspfp-fast |
ddf6fe37 | 20974 | @item -mspfp-fast |
d77de738 ML |
20975 | Generate single-precision FPX instructions, tuned for the fast |
20976 | implementation. | |
20977 | ||
d77de738 | 20978 | @opindex msimd |
ddf6fe37 | 20979 | @item -msimd |
d77de738 ML |
20980 | Enable generation of ARC SIMD instructions via target-specific |
20981 | builtins. Only valid for @option{-mcpu=ARC700}. | |
20982 | ||
d77de738 | 20983 | @opindex msoft-float |
ddf6fe37 | 20984 | @item -msoft-float |
d77de738 ML |
20985 | This option ignored; it is provided for compatibility purposes only. |
20986 | Software floating-point code is emitted by default, and this default | |
20987 | can overridden by FPX options; @option{-mspfp}, @option{-mspfp-compact}, or | |
20988 | @option{-mspfp-fast} for single precision, and @option{-mdpfp}, | |
20989 | @option{-mdpfp-compact}, or @option{-mdpfp-fast} for double precision. | |
20990 | ||
d77de738 | 20991 | @opindex mswap |
ddf6fe37 | 20992 | @item -mswap |
d77de738 ML |
20993 | Generate @code{swap} instructions. |
20994 | ||
d77de738 | 20995 | @opindex matomic |
ddf6fe37 | 20996 | @item -matomic |
d77de738 ML |
20997 | This enables use of the locked load/store conditional extension to implement |
20998 | atomic memory built-in functions. Not available for ARC 6xx or ARC | |
20999 | EM cores. | |
21000 | ||
d77de738 | 21001 | @opindex mdiv-rem |
ddf6fe37 | 21002 | @item -mdiv-rem |
d77de738 ML |
21003 | Enable @code{div} and @code{rem} instructions for ARCv2 cores. |
21004 | ||
d77de738 | 21005 | @opindex mcode-density |
ddf6fe37 | 21006 | @item -mcode-density |
d77de738 ML |
21007 | Enable code density instructions for ARC EM. |
21008 | This option is on by default for ARC HS. | |
21009 | ||
d77de738 | 21010 | @opindex mll64 |
ddf6fe37 | 21011 | @item -mll64 |
d77de738 ML |
21012 | Enable double load/store operations for ARC HS cores. |
21013 | ||
d77de738 | 21014 | @opindex mtp-regno |
ddf6fe37 | 21015 | @item -mtp-regno=@var{regno} |
d77de738 ML |
21016 | Specify thread pointer register number. |
21017 | ||
d77de738 | 21018 | @opindex mmpy-option |
ddf6fe37 | 21019 | @item -mmpy-option=@var{multo} |
d77de738 ML |
21020 | Compile ARCv2 code with a multiplier design option. You can specify |
21021 | the option using either a string or numeric value for @var{multo}. | |
21022 | @samp{wlh1} is the default value. The recognized values are: | |
21023 | ||
21024 | @table @samp | |
21025 | @item 0 | |
21026 | @itemx none | |
21027 | No multiplier available. | |
21028 | ||
21029 | @item 1 | |
21030 | @itemx w | |
21031 | 16x16 multiplier, fully pipelined. | |
21032 | The following instructions are enabled: @code{mpyw} and @code{mpyuw}. | |
21033 | ||
21034 | @item 2 | |
21035 | @itemx wlh1 | |
21036 | 32x32 multiplier, fully | |
21037 | pipelined (1 stage). The following instructions are additionally | |
21038 | enabled: @code{mpy}, @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21039 | ||
21040 | @item 3 | |
21041 | @itemx wlh2 | |
21042 | 32x32 multiplier, fully pipelined | |
21043 | (2 stages). The following instructions are additionally enabled: @code{mpy}, | |
21044 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21045 | ||
21046 | @item 4 | |
21047 | @itemx wlh3 | |
21048 | Two 16x16 multipliers, blocking, | |
21049 | sequential. The following instructions are additionally enabled: @code{mpy}, | |
21050 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21051 | ||
21052 | @item 5 | |
21053 | @itemx wlh4 | |
21054 | One 16x16 multiplier, blocking, | |
21055 | sequential. The following instructions are additionally enabled: @code{mpy}, | |
21056 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21057 | ||
21058 | @item 6 | |
21059 | @itemx wlh5 | |
21060 | One 32x4 multiplier, blocking, | |
21061 | sequential. The following instructions are additionally enabled: @code{mpy}, | |
21062 | @code{mpyu}, @code{mpym}, @code{mpymu}, and @code{mpy_s}. | |
21063 | ||
21064 | @item 7 | |
21065 | @itemx plus_dmpy | |
21066 | ARC HS SIMD support. | |
21067 | ||
21068 | @item 8 | |
21069 | @itemx plus_macd | |
21070 | ARC HS SIMD support. | |
21071 | ||
21072 | @item 9 | |
21073 | @itemx plus_qmacw | |
21074 | ARC HS SIMD support. | |
21075 | ||
21076 | @end table | |
21077 | ||
21078 | This option is only available for ARCv2 cores@. | |
21079 | ||
d77de738 | 21080 | @opindex mfpu |
ddf6fe37 | 21081 | @item -mfpu=@var{fpu} |
d77de738 ML |
21082 | Enables support for specific floating-point hardware extensions for ARCv2 |
21083 | cores. Supported values for @var{fpu} are: | |
21084 | ||
21085 | @table @samp | |
21086 | ||
21087 | @item fpus | |
21088 | Enables support for single-precision floating-point hardware | |
21089 | extensions@. | |
21090 | ||
21091 | @item fpud | |
21092 | Enables support for double-precision floating-point hardware | |
21093 | extensions. The single-precision floating-point extension is also | |
21094 | enabled. Not available for ARC EM@. | |
21095 | ||
21096 | @item fpuda | |
21097 | Enables support for double-precision floating-point hardware | |
21098 | extensions using double-precision assist instructions. The single-precision | |
21099 | floating-point extension is also enabled. This option is | |
21100 | only available for ARC EM@. | |
21101 | ||
21102 | @item fpuda_div | |
21103 | Enables support for double-precision floating-point hardware | |
21104 | extensions using double-precision assist instructions. | |
21105 | The single-precision floating-point, square-root, and divide | |
21106 | extensions are also enabled. This option is | |
21107 | only available for ARC EM@. | |
21108 | ||
21109 | @item fpuda_fma | |
21110 | Enables support for double-precision floating-point hardware | |
21111 | extensions using double-precision assist instructions. | |
21112 | The single-precision floating-point and fused multiply and add | |
21113 | hardware extensions are also enabled. This option is | |
21114 | only available for ARC EM@. | |
21115 | ||
21116 | @item fpuda_all | |
21117 | Enables support for double-precision floating-point hardware | |
21118 | extensions using double-precision assist instructions. | |
21119 | All single-precision floating-point hardware extensions are also | |
21120 | enabled. This option is only available for ARC EM@. | |
21121 | ||
21122 | @item fpus_div | |
21123 | Enables support for single-precision floating-point, square-root and divide | |
21124 | hardware extensions@. | |
21125 | ||
21126 | @item fpud_div | |
21127 | Enables support for double-precision floating-point, square-root and divide | |
21128 | hardware extensions. This option | |
21129 | includes option @samp{fpus_div}. Not available for ARC EM@. | |
21130 | ||
21131 | @item fpus_fma | |
21132 | Enables support for single-precision floating-point and | |
21133 | fused multiply and add hardware extensions@. | |
21134 | ||
21135 | @item fpud_fma | |
21136 | Enables support for double-precision floating-point and | |
21137 | fused multiply and add hardware extensions. This option | |
21138 | includes option @samp{fpus_fma}. Not available for ARC EM@. | |
21139 | ||
21140 | @item fpus_all | |
21141 | Enables support for all single-precision floating-point hardware | |
21142 | extensions@. | |
21143 | ||
21144 | @item fpud_all | |
21145 | Enables support for all single- and double-precision floating-point | |
21146 | hardware extensions. Not available for ARC EM@. | |
21147 | ||
21148 | @end table | |
21149 | ||
d77de738 | 21150 | @opindex mirq-ctrl-saved |
ddf6fe37 | 21151 | @item -mirq-ctrl-saved=@var{register-range}, @var{blink}, @var{lp_count} |
d77de738 ML |
21152 | Specifies general-purposes registers that the processor automatically |
21153 | saves/restores on interrupt entry and exit. @var{register-range} is | |
21154 | specified as two registers separated by a dash. The register range | |
21155 | always starts with @code{r0}, the upper limit is @code{fp} register. | |
21156 | @var{blink} and @var{lp_count} are optional. This option is only | |
21157 | valid for ARC EM and ARC HS cores. | |
21158 | ||
d77de738 | 21159 | @opindex mrgf-banked-regs |
ddf6fe37 | 21160 | @item -mrgf-banked-regs=@var{number} |
d77de738 ML |
21161 | Specifies the number of registers replicated in second register bank |
21162 | on entry to fast interrupt. Fast interrupts are interrupts with the | |
21163 | highest priority level P0. These interrupts save only PC and STATUS32 | |
21164 | registers to avoid memory transactions during interrupt entry and exit | |
21165 | sequences. Use this option when you are using fast interrupts in an | |
21166 | ARC V2 family processor. Permitted values are 4, 8, 16, and 32. | |
21167 | ||
d77de738 | 21168 | @opindex mlpc-width |
ddf6fe37 | 21169 | @item -mlpc-width=@var{width} |
d77de738 ML |
21170 | Specify the width of the @code{lp_count} register. Valid values for |
21171 | @var{width} are 8, 16, 20, 24, 28 and 32 bits. The default width is | |
21172 | fixed to 32 bits. If the width is less than 32, the compiler does not | |
21173 | attempt to transform loops in your program to use the zero-delay loop | |
21174 | mechanism unless it is known that the @code{lp_count} register can | |
21175 | hold the required loop-counter value. Depending on the width | |
21176 | specified, the compiler and run-time library might continue to use the | |
21177 | loop mechanism for various needs. This option defines macro | |
21178 | @code{__ARC_LPC_WIDTH__} with the value of @var{width}. | |
21179 | ||
d77de738 | 21180 | @opindex mrf16 |
ddf6fe37 | 21181 | @item -mrf16 |
d77de738 ML |
21182 | This option instructs the compiler to generate code for a 16-entry |
21183 | register file. This option defines the @code{__ARC_RF16__} | |
21184 | preprocessor macro. | |
21185 | ||
d77de738 | 21186 | @opindex mbranch-index |
ddf6fe37 | 21187 | @item -mbranch-index |
d77de738 ML |
21188 | Enable use of @code{bi} or @code{bih} instructions to implement jump |
21189 | tables. | |
21190 | ||
21191 | @end table | |
21192 | ||
21193 | The following options are passed through to the assembler, and also | |
21194 | define preprocessor macro symbols. | |
21195 | ||
21196 | @c Flags used by the assembler, but for which we define preprocessor | |
21197 | @c macro symbols as well. | |
21198 | @table @gcctabopt | |
d77de738 | 21199 | @opindex mdsp-packa |
ddf6fe37 | 21200 | @item -mdsp-packa |
d77de738 ML |
21201 | Passed down to the assembler to enable the DSP Pack A extensions. |
21202 | Also sets the preprocessor symbol @code{__Xdsp_packa}. This option is | |
21203 | deprecated. | |
21204 | ||
d77de738 | 21205 | @opindex mdvbf |
ddf6fe37 | 21206 | @item -mdvbf |
d77de738 ML |
21207 | Passed down to the assembler to enable the dual Viterbi butterfly |
21208 | extension. Also sets the preprocessor symbol @code{__Xdvbf}. This | |
21209 | option is deprecated. | |
21210 | ||
21211 | @c ARC700 4.10 extension instruction | |
d77de738 | 21212 | @opindex mlock |
ddf6fe37 | 21213 | @item -mlock |
d77de738 ML |
21214 | Passed down to the assembler to enable the locked load/store |
21215 | conditional extension. Also sets the preprocessor symbol | |
21216 | @code{__Xlock}. | |
21217 | ||
d77de738 | 21218 | @opindex mmac-d16 |
ddf6fe37 | 21219 | @item -mmac-d16 |
d77de738 ML |
21220 | Passed down to the assembler. Also sets the preprocessor symbol |
21221 | @code{__Xxmac_d16}. This option is deprecated. | |
21222 | ||
d77de738 | 21223 | @opindex mmac-24 |
ddf6fe37 | 21224 | @item -mmac-24 |
d77de738 ML |
21225 | Passed down to the assembler. Also sets the preprocessor symbol |
21226 | @code{__Xxmac_24}. This option is deprecated. | |
21227 | ||
21228 | @c ARC700 4.10 extension instruction | |
d77de738 | 21229 | @opindex mrtsc |
ddf6fe37 | 21230 | @item -mrtsc |
d77de738 ML |
21231 | Passed down to the assembler to enable the 64-bit time-stamp counter |
21232 | extension instruction. Also sets the preprocessor symbol | |
21233 | @code{__Xrtsc}. This option is deprecated. | |
21234 | ||
21235 | @c ARC700 4.10 extension instruction | |
d77de738 | 21236 | @opindex mswape |
ddf6fe37 | 21237 | @item -mswape |
d77de738 ML |
21238 | Passed down to the assembler to enable the swap byte ordering |
21239 | extension instruction. Also sets the preprocessor symbol | |
21240 | @code{__Xswape}. | |
21241 | ||
d77de738 | 21242 | @opindex mtelephony |
ddf6fe37 | 21243 | @item -mtelephony |
d77de738 ML |
21244 | Passed down to the assembler to enable dual- and single-operand |
21245 | instructions for telephony. Also sets the preprocessor symbol | |
21246 | @code{__Xtelephony}. This option is deprecated. | |
21247 | ||
d77de738 | 21248 | @opindex mxy |
ddf6fe37 | 21249 | @item -mxy |
d77de738 ML |
21250 | Passed down to the assembler to enable the XY memory extension. Also |
21251 | sets the preprocessor symbol @code{__Xxy}. | |
21252 | ||
21253 | @end table | |
21254 | ||
21255 | The following options control how the assembly code is annotated: | |
21256 | ||
21257 | @c Assembly annotation options | |
21258 | @table @gcctabopt | |
d77de738 | 21259 | @opindex misize |
ddf6fe37 | 21260 | @item -misize |
d77de738 ML |
21261 | Annotate assembler instructions with estimated addresses. |
21262 | ||
d77de738 | 21263 | @opindex mannotate-align |
ddf6fe37 | 21264 | @item -mannotate-align |
d77de738 ML |
21265 | Explain what alignment considerations lead to the decision to make an |
21266 | instruction short or long. | |
21267 | ||
21268 | @end table | |
21269 | ||
21270 | The following options are passed through to the linker: | |
21271 | ||
21272 | @c options passed through to the linker | |
21273 | @table @gcctabopt | |
d77de738 | 21274 | @opindex marclinux |
ddf6fe37 | 21275 | @item -marclinux |
d77de738 ML |
21276 | Passed through to the linker, to specify use of the @code{arclinux} emulation. |
21277 | This option is enabled by default in tool chains built for | |
21278 | @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets | |
21279 | when profiling is not requested. | |
21280 | ||
d77de738 | 21281 | @opindex marclinux_prof |
ddf6fe37 | 21282 | @item -marclinux_prof |
d77de738 ML |
21283 | Passed through to the linker, to specify use of the |
21284 | @code{arclinux_prof} emulation. This option is enabled by default in | |
21285 | tool chains built for @w{@code{arc-linux-uclibc}} and | |
21286 | @w{@code{arceb-linux-uclibc}} targets when profiling is requested. | |
21287 | ||
21288 | @end table | |
21289 | ||
21290 | The following options control the semantics of generated code: | |
21291 | ||
21292 | @c semantically relevant code generation options | |
21293 | @table @gcctabopt | |
d77de738 | 21294 | @opindex mlong-calls |
ddf6fe37 | 21295 | @item -mlong-calls |
d77de738 ML |
21296 | Generate calls as register indirect calls, thus providing access |
21297 | to the full 32-bit address range. | |
21298 | ||
d77de738 | 21299 | @opindex mmedium-calls |
ddf6fe37 | 21300 | @item -mmedium-calls |
d77de738 ML |
21301 | Don't use less than 25-bit addressing range for calls, which is the |
21302 | offset available for an unconditional branch-and-link | |
21303 | instruction. Conditional execution of function calls is suppressed, to | |
21304 | allow use of the 25-bit range, rather than the 21-bit range with | |
21305 | conditional branch-and-link. This is the default for tool chains built | |
21306 | for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} targets. | |
21307 | ||
d77de738 | 21308 | @opindex G |
ddf6fe37 | 21309 | @item -G @var{num} |
d77de738 ML |
21310 | Put definitions of externally-visible data in a small data section if |
21311 | that data is no bigger than @var{num} bytes. The default value of | |
21312 | @var{num} is 4 for any ARC configuration, or 8 when we have double | |
21313 | load/store operations. | |
21314 | ||
d77de738 ML |
21315 | @opindex mno-sdata |
21316 | @opindex msdata | |
ddf6fe37 | 21317 | @item -mno-sdata |
d77de738 ML |
21318 | Do not generate sdata references. This is the default for tool chains |
21319 | built for @w{@code{arc-linux-uclibc}} and @w{@code{arceb-linux-uclibc}} | |
21320 | targets. | |
21321 | ||
d77de738 | 21322 | @opindex mvolatile-cache |
ddf6fe37 | 21323 | @item -mvolatile-cache |
d77de738 ML |
21324 | Use ordinarily cached memory accesses for volatile references. This is the |
21325 | default. | |
21326 | ||
d77de738 ML |
21327 | @opindex mno-volatile-cache |
21328 | @opindex mvolatile-cache | |
ddf6fe37 | 21329 | @item -mno-volatile-cache |
d77de738 ML |
21330 | Enable cache bypass for volatile references. |
21331 | ||
21332 | @end table | |
21333 | ||
21334 | The following options fine tune code generation: | |
21335 | @c code generation tuning options | |
21336 | @table @gcctabopt | |
d77de738 | 21337 | @opindex malign-call |
ddf6fe37 | 21338 | @item -malign-call |
d77de738 ML |
21339 | Does nothing. Preserved for backward compatibility. |
21340 | ||
d77de738 | 21341 | @opindex mauto-modify-reg |
ddf6fe37 | 21342 | @item -mauto-modify-reg |
d77de738 ML |
21343 | Enable the use of pre/post modify with register displacement. |
21344 | ||
d77de738 | 21345 | @opindex mbbit-peephole |
ddf6fe37 | 21346 | @item -mbbit-peephole |
d77de738 ML |
21347 | Enable bbit peephole2. |
21348 | ||
d77de738 | 21349 | @opindex mno-brcc |
ddf6fe37 | 21350 | @item -mno-brcc |
d77de738 ML |
21351 | This option disables a target-specific pass in @file{arc_reorg} to |
21352 | generate compare-and-branch (@code{br@var{cc}}) instructions. | |
21353 | It has no effect on | |
21354 | generation of these instructions driven by the combiner pass. | |
21355 | ||
d77de738 | 21356 | @opindex mcase-vector-pcrel |
ddf6fe37 | 21357 | @item -mcase-vector-pcrel |
d77de738 ML |
21358 | Use PC-relative switch case tables to enable case table shortening. |
21359 | This is the default for @option{-Os}. | |
21360 | ||
d77de738 | 21361 | @opindex mcompact-casesi |
ddf6fe37 | 21362 | @item -mcompact-casesi |
d77de738 ML |
21363 | Enable compact @code{casesi} pattern. This is the default for @option{-Os}, |
21364 | and only available for ARCv1 cores. This option is deprecated. | |
21365 | ||
d77de738 | 21366 | @opindex mno-cond-exec |
ddf6fe37 | 21367 | @item -mno-cond-exec |
d77de738 ML |
21368 | Disable the ARCompact-specific pass to generate conditional |
21369 | execution instructions. | |
21370 | ||
21371 | Due to delay slot scheduling and interactions between operand numbers, | |
21372 | literal sizes, instruction lengths, and the support for conditional execution, | |
21373 | the target-independent pass to generate conditional execution is often lacking, | |
21374 | so the ARC port has kept a special pass around that tries to find more | |
21375 | conditional execution generation opportunities after register allocation, | |
21376 | branch shortening, and delay slot scheduling have been done. This pass | |
21377 | generally, but not always, improves performance and code size, at the cost of | |
21378 | extra compilation time, which is why there is an option to switch it off. | |
21379 | If you have a problem with call instructions exceeding their allowable | |
21380 | offset range because they are conditionalized, you should consider using | |
21381 | @option{-mmedium-calls} instead. | |
21382 | ||
d77de738 | 21383 | @opindex mearly-cbranchsi |
ddf6fe37 | 21384 | @item -mearly-cbranchsi |
d77de738 ML |
21385 | Enable pre-reload use of the @code{cbranchsi} pattern. |
21386 | ||
d77de738 | 21387 | @opindex mexpand-adddi |
ddf6fe37 | 21388 | @item -mexpand-adddi |
d77de738 ML |
21389 | Expand @code{adddi3} and @code{subdi3} at RTL generation time into |
21390 | @code{add.f}, @code{adc} etc. This option is deprecated. | |
21391 | ||
d77de738 | 21392 | @opindex mindexed-loads |
ddf6fe37 | 21393 | @item -mindexed-loads |
d77de738 ML |
21394 | Enable the use of indexed loads. This can be problematic because some |
21395 | optimizers then assume that indexed stores exist, which is not | |
21396 | the case. | |
21397 | ||
d77de738 | 21398 | @opindex mlra |
ddf6fe37 | 21399 | @item -mlra |
d77de738 ML |
21400 | Enable Local Register Allocation. This is still experimental for ARC, |
21401 | so by default the compiler uses standard reload | |
21402 | (i.e.@: @option{-mno-lra}). | |
21403 | ||
d77de738 | 21404 | @opindex mlra-priority-none |
ddf6fe37 | 21405 | @item -mlra-priority-none |
d77de738 ML |
21406 | Don't indicate any priority for target registers. |
21407 | ||
d77de738 | 21408 | @opindex mlra-priority-compact |
ddf6fe37 | 21409 | @item -mlra-priority-compact |
d77de738 ML |
21410 | Indicate target register priority for r0..r3 / r12..r15. |
21411 | ||
d77de738 | 21412 | @opindex mlra-priority-noncompact |
ddf6fe37 | 21413 | @item -mlra-priority-noncompact |
d77de738 ML |
21414 | Reduce target register priority for r0..r3 / r12..r15. |
21415 | ||
d77de738 | 21416 | @opindex mmillicode |
ddf6fe37 | 21417 | @item -mmillicode |
d77de738 ML |
21418 | When optimizing for size (using @option{-Os}), prologues and epilogues |
21419 | that have to save or restore a large number of registers are often | |
21420 | shortened by using call to a special function in libgcc; this is | |
21421 | referred to as a @emph{millicode} call. As these calls can pose | |
21422 | performance issues, and/or cause linking issues when linking in a | |
21423 | nonstandard way, this option is provided to turn on or off millicode | |
21424 | call generation. | |
21425 | ||
d77de738 | 21426 | @opindex mcode-density-frame |
ddf6fe37 | 21427 | @item -mcode-density-frame |
d77de738 ML |
21428 | This option enable the compiler to emit @code{enter} and @code{leave} |
21429 | instructions. These instructions are only valid for CPUs with | |
21430 | code-density feature. | |
21431 | ||
d77de738 | 21432 | @opindex mmixed-code |
ddf6fe37 | 21433 | @item -mmixed-code |
d77de738 ML |
21434 | Does nothing. Preserved for backward compatibility. |
21435 | ||
d77de738 | 21436 | @opindex mq-class |
ddf6fe37 | 21437 | @item -mq-class |
d77de738 ML |
21438 | Ths option is deprecated. Enable @samp{q} instruction alternatives. |
21439 | This is the default for @option{-Os}. | |
21440 | ||
d77de738 | 21441 | @opindex mRcq |
ddf6fe37 | 21442 | @item -mRcq |
d77de738 ML |
21443 | Does nothing. Preserved for backward compatibility. |
21444 | ||
d77de738 | 21445 | @opindex mRcw |
ddf6fe37 | 21446 | @item -mRcw |
d77de738 ML |
21447 | Does nothing. Preserved for backward compatibility. |
21448 | ||
d77de738 | 21449 | @opindex msize-level |
ddf6fe37 | 21450 | @item -msize-level=@var{level} |
d77de738 ML |
21451 | Fine-tune size optimization with regards to instruction lengths and alignment. |
21452 | The recognized values for @var{level} are: | |
21453 | @table @samp | |
21454 | @item 0 | |
21455 | No size optimization. This level is deprecated and treated like @samp{1}. | |
21456 | ||
21457 | @item 1 | |
21458 | Short instructions are used opportunistically. | |
21459 | ||
21460 | @item 2 | |
21461 | In addition, alignment of loops and of code after barriers are dropped. | |
21462 | ||
21463 | @item 3 | |
21464 | In addition, optional data alignment is dropped, and the option @option{Os} is enabled. | |
21465 | ||
21466 | @end table | |
21467 | ||
21468 | This defaults to @samp{3} when @option{-Os} is in effect. Otherwise, | |
21469 | the behavior when this is not set is equivalent to level @samp{1}. | |
21470 | ||
d77de738 | 21471 | @opindex mtune |
ddf6fe37 | 21472 | @item -mtune=@var{cpu} |
d77de738 ML |
21473 | Set instruction scheduling parameters for @var{cpu}, overriding any implied |
21474 | by @option{-mcpu=}. | |
21475 | ||
21476 | Supported values for @var{cpu} are | |
21477 | ||
21478 | @table @samp | |
21479 | @item ARC600 | |
21480 | Tune for ARC600 CPU. | |
21481 | ||
21482 | @item ARC601 | |
21483 | Tune for ARC601 CPU. | |
21484 | ||
21485 | @item ARC700 | |
21486 | Tune for ARC700 CPU with standard multiplier block. | |
21487 | ||
21488 | @item ARC700-xmac | |
21489 | Tune for ARC700 CPU with XMAC block. | |
21490 | ||
21491 | @item ARC725D | |
21492 | Tune for ARC725D CPU. | |
21493 | ||
21494 | @item ARC750D | |
21495 | Tune for ARC750D CPU. | |
21496 | ||
21497 | @item core3 | |
21498 | Tune for ARCv2 core3 type CPU. This option enable usage of | |
21499 | @code{dbnz} instruction. | |
21500 | ||
21501 | @item release31a | |
21502 | Tune for ARC4x release 3.10a. | |
21503 | ||
21504 | @end table | |
21505 | ||
d77de738 | 21506 | @opindex mmultcost |
ddf6fe37 | 21507 | @item -mmultcost=@var{num} |
d77de738 ML |
21508 | Cost to assume for a multiply instruction, with @samp{4} being equal to a |
21509 | normal instruction. | |
21510 | ||
d77de738 | 21511 | @opindex munalign-prob-threshold |
ddf6fe37 | 21512 | @item -munalign-prob-threshold=@var{probability} |
d77de738 ML |
21513 | Does nothing. Preserved for backward compatibility. |
21514 | ||
21515 | @end table | |
21516 | ||
21517 | The following options are maintained for backward compatibility, but | |
21518 | are now deprecated and will be removed in a future release: | |
21519 | ||
21520 | @c Deprecated options | |
21521 | @table @gcctabopt | |
21522 | ||
d77de738 | 21523 | @opindex margonaut |
ddf6fe37 | 21524 | @item -margonaut |
d77de738 ML |
21525 | Obsolete FPX. |
21526 | ||
d77de738 | 21527 | @opindex mbig-endian |
d77de738 | 21528 | @opindex EB |
ddf6fe37 AA |
21529 | @item -mbig-endian |
21530 | @itemx -EB | |
d77de738 ML |
21531 | Compile code for big-endian targets. Use of these options is now |
21532 | deprecated. Big-endian code is supported by configuring GCC to build | |
21533 | @w{@code{arceb-elf32}} and @w{@code{arceb-linux-uclibc}} targets, | |
21534 | for which big endian is the default. | |
21535 | ||
d77de738 | 21536 | @opindex mlittle-endian |
d77de738 | 21537 | @opindex EL |
ddf6fe37 AA |
21538 | @item -mlittle-endian |
21539 | @itemx -EL | |
d77de738 ML |
21540 | Compile code for little-endian targets. Use of these options is now |
21541 | deprecated. Little-endian code is supported by configuring GCC to build | |
21542 | @w{@code{arc-elf32}} and @w{@code{arc-linux-uclibc}} targets, | |
21543 | for which little endian is the default. | |
21544 | ||
d77de738 | 21545 | @opindex mbarrel_shifter |
ddf6fe37 | 21546 | @item -mbarrel_shifter |
d77de738 ML |
21547 | Replaced by @option{-mbarrel-shifter}. |
21548 | ||
d77de738 | 21549 | @opindex mdpfp_compact |
ddf6fe37 | 21550 | @item -mdpfp_compact |
d77de738 ML |
21551 | Replaced by @option{-mdpfp-compact}. |
21552 | ||
d77de738 | 21553 | @opindex mdpfp_fast |
ddf6fe37 | 21554 | @item -mdpfp_fast |
d77de738 ML |
21555 | Replaced by @option{-mdpfp-fast}. |
21556 | ||
d77de738 | 21557 | @opindex mdsp_packa |
ddf6fe37 | 21558 | @item -mdsp_packa |
d77de738 ML |
21559 | Replaced by @option{-mdsp-packa}. |
21560 | ||
d77de738 | 21561 | @opindex mEA |
ddf6fe37 | 21562 | @item -mEA |
d77de738 ML |
21563 | Replaced by @option{-mea}. |
21564 | ||
d77de738 | 21565 | @opindex mmac_24 |
ddf6fe37 | 21566 | @item -mmac_24 |
d77de738 ML |
21567 | Replaced by @option{-mmac-24}. |
21568 | ||
d77de738 | 21569 | @opindex mmac_d16 |
ddf6fe37 | 21570 | @item -mmac_d16 |
d77de738 ML |
21571 | Replaced by @option{-mmac-d16}. |
21572 | ||
d77de738 | 21573 | @opindex mspfp_compact |
ddf6fe37 | 21574 | @item -mspfp_compact |
d77de738 ML |
21575 | Replaced by @option{-mspfp-compact}. |
21576 | ||
d77de738 | 21577 | @opindex mspfp_fast |
ddf6fe37 | 21578 | @item -mspfp_fast |
d77de738 ML |
21579 | Replaced by @option{-mspfp-fast}. |
21580 | ||
d77de738 | 21581 | @opindex mtune |
ddf6fe37 | 21582 | @item -mtune=@var{cpu} |
d77de738 ML |
21583 | Values @samp{arc600}, @samp{arc601}, @samp{arc700} and |
21584 | @samp{arc700-xmac} for @var{cpu} are replaced by @samp{ARC600}, | |
21585 | @samp{ARC601}, @samp{ARC700} and @samp{ARC700-xmac} respectively. | |
21586 | ||
d77de738 | 21587 | @opindex multcost |
ddf6fe37 | 21588 | @item -multcost=@var{num} |
d77de738 ML |
21589 | Replaced by @option{-mmultcost}. |
21590 | ||
21591 | @end table | |
21592 | ||
21593 | @node ARM Options | |
21594 | @subsection ARM Options | |
21595 | @cindex ARM options | |
21596 | ||
21597 | These @samp{-m} options are defined for the ARM port: | |
21598 | ||
21599 | @table @gcctabopt | |
d77de738 | 21600 | @opindex mabi |
ddf6fe37 | 21601 | @item -mabi=@var{name} |
d77de738 ML |
21602 | Generate code for the specified ABI@. Permissible values are: @samp{apcs-gnu}, |
21603 | @samp{atpcs}, @samp{aapcs}, @samp{aapcs-linux} and @samp{iwmmxt}. | |
21604 | ||
d77de738 | 21605 | @opindex mapcs-frame |
ddf6fe37 | 21606 | @item -mapcs-frame |
d77de738 ML |
21607 | Generate a stack frame that is compliant with the ARM Procedure Call |
21608 | Standard for all functions, even if this is not strictly necessary for | |
21609 | correct execution of the code. Specifying @option{-fomit-frame-pointer} | |
21610 | with this option causes the stack frames not to be generated for | |
21611 | leaf functions. The default is @option{-mno-apcs-frame}. | |
21612 | This option is deprecated. | |
21613 | ||
d77de738 | 21614 | @opindex mapcs |
ddf6fe37 | 21615 | @item -mapcs |
d77de738 ML |
21616 | This is a synonym for @option{-mapcs-frame} and is deprecated. |
21617 | ||
21618 | @ignore | |
21619 | @c not currently implemented | |
d77de738 | 21620 | @opindex mapcs-stack-check |
ddf6fe37 | 21621 | @item -mapcs-stack-check |
d77de738 ML |
21622 | Generate code to check the amount of stack space available upon entry to |
21623 | every function (that actually uses some stack space). If there is | |
21624 | insufficient space available then either the function | |
21625 | @code{__rt_stkovf_split_small} or @code{__rt_stkovf_split_big} is | |
21626 | called, depending upon the amount of stack space required. The runtime | |
21627 | system is required to provide these functions. The default is | |
21628 | @option{-mno-apcs-stack-check}, since this produces smaller code. | |
21629 | ||
21630 | @c not currently implemented | |
d77de738 | 21631 | @opindex mapcs-reentrant |
ddf6fe37 | 21632 | @item -mapcs-reentrant |
d77de738 ML |
21633 | Generate reentrant, position-independent code. The default is |
21634 | @option{-mno-apcs-reentrant}. | |
21635 | @end ignore | |
21636 | ||
d77de738 | 21637 | @opindex mthumb-interwork |
ddf6fe37 | 21638 | @item -mthumb-interwork |
d77de738 ML |
21639 | Generate code that supports calling between the ARM and Thumb |
21640 | instruction sets. Without this option, on pre-v5 architectures, the | |
21641 | two instruction sets cannot be reliably used inside one program. The | |
21642 | default is @option{-mno-thumb-interwork}, since slightly larger code | |
21643 | is generated when @option{-mthumb-interwork} is specified. In AAPCS | |
21644 | configurations this option is meaningless. | |
21645 | ||
d77de738 ML |
21646 | @opindex mno-sched-prolog |
21647 | @opindex msched-prolog | |
ddf6fe37 | 21648 | @item -mno-sched-prolog |
d77de738 ML |
21649 | Prevent the reordering of instructions in the function prologue, or the |
21650 | merging of those instruction with the instructions in the function's | |
21651 | body. This means that all functions start with a recognizable set | |
21652 | of instructions (or in fact one of a choice from a small set of | |
21653 | different function prologues), and this information can be used to | |
21654 | locate the start of functions inside an executable piece of code. The | |
21655 | default is @option{-msched-prolog}. | |
21656 | ||
d77de738 | 21657 | @opindex mfloat-abi |
ddf6fe37 | 21658 | @item -mfloat-abi=@var{name} |
d77de738 ML |
21659 | Specifies which floating-point ABI to use. Permissible values |
21660 | are: @samp{soft}, @samp{softfp} and @samp{hard}. | |
21661 | ||
21662 | Specifying @samp{soft} causes GCC to generate output containing | |
21663 | library calls for floating-point operations. | |
21664 | @samp{softfp} allows the generation of code using hardware floating-point | |
21665 | instructions, but still uses the soft-float calling conventions. | |
21666 | @samp{hard} allows generation of floating-point instructions | |
21667 | and uses FPU-specific calling conventions. | |
21668 | ||
21669 | The default depends on the specific target configuration. Note that | |
21670 | the hard-float and soft-float ABIs are not link-compatible; you must | |
21671 | compile your entire program with the same ABI, and link with a | |
21672 | compatible set of libraries. | |
21673 | ||
d77de738 | 21674 | @opindex mgeneral-regs-only |
ddf6fe37 | 21675 | @item -mgeneral-regs-only |
d77de738 ML |
21676 | Generate code which uses only the general-purpose registers. This will prevent |
21677 | the compiler from using floating-point and Advanced SIMD registers but will not | |
21678 | impose any restrictions on the assembler. | |
21679 | ||
d77de738 | 21680 | @opindex mlittle-endian |
ddf6fe37 | 21681 | @item -mlittle-endian |
d77de738 ML |
21682 | Generate code for a processor running in little-endian mode. This is |
21683 | the default for all standard configurations. | |
21684 | ||
d77de738 | 21685 | @opindex mbig-endian |
ddf6fe37 | 21686 | @item -mbig-endian |
d77de738 ML |
21687 | Generate code for a processor running in big-endian mode; the default is |
21688 | to compile code for a little-endian processor. | |
21689 | ||
ddf6fe37 | 21690 | @opindex mbe8 |
d77de738 ML |
21691 | @item -mbe8 |
21692 | @itemx -mbe32 | |
d77de738 ML |
21693 | When linking a big-endian image select between BE8 and BE32 formats. |
21694 | The option has no effect for little-endian images and is ignored. The | |
21695 | default is dependent on the selected target architecture. For ARMv6 | |
21696 | and later architectures the default is BE8, for older architectures | |
21697 | the default is BE32. BE32 format has been deprecated by ARM. | |
21698 | ||
d77de738 | 21699 | @opindex march |
ddf6fe37 | 21700 | @item -march=@var{name}@r{[}+extension@dots{}@r{]} |
d77de738 ML |
21701 | This specifies the name of the target ARM architecture. GCC uses this |
21702 | name to determine what kind of instructions it can emit when generating | |
21703 | assembly code. This option can be used in conjunction with or instead | |
21704 | of the @option{-mcpu=} option. | |
21705 | ||
21706 | Permissible names are: | |
21707 | @samp{armv4t}, | |
21708 | @samp{armv5t}, @samp{armv5te}, | |
21709 | @samp{armv6}, @samp{armv6j}, @samp{armv6k}, @samp{armv6kz}, @samp{armv6t2}, | |
21710 | @samp{armv6z}, @samp{armv6zk}, | |
21711 | @samp{armv7}, @samp{armv7-a}, @samp{armv7ve}, | |
21712 | @samp{armv8-a}, @samp{armv8.1-a}, @samp{armv8.2-a}, @samp{armv8.3-a}, | |
21713 | @samp{armv8.4-a}, | |
21714 | @samp{armv8.5-a}, | |
21715 | @samp{armv8.6-a}, | |
21716 | @samp{armv9-a}, | |
21717 | @samp{armv7-r}, | |
21718 | @samp{armv8-r}, | |
21719 | @samp{armv6-m}, @samp{armv6s-m}, | |
21720 | @samp{armv7-m}, @samp{armv7e-m}, | |
21721 | @samp{armv8-m.base}, @samp{armv8-m.main}, | |
21722 | @samp{armv8.1-m.main}, | |
21723 | @samp{armv9-a}, | |
21724 | @samp{iwmmxt} and @samp{iwmmxt2}. | |
21725 | ||
21726 | Additionally, the following architectures, which lack support for the | |
21727 | Thumb execution state, are recognized but support is deprecated: @samp{armv4}. | |
21728 | ||
21729 | Many of the architectures support extensions. These can be added by | |
21730 | appending @samp{+@var{extension}} to the architecture name. Extension | |
21731 | options are processed in order and capabilities accumulate. An extension | |
21732 | will also enable any necessary base extensions | |
21733 | upon which it depends. For example, the @samp{+crypto} extension | |
21734 | will always enable the @samp{+simd} extension. The exception to the | |
21735 | additive construction is for extensions that are prefixed with | |
21736 | @samp{+no@dots{}}: these extensions disable the specified option and | |
21737 | any other extensions that may depend on the presence of that | |
21738 | extension. | |
21739 | ||
21740 | For example, @samp{-march=armv7-a+simd+nofp+vfpv4} is equivalent to | |
21741 | writing @samp{-march=armv7-a+vfpv4} since the @samp{+simd} option is | |
21742 | entirely disabled by the @samp{+nofp} option that follows it. | |
21743 | ||
21744 | Most extension names are generically named, but have an effect that is | |
21745 | dependent upon the architecture to which it is applied. For example, | |
21746 | the @samp{+simd} option can be applied to both @samp{armv7-a} and | |
21747 | @samp{armv8-a} architectures, but will enable the original ARMv7-A | |
21748 | Advanced SIMD (Neon) extensions for @samp{armv7-a} and the ARMv8-A | |
21749 | variant for @samp{armv8-a}. | |
21750 | ||
21751 | The table below lists the supported extensions for each architecture. | |
21752 | Architectures not mentioned do not support any extensions. | |
21753 | ||
21754 | @table @samp | |
21755 | @item armv5te | |
21756 | @itemx armv6 | |
21757 | @itemx armv6j | |
21758 | @itemx armv6k | |
21759 | @itemx armv6kz | |
21760 | @itemx armv6t2 | |
21761 | @itemx armv6z | |
21762 | @itemx armv6zk | |
21763 | @table @samp | |
21764 | @item +fp | |
21765 | The VFPv2 floating-point instructions. The extension @samp{+vfpv2} can be | |
21766 | used as an alias for this extension. | |
21767 | ||
21768 | @item +nofp | |
21769 | Disable the floating-point instructions. | |
21770 | @end table | |
21771 | ||
21772 | @item armv7 | |
21773 | The common subset of the ARMv7-A, ARMv7-R and ARMv7-M architectures. | |
21774 | @table @samp | |
21775 | @item +fp | |
21776 | The VFPv3 floating-point instructions, with 16 double-precision | |
21777 | registers. The extension @samp{+vfpv3-d16} can be used as an alias | |
21778 | for this extension. Note that floating-point is not supported by the | |
21779 | base ARMv7-M architecture, but is compatible with both the ARMv7-A and | |
21780 | ARMv7-R architectures. | |
21781 | ||
21782 | @item +nofp | |
21783 | Disable the floating-point instructions. | |
21784 | @end table | |
21785 | ||
21786 | @item armv7-a | |
21787 | @table @samp | |
21788 | @item +mp | |
21789 | The multiprocessing extension. | |
21790 | ||
21791 | @item +sec | |
21792 | The security extension. | |
21793 | ||
21794 | @item +fp | |
21795 | The VFPv3 floating-point instructions, with 16 double-precision | |
21796 | registers. The extension @samp{+vfpv3-d16} can be used as an alias | |
21797 | for this extension. | |
21798 | ||
21799 | @item +simd | |
21800 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions. | |
21801 | The extensions @samp{+neon} and @samp{+neon-vfpv3} can be used as aliases | |
21802 | for this extension. | |
21803 | ||
21804 | @item +vfpv3 | |
21805 | The VFPv3 floating-point instructions, with 32 double-precision | |
21806 | registers. | |
21807 | ||
21808 | @item +vfpv3-d16-fp16 | |
21809 | The VFPv3 floating-point instructions, with 16 double-precision | |
21810 | registers and the half-precision floating-point conversion operations. | |
21811 | ||
21812 | @item +vfpv3-fp16 | |
21813 | The VFPv3 floating-point instructions, with 32 double-precision | |
21814 | registers and the half-precision floating-point conversion operations. | |
21815 | ||
21816 | @item +vfpv4-d16 | |
21817 | The VFPv4 floating-point instructions, with 16 double-precision | |
21818 | registers. | |
21819 | ||
21820 | @item +vfpv4 | |
21821 | The VFPv4 floating-point instructions, with 32 double-precision | |
21822 | registers. | |
21823 | ||
21824 | @item +neon-fp16 | |
21825 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with | |
21826 | the half-precision floating-point conversion operations. | |
21827 | ||
21828 | @item +neon-vfpv4 | |
21829 | The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. | |
21830 | ||
21831 | @item +nosimd | |
21832 | Disable the Advanced SIMD instructions (does not disable floating point). | |
21833 | ||
21834 | @item +nofp | |
21835 | Disable the floating-point and Advanced SIMD instructions. | |
21836 | @end table | |
21837 | ||
21838 | @item armv7ve | |
21839 | The extended version of the ARMv7-A architecture with support for | |
21840 | virtualization. | |
21841 | @table @samp | |
21842 | @item +fp | |
21843 | The VFPv4 floating-point instructions, with 16 double-precision registers. | |
21844 | The extension @samp{+vfpv4-d16} can be used as an alias for this extension. | |
21845 | ||
21846 | @item +simd | |
21847 | The Advanced SIMD (Neon) v2 and the VFPv4 floating-point instructions. The | |
21848 | extension @samp{+neon-vfpv4} can be used as an alias for this extension. | |
21849 | ||
21850 | @item +vfpv3-d16 | |
21851 | The VFPv3 floating-point instructions, with 16 double-precision | |
21852 | registers. | |
21853 | ||
21854 | @item +vfpv3 | |
21855 | The VFPv3 floating-point instructions, with 32 double-precision | |
21856 | registers. | |
21857 | ||
21858 | @item +vfpv3-d16-fp16 | |
21859 | The VFPv3 floating-point instructions, with 16 double-precision | |
21860 | registers and the half-precision floating-point conversion operations. | |
21861 | ||
21862 | @item +vfpv3-fp16 | |
21863 | The VFPv3 floating-point instructions, with 32 double-precision | |
21864 | registers and the half-precision floating-point conversion operations. | |
21865 | ||
21866 | @item +vfpv4-d16 | |
21867 | The VFPv4 floating-point instructions, with 16 double-precision | |
21868 | registers. | |
21869 | ||
21870 | @item +vfpv4 | |
21871 | The VFPv4 floating-point instructions, with 32 double-precision | |
21872 | registers. | |
21873 | ||
21874 | @item +neon | |
21875 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions. | |
21876 | The extension @samp{+neon-vfpv3} can be used as an alias for this extension. | |
21877 | ||
21878 | @item +neon-fp16 | |
21879 | The Advanced SIMD (Neon) v1 and the VFPv3 floating-point instructions, with | |
21880 | the half-precision floating-point conversion operations. | |
21881 | ||
21882 | @item +nosimd | |
21883 | Disable the Advanced SIMD instructions (does not disable floating point). | |
21884 | ||
21885 | @item +nofp | |
21886 | Disable the floating-point and Advanced SIMD instructions. | |
21887 | @end table | |
21888 | ||
21889 | @item armv8-a | |
21890 | @table @samp | |
21891 | @item +crc | |
21892 | The Cyclic Redundancy Check (CRC) instructions. | |
21893 | @item +simd | |
21894 | The ARMv8-A Advanced SIMD and floating-point instructions. | |
21895 | @item +crypto | |
21896 | The cryptographic instructions. | |
21897 | @item +nocrypto | |
21898 | Disable the cryptographic instructions. | |
21899 | @item +nofp | |
21900 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
21901 | @item +sb | |
21902 | Speculation Barrier Instruction. | |
21903 | @item +predres | |
21904 | Execution and Data Prediction Restriction Instructions. | |
21905 | @end table | |
21906 | ||
21907 | @item armv8.1-a | |
21908 | @table @samp | |
21909 | @item +simd | |
21910 | The ARMv8.1-A Advanced SIMD and floating-point instructions. | |
21911 | ||
21912 | @item +crypto | |
21913 | The cryptographic instructions. This also enables the Advanced SIMD and | |
21914 | floating-point instructions. | |
21915 | ||
21916 | @item +nocrypto | |
21917 | Disable the cryptographic instructions. | |
21918 | ||
21919 | @item +nofp | |
21920 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
21921 | ||
21922 | @item +sb | |
21923 | Speculation Barrier Instruction. | |
21924 | ||
21925 | @item +predres | |
21926 | Execution and Data Prediction Restriction Instructions. | |
21927 | @end table | |
21928 | ||
21929 | @item armv8.2-a | |
21930 | @itemx armv8.3-a | |
21931 | @table @samp | |
21932 | @item +fp16 | |
21933 | The half-precision floating-point data processing instructions. | |
21934 | This also enables the Advanced SIMD and floating-point instructions. | |
21935 | ||
21936 | @item +fp16fml | |
21937 | The half-precision floating-point fmla extension. This also enables | |
21938 | the half-precision floating-point extension and Advanced SIMD and | |
21939 | floating-point instructions. | |
21940 | ||
21941 | @item +simd | |
21942 | The ARMv8.1-A Advanced SIMD and floating-point instructions. | |
21943 | ||
21944 | @item +crypto | |
21945 | The cryptographic instructions. This also enables the Advanced SIMD and | |
21946 | floating-point instructions. | |
21947 | ||
21948 | @item +dotprod | |
21949 | Enable the Dot Product extension. This also enables Advanced SIMD instructions. | |
21950 | ||
21951 | @item +nocrypto | |
21952 | Disable the cryptographic extension. | |
21953 | ||
21954 | @item +nofp | |
21955 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
21956 | ||
21957 | @item +sb | |
21958 | Speculation Barrier Instruction. | |
21959 | ||
21960 | @item +predres | |
21961 | Execution and Data Prediction Restriction Instructions. | |
21962 | ||
21963 | @item +i8mm | |
21964 | 8-bit Integer Matrix Multiply instructions. | |
21965 | This also enables Advanced SIMD and floating-point instructions. | |
21966 | ||
21967 | @item +bf16 | |
21968 | Brain half-precision floating-point instructions. | |
21969 | This also enables Advanced SIMD and floating-point instructions. | |
21970 | @end table | |
21971 | ||
21972 | @item armv8.4-a | |
21973 | @table @samp | |
21974 | @item +fp16 | |
21975 | The half-precision floating-point data processing instructions. | |
21976 | This also enables the Advanced SIMD and floating-point instructions as well | |
21977 | as the Dot Product extension and the half-precision floating-point fmla | |
21978 | extension. | |
21979 | ||
21980 | @item +simd | |
21981 | The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the | |
21982 | Dot Product extension. | |
21983 | ||
21984 | @item +crypto | |
21985 | The cryptographic instructions. This also enables the Advanced SIMD and | |
21986 | floating-point instructions as well as the Dot Product extension. | |
21987 | ||
21988 | @item +nocrypto | |
21989 | Disable the cryptographic extension. | |
21990 | ||
21991 | @item +nofp | |
21992 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
21993 | ||
21994 | @item +sb | |
21995 | Speculation Barrier Instruction. | |
21996 | ||
21997 | @item +predres | |
21998 | Execution and Data Prediction Restriction Instructions. | |
21999 | ||
22000 | @item +i8mm | |
22001 | 8-bit Integer Matrix Multiply instructions. | |
22002 | This also enables Advanced SIMD and floating-point instructions. | |
22003 | ||
22004 | @item +bf16 | |
22005 | Brain half-precision floating-point instructions. | |
22006 | This also enables Advanced SIMD and floating-point instructions. | |
22007 | @end table | |
22008 | ||
22009 | @item armv8.5-a | |
22010 | @table @samp | |
22011 | @item +fp16 | |
22012 | The half-precision floating-point data processing instructions. | |
22013 | This also enables the Advanced SIMD and floating-point instructions as well | |
22014 | as the Dot Product extension and the half-precision floating-point fmla | |
22015 | extension. | |
22016 | ||
22017 | @item +simd | |
22018 | The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the | |
22019 | Dot Product extension. | |
22020 | ||
22021 | @item +crypto | |
22022 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22023 | floating-point instructions as well as the Dot Product extension. | |
22024 | ||
22025 | @item +nocrypto | |
22026 | Disable the cryptographic extension. | |
22027 | ||
22028 | @item +nofp | |
22029 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22030 | ||
22031 | @item +i8mm | |
22032 | 8-bit Integer Matrix Multiply instructions. | |
22033 | This also enables Advanced SIMD and floating-point instructions. | |
22034 | ||
22035 | @item +bf16 | |
22036 | Brain half-precision floating-point instructions. | |
22037 | This also enables Advanced SIMD and floating-point instructions. | |
22038 | @end table | |
22039 | ||
22040 | @item armv8.6-a | |
22041 | @table @samp | |
22042 | @item +fp16 | |
22043 | The half-precision floating-point data processing instructions. | |
22044 | This also enables the Advanced SIMD and floating-point instructions as well | |
22045 | as the Dot Product extension and the half-precision floating-point fmla | |
22046 | extension. | |
22047 | ||
22048 | @item +simd | |
22049 | The ARMv8.3-A Advanced SIMD and floating-point instructions as well as the | |
22050 | Dot Product extension. | |
22051 | ||
22052 | @item +crypto | |
22053 | The cryptographic instructions. This also enables the Advanced SIMD and | |
22054 | floating-point instructions as well as the Dot Product extension. | |
22055 | ||
22056 | @item +nocrypto | |
22057 | Disable the cryptographic extension. | |
22058 | ||
22059 | @item +nofp | |
22060 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22061 | ||
22062 | @item +i8mm | |
22063 | 8-bit Integer Matrix Multiply instructions. | |
22064 | This also enables Advanced SIMD and floating-point instructions. | |
22065 | ||
22066 | @item +bf16 | |
22067 | Brain half-precision floating-point instructions. | |
22068 | This also enables Advanced SIMD and floating-point instructions. | |
22069 | @end table | |
22070 | ||
22071 | @item armv7-r | |
22072 | @table @samp | |
22073 | @item +fp.sp | |
22074 | The single-precision VFPv3 floating-point instructions. The extension | |
22075 | @samp{+vfpv3xd} can be used as an alias for this extension. | |
22076 | ||
22077 | @item +fp | |
22078 | The VFPv3 floating-point instructions with 16 double-precision registers. | |
22079 | The extension +vfpv3-d16 can be used as an alias for this extension. | |
22080 | ||
22081 | @item +vfpv3xd-d16-fp16 | |
22082 | The single-precision VFPv3 floating-point instructions with 16 double-precision | |
22083 | registers and the half-precision floating-point conversion operations. | |
22084 | ||
22085 | @item +vfpv3-d16-fp16 | |
22086 | The VFPv3 floating-point instructions with 16 double-precision | |
22087 | registers and the half-precision floating-point conversion operations. | |
22088 | ||
22089 | @item +nofp | |
22090 | Disable the floating-point extension. | |
22091 | ||
22092 | @item +idiv | |
22093 | The ARM-state integer division instructions. | |
22094 | ||
22095 | @item +noidiv | |
22096 | Disable the ARM-state integer division extension. | |
22097 | @end table | |
22098 | ||
22099 | @item armv7e-m | |
22100 | @table @samp | |
22101 | @item +fp | |
22102 | The single-precision VFPv4 floating-point instructions. | |
22103 | ||
22104 | @item +fpv5 | |
22105 | The single-precision FPv5 floating-point instructions. | |
22106 | ||
22107 | @item +fp.dp | |
22108 | The single- and double-precision FPv5 floating-point instructions. | |
22109 | ||
22110 | @item +nofp | |
22111 | Disable the floating-point extensions. | |
22112 | @end table | |
22113 | ||
22114 | @item armv8.1-m.main | |
22115 | @table @samp | |
22116 | ||
22117 | @item +dsp | |
22118 | The DSP instructions. | |
22119 | ||
22120 | @item +mve | |
22121 | The M-Profile Vector Extension (MVE) integer instructions. | |
22122 | ||
22123 | @item +mve.fp | |
22124 | The M-Profile Vector Extension (MVE) integer and single precision | |
22125 | floating-point instructions. | |
22126 | ||
22127 | @item +fp | |
22128 | The single-precision floating-point instructions. | |
22129 | ||
22130 | @item +fp.dp | |
22131 | The single- and double-precision floating-point instructions. | |
22132 | ||
22133 | @item +nofp | |
22134 | Disable the floating-point extension. | |
22135 | ||
22136 | @item +cdecp0, +cdecp1, ... , +cdecp7 | |
22137 | Enable the Custom Datapath Extension (CDE) on selected coprocessors according | |
22138 | to the numbers given in the options in the range 0 to 7. | |
c91bb7b9 AC |
22139 | |
22140 | @item +pacbti | |
22141 | Enable the Pointer Authentication and Branch Target Identification Extension. | |
d77de738 ML |
22142 | @end table |
22143 | ||
22144 | @item armv8-m.main | |
22145 | @table @samp | |
22146 | @item +dsp | |
22147 | The DSP instructions. | |
22148 | ||
22149 | @item +nodsp | |
22150 | Disable the DSP extension. | |
22151 | ||
22152 | @item +fp | |
22153 | The single-precision floating-point instructions. | |
22154 | ||
22155 | @item +fp.dp | |
22156 | The single- and double-precision floating-point instructions. | |
22157 | ||
22158 | @item +nofp | |
22159 | Disable the floating-point extension. | |
22160 | ||
22161 | @item +cdecp0, +cdecp1, ... , +cdecp7 | |
22162 | Enable the Custom Datapath Extension (CDE) on selected coprocessors according | |
22163 | to the numbers given in the options in the range 0 to 7. | |
22164 | @end table | |
22165 | ||
22166 | @item armv8-r | |
22167 | @table @samp | |
22168 | @item +crc | |
22169 | The Cyclic Redundancy Check (CRC) instructions. | |
22170 | @item +fp.sp | |
22171 | The single-precision FPv5 floating-point instructions. | |
22172 | @item +simd | |
22173 | The ARMv8-A Advanced SIMD and floating-point instructions. | |
22174 | @item +crypto | |
22175 | The cryptographic instructions. | |
22176 | @item +nocrypto | |
22177 | Disable the cryptographic instructions. | |
22178 | @item +nofp | |
22179 | Disable the floating-point, Advanced SIMD and cryptographic instructions. | |
22180 | @end table | |
22181 | ||
22182 | @end table | |
22183 | ||
22184 | @option{-march=native} causes the compiler to auto-detect the architecture | |
22185 | of the build computer. At present, this feature is only supported on | |
22186 | GNU/Linux, and not all architectures are recognized. If the auto-detect | |
22187 | is unsuccessful the option has no effect. | |
22188 | ||
d77de738 | 22189 | @opindex mtune |
ddf6fe37 | 22190 | @item -mtune=@var{name} |
d77de738 ML |
22191 | This option specifies the name of the target ARM processor for |
22192 | which GCC should tune the performance of the code. | |
22193 | For some ARM implementations better performance can be obtained by using | |
22194 | this option. | |
22195 | Permissible names are: @samp{arm7tdmi}, @samp{arm7tdmi-s}, @samp{arm710t}, | |
22196 | @samp{arm720t}, @samp{arm740t}, @samp{strongarm}, @samp{strongarm110}, | |
22197 | @samp{strongarm1100}, @samp{strongarm1110}, @samp{arm8}, @samp{arm810}, | |
22198 | @samp{arm9}, @samp{arm9e}, @samp{arm920}, @samp{arm920t}, @samp{arm922t}, | |
22199 | @samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm926ej-s}, | |
22200 | @samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, @samp{arm1020t}, | |
22201 | @samp{arm1026ej-s}, @samp{arm10e}, @samp{arm1020e}, @samp{arm1022e}, | |
22202 | @samp{arm1136j-s}, @samp{arm1136jf-s}, @samp{mpcore}, @samp{mpcorenovfp}, | |
22203 | @samp{arm1156t2-s}, @samp{arm1156t2f-s}, @samp{arm1176jz-s}, @samp{arm1176jzf-s}, | |
22204 | @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, @samp{cortex-a8}, | |
22205 | @samp{cortex-a9}, @samp{cortex-a12}, @samp{cortex-a15}, @samp{cortex-a17}, | |
22206 | @samp{cortex-a32}, @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, | |
22207 | @samp{cortex-a57}, @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, | |
22208 | @samp{cortex-a76}, @samp{cortex-a76ae}, @samp{cortex-a77}, | |
22209 | @samp{cortex-a78}, @samp{cortex-a78ae}, @samp{cortex-a78c}, @samp{cortex-a710}, | |
22210 | @samp{ares}, @samp{cortex-r4}, @samp{cortex-r4f}, @samp{cortex-r5}, | |
22211 | @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, @samp{cortex-r52plus}, | |
22212 | @samp{cortex-m0}, @samp{cortex-m0plus}, @samp{cortex-m1}, @samp{cortex-m3}, | |
22213 | @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m23}, @samp{cortex-m33}, | |
ccfd1e7f SP |
22214 | @samp{cortex-m35p}, @samp{cortex-m55}, @samp{cortex-m85}, @samp{cortex-x1}, |
22215 | @samp{cortex-x1c}, @samp{cortex-m1.small-multiply}, @samp{cortex-m0.small-multiply}, | |
d77de738 ML |
22216 | @samp{cortex-m0plus.small-multiply}, @samp{exynos-m1}, @samp{marvell-pj4}, |
22217 | @samp{neoverse-n1}, @samp{neoverse-n2}, @samp{neoverse-v1}, @samp{xscale}, | |
22218 | @samp{iwmmxt}, @samp{iwmmxt2}, @samp{ep9312}, @samp{fa526}, @samp{fa626}, | |
22219 | @samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}, @samp{star-mc1}, | |
22220 | @samp{xgene1}. | |
22221 | ||
22222 | Additionally, this option can specify that GCC should tune the performance | |
22223 | of the code for a big.LITTLE system. Permissible names are: | |
22224 | @samp{cortex-a15.cortex-a7}, @samp{cortex-a17.cortex-a7}, | |
22225 | @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
22226 | @samp{cortex-a72.cortex-a35}, @samp{cortex-a73.cortex-a53}, | |
22227 | @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}. | |
22228 | ||
22229 | @option{-mtune=generic-@var{arch}} specifies that GCC should tune the | |
22230 | performance for a blend of processors within architecture @var{arch}. | |
22231 | The aim is to generate code that run well on the current most popular | |
22232 | processors, balancing between optimizations that benefit some CPUs in the | |
22233 | range, and avoiding performance pitfalls of other CPUs. The effects of | |
22234 | this option may change in future GCC versions as CPU models come and go. | |
22235 | ||
22236 | @option{-mtune} permits the same extension options as @option{-mcpu}, but | |
22237 | the extension options do not affect the tuning of the generated code. | |
22238 | ||
22239 | @option{-mtune=native} causes the compiler to auto-detect the CPU | |
22240 | of the build computer. At present, this feature is only supported on | |
22241 | GNU/Linux, and not all architectures are recognized. If the auto-detect is | |
22242 | unsuccessful the option has no effect. | |
22243 | ||
d77de738 | 22244 | @opindex mcpu |
ddf6fe37 | 22245 | @item -mcpu=@var{name}@r{[}+extension@dots{}@r{]} |
d77de738 ML |
22246 | This specifies the name of the target ARM processor. GCC uses this name |
22247 | to derive the name of the target ARM architecture (as if specified | |
22248 | by @option{-march}) and the ARM processor type for which to tune for | |
22249 | performance (as if specified by @option{-mtune}). Where this option | |
22250 | is used in conjunction with @option{-march} or @option{-mtune}, | |
22251 | those options take precedence over the appropriate part of this option. | |
22252 | ||
22253 | Many of the supported CPUs implement optional architectural | |
22254 | extensions. Where this is so the architectural extensions are | |
22255 | normally enabled by default. If implementations that lack the | |
22256 | extension exist, then the extension syntax can be used to disable | |
22257 | those extensions that have been omitted. For floating-point and | |
22258 | Advanced SIMD (Neon) instructions, the settings of the options | |
22259 | @option{-mfloat-abi} and @option{-mfpu} must also be considered: | |
22260 | floating-point and Advanced SIMD instructions will only be used if | |
22261 | @option{-mfloat-abi} is not set to @samp{soft}; and any setting of | |
22262 | @option{-mfpu} other than @samp{auto} will override the available | |
22263 | floating-point and SIMD extension instructions. | |
22264 | ||
22265 | For example, @samp{cortex-a9} can be found in three major | |
22266 | configurations: integer only, with just a floating-point unit or with | |
22267 | floating-point and Advanced SIMD. The default is to enable all the | |
22268 | instructions, but the extensions @samp{+nosimd} and @samp{+nofp} can | |
22269 | be used to disable just the SIMD or both the SIMD and floating-point | |
22270 | instructions respectively. | |
22271 | ||
22272 | Permissible names for this option are the same as those for | |
22273 | @option{-mtune}. | |
22274 | ||
22275 | The following extension options are common to the listed CPUs: | |
22276 | ||
22277 | @table @samp | |
22278 | @item +nodsp | |
ccfd1e7f SP |
22279 | Disable the DSP instructions on @samp{cortex-m33}, @samp{cortex-m35p}, |
22280 | @samp{cortex-m55} and @samp{cortex-m85}. Also disable the M-Profile Vector | |
22281 | Extension (MVE) integer and single precision floating-point instructions on | |
22282 | @samp{cortex-m55} and @samp{cortex-m85}. | |
22283 | ||
22284 | @item +nopacbti | |
22285 | Disable the Pointer Authentication and Branch Target Identification Extension | |
22286 | on @samp{cortex-m85}. | |
d77de738 ML |
22287 | |
22288 | @item +nomve | |
22289 | Disable the M-Profile Vector Extension (MVE) integer and single precision | |
ccfd1e7f | 22290 | floating-point instructions on @samp{cortex-m55} and @samp{cortex-m85}. |
d77de738 ML |
22291 | |
22292 | @item +nomve.fp | |
22293 | Disable the M-Profile Vector Extension (MVE) single precision floating-point | |
ccfd1e7f | 22294 | instructions on @samp{cortex-m55} and @samp{cortex-m85}. |
d77de738 | 22295 | |
798a0d05 SP |
22296 | @item +cdecp0, +cdecp1, ... , +cdecp7 |
22297 | Enable the Custom Datapath Extension (CDE) on selected coprocessors according | |
22298 | to the numbers given in the options in the range 0 to 7 on @samp{cortex-m55}. | |
22299 | ||
d77de738 ML |
22300 | @item +nofp |
22301 | Disables the floating-point instructions on @samp{arm9e}, | |
22302 | @samp{arm946e-s}, @samp{arm966e-s}, @samp{arm968e-s}, @samp{arm10e}, | |
22303 | @samp{arm1020e}, @samp{arm1022e}, @samp{arm926ej-s}, | |
22304 | @samp{arm1026ej-s}, @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, | |
22305 | @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p} | |
ccfd1e7f SP |
22306 | @samp{cortex-m4}, @samp{cortex-m7}, @samp{cortex-m33}, @samp{cortex-m35p}, |
22307 | @samp{cortex-m55} and @samp{cortex-m85}. | |
d77de738 ML |
22308 | Disables the floating-point and SIMD instructions on |
22309 | @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7}, | |
22310 | @samp{cortex-a8}, @samp{cortex-a9}, @samp{cortex-a12}, | |
22311 | @samp{cortex-a15}, @samp{cortex-a17}, @samp{cortex-a15.cortex-a7}, | |
22312 | @samp{cortex-a17.cortex-a7}, @samp{cortex-a32}, @samp{cortex-a35}, | |
22313 | @samp{cortex-a53} and @samp{cortex-a55}. | |
22314 | ||
22315 | @item +nofp.dp | |
22316 | Disables the double-precision component of the floating-point instructions | |
22317 | on @samp{cortex-r5}, @samp{cortex-r7}, @samp{cortex-r8}, @samp{cortex-r52}, | |
22318 | @samp{cortex-r52plus} and @samp{cortex-m7}. | |
22319 | ||
22320 | @item +nosimd | |
22321 | Disables the SIMD (but not floating-point) instructions on | |
22322 | @samp{generic-armv7-a}, @samp{cortex-a5}, @samp{cortex-a7} | |
22323 | and @samp{cortex-a9}. | |
22324 | ||
22325 | @item +crypto | |
22326 | Enables the cryptographic instructions on @samp{cortex-a32}, | |
22327 | @samp{cortex-a35}, @samp{cortex-a53}, @samp{cortex-a55}, @samp{cortex-a57}, | |
22328 | @samp{cortex-a72}, @samp{cortex-a73}, @samp{cortex-a75}, @samp{exynos-m1}, | |
22329 | @samp{xgene1}, @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53}, | |
22330 | @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53} and | |
22331 | @samp{cortex-a75.cortex-a55}. | |
22332 | @end table | |
22333 | ||
22334 | Additionally the @samp{generic-armv7-a} pseudo target defaults to | |
22335 | VFPv3 with 16 double-precision registers. It supports the following | |
22336 | extension options: @samp{mp}, @samp{sec}, @samp{vfpv3-d16}, | |
22337 | @samp{vfpv3}, @samp{vfpv3-d16-fp16}, @samp{vfpv3-fp16}, | |
22338 | @samp{vfpv4-d16}, @samp{vfpv4}, @samp{neon}, @samp{neon-vfpv3}, | |
22339 | @samp{neon-fp16}, @samp{neon-vfpv4}. The meanings are the same as for | |
22340 | the extensions to @option{-march=armv7-a}. | |
22341 | ||
22342 | @option{-mcpu=generic-@var{arch}} is also permissible, and is | |
22343 | equivalent to @option{-march=@var{arch} -mtune=generic-@var{arch}}. | |
22344 | See @option{-mtune} for more information. | |
22345 | ||
22346 | @option{-mcpu=native} causes the compiler to auto-detect the CPU | |
22347 | of the build computer. At present, this feature is only supported on | |
22348 | GNU/Linux, and not all architectures are recognized. If the auto-detect | |
22349 | is unsuccessful the option has no effect. | |
22350 | ||
d77de738 | 22351 | @opindex mfpu |
ddf6fe37 | 22352 | @item -mfpu=@var{name} |
d77de738 ML |
22353 | This specifies what floating-point hardware (or hardware emulation) is |
22354 | available on the target. Permissible names are: @samp{auto}, @samp{vfpv2}, | |
22355 | @samp{vfpv3}, | |
22356 | @samp{vfpv3-fp16}, @samp{vfpv3-d16}, @samp{vfpv3-d16-fp16}, @samp{vfpv3xd}, | |
22357 | @samp{vfpv3xd-fp16}, @samp{neon-vfpv3}, @samp{neon-fp16}, @samp{vfpv4}, | |
22358 | @samp{vfpv4-d16}, @samp{fpv4-sp-d16}, @samp{neon-vfpv4}, | |
22359 | @samp{fpv5-d16}, @samp{fpv5-sp-d16}, | |
22360 | @samp{fp-armv8}, @samp{neon-fp-armv8} and @samp{crypto-neon-fp-armv8}. | |
22361 | Note that @samp{neon} is an alias for @samp{neon-vfpv3} and @samp{vfp} | |
22362 | is an alias for @samp{vfpv2}. | |
22363 | ||
22364 | The setting @samp{auto} is the default and is special. It causes the | |
22365 | compiler to select the floating-point and Advanced SIMD instructions | |
22366 | based on the settings of @option{-mcpu} and @option{-march}. | |
22367 | ||
22368 | If the selected floating-point hardware includes the NEON extension | |
22369 | (e.g.@: @option{-mfpu=neon}), note that floating-point | |
22370 | operations are not generated by GCC's auto-vectorization pass unless | |
22371 | @option{-funsafe-math-optimizations} is also specified. This is | |
22372 | because NEON hardware does not fully implement the IEEE 754 standard for | |
22373 | floating-point arithmetic (in particular denormal values are treated as | |
22374 | zero), so the use of NEON instructions may lead to a loss of precision. | |
22375 | ||
22376 | 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}). | |
22377 | ||
d77de738 | 22378 | @opindex mfp16-format |
ddf6fe37 | 22379 | @item -mfp16-format=@var{name} |
d77de738 ML |
22380 | Specify the format of the @code{__fp16} half-precision floating-point type. |
22381 | Permissible names are @samp{none}, @samp{ieee}, and @samp{alternative}; | |
22382 | the default is @samp{none}, in which case the @code{__fp16} type is not | |
22383 | defined. @xref{Half-Precision}, for more information. | |
22384 | ||
d77de738 | 22385 | @opindex mstructure-size-boundary |
ddf6fe37 | 22386 | @item -mstructure-size-boundary=@var{n} |
d77de738 ML |
22387 | The sizes of all structures and unions are rounded up to a multiple |
22388 | of the number of bits set by this option. Permissible values are 8, 32 | |
22389 | and 64. The default value varies for different toolchains. For the COFF | |
22390 | targeted toolchain the default value is 8. A value of 64 is only allowed | |
22391 | if the underlying ABI supports it. | |
22392 | ||
22393 | Specifying a larger number can produce faster, more efficient code, but | |
22394 | can also increase the size of the program. Different values are potentially | |
22395 | incompatible. Code compiled with one value cannot necessarily expect to | |
22396 | work with code or libraries compiled with another value, if they exchange | |
22397 | information using structures or unions. | |
22398 | ||
22399 | This option is deprecated. | |
22400 | ||
d77de738 | 22401 | @opindex mabort-on-noreturn |
ddf6fe37 | 22402 | @item -mabort-on-noreturn |
d77de738 ML |
22403 | Generate a call to the function @code{abort} at the end of a |
22404 | @code{noreturn} function. It is executed if the function tries to | |
22405 | return. | |
22406 | ||
d77de738 ML |
22407 | @opindex mlong-calls |
22408 | @opindex mno-long-calls | |
ddf6fe37 AA |
22409 | @item -mlong-calls |
22410 | @itemx -mno-long-calls | |
d77de738 ML |
22411 | Tells the compiler to perform function calls by first loading the |
22412 | address of the function into a register and then performing a subroutine | |
22413 | call on this register. This switch is needed if the target function | |
22414 | lies outside of the 64-megabyte addressing range of the offset-based | |
22415 | version of subroutine call instruction. | |
22416 | ||
22417 | Even if this switch is enabled, not all function calls are turned | |
22418 | into long calls. The heuristic is that static functions, functions | |
22419 | that have the @code{short_call} attribute, functions that are inside | |
22420 | the scope of a @code{#pragma no_long_calls} directive, and functions whose | |
22421 | definitions have already been compiled within the current compilation | |
22422 | unit are not turned into long calls. The exceptions to this rule are | |
22423 | that weak function definitions, functions with the @code{long_call} | |
22424 | attribute or the @code{section} attribute, and functions that are within | |
22425 | the scope of a @code{#pragma long_calls} directive are always | |
22426 | turned into long calls. | |
22427 | ||
22428 | This feature is not enabled by default. Specifying | |
22429 | @option{-mno-long-calls} restores the default behavior, as does | |
22430 | placing the function calls within the scope of a @code{#pragma | |
22431 | long_calls_off} directive. Note these switches have no effect on how | |
22432 | the compiler generates code to handle function calls via function | |
22433 | pointers. | |
22434 | ||
d77de738 | 22435 | @opindex msingle-pic-base |
ddf6fe37 | 22436 | @item -msingle-pic-base |
d77de738 ML |
22437 | Treat the register used for PIC addressing as read-only, rather than |
22438 | loading it in the prologue for each function. The runtime system is | |
22439 | responsible for initializing this register with an appropriate value | |
22440 | before execution begins. | |
22441 | ||
d77de738 | 22442 | @opindex mpic-register |
ddf6fe37 | 22443 | @item -mpic-register=@var{reg} |
d77de738 ML |
22444 | Specify the register to be used for PIC addressing. |
22445 | For standard PIC base case, the default is any suitable register | |
22446 | determined by compiler. For single PIC base case, the default is | |
22447 | @samp{R9} if target is EABI based or stack-checking is enabled, | |
22448 | otherwise the default is @samp{R10}. | |
22449 | ||
d77de738 | 22450 | @opindex mpic-data-is-text-relative |
ddf6fe37 | 22451 | @item -mpic-data-is-text-relative |
d77de738 ML |
22452 | Assume that the displacement between the text and data segments is fixed |
22453 | at static link time. This permits using PC-relative addressing | |
22454 | operations to access data known to be in the data segment. For | |
22455 | non-VxWorks RTP targets, this option is enabled by default. When | |
22456 | disabled on such targets, it will enable @option{-msingle-pic-base} by | |
22457 | default. | |
22458 | ||
d77de738 | 22459 | @opindex mpoke-function-name |
ddf6fe37 | 22460 | @item -mpoke-function-name |
d77de738 ML |
22461 | Write the name of each function into the text section, directly |
22462 | preceding the function prologue. The generated code is similar to this: | |
22463 | ||
22464 | @smallexample | |
22465 | t0 | |
22466 | .ascii "arm_poke_function_name", 0 | |
22467 | .align | |
22468 | t1 | |
22469 | .word 0xff000000 + (t1 - t0) | |
22470 | arm_poke_function_name | |
22471 | mov ip, sp | |
22472 | stmfd sp!, @{fp, ip, lr, pc@} | |
22473 | sub fp, ip, #4 | |
22474 | @end smallexample | |
22475 | ||
22476 | When performing a stack backtrace, code can inspect the value of | |
22477 | @code{pc} stored at @code{fp + 0}. If the trace function then looks at | |
22478 | location @code{pc - 12} and the top 8 bits are set, then we know that | |
22479 | there is a function name embedded immediately preceding this location | |
22480 | and has length @code{((pc[-3]) & 0xff000000)}. | |
22481 | ||
d77de738 ML |
22482 | @opindex marm |
22483 | @opindex mthumb | |
ddf6fe37 AA |
22484 | @item -mthumb |
22485 | @itemx -marm | |
d77de738 ML |
22486 | |
22487 | Select between generating code that executes in ARM and Thumb | |
22488 | states. The default for most configurations is to generate code | |
22489 | that executes in ARM state, but the default can be changed by | |
22490 | configuring GCC with the @option{--with-mode=}@var{state} | |
22491 | configure option. | |
22492 | ||
22493 | You can also override the ARM and Thumb mode for each function | |
22494 | by using the @code{target("thumb")} and @code{target("arm")} function attributes | |
22495 | (@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}). | |
22496 | ||
d77de738 | 22497 | @opindex mflip-thumb |
ddf6fe37 | 22498 | @item -mflip-thumb |
d77de738 ML |
22499 | Switch ARM/Thumb modes on alternating functions. |
22500 | This option is provided for regression testing of mixed Thumb/ARM code | |
22501 | generation, and is not intended for ordinary use in compiling code. | |
22502 | ||
d77de738 | 22503 | @opindex mtpcs-frame |
ddf6fe37 | 22504 | @item -mtpcs-frame |
d77de738 ML |
22505 | Generate a stack frame that is compliant with the Thumb Procedure Call |
22506 | Standard for all non-leaf functions. (A leaf function is one that does | |
22507 | not call any other functions.) The default is @option{-mno-tpcs-frame}. | |
22508 | ||
d77de738 | 22509 | @opindex mtpcs-leaf-frame |
ddf6fe37 | 22510 | @item -mtpcs-leaf-frame |
d77de738 ML |
22511 | Generate a stack frame that is compliant with the Thumb Procedure Call |
22512 | Standard for all leaf functions. (A leaf function is one that does | |
22513 | not call any other functions.) The default is @option{-mno-apcs-leaf-frame}. | |
22514 | ||
d77de738 | 22515 | @opindex mcallee-super-interworking |
ddf6fe37 | 22516 | @item -mcallee-super-interworking |
d77de738 ML |
22517 | Gives all externally visible functions in the file being compiled an ARM |
22518 | instruction set header which switches to Thumb mode before executing the | |
22519 | rest of the function. This allows these functions to be called from | |
22520 | non-interworking code. This option is not valid in AAPCS configurations | |
22521 | because interworking is enabled by default. | |
22522 | ||
d77de738 | 22523 | @opindex mcaller-super-interworking |
ddf6fe37 | 22524 | @item -mcaller-super-interworking |
d77de738 ML |
22525 | Allows calls via function pointers (including virtual functions) to |
22526 | execute correctly regardless of whether the target code has been | |
22527 | compiled for interworking or not. There is a small overhead in the cost | |
22528 | of executing a function pointer if this option is enabled. This option | |
22529 | is not valid in AAPCS configurations because interworking is enabled | |
22530 | by default. | |
22531 | ||
d77de738 | 22532 | @opindex mtp |
ddf6fe37 | 22533 | @item -mtp=@var{name} |
d77de738 ML |
22534 | Specify the access model for the thread local storage pointer. The valid |
22535 | models are @samp{soft}, which generates calls to @code{__aeabi_read_tp}, | |
22536 | @samp{cp15}, which fetches the thread pointer from @code{cp15} directly | |
22537 | (supported in the arm6k architecture), and @samp{auto}, which uses the | |
22538 | best available method for the selected processor. The default setting is | |
22539 | @samp{auto}. | |
22540 | ||
d77de738 | 22541 | @opindex mtls-dialect |
ddf6fe37 | 22542 | @item -mtls-dialect=@var{dialect} |
d77de738 ML |
22543 | Specify the dialect to use for accessing thread local storage. Two |
22544 | @var{dialect}s are supported---@samp{gnu} and @samp{gnu2}. The | |
22545 | @samp{gnu} dialect selects the original GNU scheme for supporting | |
22546 | local and global dynamic TLS models. The @samp{gnu2} dialect | |
22547 | selects the GNU descriptor scheme, which provides better performance | |
22548 | for shared libraries. The GNU descriptor scheme is compatible with | |
22549 | the original scheme, but does require new assembler, linker and | |
22550 | library support. Initial and local exec TLS models are unaffected by | |
22551 | this option and always use the original scheme. | |
22552 | ||
d77de738 | 22553 | @opindex mword-relocations |
ddf6fe37 | 22554 | @item -mword-relocations |
d77de738 ML |
22555 | Only generate absolute relocations on word-sized values (i.e.@: R_ARM_ABS32). |
22556 | This is enabled by default on targets (uClinux, SymbianOS) where the runtime | |
22557 | loader imposes this restriction, and when @option{-fpic} or @option{-fPIC} | |
22558 | is specified. This option conflicts with @option{-mslow-flash-data}. | |
22559 | ||
d77de738 | 22560 | @opindex mfix-cortex-m3-ldrd |
ddf6fe37 | 22561 | @item -mfix-cortex-m3-ldrd |
d77de738 ML |
22562 | Some Cortex-M3 cores can cause data corruption when @code{ldrd} instructions |
22563 | with overlapping destination and base registers are used. This option avoids | |
22564 | generating these instructions. This option is enabled by default when | |
22565 | @option{-mcpu=cortex-m3} is specified. | |
22566 | ||
22567 | @item -mfix-cortex-a57-aes-1742098 | |
22568 | @itemx -mno-fix-cortex-a57-aes-1742098 | |
22569 | @itemx -mfix-cortex-a72-aes-1655431 | |
22570 | @itemx -mno-fix-cortex-a72-aes-1655431 | |
22571 | Enable (disable) mitigation for an erratum on Cortex-A57 and | |
22572 | Cortex-A72 that affects the AES cryptographic instructions. This | |
22573 | option is enabled by default when either @option{-mcpu=cortex-a57} or | |
22574 | @option{-mcpu=cortex-a72} is specified. | |
22575 | ||
d77de738 ML |
22576 | @opindex munaligned-access |
22577 | @opindex mno-unaligned-access | |
ddf6fe37 AA |
22578 | @item -munaligned-access |
22579 | @itemx -mno-unaligned-access | |
d77de738 ML |
22580 | Enables (or disables) reading and writing of 16- and 32- bit values |
22581 | from addresses that are not 16- or 32- bit aligned. By default | |
22582 | unaligned access is disabled for all pre-ARMv6, all ARMv6-M and for | |
22583 | ARMv8-M Baseline architectures, and enabled for all other | |
22584 | architectures. If unaligned access is not enabled then words in packed | |
22585 | data structures are accessed a byte at a time. | |
22586 | ||
22587 | The ARM attribute @code{Tag_CPU_unaligned_access} is set in the | |
22588 | generated object file to either true or false, depending upon the | |
22589 | setting of this option. If unaligned access is enabled then the | |
22590 | preprocessor symbol @code{__ARM_FEATURE_UNALIGNED} is also | |
22591 | defined. | |
22592 | ||
d77de738 | 22593 | @opindex mneon-for-64bits |
ddf6fe37 | 22594 | @item -mneon-for-64bits |
d77de738 ML |
22595 | This option is deprecated and has no effect. |
22596 | ||
d77de738 | 22597 | @opindex mslow-flash-data |
ddf6fe37 | 22598 | @item -mslow-flash-data |
d77de738 ML |
22599 | Assume loading data from flash is slower than fetching instruction. |
22600 | Therefore literal load is minimized for better performance. | |
22601 | This option is only supported when compiling for ARMv7 M-profile and | |
22602 | off by default. It conflicts with @option{-mword-relocations}. | |
22603 | ||
d77de738 | 22604 | @opindex masm-syntax-unified |
ddf6fe37 | 22605 | @item -masm-syntax-unified |
d77de738 ML |
22606 | Assume inline assembler is using unified asm syntax. The default is |
22607 | currently off which implies divided syntax. This option has no impact | |
22608 | on Thumb2. However, this may change in future releases of GCC. | |
22609 | Divided syntax should be considered deprecated. | |
22610 | ||
d77de738 | 22611 | @opindex mrestrict-it |
ddf6fe37 | 22612 | @item -mrestrict-it |
d77de738 ML |
22613 | Restricts generation of IT blocks to conform to the rules of ARMv8-A. |
22614 | IT blocks can only contain a single 16-bit instruction from a select | |
22615 | set of instructions. This option is on by default for ARMv8-A Thumb mode. | |
22616 | ||
d77de738 | 22617 | @opindex mprint-tune-info |
ddf6fe37 | 22618 | @item -mprint-tune-info |
d77de738 ML |
22619 | Print CPU tuning information as comment in assembler file. This is |
22620 | an option used only for regression testing of the compiler and not | |
22621 | intended for ordinary use in compiling code. This option is disabled | |
22622 | by default. | |
22623 | ||
d77de738 | 22624 | @opindex mverbose-cost-dump |
ddf6fe37 | 22625 | @item -mverbose-cost-dump |
d77de738 ML |
22626 | Enable verbose cost model dumping in the debug dump files. This option is |
22627 | provided for use in debugging the compiler. | |
22628 | ||
d77de738 | 22629 | @opindex mpure-code |
ddf6fe37 | 22630 | @item -mpure-code |
d77de738 ML |
22631 | Do not allow constant data to be placed in code sections. |
22632 | Additionally, when compiling for ELF object format give all text sections the | |
22633 | ELF processor-specific section attribute @code{SHF_ARM_PURECODE}. This option | |
22634 | is only available when generating non-pic code for M-profile targets. | |
22635 | ||
d77de738 | 22636 | @opindex mcmse |
ddf6fe37 | 22637 | @item -mcmse |
d77de738 ML |
22638 | Generate secure code as per the "ARMv8-M Security Extensions: Requirements on |
22639 | Development Tools Engineering Specification", which can be found on | |
22640 | @url{https://developer.arm.com/documentation/ecm0359818/latest/}. | |
22641 | ||
d77de738 | 22642 | @opindex mfix-cmse-cve-2021-35465 |
ddf6fe37 | 22643 | @item -mfix-cmse-cve-2021-35465 |
d77de738 ML |
22644 | Mitigate against a potential security issue with the @code{VLLDM} instruction |
22645 | in some M-profile devices when using CMSE (CVE-2021-365465). This option is | |
22646 | enabled by default when the option @option{-mcpu=} is used with | |
ccfd1e7f SP |
22647 | @code{cortex-m33}, @code{cortex-m35p}, @code{cortex-m55}, @code{cortex-m85} |
22648 | or @code{star-mc1}. The option @option{-mno-fix-cmse-cve-2021-35465} can be used | |
22649 | to disable the mitigation. | |
d77de738 | 22650 | |
d77de738 ML |
22651 | @opindex mstack-protector-guard |
22652 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
22653 | @item -mstack-protector-guard=@var{guard} |
22654 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
22655 | Generate stack protection code using canary at @var{guard}. Supported |
22656 | locations are @samp{global} for a global canary or @samp{tls} for a | |
22657 | canary accessible via the TLS register. The option | |
22658 | @option{-mstack-protector-guard-offset=} is for use with | |
22659 | @option{-fstack-protector-guard=tls} and not for use in user-land code. | |
22660 | ||
d77de738 ML |
22661 | @opindex mfdpic |
22662 | @opindex mno-fdpic | |
ddf6fe37 AA |
22663 | @item -mfdpic |
22664 | @itemx -mno-fdpic | |
d77de738 ML |
22665 | Select the FDPIC ABI, which uses 64-bit function descriptors to |
22666 | represent pointers to functions. When the compiler is configured for | |
22667 | @code{arm-*-uclinuxfdpiceabi} targets, this option is on by default | |
22668 | and implies @option{-fPIE} if none of the PIC/PIE-related options is | |
22669 | provided. On other targets, it only enables the FDPIC-specific code | |
22670 | generation features, and the user should explicitly provide the | |
22671 | PIC/PIE-related options as needed. | |
22672 | ||
22673 | Note that static linking is not supported because it would still | |
22674 | involve the dynamic linker when the program self-relocates. If such | |
22675 | behavior is acceptable, use -static and -Wl,-dynamic-linker options. | |
22676 | ||
22677 | The opposite @option{-mno-fdpic} option is useful (and required) to | |
22678 | build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi}) | |
22679 | toolchain as the one used to build the userland programs. | |
22680 | ||
14fab5fb | 22681 | @opindex mbranch-protection |
ddf6fe37 | 22682 | @item -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]] |
14fab5fb AC |
22683 | Enable branch protection features (armv8.1-m.main only). |
22684 | @samp{none} generate code without branch protection or return address | |
22685 | signing. | |
22686 | @samp{standard[+@var{leaf}]} generate code with all branch protection | |
22687 | features enabled at their standard level. | |
22688 | @samp{pac-ret[+@var{leaf}]} generate code with return address signing | |
22689 | set to its standard level, which is to sign all functions that save | |
22690 | the return address to memory. | |
22691 | @samp{leaf} When return address signing is enabled, also sign leaf | |
22692 | functions even if they do not write the return address to memory. | |
22693 | +@samp{bti} Add landing-pad instructions at the permitted targets of | |
22694 | indirect branch instructions. | |
22695 | ||
22696 | If the @samp{+pacbti} architecture extension is not enabled, then all | |
22697 | branch protection and return address signing operations are | |
22698 | constrained to use only the instructions defined in the | |
22699 | architectural-NOP space. The generated code will remain | |
22700 | backwards-compatible with earlier versions of the architecture, but | |
22701 | the additional security can be enabled at run time on processors that | |
22702 | support the @samp{PACBTI} extension. | |
22703 | ||
22704 | Branch target enforcement using BTI can only be enabled at runtime if | |
22705 | all code in the application has been compiled with at least | |
22706 | @samp{-mbranch-protection=bti}. | |
22707 | ||
22708 | Any setting other than @samp{none} is supported only on armv8-m.main | |
22709 | or later. | |
22710 | ||
22711 | The default is to generate code without branch protection or return | |
22712 | address signing. | |
22713 | ||
d77de738 ML |
22714 | @end table |
22715 | ||
22716 | @node AVR Options | |
22717 | @subsection AVR Options | |
22718 | @cindex AVR Options | |
22719 | ||
22720 | These options are defined for AVR implementations: | |
22721 | ||
22722 | @table @gcctabopt | |
d77de738 | 22723 | @opindex mmcu |
ddf6fe37 | 22724 | @item -mmcu=@var{mcu} |
d77de738 ML |
22725 | Specify Atmel AVR instruction set architectures (ISA) or MCU type. |
22726 | ||
22727 | The default for this option is@tie{}@samp{avr2}. | |
22728 | ||
22729 | GCC supports the following AVR devices and ISAs: | |
22730 | ||
22731 | @include avr-mmcu.texi | |
22732 | ||
d77de738 | 22733 | @opindex mabsdata |
ddf6fe37 | 22734 | @item -mabsdata |
d77de738 ML |
22735 | |
22736 | Assume that all data in static storage can be accessed by LDS / STS | |
22737 | instructions. This option has only an effect on reduced Tiny devices like | |
22738 | ATtiny40. See also the @code{absdata} | |
22739 | @ref{AVR Variable Attributes,variable attribute}. | |
22740 | ||
d77de738 | 22741 | @opindex maccumulate-args |
ddf6fe37 | 22742 | @item -maccumulate-args |
d77de738 ML |
22743 | Accumulate outgoing function arguments and acquire/release the needed |
22744 | stack space for outgoing function arguments once in function | |
22745 | prologue/epilogue. Without this option, outgoing arguments are pushed | |
22746 | before calling a function and popped afterwards. | |
22747 | ||
22748 | Popping the arguments after the function call can be expensive on | |
22749 | AVR so that accumulating the stack space might lead to smaller | |
22750 | executables because arguments need not be removed from the | |
22751 | stack after such a function call. | |
22752 | ||
22753 | This option can lead to reduced code size for functions that perform | |
22754 | several calls to functions that get their arguments on the stack like | |
22755 | calls to printf-like functions. | |
22756 | ||
d77de738 | 22757 | @opindex mbranch-cost |
ddf6fe37 | 22758 | @item -mbranch-cost=@var{cost} |
d77de738 ML |
22759 | Set the branch costs for conditional branch instructions to |
22760 | @var{cost}. Reasonable values for @var{cost} are small, non-negative | |
22761 | integers. The default branch cost is 0. | |
22762 | ||
d77de738 | 22763 | @opindex mcall-prologues |
ddf6fe37 | 22764 | @item -mcall-prologues |
d77de738 ML |
22765 | Functions prologues/epilogues are expanded as calls to appropriate |
22766 | subroutines. Code size is smaller. | |
22767 | ||
d77de738 ML |
22768 | @opindex mdouble |
22769 | @opindex mlong-double | |
ddf6fe37 AA |
22770 | @item -mdouble=@var{bits} |
22771 | @itemx -mlong-double=@var{bits} | |
d77de738 ML |
22772 | Set the size (in bits) of the @code{double} or @code{long double} type, |
22773 | respectively. Possible values for @var{bits} are 32 and 64. | |
22774 | Whether or not a specific value for @var{bits} is allowed depends on | |
22775 | the @code{--with-double=} and @code{--with-long-double=} | |
22776 | @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure options}}, | |
22777 | and the same applies for the default values of the options. | |
22778 | ||
d77de738 | 22779 | @opindex mgas-isr-prologues |
ddf6fe37 | 22780 | @item -mgas-isr-prologues |
d77de738 ML |
22781 | Interrupt service routines (ISRs) may use the @code{__gcc_isr} pseudo |
22782 | instruction supported by GNU Binutils. | |
22783 | If this option is on, the feature can still be disabled for individual | |
22784 | ISRs by means of the @ref{AVR Function Attributes,,@code{no_gccisr}} | |
22785 | function attribute. This feature is activated per default | |
22786 | if optimization is on (but not with @option{-Og}, @pxref{Optimize Options}), | |
22787 | and if GNU Binutils support @w{@uref{https://sourceware.org/PR21683,PR21683}}. | |
22788 | ||
d77de738 | 22789 | @opindex mint8 |
ddf6fe37 | 22790 | @item -mint8 |
d77de738 ML |
22791 | Assume @code{int} to be 8-bit integer. This affects the sizes of all types: a |
22792 | @code{char} is 1 byte, an @code{int} is 1 byte, a @code{long} is 2 bytes, | |
22793 | and @code{long long} is 4 bytes. Please note that this option does not | |
22794 | conform to the C standards, but it results in smaller code | |
22795 | size. | |
22796 | ||
d77de738 | 22797 | @opindex mmain-is-OS_task |
ddf6fe37 | 22798 | @item -mmain-is-OS_task |
d77de738 ML |
22799 | Do not save registers in @code{main}. The effect is the same like |
22800 | attaching attribute @ref{AVR Function Attributes,,@code{OS_task}} | |
22801 | to @code{main}. It is activated per default if optimization is on. | |
22802 | ||
d77de738 | 22803 | @opindex mn-flash |
ddf6fe37 | 22804 | @item -mn-flash=@var{num} |
d77de738 ML |
22805 | Assume that the flash memory has a size of |
22806 | @var{num} times 64@tie{}KiB. | |
22807 | ||
d77de738 | 22808 | @opindex mno-interrupts |
ddf6fe37 | 22809 | @item -mno-interrupts |
d77de738 ML |
22810 | Generated code is not compatible with hardware interrupts. |
22811 | Code size is smaller. | |
22812 | ||
d77de738 | 22813 | @opindex mrelax |
ddf6fe37 | 22814 | @item -mrelax |
d77de738 ML |
22815 | Try to replace @code{CALL} resp.@: @code{JMP} instruction by the shorter |
22816 | @code{RCALL} resp.@: @code{RJMP} instruction if applicable. | |
22817 | Setting @option{-mrelax} just adds the @option{--mlink-relax} option to | |
22818 | the assembler's command line and the @option{--relax} option to the | |
22819 | linker's command line. | |
22820 | ||
22821 | Jump relaxing is performed by the linker because jump offsets are not | |
22822 | known before code is located. Therefore, the assembler code generated by the | |
22823 | compiler is the same, but the instructions in the executable may | |
22824 | differ from instructions in the assembler code. | |
22825 | ||
22826 | Relaxing must be turned on if linker stubs are needed, see the | |
22827 | section on @code{EIND} and linker stubs below. | |
22828 | ||
d77de738 | 22829 | @opindex mrmw |
ddf6fe37 | 22830 | @item -mrmw |
d77de738 ML |
22831 | Assume that the device supports the Read-Modify-Write |
22832 | instructions @code{XCH}, @code{LAC}, @code{LAS} and @code{LAT}. | |
22833 | ||
d77de738 | 22834 | @opindex mshort-calls |
ddf6fe37 | 22835 | @item -mshort-calls |
d77de738 ML |
22836 | |
22837 | Assume that @code{RJMP} and @code{RCALL} can target the whole | |
22838 | program memory. | |
22839 | ||
22840 | This option is used internally for multilib selection. It is | |
22841 | not an optimization option, and you don't need to set it by hand. | |
22842 | ||
d77de738 | 22843 | @opindex msp8 |
ddf6fe37 | 22844 | @item -msp8 |
d77de738 ML |
22845 | Treat the stack pointer register as an 8-bit register, |
22846 | i.e.@: assume the high byte of the stack pointer is zero. | |
22847 | In general, you don't need to set this option by hand. | |
22848 | ||
22849 | This option is used internally by the compiler to select and | |
22850 | build multilibs for architectures @code{avr2} and @code{avr25}. | |
22851 | These architectures mix devices with and without @code{SPH}. | |
22852 | For any setting other than @option{-mmcu=avr2} or @option{-mmcu=avr25} | |
22853 | the compiler driver adds or removes this option from the compiler | |
22854 | proper's command line, because the compiler then knows if the device | |
22855 | or architecture has an 8-bit stack pointer and thus no @code{SPH} | |
22856 | register or not. | |
22857 | ||
d77de738 | 22858 | @opindex mstrict-X |
ddf6fe37 | 22859 | @item -mstrict-X |
d77de738 ML |
22860 | Use address register @code{X} in a way proposed by the hardware. This means |
22861 | that @code{X} is only used in indirect, post-increment or | |
22862 | pre-decrement addressing. | |
22863 | ||
22864 | Without this option, the @code{X} register may be used in the same way | |
22865 | as @code{Y} or @code{Z} which then is emulated by additional | |
22866 | instructions. | |
22867 | For example, loading a value with @code{X+const} addressing with a | |
22868 | small non-negative @code{const < 64} to a register @var{Rn} is | |
22869 | performed as | |
22870 | ||
22871 | @example | |
22872 | adiw r26, const ; X += const | |
22873 | ld @var{Rn}, X ; @var{Rn} = *X | |
22874 | sbiw r26, const ; X -= const | |
22875 | @end example | |
22876 | ||
d77de738 | 22877 | @opindex mtiny-stack |
ddf6fe37 | 22878 | @item -mtiny-stack |
d77de738 ML |
22879 | Only change the lower 8@tie{}bits of the stack pointer. |
22880 | ||
d77de738 | 22881 | @opindex mfract-convert-truncate |
ddf6fe37 | 22882 | @item -mfract-convert-truncate |
d77de738 ML |
22883 | Allow to use truncation instead of rounding towards zero for fractional fixed-point types. |
22884 | ||
d77de738 | 22885 | @opindex nodevicelib |
ddf6fe37 | 22886 | @item -nodevicelib |
d77de738 ML |
22887 | Don't link against AVR-LibC's device specific library @code{lib<mcu>.a}. |
22888 | ||
d77de738 | 22889 | @opindex nodevicespecs |
ddf6fe37 | 22890 | @item -nodevicespecs |
d77de738 ML |
22891 | Don't add @option{-specs=device-specs/specs-@var{mcu}} to the compiler driver's |
22892 | command line. The user takes responsibility for supplying the sub-processes | |
22893 | like compiler proper, assembler and linker with appropriate command line | |
22894 | options. This means that the user has to supply her private device specs | |
22895 | file by means of @option{-specs=@var{path-to-specs-file}}. There is no | |
22896 | more need for option @option{-mmcu=@var{mcu}}. | |
22897 | ||
22898 | This option can also serve as a replacement for the older way of | |
22899 | specifying custom device-specs files that needed @option{-B @var{some-path}} to point to a directory | |
22900 | which contains a folder named @code{device-specs} which contains a specs file named | |
22901 | @code{specs-@var{mcu}}, where @var{mcu} was specified by @option{-mmcu=@var{mcu}}. | |
22902 | ||
d77de738 ML |
22903 | @opindex Waddr-space-convert |
22904 | @opindex Wno-addr-space-convert | |
ddf6fe37 | 22905 | @item -Waddr-space-convert |
d77de738 ML |
22906 | Warn about conversions between address spaces in the case where the |
22907 | resulting address space is not contained in the incoming address space. | |
22908 | ||
d77de738 ML |
22909 | @opindex Wmisspelled-isr |
22910 | @opindex Wno-misspelled-isr | |
ddf6fe37 | 22911 | @item -Wmisspelled-isr |
d77de738 ML |
22912 | Warn if the ISR is misspelled, i.e.@: without __vector prefix. |
22913 | Enabled by default. | |
22914 | @end table | |
22915 | ||
22916 | @subsubsection @code{EIND} and Devices with More Than 128 Ki Bytes of Flash | |
22917 | @cindex @code{EIND} | |
22918 | Pointers in the implementation are 16@tie{}bits wide. | |
22919 | The address of a function or label is represented as word address so | |
22920 | that indirect jumps and calls can target any code address in the | |
22921 | range of 64@tie{}Ki words. | |
22922 | ||
22923 | In order to facilitate indirect jump on devices with more than 128@tie{}Ki | |
22924 | bytes of program memory space, there is a special function register called | |
22925 | @code{EIND} that serves as most significant part of the target address | |
22926 | when @code{EICALL} or @code{EIJMP} instructions are used. | |
22927 | ||
22928 | Indirect jumps and calls on these devices are handled as follows by | |
22929 | the compiler and are subject to some limitations: | |
22930 | ||
22931 | @itemize @bullet | |
22932 | ||
22933 | @item | |
22934 | The compiler never sets @code{EIND}. | |
22935 | ||
22936 | @item | |
22937 | The compiler uses @code{EIND} implicitly in @code{EICALL}/@code{EIJMP} | |
22938 | instructions or might read @code{EIND} directly in order to emulate an | |
22939 | indirect call/jump by means of a @code{RET} instruction. | |
22940 | ||
22941 | @item | |
22942 | The compiler assumes that @code{EIND} never changes during the startup | |
22943 | code or during the application. In particular, @code{EIND} is not | |
22944 | saved/restored in function or interrupt service routine | |
22945 | prologue/epilogue. | |
22946 | ||
22947 | @item | |
22948 | For indirect calls to functions and computed goto, the linker | |
22949 | generates @emph{stubs}. Stubs are jump pads sometimes also called | |
22950 | @emph{trampolines}. Thus, the indirect call/jump jumps to such a stub. | |
22951 | The stub contains a direct jump to the desired address. | |
22952 | ||
22953 | @item | |
22954 | Linker relaxation must be turned on so that the linker generates | |
22955 | the stubs correctly in all situations. See the compiler option | |
22956 | @option{-mrelax} and the linker option @option{--relax}. | |
22957 | There are corner cases where the linker is supposed to generate stubs | |
22958 | but aborts without relaxation and without a helpful error message. | |
22959 | ||
22960 | @item | |
22961 | The default linker script is arranged for code with @code{EIND = 0}. | |
22962 | If code is supposed to work for a setup with @code{EIND != 0}, a custom | |
22963 | linker script has to be used in order to place the sections whose | |
22964 | name start with @code{.trampolines} into the segment where @code{EIND} | |
22965 | points to. | |
22966 | ||
22967 | @item | |
22968 | The startup code from libgcc never sets @code{EIND}. | |
22969 | Notice that startup code is a blend of code from libgcc and AVR-LibC. | |
22970 | For the impact of AVR-LibC on @code{EIND}, see the | |
a65da9be | 22971 | @w{@uref{https://www.nongnu.org/avr-libc/user-manual/,AVR-LibC user manual}}. |
d77de738 ML |
22972 | |
22973 | @item | |
22974 | It is legitimate for user-specific startup code to set up @code{EIND} | |
22975 | early, for example by means of initialization code located in | |
22976 | section @code{.init3}. Such code runs prior to general startup code | |
22977 | that initializes RAM and calls constructors, but after the bit | |
22978 | of startup code from AVR-LibC that sets @code{EIND} to the segment | |
22979 | where the vector table is located. | |
22980 | @example | |
22981 | #include <avr/io.h> | |
22982 | ||
22983 | static void | |
22984 | __attribute__((section(".init3"),naked,used,no_instrument_function)) | |
22985 | init3_set_eind (void) | |
22986 | @{ | |
22987 | __asm volatile ("ldi r24,pm_hh8(__trampolines_start)\n\t" | |
22988 | "out %i0,r24" :: "n" (&EIND) : "r24","memory"); | |
22989 | @} | |
22990 | @end example | |
22991 | ||
22992 | @noindent | |
22993 | The @code{__trampolines_start} symbol is defined in the linker script. | |
22994 | ||
22995 | @item | |
22996 | Stubs are generated automatically by the linker if | |
22997 | the following two conditions are met: | |
22998 | @itemize @minus | |
22999 | ||
23000 | @item The address of a label is taken by means of the @code{gs} modifier | |
23001 | (short for @emph{generate stubs}) like so: | |
23002 | @example | |
23003 | LDI r24, lo8(gs(@var{func})) | |
23004 | LDI r25, hi8(gs(@var{func})) | |
23005 | @end example | |
23006 | @item The final location of that label is in a code segment | |
23007 | @emph{outside} the segment where the stubs are located. | |
23008 | @end itemize | |
23009 | ||
23010 | @item | |
23011 | The compiler emits such @code{gs} modifiers for code labels in the | |
23012 | following situations: | |
23013 | @itemize @minus | |
23014 | @item Taking address of a function or code label. | |
23015 | @item Computed goto. | |
23016 | @item If prologue-save function is used, see @option{-mcall-prologues} | |
23017 | command-line option. | |
23018 | @item Switch/case dispatch tables. If you do not want such dispatch | |
23019 | tables you can specify the @option{-fno-jump-tables} command-line option. | |
23020 | @item C and C++ constructors/destructors called during startup/shutdown. | |
23021 | @item If the tools hit a @code{gs()} modifier explained above. | |
23022 | @end itemize | |
23023 | ||
23024 | @item | |
23025 | Jumping to non-symbolic addresses like so is @emph{not} supported: | |
23026 | ||
23027 | @example | |
23028 | int main (void) | |
23029 | @{ | |
23030 | /* Call function at word address 0x2 */ | |
23031 | return ((int(*)(void)) 0x2)(); | |
23032 | @} | |
23033 | @end example | |
23034 | ||
23035 | Instead, a stub has to be set up, i.e.@: the function has to be called | |
23036 | through a symbol (@code{func_4} in the example): | |
23037 | ||
23038 | @example | |
23039 | int main (void) | |
23040 | @{ | |
23041 | extern int func_4 (void); | |
23042 | ||
23043 | /* Call function at byte address 0x4 */ | |
23044 | return func_4(); | |
23045 | @} | |
23046 | @end example | |
23047 | ||
23048 | and the application be linked with @option{-Wl,--defsym,func_4=0x4}. | |
23049 | Alternatively, @code{func_4} can be defined in the linker script. | |
23050 | @end itemize | |
23051 | ||
23052 | @subsubsection Handling of the @code{RAMPD}, @code{RAMPX}, @code{RAMPY} and @code{RAMPZ} Special Function Registers | |
23053 | @cindex @code{RAMPD} | |
23054 | @cindex @code{RAMPX} | |
23055 | @cindex @code{RAMPY} | |
23056 | @cindex @code{RAMPZ} | |
23057 | Some AVR devices support memories larger than the 64@tie{}KiB range | |
23058 | that can be accessed with 16-bit pointers. To access memory locations | |
23059 | outside this 64@tie{}KiB range, the content of a @code{RAMP} | |
23060 | register is used as high part of the address: | |
23061 | The @code{X}, @code{Y}, @code{Z} address register is concatenated | |
23062 | with the @code{RAMPX}, @code{RAMPY}, @code{RAMPZ} special function | |
23063 | register, respectively, to get a wide address. Similarly, | |
23064 | @code{RAMPD} is used together with direct addressing. | |
23065 | ||
23066 | @itemize | |
23067 | @item | |
23068 | The startup code initializes the @code{RAMP} special function | |
23069 | registers with zero. | |
23070 | ||
23071 | @item | |
23072 | If a @ref{AVR Named Address Spaces,named address space} other than | |
23073 | generic or @code{__flash} is used, then @code{RAMPZ} is set | |
23074 | as needed before the operation. | |
23075 | ||
23076 | @item | |
23077 | If the device supports RAM larger than 64@tie{}KiB and the compiler | |
23078 | needs to change @code{RAMPZ} to accomplish an operation, @code{RAMPZ} | |
23079 | is reset to zero after the operation. | |
23080 | ||
23081 | @item | |
23082 | If the device comes with a specific @code{RAMP} register, the ISR | |
23083 | prologue/epilogue saves/restores that SFR and initializes it with | |
23084 | zero in case the ISR code might (implicitly) use it. | |
23085 | ||
23086 | @item | |
23087 | RAM larger than 64@tie{}KiB is not supported by GCC for AVR targets. | |
23088 | If you use inline assembler to read from locations outside the | |
23089 | 16-bit address range and change one of the @code{RAMP} registers, | |
23090 | you must reset it to zero after the access. | |
23091 | ||
23092 | @end itemize | |
23093 | ||
23094 | @subsubsection AVR Built-in Macros | |
23095 | ||
23096 | GCC defines several built-in macros so that the user code can test | |
23097 | for the presence or absence of features. Almost any of the following | |
23098 | built-in macros are deduced from device capabilities and thus | |
23099 | triggered by the @option{-mmcu=} command-line option. | |
23100 | ||
23101 | For even more AVR-specific built-in macros see | |
23102 | @ref{AVR Named Address Spaces} and @ref{AVR Built-in Functions}. | |
23103 | ||
23104 | @table @code | |
23105 | ||
23106 | @item __AVR_ARCH__ | |
23107 | Build-in macro that resolves to a decimal number that identifies the | |
23108 | architecture and depends on the @option{-mmcu=@var{mcu}} option. | |
23109 | Possible values are: | |
23110 | ||
23111 | @code{2}, @code{25}, @code{3}, @code{31}, @code{35}, | |
23112 | @code{4}, @code{5}, @code{51}, @code{6} | |
23113 | ||
23114 | for @var{mcu}=@code{avr2}, @code{avr25}, @code{avr3}, @code{avr31}, | |
23115 | @code{avr35}, @code{avr4}, @code{avr5}, @code{avr51}, @code{avr6}, | |
23116 | ||
23117 | respectively and | |
23118 | ||
23119 | @code{100}, | |
23120 | @code{102}, @code{103}, @code{104}, | |
23121 | @code{105}, @code{106}, @code{107} | |
23122 | ||
23123 | for @var{mcu}=@code{avrtiny}, | |
23124 | @code{avrxmega2}, @code{avrxmega3}, @code{avrxmega4}, | |
23125 | @code{avrxmega5}, @code{avrxmega6}, @code{avrxmega7}, respectively. | |
23126 | If @var{mcu} specifies a device, this built-in macro is set | |
23127 | accordingly. For example, with @option{-mmcu=atmega8} the macro is | |
23128 | defined to @code{4}. | |
23129 | ||
23130 | @item __AVR_@var{Device}__ | |
23131 | Setting @option{-mmcu=@var{device}} defines this built-in macro which reflects | |
23132 | the device's name. For example, @option{-mmcu=atmega8} defines the | |
23133 | built-in macro @code{__AVR_ATmega8__}, @option{-mmcu=attiny261a} defines | |
23134 | @code{__AVR_ATtiny261A__}, etc. | |
23135 | ||
23136 | The built-in macros' names follow | |
23137 | the scheme @code{__AVR_@var{Device}__} where @var{Device} is | |
23138 | the device name as from the AVR user manual. The difference between | |
23139 | @var{Device} in the built-in macro and @var{device} in | |
23140 | @option{-mmcu=@var{device}} is that the latter is always lowercase. | |
23141 | ||
23142 | If @var{device} is not a device but only a core architecture like | |
23143 | @samp{avr51}, this macro is not defined. | |
23144 | ||
23145 | @item __AVR_DEVICE_NAME__ | |
23146 | Setting @option{-mmcu=@var{device}} defines this built-in macro to | |
23147 | the device's name. For example, with @option{-mmcu=atmega8} the macro | |
23148 | is defined to @code{atmega8}. | |
23149 | ||
23150 | If @var{device} is not a device but only a core architecture like | |
23151 | @samp{avr51}, this macro is not defined. | |
23152 | ||
23153 | @item __AVR_XMEGA__ | |
23154 | The device / architecture belongs to the XMEGA family of devices. | |
23155 | ||
23156 | @item __AVR_HAVE_ELPM__ | |
23157 | The device has the @code{ELPM} instruction. | |
23158 | ||
23159 | @item __AVR_HAVE_ELPMX__ | |
23160 | The device has the @code{ELPM R@var{n},Z} and @code{ELPM | |
23161 | R@var{n},Z+} instructions. | |
23162 | ||
23163 | @item __AVR_HAVE_MOVW__ | |
23164 | The device has the @code{MOVW} instruction to perform 16-bit | |
23165 | register-register moves. | |
23166 | ||
23167 | @item __AVR_HAVE_LPMX__ | |
23168 | The device has the @code{LPM R@var{n},Z} and | |
23169 | @code{LPM R@var{n},Z+} instructions. | |
23170 | ||
23171 | @item __AVR_HAVE_MUL__ | |
23172 | The device has a hardware multiplier. | |
23173 | ||
23174 | @item __AVR_HAVE_JMP_CALL__ | |
23175 | The device has the @code{JMP} and @code{CALL} instructions. | |
23176 | This is the case for devices with more than 8@tie{}KiB of program | |
23177 | memory. | |
23178 | ||
23179 | @item __AVR_HAVE_EIJMP_EICALL__ | |
23180 | @itemx __AVR_3_BYTE_PC__ | |
23181 | The device has the @code{EIJMP} and @code{EICALL} instructions. | |
23182 | This is the case for devices with more than 128@tie{}KiB of program memory. | |
23183 | This also means that the program counter | |
23184 | (PC) is 3@tie{}bytes wide. | |
23185 | ||
23186 | @item __AVR_2_BYTE_PC__ | |
23187 | The program counter (PC) is 2@tie{}bytes wide. This is the case for devices | |
23188 | with up to 128@tie{}KiB of program memory. | |
23189 | ||
23190 | @item __AVR_HAVE_8BIT_SP__ | |
23191 | @itemx __AVR_HAVE_16BIT_SP__ | |
23192 | The stack pointer (SP) register is treated as 8-bit respectively | |
23193 | 16-bit register by the compiler. | |
23194 | The definition of these macros is affected by @option{-mtiny-stack}. | |
23195 | ||
23196 | @item __AVR_HAVE_SPH__ | |
23197 | @itemx __AVR_SP8__ | |
23198 | The device has the SPH (high part of stack pointer) special function | |
23199 | register or has an 8-bit stack pointer, respectively. | |
23200 | The definition of these macros is affected by @option{-mmcu=} and | |
23201 | in the cases of @option{-mmcu=avr2} and @option{-mmcu=avr25} also | |
23202 | by @option{-msp8}. | |
23203 | ||
23204 | @item __AVR_HAVE_RAMPD__ | |
23205 | @itemx __AVR_HAVE_RAMPX__ | |
23206 | @itemx __AVR_HAVE_RAMPY__ | |
23207 | @itemx __AVR_HAVE_RAMPZ__ | |
23208 | The device has the @code{RAMPD}, @code{RAMPX}, @code{RAMPY}, | |
23209 | @code{RAMPZ} special function register, respectively. | |
23210 | ||
23211 | @item __NO_INTERRUPTS__ | |
23212 | This macro reflects the @option{-mno-interrupts} command-line option. | |
23213 | ||
23214 | @item __AVR_ERRATA_SKIP__ | |
23215 | @itemx __AVR_ERRATA_SKIP_JMP_CALL__ | |
23216 | Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit | |
23217 | instructions because of a hardware erratum. Skip instructions are | |
23218 | @code{SBRS}, @code{SBRC}, @code{SBIS}, @code{SBIC} and @code{CPSE}. | |
23219 | The second macro is only defined if @code{__AVR_HAVE_JMP_CALL__} is also | |
23220 | set. | |
23221 | ||
23222 | @item __AVR_ISA_RMW__ | |
23223 | The device has Read-Modify-Write instructions (XCH, LAC, LAS and LAT). | |
23224 | ||
23225 | @item __AVR_SFR_OFFSET__=@var{offset} | |
23226 | Instructions that can address I/O special function registers directly | |
23227 | like @code{IN}, @code{OUT}, @code{SBI}, etc.@: may use a different | |
23228 | address as if addressed by an instruction to access RAM like @code{LD} | |
23229 | or @code{STS}. This offset depends on the device architecture and has | |
23230 | to be subtracted from the RAM address in order to get the | |
23231 | respective I/O@tie{}address. | |
23232 | ||
23233 | @item __AVR_SHORT_CALLS__ | |
23234 | The @option{-mshort-calls} command line option is set. | |
23235 | ||
23236 | @item __AVR_PM_BASE_ADDRESS__=@var{addr} | |
23237 | Some devices support reading from flash memory by means of @code{LD*} | |
23238 | instructions. The flash memory is seen in the data address space | |
23239 | at an offset of @code{__AVR_PM_BASE_ADDRESS__}. If this macro | |
23240 | is not defined, this feature is not available. If defined, | |
23241 | the address space is linear and there is no need to put | |
23242 | @code{.rodata} into RAM. This is handled by the default linker | |
23243 | description file, and is currently available for | |
23244 | @code{avrtiny} and @code{avrxmega3}. Even more convenient, | |
23245 | there is no need to use address spaces like @code{__flash} or | |
23246 | features like attribute @code{progmem} and @code{pgm_read_*}. | |
23247 | ||
23248 | @item __WITH_AVRLIBC__ | |
23249 | The compiler is configured to be used together with AVR-Libc. | |
23250 | See the @option{--with-avrlibc} configure option. | |
23251 | ||
23252 | @item __HAVE_DOUBLE_MULTILIB__ | |
23253 | Defined if @option{-mdouble=} acts as a multilib option. | |
23254 | ||
23255 | @item __HAVE_DOUBLE32__ | |
23256 | @itemx __HAVE_DOUBLE64__ | |
23257 | Defined if the compiler supports 32-bit double resp. 64-bit double. | |
23258 | The actual layout is specified by option @option{-mdouble=}. | |
23259 | ||
23260 | @item __DEFAULT_DOUBLE__ | |
23261 | The size in bits of @code{double} if @option{-mdouble=} is not set. | |
23262 | To test the layout of @code{double} in a program, use the built-in | |
23263 | macro @code{__SIZEOF_DOUBLE__}. | |
23264 | ||
23265 | @item __HAVE_LONG_DOUBLE32__ | |
23266 | @itemx __HAVE_LONG_DOUBLE64__ | |
23267 | @itemx __HAVE_LONG_DOUBLE_MULTILIB__ | |
23268 | @itemx __DEFAULT_LONG_DOUBLE__ | |
23269 | Same as above, but for @code{long double} instead of @code{double}. | |
23270 | ||
23271 | @item __WITH_DOUBLE_COMPARISON__ | |
23272 | Reflects the @code{--with-double-comparison=@{tristate|bool|libf7@}} | |
23273 | @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}} | |
23274 | and is defined to @code{2} or @code{3}. | |
23275 | ||
23276 | @item __WITH_LIBF7_LIBGCC__ | |
23277 | @itemx __WITH_LIBF7_MATH__ | |
23278 | @itemx __WITH_LIBF7_MATH_SYMBOLS__ | |
23279 | Reflects the @code{--with-libf7=@{libgcc|math|math-symbols@}} | |
23280 | @w{@uref{https://gcc.gnu.org/install/configure.html#avr,configure option}}. | |
23281 | ||
23282 | @end table | |
23283 | ||
23284 | @node Blackfin Options | |
23285 | @subsection Blackfin Options | |
23286 | @cindex Blackfin Options | |
23287 | ||
23288 | @table @gcctabopt | |
d77de738 | 23289 | @opindex mcpu= |
ddf6fe37 | 23290 | @item -mcpu=@var{cpu}@r{[}-@var{sirevision}@r{]} |
d77de738 ML |
23291 | Specifies the name of the target Blackfin processor. Currently, @var{cpu} |
23292 | can be one of @samp{bf512}, @samp{bf514}, @samp{bf516}, @samp{bf518}, | |
23293 | @samp{bf522}, @samp{bf523}, @samp{bf524}, @samp{bf525}, @samp{bf526}, | |
23294 | @samp{bf527}, @samp{bf531}, @samp{bf532}, @samp{bf533}, | |
23295 | @samp{bf534}, @samp{bf536}, @samp{bf537}, @samp{bf538}, @samp{bf539}, | |
23296 | @samp{bf542}, @samp{bf544}, @samp{bf547}, @samp{bf548}, @samp{bf549}, | |
23297 | @samp{bf542m}, @samp{bf544m}, @samp{bf547m}, @samp{bf548m}, @samp{bf549m}, | |
23298 | @samp{bf561}, @samp{bf592}. | |
23299 | ||
23300 | The optional @var{sirevision} specifies the silicon revision of the target | |
23301 | Blackfin processor. Any workarounds available for the targeted silicon revision | |
23302 | are enabled. If @var{sirevision} is @samp{none}, no workarounds are enabled. | |
23303 | If @var{sirevision} is @samp{any}, all workarounds for the targeted processor | |
23304 | are enabled. The @code{__SILICON_REVISION__} macro is defined to two | |
23305 | hexadecimal digits representing the major and minor numbers in the silicon | |
23306 | revision. If @var{sirevision} is @samp{none}, the @code{__SILICON_REVISION__} | |
23307 | is not defined. If @var{sirevision} is @samp{any}, the | |
23308 | @code{__SILICON_REVISION__} is defined to be @code{0xffff}. | |
23309 | If this optional @var{sirevision} is not used, GCC assumes the latest known | |
23310 | silicon revision of the targeted Blackfin processor. | |
23311 | ||
23312 | GCC defines a preprocessor macro for the specified @var{cpu}. | |
23313 | For the @samp{bfin-elf} toolchain, this option causes the hardware BSP | |
23314 | provided by libgloss to be linked in if @option{-msim} is not given. | |
23315 | ||
23316 | Without this option, @samp{bf532} is used as the processor by default. | |
23317 | ||
23318 | Note that support for @samp{bf561} is incomplete. For @samp{bf561}, | |
23319 | only the preprocessor macro is defined. | |
23320 | ||
d77de738 | 23321 | @opindex msim |
ddf6fe37 | 23322 | @item -msim |
d77de738 ML |
23323 | Specifies that the program will be run on the simulator. This causes |
23324 | the simulator BSP provided by libgloss to be linked in. This option | |
23325 | has effect only for @samp{bfin-elf} toolchain. | |
23326 | Certain other options, such as @option{-mid-shared-library} and | |
23327 | @option{-mfdpic}, imply @option{-msim}. | |
23328 | ||
d77de738 | 23329 | @opindex momit-leaf-frame-pointer |
ddf6fe37 | 23330 | @item -momit-leaf-frame-pointer |
d77de738 ML |
23331 | Don't keep the frame pointer in a register for leaf functions. This |
23332 | avoids the instructions to save, set up and restore frame pointers and | |
23333 | makes an extra register available in leaf functions. | |
23334 | ||
d77de738 | 23335 | @opindex mspecld-anomaly |
ddf6fe37 | 23336 | @item -mspecld-anomaly |
d77de738 ML |
23337 | When enabled, the compiler ensures that the generated code does not |
23338 | contain speculative loads after jump instructions. If this option is used, | |
23339 | @code{__WORKAROUND_SPECULATIVE_LOADS} is defined. | |
23340 | ||
d77de738 ML |
23341 | @opindex mno-specld-anomaly |
23342 | @opindex mspecld-anomaly | |
ddf6fe37 | 23343 | @item -mno-specld-anomaly |
d77de738 ML |
23344 | Don't generate extra code to prevent speculative loads from occurring. |
23345 | ||
d77de738 | 23346 | @opindex mcsync-anomaly |
ddf6fe37 | 23347 | @item -mcsync-anomaly |
d77de738 ML |
23348 | When enabled, the compiler ensures that the generated code does not |
23349 | contain CSYNC or SSYNC instructions too soon after conditional branches. | |
23350 | If this option is used, @code{__WORKAROUND_SPECULATIVE_SYNCS} is defined. | |
23351 | ||
d77de738 ML |
23352 | @opindex mno-csync-anomaly |
23353 | @opindex mcsync-anomaly | |
ddf6fe37 | 23354 | @item -mno-csync-anomaly |
d77de738 ML |
23355 | Don't generate extra code to prevent CSYNC or SSYNC instructions from |
23356 | occurring too soon after a conditional branch. | |
23357 | ||
d77de738 | 23358 | @opindex mlow64k |
ddf6fe37 | 23359 | @item -mlow64k |
d77de738 ML |
23360 | When enabled, the compiler is free to take advantage of the knowledge that |
23361 | the entire program fits into the low 64k of memory. | |
23362 | ||
d77de738 | 23363 | @opindex mno-low64k |
ddf6fe37 | 23364 | @item -mno-low64k |
d77de738 ML |
23365 | Assume that the program is arbitrarily large. This is the default. |
23366 | ||
d77de738 | 23367 | @opindex mstack-check-l1 |
ddf6fe37 | 23368 | @item -mstack-check-l1 |
d77de738 ML |
23369 | Do stack checking using information placed into L1 scratchpad memory by the |
23370 | uClinux kernel. | |
23371 | ||
d77de738 | 23372 | @opindex mid-shared-library |
ddf6fe37 | 23373 | @item -mid-shared-library |
d77de738 ML |
23374 | Generate code that supports shared libraries via the library ID method. |
23375 | This allows for execute in place and shared libraries in an environment | |
23376 | without virtual memory management. This option implies @option{-fPIC}. | |
23377 | With a @samp{bfin-elf} target, this option implies @option{-msim}. | |
23378 | ||
d77de738 ML |
23379 | @opindex mno-id-shared-library |
23380 | @opindex mid-shared-library | |
ddf6fe37 | 23381 | @item -mno-id-shared-library |
d77de738 ML |
23382 | Generate code that doesn't assume ID-based shared libraries are being used. |
23383 | This is the default. | |
23384 | ||
d77de738 | 23385 | @opindex mleaf-id-shared-library |
ddf6fe37 | 23386 | @item -mleaf-id-shared-library |
d77de738 ML |
23387 | Generate code that supports shared libraries via the library ID method, |
23388 | but assumes that this library or executable won't link against any other | |
23389 | ID shared libraries. That allows the compiler to use faster code for jumps | |
23390 | and calls. | |
23391 | ||
d77de738 ML |
23392 | @opindex mno-leaf-id-shared-library |
23393 | @opindex mleaf-id-shared-library | |
ddf6fe37 | 23394 | @item -mno-leaf-id-shared-library |
d77de738 ML |
23395 | Do not assume that the code being compiled won't link against any ID shared |
23396 | libraries. Slower code is generated for jump and call insns. | |
23397 | ||
d77de738 | 23398 | @opindex mshared-library-id |
ddf6fe37 | 23399 | @item -mshared-library-id=n |
d77de738 ML |
23400 | Specifies the identification number of the ID-based shared library being |
23401 | compiled. Specifying a value of 0 generates more compact code; specifying | |
23402 | other values forces the allocation of that number to the current | |
23403 | library but is no more space- or time-efficient than omitting this option. | |
23404 | ||
d77de738 | 23405 | @opindex msep-data |
ddf6fe37 | 23406 | @item -msep-data |
d77de738 ML |
23407 | Generate code that allows the data segment to be located in a different |
23408 | area of memory from the text segment. This allows for execute in place in | |
23409 | an environment without virtual memory management by eliminating relocations | |
23410 | against the text section. | |
23411 | ||
d77de738 ML |
23412 | @opindex mno-sep-data |
23413 | @opindex msep-data | |
ddf6fe37 | 23414 | @item -mno-sep-data |
d77de738 ML |
23415 | Generate code that assumes that the data segment follows the text segment. |
23416 | This is the default. | |
23417 | ||
d77de738 ML |
23418 | @opindex mlong-calls |
23419 | @opindex mno-long-calls | |
ddf6fe37 AA |
23420 | @item -mlong-calls |
23421 | @itemx -mno-long-calls | |
d77de738 ML |
23422 | Tells the compiler to perform function calls by first loading the |
23423 | address of the function into a register and then performing a subroutine | |
23424 | call on this register. This switch is needed if the target function | |
23425 | lies outside of the 24-bit addressing range of the offset-based | |
23426 | version of subroutine call instruction. | |
23427 | ||
23428 | This feature is not enabled by default. Specifying | |
23429 | @option{-mno-long-calls} restores the default behavior. Note these | |
23430 | switches have no effect on how the compiler generates code to handle | |
23431 | function calls via function pointers. | |
23432 | ||
d77de738 | 23433 | @opindex mfast-fp |
ddf6fe37 | 23434 | @item -mfast-fp |
d77de738 ML |
23435 | Link with the fast floating-point library. This library relaxes some of |
23436 | the IEEE floating-point standard's rules for checking inputs against | |
23437 | Not-a-Number (NAN), in the interest of performance. | |
23438 | ||
d77de738 | 23439 | @opindex minline-plt |
ddf6fe37 | 23440 | @item -minline-plt |
d77de738 ML |
23441 | Enable inlining of PLT entries in function calls to functions that are |
23442 | not known to bind locally. It has no effect without @option{-mfdpic}. | |
23443 | ||
d77de738 | 23444 | @opindex mmulticore |
ddf6fe37 | 23445 | @item -mmulticore |
d77de738 ML |
23446 | Build a standalone application for multicore Blackfin processors. |
23447 | This option causes proper start files and link scripts supporting | |
23448 | multicore to be used, and defines the macro @code{__BFIN_MULTICORE}. | |
23449 | It can only be used with @option{-mcpu=bf561@r{[}-@var{sirevision}@r{]}}. | |
23450 | ||
23451 | This option can be used with @option{-mcorea} or @option{-mcoreb}, which | |
23452 | selects the one-application-per-core programming model. Without | |
23453 | @option{-mcorea} or @option{-mcoreb}, the single-application/dual-core | |
23454 | programming model is used. In this model, the main function of Core B | |
23455 | should be named as @code{coreb_main}. | |
23456 | ||
23457 | If this option is not used, the single-core application programming | |
23458 | model is used. | |
23459 | ||
d77de738 | 23460 | @opindex mcorea |
ddf6fe37 | 23461 | @item -mcorea |
d77de738 ML |
23462 | Build a standalone application for Core A of BF561 when using |
23463 | the one-application-per-core programming model. Proper start files | |
23464 | and link scripts are used to support Core A, and the macro | |
23465 | @code{__BFIN_COREA} is defined. | |
23466 | This option can only be used in conjunction with @option{-mmulticore}. | |
23467 | ||
d77de738 | 23468 | @opindex mcoreb |
ddf6fe37 | 23469 | @item -mcoreb |
d77de738 ML |
23470 | Build a standalone application for Core B of BF561 when using |
23471 | the one-application-per-core programming model. Proper start files | |
23472 | and link scripts are used to support Core B, and the macro | |
23473 | @code{__BFIN_COREB} is defined. When this option is used, @code{coreb_main} | |
23474 | should be used instead of @code{main}. | |
23475 | This option can only be used in conjunction with @option{-mmulticore}. | |
23476 | ||
d77de738 | 23477 | @opindex msdram |
ddf6fe37 | 23478 | @item -msdram |
d77de738 ML |
23479 | Build a standalone application for SDRAM. Proper start files and |
23480 | link scripts are used to put the application into SDRAM, and the macro | |
23481 | @code{__BFIN_SDRAM} is defined. | |
23482 | The loader should initialize SDRAM before loading the application. | |
23483 | ||
d77de738 | 23484 | @opindex micplb |
ddf6fe37 | 23485 | @item -micplb |
d77de738 ML |
23486 | Assume that ICPLBs are enabled at run time. This has an effect on certain |
23487 | anomaly workarounds. For Linux targets, the default is to assume ICPLBs | |
23488 | are enabled; for standalone applications the default is off. | |
23489 | @end table | |
23490 | ||
23491 | @node C6X Options | |
23492 | @subsection C6X Options | |
23493 | @cindex C6X Options | |
23494 | ||
23495 | @table @gcctabopt | |
d77de738 | 23496 | @opindex march |
ddf6fe37 | 23497 | @item -march=@var{name} |
d77de738 ML |
23498 | This specifies the name of the target architecture. GCC uses this |
23499 | name to determine what kind of instructions it can emit when generating | |
23500 | assembly code. Permissible names are: @samp{c62x}, | |
23501 | @samp{c64x}, @samp{c64x+}, @samp{c67x}, @samp{c67x+}, @samp{c674x}. | |
23502 | ||
d77de738 | 23503 | @opindex mbig-endian |
ddf6fe37 | 23504 | @item -mbig-endian |
d77de738 ML |
23505 | Generate code for a big-endian target. |
23506 | ||
d77de738 | 23507 | @opindex mlittle-endian |
ddf6fe37 | 23508 | @item -mlittle-endian |
d77de738 ML |
23509 | Generate code for a little-endian target. This is the default. |
23510 | ||
d77de738 | 23511 | @opindex msim |
ddf6fe37 | 23512 | @item -msim |
d77de738 ML |
23513 | Choose startup files and linker script suitable for the simulator. |
23514 | ||
d77de738 | 23515 | @opindex msdata=default |
ddf6fe37 | 23516 | @item -msdata=default |
d77de738 ML |
23517 | Put small global and static data in the @code{.neardata} section, |
23518 | which is pointed to by register @code{B14}. Put small uninitialized | |
23519 | global and static data in the @code{.bss} section, which is adjacent | |
23520 | to the @code{.neardata} section. Put small read-only data into the | |
23521 | @code{.rodata} section. The corresponding sections used for large | |
23522 | pieces of data are @code{.fardata}, @code{.far} and @code{.const}. | |
23523 | ||
d77de738 | 23524 | @opindex msdata=all |
ddf6fe37 | 23525 | @item -msdata=all |
d77de738 ML |
23526 | Put all data, not just small objects, into the sections reserved for |
23527 | small data, and use addressing relative to the @code{B14} register to | |
23528 | access them. | |
23529 | ||
d77de738 | 23530 | @opindex msdata=none |
ddf6fe37 | 23531 | @item -msdata=none |
d77de738 ML |
23532 | Make no use of the sections reserved for small data, and use absolute |
23533 | addresses to access all data. Put all initialized global and static | |
23534 | data in the @code{.fardata} section, and all uninitialized data in the | |
23535 | @code{.far} section. Put all constant data into the @code{.const} | |
23536 | section. | |
23537 | @end table | |
23538 | ||
23539 | @node CRIS Options | |
23540 | @subsection CRIS Options | |
23541 | @cindex CRIS Options | |
23542 | ||
23543 | These options are defined specifically for the CRIS ports. | |
23544 | ||
23545 | @table @gcctabopt | |
d77de738 ML |
23546 | @opindex march |
23547 | @opindex mcpu | |
ddf6fe37 AA |
23548 | @item -march=@var{architecture-type} |
23549 | @itemx -mcpu=@var{architecture-type} | |
d77de738 ML |
23550 | Generate code for the specified architecture. The choices for |
23551 | @var{architecture-type} are @samp{v3}, @samp{v8} and @samp{v10} for | |
23552 | respectively ETRAX@w{ }4, ETRAX@w{ }100, and ETRAX@w{ }100@w{ }LX@. | |
23553 | Default is @samp{v0}. | |
23554 | ||
d77de738 | 23555 | @opindex mtune |
ddf6fe37 | 23556 | @item -mtune=@var{architecture-type} |
d77de738 ML |
23557 | Tune to @var{architecture-type} everything applicable about the generated |
23558 | code, except for the ABI and the set of available instructions. The | |
23559 | choices for @var{architecture-type} are the same as for | |
23560 | @option{-march=@var{architecture-type}}. | |
23561 | ||
d77de738 | 23562 | @opindex mmax-stack-frame |
ddf6fe37 | 23563 | @item -mmax-stack-frame=@var{n} |
d77de738 ML |
23564 | Warn when the stack frame of a function exceeds @var{n} bytes. |
23565 | ||
d77de738 ML |
23566 | @opindex metrax4 |
23567 | @opindex metrax100 | |
ddf6fe37 AA |
23568 | @item -metrax4 |
23569 | @itemx -metrax100 | |
d77de738 ML |
23570 | The options @option{-metrax4} and @option{-metrax100} are synonyms for |
23571 | @option{-march=v3} and @option{-march=v8} respectively. | |
23572 | ||
d77de738 ML |
23573 | @opindex mmul-bug-workaround |
23574 | @opindex mno-mul-bug-workaround | |
ddf6fe37 AA |
23575 | @item -mmul-bug-workaround |
23576 | @itemx -mno-mul-bug-workaround | |
d77de738 ML |
23577 | Work around a bug in the @code{muls} and @code{mulu} instructions for CPU |
23578 | models where it applies. This option is disabled by default. | |
23579 | ||
d77de738 | 23580 | @opindex mpdebug |
ddf6fe37 | 23581 | @item -mpdebug |
d77de738 ML |
23582 | Enable CRIS-specific verbose debug-related information in the assembly |
23583 | code. This option also has the effect of turning off the @samp{#NO_APP} | |
23584 | formatted-code indicator to the assembler at the beginning of the | |
23585 | assembly file. | |
23586 | ||
d77de738 | 23587 | @opindex mcc-init |
ddf6fe37 | 23588 | @item -mcc-init |
d77de738 ML |
23589 | Do not use condition-code results from previous instruction; always emit |
23590 | compare and test instructions before use of condition codes. | |
23591 | ||
d77de738 ML |
23592 | @opindex mno-side-effects |
23593 | @opindex mside-effects | |
ddf6fe37 | 23594 | @item -mno-side-effects |
d77de738 ML |
23595 | Do not emit instructions with side effects in addressing modes other than |
23596 | post-increment. | |
23597 | ||
d77de738 ML |
23598 | @opindex mstack-align |
23599 | @opindex mno-stack-align | |
23600 | @opindex mdata-align | |
23601 | @opindex mno-data-align | |
23602 | @opindex mconst-align | |
23603 | @opindex mno-const-align | |
ddf6fe37 AA |
23604 | @item -mstack-align |
23605 | @itemx -mno-stack-align | |
23606 | @itemx -mdata-align | |
23607 | @itemx -mno-data-align | |
23608 | @itemx -mconst-align | |
23609 | @itemx -mno-const-align | |
d77de738 ML |
23610 | These options (@samp{no-} options) arrange (eliminate arrangements) for the |
23611 | stack frame, individual data and constants to be aligned for the maximum | |
23612 | single data access size for the chosen CPU model. The default is to | |
23613 | arrange for 32-bit alignment. ABI details such as structure layout are | |
23614 | not affected by these options. | |
23615 | ||
d77de738 ML |
23616 | @opindex m32-bit |
23617 | @opindex m16-bit | |
23618 | @opindex m8-bit | |
ddf6fe37 AA |
23619 | @item -m32-bit |
23620 | @itemx -m16-bit | |
23621 | @itemx -m8-bit | |
d77de738 ML |
23622 | Similar to the stack- data- and const-align options above, these options |
23623 | arrange for stack frame, writable data and constants to all be 32-bit, | |
23624 | 16-bit or 8-bit aligned. The default is 32-bit alignment. | |
23625 | ||
d77de738 ML |
23626 | @opindex mno-prologue-epilogue |
23627 | @opindex mprologue-epilogue | |
ddf6fe37 AA |
23628 | @item -mno-prologue-epilogue |
23629 | @itemx -mprologue-epilogue | |
d77de738 ML |
23630 | With @option{-mno-prologue-epilogue}, the normal function prologue and |
23631 | epilogue which set up the stack frame are omitted and no return | |
23632 | instructions or return sequences are generated in the code. Use this | |
23633 | option only together with visual inspection of the compiled code: no | |
23634 | warnings or errors are generated when call-saved registers must be saved, | |
23635 | or storage for local variables needs to be allocated. | |
23636 | ||
d77de738 | 23637 | @opindex melf |
ddf6fe37 | 23638 | @item -melf |
d77de738 ML |
23639 | Legacy no-op option. |
23640 | ||
d77de738 | 23641 | @opindex sim |
ddf6fe37 | 23642 | @item -sim |
d77de738 ML |
23643 | This option arranges |
23644 | to link with input-output functions from a simulator library. Code, | |
23645 | initialized data and zero-initialized data are allocated consecutively. | |
23646 | ||
d77de738 | 23647 | @opindex sim2 |
ddf6fe37 | 23648 | @item -sim2 |
d77de738 ML |
23649 | Like @option{-sim}, but pass linker options to locate initialized data at |
23650 | 0x40000000 and zero-initialized data at 0x80000000. | |
23651 | @end table | |
23652 | ||
23653 | @node C-SKY Options | |
23654 | @subsection C-SKY Options | |
23655 | @cindex C-SKY Options | |
23656 | ||
23657 | GCC supports these options when compiling for C-SKY V2 processors. | |
23658 | ||
23659 | @table @gcctabopt | |
23660 | ||
d77de738 | 23661 | @opindex march= |
ddf6fe37 | 23662 | @item -march=@var{arch} |
d77de738 ML |
23663 | Specify the C-SKY target architecture. Valid values for @var{arch} are: |
23664 | @samp{ck801}, @samp{ck802}, @samp{ck803}, @samp{ck807}, and @samp{ck810}. | |
23665 | The default is @samp{ck810}. | |
23666 | ||
d77de738 | 23667 | @opindex mcpu= |
ddf6fe37 | 23668 | @item -mcpu=@var{cpu} |
d77de738 ML |
23669 | Specify the C-SKY target processor. Valid values for @var{cpu} are: |
23670 | @samp{ck801}, @samp{ck801t}, | |
23671 | @samp{ck802}, @samp{ck802t}, @samp{ck802j}, | |
23672 | @samp{ck803}, @samp{ck803h}, @samp{ck803t}, @samp{ck803ht}, | |
23673 | @samp{ck803f}, @samp{ck803fh}, @samp{ck803e}, @samp{ck803eh}, | |
23674 | @samp{ck803et}, @samp{ck803eht}, @samp{ck803ef}, @samp{ck803efh}, | |
23675 | @samp{ck803ft}, @samp{ck803eft}, @samp{ck803efht}, @samp{ck803r1}, | |
23676 | @samp{ck803hr1}, @samp{ck803tr1}, @samp{ck803htr1}, @samp{ck803fr1}, | |
23677 | @samp{ck803fhr1}, @samp{ck803er1}, @samp{ck803ehr1}, @samp{ck803etr1}, | |
23678 | @samp{ck803ehtr1}, @samp{ck803efr1}, @samp{ck803efhr1}, @samp{ck803ftr1}, | |
23679 | @samp{ck803eftr1}, @samp{ck803efhtr1}, | |
23680 | @samp{ck803s}, @samp{ck803st}, @samp{ck803se}, @samp{ck803sf}, | |
23681 | @samp{ck803sef}, @samp{ck803seft}, | |
23682 | @samp{ck807e}, @samp{ck807ef}, @samp{ck807}, @samp{ck807f}, | |
23683 | @samp{ck810e}, @samp{ck810et}, @samp{ck810ef}, @samp{ck810eft}, | |
23684 | @samp{ck810}, @samp{ck810v}, @samp{ck810f}, @samp{ck810t}, @samp{ck810fv}, | |
23685 | @samp{ck810tv}, @samp{ck810ft}, and @samp{ck810ftv}. | |
23686 | ||
d77de738 | 23687 | @opindex mbig-endian |
d77de738 | 23688 | @opindex EB |
d77de738 | 23689 | @opindex mlittle-endian |
d77de738 | 23690 | @opindex EL |
ddf6fe37 AA |
23691 | @item -mbig-endian |
23692 | @itemx -EB | |
23693 | @itemx -mlittle-endian | |
23694 | @itemx -EL | |
d77de738 ML |
23695 | |
23696 | Select big- or little-endian code. The default is little-endian. | |
23697 | ||
d77de738 | 23698 | @opindex mfloat-abi |
ddf6fe37 | 23699 | @item -mfloat-abi=@var{name} |
d77de738 ML |
23700 | Specifies which floating-point ABI to use. Permissible values |
23701 | are: @samp{soft}, @samp{softfp} and @samp{hard}. | |
23702 | ||
23703 | Specifying @samp{soft} causes GCC to generate output containing | |
23704 | library calls for floating-point operations. | |
23705 | @samp{softfp} allows the generation of code using hardware floating-point | |
23706 | instructions, but still uses the soft-float calling conventions. | |
23707 | @samp{hard} allows generation of floating-point instructions | |
23708 | and uses FPU-specific calling conventions. | |
23709 | ||
23710 | The default depends on the specific target configuration. Note that | |
23711 | the hard-float and soft-float ABIs are not link-compatible; you must | |
23712 | compile your entire program with the same ABI, and link with a | |
23713 | compatible set of libraries. | |
23714 | ||
d77de738 | 23715 | @opindex mhard-float |
d77de738 | 23716 | @opindex msoft-float |
ddf6fe37 AA |
23717 | @item -mhard-float |
23718 | @itemx -msoft-float | |
d77de738 ML |
23719 | |
23720 | Select hardware or software floating-point implementations. | |
23721 | The default is soft float. | |
23722 | ||
ddf6fe37 | 23723 | @opindex mdouble-float |
d77de738 ML |
23724 | @item -mdouble-float |
23725 | @itemx -mno-double-float | |
d77de738 ML |
23726 | When @option{-mhard-float} is in effect, enable generation of |
23727 | double-precision float instructions. This is the default except | |
23728 | when compiling for CK803. | |
23729 | ||
ddf6fe37 | 23730 | @opindex mfdivdu |
d77de738 ML |
23731 | @item -mfdivdu |
23732 | @itemx -mno-fdivdu | |
d77de738 ML |
23733 | When @option{-mhard-float} is in effect, enable generation of |
23734 | @code{frecipd}, @code{fsqrtd}, and @code{fdivd} instructions. | |
23735 | This is the default except when compiling for CK803. | |
23736 | ||
d77de738 | 23737 | @opindex mfpu= |
ddf6fe37 | 23738 | @item -mfpu=@var{fpu} |
d77de738 ML |
23739 | Select the floating-point processor. This option can only be used with |
23740 | @option{-mhard-float}. | |
23741 | Values for @var{fpu} are | |
23742 | @samp{fpv2_sf} (equivalent to @samp{-mno-double-float -mno-fdivdu}), | |
23743 | @samp{fpv2} (@samp{-mdouble-float -mno-divdu}), and | |
23744 | @samp{fpv2_divd} (@samp{-mdouble-float -mdivdu}). | |
23745 | ||
ddf6fe37 | 23746 | @opindex melrw |
d77de738 ML |
23747 | @item -melrw |
23748 | @itemx -mno-elrw | |
d77de738 ML |
23749 | Enable the extended @code{lrw} instruction. This option defaults to on |
23750 | for CK801 and off otherwise. | |
23751 | ||
ddf6fe37 | 23752 | @opindex mistack |
d77de738 ML |
23753 | @item -mistack |
23754 | @itemx -mno-istack | |
d77de738 ML |
23755 | Enable interrupt stack instructions; the default is off. |
23756 | ||
23757 | The @option{-mistack} option is required to handle the | |
23758 | @code{interrupt} and @code{isr} function attributes | |
23759 | (@pxref{C-SKY Function Attributes}). | |
23760 | ||
d77de738 | 23761 | @opindex mmp |
ddf6fe37 | 23762 | @item -mmp |
d77de738 ML |
23763 | Enable multiprocessor instructions; the default is off. |
23764 | ||
d77de738 | 23765 | @opindex mcp |
ddf6fe37 | 23766 | @item -mcp |
d77de738 ML |
23767 | Enable coprocessor instructions; the default is off. |
23768 | ||
d77de738 | 23769 | @opindex mcache |
ddf6fe37 | 23770 | @item -mcache |
d77de738 ML |
23771 | Enable coprocessor instructions; the default is off. |
23772 | ||
d77de738 | 23773 | @opindex msecurity |
ddf6fe37 | 23774 | @item -msecurity |
d77de738 ML |
23775 | Enable C-SKY security instructions; the default is off. |
23776 | ||
d77de738 | 23777 | @opindex mtrust |
ddf6fe37 | 23778 | @item -mtrust |
d77de738 ML |
23779 | Enable C-SKY trust instructions; the default is off. |
23780 | ||
d77de738 | 23781 | @opindex mdsp |
d77de738 | 23782 | @opindex medsp |
d77de738 | 23783 | @opindex mvdsp |
ddf6fe37 AA |
23784 | @item -mdsp |
23785 | @itemx -medsp | |
23786 | @itemx -mvdsp | |
d77de738 ML |
23787 | Enable C-SKY DSP, Enhanced DSP, or Vector DSP instructions, respectively. |
23788 | All of these options default to off. | |
23789 | ||
ddf6fe37 | 23790 | @opindex mdiv |
d77de738 ML |
23791 | @item -mdiv |
23792 | @itemx -mno-div | |
d77de738 ML |
23793 | Generate divide instructions. Default is off. |
23794 | ||
ddf6fe37 | 23795 | @opindex msmart |
d77de738 ML |
23796 | @item -msmart |
23797 | @itemx -mno-smart | |
d77de738 ML |
23798 | Generate code for Smart Mode, using only registers numbered 0-7 to allow |
23799 | use of 16-bit instructions. This option is ignored for CK801 where this | |
23800 | is the required behavior, and it defaults to on for CK802. | |
23801 | For other targets, the default is off. | |
23802 | ||
ddf6fe37 | 23803 | @opindex mhigh-registers |
d77de738 ML |
23804 | @item -mhigh-registers |
23805 | @itemx -mno-high-registers | |
d77de738 ML |
23806 | Generate code using the high registers numbered 16-31. This option |
23807 | is not supported on CK801, CK802, or CK803, and is enabled by default | |
23808 | for other processors. | |
23809 | ||
ddf6fe37 | 23810 | @opindex manchor |
d77de738 ML |
23811 | @item -manchor |
23812 | @itemx -mno-anchor | |
d77de738 ML |
23813 | Generate code using global anchor symbol addresses. |
23814 | ||
ddf6fe37 | 23815 | @opindex mpushpop |
d77de738 ML |
23816 | @item -mpushpop |
23817 | @itemx -mno-pushpop | |
d77de738 ML |
23818 | Generate code using @code{push} and @code{pop} instructions. This option |
23819 | defaults to on. | |
23820 | ||
ddf6fe37 | 23821 | @opindex mmultiple-stld |
d77de738 ML |
23822 | @item -mmultiple-stld |
23823 | @itemx -mstm | |
23824 | @itemx -mno-multiple-stld | |
23825 | @itemx -mno-stm | |
d77de738 ML |
23826 | Generate code using @code{stm} and @code{ldm} instructions. This option |
23827 | isn't supported on CK801 but is enabled by default on other processors. | |
23828 | ||
ddf6fe37 | 23829 | @opindex mconstpool |
d77de738 ML |
23830 | @item -mconstpool |
23831 | @itemx -mno-constpool | |
d77de738 ML |
23832 | Create constant pools in the compiler instead of deferring it to the |
23833 | assembler. This option is the default and required for correct code | |
23834 | generation on CK801 and CK802, and is optional on other processors. | |
23835 | ||
ddf6fe37 | 23836 | @opindex mstack-size |
d77de738 ML |
23837 | @item -mstack-size |
23838 | @item -mno-stack-size | |
d77de738 ML |
23839 | Emit @code{.stack_size} directives for each function in the assembly |
23840 | output. This option defaults to off. | |
23841 | ||
ddf6fe37 | 23842 | @opindex mccrt |
d77de738 ML |
23843 | @item -mccrt |
23844 | @itemx -mno-ccrt | |
d77de738 ML |
23845 | Generate code for the C-SKY compiler runtime instead of libgcc. This |
23846 | option defaults to off. | |
23847 | ||
d77de738 | 23848 | @opindex mbranch-cost= |
ddf6fe37 | 23849 | @item -mbranch-cost=@var{n} |
d77de738 ML |
23850 | Set the branch costs to roughly @code{n} instructions. The default is 1. |
23851 | ||
ddf6fe37 | 23852 | @opindex msched-prolog |
d77de738 ML |
23853 | @item -msched-prolog |
23854 | @itemx -mno-sched-prolog | |
d77de738 ML |
23855 | Permit scheduling of function prologue and epilogue sequences. Using |
23856 | this option can result in code that is not compliant with the C-SKY V2 ABI | |
23857 | prologue requirements and that cannot be debugged or backtraced. | |
23858 | It is disabled by default. | |
23859 | ||
d77de738 | 23860 | @opindex msim |
ddf6fe37 | 23861 | @item -msim |
d77de738 ML |
23862 | Links the library libsemi.a which is in compatible with simulator. Applicable |
23863 | to ELF compiler only. | |
23864 | ||
23865 | @end table | |
23866 | ||
23867 | @node Darwin Options | |
23868 | @subsection Darwin Options | |
23869 | @cindex Darwin options | |
23870 | ||
23871 | These options are defined for all architectures running the Darwin operating | |
23872 | system. | |
23873 | ||
23874 | FSF GCC on Darwin does not create ``fat'' object files; it creates | |
23875 | an object file for the single architecture that GCC was built to | |
23876 | target. Apple's GCC on Darwin does create ``fat'' files if multiple | |
23877 | @option{-arch} options are used; it does so by running the compiler or | |
23878 | linker multiple times and joining the results together with | |
23879 | @file{lipo}. | |
23880 | ||
23881 | The subtype of the file created (like @samp{ppc7400} or @samp{ppc970} or | |
23882 | @samp{i686}) is determined by the flags that specify the ISA | |
23883 | that GCC is targeting, like @option{-mcpu} or @option{-march}. The | |
23884 | @option{-force_cpusubtype_ALL} option can be used to override this. | |
23885 | ||
23886 | The Darwin tools vary in their behavior when presented with an ISA | |
23887 | mismatch. The assembler, @file{as}, only permits instructions to | |
23888 | be used that are valid for the subtype of the file it is generating, | |
23889 | so you cannot put 64-bit instructions in a @samp{ppc750} object file. | |
23890 | The linker for shared libraries, @file{/usr/bin/libtool}, fails | |
23891 | and prints an error if asked to create a shared library with a less | |
23892 | restrictive subtype than its input files (for instance, trying to put | |
23893 | a @samp{ppc970} object file in a @samp{ppc7400} library). The linker | |
23894 | for executables, @command{ld}, quietly gives the executable the most | |
23895 | restrictive subtype of any of its input files. | |
23896 | ||
23897 | @table @gcctabopt | |
d77de738 | 23898 | @opindex F |
ddf6fe37 | 23899 | @item -F@var{dir} |
d77de738 ML |
23900 | Add the framework directory @var{dir} to the head of the list of |
23901 | directories to be searched for header files. These directories are | |
23902 | interleaved with those specified by @option{-I} options and are | |
23903 | scanned in a left-to-right order. | |
23904 | ||
23905 | A framework directory is a directory with frameworks in it. A | |
23906 | framework is a directory with a @file{Headers} and/or | |
23907 | @file{PrivateHeaders} directory contained directly in it that ends | |
23908 | in @file{.framework}. The name of a framework is the name of this | |
23909 | directory excluding the @file{.framework}. Headers associated with | |
23910 | the framework are found in one of those two directories, with | |
23911 | @file{Headers} being searched first. A subframework is a framework | |
23912 | directory that is in a framework's @file{Frameworks} directory. | |
23913 | Includes of subframework headers can only appear in a header of a | |
23914 | framework that contains the subframework, or in a sibling subframework | |
23915 | header. Two subframeworks are siblings if they occur in the same | |
23916 | framework. A subframework should not have the same name as a | |
23917 | framework; a warning is issued if this is violated. Currently a | |
23918 | subframework cannot have subframeworks; in the future, the mechanism | |
23919 | may be extended to support this. The standard frameworks can be found | |
23920 | in @file{/System/Library/Frameworks} and | |
23921 | @file{/Library/Frameworks}. An example include looks like | |
23922 | @code{#include <Framework/header.h>}, where @file{Framework} denotes | |
23923 | the name of the framework and @file{header.h} is found in the | |
23924 | @file{PrivateHeaders} or @file{Headers} directory. | |
23925 | ||
d77de738 | 23926 | @opindex iframework |
ddf6fe37 | 23927 | @item -iframework@var{dir} |
d77de738 ML |
23928 | Like @option{-F} except the directory is a treated as a system |
23929 | directory. The main difference between this @option{-iframework} and | |
23930 | @option{-F} is that with @option{-iframework} the compiler does not | |
23931 | warn about constructs contained within header files found via | |
23932 | @var{dir}. This option is valid only for the C family of languages. | |
23933 | ||
d77de738 | 23934 | @opindex gused |
ddf6fe37 | 23935 | @item -gused |
d77de738 ML |
23936 | Emit debugging information for symbols that are used. For stabs |
23937 | debugging format, this enables @option{-feliminate-unused-debug-symbols}. | |
23938 | This is by default ON@. | |
23939 | ||
d77de738 | 23940 | @opindex gfull |
ddf6fe37 | 23941 | @item -gfull |
d77de738 ML |
23942 | Emit debugging information for all symbols and types. |
23943 | ||
23944 | @item -mmacosx-version-min=@var{version} | |
23945 | The earliest version of MacOS X that this executable will run on | |
23946 | is @var{version}. Typical values of @var{version} include @code{10.1}, | |
23947 | @code{10.2}, and @code{10.3.9}. | |
23948 | ||
23949 | If the compiler was built to use the system's headers by default, | |
23950 | then the default for this option is the system version on which the | |
23951 | compiler is running, otherwise the default is to make choices that | |
23952 | are compatible with as many systems and code bases as possible. | |
23953 | ||
d77de738 | 23954 | @opindex mkernel |
ddf6fe37 | 23955 | @item -mkernel |
d77de738 ML |
23956 | Enable kernel development mode. The @option{-mkernel} option sets |
23957 | @option{-static}, @option{-fno-common}, @option{-fno-use-cxa-atexit}, | |
23958 | @option{-fno-exceptions}, @option{-fno-non-call-exceptions}, | |
23959 | @option{-fapple-kext}, @option{-fno-weak} and @option{-fno-rtti} where | |
23960 | applicable. This mode also sets @option{-mno-altivec}, | |
23961 | @option{-msoft-float}, @option{-fno-builtin} and | |
23962 | @option{-mlong-branch} for PowerPC targets. | |
23963 | ||
d77de738 | 23964 | @opindex mone-byte-bool |
ddf6fe37 | 23965 | @item -mone-byte-bool |
d77de738 ML |
23966 | Override the defaults for @code{bool} so that @code{sizeof(bool)==1}. |
23967 | By default @code{sizeof(bool)} is @code{4} when compiling for | |
23968 | Darwin/PowerPC and @code{1} when compiling for Darwin/x86, so this | |
23969 | option has no effect on x86. | |
23970 | ||
23971 | @strong{Warning:} The @option{-mone-byte-bool} switch causes GCC | |
23972 | to generate code that is not binary compatible with code generated | |
23973 | without that switch. Using this switch may require recompiling all | |
23974 | other modules in a program, including system libraries. Use this | |
23975 | switch to conform to a non-default data model. | |
23976 | ||
d77de738 ML |
23977 | @opindex mfix-and-continue |
23978 | @opindex ffix-and-continue | |
23979 | @opindex findirect-data | |
ddf6fe37 AA |
23980 | @item -mfix-and-continue |
23981 | @itemx -ffix-and-continue | |
23982 | @itemx -findirect-data | |
d77de738 ML |
23983 | Generate code suitable for fast turnaround development, such as to |
23984 | allow GDB to dynamically load @file{.o} files into already-running | |
23985 | programs. @option{-findirect-data} and @option{-ffix-and-continue} | |
23986 | are provided for backwards compatibility. | |
23987 | ||
d77de738 | 23988 | @opindex all_load |
ddf6fe37 | 23989 | @item -all_load |
d77de738 ML |
23990 | Loads all members of static archive libraries. |
23991 | See man ld(1) for more information. | |
23992 | ||
d77de738 | 23993 | @opindex arch_errors_fatal |
ddf6fe37 | 23994 | @item -arch_errors_fatal |
d77de738 ML |
23995 | Cause the errors having to do with files that have the wrong architecture |
23996 | to be fatal. | |
23997 | ||
d77de738 | 23998 | @opindex bind_at_load |
ddf6fe37 | 23999 | @item -bind_at_load |
d77de738 ML |
24000 | Causes the output file to be marked such that the dynamic linker will |
24001 | bind all undefined references when the file is loaded or launched. | |
24002 | ||
d77de738 | 24003 | @opindex bundle |
ddf6fe37 | 24004 | @item -bundle |
d77de738 ML |
24005 | Produce a Mach-o bundle format file. |
24006 | See man ld(1) for more information. | |
24007 | ||
d77de738 | 24008 | @opindex bundle_loader |
ddf6fe37 | 24009 | @item -bundle_loader @var{executable} |
d77de738 ML |
24010 | This option specifies the @var{executable} that will load the build |
24011 | output file being linked. See man ld(1) for more information. | |
24012 | ||
d77de738 | 24013 | @opindex dynamiclib |
ddf6fe37 | 24014 | @item -dynamiclib |
d77de738 ML |
24015 | When passed this option, GCC produces a dynamic library instead of |
24016 | an executable when linking, using the Darwin @file{libtool} command. | |
24017 | ||
d77de738 | 24018 | @opindex force_cpusubtype_ALL |
ddf6fe37 | 24019 | @item -force_cpusubtype_ALL |
d77de738 ML |
24020 | This causes GCC's output file to have the @samp{ALL} subtype, instead of |
24021 | one controlled by the @option{-mcpu} or @option{-march} option. | |
24022 | ||
24023 | @item -allowable_client @var{client_name} | |
24024 | @itemx -client_name | |
24025 | @itemx -compatibility_version | |
24026 | @itemx -current_version | |
24027 | @itemx -dead_strip | |
24028 | @itemx -dependency-file | |
24029 | @itemx -dylib_file | |
24030 | @itemx -dylinker_install_name | |
24031 | @itemx -dynamic | |
24032 | @itemx -exported_symbols_list | |
24033 | @itemx -filelist | |
24034 | @need 800 | |
24035 | @itemx -flat_namespace | |
24036 | @itemx -force_flat_namespace | |
24037 | @itemx -headerpad_max_install_names | |
24038 | @itemx -image_base | |
24039 | @itemx -init | |
24040 | @itemx -install_name | |
24041 | @itemx -keep_private_externs | |
24042 | @itemx -multi_module | |
24043 | @itemx -multiply_defined | |
24044 | @itemx -multiply_defined_unused | |
24045 | @need 800 | |
24046 | @itemx -noall_load | |
24047 | @itemx -no_dead_strip_inits_and_terms | |
24048 | @itemx -nofixprebinding | |
24049 | @itemx -nomultidefs | |
24050 | @itemx -noprebind | |
24051 | @itemx -noseglinkedit | |
24052 | @itemx -pagezero_size | |
24053 | @itemx -prebind | |
24054 | @itemx -prebind_all_twolevel_modules | |
24055 | @itemx -private_bundle | |
24056 | @need 800 | |
24057 | @itemx -read_only_relocs | |
24058 | @itemx -sectalign | |
24059 | @itemx -sectobjectsymbols | |
24060 | @itemx -whyload | |
24061 | @itemx -seg1addr | |
24062 | @itemx -sectcreate | |
24063 | @itemx -sectobjectsymbols | |
24064 | @itemx -sectorder | |
24065 | @itemx -segaddr | |
24066 | @itemx -segs_read_only_addr | |
24067 | @need 800 | |
24068 | @itemx -segs_read_write_addr | |
24069 | @itemx -seg_addr_table | |
24070 | @itemx -seg_addr_table_filename | |
24071 | @itemx -seglinkedit | |
24072 | @itemx -segprot | |
24073 | @itemx -segs_read_only_addr | |
24074 | @itemx -segs_read_write_addr | |
24075 | @itemx -single_module | |
24076 | @itemx -static | |
24077 | @itemx -sub_library | |
24078 | @need 800 | |
d77de738 ML |
24079 | @opindex allowable_client |
24080 | @opindex client_name | |
24081 | @opindex compatibility_version | |
24082 | @opindex current_version | |
24083 | @opindex dead_strip | |
24084 | @opindex dependency-file | |
24085 | @opindex dylib_file | |
24086 | @opindex dylinker_install_name | |
24087 | @opindex dynamic | |
24088 | @opindex exported_symbols_list | |
24089 | @opindex filelist | |
24090 | @opindex flat_namespace | |
24091 | @opindex force_flat_namespace | |
24092 | @opindex headerpad_max_install_names | |
24093 | @opindex image_base | |
24094 | @opindex init | |
24095 | @opindex install_name | |
24096 | @opindex keep_private_externs | |
24097 | @opindex multi_module | |
24098 | @opindex multiply_defined | |
24099 | @opindex multiply_defined_unused | |
24100 | @opindex noall_load | |
24101 | @opindex no_dead_strip_inits_and_terms | |
24102 | @opindex nofixprebinding | |
24103 | @opindex nomultidefs | |
24104 | @opindex noprebind | |
24105 | @opindex noseglinkedit | |
24106 | @opindex pagezero_size | |
24107 | @opindex prebind | |
24108 | @opindex prebind_all_twolevel_modules | |
24109 | @opindex private_bundle | |
24110 | @opindex read_only_relocs | |
24111 | @opindex sectalign | |
24112 | @opindex sectobjectsymbols | |
24113 | @opindex whyload | |
24114 | @opindex seg1addr | |
24115 | @opindex sectcreate | |
24116 | @opindex sectobjectsymbols | |
24117 | @opindex sectorder | |
24118 | @opindex segaddr | |
24119 | @opindex segs_read_only_addr | |
24120 | @opindex segs_read_write_addr | |
24121 | @opindex seg_addr_table | |
24122 | @opindex seg_addr_table_filename | |
24123 | @opindex seglinkedit | |
24124 | @opindex segprot | |
24125 | @opindex segs_read_only_addr | |
24126 | @opindex segs_read_write_addr | |
24127 | @opindex single_module | |
24128 | @opindex static | |
24129 | @opindex sub_library | |
24130 | @opindex sub_umbrella | |
24131 | @opindex twolevel_namespace | |
24132 | @opindex umbrella | |
24133 | @opindex undefined | |
24134 | @opindex unexported_symbols_list | |
24135 | @opindex weak_reference_mismatches | |
24136 | @opindex whatsloaded | |
ddf6fe37 AA |
24137 | @itemx -sub_umbrella |
24138 | @itemx -twolevel_namespace | |
24139 | @itemx -umbrella | |
24140 | @itemx -undefined | |
24141 | @itemx -unexported_symbols_list | |
24142 | @itemx -weak_reference_mismatches | |
24143 | @itemx -whatsloaded | |
d77de738 ML |
24144 | These options are passed to the Darwin linker. The Darwin linker man page |
24145 | describes them in detail. | |
24146 | @end table | |
24147 | ||
24148 | @node DEC Alpha Options | |
24149 | @subsection DEC Alpha Options | |
24150 | ||
24151 | These @samp{-m} options are defined for the DEC Alpha implementations: | |
24152 | ||
24153 | @table @gcctabopt | |
d77de738 ML |
24154 | @opindex mno-soft-float |
24155 | @opindex msoft-float | |
ddf6fe37 AA |
24156 | @item -mno-soft-float |
24157 | @itemx -msoft-float | |
d77de738 ML |
24158 | Use (do not use) the hardware floating-point instructions for |
24159 | floating-point operations. When @option{-msoft-float} is specified, | |
24160 | functions in @file{libgcc.a} are used to perform floating-point | |
24161 | operations. Unless they are replaced by routines that emulate the | |
24162 | floating-point operations, or compiled in such a way as to call such | |
24163 | emulations routines, these routines issue floating-point | |
24164 | operations. If you are compiling for an Alpha without floating-point | |
24165 | operations, you must ensure that the library is built so as not to call | |
24166 | them. | |
24167 | ||
24168 | Note that Alpha implementations without floating-point operations are | |
24169 | required to have floating-point registers. | |
24170 | ||
d77de738 ML |
24171 | @opindex mfp-reg |
24172 | @opindex mno-fp-regs | |
ddf6fe37 AA |
24173 | @item -mfp-reg |
24174 | @itemx -mno-fp-regs | |
d77de738 ML |
24175 | Generate code that uses (does not use) the floating-point register set. |
24176 | @option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point | |
24177 | register set is not used, floating-point operands are passed in integer | |
24178 | registers as if they were integers and floating-point results are passed | |
24179 | in @code{$0} instead of @code{$f0}. This is a non-standard calling sequence, | |
24180 | so any function with a floating-point argument or return value called by code | |
24181 | compiled with @option{-mno-fp-regs} must also be compiled with that | |
24182 | option. | |
24183 | ||
24184 | A typical use of this option is building a kernel that does not use, | |
24185 | and hence need not save and restore, any floating-point registers. | |
24186 | ||
d77de738 | 24187 | @opindex mieee |
ddf6fe37 | 24188 | @item -mieee |
d77de738 ML |
24189 | The Alpha architecture implements floating-point hardware optimized for |
24190 | maximum performance. It is mostly compliant with the IEEE floating-point | |
24191 | standard. However, for full compliance, software assistance is | |
24192 | required. This option generates code fully IEEE-compliant code | |
24193 | @emph{except} that the @var{inexact-flag} is not maintained (see below). | |
24194 | If this option is turned on, the preprocessor macro @code{_IEEE_FP} is | |
24195 | defined during compilation. The resulting code is less efficient but is | |
24196 | able to correctly support denormalized numbers and exceptional IEEE | |
24197 | values such as not-a-number and plus/minus infinity. Other Alpha | |
24198 | compilers call this option @option{-ieee_with_no_inexact}. | |
24199 | ||
d77de738 | 24200 | @opindex mieee-with-inexact |
ddf6fe37 | 24201 | @item -mieee-with-inexact |
d77de738 ML |
24202 | This is like @option{-mieee} except the generated code also maintains |
24203 | the IEEE @var{inexact-flag}. Turning on this option causes the | |
24204 | generated code to implement fully-compliant IEEE math. In addition to | |
24205 | @code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor | |
24206 | macro. On some Alpha implementations the resulting code may execute | |
24207 | significantly slower than the code generated by default. Since there is | |
24208 | very little code that depends on the @var{inexact-flag}, you should | |
24209 | normally not specify this option. Other Alpha compilers call this | |
24210 | option @option{-ieee_with_inexact}. | |
24211 | ||
d77de738 | 24212 | @opindex mfp-trap-mode |
ddf6fe37 | 24213 | @item -mfp-trap-mode=@var{trap-mode} |
d77de738 ML |
24214 | This option controls what floating-point related traps are enabled. |
24215 | Other Alpha compilers call this option @option{-fptm @var{trap-mode}}. | |
24216 | The trap mode can be set to one of four values: | |
24217 | ||
24218 | @table @samp | |
24219 | @item n | |
24220 | This is the default (normal) setting. The only traps that are enabled | |
24221 | are the ones that cannot be disabled in software (e.g., division by zero | |
24222 | trap). | |
24223 | ||
24224 | @item u | |
24225 | In addition to the traps enabled by @samp{n}, underflow traps are enabled | |
24226 | as well. | |
24227 | ||
24228 | @item su | |
24229 | Like @samp{u}, but the instructions are marked to be safe for software | |
24230 | completion (see Alpha architecture manual for details). | |
24231 | ||
24232 | @item sui | |
24233 | Like @samp{su}, but inexact traps are enabled as well. | |
24234 | @end table | |
24235 | ||
d77de738 | 24236 | @opindex mfp-rounding-mode |
ddf6fe37 | 24237 | @item -mfp-rounding-mode=@var{rounding-mode} |
d77de738 ML |
24238 | Selects the IEEE rounding mode. Other Alpha compilers call this option |
24239 | @option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one | |
24240 | of: | |
24241 | ||
24242 | @table @samp | |
24243 | @item n | |
24244 | Normal IEEE rounding mode. Floating-point numbers are rounded towards | |
24245 | the nearest machine number or towards the even machine number in case | |
24246 | of a tie. | |
24247 | ||
24248 | @item m | |
24249 | Round towards minus infinity. | |
24250 | ||
24251 | @item c | |
24252 | Chopped rounding mode. Floating-point numbers are rounded towards zero. | |
24253 | ||
24254 | @item d | |
24255 | Dynamic rounding mode. A field in the floating-point control register | |
24256 | (@var{fpcr}, see Alpha architecture reference manual) controls the | |
24257 | rounding mode in effect. The C library initializes this register for | |
24258 | rounding towards plus infinity. Thus, unless your program modifies the | |
24259 | @var{fpcr}, @samp{d} corresponds to round towards plus infinity. | |
24260 | @end table | |
24261 | ||
d77de738 | 24262 | @opindex mtrap-precision |
ddf6fe37 | 24263 | @item -mtrap-precision=@var{trap-precision} |
d77de738 ML |
24264 | In the Alpha architecture, floating-point traps are imprecise. This |
24265 | means without software assistance it is impossible to recover from a | |
24266 | floating trap and program execution normally needs to be terminated. | |
24267 | GCC can generate code that can assist operating system trap handlers | |
24268 | in determining the exact location that caused a floating-point trap. | |
24269 | Depending on the requirements of an application, different levels of | |
24270 | precisions can be selected: | |
24271 | ||
24272 | @table @samp | |
24273 | @item p | |
24274 | Program precision. This option is the default and means a trap handler | |
24275 | can only identify which program caused a floating-point exception. | |
24276 | ||
24277 | @item f | |
24278 | Function precision. The trap handler can determine the function that | |
24279 | caused a floating-point exception. | |
24280 | ||
24281 | @item i | |
24282 | Instruction precision. The trap handler can determine the exact | |
24283 | instruction that caused a floating-point exception. | |
24284 | @end table | |
24285 | ||
24286 | Other Alpha compilers provide the equivalent options called | |
24287 | @option{-scope_safe} and @option{-resumption_safe}. | |
24288 | ||
d77de738 | 24289 | @opindex mieee-conformant |
ddf6fe37 | 24290 | @item -mieee-conformant |
d77de738 ML |
24291 | This option marks the generated code as IEEE conformant. You must not |
24292 | use this option unless you also specify @option{-mtrap-precision=i} and either | |
24293 | @option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect | |
24294 | is to emit the line @samp{.eflag 48} in the function prologue of the | |
24295 | generated assembly file. | |
24296 | ||
d77de738 | 24297 | @opindex mbuild-constants |
ddf6fe37 | 24298 | @item -mbuild-constants |
d77de738 ML |
24299 | Normally GCC examines a 32- or 64-bit integer constant to |
24300 | see if it can construct it from smaller constants in two or three | |
24301 | instructions. If it cannot, it outputs the constant as a literal and | |
24302 | generates code to load it from the data segment at run time. | |
24303 | ||
24304 | Use this option to require GCC to construct @emph{all} integer constants | |
24305 | using code, even if it takes more instructions (the maximum is six). | |
24306 | ||
24307 | You typically use this option to build a shared library dynamic | |
24308 | loader. Itself a shared library, it must relocate itself in memory | |
24309 | before it can find the variables and constants in its own data segment. | |
24310 | ||
d77de738 ML |
24311 | @opindex mbwx |
24312 | @opindex mno-bwx | |
24313 | @opindex mcix | |
24314 | @opindex mno-cix | |
24315 | @opindex mfix | |
24316 | @opindex mno-fix | |
24317 | @opindex mmax | |
24318 | @opindex mno-max | |
ddf6fe37 AA |
24319 | @item -mbwx |
24320 | @itemx -mno-bwx | |
24321 | @itemx -mcix | |
24322 | @itemx -mno-cix | |
24323 | @itemx -mfix | |
24324 | @itemx -mno-fix | |
24325 | @itemx -mmax | |
24326 | @itemx -mno-max | |
d77de738 ML |
24327 | Indicate whether GCC should generate code to use the optional BWX, |
24328 | CIX, FIX and MAX instruction sets. The default is to use the instruction | |
24329 | sets supported by the CPU type specified via @option{-mcpu=} option or that | |
24330 | of the CPU on which GCC was built if none is specified. | |
24331 | ||
d77de738 ML |
24332 | @opindex mfloat-vax |
24333 | @opindex mfloat-ieee | |
ddf6fe37 AA |
24334 | @item -mfloat-vax |
24335 | @itemx -mfloat-ieee | |
d77de738 ML |
24336 | Generate code that uses (does not use) VAX F and G floating-point |
24337 | arithmetic instead of IEEE single and double precision. | |
24338 | ||
d77de738 ML |
24339 | @opindex mexplicit-relocs |
24340 | @opindex mno-explicit-relocs | |
ddf6fe37 AA |
24341 | @item -mexplicit-relocs |
24342 | @itemx -mno-explicit-relocs | |
d77de738 ML |
24343 | Older Alpha assemblers provided no way to generate symbol relocations |
24344 | except via assembler macros. Use of these macros does not allow | |
24345 | optimal instruction scheduling. GNU binutils as of version 2.12 | |
24346 | supports a new syntax that allows the compiler to explicitly mark | |
24347 | which relocations should apply to which instructions. This option | |
24348 | is mostly useful for debugging, as GCC detects the capabilities of | |
24349 | the assembler when it is built and sets the default accordingly. | |
24350 | ||
d77de738 ML |
24351 | @opindex msmall-data |
24352 | @opindex mlarge-data | |
ddf6fe37 AA |
24353 | @item -msmall-data |
24354 | @itemx -mlarge-data | |
d77de738 ML |
24355 | When @option{-mexplicit-relocs} is in effect, static data is |
24356 | accessed via @dfn{gp-relative} relocations. When @option{-msmall-data} | |
24357 | is used, objects 8 bytes long or smaller are placed in a @dfn{small data area} | |
24358 | (the @code{.sdata} and @code{.sbss} sections) and are accessed via | |
24359 | 16-bit relocations off of the @code{$gp} register. This limits the | |
24360 | size of the small data area to 64KB, but allows the variables to be | |
24361 | directly accessed via a single instruction. | |
24362 | ||
24363 | The default is @option{-mlarge-data}. With this option the data area | |
24364 | is limited to just below 2GB@. Programs that require more than 2GB of | |
24365 | data must use @code{malloc} or @code{mmap} to allocate the data in the | |
24366 | heap instead of in the program's data segment. | |
24367 | ||
24368 | When generating code for shared libraries, @option{-fpic} implies | |
24369 | @option{-msmall-data} and @option{-fPIC} implies @option{-mlarge-data}. | |
24370 | ||
d77de738 ML |
24371 | @opindex msmall-text |
24372 | @opindex mlarge-text | |
ddf6fe37 AA |
24373 | @item -msmall-text |
24374 | @itemx -mlarge-text | |
d77de738 ML |
24375 | When @option{-msmall-text} is used, the compiler assumes that the |
24376 | code of the entire program (or shared library) fits in 4MB, and is | |
24377 | thus reachable with a branch instruction. When @option{-msmall-data} | |
24378 | is used, the compiler can assume that all local symbols share the | |
24379 | same @code{$gp} value, and thus reduce the number of instructions | |
24380 | required for a function call from 4 to 1. | |
24381 | ||
24382 | The default is @option{-mlarge-text}. | |
24383 | ||
d77de738 | 24384 | @opindex mcpu |
ddf6fe37 | 24385 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
24386 | Set the instruction set and instruction scheduling parameters for |
24387 | machine type @var{cpu_type}. You can specify either the @samp{EV} | |
24388 | style name or the corresponding chip number. GCC supports scheduling | |
24389 | parameters for the EV4, EV5 and EV6 family of processors and | |
24390 | chooses the default values for the instruction set from the processor | |
24391 | you specify. If you do not specify a processor type, GCC defaults | |
24392 | to the processor on which the compiler was built. | |
24393 | ||
24394 | Supported values for @var{cpu_type} are | |
24395 | ||
24396 | @table @samp | |
24397 | @item ev4 | |
24398 | @itemx ev45 | |
24399 | @itemx 21064 | |
24400 | Schedules as an EV4 and has no instruction set extensions. | |
24401 | ||
24402 | @item ev5 | |
24403 | @itemx 21164 | |
24404 | Schedules as an EV5 and has no instruction set extensions. | |
24405 | ||
24406 | @item ev56 | |
24407 | @itemx 21164a | |
24408 | Schedules as an EV5 and supports the BWX extension. | |
24409 | ||
24410 | @item pca56 | |
24411 | @itemx 21164pc | |
24412 | @itemx 21164PC | |
24413 | Schedules as an EV5 and supports the BWX and MAX extensions. | |
24414 | ||
24415 | @item ev6 | |
24416 | @itemx 21264 | |
24417 | Schedules as an EV6 and supports the BWX, FIX, and MAX extensions. | |
24418 | ||
24419 | @item ev67 | |
24420 | @itemx 21264a | |
24421 | Schedules as an EV6 and supports the BWX, CIX, FIX, and MAX extensions. | |
24422 | @end table | |
24423 | ||
24424 | Native toolchains also support the value @samp{native}, | |
24425 | which selects the best architecture option for the host processor. | |
24426 | @option{-mcpu=native} has no effect if GCC does not recognize | |
24427 | the processor. | |
24428 | ||
d77de738 | 24429 | @opindex mtune |
ddf6fe37 | 24430 | @item -mtune=@var{cpu_type} |
d77de738 ML |
24431 | Set only the instruction scheduling parameters for machine type |
24432 | @var{cpu_type}. The instruction set is not changed. | |
24433 | ||
24434 | Native toolchains also support the value @samp{native}, | |
24435 | which selects the best architecture option for the host processor. | |
24436 | @option{-mtune=native} has no effect if GCC does not recognize | |
24437 | the processor. | |
24438 | ||
d77de738 | 24439 | @opindex mmemory-latency |
ddf6fe37 | 24440 | @item -mmemory-latency=@var{time} |
d77de738 ML |
24441 | Sets the latency the scheduler should assume for typical memory |
24442 | references as seen by the application. This number is highly | |
24443 | dependent on the memory access patterns used by the application | |
24444 | and the size of the external cache on the machine. | |
24445 | ||
24446 | Valid options for @var{time} are | |
24447 | ||
24448 | @table @samp | |
24449 | @item @var{number} | |
24450 | A decimal number representing clock cycles. | |
24451 | ||
24452 | @item L1 | |
24453 | @itemx L2 | |
24454 | @itemx L3 | |
24455 | @itemx main | |
24456 | The compiler contains estimates of the number of clock cycles for | |
24457 | ``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches | |
24458 | (also called Dcache, Scache, and Bcache), as well as to main memory. | |
24459 | Note that L3 is only valid for EV5. | |
24460 | ||
24461 | @end table | |
24462 | @end table | |
24463 | ||
24464 | @node eBPF Options | |
24465 | @subsection eBPF Options | |
24466 | @cindex eBPF Options | |
24467 | ||
24468 | @table @gcctabopt | |
24469 | @item -mframe-limit=@var{bytes} | |
24470 | This specifies the hard limit for frame sizes, in bytes. Currently, | |
24471 | the value that can be specified should be less than or equal to | |
24472 | @samp{32767}. Defaults to whatever limit is imposed by the version of | |
24473 | the Linux kernel targeted. | |
24474 | ||
d77de738 | 24475 | @opindex mkernel |
ddf6fe37 | 24476 | @item -mkernel=@var{version} |
d77de738 ML |
24477 | This specifies the minimum version of the kernel that will run the |
24478 | compiled program. GCC uses this version to determine which | |
24479 | instructions to use, what kernel helpers to allow, etc. Currently, | |
24480 | @var{version} can be one of @samp{4.0}, @samp{4.1}, @samp{4.2}, | |
24481 | @samp{4.3}, @samp{4.4}, @samp{4.5}, @samp{4.6}, @samp{4.7}, | |
24482 | @samp{4.8}, @samp{4.9}, @samp{4.10}, @samp{4.11}, @samp{4.12}, | |
24483 | @samp{4.13}, @samp{4.14}, @samp{4.15}, @samp{4.16}, @samp{4.17}, | |
24484 | @samp{4.18}, @samp{4.19}, @samp{4.20}, @samp{5.0}, @samp{5.1}, | |
24485 | @samp{5.2}, @samp{latest} and @samp{native}. | |
24486 | ||
d77de738 | 24487 | @opindex mbig-endian |
ddf6fe37 | 24488 | @item -mbig-endian |
d77de738 ML |
24489 | Generate code for a big-endian target. |
24490 | ||
d77de738 | 24491 | @opindex mlittle-endian |
ddf6fe37 | 24492 | @item -mlittle-endian |
d77de738 ML |
24493 | Generate code for a little-endian target. This is the default. |
24494 | ||
d77de738 | 24495 | @opindex mjmpext |
ddf6fe37 | 24496 | @item -mjmpext |
d77de738 ML |
24497 | Enable generation of extra conditional-branch instructions. |
24498 | Enabled for CPU v2 and above. | |
24499 | ||
d77de738 | 24500 | @opindex mjmp32 |
ddf6fe37 | 24501 | @item -mjmp32 |
d77de738 ML |
24502 | Enable 32-bit jump instructions. Enabled for CPU v3 and above. |
24503 | ||
d77de738 | 24504 | @opindex malu32 |
ddf6fe37 | 24505 | @item -malu32 |
d77de738 ML |
24506 | Enable 32-bit ALU instructions. Enabled for CPU v3 and above. |
24507 | ||
d77de738 | 24508 | @opindex mcpu |
ddf6fe37 | 24509 | @item -mcpu=@var{version} |
d77de738 ML |
24510 | This specifies which version of the eBPF ISA to target. Newer versions |
24511 | may not be supported by all kernels. The default is @samp{v3}. | |
24512 | ||
24513 | Supported values for @var{version} are: | |
24514 | ||
24515 | @table @samp | |
24516 | @item v1 | |
24517 | The first stable eBPF ISA with no special features or extensions. | |
24518 | ||
24519 | @item v2 | |
24520 | Supports the jump extensions, as in @option{-mjmpext}. | |
24521 | ||
24522 | @item v3 | |
24523 | All features of v2, plus: | |
24524 | @itemize @minus | |
24525 | @item 32-bit jump operations, as in @option{-mjmp32} | |
24526 | @item 32-bit ALU operations, as in @option{-malu32} | |
24527 | @end itemize | |
24528 | ||
24529 | @end table | |
24530 | ||
d77de738 | 24531 | @opindex mco-re |
ddf6fe37 | 24532 | @item -mco-re |
d77de738 ML |
24533 | Enable BPF Compile Once - Run Everywhere (CO-RE) support. Requires and |
24534 | is implied by @option{-gbtf}. | |
24535 | ||
d77de738 | 24536 | @opindex mno-co-re |
ddf6fe37 | 24537 | @item -mno-co-re |
d77de738 ML |
24538 | Disable BPF Compile Once - Run Everywhere (CO-RE) support. BPF CO-RE |
24539 | support is enabled by default when generating BTF debug information for | |
24540 | the BPF target. | |
24541 | ||
24542 | @item -mxbpf | |
24543 | Generate code for an expanded version of BPF, which relaxes some of | |
24544 | the restrictions imposed by the BPF architecture: | |
24545 | @itemize @minus | |
24546 | @item Save and restore callee-saved registers at function entry and | |
24547 | exit, respectively. | |
24548 | @end itemize | |
24549 | @end table | |
24550 | ||
24551 | @node FR30 Options | |
24552 | @subsection FR30 Options | |
24553 | @cindex FR30 Options | |
24554 | ||
24555 | These options are defined specifically for the FR30 port. | |
24556 | ||
24557 | @table @gcctabopt | |
24558 | ||
d77de738 | 24559 | @opindex msmall-model |
ddf6fe37 | 24560 | @item -msmall-model |
d77de738 ML |
24561 | Use the small address space model. This can produce smaller code, but |
24562 | it does assume that all symbolic values and addresses fit into a | |
24563 | 20-bit range. | |
24564 | ||
d77de738 | 24565 | @opindex mno-lsim |
ddf6fe37 | 24566 | @item -mno-lsim |
d77de738 ML |
24567 | Assume that runtime support has been provided and so there is no need |
24568 | to include the simulator library (@file{libsim.a}) on the linker | |
24569 | command line. | |
24570 | ||
24571 | @end table | |
24572 | ||
24573 | @node FT32 Options | |
24574 | @subsection FT32 Options | |
24575 | @cindex FT32 Options | |
24576 | ||
24577 | These options are defined specifically for the FT32 port. | |
24578 | ||
24579 | @table @gcctabopt | |
24580 | ||
d77de738 | 24581 | @opindex msim |
ddf6fe37 | 24582 | @item -msim |
d77de738 ML |
24583 | Specifies that the program will be run on the simulator. This causes |
24584 | an alternate runtime startup and library to be linked. | |
24585 | You must not use this option when generating programs that will run on | |
24586 | real hardware; you must provide your own runtime library for whatever | |
24587 | I/O functions are needed. | |
24588 | ||
d77de738 | 24589 | @opindex mlra |
ddf6fe37 | 24590 | @item -mlra |
d77de738 ML |
24591 | Enable Local Register Allocation. This is still experimental for FT32, |
24592 | so by default the compiler uses standard reload. | |
24593 | ||
d77de738 | 24594 | @opindex mnodiv |
ddf6fe37 | 24595 | @item -mnodiv |
d77de738 ML |
24596 | Do not use div and mod instructions. |
24597 | ||
d77de738 | 24598 | @opindex mft32b |
ddf6fe37 | 24599 | @item -mft32b |
d77de738 ML |
24600 | Enable use of the extended instructions of the FT32B processor. |
24601 | ||
d77de738 | 24602 | @opindex mcompress |
ddf6fe37 | 24603 | @item -mcompress |
d77de738 ML |
24604 | Compress all code using the Ft32B code compression scheme. |
24605 | ||
d77de738 | 24606 | @opindex mnopm |
ddf6fe37 | 24607 | @item -mnopm |
d77de738 ML |
24608 | Do not generate code that reads program memory. |
24609 | ||
24610 | @end table | |
24611 | ||
24612 | @node FRV Options | |
24613 | @subsection FRV Options | |
24614 | @cindex FRV Options | |
24615 | ||
24616 | @table @gcctabopt | |
d77de738 | 24617 | @opindex mgpr-32 |
ddf6fe37 | 24618 | @item -mgpr-32 |
d77de738 ML |
24619 | |
24620 | Only use the first 32 general-purpose registers. | |
24621 | ||
d77de738 | 24622 | @opindex mgpr-64 |
ddf6fe37 | 24623 | @item -mgpr-64 |
d77de738 ML |
24624 | |
24625 | Use all 64 general-purpose registers. | |
24626 | ||
d77de738 | 24627 | @opindex mfpr-32 |
ddf6fe37 | 24628 | @item -mfpr-32 |
d77de738 ML |
24629 | |
24630 | Use only the first 32 floating-point registers. | |
24631 | ||
d77de738 | 24632 | @opindex mfpr-64 |
ddf6fe37 | 24633 | @item -mfpr-64 |
d77de738 ML |
24634 | |
24635 | Use all 64 floating-point registers. | |
24636 | ||
d77de738 | 24637 | @opindex mhard-float |
ddf6fe37 | 24638 | @item -mhard-float |
d77de738 ML |
24639 | |
24640 | Use hardware instructions for floating-point operations. | |
24641 | ||
d77de738 | 24642 | @opindex msoft-float |
ddf6fe37 | 24643 | @item -msoft-float |
d77de738 ML |
24644 | |
24645 | Use library routines for floating-point operations. | |
24646 | ||
d77de738 | 24647 | @opindex malloc-cc |
ddf6fe37 | 24648 | @item -malloc-cc |
d77de738 ML |
24649 | |
24650 | Dynamically allocate condition code registers. | |
24651 | ||
d77de738 | 24652 | @opindex mfixed-cc |
ddf6fe37 | 24653 | @item -mfixed-cc |
d77de738 ML |
24654 | |
24655 | Do not try to dynamically allocate condition code registers, only | |
24656 | use @code{icc0} and @code{fcc0}. | |
24657 | ||
d77de738 | 24658 | @opindex mdword |
ddf6fe37 | 24659 | @item -mdword |
d77de738 ML |
24660 | |
24661 | Change ABI to use double word insns. | |
24662 | ||
d77de738 ML |
24663 | @opindex mno-dword |
24664 | @opindex mdword | |
ddf6fe37 | 24665 | @item -mno-dword |
d77de738 ML |
24666 | |
24667 | Do not use double word instructions. | |
24668 | ||
d77de738 | 24669 | @opindex mdouble |
ddf6fe37 | 24670 | @item -mdouble |
d77de738 ML |
24671 | |
24672 | Use floating-point double instructions. | |
24673 | ||
d77de738 | 24674 | @opindex mno-double |
ddf6fe37 | 24675 | @item -mno-double |
d77de738 ML |
24676 | |
24677 | Do not use floating-point double instructions. | |
24678 | ||
d77de738 | 24679 | @opindex mmedia |
ddf6fe37 | 24680 | @item -mmedia |
d77de738 ML |
24681 | |
24682 | Use media instructions. | |
24683 | ||
d77de738 | 24684 | @opindex mno-media |
ddf6fe37 | 24685 | @item -mno-media |
d77de738 ML |
24686 | |
24687 | Do not use media instructions. | |
24688 | ||
d77de738 | 24689 | @opindex mmuladd |
ddf6fe37 | 24690 | @item -mmuladd |
d77de738 ML |
24691 | |
24692 | Use multiply and add/subtract instructions. | |
24693 | ||
d77de738 | 24694 | @opindex mno-muladd |
ddf6fe37 | 24695 | @item -mno-muladd |
d77de738 ML |
24696 | |
24697 | Do not use multiply and add/subtract instructions. | |
24698 | ||
d77de738 | 24699 | @opindex mfdpic |
ddf6fe37 | 24700 | @item -mfdpic |
d77de738 ML |
24701 | |
24702 | Select the FDPIC ABI, which uses function descriptors to represent | |
24703 | pointers to functions. Without any PIC/PIE-related options, it | |
24704 | implies @option{-fPIE}. With @option{-fpic} or @option{-fpie}, it | |
24705 | assumes GOT entries and small data are within a 12-bit range from the | |
24706 | GOT base address; with @option{-fPIC} or @option{-fPIE}, GOT offsets | |
24707 | are computed with 32 bits. | |
24708 | With a @samp{bfin-elf} target, this option implies @option{-msim}. | |
24709 | ||
d77de738 | 24710 | @opindex minline-plt |
ddf6fe37 | 24711 | @item -minline-plt |
d77de738 ML |
24712 | |
24713 | Enable inlining of PLT entries in function calls to functions that are | |
24714 | not known to bind locally. It has no effect without @option{-mfdpic}. | |
24715 | It's enabled by default if optimizing for speed and compiling for | |
24716 | shared libraries (i.e., @option{-fPIC} or @option{-fpic}), or when an | |
24717 | optimization option such as @option{-O3} or above is present in the | |
24718 | command line. | |
24719 | ||
d77de738 | 24720 | @opindex mTLS |
ddf6fe37 | 24721 | @item -mTLS |
d77de738 ML |
24722 | |
24723 | Assume a large TLS segment when generating thread-local code. | |
24724 | ||
d77de738 | 24725 | @opindex mtls |
ddf6fe37 | 24726 | @item -mtls |
d77de738 ML |
24727 | |
24728 | Do not assume a large TLS segment when generating thread-local code. | |
24729 | ||
d77de738 | 24730 | @opindex mgprel-ro |
ddf6fe37 | 24731 | @item -mgprel-ro |
d77de738 ML |
24732 | |
24733 | Enable the use of @code{GPREL} relocations in the FDPIC ABI for data | |
24734 | that is known to be in read-only sections. It's enabled by default, | |
24735 | except for @option{-fpic} or @option{-fpie}: even though it may help | |
24736 | make the global offset table smaller, it trades 1 instruction for 4. | |
24737 | With @option{-fPIC} or @option{-fPIE}, it trades 3 instructions for 4, | |
24738 | one of which may be shared by multiple symbols, and it avoids the need | |
24739 | for a GOT entry for the referenced symbol, so it's more likely to be a | |
24740 | win. If it is not, @option{-mno-gprel-ro} can be used to disable it. | |
24741 | ||
d77de738 | 24742 | @opindex multilib-library-pic |
ddf6fe37 | 24743 | @item -multilib-library-pic |
d77de738 ML |
24744 | |
24745 | Link with the (library, not FD) pic libraries. It's implied by | |
24746 | @option{-mlibrary-pic}, as well as by @option{-fPIC} and | |
24747 | @option{-fpic} without @option{-mfdpic}. You should never have to use | |
24748 | it explicitly. | |
24749 | ||
d77de738 | 24750 | @opindex mlinked-fp |
ddf6fe37 | 24751 | @item -mlinked-fp |
d77de738 ML |
24752 | |
24753 | Follow the EABI requirement of always creating a frame pointer whenever | |
24754 | a stack frame is allocated. This option is enabled by default and can | |
24755 | be disabled with @option{-mno-linked-fp}. | |
24756 | ||
d77de738 | 24757 | @opindex mlong-calls |
ddf6fe37 | 24758 | @item -mlong-calls |
d77de738 ML |
24759 | |
24760 | Use indirect addressing to call functions outside the current | |
24761 | compilation unit. This allows the functions to be placed anywhere | |
24762 | within the 32-bit address space. | |
24763 | ||
d77de738 | 24764 | @opindex malign-labels |
ddf6fe37 | 24765 | @item -malign-labels |
d77de738 ML |
24766 | |
24767 | Try to align labels to an 8-byte boundary by inserting NOPs into the | |
24768 | previous packet. This option only has an effect when VLIW packing | |
24769 | is enabled. It doesn't create new packets; it merely adds NOPs to | |
24770 | existing ones. | |
24771 | ||
d77de738 | 24772 | @opindex mlibrary-pic |
ddf6fe37 | 24773 | @item -mlibrary-pic |
d77de738 ML |
24774 | |
24775 | Generate position-independent EABI code. | |
24776 | ||
d77de738 | 24777 | @opindex macc-4 |
ddf6fe37 | 24778 | @item -macc-4 |
d77de738 ML |
24779 | |
24780 | Use only the first four media accumulator registers. | |
24781 | ||
d77de738 | 24782 | @opindex macc-8 |
ddf6fe37 | 24783 | @item -macc-8 |
d77de738 ML |
24784 | |
24785 | Use all eight media accumulator registers. | |
24786 | ||
d77de738 | 24787 | @opindex mpack |
ddf6fe37 | 24788 | @item -mpack |
d77de738 ML |
24789 | |
24790 | Pack VLIW instructions. | |
24791 | ||
d77de738 | 24792 | @opindex mno-pack |
ddf6fe37 | 24793 | @item -mno-pack |
d77de738 ML |
24794 | |
24795 | Do not pack VLIW instructions. | |
24796 | ||
d77de738 | 24797 | @opindex mno-eflags |
ddf6fe37 | 24798 | @item -mno-eflags |
d77de738 ML |
24799 | |
24800 | Do not mark ABI switches in e_flags. | |
24801 | ||
d77de738 | 24802 | @opindex mcond-move |
ddf6fe37 | 24803 | @item -mcond-move |
d77de738 ML |
24804 | |
24805 | Enable the use of conditional-move instructions (default). | |
24806 | ||
24807 | This switch is mainly for debugging the compiler and will likely be removed | |
24808 | in a future version. | |
24809 | ||
d77de738 | 24810 | @opindex mno-cond-move |
ddf6fe37 | 24811 | @item -mno-cond-move |
d77de738 ML |
24812 | |
24813 | Disable the use of conditional-move instructions. | |
24814 | ||
24815 | This switch is mainly for debugging the compiler and will likely be removed | |
24816 | in a future version. | |
24817 | ||
d77de738 | 24818 | @opindex mscc |
ddf6fe37 | 24819 | @item -mscc |
d77de738 ML |
24820 | |
24821 | Enable the use of conditional set instructions (default). | |
24822 | ||
24823 | This switch is mainly for debugging the compiler and will likely be removed | |
24824 | in a future version. | |
24825 | ||
d77de738 | 24826 | @opindex mno-scc |
ddf6fe37 | 24827 | @item -mno-scc |
d77de738 ML |
24828 | |
24829 | Disable the use of conditional set instructions. | |
24830 | ||
24831 | This switch is mainly for debugging the compiler and will likely be removed | |
24832 | in a future version. | |
24833 | ||
d77de738 | 24834 | @opindex mcond-exec |
ddf6fe37 | 24835 | @item -mcond-exec |
d77de738 ML |
24836 | |
24837 | Enable the use of conditional execution (default). | |
24838 | ||
24839 | This switch is mainly for debugging the compiler and will likely be removed | |
24840 | in a future version. | |
24841 | ||
d77de738 | 24842 | @opindex mno-cond-exec |
ddf6fe37 | 24843 | @item -mno-cond-exec |
d77de738 ML |
24844 | |
24845 | Disable the use of conditional execution. | |
24846 | ||
24847 | This switch is mainly for debugging the compiler and will likely be removed | |
24848 | in a future version. | |
24849 | ||
d77de738 | 24850 | @opindex mvliw-branch |
ddf6fe37 | 24851 | @item -mvliw-branch |
d77de738 ML |
24852 | |
24853 | Run a pass to pack branches into VLIW instructions (default). | |
24854 | ||
24855 | This switch is mainly for debugging the compiler and will likely be removed | |
24856 | in a future version. | |
24857 | ||
d77de738 | 24858 | @opindex mno-vliw-branch |
ddf6fe37 | 24859 | @item -mno-vliw-branch |
d77de738 ML |
24860 | |
24861 | Do not run a pass to pack branches into VLIW instructions. | |
24862 | ||
24863 | This switch is mainly for debugging the compiler and will likely be removed | |
24864 | in a future version. | |
24865 | ||
d77de738 | 24866 | @opindex mmulti-cond-exec |
ddf6fe37 | 24867 | @item -mmulti-cond-exec |
d77de738 ML |
24868 | |
24869 | Enable optimization of @code{&&} and @code{||} in conditional execution | |
24870 | (default). | |
24871 | ||
24872 | This switch is mainly for debugging the compiler and will likely be removed | |
24873 | in a future version. | |
24874 | ||
d77de738 | 24875 | @opindex mno-multi-cond-exec |
ddf6fe37 | 24876 | @item -mno-multi-cond-exec |
d77de738 ML |
24877 | |
24878 | Disable optimization of @code{&&} and @code{||} in conditional execution. | |
24879 | ||
24880 | This switch is mainly for debugging the compiler and will likely be removed | |
24881 | in a future version. | |
24882 | ||
d77de738 | 24883 | @opindex mnested-cond-exec |
ddf6fe37 | 24884 | @item -mnested-cond-exec |
d77de738 ML |
24885 | |
24886 | Enable nested conditional execution optimizations (default). | |
24887 | ||
24888 | This switch is mainly for debugging the compiler and will likely be removed | |
24889 | in a future version. | |
24890 | ||
d77de738 | 24891 | @opindex mno-nested-cond-exec |
ddf6fe37 | 24892 | @item -mno-nested-cond-exec |
d77de738 ML |
24893 | |
24894 | Disable nested conditional execution optimizations. | |
24895 | ||
24896 | This switch is mainly for debugging the compiler and will likely be removed | |
24897 | in a future version. | |
24898 | ||
d77de738 | 24899 | @opindex moptimize-membar |
ddf6fe37 | 24900 | @item -moptimize-membar |
d77de738 ML |
24901 | |
24902 | This switch removes redundant @code{membar} instructions from the | |
24903 | compiler-generated code. It is enabled by default. | |
24904 | ||
d77de738 ML |
24905 | @opindex mno-optimize-membar |
24906 | @opindex moptimize-membar | |
ddf6fe37 | 24907 | @item -mno-optimize-membar |
d77de738 ML |
24908 | |
24909 | This switch disables the automatic removal of redundant @code{membar} | |
24910 | instructions from the generated code. | |
24911 | ||
d77de738 | 24912 | @opindex mtomcat-stats |
ddf6fe37 | 24913 | @item -mtomcat-stats |
d77de738 ML |
24914 | |
24915 | Cause gas to print out tomcat statistics. | |
24916 | ||
d77de738 | 24917 | @opindex mcpu |
ddf6fe37 | 24918 | @item -mcpu=@var{cpu} |
d77de738 ML |
24919 | |
24920 | Select the processor type for which to generate code. Possible values are | |
24921 | @samp{frv}, @samp{fr550}, @samp{tomcat}, @samp{fr500}, @samp{fr450}, | |
24922 | @samp{fr405}, @samp{fr400}, @samp{fr300} and @samp{simple}. | |
24923 | ||
24924 | @end table | |
24925 | ||
24926 | @node GNU/Linux Options | |
24927 | @subsection GNU/Linux Options | |
24928 | ||
24929 | These @samp{-m} options are defined for GNU/Linux targets: | |
24930 | ||
24931 | @table @gcctabopt | |
d77de738 | 24932 | @opindex mglibc |
ddf6fe37 | 24933 | @item -mglibc |
d77de738 ML |
24934 | Use the GNU C library. This is the default except |
24935 | on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and | |
24936 | @samp{*-*-linux-*android*} targets. | |
24937 | ||
d77de738 | 24938 | @opindex muclibc |
ddf6fe37 | 24939 | @item -muclibc |
d77de738 ML |
24940 | Use uClibc C library. This is the default on |
24941 | @samp{*-*-linux-*uclibc*} targets. | |
24942 | ||
d77de738 | 24943 | @opindex mmusl |
ddf6fe37 | 24944 | @item -mmusl |
d77de738 ML |
24945 | Use the musl C library. This is the default on |
24946 | @samp{*-*-linux-*musl*} targets. | |
24947 | ||
d77de738 | 24948 | @opindex mbionic |
ddf6fe37 | 24949 | @item -mbionic |
d77de738 ML |
24950 | Use Bionic C library. This is the default on |
24951 | @samp{*-*-linux-*android*} targets. | |
24952 | ||
d77de738 | 24953 | @opindex mandroid |
ddf6fe37 | 24954 | @item -mandroid |
d77de738 ML |
24955 | Compile code compatible with Android platform. This is the default on |
24956 | @samp{*-*-linux-*android*} targets. | |
24957 | ||
24958 | When compiling, this option enables @option{-mbionic}, @option{-fPIC}, | |
24959 | @option{-fno-exceptions} and @option{-fno-rtti} by default. When linking, | |
24960 | this option makes the GCC driver pass Android-specific options to the linker. | |
24961 | Finally, this option causes the preprocessor macro @code{__ANDROID__} | |
24962 | to be defined. | |
24963 | ||
d77de738 | 24964 | @opindex tno-android-cc |
ddf6fe37 | 24965 | @item -tno-android-cc |
d77de738 ML |
24966 | Disable compilation effects of @option{-mandroid}, i.e., do not enable |
24967 | @option{-mbionic}, @option{-fPIC}, @option{-fno-exceptions} and | |
24968 | @option{-fno-rtti} by default. | |
24969 | ||
d77de738 | 24970 | @opindex tno-android-ld |
ddf6fe37 | 24971 | @item -tno-android-ld |
d77de738 ML |
24972 | Disable linking effects of @option{-mandroid}, i.e., pass standard Linux |
24973 | linking options to the linker. | |
24974 | ||
24975 | @end table | |
24976 | ||
24977 | @node H8/300 Options | |
24978 | @subsection H8/300 Options | |
24979 | ||
24980 | These @samp{-m} options are defined for the H8/300 implementations: | |
24981 | ||
24982 | @table @gcctabopt | |
d77de738 | 24983 | @opindex mrelax |
ddf6fe37 | 24984 | @item -mrelax |
d77de738 ML |
24985 | Shorten some address references at link time, when possible; uses the |
24986 | linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300, | |
24987 | ld, Using ld}, for a fuller description. | |
24988 | ||
d77de738 | 24989 | @opindex mh |
ddf6fe37 | 24990 | @item -mh |
d77de738 ML |
24991 | Generate code for the H8/300H@. |
24992 | ||
d77de738 | 24993 | @opindex ms |
ddf6fe37 | 24994 | @item -ms |
d77de738 ML |
24995 | Generate code for the H8S@. |
24996 | ||
d77de738 | 24997 | @opindex mn |
ddf6fe37 | 24998 | @item -mn |
d77de738 ML |
24999 | Generate code for the H8S and H8/300H in the normal mode. This switch |
25000 | must be used either with @option{-mh} or @option{-ms}. | |
25001 | ||
d77de738 | 25002 | @opindex ms2600 |
ddf6fe37 | 25003 | @item -ms2600 |
d77de738 ML |
25004 | Generate code for the H8S/2600. This switch must be used with @option{-ms}. |
25005 | ||
d77de738 | 25006 | @opindex mexr |
ddf6fe37 | 25007 | @item -mexr |
d77de738 ML |
25008 | Extended registers are stored on stack before execution of function |
25009 | with monitor attribute. Default option is @option{-mexr}. | |
25010 | This option is valid only for H8S targets. | |
25011 | ||
d77de738 ML |
25012 | @opindex mno-exr |
25013 | @opindex mexr | |
ddf6fe37 | 25014 | @item -mno-exr |
d77de738 ML |
25015 | Extended registers are not stored on stack before execution of function |
25016 | with monitor attribute. Default option is @option{-mno-exr}. | |
25017 | This option is valid only for H8S targets. | |
25018 | ||
d77de738 | 25019 | @opindex mint32 |
ddf6fe37 | 25020 | @item -mint32 |
d77de738 ML |
25021 | Make @code{int} data 32 bits by default. |
25022 | ||
d77de738 | 25023 | @opindex malign-300 |
ddf6fe37 | 25024 | @item -malign-300 |
d77de738 ML |
25025 | On the H8/300H and H8S, use the same alignment rules as for the H8/300. |
25026 | The default for the H8/300H and H8S is to align longs and floats on | |
25027 | 4-byte boundaries. | |
25028 | @option{-malign-300} causes them to be aligned on 2-byte boundaries. | |
25029 | This option has no effect on the H8/300. | |
25030 | @end table | |
25031 | ||
25032 | @node HPPA Options | |
25033 | @subsection HPPA Options | |
25034 | @cindex HPPA Options | |
25035 | ||
25036 | These @samp{-m} options are defined for the HPPA family of computers: | |
25037 | ||
25038 | @table @gcctabopt | |
d77de738 | 25039 | @opindex march |
ddf6fe37 | 25040 | @item -march=@var{architecture-type} |
d77de738 ML |
25041 | Generate code for the specified architecture. The choices for |
25042 | @var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA | |
25043 | 1.1, and @samp{2.0} for PA 2.0 processors. Refer to | |
25044 | @file{/usr/lib/sched.models} on an HP-UX system to determine the proper | |
25045 | architecture option for your machine. Code compiled for lower numbered | |
25046 | architectures runs on higher numbered architectures, but not the | |
25047 | other way around. | |
25048 | ||
d77de738 ML |
25049 | @opindex mpa-risc-1-0 |
25050 | @opindex mpa-risc-1-1 | |
25051 | @opindex mpa-risc-2-0 | |
ddf6fe37 AA |
25052 | @item -mpa-risc-1-0 |
25053 | @itemx -mpa-risc-1-1 | |
25054 | @itemx -mpa-risc-2-0 | |
d77de738 ML |
25055 | Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively. |
25056 | ||
cf467fb9 JDA |
25057 | @opindex matomic-libcalls |
25058 | @opindex mno-atomic-libcalls | |
ddf6fe37 | 25059 | @item -matomic-libcalls |
cf467fb9 JDA |
25060 | Generate libcalls for atomic loads and stores when sync libcalls are disabled. |
25061 | This option is enabled by default. It only affects the generation of | |
25062 | atomic libcalls by the HPPA backend. | |
25063 | ||
25064 | Both the sync and @file{libatomic} libcall implementations use locking. | |
25065 | As a result, processor stores are not atomic with respect to other | |
25066 | atomic operations. Processor loads up to DImode are atomic with | |
25067 | respect to other atomic operations provided they are implemented as | |
25068 | a single access. | |
25069 | ||
25070 | The PA-RISC architecture does not support any atomic operations in | |
25071 | hardware except for the @code{ldcw} instruction. Thus, all atomic | |
25072 | support is implemented using sync and atomic libcalls. Sync libcall | |
25073 | support is in @file{libgcc.a}. Atomic libcall support is in | |
25074 | @file{libatomic}. | |
25075 | ||
25076 | This option generates @code{__atomic_exchange} calls for atomic stores. | |
25077 | It also provides special handling for atomic DImode accesses on 32-bit | |
25078 | targets. | |
25079 | ||
cf467fb9 | 25080 | @opindex mbig-switch |
ddf6fe37 | 25081 | @item -mbig-switch |
cf467fb9 JDA |
25082 | Does nothing. Preserved for backward compatibility. |
25083 | ||
d77de738 | 25084 | @opindex mcaller-copies |
ddf6fe37 | 25085 | @item -mcaller-copies |
d77de738 ML |
25086 | The caller copies function arguments passed by hidden reference. This |
25087 | option should be used with care as it is not compatible with the default | |
25088 | 32-bit runtime. However, only aggregates larger than eight bytes are | |
25089 | passed by hidden reference and the option provides better compatibility | |
25090 | with OpenMP. | |
25091 | ||
cf467fb9 | 25092 | @opindex mcoherent-ldcw |
ddf6fe37 | 25093 | @item -mcoherent-ldcw |
cf467fb9 | 25094 | Use ldcw/ldcd coherent cache-control hint. |
d77de738 | 25095 | |
d77de738 | 25096 | @opindex mdisable-fpregs |
ddf6fe37 | 25097 | @item -mdisable-fpregs |
cf467fb9 | 25098 | Disable floating-point registers. Equivalent to @code{-msoft-float}. |
d77de738 | 25099 | |
d77de738 | 25100 | @opindex mdisable-indexing |
ddf6fe37 | 25101 | @item -mdisable-indexing |
d77de738 ML |
25102 | Prevent the compiler from using indexing address modes. This avoids some |
25103 | rather obscure problems when compiling MIG generated code under MACH@. | |
25104 | ||
d77de738 | 25105 | @opindex mfast-indirect-calls |
ddf6fe37 | 25106 | @item -mfast-indirect-calls |
d77de738 ML |
25107 | Generate code that assumes calls never cross space boundaries. This |
25108 | allows GCC to emit code that performs faster indirect calls. | |
25109 | ||
25110 | This option does not work in the presence of shared libraries or nested | |
25111 | functions. | |
25112 | ||
d77de738 | 25113 | @opindex mfixed-range |
ddf6fe37 | 25114 | @item -mfixed-range=@var{register-range} |
d77de738 ML |
25115 | Generate code treating the given register range as fixed registers. |
25116 | A fixed register is one that the register allocator cannot use. This is | |
25117 | useful when compiling kernel code. A register range is specified as | |
25118 | two registers separated by a dash. Multiple register ranges can be | |
25119 | specified separated by a comma. | |
25120 | ||
d77de738 | 25121 | @opindex mgas |
ddf6fe37 | 25122 | @item -mgas |
d77de738 ML |
25123 | Enable the use of assembler directives only GAS understands. |
25124 | ||
d77de738 | 25125 | @opindex mgnu-ld |
ddf6fe37 | 25126 | @item -mgnu-ld |
d77de738 ML |
25127 | Use options specific to GNU @command{ld}. |
25128 | This passes @option{-shared} to @command{ld} when | |
25129 | building a shared library. It is the default when GCC is configured, | |
25130 | explicitly or implicitly, with the GNU linker. This option does not | |
25131 | affect which @command{ld} is called; it only changes what parameters | |
25132 | are passed to that @command{ld}. | |
25133 | The @command{ld} that is called is determined by the | |
25134 | @option{--with-ld} configure option, GCC's program search path, and | |
25135 | finally by the user's @env{PATH}. The linker used by GCC can be printed | |
25136 | using @samp{which `gcc -print-prog-name=ld`}. This option is only available | |
25137 | on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}. | |
25138 | ||
d77de738 | 25139 | @opindex mhp-ld |
ddf6fe37 | 25140 | @item -mhp-ld |
d77de738 ML |
25141 | Use options specific to HP @command{ld}. |
25142 | This passes @option{-b} to @command{ld} when building | |
25143 | a shared library and passes @option{+Accept TypeMismatch} to @command{ld} on all | |
25144 | links. It is the default when GCC is configured, explicitly or | |
25145 | implicitly, with the HP linker. This option does not affect | |
25146 | which @command{ld} is called; it only changes what parameters are passed to that | |
25147 | @command{ld}. | |
25148 | The @command{ld} that is called is determined by the @option{--with-ld} | |
25149 | configure option, GCC's program search path, and finally by the user's | |
25150 | @env{PATH}. The linker used by GCC can be printed using @samp{which | |
25151 | `gcc -print-prog-name=ld`}. This option is only available on the 64-bit | |
25152 | HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}. | |
25153 | ||
cf467fb9 | 25154 | @opindex mlinker-opt |
ddf6fe37 | 25155 | @item -mlinker-opt |
cf467fb9 JDA |
25156 | Enable the optimization pass in the HP-UX linker. Note this makes symbolic |
25157 | debugging impossible. It also triggers a bug in the HP-UX 8 and HP-UX 9 | |
25158 | linkers in which they give bogus error messages when linking some programs. | |
25159 | ||
d77de738 ML |
25160 | @opindex mno-long-calls |
25161 | @opindex mlong-calls | |
ddf6fe37 | 25162 | @item -mlong-calls |
d77de738 ML |
25163 | Generate code that uses long call sequences. This ensures that a call |
25164 | is always able to reach linker generated stubs. The default is to generate | |
25165 | long calls only when the distance from the call site to the beginning | |
25166 | of the function or translation unit, as the case may be, exceeds a | |
25167 | predefined limit set by the branch type being used. The limits for | |
25168 | normal calls are 7,600,000 and 240,000 bytes, respectively for the | |
25169 | PA 2.0 and PA 1.X architectures. Sibcalls are always limited at | |
25170 | 240,000 bytes. | |
25171 | ||
25172 | Distances are measured from the beginning of functions when using the | |
25173 | @option{-ffunction-sections} option, or when using the @option{-mgas} | |
25174 | and @option{-mno-portable-runtime} options together under HP-UX with | |
25175 | the SOM linker. | |
25176 | ||
25177 | It is normally not desirable to use this option as it degrades | |
25178 | performance. However, it may be useful in large applications, | |
25179 | particularly when partial linking is used to build the application. | |
25180 | ||
25181 | The types of long calls used depends on the capabilities of the | |
25182 | assembler and linker, and the type of code being generated. The | |
25183 | impact on systems that support long absolute calls, and long pic | |
25184 | symbol-difference or pc-relative calls should be relatively small. | |
25185 | However, an indirect call is used on 32-bit ELF systems in pic code | |
25186 | and it is quite long. | |
25187 | ||
cf467fb9 | 25188 | @opindex mlong-load-store |
ddf6fe37 | 25189 | @item -mlong-load-store |
cf467fb9 JDA |
25190 | Generate 3-instruction load and store sequences as sometimes required by |
25191 | the HP-UX 10 linker. This is equivalent to the @samp{+k} option to | |
25192 | the HP compilers. | |
25193 | ||
cf467fb9 | 25194 | @opindex mjump-in-delay |
ddf6fe37 | 25195 | @item -mjump-in-delay |
cf467fb9 JDA |
25196 | This option is ignored and provided for compatibility purposes only. |
25197 | ||
cf467fb9 JDA |
25198 | @opindex mno-space-regs |
25199 | @opindex mspace-regs | |
ddf6fe37 | 25200 | @item -mno-space-regs |
cf467fb9 JDA |
25201 | Generate code that assumes the target has no space registers. This allows |
25202 | GCC to generate faster indirect calls and use unscaled index address modes. | |
25203 | ||
25204 | Such code is suitable for level 0 PA systems and kernels. | |
25205 | ||
cf467fb9 | 25206 | @opindex mordered |
ddf6fe37 | 25207 | @item -mordered |
cf467fb9 JDA |
25208 | Assume memory references are ordered and barriers are not needed. |
25209 | ||
cf467fb9 | 25210 | @opindex mportable-runtime |
ddf6fe37 | 25211 | @item -mportable-runtime |
cf467fb9 JDA |
25212 | Use the portable calling conventions proposed by HP for ELF systems. |
25213 | ||
cf467fb9 | 25214 | @opindex mschedule |
ddf6fe37 | 25215 | @item -mschedule=@var{cpu-type} |
cf467fb9 JDA |
25216 | Schedule code according to the constraints for the machine type |
25217 | @var{cpu-type}. The choices for @var{cpu-type} are @samp{700} | |
25218 | @samp{7100}, @samp{7100LC}, @samp{7200}, @samp{7300} and @samp{8000}. Refer | |
25219 | to @file{/usr/lib/sched.models} on an HP-UX system to determine the | |
25220 | proper scheduling option for your machine. The default scheduling is | |
25221 | @samp{8000}. | |
25222 | ||
cf467fb9 | 25223 | @opindex msio |
ddf6fe37 | 25224 | @item -msio |
cf467fb9 JDA |
25225 | Generate the predefine, @code{_SIO}, for server IO@. The default is |
25226 | @option{-mwsio}. This generates the predefines, @code{__hp9000s700}, | |
25227 | @code{__hp9000s700__} and @code{_WSIO}, for workstation IO@. These | |
25228 | options are available under HP-UX and HI-UX@. | |
25229 | ||
cf467fb9 | 25230 | @opindex msoft-float |
ddf6fe37 | 25231 | @item -msoft-float |
cf467fb9 JDA |
25232 | Generate output containing library calls for floating point. |
25233 | @strong{Warning:} the requisite libraries are not available for all HPPA | |
25234 | targets. Normally the facilities of the machine's usual C compiler are | |
25235 | used, but this cannot be done directly in cross-compilation. You must make | |
25236 | your own arrangements to provide suitable library functions for | |
25237 | cross-compilation. | |
25238 | ||
25239 | @option{-msoft-float} changes the calling convention in the output file; | |
25240 | therefore, it is only useful if you compile @emph{all} of a program with | |
25241 | this option. In particular, you need to compile @file{libgcc.a}, the | |
25242 | library that comes with GCC, with @option{-msoft-float} in order for | |
25243 | this to work. | |
25244 | ||
cf467fb9 | 25245 | @opindex msoft-mult |
ddf6fe37 | 25246 | @item -msoft-mult |
cf467fb9 JDA |
25247 | Use software integer multiplication. |
25248 | ||
25249 | This disables the use of the @code{xmpyu} instruction. | |
25250 | ||
d77de738 | 25251 | @opindex march |
ddf6fe37 | 25252 | @item -munix=@var{unix-std} |
d77de738 ML |
25253 | Generate compiler predefines and select a startfile for the specified |
25254 | UNIX standard. The choices for @var{unix-std} are @samp{93}, @samp{95} | |
25255 | and @samp{98}. @samp{93} is supported on all HP-UX versions. @samp{95} | |
25256 | is available on HP-UX 10.10 and later. @samp{98} is available on HP-UX | |
25257 | 11.11 and later. The default values are @samp{93} for HP-UX 10.00, | |
25258 | @samp{95} for HP-UX 10.10 though to 11.00, and @samp{98} for HP-UX 11.11 | |
25259 | and later. | |
25260 | ||
25261 | @option{-munix=93} provides the same predefines as GCC 3.3 and 3.4. | |
25262 | @option{-munix=95} provides additional predefines for @code{XOPEN_UNIX} | |
25263 | and @code{_XOPEN_SOURCE_EXTENDED}, and the startfile @file{unix95.o}. | |
25264 | @option{-munix=98} provides additional predefines for @code{_XOPEN_UNIX}, | |
25265 | @code{_XOPEN_SOURCE_EXTENDED}, @code{_INCLUDE__STDC_A1_SOURCE} and | |
25266 | @code{_INCLUDE_XOPEN_SOURCE_500}, and the startfile @file{unix98.o}. | |
25267 | ||
25268 | It is @emph{important} to note that this option changes the interfaces | |
25269 | for various library routines. It also affects the operational behavior | |
25270 | of the C library. Thus, @emph{extreme} care is needed in using this | |
25271 | option. | |
25272 | ||
25273 | Library code that is intended to operate with more than one UNIX | |
25274 | standard must test, set and restore the variable @code{__xpg4_extended_mask} | |
25275 | as appropriate. Most GNU software doesn't provide this capability. | |
25276 | ||
d77de738 | 25277 | @opindex nolibdld |
ddf6fe37 | 25278 | @item -nolibdld |
d77de738 ML |
25279 | Suppress the generation of link options to search libdld.sl when the |
25280 | @option{-static} option is specified on HP-UX 10 and later. | |
25281 | ||
d77de738 | 25282 | @opindex static |
ddf6fe37 | 25283 | @item -static |
d77de738 ML |
25284 | The HP-UX implementation of setlocale in libc has a dependency on |
25285 | libdld.sl. There isn't an archive version of libdld.sl. Thus, | |
25286 | when the @option{-static} option is specified, special link options | |
25287 | are needed to resolve this dependency. | |
25288 | ||
25289 | On HP-UX 10 and later, the GCC driver adds the necessary options to | |
25290 | link with libdld.sl when the @option{-static} option is specified. | |
25291 | This causes the resulting binary to be dynamic. On the 64-bit port, | |
25292 | the linkers generate dynamic binaries by default in any case. The | |
25293 | @option{-nolibdld} option can be used to prevent the GCC driver from | |
25294 | adding these link options. | |
25295 | ||
d77de738 | 25296 | @opindex threads |
ddf6fe37 | 25297 | @item -threads |
d77de738 ML |
25298 | Add support for multithreading with the @dfn{dce thread} library |
25299 | under HP-UX@. This option sets flags for both the preprocessor and | |
25300 | linker. | |
25301 | @end table | |
25302 | ||
25303 | @node IA-64 Options | |
25304 | @subsection IA-64 Options | |
25305 | @cindex IA-64 Options | |
25306 | ||
25307 | These are the @samp{-m} options defined for the Intel IA-64 architecture. | |
25308 | ||
25309 | @table @gcctabopt | |
d77de738 | 25310 | @opindex mbig-endian |
ddf6fe37 | 25311 | @item -mbig-endian |
d77de738 ML |
25312 | Generate code for a big-endian target. This is the default for HP-UX@. |
25313 | ||
d77de738 | 25314 | @opindex mlittle-endian |
ddf6fe37 | 25315 | @item -mlittle-endian |
d77de738 ML |
25316 | Generate code for a little-endian target. This is the default for AIX5 |
25317 | and GNU/Linux. | |
25318 | ||
d77de738 ML |
25319 | @opindex mgnu-as |
25320 | @opindex mno-gnu-as | |
ddf6fe37 AA |
25321 | @item -mgnu-as |
25322 | @itemx -mno-gnu-as | |
d77de738 ML |
25323 | Generate (or don't) code for the GNU assembler. This is the default. |
25324 | @c Also, this is the default if the configure option @option{--with-gnu-as} | |
25325 | @c is used. | |
25326 | ||
d77de738 ML |
25327 | @opindex mgnu-ld |
25328 | @opindex mno-gnu-ld | |
ddf6fe37 AA |
25329 | @item -mgnu-ld |
25330 | @itemx -mno-gnu-ld | |
d77de738 ML |
25331 | Generate (or don't) code for the GNU linker. This is the default. |
25332 | @c Also, this is the default if the configure option @option{--with-gnu-ld} | |
25333 | @c is used. | |
25334 | ||
d77de738 | 25335 | @opindex mno-pic |
ddf6fe37 | 25336 | @item -mno-pic |
d77de738 ML |
25337 | Generate code that does not use a global pointer register. The result |
25338 | is not position independent code, and violates the IA-64 ABI@. | |
25339 | ||
d77de738 ML |
25340 | @opindex mvolatile-asm-stop |
25341 | @opindex mno-volatile-asm-stop | |
ddf6fe37 AA |
25342 | @item -mvolatile-asm-stop |
25343 | @itemx -mno-volatile-asm-stop | |
d77de738 ML |
25344 | Generate (or don't) a stop bit immediately before and after volatile asm |
25345 | statements. | |
25346 | ||
d77de738 ML |
25347 | @opindex mregister-names |
25348 | @opindex mno-register-names | |
ddf6fe37 AA |
25349 | @item -mregister-names |
25350 | @itemx -mno-register-names | |
d77de738 ML |
25351 | Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for |
25352 | the stacked registers. This may make assembler output more readable. | |
25353 | ||
d77de738 ML |
25354 | @opindex mno-sdata |
25355 | @opindex msdata | |
ddf6fe37 AA |
25356 | @item -mno-sdata |
25357 | @itemx -msdata | |
d77de738 ML |
25358 | Disable (or enable) optimizations that use the small data section. This may |
25359 | be useful for working around optimizer bugs. | |
25360 | ||
d77de738 | 25361 | @opindex mconstant-gp |
ddf6fe37 | 25362 | @item -mconstant-gp |
d77de738 ML |
25363 | Generate code that uses a single constant global pointer value. This is |
25364 | useful when compiling kernel code. | |
25365 | ||
d77de738 | 25366 | @opindex mauto-pic |
ddf6fe37 | 25367 | @item -mauto-pic |
d77de738 ML |
25368 | Generate code that is self-relocatable. This implies @option{-mconstant-gp}. |
25369 | This is useful when compiling firmware code. | |
25370 | ||
d77de738 | 25371 | @opindex minline-float-divide-min-latency |
ddf6fe37 | 25372 | @item -minline-float-divide-min-latency |
d77de738 ML |
25373 | Generate code for inline divides of floating-point values |
25374 | using the minimum latency algorithm. | |
25375 | ||
d77de738 | 25376 | @opindex minline-float-divide-max-throughput |
ddf6fe37 | 25377 | @item -minline-float-divide-max-throughput |
d77de738 ML |
25378 | Generate code for inline divides of floating-point values |
25379 | using the maximum throughput algorithm. | |
25380 | ||
d77de738 | 25381 | @opindex mno-inline-float-divide |
ddf6fe37 | 25382 | @item -mno-inline-float-divide |
d77de738 ML |
25383 | Do not generate inline code for divides of floating-point values. |
25384 | ||
d77de738 | 25385 | @opindex minline-int-divide-min-latency |
ddf6fe37 | 25386 | @item -minline-int-divide-min-latency |
d77de738 ML |
25387 | Generate code for inline divides of integer values |
25388 | using the minimum latency algorithm. | |
25389 | ||
d77de738 | 25390 | @opindex minline-int-divide-max-throughput |
ddf6fe37 | 25391 | @item -minline-int-divide-max-throughput |
d77de738 ML |
25392 | Generate code for inline divides of integer values |
25393 | using the maximum throughput algorithm. | |
25394 | ||
d77de738 ML |
25395 | @opindex mno-inline-int-divide |
25396 | @opindex minline-int-divide | |
ddf6fe37 | 25397 | @item -mno-inline-int-divide |
d77de738 ML |
25398 | Do not generate inline code for divides of integer values. |
25399 | ||
d77de738 | 25400 | @opindex minline-sqrt-min-latency |
ddf6fe37 | 25401 | @item -minline-sqrt-min-latency |
d77de738 ML |
25402 | Generate code for inline square roots |
25403 | using the minimum latency algorithm. | |
25404 | ||
d77de738 | 25405 | @opindex minline-sqrt-max-throughput |
ddf6fe37 | 25406 | @item -minline-sqrt-max-throughput |
d77de738 ML |
25407 | Generate code for inline square roots |
25408 | using the maximum throughput algorithm. | |
25409 | ||
d77de738 | 25410 | @opindex mno-inline-sqrt |
ddf6fe37 | 25411 | @item -mno-inline-sqrt |
d77de738 ML |
25412 | Do not generate inline code for @code{sqrt}. |
25413 | ||
d77de738 ML |
25414 | @opindex mfused-madd |
25415 | @opindex mno-fused-madd | |
ddf6fe37 AA |
25416 | @item -mfused-madd |
25417 | @itemx -mno-fused-madd | |
d77de738 ML |
25418 | Do (don't) generate code that uses the fused multiply/add or multiply/subtract |
25419 | instructions. The default is to use these instructions. | |
25420 | ||
d77de738 ML |
25421 | @opindex mno-dwarf2-asm |
25422 | @opindex mdwarf2-asm | |
ddf6fe37 AA |
25423 | @item -mno-dwarf2-asm |
25424 | @itemx -mdwarf2-asm | |
d77de738 ML |
25425 | Don't (or do) generate assembler code for the DWARF line number debugging |
25426 | info. This may be useful when not using the GNU assembler. | |
25427 | ||
d77de738 ML |
25428 | @opindex mearly-stop-bits |
25429 | @opindex mno-early-stop-bits | |
ddf6fe37 AA |
25430 | @item -mearly-stop-bits |
25431 | @itemx -mno-early-stop-bits | |
d77de738 ML |
25432 | Allow stop bits to be placed earlier than immediately preceding the |
25433 | instruction that triggered the stop bit. This can improve instruction | |
25434 | scheduling, but does not always do so. | |
25435 | ||
d77de738 | 25436 | @opindex mfixed-range |
ddf6fe37 | 25437 | @item -mfixed-range=@var{register-range} |
d77de738 ML |
25438 | Generate code treating the given register range as fixed registers. |
25439 | A fixed register is one that the register allocator cannot use. This is | |
25440 | useful when compiling kernel code. A register range is specified as | |
25441 | two registers separated by a dash. Multiple register ranges can be | |
25442 | specified separated by a comma. | |
25443 | ||
d77de738 | 25444 | @opindex mtls-size |
ddf6fe37 | 25445 | @item -mtls-size=@var{tls-size} |
d77de738 ML |
25446 | Specify bit size of immediate TLS offsets. Valid values are 14, 22, and |
25447 | 64. | |
25448 | ||
d77de738 | 25449 | @opindex mtune |
ddf6fe37 | 25450 | @item -mtune=@var{cpu-type} |
d77de738 ML |
25451 | Tune the instruction scheduling for a particular CPU, Valid values are |
25452 | @samp{itanium}, @samp{itanium1}, @samp{merced}, @samp{itanium2}, | |
25453 | and @samp{mckinley}. | |
25454 | ||
d77de738 ML |
25455 | @opindex milp32 |
25456 | @opindex mlp64 | |
ddf6fe37 AA |
25457 | @item -milp32 |
25458 | @itemx -mlp64 | |
d77de738 ML |
25459 | Generate code for a 32-bit or 64-bit environment. |
25460 | The 32-bit environment sets int, long and pointer to 32 bits. | |
25461 | The 64-bit environment sets int to 32 bits and long and pointer | |
25462 | to 64 bits. These are HP-UX specific flags. | |
25463 | ||
d77de738 ML |
25464 | @opindex mno-sched-br-data-spec |
25465 | @opindex msched-br-data-spec | |
ddf6fe37 AA |
25466 | @item -mno-sched-br-data-spec |
25467 | @itemx -msched-br-data-spec | |
d77de738 ML |
25468 | (Dis/En)able data speculative scheduling before reload. |
25469 | This results in generation of @code{ld.a} instructions and | |
25470 | the corresponding check instructions (@code{ld.c} / @code{chk.a}). | |
25471 | The default setting is disabled. | |
25472 | ||
d77de738 ML |
25473 | @opindex msched-ar-data-spec |
25474 | @opindex mno-sched-ar-data-spec | |
ddf6fe37 AA |
25475 | @item -msched-ar-data-spec |
25476 | @itemx -mno-sched-ar-data-spec | |
d77de738 ML |
25477 | (En/Dis)able data speculative scheduling after reload. |
25478 | This results in generation of @code{ld.a} instructions and | |
25479 | the corresponding check instructions (@code{ld.c} / @code{chk.a}). | |
25480 | The default setting is enabled. | |
25481 | ||
d77de738 ML |
25482 | @opindex mno-sched-control-spec |
25483 | @opindex msched-control-spec | |
ddf6fe37 AA |
25484 | @item -mno-sched-control-spec |
25485 | @itemx -msched-control-spec | |
d77de738 ML |
25486 | (Dis/En)able control speculative scheduling. This feature is |
25487 | available only during region scheduling (i.e.@: before reload). | |
25488 | This results in generation of the @code{ld.s} instructions and | |
25489 | the corresponding check instructions @code{chk.s}. | |
25490 | The default setting is disabled. | |
25491 | ||
d77de738 ML |
25492 | @opindex msched-br-in-data-spec |
25493 | @opindex mno-sched-br-in-data-spec | |
ddf6fe37 AA |
25494 | @item -msched-br-in-data-spec |
25495 | @itemx -mno-sched-br-in-data-spec | |
d77de738 ML |
25496 | (En/Dis)able speculative scheduling of the instructions that |
25497 | are dependent on the data speculative loads before reload. | |
25498 | This is effective only with @option{-msched-br-data-spec} enabled. | |
25499 | The default setting is enabled. | |
25500 | ||
d77de738 ML |
25501 | @opindex msched-ar-in-data-spec |
25502 | @opindex mno-sched-ar-in-data-spec | |
ddf6fe37 AA |
25503 | @item -msched-ar-in-data-spec |
25504 | @itemx -mno-sched-ar-in-data-spec | |
d77de738 ML |
25505 | (En/Dis)able speculative scheduling of the instructions that |
25506 | are dependent on the data speculative loads after reload. | |
25507 | This is effective only with @option{-msched-ar-data-spec} enabled. | |
25508 | The default setting is enabled. | |
25509 | ||
d77de738 ML |
25510 | @opindex msched-in-control-spec |
25511 | @opindex mno-sched-in-control-spec | |
ddf6fe37 AA |
25512 | @item -msched-in-control-spec |
25513 | @itemx -mno-sched-in-control-spec | |
d77de738 ML |
25514 | (En/Dis)able speculative scheduling of the instructions that |
25515 | are dependent on the control speculative loads. | |
25516 | This is effective only with @option{-msched-control-spec} enabled. | |
25517 | The default setting is enabled. | |
25518 | ||
d77de738 ML |
25519 | @opindex mno-sched-prefer-non-data-spec-insns |
25520 | @opindex msched-prefer-non-data-spec-insns | |
ddf6fe37 AA |
25521 | @item -mno-sched-prefer-non-data-spec-insns |
25522 | @itemx -msched-prefer-non-data-spec-insns | |
d77de738 ML |
25523 | If enabled, data-speculative instructions are chosen for schedule |
25524 | only if there are no other choices at the moment. This makes | |
25525 | the use of the data speculation much more conservative. | |
25526 | The default setting is disabled. | |
25527 | ||
d77de738 ML |
25528 | @opindex mno-sched-prefer-non-control-spec-insns |
25529 | @opindex msched-prefer-non-control-spec-insns | |
ddf6fe37 AA |
25530 | @item -mno-sched-prefer-non-control-spec-insns |
25531 | @itemx -msched-prefer-non-control-spec-insns | |
d77de738 ML |
25532 | If enabled, control-speculative instructions are chosen for schedule |
25533 | only if there are no other choices at the moment. This makes | |
25534 | the use of the control speculation much more conservative. | |
25535 | The default setting is disabled. | |
25536 | ||
d77de738 ML |
25537 | @opindex mno-sched-count-spec-in-critical-path |
25538 | @opindex msched-count-spec-in-critical-path | |
ddf6fe37 AA |
25539 | @item -mno-sched-count-spec-in-critical-path |
25540 | @itemx -msched-count-spec-in-critical-path | |
d77de738 ML |
25541 | If enabled, speculative dependencies are considered during |
25542 | computation of the instructions priorities. This makes the use of the | |
25543 | speculation a bit more conservative. | |
25544 | The default setting is disabled. | |
25545 | ||
d77de738 | 25546 | @opindex msched-spec-ldc |
ddf6fe37 | 25547 | @item -msched-spec-ldc |
d77de738 ML |
25548 | Use a simple data speculation check. This option is on by default. |
25549 | ||
d77de738 | 25550 | @opindex msched-spec-ldc |
ddf6fe37 | 25551 | @item -msched-control-spec-ldc |
d77de738 ML |
25552 | Use a simple check for control speculation. This option is on by default. |
25553 | ||
d77de738 | 25554 | @opindex msched-stop-bits-after-every-cycle |
ddf6fe37 | 25555 | @item -msched-stop-bits-after-every-cycle |
d77de738 ML |
25556 | Place a stop bit after every cycle when scheduling. This option is on |
25557 | by default. | |
25558 | ||
d77de738 | 25559 | @opindex msched-fp-mem-deps-zero-cost |
ddf6fe37 | 25560 | @item -msched-fp-mem-deps-zero-cost |
d77de738 ML |
25561 | Assume that floating-point stores and loads are not likely to cause a conflict |
25562 | when placed into the same instruction group. This option is disabled by | |
25563 | default. | |
25564 | ||
d77de738 | 25565 | @opindex msel-sched-dont-check-control-spec |
ddf6fe37 | 25566 | @item -msel-sched-dont-check-control-spec |
d77de738 ML |
25567 | Generate checks for control speculation in selective scheduling. |
25568 | This flag is disabled by default. | |
25569 | ||
d77de738 | 25570 | @opindex msched-max-memory-insns |
ddf6fe37 | 25571 | @item -msched-max-memory-insns=@var{max-insns} |
d77de738 ML |
25572 | Limit on the number of memory insns per instruction group, giving lower |
25573 | priority to subsequent memory insns attempting to schedule in the same | |
25574 | instruction group. Frequently useful to prevent cache bank conflicts. | |
25575 | The default value is 1. | |
25576 | ||
d77de738 | 25577 | @opindex msched-max-memory-insns-hard-limit |
ddf6fe37 | 25578 | @item -msched-max-memory-insns-hard-limit |
d77de738 ML |
25579 | Makes the limit specified by @option{msched-max-memory-insns} a hard limit, |
25580 | disallowing more than that number in an instruction group. | |
25581 | Otherwise, the limit is ``soft'', meaning that non-memory operations | |
25582 | are preferred when the limit is reached, but memory operations may still | |
25583 | be scheduled. | |
25584 | ||
25585 | @end table | |
25586 | ||
25587 | @node LM32 Options | |
25588 | @subsection LM32 Options | |
25589 | @cindex LM32 options | |
25590 | ||
25591 | These @option{-m} options are defined for the LatticeMico32 architecture: | |
25592 | ||
25593 | @table @gcctabopt | |
d77de738 | 25594 | @opindex mbarrel-shift-enabled |
ddf6fe37 | 25595 | @item -mbarrel-shift-enabled |
d77de738 ML |
25596 | Enable barrel-shift instructions. |
25597 | ||
d77de738 | 25598 | @opindex mdivide-enabled |
ddf6fe37 | 25599 | @item -mdivide-enabled |
d77de738 ML |
25600 | Enable divide and modulus instructions. |
25601 | ||
d77de738 | 25602 | @opindex multiply-enabled |
ddf6fe37 | 25603 | @item -mmultiply-enabled |
d77de738 ML |
25604 | Enable multiply instructions. |
25605 | ||
d77de738 | 25606 | @opindex msign-extend-enabled |
ddf6fe37 | 25607 | @item -msign-extend-enabled |
d77de738 ML |
25608 | Enable sign extend instructions. |
25609 | ||
d77de738 | 25610 | @opindex muser-enabled |
ddf6fe37 | 25611 | @item -muser-enabled |
d77de738 ML |
25612 | Enable user-defined instructions. |
25613 | ||
25614 | @end table | |
25615 | ||
25616 | @node LoongArch Options | |
25617 | @subsection LoongArch Options | |
25618 | @cindex LoongArch Options | |
25619 | ||
25620 | These command-line options are defined for LoongArch targets: | |
25621 | ||
25622 | @table @gcctabopt | |
9c19597c | 25623 | @opindex march |
ddf6fe37 | 25624 | @item -march=@var{cpu-type} |
d77de738 ML |
25625 | Generate instructions for the machine type @var{cpu-type}. In contrast to |
25626 | @option{-mtune=@var{cpu-type}}, which merely tunes the generated code | |
25627 | for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC | |
25628 | to generate code that may not run at all on processors other than the one | |
25629 | indicated. Specifying @option{-march=@var{cpu-type}} implies | |
25630 | @option{-mtune=@var{cpu-type}}, except where noted otherwise. | |
25631 | ||
25632 | The choices for @var{cpu-type} are: | |
25633 | ||
25634 | @table @samp | |
25635 | @item native | |
25636 | This selects the CPU to generate code for at compilation time by determining | |
25637 | the processor type of the compiling machine. Using @option{-march=native} | |
25638 | enables all instruction subsets supported by the local machine (hence | |
25639 | the result might not run on different machines). Using @option{-mtune=native} | |
25640 | produces code optimized for the local machine under the constraints | |
25641 | of the selected instruction set. | |
25642 | @item loongarch64 | |
25643 | A generic CPU with 64-bit extensions. | |
25644 | @item la464 | |
25645 | LoongArch LA464 CPU with LBT, LSX, LASX, LVZ. | |
25646 | @end table | |
25647 | ||
d77de738 | 25648 | @opindex mtune |
ddf6fe37 | 25649 | @item -mtune=@var{cpu-type} |
d77de738 ML |
25650 | Optimize the output for the given processor, specified by microarchitecture |
25651 | name. | |
25652 | ||
d77de738 | 25653 | @opindex mabi |
ddf6fe37 | 25654 | @item -mabi=@var{base-abi-type} |
d77de738 ML |
25655 | Generate code for the specified calling convention. |
25656 | @var{base-abi-type} can be one of: | |
25657 | @table @samp | |
25658 | @item lp64d | |
25659 | Uses 64-bit general purpose registers and 32/64-bit floating-point | |
25660 | registers for parameter passing. Data model is LP64, where @samp{int} | |
25661 | is 32 bits, while @samp{long int} and pointers are 64 bits. | |
25662 | @item lp64f | |
25663 | Uses 64-bit general purpose registers and 32-bit floating-point | |
25664 | registers for parameter passing. Data model is LP64, where @samp{int} | |
25665 | is 32 bits, while @samp{long int} and pointers are 64 bits. | |
25666 | @item lp64s | |
25667 | Uses 64-bit general purpose registers and no floating-point | |
25668 | registers for parameter passing. Data model is LP64, where @samp{int} | |
25669 | is 32 bits, while @samp{long int} and pointers are 64 bits. | |
25670 | @end table | |
25671 | ||
d77de738 | 25672 | @opindex mfpu |
ddf6fe37 | 25673 | @item -mfpu=@var{fpu-type} |
d77de738 ML |
25674 | Generate code for the specified FPU type, which can be one of: |
25675 | @table @samp | |
25676 | @item 64 | |
25677 | Allow the use of hardware floating-point instructions for 32-bit | |
25678 | and 64-bit operations. | |
25679 | @item 32 | |
25680 | Allow the use of hardware floating-point instructions for 32-bit | |
25681 | operations. | |
25682 | @item none | |
25683 | @item 0 | |
25684 | Prevent the use of hardware floating-point instructions. | |
25685 | @end table | |
25686 | ||
d77de738 | 25687 | @opindex msoft-float |
ddf6fe37 | 25688 | @item -msoft-float |
d77de738 ML |
25689 | Force @option{-mfpu=none} and prevents the use of floating-point |
25690 | registers for parameter passing. This option may change the target | |
25691 | ABI. | |
25692 | ||
9c19597c | 25693 | @opindex msingle-float |
ddf6fe37 | 25694 | @item -msingle-float |
d77de738 ML |
25695 | Force @option{-mfpu=32} and allow the use of 32-bit floating-point |
25696 | registers for parameter passing. This option may change the target | |
25697 | ABI. | |
25698 | ||
9c19597c | 25699 | @opindex mdouble-float |
ddf6fe37 | 25700 | @item -mdouble-float |
d77de738 ML |
25701 | Force @option{-mfpu=64} and allow the use of 32/64-bit floating-point |
25702 | registers for parameter passing. This option may change the target | |
25703 | ABI. | |
25704 | ||
9c19597c | 25705 | @opindex mbranch-cost |
ddf6fe37 | 25706 | @item -mbranch-cost=@var{n} |
d77de738 ML |
25707 | Set the cost of branches to roughly @var{n} instructions. |
25708 | ||
ddf6fe37 | 25709 | @opindex mcheck-zero-division |
d77de738 ML |
25710 | @item -mcheck-zero-division |
25711 | @itemx -mno-check-zero-divison | |
d77de738 ML |
25712 | Trap (do not trap) on integer division by zero. The default is |
25713 | @option{-mcheck-zero-division} for @option{-O0} or @option{-Og}, and | |
25714 | @option{-mno-check-zero-division} for other optimization levels. | |
25715 | ||
ddf6fe37 | 25716 | @opindex mcond-move-int |
d77de738 ML |
25717 | @item -mcond-move-int |
25718 | @itemx -mno-cond-move-int | |
d77de738 ML |
25719 | Conditional moves for integral data in general-purpose registers |
25720 | are enabled (disabled). The default is @option{-mcond-move-int}. | |
25721 | ||
ddf6fe37 | 25722 | @opindex mcond-move-float |
d77de738 ML |
25723 | @item -mcond-move-float |
25724 | @itemx -mno-cond-move-float | |
d77de738 ML |
25725 | Conditional moves for floating-point registers are enabled (disabled). |
25726 | The default is @option{-mcond-move-float}. | |
25727 | ||
ddf6fe37 | 25728 | @opindex mmemcpy |
d77de738 ML |
25729 | @item -mmemcpy |
25730 | @itemx -mno-memcpy | |
d77de738 ML |
25731 | Force (do not force) the use of @code{memcpy} for non-trivial block moves. |
25732 | The default is @option{-mno-memcpy}, which allows GCC to inline most | |
25733 | constant-sized copies. Setting optimization level to @option{-Os} also | |
25734 | forces the use of @code{memcpy}, but @option{-mno-memcpy} may override this | |
25735 | behavior if explicitly specified, regardless of the order these options on | |
25736 | the command line. | |
25737 | ||
ddf6fe37 | 25738 | @opindex mstrict-align |
d77de738 ML |
25739 | @item -mstrict-align |
25740 | @itemx -mno-strict-align | |
d77de738 ML |
25741 | Avoid or allow generating memory accesses that may not be aligned on a natural |
25742 | object boundary as described in the architecture specification. The default is | |
25743 | @option{-mno-strict-align}. | |
25744 | ||
9c19597c | 25745 | @opindex msmall-data-limit |
ddf6fe37 | 25746 | @item -msmall-data-limit=@var{number} |
d77de738 ML |
25747 | Put global and static data smaller than @var{number} bytes into a special |
25748 | section (on some targets). The default value is 0. | |
25749 | ||
9c19597c | 25750 | @opindex mmax-inline-memcpy-size |
ddf6fe37 | 25751 | @item -mmax-inline-memcpy-size=@var{n} |
d77de738 ML |
25752 | Inline all block moves (such as calls to @code{memcpy} or structure copies) |
25753 | less than or equal to @var{n} bytes. The default value of @var{n} is 1024. | |
25754 | ||
25755 | @item -mcmodel=@var{code-model} | |
25756 | Set the code model to one of: | |
25757 | @table @samp | |
25758 | @item tiny-static (Not implemented yet) | |
25759 | @item tiny (Not implemented yet) | |
25760 | ||
25761 | @item normal | |
25762 | The text segment must be within 128MB addressing space. The data segment must | |
25763 | be within 2GB addressing space. | |
25764 | ||
25765 | @item medium | |
25766 | The text segment and data segment must be within 2GB addressing space. | |
25767 | ||
25768 | @item large (Not implemented yet) | |
25769 | ||
25770 | @item extreme | |
25771 | This mode does not limit the size of the code segment and data segment. | |
25772 | The @option{-mcmodel=extreme} option is incompatible with @option{-fplt} and | |
25773 | @option{-mno-explicit-relocs}. | |
25774 | @end table | |
25775 | The default code model is @code{normal}. | |
25776 | ||
d77de738 ML |
25777 | @opindex mexplicit-relocs |
25778 | @opindex mno-explicit-relocs | |
ddf6fe37 AA |
25779 | @item -mexplicit-relocs |
25780 | @itemx -mno-explicit-relocs | |
d77de738 ML |
25781 | Use or do not use assembler relocation operators when dealing with symbolic |
25782 | addresses. The alternative is to use assembler macros instead, which may | |
25783 | limit optimization. The default value for the option is determined during | |
25784 | GCC build-time by detecting corresponding assembler support: | |
25785 | @code{-mexplicit-relocs} if said support is present, | |
25786 | @code{-mno-explicit-relocs} otherwise. This option is mostly useful for | |
25787 | debugging, or interoperation with assemblers different from the build-time | |
25788 | one. | |
25789 | ||
ddf6fe37 | 25790 | @opindex mdirect-extern-access |
d77de738 ML |
25791 | @item -mdirect-extern-access |
25792 | @itemx -mno-direct-extern-access | |
d77de738 ML |
25793 | Do not use or use GOT to access external symbols. The default is |
25794 | @option{-mno-direct-extern-access}: GOT is used for external symbols with | |
25795 | default visibility, but not used for other external symbols. | |
25796 | ||
25797 | With @option{-mdirect-extern-access}, GOT is not used and all external | |
25798 | symbols are PC-relatively addressed. It is @strong{only} suitable for | |
25799 | environments where no dynamic link is performed, like firmwares, OS | |
25800 | kernels, executables linked with @option{-static} or @option{-static-pie}. | |
25801 | @option{-mdirect-extern-access} is not compatible with @option{-fPIC} or | |
25802 | @option{-fpic}. | |
25803 | @end table | |
25804 | ||
25805 | @node M32C Options | |
25806 | @subsection M32C Options | |
25807 | @cindex M32C options | |
25808 | ||
25809 | @table @gcctabopt | |
d77de738 | 25810 | @opindex mcpu= |
ddf6fe37 | 25811 | @item -mcpu=@var{name} |
d77de738 ML |
25812 | Select the CPU for which code is generated. @var{name} may be one of |
25813 | @samp{r8c} for the R8C/Tiny series, @samp{m16c} for the M16C (up to | |
25814 | /60) series, @samp{m32cm} for the M16C/80 series, or @samp{m32c} for | |
25815 | the M32C/80 series. | |
25816 | ||
d77de738 | 25817 | @opindex msim |
ddf6fe37 | 25818 | @item -msim |
d77de738 ML |
25819 | Specifies that the program will be run on the simulator. This causes |
25820 | an alternate runtime library to be linked in which supports, for | |
25821 | example, file I/O@. You must not use this option when generating | |
25822 | programs that will run on real hardware; you must provide your own | |
25823 | runtime library for whatever I/O functions are needed. | |
25824 | ||
d77de738 | 25825 | @opindex memregs= |
ddf6fe37 | 25826 | @item -memregs=@var{number} |
d77de738 ML |
25827 | Specifies the number of memory-based pseudo-registers GCC uses |
25828 | during code generation. These pseudo-registers are used like real | |
25829 | registers, so there is a tradeoff between GCC's ability to fit the | |
25830 | code into available registers, and the performance penalty of using | |
25831 | memory instead of registers. Note that all modules in a program must | |
25832 | be compiled with the same value for this option. Because of that, you | |
25833 | must not use this option with GCC's default runtime libraries. | |
25834 | ||
25835 | @end table | |
25836 | ||
25837 | @node M32R/D Options | |
25838 | @subsection M32R/D Options | |
25839 | @cindex M32R/D options | |
25840 | ||
25841 | These @option{-m} options are defined for Renesas M32R/D architectures: | |
25842 | ||
25843 | @table @gcctabopt | |
d77de738 | 25844 | @opindex m32r2 |
ddf6fe37 | 25845 | @item -m32r2 |
d77de738 ML |
25846 | Generate code for the M32R/2@. |
25847 | ||
d77de738 | 25848 | @opindex m32rx |
ddf6fe37 | 25849 | @item -m32rx |
d77de738 ML |
25850 | Generate code for the M32R/X@. |
25851 | ||
d77de738 | 25852 | @opindex m32r |
ddf6fe37 | 25853 | @item -m32r |
d77de738 ML |
25854 | Generate code for the M32R@. This is the default. |
25855 | ||
d77de738 | 25856 | @opindex mmodel=small |
ddf6fe37 | 25857 | @item -mmodel=small |
d77de738 ML |
25858 | Assume all objects live in the lower 16MB of memory (so that their addresses |
25859 | can be loaded with the @code{ld24} instruction), and assume all subroutines | |
25860 | are reachable with the @code{bl} instruction. | |
25861 | This is the default. | |
25862 | ||
25863 | The addressability of a particular object can be set with the | |
25864 | @code{model} attribute. | |
25865 | ||
d77de738 | 25866 | @opindex mmodel=medium |
ddf6fe37 | 25867 | @item -mmodel=medium |
d77de738 ML |
25868 | Assume objects may be anywhere in the 32-bit address space (the compiler |
25869 | generates @code{seth/add3} instructions to load their addresses), and | |
25870 | assume all subroutines are reachable with the @code{bl} instruction. | |
25871 | ||
d77de738 | 25872 | @opindex mmodel=large |
ddf6fe37 | 25873 | @item -mmodel=large |
d77de738 ML |
25874 | Assume objects may be anywhere in the 32-bit address space (the compiler |
25875 | generates @code{seth/add3} instructions to load their addresses), and | |
25876 | assume subroutines may not be reachable with the @code{bl} instruction | |
25877 | (the compiler generates the much slower @code{seth/add3/jl} | |
25878 | instruction sequence). | |
25879 | ||
d77de738 | 25880 | @opindex msdata=none |
ddf6fe37 | 25881 | @item -msdata=none |
d77de738 ML |
25882 | Disable use of the small data area. Variables are put into |
25883 | one of @code{.data}, @code{.bss}, or @code{.rodata} (unless the | |
25884 | @code{section} attribute has been specified). | |
25885 | This is the default. | |
25886 | ||
25887 | The small data area consists of sections @code{.sdata} and @code{.sbss}. | |
25888 | Objects may be explicitly put in the small data area with the | |
25889 | @code{section} attribute using one of these sections. | |
25890 | ||
d77de738 | 25891 | @opindex msdata=sdata |
ddf6fe37 | 25892 | @item -msdata=sdata |
d77de738 ML |
25893 | Put small global and static data in the small data area, but do not |
25894 | generate special code to reference them. | |
25895 | ||
d77de738 | 25896 | @opindex msdata=use |
ddf6fe37 | 25897 | @item -msdata=use |
d77de738 ML |
25898 | Put small global and static data in the small data area, and generate |
25899 | special instructions to reference them. | |
25900 | ||
d77de738 ML |
25901 | @opindex G |
25902 | @cindex smaller data references | |
f33d7a88 | 25903 | @item -G @var{num} |
d77de738 ML |
25904 | Put global and static objects less than or equal to @var{num} bytes |
25905 | into the small data or BSS sections instead of the normal data or BSS | |
25906 | sections. The default value of @var{num} is 8. | |
25907 | The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use} | |
25908 | for this option to have any effect. | |
25909 | ||
25910 | All modules should be compiled with the same @option{-G @var{num}} value. | |
25911 | Compiling with different values of @var{num} may or may not work; if it | |
25912 | doesn't the linker gives an error message---incorrect code is not | |
25913 | generated. | |
25914 | ||
d77de738 | 25915 | @opindex mdebug |
ddf6fe37 | 25916 | @item -mdebug |
d77de738 ML |
25917 | Makes the M32R-specific code in the compiler display some statistics |
25918 | that might help in debugging programs. | |
25919 | ||
d77de738 | 25920 | @opindex malign-loops |
ddf6fe37 | 25921 | @item -malign-loops |
d77de738 ML |
25922 | Align all loops to a 32-byte boundary. |
25923 | ||
d77de738 | 25924 | @opindex mno-align-loops |
ddf6fe37 | 25925 | @item -mno-align-loops |
d77de738 ML |
25926 | Do not enforce a 32-byte alignment for loops. This is the default. |
25927 | ||
d77de738 | 25928 | @opindex missue-rate=@var{number} |
ddf6fe37 | 25929 | @item -missue-rate=@var{number} |
d77de738 ML |
25930 | Issue @var{number} instructions per cycle. @var{number} can only be 1 |
25931 | or 2. | |
25932 | ||
d77de738 | 25933 | @opindex mbranch-cost=@var{number} |
ddf6fe37 | 25934 | @item -mbranch-cost=@var{number} |
d77de738 ML |
25935 | @var{number} can only be 1 or 2. If it is 1 then branches are |
25936 | preferred over conditional code, if it is 2, then the opposite applies. | |
25937 | ||
d77de738 | 25938 | @opindex mflush-trap=@var{number} |
ddf6fe37 | 25939 | @item -mflush-trap=@var{number} |
d77de738 ML |
25940 | Specifies the trap number to use to flush the cache. The default is |
25941 | 12. Valid numbers are between 0 and 15 inclusive. | |
25942 | ||
d77de738 | 25943 | @opindex mno-flush-trap |
ddf6fe37 | 25944 | @item -mno-flush-trap |
d77de738 ML |
25945 | Specifies that the cache cannot be flushed by using a trap. |
25946 | ||
d77de738 | 25947 | @opindex mflush-func=@var{name} |
ddf6fe37 | 25948 | @item -mflush-func=@var{name} |
d77de738 ML |
25949 | Specifies the name of the operating system function to call to flush |
25950 | the cache. The default is @samp{_flush_cache}, but a function call | |
25951 | is only used if a trap is not available. | |
25952 | ||
d77de738 | 25953 | @opindex mno-flush-func |
ddf6fe37 | 25954 | @item -mno-flush-func |
d77de738 ML |
25955 | Indicates that there is no OS function for flushing the cache. |
25956 | ||
25957 | @end table | |
25958 | ||
25959 | @node M680x0 Options | |
25960 | @subsection M680x0 Options | |
25961 | @cindex M680x0 options | |
25962 | ||
25963 | These are the @samp{-m} options defined for M680x0 and ColdFire processors. | |
25964 | The default settings depend on which architecture was selected when | |
25965 | the compiler was configured; the defaults for the most common choices | |
25966 | are given below. | |
25967 | ||
25968 | @table @gcctabopt | |
d77de738 | 25969 | @opindex march |
ddf6fe37 | 25970 | @item -march=@var{arch} |
d77de738 ML |
25971 | Generate code for a specific M680x0 or ColdFire instruction set |
25972 | architecture. Permissible values of @var{arch} for M680x0 | |
25973 | architectures are: @samp{68000}, @samp{68010}, @samp{68020}, | |
25974 | @samp{68030}, @samp{68040}, @samp{68060} and @samp{cpu32}. ColdFire | |
25975 | architectures are selected according to Freescale's ISA classification | |
25976 | and the permissible values are: @samp{isaa}, @samp{isaaplus}, | |
25977 | @samp{isab} and @samp{isac}. | |
25978 | ||
25979 | GCC defines a macro @code{__mcf@var{arch}__} whenever it is generating | |
25980 | code for a ColdFire target. The @var{arch} in this macro is one of the | |
25981 | @option{-march} arguments given above. | |
25982 | ||
25983 | When used together, @option{-march} and @option{-mtune} select code | |
25984 | that runs on a family of similar processors but that is optimized | |
25985 | for a particular microarchitecture. | |
25986 | ||
d77de738 | 25987 | @opindex mcpu |
ddf6fe37 | 25988 | @item -mcpu=@var{cpu} |
d77de738 ML |
25989 | Generate code for a specific M680x0 or ColdFire processor. |
25990 | The M680x0 @var{cpu}s are: @samp{68000}, @samp{68010}, @samp{68020}, | |
25991 | @samp{68030}, @samp{68040}, @samp{68060}, @samp{68302}, @samp{68332} | |
25992 | and @samp{cpu32}. The ColdFire @var{cpu}s are given by the table | |
25993 | below, which also classifies the CPUs into families: | |
25994 | ||
25995 | @multitable @columnfractions 0.20 0.80 | |
25996 | @headitem @strong{Family} @tab @strong{@samp{-mcpu} arguments} | |
25997 | @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} | |
25998 | @item @samp{5206} @tab @samp{5202} @samp{5204} @samp{5206} | |
25999 | @item @samp{5206e} @tab @samp{5206e} | |
26000 | @item @samp{5208} @tab @samp{5207} @samp{5208} | |
26001 | @item @samp{5211a} @tab @samp{5210a} @samp{5211a} | |
26002 | @item @samp{5213} @tab @samp{5211} @samp{5212} @samp{5213} | |
26003 | @item @samp{5216} @tab @samp{5214} @samp{5216} | |
26004 | @item @samp{52235} @tab @samp{52230} @samp{52231} @samp{52232} @samp{52233} @samp{52234} @samp{52235} | |
26005 | @item @samp{5225} @tab @samp{5224} @samp{5225} | |
26006 | @item @samp{52259} @tab @samp{52252} @samp{52254} @samp{52255} @samp{52256} @samp{52258} @samp{52259} | |
26007 | @item @samp{5235} @tab @samp{5232} @samp{5233} @samp{5234} @samp{5235} @samp{523x} | |
26008 | @item @samp{5249} @tab @samp{5249} | |
26009 | @item @samp{5250} @tab @samp{5250} | |
26010 | @item @samp{5271} @tab @samp{5270} @samp{5271} | |
26011 | @item @samp{5272} @tab @samp{5272} | |
26012 | @item @samp{5275} @tab @samp{5274} @samp{5275} | |
26013 | @item @samp{5282} @tab @samp{5280} @samp{5281} @samp{5282} @samp{528x} | |
26014 | @item @samp{53017} @tab @samp{53011} @samp{53012} @samp{53013} @samp{53014} @samp{53015} @samp{53016} @samp{53017} | |
26015 | @item @samp{5307} @tab @samp{5307} | |
26016 | @item @samp{5329} @tab @samp{5327} @samp{5328} @samp{5329} @samp{532x} | |
26017 | @item @samp{5373} @tab @samp{5372} @samp{5373} @samp{537x} | |
26018 | @item @samp{5407} @tab @samp{5407} | |
26019 | @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} | |
26020 | @end multitable | |
26021 | ||
26022 | @option{-mcpu=@var{cpu}} overrides @option{-march=@var{arch}} if | |
26023 | @var{arch} is compatible with @var{cpu}. Other combinations of | |
26024 | @option{-mcpu} and @option{-march} are rejected. | |
26025 | ||
26026 | GCC defines the macro @code{__mcf_cpu_@var{cpu}} when ColdFire target | |
26027 | @var{cpu} is selected. It also defines @code{__mcf_family_@var{family}}, | |
26028 | where the value of @var{family} is given by the table above. | |
26029 | ||
d77de738 | 26030 | @opindex mtune |
ddf6fe37 | 26031 | @item -mtune=@var{tune} |
d77de738 ML |
26032 | Tune the code for a particular microarchitecture within the |
26033 | constraints set by @option{-march} and @option{-mcpu}. | |
26034 | The M680x0 microarchitectures are: @samp{68000}, @samp{68010}, | |
26035 | @samp{68020}, @samp{68030}, @samp{68040}, @samp{68060} | |
26036 | and @samp{cpu32}. The ColdFire microarchitectures | |
26037 | are: @samp{cfv1}, @samp{cfv2}, @samp{cfv3}, @samp{cfv4} and @samp{cfv4e}. | |
26038 | ||
26039 | You can also use @option{-mtune=68020-40} for code that needs | |
26040 | to run relatively well on 68020, 68030 and 68040 targets. | |
26041 | @option{-mtune=68020-60} is similar but includes 68060 targets | |
26042 | as well. These two options select the same tuning decisions as | |
26043 | @option{-m68020-40} and @option{-m68020-60} respectively. | |
26044 | ||
26045 | GCC defines the macros @code{__mc@var{arch}} and @code{__mc@var{arch}__} | |
26046 | when tuning for 680x0 architecture @var{arch}. It also defines | |
26047 | @code{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std} | |
26048 | option is used. If GCC is tuning for a range of architectures, | |
26049 | as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60}, | |
26050 | it defines the macros for every architecture in the range. | |
26051 | ||
26052 | GCC also defines the macro @code{__m@var{uarch}__} when tuning for | |
26053 | ColdFire microarchitecture @var{uarch}, where @var{uarch} is one | |
26054 | of the arguments given above. | |
26055 | ||
d77de738 ML |
26056 | @opindex m68000 |
26057 | @opindex mc68000 | |
ddf6fe37 AA |
26058 | @item -m68000 |
26059 | @itemx -mc68000 | |
d77de738 ML |
26060 | Generate output for a 68000. This is the default |
26061 | when the compiler is configured for 68000-based systems. | |
26062 | It is equivalent to @option{-march=68000}. | |
26063 | ||
26064 | Use this option for microcontrollers with a 68000 or EC000 core, | |
26065 | including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356. | |
26066 | ||
d77de738 | 26067 | @opindex m68010 |
ddf6fe37 | 26068 | @item -m68010 |
d77de738 ML |
26069 | Generate output for a 68010. This is the default |
26070 | when the compiler is configured for 68010-based systems. | |
26071 | It is equivalent to @option{-march=68010}. | |
26072 | ||
d77de738 ML |
26073 | @opindex m68020 |
26074 | @opindex mc68020 | |
ddf6fe37 AA |
26075 | @item -m68020 |
26076 | @itemx -mc68020 | |
d77de738 ML |
26077 | Generate output for a 68020. This is the default |
26078 | when the compiler is configured for 68020-based systems. | |
26079 | It is equivalent to @option{-march=68020}. | |
26080 | ||
d77de738 | 26081 | @opindex m68030 |
ddf6fe37 | 26082 | @item -m68030 |
d77de738 ML |
26083 | Generate output for a 68030. This is the default when the compiler is |
26084 | configured for 68030-based systems. It is equivalent to | |
26085 | @option{-march=68030}. | |
26086 | ||
d77de738 | 26087 | @opindex m68040 |
ddf6fe37 | 26088 | @item -m68040 |
d77de738 ML |
26089 | Generate output for a 68040. This is the default when the compiler is |
26090 | configured for 68040-based systems. It is equivalent to | |
26091 | @option{-march=68040}. | |
26092 | ||
26093 | This option inhibits the use of 68881/68882 instructions that have to be | |
26094 | emulated by software on the 68040. Use this option if your 68040 does not | |
26095 | have code to emulate those instructions. | |
26096 | ||
d77de738 | 26097 | @opindex m68060 |
ddf6fe37 | 26098 | @item -m68060 |
d77de738 ML |
26099 | Generate output for a 68060. This is the default when the compiler is |
26100 | configured for 68060-based systems. It is equivalent to | |
26101 | @option{-march=68060}. | |
26102 | ||
26103 | This option inhibits the use of 68020 and 68881/68882 instructions that | |
26104 | have to be emulated by software on the 68060. Use this option if your 68060 | |
26105 | does not have code to emulate those instructions. | |
26106 | ||
d77de738 | 26107 | @opindex mcpu32 |
ddf6fe37 | 26108 | @item -mcpu32 |
d77de738 ML |
26109 | Generate output for a CPU32. This is the default |
26110 | when the compiler is configured for CPU32-based systems. | |
26111 | It is equivalent to @option{-march=cpu32}. | |
26112 | ||
26113 | Use this option for microcontrollers with a | |
26114 | CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334, | |
26115 | 68336, 68340, 68341, 68349 and 68360. | |
26116 | ||
d77de738 | 26117 | @opindex m5200 |
ddf6fe37 | 26118 | @item -m5200 |
d77de738 ML |
26119 | Generate output for a 520X ColdFire CPU@. This is the default |
26120 | when the compiler is configured for 520X-based systems. | |
26121 | It is equivalent to @option{-mcpu=5206}, and is now deprecated | |
26122 | in favor of that option. | |
26123 | ||
26124 | Use this option for microcontroller with a 5200 core, including | |
26125 | the MCF5202, MCF5203, MCF5204 and MCF5206. | |
26126 | ||
d77de738 | 26127 | @opindex m5206e |
ddf6fe37 | 26128 | @item -m5206e |
d77de738 ML |
26129 | Generate output for a 5206e ColdFire CPU@. The option is now |
26130 | deprecated in favor of the equivalent @option{-mcpu=5206e}. | |
26131 | ||
d77de738 | 26132 | @opindex m528x |
ddf6fe37 | 26133 | @item -m528x |
d77de738 ML |
26134 | Generate output for a member of the ColdFire 528X family. |
26135 | The option is now deprecated in favor of the equivalent | |
26136 | @option{-mcpu=528x}. | |
26137 | ||
d77de738 | 26138 | @opindex m5307 |
ddf6fe37 | 26139 | @item -m5307 |
d77de738 ML |
26140 | Generate output for a ColdFire 5307 CPU@. The option is now deprecated |
26141 | in favor of the equivalent @option{-mcpu=5307}. | |
26142 | ||
d77de738 | 26143 | @opindex m5407 |
ddf6fe37 | 26144 | @item -m5407 |
d77de738 ML |
26145 | Generate output for a ColdFire 5407 CPU@. The option is now deprecated |
26146 | in favor of the equivalent @option{-mcpu=5407}. | |
26147 | ||
d77de738 | 26148 | @opindex mcfv4e |
ddf6fe37 | 26149 | @item -mcfv4e |
d77de738 ML |
26150 | Generate output for a ColdFire V4e family CPU (e.g.@: 547x/548x). |
26151 | This includes use of hardware floating-point instructions. | |
26152 | The option is equivalent to @option{-mcpu=547x}, and is now | |
26153 | deprecated in favor of that option. | |
26154 | ||
d77de738 | 26155 | @opindex m68020-40 |
ddf6fe37 | 26156 | @item -m68020-40 |
d77de738 ML |
26157 | Generate output for a 68040, without using any of the new instructions. |
26158 | This results in code that can run relatively efficiently on either a | |
26159 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
26160 | 68881 instructions that are emulated on the 68040. | |
26161 | ||
26162 | The option is equivalent to @option{-march=68020} @option{-mtune=68020-40}. | |
26163 | ||
d77de738 | 26164 | @opindex m68020-60 |
ddf6fe37 | 26165 | @item -m68020-60 |
d77de738 ML |
26166 | Generate output for a 68060, without using any of the new instructions. |
26167 | This results in code that can run relatively efficiently on either a | |
26168 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
26169 | 68881 instructions that are emulated on the 68060. | |
26170 | ||
26171 | The option is equivalent to @option{-march=68020} @option{-mtune=68020-60}. | |
26172 | ||
d77de738 ML |
26173 | @opindex mhard-float |
26174 | @opindex m68881 | |
ddf6fe37 AA |
26175 | @item -mhard-float |
26176 | @itemx -m68881 | |
d77de738 ML |
26177 | Generate floating-point instructions. This is the default for 68020 |
26178 | and above, and for ColdFire devices that have an FPU@. It defines the | |
26179 | macro @code{__HAVE_68881__} on M680x0 targets and @code{__mcffpu__} | |
26180 | on ColdFire targets. | |
26181 | ||
d77de738 | 26182 | @opindex msoft-float |
ddf6fe37 | 26183 | @item -msoft-float |
d77de738 ML |
26184 | Do not generate floating-point instructions; use library calls instead. |
26185 | This is the default for 68000, 68010, and 68832 targets. It is also | |
26186 | the default for ColdFire devices that have no FPU. | |
26187 | ||
d77de738 ML |
26188 | @opindex mdiv |
26189 | @opindex mno-div | |
ddf6fe37 AA |
26190 | @item -mdiv |
26191 | @itemx -mno-div | |
d77de738 ML |
26192 | Generate (do not generate) ColdFire hardware divide and remainder |
26193 | instructions. If @option{-march} is used without @option{-mcpu}, | |
26194 | the default is ``on'' for ColdFire architectures and ``off'' for M680x0 | |
26195 | architectures. Otherwise, the default is taken from the target CPU | |
26196 | (either the default CPU, or the one specified by @option{-mcpu}). For | |
26197 | example, the default is ``off'' for @option{-mcpu=5206} and ``on'' for | |
26198 | @option{-mcpu=5206e}. | |
26199 | ||
26200 | GCC defines the macro @code{__mcfhwdiv__} when this option is enabled. | |
26201 | ||
d77de738 | 26202 | @opindex mshort |
ddf6fe37 | 26203 | @item -mshort |
d77de738 ML |
26204 | Consider type @code{int} to be 16 bits wide, like @code{short int}. |
26205 | Additionally, parameters passed on the stack are also aligned to a | |
26206 | 16-bit boundary even on targets whose API mandates promotion to 32-bit. | |
26207 | ||
d77de738 | 26208 | @opindex mno-short |
ddf6fe37 | 26209 | @item -mno-short |
d77de738 ML |
26210 | Do not consider type @code{int} to be 16 bits wide. This is the default. |
26211 | ||
d77de738 ML |
26212 | @opindex mnobitfield |
26213 | @opindex mno-bitfield | |
ddf6fe37 AA |
26214 | @item -mnobitfield |
26215 | @itemx -mno-bitfield | |
d77de738 ML |
26216 | Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32} |
26217 | and @option{-m5200} options imply @w{@option{-mnobitfield}}. | |
26218 | ||
d77de738 | 26219 | @opindex mbitfield |
ddf6fe37 | 26220 | @item -mbitfield |
d77de738 ML |
26221 | Do use the bit-field instructions. The @option{-m68020} option implies |
26222 | @option{-mbitfield}. This is the default if you use a configuration | |
26223 | designed for a 68020. | |
26224 | ||
d77de738 | 26225 | @opindex mrtd |
ddf6fe37 | 26226 | @item -mrtd |
d77de738 ML |
26227 | Use a different function-calling convention, in which functions |
26228 | that take a fixed number of arguments return with the @code{rtd} | |
26229 | instruction, which pops their arguments while returning. This | |
26230 | saves one instruction in the caller since there is no need to pop | |
26231 | the arguments there. | |
26232 | ||
26233 | This calling convention is incompatible with the one normally | |
26234 | used on Unix, so you cannot use it if you need to call libraries | |
26235 | compiled with the Unix compiler. | |
26236 | ||
26237 | Also, you must provide function prototypes for all functions that | |
26238 | take variable numbers of arguments (including @code{printf}); | |
26239 | otherwise incorrect code is generated for calls to those | |
26240 | functions. | |
26241 | ||
26242 | In addition, seriously incorrect code results if you call a | |
26243 | function with too many arguments. (Normally, extra arguments are | |
26244 | harmlessly ignored.) | |
26245 | ||
26246 | The @code{rtd} instruction is supported by the 68010, 68020, 68030, | |
26247 | 68040, 68060 and CPU32 processors, but not by the 68000 or 5200. | |
26248 | ||
26249 | The default is @option{-mno-rtd}. | |
26250 | ||
d77de738 ML |
26251 | @opindex malign-int |
26252 | @opindex mno-align-int | |
ddf6fe37 AA |
26253 | @item -malign-int |
26254 | @itemx -mno-align-int | |
d77de738 ML |
26255 | Control whether GCC aligns @code{int}, @code{long}, @code{long long}, |
26256 | @code{float}, @code{double}, and @code{long double} variables on a 32-bit | |
26257 | boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}). | |
26258 | Aligning variables on 32-bit boundaries produces code that runs somewhat | |
26259 | faster on processors with 32-bit busses at the expense of more memory. | |
26260 | ||
26261 | @strong{Warning:} if you use the @option{-malign-int} switch, GCC | |
26262 | aligns structures containing the above types differently than | |
26263 | most published application binary interface specifications for the m68k. | |
26264 | ||
26265 | @opindex mpcrel | |
26266 | Use the pc-relative addressing mode of the 68000 directly, instead of | |
26267 | using a global offset table. At present, this option implies @option{-fpic}, | |
26268 | allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is | |
26269 | not presently supported with @option{-mpcrel}, though this could be supported for | |
26270 | 68020 and higher processors. | |
26271 | ||
d77de738 ML |
26272 | @opindex mno-strict-align |
26273 | @opindex mstrict-align | |
ddf6fe37 AA |
26274 | @item -mno-strict-align |
26275 | @itemx -mstrict-align | |
d77de738 ML |
26276 | Do not (do) assume that unaligned memory references are handled by |
26277 | the system. | |
26278 | ||
26279 | @item -msep-data | |
26280 | Generate code that allows the data segment to be located in a different | |
26281 | area of memory from the text segment. This allows for execute-in-place in | |
26282 | an environment without virtual memory management. This option implies | |
26283 | @option{-fPIC}. | |
26284 | ||
26285 | @item -mno-sep-data | |
26286 | Generate code that assumes that the data segment follows the text segment. | |
26287 | This is the default. | |
26288 | ||
26289 | @item -mid-shared-library | |
26290 | Generate code that supports shared libraries via the library ID method. | |
26291 | This allows for execute-in-place and shared libraries in an environment | |
26292 | without virtual memory management. This option implies @option{-fPIC}. | |
26293 | ||
26294 | @item -mno-id-shared-library | |
26295 | Generate code that doesn't assume ID-based shared libraries are being used. | |
26296 | This is the default. | |
26297 | ||
26298 | @item -mshared-library-id=n | |
26299 | Specifies the identification number of the ID-based shared library being | |
26300 | compiled. Specifying a value of 0 generates more compact code; specifying | |
26301 | other values forces the allocation of that number to the current | |
26302 | library, but is no more space- or time-efficient than omitting this option. | |
26303 | ||
d77de738 ML |
26304 | @opindex mxgot |
26305 | @opindex mno-xgot | |
ddf6fe37 AA |
26306 | @item -mxgot |
26307 | @itemx -mno-xgot | |
d77de738 ML |
26308 | When generating position-independent code for ColdFire, generate code |
26309 | that works if the GOT has more than 8192 entries. This code is | |
26310 | larger and slower than code generated without this option. On M680x0 | |
26311 | processors, this option is not needed; @option{-fPIC} suffices. | |
26312 | ||
26313 | GCC normally uses a single instruction to load values from the GOT@. | |
26314 | While this is relatively efficient, it only works if the GOT | |
26315 | is smaller than about 64k. Anything larger causes the linker | |
26316 | to report an error such as: | |
26317 | ||
26318 | @cindex relocation truncated to fit (ColdFire) | |
26319 | @smallexample | |
26320 | relocation truncated to fit: R_68K_GOT16O foobar | |
26321 | @end smallexample | |
26322 | ||
26323 | If this happens, you should recompile your code with @option{-mxgot}. | |
26324 | It should then work with very large GOTs. However, code generated with | |
26325 | @option{-mxgot} is less efficient, since it takes 4 instructions to fetch | |
26326 | the value of a global symbol. | |
26327 | ||
26328 | Note that some linkers, including newer versions of the GNU linker, | |
26329 | can create multiple GOTs and sort GOT entries. If you have such a linker, | |
26330 | you should only need to use @option{-mxgot} when compiling a single | |
26331 | object file that accesses more than 8192 GOT entries. Very few do. | |
26332 | ||
26333 | These options have no effect unless GCC is generating | |
26334 | position-independent code. | |
26335 | ||
d77de738 | 26336 | @opindex mlong-jump-table-offsets |
ddf6fe37 | 26337 | @item -mlong-jump-table-offsets |
d77de738 ML |
26338 | Use 32-bit offsets in @code{switch} tables. The default is to use |
26339 | 16-bit offsets. | |
26340 | ||
26341 | @end table | |
26342 | ||
26343 | @node MCore Options | |
26344 | @subsection MCore Options | |
26345 | @cindex MCore options | |
26346 | ||
26347 | These are the @samp{-m} options defined for the Motorola M*Core | |
26348 | processors. | |
26349 | ||
26350 | @table @gcctabopt | |
26351 | ||
d77de738 ML |
26352 | @opindex mhardlit |
26353 | @opindex mno-hardlit | |
ddf6fe37 AA |
26354 | @item -mhardlit |
26355 | @itemx -mno-hardlit | |
d77de738 ML |
26356 | Inline constants into the code stream if it can be done in two |
26357 | instructions or less. | |
26358 | ||
d77de738 ML |
26359 | @opindex mdiv |
26360 | @opindex mno-div | |
ddf6fe37 AA |
26361 | @item -mdiv |
26362 | @itemx -mno-div | |
d77de738 ML |
26363 | Use the divide instruction. (Enabled by default). |
26364 | ||
d77de738 ML |
26365 | @opindex mrelax-immediate |
26366 | @opindex mno-relax-immediate | |
ddf6fe37 AA |
26367 | @item -mrelax-immediate |
26368 | @itemx -mno-relax-immediate | |
d77de738 ML |
26369 | Allow arbitrary-sized immediates in bit operations. |
26370 | ||
d77de738 ML |
26371 | @opindex mwide-bitfields |
26372 | @opindex mno-wide-bitfields | |
ddf6fe37 AA |
26373 | @item -mwide-bitfields |
26374 | @itemx -mno-wide-bitfields | |
d77de738 ML |
26375 | Always treat bit-fields as @code{int}-sized. |
26376 | ||
d77de738 ML |
26377 | @opindex m4byte-functions |
26378 | @opindex mno-4byte-functions | |
ddf6fe37 AA |
26379 | @item -m4byte-functions |
26380 | @itemx -mno-4byte-functions | |
d77de738 ML |
26381 | Force all functions to be aligned to a 4-byte boundary. |
26382 | ||
d77de738 ML |
26383 | @opindex mcallgraph-data |
26384 | @opindex mno-callgraph-data | |
ddf6fe37 AA |
26385 | @item -mcallgraph-data |
26386 | @itemx -mno-callgraph-data | |
d77de738 ML |
26387 | Emit callgraph information. |
26388 | ||
d77de738 ML |
26389 | @opindex mslow-bytes |
26390 | @opindex mno-slow-bytes | |
ddf6fe37 AA |
26391 | @item -mslow-bytes |
26392 | @itemx -mno-slow-bytes | |
d77de738 ML |
26393 | Prefer word access when reading byte quantities. |
26394 | ||
d77de738 ML |
26395 | @opindex mlittle-endian |
26396 | @opindex mbig-endian | |
ddf6fe37 AA |
26397 | @item -mlittle-endian |
26398 | @itemx -mbig-endian | |
d77de738 ML |
26399 | Generate code for a little-endian target. |
26400 | ||
d77de738 ML |
26401 | @opindex m210 |
26402 | @opindex m340 | |
ddf6fe37 AA |
26403 | @item -m210 |
26404 | @itemx -m340 | |
d77de738 ML |
26405 | Generate code for the 210 processor. |
26406 | ||
d77de738 | 26407 | @opindex mno-lsim |
ddf6fe37 | 26408 | @item -mno-lsim |
d77de738 ML |
26409 | Assume that runtime support has been provided and so omit the |
26410 | simulator library (@file{libsim.a)} from the linker command line. | |
26411 | ||
d77de738 | 26412 | @opindex mstack-increment |
ddf6fe37 | 26413 | @item -mstack-increment=@var{size} |
d77de738 ML |
26414 | Set the maximum amount for a single stack increment operation. Large |
26415 | values can increase the speed of programs that contain functions | |
26416 | that need a large amount of stack space, but they can also trigger a | |
26417 | segmentation fault if the stack is extended too much. The default | |
26418 | value is 0x1000. | |
26419 | ||
26420 | @end table | |
26421 | ||
d77de738 ML |
26422 | @node MicroBlaze Options |
26423 | @subsection MicroBlaze Options | |
26424 | @cindex MicroBlaze Options | |
26425 | ||
26426 | @table @gcctabopt | |
26427 | ||
d77de738 | 26428 | @opindex msoft-float |
ddf6fe37 | 26429 | @item -msoft-float |
d77de738 ML |
26430 | Use software emulation for floating point (default). |
26431 | ||
d77de738 | 26432 | @opindex mhard-float |
ddf6fe37 | 26433 | @item -mhard-float |
d77de738 ML |
26434 | Use hardware floating-point instructions. |
26435 | ||
d77de738 | 26436 | @opindex mmemcpy |
ddf6fe37 | 26437 | @item -mmemcpy |
d77de738 ML |
26438 | Do not optimize block moves, use @code{memcpy}. |
26439 | ||
d77de738 | 26440 | @opindex mno-clearbss |
ddf6fe37 | 26441 | @item -mno-clearbss |
d77de738 ML |
26442 | This option is deprecated. Use @option{-fno-zero-initialized-in-bss} instead. |
26443 | ||
d77de738 | 26444 | @opindex mcpu= |
ddf6fe37 | 26445 | @item -mcpu=@var{cpu-type} |
d77de738 ML |
26446 | Use features of, and schedule code for, the given CPU. |
26447 | Supported values are in the format @samp{v@var{X}.@var{YY}.@var{Z}}, | |
26448 | where @var{X} is a major version, @var{YY} is the minor version, and | |
26449 | @var{Z} is compatibility code. Example values are @samp{v3.00.a}, | |
26450 | @samp{v4.00.b}, @samp{v5.00.a}, @samp{v5.00.b}, @samp{v6.00.a}. | |
26451 | ||
d77de738 | 26452 | @opindex mxl-soft-mul |
ddf6fe37 | 26453 | @item -mxl-soft-mul |
d77de738 ML |
26454 | Use software multiply emulation (default). |
26455 | ||
d77de738 | 26456 | @opindex mxl-soft-div |
ddf6fe37 | 26457 | @item -mxl-soft-div |
d77de738 ML |
26458 | Use software emulation for divides (default). |
26459 | ||
d77de738 | 26460 | @opindex mxl-barrel-shift |
ddf6fe37 | 26461 | @item -mxl-barrel-shift |
d77de738 ML |
26462 | Use the hardware barrel shifter. |
26463 | ||
d77de738 | 26464 | @opindex mxl-pattern-compare |
ddf6fe37 | 26465 | @item -mxl-pattern-compare |
d77de738 ML |
26466 | Use pattern compare instructions. |
26467 | ||
d77de738 | 26468 | @opindex msmall-divides |
ddf6fe37 | 26469 | @item -msmall-divides |
d77de738 ML |
26470 | Use table lookup optimization for small signed integer divisions. |
26471 | ||
d77de738 | 26472 | @opindex mxl-stack-check |
ddf6fe37 | 26473 | @item -mxl-stack-check |
d77de738 ML |
26474 | This option is deprecated. Use @option{-fstack-check} instead. |
26475 | ||
d77de738 | 26476 | @opindex mxl-gp-opt |
ddf6fe37 | 26477 | @item -mxl-gp-opt |
d77de738 ML |
26478 | Use GP-relative @code{.sdata}/@code{.sbss} sections. |
26479 | ||
d77de738 | 26480 | @opindex mxl-multiply-high |
ddf6fe37 | 26481 | @item -mxl-multiply-high |
d77de738 ML |
26482 | Use multiply high instructions for high part of 32x32 multiply. |
26483 | ||
d77de738 | 26484 | @opindex mxl-float-convert |
ddf6fe37 | 26485 | @item -mxl-float-convert |
d77de738 ML |
26486 | Use hardware floating-point conversion instructions. |
26487 | ||
d77de738 | 26488 | @opindex mxl-float-sqrt |
ddf6fe37 | 26489 | @item -mxl-float-sqrt |
d77de738 ML |
26490 | Use hardware floating-point square root instruction. |
26491 | ||
d77de738 | 26492 | @opindex mbig-endian |
ddf6fe37 | 26493 | @item -mbig-endian |
d77de738 ML |
26494 | Generate code for a big-endian target. |
26495 | ||
d77de738 | 26496 | @opindex mlittle-endian |
ddf6fe37 | 26497 | @item -mlittle-endian |
d77de738 ML |
26498 | Generate code for a little-endian target. |
26499 | ||
d77de738 | 26500 | @opindex mxl-reorder |
ddf6fe37 | 26501 | @item -mxl-reorder |
d77de738 ML |
26502 | Use reorder instructions (swap and byte reversed load/store). |
26503 | ||
26504 | @item -mxl-mode-@var{app-model} | |
26505 | Select application model @var{app-model}. Valid models are | |
26506 | @table @samp | |
26507 | @item executable | |
26508 | normal executable (default), uses startup code @file{crt0.o}. | |
26509 | ||
26510 | @item xmdstub | |
26511 | for use with Xilinx Microprocessor Debugger (XMD) based | |
26512 | software intrusive debug agent called xmdstub. This uses startup file | |
26513 | @file{crt1.o} and sets the start address of the program to 0x800. | |
26514 | ||
26515 | @item bootstrap | |
26516 | for applications that are loaded using a bootloader. | |
26517 | This model uses startup file @file{crt2.o} which does not contain a processor | |
26518 | reset vector handler. This is suitable for transferring control on a | |
26519 | processor reset to the bootloader rather than the application. | |
26520 | ||
26521 | @item novectors | |
26522 | for applications that do not require any of the | |
26523 | MicroBlaze vectors. This option may be useful for applications running | |
26524 | within a monitoring application. This model uses @file{crt3.o} as a startup file. | |
26525 | @end table | |
26526 | ||
26527 | Option @option{-xl-mode-@var{app-model}} is a deprecated alias for | |
26528 | @option{-mxl-mode-@var{app-model}}. | |
26529 | ||
d77de738 | 26530 | @opindex mpic-data-is-text-relative |
ddf6fe37 | 26531 | @item -mpic-data-is-text-relative |
d77de738 ML |
26532 | Assume that the displacement between the text and data segments is fixed |
26533 | at static link time. This allows data to be referenced by offset from start of | |
26534 | text address instead of GOT since PC-relative addressing is not supported. | |
26535 | ||
26536 | @end table | |
26537 | ||
26538 | @node MIPS Options | |
26539 | @subsection MIPS Options | |
26540 | @cindex MIPS options | |
26541 | ||
26542 | @table @gcctabopt | |
26543 | ||
d77de738 | 26544 | @opindex EB |
ddf6fe37 | 26545 | @item -EB |
d77de738 ML |
26546 | Generate big-endian code. |
26547 | ||
d77de738 | 26548 | @opindex EL |
ddf6fe37 | 26549 | @item -EL |
d77de738 ML |
26550 | Generate little-endian code. This is the default for @samp{mips*el-*-*} |
26551 | configurations. | |
26552 | ||
d77de738 | 26553 | @opindex march |
ddf6fe37 | 26554 | @item -march=@var{arch} |
d77de738 ML |
26555 | Generate code that runs on @var{arch}, which can be the name of a |
26556 | generic MIPS ISA, or the name of a particular processor. | |
26557 | The ISA names are: | |
26558 | @samp{mips1}, @samp{mips2}, @samp{mips3}, @samp{mips4}, | |
26559 | @samp{mips32}, @samp{mips32r2}, @samp{mips32r3}, @samp{mips32r5}, | |
26560 | @samp{mips32r6}, @samp{mips64}, @samp{mips64r2}, @samp{mips64r3}, | |
26561 | @samp{mips64r5} and @samp{mips64r6}. | |
26562 | The processor names are: | |
26563 | @samp{4kc}, @samp{4km}, @samp{4kp}, @samp{4ksc}, | |
26564 | @samp{4kec}, @samp{4kem}, @samp{4kep}, @samp{4ksd}, | |
26565 | @samp{5kc}, @samp{5kf}, | |
26566 | @samp{20kc}, | |
26567 | @samp{24kc}, @samp{24kf2_1}, @samp{24kf1_1}, | |
26568 | @samp{24kec}, @samp{24kef2_1}, @samp{24kef1_1}, | |
26569 | @samp{34kc}, @samp{34kf2_1}, @samp{34kf1_1}, @samp{34kn}, | |
26570 | @samp{74kc}, @samp{74kf2_1}, @samp{74kf1_1}, @samp{74kf3_2}, | |
26571 | @samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1}, | |
26572 | @samp{i6400}, @samp{i6500}, | |
26573 | @samp{interaptiv}, | |
26574 | @samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a}, @samp{gs464}, | |
26575 | @samp{gs464e}, @samp{gs264e}, | |
26576 | @samp{m4k}, | |
26577 | @samp{m14k}, @samp{m14kc}, @samp{m14ke}, @samp{m14kec}, | |
26578 | @samp{m5100}, @samp{m5101}, | |
26579 | @samp{octeon}, @samp{octeon+}, @samp{octeon2}, @samp{octeon3}, | |
26580 | @samp{orion}, | |
26581 | @samp{p5600}, @samp{p6600}, | |
26582 | @samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400}, | |
26583 | @samp{r4600}, @samp{r4650}, @samp{r4700}, @samp{r5900}, | |
26584 | @samp{r6000}, @samp{r8000}, | |
26585 | @samp{rm7000}, @samp{rm9000}, | |
26586 | @samp{r10000}, @samp{r12000}, @samp{r14000}, @samp{r16000}, | |
26587 | @samp{sb1}, | |
26588 | @samp{sr71000}, | |
26589 | @samp{vr4100}, @samp{vr4111}, @samp{vr4120}, @samp{vr4130}, @samp{vr4300}, | |
26590 | @samp{vr5000}, @samp{vr5400}, @samp{vr5500}, | |
26591 | @samp{xlr} and @samp{xlp}. | |
26592 | The special value @samp{from-abi} selects the | |
26593 | most compatible architecture for the selected ABI (that is, | |
26594 | @samp{mips1} for 32-bit ABIs and @samp{mips3} for 64-bit ABIs)@. | |
26595 | ||
26596 | The native Linux/GNU toolchain also supports the value @samp{native}, | |
26597 | which selects the best architecture option for the host processor. | |
26598 | @option{-march=native} has no effect if GCC does not recognize | |
26599 | the processor. | |
26600 | ||
26601 | In processor names, a final @samp{000} can be abbreviated as @samp{k} | |
26602 | (for example, @option{-march=r2k}). Prefixes are optional, and | |
26603 | @samp{vr} may be written @samp{r}. | |
26604 | ||
26605 | Names of the form @samp{@var{n}f2_1} refer to processors with | |
26606 | FPUs clocked at half the rate of the core, names of the form | |
26607 | @samp{@var{n}f1_1} refer to processors with FPUs clocked at the same | |
26608 | rate as the core, and names of the form @samp{@var{n}f3_2} refer to | |
26609 | processors with FPUs clocked a ratio of 3:2 with respect to the core. | |
26610 | For compatibility reasons, @samp{@var{n}f} is accepted as a synonym | |
26611 | for @samp{@var{n}f2_1} while @samp{@var{n}x} and @samp{@var{b}fx} are | |
26612 | accepted as synonyms for @samp{@var{n}f1_1}. | |
26613 | ||
26614 | GCC defines two macros based on the value of this option. The first | |
26615 | is @code{_MIPS_ARCH}, which gives the name of target architecture, as | |
26616 | a string. The second has the form @code{_MIPS_ARCH_@var{foo}}, | |
26617 | where @var{foo} is the capitalized value of @code{_MIPS_ARCH}@. | |
26618 | For example, @option{-march=r2000} sets @code{_MIPS_ARCH} | |
26619 | to @code{"r2000"} and defines the macro @code{_MIPS_ARCH_R2000}. | |
26620 | ||
26621 | Note that the @code{_MIPS_ARCH} macro uses the processor names given | |
26622 | above. In other words, it has the full prefix and does not | |
26623 | abbreviate @samp{000} as @samp{k}. In the case of @samp{from-abi}, | |
26624 | the macro names the resolved architecture (either @code{"mips1"} or | |
26625 | @code{"mips3"}). It names the default architecture when no | |
26626 | @option{-march} option is given. | |
26627 | ||
d77de738 | 26628 | @opindex mtune |
ddf6fe37 | 26629 | @item -mtune=@var{arch} |
d77de738 ML |
26630 | Optimize for @var{arch}. Among other things, this option controls |
26631 | the way instructions are scheduled, and the perceived cost of arithmetic | |
26632 | operations. The list of @var{arch} values is the same as for | |
26633 | @option{-march}. | |
26634 | ||
26635 | When this option is not used, GCC optimizes for the processor | |
26636 | specified by @option{-march}. By using @option{-march} and | |
26637 | @option{-mtune} together, it is possible to generate code that | |
26638 | runs on a family of processors, but optimize the code for one | |
26639 | particular member of that family. | |
26640 | ||
26641 | @option{-mtune} defines the macros @code{_MIPS_TUNE} and | |
26642 | @code{_MIPS_TUNE_@var{foo}}, which work in the same way as the | |
26643 | @option{-march} ones described above. | |
26644 | ||
d77de738 | 26645 | @opindex mips1 |
ddf6fe37 | 26646 | @item -mips1 |
d77de738 ML |
26647 | Equivalent to @option{-march=mips1}. |
26648 | ||
d77de738 | 26649 | @opindex mips2 |
ddf6fe37 | 26650 | @item -mips2 |
d77de738 ML |
26651 | Equivalent to @option{-march=mips2}. |
26652 | ||
d77de738 | 26653 | @opindex mips3 |
ddf6fe37 | 26654 | @item -mips3 |
d77de738 ML |
26655 | Equivalent to @option{-march=mips3}. |
26656 | ||
d77de738 | 26657 | @opindex mips4 |
ddf6fe37 | 26658 | @item -mips4 |
d77de738 ML |
26659 | Equivalent to @option{-march=mips4}. |
26660 | ||
d77de738 | 26661 | @opindex mips32 |
ddf6fe37 | 26662 | @item -mips32 |
d77de738 ML |
26663 | Equivalent to @option{-march=mips32}. |
26664 | ||
d77de738 | 26665 | @opindex mips32r3 |
ddf6fe37 | 26666 | @item -mips32r3 |
d77de738 ML |
26667 | Equivalent to @option{-march=mips32r3}. |
26668 | ||
d77de738 | 26669 | @opindex mips32r5 |
ddf6fe37 | 26670 | @item -mips32r5 |
d77de738 ML |
26671 | Equivalent to @option{-march=mips32r5}. |
26672 | ||
d77de738 | 26673 | @opindex mips32r6 |
ddf6fe37 | 26674 | @item -mips32r6 |
d77de738 ML |
26675 | Equivalent to @option{-march=mips32r6}. |
26676 | ||
d77de738 | 26677 | @opindex mips64 |
ddf6fe37 | 26678 | @item -mips64 |
d77de738 ML |
26679 | Equivalent to @option{-march=mips64}. |
26680 | ||
d77de738 | 26681 | @opindex mips64r2 |
ddf6fe37 | 26682 | @item -mips64r2 |
d77de738 ML |
26683 | Equivalent to @option{-march=mips64r2}. |
26684 | ||
d77de738 | 26685 | @opindex mips64r3 |
ddf6fe37 | 26686 | @item -mips64r3 |
d77de738 ML |
26687 | Equivalent to @option{-march=mips64r3}. |
26688 | ||
d77de738 | 26689 | @opindex mips64r5 |
ddf6fe37 | 26690 | @item -mips64r5 |
d77de738 ML |
26691 | Equivalent to @option{-march=mips64r5}. |
26692 | ||
d77de738 | 26693 | @opindex mips64r6 |
ddf6fe37 | 26694 | @item -mips64r6 |
d77de738 ML |
26695 | Equivalent to @option{-march=mips64r6}. |
26696 | ||
d77de738 ML |
26697 | @opindex mips16 |
26698 | @opindex mno-mips16 | |
ddf6fe37 AA |
26699 | @item -mips16 |
26700 | @itemx -mno-mips16 | |
d77de738 ML |
26701 | Generate (do not generate) MIPS16 code. If GCC is targeting a |
26702 | MIPS32 or MIPS64 architecture, it makes use of the MIPS16e ASE@. | |
26703 | ||
26704 | MIPS16 code generation can also be controlled on a per-function basis | |
26705 | by means of @code{mips16} and @code{nomips16} attributes. | |
26706 | @xref{Function Attributes}, for more information. | |
26707 | ||
d77de738 | 26708 | @opindex mflip-mips16 |
ddf6fe37 | 26709 | @item -mflip-mips16 |
d77de738 ML |
26710 | Generate MIPS16 code on alternating functions. This option is provided |
26711 | for regression testing of mixed MIPS16/non-MIPS16 code generation, and is | |
26712 | not intended for ordinary use in compiling user code. | |
26713 | ||
d77de738 ML |
26714 | @opindex minterlink-compressed |
26715 | @opindex mno-interlink-compressed | |
ddf6fe37 AA |
26716 | @item -minterlink-compressed |
26717 | @itemx -mno-interlink-compressed | |
d77de738 ML |
26718 | Require (do not require) that code using the standard (uncompressed) MIPS ISA |
26719 | be link-compatible with MIPS16 and microMIPS code, and vice versa. | |
26720 | ||
26721 | For example, code using the standard ISA encoding cannot jump directly | |
26722 | to MIPS16 or microMIPS code; it must either use a call or an indirect jump. | |
26723 | @option{-minterlink-compressed} therefore disables direct jumps unless GCC | |
26724 | knows that the target of the jump is not compressed. | |
26725 | ||
d77de738 ML |
26726 | @opindex minterlink-mips16 |
26727 | @opindex mno-interlink-mips16 | |
ddf6fe37 AA |
26728 | @item -minterlink-mips16 |
26729 | @itemx -mno-interlink-mips16 | |
d77de738 ML |
26730 | Aliases of @option{-minterlink-compressed} and |
26731 | @option{-mno-interlink-compressed}. These options predate the microMIPS ASE | |
26732 | and are retained for backwards compatibility. | |
26733 | ||
d77de738 ML |
26734 | @opindex mabi=32 |
26735 | @opindex mabi=o64 | |
26736 | @opindex mabi=n32 | |
26737 | @opindex mabi=64 | |
26738 | @opindex mabi=eabi | |
ddf6fe37 AA |
26739 | @item -mabi=32 |
26740 | @itemx -mabi=o64 | |
26741 | @itemx -mabi=n32 | |
26742 | @itemx -mabi=64 | |
26743 | @itemx -mabi=eabi | |
d77de738 ML |
26744 | Generate code for the given ABI@. |
26745 | ||
26746 | Note that the EABI has a 32-bit and a 64-bit variant. GCC normally | |
26747 | generates 64-bit code when you select a 64-bit architecture, but you | |
26748 | can use @option{-mgp32} to get 32-bit code instead. | |
26749 | ||
26750 | For information about the O64 ABI, see | |
26751 | @uref{https://gcc.gnu.org/@/projects/@/mipso64-abi.html}. | |
26752 | ||
26753 | GCC supports a variant of the o32 ABI in which floating-point registers | |
26754 | are 64 rather than 32 bits wide. You can select this combination with | |
26755 | @option{-mabi=32} @option{-mfp64}. This ABI relies on the @code{mthc1} | |
26756 | and @code{mfhc1} instructions and is therefore only supported for | |
26757 | MIPS32R2, MIPS32R3 and MIPS32R5 processors. | |
26758 | ||
26759 | The register assignments for arguments and return values remain the | |
26760 | same, but each scalar value is passed in a single 64-bit register | |
26761 | rather than a pair of 32-bit registers. For example, scalar | |
26762 | floating-point values are returned in @samp{$f0} only, not a | |
26763 | @samp{$f0}/@samp{$f1} pair. The set of call-saved registers also | |
26764 | remains the same in that the even-numbered double-precision registers | |
26765 | are saved. | |
26766 | ||
26767 | Two additional variants of the o32 ABI are supported to enable | |
26768 | a transition from 32-bit to 64-bit registers. These are FPXX | |
26769 | (@option{-mfpxx}) and FP64A (@option{-mfp64} @option{-mno-odd-spreg}). | |
26770 | The FPXX extension mandates that all code must execute correctly | |
26771 | when run using 32-bit or 64-bit registers. The code can be interlinked | |
26772 | with either FP32 or FP64, but not both. | |
26773 | The FP64A extension is similar to the FP64 extension but forbids the | |
26774 | use of odd-numbered single-precision registers. This can be used | |
26775 | in conjunction with the @code{FRE} mode of FPUs in MIPS32R5 | |
26776 | processors and allows both FP32 and FP64A code to interlink and | |
26777 | run in the same process without changing FPU modes. | |
26778 | ||
d77de738 ML |
26779 | @opindex mabicalls |
26780 | @opindex mno-abicalls | |
ddf6fe37 AA |
26781 | @item -mabicalls |
26782 | @itemx -mno-abicalls | |
d77de738 ML |
26783 | Generate (do not generate) code that is suitable for SVR4-style |
26784 | dynamic objects. @option{-mabicalls} is the default for SVR4-based | |
26785 | systems. | |
26786 | ||
26787 | @item -mshared | |
26788 | @itemx -mno-shared | |
26789 | Generate (do not generate) code that is fully position-independent, | |
26790 | and that can therefore be linked into shared libraries. This option | |
26791 | only affects @option{-mabicalls}. | |
26792 | ||
26793 | All @option{-mabicalls} code has traditionally been position-independent, | |
26794 | regardless of options like @option{-fPIC} and @option{-fpic}. However, | |
26795 | as an extension, the GNU toolchain allows executables to use absolute | |
26796 | accesses for locally-binding symbols. It can also use shorter GP | |
26797 | initialization sequences and generate direct calls to locally-defined | |
26798 | functions. This mode is selected by @option{-mno-shared}. | |
26799 | ||
26800 | @option{-mno-shared} depends on binutils 2.16 or higher and generates | |
26801 | objects that can only be linked by the GNU linker. However, the option | |
26802 | does not affect the ABI of the final executable; it only affects the ABI | |
26803 | of relocatable objects. Using @option{-mno-shared} generally makes | |
26804 | executables both smaller and quicker. | |
26805 | ||
26806 | @option{-mshared} is the default. | |
26807 | ||
d77de738 ML |
26808 | @opindex mplt |
26809 | @opindex mno-plt | |
ddf6fe37 AA |
26810 | @item -mplt |
26811 | @itemx -mno-plt | |
d77de738 ML |
26812 | Assume (do not assume) that the static and dynamic linkers |
26813 | support PLTs and copy relocations. This option only affects | |
26814 | @option{-mno-shared -mabicalls}. For the n64 ABI, this option | |
26815 | has no effect without @option{-msym32}. | |
26816 | ||
26817 | You can make @option{-mplt} the default by configuring | |
26818 | GCC with @option{--with-mips-plt}. The default is | |
26819 | @option{-mno-plt} otherwise. | |
26820 | ||
d77de738 ML |
26821 | @opindex mxgot |
26822 | @opindex mno-xgot | |
ddf6fe37 AA |
26823 | @item -mxgot |
26824 | @itemx -mno-xgot | |
d77de738 ML |
26825 | Lift (do not lift) the usual restrictions on the size of the global |
26826 | offset table. | |
26827 | ||
26828 | GCC normally uses a single instruction to load values from the GOT@. | |
26829 | While this is relatively efficient, it only works if the GOT | |
26830 | is smaller than about 64k. Anything larger causes the linker | |
26831 | to report an error such as: | |
26832 | ||
26833 | @cindex relocation truncated to fit (MIPS) | |
26834 | @smallexample | |
26835 | relocation truncated to fit: R_MIPS_GOT16 foobar | |
26836 | @end smallexample | |
26837 | ||
26838 | If this happens, you should recompile your code with @option{-mxgot}. | |
26839 | This works with very large GOTs, although the code is also | |
26840 | less efficient, since it takes three instructions to fetch the | |
26841 | value of a global symbol. | |
26842 | ||
26843 | Note that some linkers can create multiple GOTs. If you have such a | |
26844 | linker, you should only need to use @option{-mxgot} when a single object | |
26845 | file accesses more than 64k's worth of GOT entries. Very few do. | |
26846 | ||
26847 | These options have no effect unless GCC is generating position | |
26848 | independent code. | |
26849 | ||
d77de738 | 26850 | @opindex mgp32 |
ddf6fe37 | 26851 | @item -mgp32 |
d77de738 ML |
26852 | Assume that general-purpose registers are 32 bits wide. |
26853 | ||
d77de738 | 26854 | @opindex mgp64 |
ddf6fe37 | 26855 | @item -mgp64 |
d77de738 ML |
26856 | Assume that general-purpose registers are 64 bits wide. |
26857 | ||
d77de738 | 26858 | @opindex mfp32 |
ddf6fe37 | 26859 | @item -mfp32 |
d77de738 ML |
26860 | Assume that floating-point registers are 32 bits wide. |
26861 | ||
d77de738 | 26862 | @opindex mfp64 |
ddf6fe37 | 26863 | @item -mfp64 |
d77de738 ML |
26864 | Assume that floating-point registers are 64 bits wide. |
26865 | ||
d77de738 | 26866 | @opindex mfpxx |
ddf6fe37 | 26867 | @item -mfpxx |
d77de738 ML |
26868 | Do not assume the width of floating-point registers. |
26869 | ||
d77de738 | 26870 | @opindex mhard-float |
ddf6fe37 | 26871 | @item -mhard-float |
d77de738 ML |
26872 | Use floating-point coprocessor instructions. |
26873 | ||
d77de738 | 26874 | @opindex msoft-float |
ddf6fe37 | 26875 | @item -msoft-float |
d77de738 ML |
26876 | Do not use floating-point coprocessor instructions. Implement |
26877 | floating-point calculations using library calls instead. | |
26878 | ||
d77de738 | 26879 | @opindex mno-float |
ddf6fe37 | 26880 | @item -mno-float |
d77de738 ML |
26881 | Equivalent to @option{-msoft-float}, but additionally asserts that the |
26882 | program being compiled does not perform any floating-point operations. | |
26883 | This option is presently supported only by some bare-metal MIPS | |
26884 | configurations, where it may select a special set of libraries | |
26885 | that lack all floating-point support (including, for example, the | |
26886 | floating-point @code{printf} formats). | |
26887 | If code compiled with @option{-mno-float} accidentally contains | |
26888 | floating-point operations, it is likely to suffer a link-time | |
26889 | or run-time failure. | |
26890 | ||
d77de738 | 26891 | @opindex msingle-float |
ddf6fe37 | 26892 | @item -msingle-float |
d77de738 ML |
26893 | Assume that the floating-point coprocessor only supports single-precision |
26894 | operations. | |
26895 | ||
d77de738 | 26896 | @opindex mdouble-float |
ddf6fe37 | 26897 | @item -mdouble-float |
d77de738 ML |
26898 | Assume that the floating-point coprocessor supports double-precision |
26899 | operations. This is the default. | |
26900 | ||
d77de738 ML |
26901 | @opindex modd-spreg |
26902 | @opindex mno-odd-spreg | |
ddf6fe37 AA |
26903 | @item -modd-spreg |
26904 | @itemx -mno-odd-spreg | |
d77de738 ML |
26905 | Enable the use of odd-numbered single-precision floating-point registers |
26906 | for the o32 ABI. This is the default for processors that are known to | |
26907 | support these registers. When using the o32 FPXX ABI, @option{-mno-odd-spreg} | |
26908 | is set by default. | |
26909 | ||
d77de738 ML |
26910 | @opindex mabs=2008 |
26911 | @opindex mabs=legacy | |
ddf6fe37 AA |
26912 | @item -mabs=2008 |
26913 | @itemx -mabs=legacy | |
d77de738 ML |
26914 | These options control the treatment of the special not-a-number (NaN) |
26915 | IEEE 754 floating-point data with the @code{abs.@i{fmt}} and | |
26916 | @code{neg.@i{fmt}} machine instructions. | |
26917 | ||
26918 | By default or when @option{-mabs=legacy} is used the legacy | |
26919 | treatment is selected. In this case these instructions are considered | |
26920 | arithmetic and avoided where correct operation is required and the | |
26921 | input operand might be a NaN. A longer sequence of instructions that | |
26922 | manipulate the sign bit of floating-point datum manually is used | |
26923 | instead unless the @option{-ffinite-math-only} option has also been | |
26924 | specified. | |
26925 | ||
26926 | The @option{-mabs=2008} option selects the IEEE 754-2008 treatment. In | |
26927 | this case these instructions are considered non-arithmetic and therefore | |
26928 | operating correctly in all cases, including in particular where the | |
26929 | input operand is a NaN. These instructions are therefore always used | |
26930 | for the respective operations. | |
26931 | ||
d77de738 ML |
26932 | @opindex mnan=2008 |
26933 | @opindex mnan=legacy | |
ddf6fe37 AA |
26934 | @item -mnan=2008 |
26935 | @itemx -mnan=legacy | |
d77de738 ML |
26936 | These options control the encoding of the special not-a-number (NaN) |
26937 | IEEE 754 floating-point data. | |
26938 | ||
26939 | The @option{-mnan=legacy} option selects the legacy encoding. In this | |
26940 | case quiet NaNs (qNaNs) are denoted by the first bit of their trailing | |
26941 | significand field being 0, whereas signaling NaNs (sNaNs) are denoted | |
26942 | by the first bit of their trailing significand field being 1. | |
26943 | ||
26944 | The @option{-mnan=2008} option selects the IEEE 754-2008 encoding. In | |
26945 | this case qNaNs are denoted by the first bit of their trailing | |
26946 | significand field being 1, whereas sNaNs are denoted by the first bit of | |
26947 | their trailing significand field being 0. | |
26948 | ||
26949 | The default is @option{-mnan=legacy} unless GCC has been configured with | |
26950 | @option{--with-nan=2008}. | |
26951 | ||
d77de738 ML |
26952 | @opindex mllsc |
26953 | @opindex mno-llsc | |
ddf6fe37 AA |
26954 | @item -mllsc |
26955 | @itemx -mno-llsc | |
d77de738 ML |
26956 | Use (do not use) @samp{ll}, @samp{sc}, and @samp{sync} instructions to |
26957 | implement atomic memory built-in functions. When neither option is | |
26958 | specified, GCC uses the instructions if the target architecture | |
26959 | supports them. | |
26960 | ||
26961 | @option{-mllsc} is useful if the runtime environment can emulate the | |
26962 | instructions and @option{-mno-llsc} can be useful when compiling for | |
26963 | nonstandard ISAs. You can make either option the default by | |
26964 | configuring GCC with @option{--with-llsc} and @option{--without-llsc} | |
26965 | respectively. @option{--with-llsc} is the default for some | |
26966 | configurations; see the installation documentation for details. | |
26967 | ||
d77de738 ML |
26968 | @opindex mdsp |
26969 | @opindex mno-dsp | |
ddf6fe37 AA |
26970 | @item -mdsp |
26971 | @itemx -mno-dsp | |
d77de738 ML |
26972 | Use (do not use) revision 1 of the MIPS DSP ASE@. |
26973 | @xref{MIPS DSP Built-in Functions}. This option defines the | |
26974 | preprocessor macro @code{__mips_dsp}. It also defines | |
26975 | @code{__mips_dsp_rev} to 1. | |
26976 | ||
d77de738 ML |
26977 | @opindex mdspr2 |
26978 | @opindex mno-dspr2 | |
ddf6fe37 AA |
26979 | @item -mdspr2 |
26980 | @itemx -mno-dspr2 | |
d77de738 ML |
26981 | Use (do not use) revision 2 of the MIPS DSP ASE@. |
26982 | @xref{MIPS DSP Built-in Functions}. This option defines the | |
26983 | preprocessor macros @code{__mips_dsp} and @code{__mips_dspr2}. | |
26984 | It also defines @code{__mips_dsp_rev} to 2. | |
26985 | ||
d77de738 ML |
26986 | @opindex msmartmips |
26987 | @opindex mno-smartmips | |
ddf6fe37 AA |
26988 | @item -msmartmips |
26989 | @itemx -mno-smartmips | |
d77de738 ML |
26990 | Use (do not use) the MIPS SmartMIPS ASE. |
26991 | ||
d77de738 ML |
26992 | @opindex mpaired-single |
26993 | @opindex mno-paired-single | |
ddf6fe37 AA |
26994 | @item -mpaired-single |
26995 | @itemx -mno-paired-single | |
d77de738 ML |
26996 | Use (do not use) paired-single floating-point instructions. |
26997 | @xref{MIPS Paired-Single Support}. This option requires | |
26998 | hardware floating-point support to be enabled. | |
26999 | ||
d77de738 ML |
27000 | @opindex mdmx |
27001 | @opindex mno-mdmx | |
ddf6fe37 AA |
27002 | @item -mdmx |
27003 | @itemx -mno-mdmx | |
d77de738 ML |
27004 | Use (do not use) MIPS Digital Media Extension instructions. |
27005 | This option can only be used when generating 64-bit code and requires | |
27006 | hardware floating-point support to be enabled. | |
27007 | ||
d77de738 ML |
27008 | @opindex mips3d |
27009 | @opindex mno-mips3d | |
ddf6fe37 AA |
27010 | @item -mips3d |
27011 | @itemx -mno-mips3d | |
d77de738 ML |
27012 | Use (do not use) the MIPS-3D ASE@. @xref{MIPS-3D Built-in Functions}. |
27013 | The option @option{-mips3d} implies @option{-mpaired-single}. | |
27014 | ||
d77de738 ML |
27015 | @opindex mmicromips |
27016 | @opindex mno-mmicromips | |
ddf6fe37 AA |
27017 | @item -mmicromips |
27018 | @itemx -mno-micromips | |
d77de738 ML |
27019 | Generate (do not generate) microMIPS code. |
27020 | ||
27021 | MicroMIPS code generation can also be controlled on a per-function basis | |
27022 | by means of @code{micromips} and @code{nomicromips} attributes. | |
27023 | @xref{Function Attributes}, for more information. | |
27024 | ||
d77de738 ML |
27025 | @opindex mmt |
27026 | @opindex mno-mt | |
ddf6fe37 AA |
27027 | @item -mmt |
27028 | @itemx -mno-mt | |
d77de738 ML |
27029 | Use (do not use) MT Multithreading instructions. |
27030 | ||
d77de738 ML |
27031 | @opindex mmcu |
27032 | @opindex mno-mcu | |
ddf6fe37 AA |
27033 | @item -mmcu |
27034 | @itemx -mno-mcu | |
d77de738 ML |
27035 | Use (do not use) the MIPS MCU ASE instructions. |
27036 | ||
d77de738 ML |
27037 | @opindex meva |
27038 | @opindex mno-eva | |
ddf6fe37 AA |
27039 | @item -meva |
27040 | @itemx -mno-eva | |
d77de738 ML |
27041 | Use (do not use) the MIPS Enhanced Virtual Addressing instructions. |
27042 | ||
d77de738 ML |
27043 | @opindex mvirt |
27044 | @opindex mno-virt | |
ddf6fe37 AA |
27045 | @item -mvirt |
27046 | @itemx -mno-virt | |
d77de738 ML |
27047 | Use (do not use) the MIPS Virtualization (VZ) instructions. |
27048 | ||
d77de738 ML |
27049 | @opindex mxpa |
27050 | @opindex mno-xpa | |
ddf6fe37 AA |
27051 | @item -mxpa |
27052 | @itemx -mno-xpa | |
d77de738 ML |
27053 | Use (do not use) the MIPS eXtended Physical Address (XPA) instructions. |
27054 | ||
d77de738 ML |
27055 | @opindex mcrc |
27056 | @opindex mno-crc | |
ddf6fe37 AA |
27057 | @item -mcrc |
27058 | @itemx -mno-crc | |
d77de738 ML |
27059 | Use (do not use) the MIPS Cyclic Redundancy Check (CRC) instructions. |
27060 | ||
d77de738 ML |
27061 | @opindex mginv |
27062 | @opindex mno-ginv | |
ddf6fe37 AA |
27063 | @item -mginv |
27064 | @itemx -mno-ginv | |
d77de738 ML |
27065 | Use (do not use) the MIPS Global INValidate (GINV) instructions. |
27066 | ||
d77de738 ML |
27067 | @opindex mloongson-mmi |
27068 | @opindex mno-loongson-mmi | |
ddf6fe37 AA |
27069 | @item -mloongson-mmi |
27070 | @itemx -mno-loongson-mmi | |
d77de738 ML |
27071 | Use (do not use) the MIPS Loongson MultiMedia extensions Instructions (MMI). |
27072 | ||
d77de738 ML |
27073 | @opindex mloongson-ext |
27074 | @opindex mno-loongson-ext | |
ddf6fe37 AA |
27075 | @item -mloongson-ext |
27076 | @itemx -mno-loongson-ext | |
d77de738 ML |
27077 | Use (do not use) the MIPS Loongson EXTensions (EXT) instructions. |
27078 | ||
d77de738 ML |
27079 | @opindex mloongson-ext2 |
27080 | @opindex mno-loongson-ext2 | |
ddf6fe37 AA |
27081 | @item -mloongson-ext2 |
27082 | @itemx -mno-loongson-ext2 | |
d77de738 ML |
27083 | Use (do not use) the MIPS Loongson EXTensions r2 (EXT2) instructions. |
27084 | ||
d77de738 | 27085 | @opindex mlong64 |
ddf6fe37 | 27086 | @item -mlong64 |
d77de738 ML |
27087 | Force @code{long} types to be 64 bits wide. See @option{-mlong32} for |
27088 | an explanation of the default and the way that the pointer size is | |
27089 | determined. | |
27090 | ||
d77de738 | 27091 | @opindex mlong32 |
ddf6fe37 | 27092 | @item -mlong32 |
d77de738 ML |
27093 | Force @code{long}, @code{int}, and pointer types to be 32 bits wide. |
27094 | ||
27095 | The default size of @code{int}s, @code{long}s and pointers depends on | |
27096 | the ABI@. All the supported ABIs use 32-bit @code{int}s. The n64 ABI | |
27097 | uses 64-bit @code{long}s, as does the 64-bit EABI; the others use | |
27098 | 32-bit @code{long}s. Pointers are the same size as @code{long}s, | |
27099 | or the same size as integer registers, whichever is smaller. | |
27100 | ||
d77de738 ML |
27101 | @opindex msym32 |
27102 | @opindex mno-sym32 | |
ddf6fe37 AA |
27103 | @item -msym32 |
27104 | @itemx -mno-sym32 | |
d77de738 ML |
27105 | Assume (do not assume) that all symbols have 32-bit values, regardless |
27106 | of the selected ABI@. This option is useful in combination with | |
27107 | @option{-mabi=64} and @option{-mno-abicalls} because it allows GCC | |
27108 | to generate shorter and faster references to symbolic addresses. | |
27109 | ||
d77de738 | 27110 | @opindex G |
ddf6fe37 | 27111 | @item -G @var{num} |
d77de738 ML |
27112 | Put definitions of externally-visible data in a small data section |
27113 | if that data is no bigger than @var{num} bytes. GCC can then generate | |
27114 | more efficient accesses to the data; see @option{-mgpopt} for details. | |
27115 | ||
27116 | The default @option{-G} option depends on the configuration. | |
27117 | ||
d77de738 ML |
27118 | @opindex mlocal-sdata |
27119 | @opindex mno-local-sdata | |
ddf6fe37 AA |
27120 | @item -mlocal-sdata |
27121 | @itemx -mno-local-sdata | |
d77de738 ML |
27122 | Extend (do not extend) the @option{-G} behavior to local data too, |
27123 | such as to static variables in C@. @option{-mlocal-sdata} is the | |
27124 | default for all configurations. | |
27125 | ||
27126 | If the linker complains that an application is using too much small data, | |
27127 | you might want to try rebuilding the less performance-critical parts with | |
27128 | @option{-mno-local-sdata}. You might also want to build large | |
27129 | libraries with @option{-mno-local-sdata}, so that the libraries leave | |
27130 | more room for the main program. | |
27131 | ||
d77de738 ML |
27132 | @opindex mextern-sdata |
27133 | @opindex mno-extern-sdata | |
ddf6fe37 AA |
27134 | @item -mextern-sdata |
27135 | @itemx -mno-extern-sdata | |
d77de738 ML |
27136 | Assume (do not assume) that externally-defined data is in |
27137 | a small data section if the size of that data is within the @option{-G} limit. | |
27138 | @option{-mextern-sdata} is the default for all configurations. | |
27139 | ||
27140 | If you compile a module @var{Mod} with @option{-mextern-sdata} @option{-G | |
27141 | @var{num}} @option{-mgpopt}, and @var{Mod} references a variable @var{Var} | |
27142 | that is no bigger than @var{num} bytes, you must make sure that @var{Var} | |
27143 | is placed in a small data section. If @var{Var} is defined by another | |
27144 | module, you must either compile that module with a high-enough | |
27145 | @option{-G} setting or attach a @code{section} attribute to @var{Var}'s | |
27146 | definition. If @var{Var} is common, you must link the application | |
27147 | with a high-enough @option{-G} setting. | |
27148 | ||
27149 | The easiest way of satisfying these restrictions is to compile | |
27150 | and link every module with the same @option{-G} option. However, | |
27151 | you may wish to build a library that supports several different | |
27152 | small data limits. You can do this by compiling the library with | |
27153 | the highest supported @option{-G} setting and additionally using | |
27154 | @option{-mno-extern-sdata} to stop the library from making assumptions | |
27155 | about externally-defined data. | |
27156 | ||
d77de738 ML |
27157 | @opindex mgpopt |
27158 | @opindex mno-gpopt | |
ddf6fe37 AA |
27159 | @item -mgpopt |
27160 | @itemx -mno-gpopt | |
d77de738 ML |
27161 | Use (do not use) GP-relative accesses for symbols that are known to be |
27162 | in a small data section; see @option{-G}, @option{-mlocal-sdata} and | |
27163 | @option{-mextern-sdata}. @option{-mgpopt} is the default for all | |
27164 | configurations. | |
27165 | ||
27166 | @option{-mno-gpopt} is useful for cases where the @code{$gp} register | |
27167 | might not hold the value of @code{_gp}. For example, if the code is | |
27168 | part of a library that might be used in a boot monitor, programs that | |
27169 | call boot monitor routines pass an unknown value in @code{$gp}. | |
27170 | (In such situations, the boot monitor itself is usually compiled | |
27171 | with @option{-G0}.) | |
27172 | ||
27173 | @option{-mno-gpopt} implies @option{-mno-local-sdata} and | |
27174 | @option{-mno-extern-sdata}. | |
27175 | ||
d77de738 ML |
27176 | @opindex membedded-data |
27177 | @opindex mno-embedded-data | |
ddf6fe37 AA |
27178 | @item -membedded-data |
27179 | @itemx -mno-embedded-data | |
d77de738 ML |
27180 | Allocate variables to the read-only data section first if possible, then |
27181 | next in the small data section if possible, otherwise in data. This gives | |
27182 | slightly slower code than the default, but reduces the amount of RAM required | |
27183 | when executing, and thus may be preferred for some embedded systems. | |
27184 | ||
d77de738 ML |
27185 | @opindex muninit-const-in-rodata |
27186 | @opindex mno-uninit-const-in-rodata | |
ddf6fe37 AA |
27187 | @item -muninit-const-in-rodata |
27188 | @itemx -mno-uninit-const-in-rodata | |
d77de738 ML |
27189 | Put uninitialized @code{const} variables in the read-only data section. |
27190 | This option is only meaningful in conjunction with @option{-membedded-data}. | |
27191 | ||
d77de738 | 27192 | @opindex mcode-readable |
ddf6fe37 | 27193 | @item -mcode-readable=@var{setting} |
d77de738 ML |
27194 | Specify whether GCC may generate code that reads from executable sections. |
27195 | There are three possible settings: | |
27196 | ||
27197 | @table @gcctabopt | |
27198 | @item -mcode-readable=yes | |
27199 | Instructions may freely access executable sections. This is the | |
27200 | default setting. | |
27201 | ||
27202 | @item -mcode-readable=pcrel | |
27203 | MIPS16 PC-relative load instructions can access executable sections, | |
27204 | but other instructions must not do so. This option is useful on 4KSc | |
27205 | and 4KSd processors when the code TLBs have the Read Inhibit bit set. | |
27206 | It is also useful on processors that can be configured to have a dual | |
27207 | instruction/data SRAM interface and that, like the M4K, automatically | |
27208 | redirect PC-relative loads to the instruction RAM. | |
27209 | ||
27210 | @item -mcode-readable=no | |
27211 | Instructions must not access executable sections. This option can be | |
27212 | useful on targets that are configured to have a dual instruction/data | |
27213 | SRAM interface but that (unlike the M4K) do not automatically redirect | |
27214 | PC-relative loads to the instruction RAM. | |
27215 | @end table | |
27216 | ||
d77de738 ML |
27217 | @opindex msplit-addresses |
27218 | @opindex mno-split-addresses | |
ddf6fe37 AA |
27219 | @item -msplit-addresses |
27220 | @itemx -mno-split-addresses | |
d77de738 ML |
27221 | Enable (disable) use of the @code{%hi()} and @code{%lo()} assembler |
27222 | relocation operators. This option has been superseded by | |
27223 | @option{-mexplicit-relocs} but is retained for backwards compatibility. | |
27224 | ||
d77de738 ML |
27225 | @opindex mexplicit-relocs |
27226 | @opindex mno-explicit-relocs | |
ddf6fe37 AA |
27227 | @item -mexplicit-relocs |
27228 | @itemx -mno-explicit-relocs | |
d77de738 ML |
27229 | Use (do not use) assembler relocation operators when dealing with symbolic |
27230 | addresses. The alternative, selected by @option{-mno-explicit-relocs}, | |
27231 | is to use assembler macros instead. | |
27232 | ||
27233 | @option{-mexplicit-relocs} is the default if GCC was configured | |
27234 | to use an assembler that supports relocation operators. | |
27235 | ||
d77de738 ML |
27236 | @opindex mcheck-zero-division |
27237 | @opindex mno-check-zero-division | |
ddf6fe37 AA |
27238 | @item -mcheck-zero-division |
27239 | @itemx -mno-check-zero-division | |
d77de738 ML |
27240 | Trap (do not trap) on integer division by zero. |
27241 | ||
27242 | The default is @option{-mcheck-zero-division}. | |
27243 | ||
d77de738 ML |
27244 | @opindex mdivide-traps |
27245 | @opindex mdivide-breaks | |
ddf6fe37 AA |
27246 | @item -mdivide-traps |
27247 | @itemx -mdivide-breaks | |
d77de738 ML |
27248 | MIPS systems check for division by zero by generating either a |
27249 | conditional trap or a break instruction. Using traps results in | |
27250 | smaller code, but is only supported on MIPS II and later. Also, some | |
27251 | versions of the Linux kernel have a bug that prevents trap from | |
27252 | generating the proper signal (@code{SIGFPE}). Use @option{-mdivide-traps} to | |
27253 | allow conditional traps on architectures that support them and | |
27254 | @option{-mdivide-breaks} to force the use of breaks. | |
27255 | ||
27256 | The default is usually @option{-mdivide-traps}, but this can be | |
27257 | overridden at configure time using @option{--with-divide=breaks}. | |
27258 | Divide-by-zero checks can be completely disabled using | |
27259 | @option{-mno-check-zero-division}. | |
27260 | ||
d77de738 ML |
27261 | @opindex mload-store-pairs |
27262 | @opindex mno-load-store-pairs | |
ddf6fe37 AA |
27263 | @item -mload-store-pairs |
27264 | @itemx -mno-load-store-pairs | |
d77de738 ML |
27265 | Enable (disable) an optimization that pairs consecutive load or store |
27266 | instructions to enable load/store bonding. This option is enabled by | |
27267 | default but only takes effect when the selected architecture is known | |
27268 | to support bonding. | |
27269 | ||
d77de738 ML |
27270 | @opindex munaligned-access |
27271 | @opindex mno-unaligned-access | |
ddf6fe37 AA |
27272 | @item -munaligned-access |
27273 | @itemx -mno-unaligned-access | |
d77de738 ML |
27274 | Enable (disable) direct unaligned access for MIPS Release 6. |
27275 | MIPSr6 requires load/store unaligned-access support, | |
27276 | by hardware or trap&emulate. | |
27277 | So @option{-mno-unaligned-access} may be needed by kernel. | |
27278 | ||
d77de738 ML |
27279 | @opindex mmemcpy |
27280 | @opindex mno-memcpy | |
ddf6fe37 AA |
27281 | @item -mmemcpy |
27282 | @itemx -mno-memcpy | |
d77de738 ML |
27283 | Force (do not force) the use of @code{memcpy} for non-trivial block |
27284 | moves. The default is @option{-mno-memcpy}, which allows GCC to inline | |
27285 | most constant-sized copies. | |
27286 | ||
d77de738 ML |
27287 | @opindex mlong-calls |
27288 | @opindex mno-long-calls | |
ddf6fe37 AA |
27289 | @item -mlong-calls |
27290 | @itemx -mno-long-calls | |
d77de738 ML |
27291 | Disable (do not disable) use of the @code{jal} instruction. Calling |
27292 | functions using @code{jal} is more efficient but requires the caller | |
27293 | and callee to be in the same 256 megabyte segment. | |
27294 | ||
27295 | This option has no effect on abicalls code. The default is | |
27296 | @option{-mno-long-calls}. | |
27297 | ||
d77de738 ML |
27298 | @opindex mmad |
27299 | @opindex mno-mad | |
ddf6fe37 AA |
27300 | @item -mmad |
27301 | @itemx -mno-mad | |
d77de738 ML |
27302 | Enable (disable) use of the @code{mad}, @code{madu} and @code{mul} |
27303 | instructions, as provided by the R4650 ISA@. | |
27304 | ||
d77de738 ML |
27305 | @opindex mimadd |
27306 | @opindex mno-imadd | |
ddf6fe37 AA |
27307 | @item -mimadd |
27308 | @itemx -mno-imadd | |
d77de738 ML |
27309 | Enable (disable) use of the @code{madd} and @code{msub} integer |
27310 | instructions. The default is @option{-mimadd} on architectures | |
27311 | that support @code{madd} and @code{msub} except for the 74k | |
27312 | architecture where it was found to generate slower code. | |
27313 | ||
d77de738 ML |
27314 | @opindex mfused-madd |
27315 | @opindex mno-fused-madd | |
ddf6fe37 AA |
27316 | @item -mfused-madd |
27317 | @itemx -mno-fused-madd | |
d77de738 ML |
27318 | Enable (disable) use of the floating-point multiply-accumulate |
27319 | instructions, when they are available. The default is | |
27320 | @option{-mfused-madd}. | |
27321 | ||
27322 | On the R8000 CPU when multiply-accumulate instructions are used, | |
27323 | the intermediate product is calculated to infinite precision | |
27324 | and is not subject to the FCSR Flush to Zero bit. This may be | |
27325 | undesirable in some circumstances. On other processors the result | |
27326 | is numerically identical to the equivalent computation using | |
27327 | separate multiply, add, subtract and negate instructions. | |
27328 | ||
d77de738 | 27329 | @opindex nocpp |
ddf6fe37 | 27330 | @item -nocpp |
d77de738 ML |
27331 | Tell the MIPS assembler to not run its preprocessor over user |
27332 | assembler files (with a @samp{.s} suffix) when assembling them. | |
27333 | ||
d77de738 ML |
27334 | @opindex mfix-24k |
27335 | @opindex mno-fix-24k | |
ddf6fe37 AA |
27336 | @item -mfix-24k |
27337 | @itemx -mno-fix-24k | |
d77de738 ML |
27338 | Work around the 24K E48 (lost data on stores during refill) errata. |
27339 | The workarounds are implemented by the assembler rather than by GCC@. | |
27340 | ||
d77de738 ML |
27341 | @opindex mfix-r4000 |
27342 | @opindex mno-fix-r4000 | |
ddf6fe37 AA |
27343 | @item -mfix-r4000 |
27344 | @itemx -mno-fix-r4000 | |
d77de738 ML |
27345 | Work around certain R4000 CPU errata: |
27346 | @itemize @minus | |
27347 | @item | |
27348 | A double-word or a variable shift may give an incorrect result if executed | |
27349 | immediately after starting an integer division. | |
27350 | @item | |
27351 | A double-word or a variable shift may give an incorrect result if executed | |
27352 | while an integer multiplication is in progress. | |
27353 | @item | |
27354 | An integer division may give an incorrect result if started in a delay slot | |
27355 | of a taken branch or a jump. | |
27356 | @end itemize | |
27357 | ||
d77de738 ML |
27358 | @opindex mfix-r4400 |
27359 | @opindex mno-fix-r4400 | |
ddf6fe37 AA |
27360 | @item -mfix-r4400 |
27361 | @itemx -mno-fix-r4400 | |
d77de738 ML |
27362 | Work around certain R4400 CPU errata: |
27363 | @itemize @minus | |
27364 | @item | |
27365 | A double-word or a variable shift may give an incorrect result if executed | |
27366 | immediately after starting an integer division. | |
27367 | @end itemize | |
27368 | ||
d77de738 ML |
27369 | @opindex mfix-r10000 |
27370 | @opindex mno-fix-r10000 | |
ddf6fe37 AA |
27371 | @item -mfix-r10000 |
27372 | @itemx -mno-fix-r10000 | |
d77de738 ML |
27373 | Work around certain R10000 errata: |
27374 | @itemize @minus | |
27375 | @item | |
27376 | @code{ll}/@code{sc} sequences may not behave atomically on revisions | |
27377 | prior to 3.0. They may deadlock on revisions 2.6 and earlier. | |
27378 | @end itemize | |
27379 | ||
27380 | This option can only be used if the target architecture supports | |
27381 | branch-likely instructions. @option{-mfix-r10000} is the default when | |
27382 | @option{-march=r10000} is used; @option{-mno-fix-r10000} is the default | |
27383 | otherwise. | |
27384 | ||
ddf6fe37 | 27385 | @opindex mfix-r5900 |
d77de738 ML |
27386 | @item -mfix-r5900 |
27387 | @itemx -mno-fix-r5900 | |
d77de738 ML |
27388 | Do not attempt to schedule the preceding instruction into the delay slot |
27389 | of a branch instruction placed at the end of a short loop of six | |
27390 | instructions or fewer and always schedule a @code{nop} instruction there | |
27391 | instead. The short loop bug under certain conditions causes loops to | |
27392 | execute only once or twice, due to a hardware bug in the R5900 chip. The | |
27393 | workaround is implemented by the assembler rather than by GCC@. | |
27394 | ||
ddf6fe37 | 27395 | @opindex mfix-rm7000 |
d77de738 ML |
27396 | @item -mfix-rm7000 |
27397 | @itemx -mno-fix-rm7000 | |
d77de738 ML |
27398 | Work around the RM7000 @code{dmult}/@code{dmultu} errata. The |
27399 | workarounds are implemented by the assembler rather than by GCC@. | |
27400 | ||
ddf6fe37 | 27401 | @opindex mfix-vr4120 |
d77de738 ML |
27402 | @item -mfix-vr4120 |
27403 | @itemx -mno-fix-vr4120 | |
d77de738 ML |
27404 | Work around certain VR4120 errata: |
27405 | @itemize @minus | |
27406 | @item | |
27407 | @code{dmultu} does not always produce the correct result. | |
27408 | @item | |
27409 | @code{div} and @code{ddiv} do not always produce the correct result if one | |
27410 | of the operands is negative. | |
27411 | @end itemize | |
27412 | The workarounds for the division errata rely on special functions in | |
27413 | @file{libgcc.a}. At present, these functions are only provided by | |
27414 | the @code{mips64vr*-elf} configurations. | |
27415 | ||
27416 | Other VR4120 errata require a NOP to be inserted between certain pairs of | |
27417 | instructions. These errata are handled by the assembler, not by GCC itself. | |
27418 | ||
d77de738 | 27419 | @opindex mfix-vr4130 |
ddf6fe37 | 27420 | @item -mfix-vr4130 |
d77de738 ML |
27421 | Work around the VR4130 @code{mflo}/@code{mfhi} errata. The |
27422 | workarounds are implemented by the assembler rather than by GCC, | |
27423 | although GCC avoids using @code{mflo} and @code{mfhi} if the | |
27424 | VR4130 @code{macc}, @code{macchi}, @code{dmacc} and @code{dmacchi} | |
27425 | instructions are available instead. | |
27426 | ||
ddf6fe37 | 27427 | @opindex mfix-sb1 |
d77de738 ML |
27428 | @item -mfix-sb1 |
27429 | @itemx -mno-fix-sb1 | |
d77de738 ML |
27430 | Work around certain SB-1 CPU core errata. |
27431 | (This flag currently works around the SB-1 revision 2 | |
27432 | ``F1'' and ``F2'' floating-point errata.) | |
27433 | ||
d77de738 | 27434 | @opindex mr10k-cache-barrier |
ddf6fe37 | 27435 | @item -mr10k-cache-barrier=@var{setting} |
d77de738 ML |
27436 | Specify whether GCC should insert cache barriers to avoid the |
27437 | side effects of speculation on R10K processors. | |
27438 | ||
27439 | In common with many processors, the R10K tries to predict the outcome | |
27440 | of a conditional branch and speculatively executes instructions from | |
27441 | the ``taken'' branch. It later aborts these instructions if the | |
27442 | predicted outcome is wrong. However, on the R10K, even aborted | |
27443 | instructions can have side effects. | |
27444 | ||
27445 | This problem only affects kernel stores and, depending on the system, | |
27446 | kernel loads. As an example, a speculatively-executed store may load | |
27447 | the target memory into cache and mark the cache line as dirty, even if | |
27448 | the store itself is later aborted. If a DMA operation writes to the | |
27449 | same area of memory before the ``dirty'' line is flushed, the cached | |
27450 | data overwrites the DMA-ed data. See the R10K processor manual | |
27451 | for a full description, including other potential problems. | |
27452 | ||
27453 | One workaround is to insert cache barrier instructions before every memory | |
27454 | access that might be speculatively executed and that might have side | |
27455 | effects even if aborted. @option{-mr10k-cache-barrier=@var{setting}} | |
27456 | controls GCC's implementation of this workaround. It assumes that | |
27457 | aborted accesses to any byte in the following regions does not have | |
27458 | side effects: | |
27459 | ||
27460 | @enumerate | |
27461 | @item | |
27462 | the memory occupied by the current function's stack frame; | |
27463 | ||
27464 | @item | |
27465 | the memory occupied by an incoming stack argument; | |
27466 | ||
27467 | @item | |
27468 | the memory occupied by an object with a link-time-constant address. | |
27469 | @end enumerate | |
27470 | ||
27471 | It is the kernel's responsibility to ensure that speculative | |
27472 | accesses to these regions are indeed safe. | |
27473 | ||
27474 | If the input program contains a function declaration such as: | |
27475 | ||
27476 | @smallexample | |
27477 | void foo (void); | |
27478 | @end smallexample | |
27479 | ||
27480 | then the implementation of @code{foo} must allow @code{j foo} and | |
27481 | @code{jal foo} to be executed speculatively. GCC honors this | |
27482 | restriction for functions it compiles itself. It expects non-GCC | |
27483 | functions (such as hand-written assembly code) to do the same. | |
27484 | ||
27485 | The option has three forms: | |
27486 | ||
27487 | @table @gcctabopt | |
27488 | @item -mr10k-cache-barrier=load-store | |
27489 | Insert a cache barrier before a load or store that might be | |
27490 | speculatively executed and that might have side effects even | |
27491 | if aborted. | |
27492 | ||
27493 | @item -mr10k-cache-barrier=store | |
27494 | Insert a cache barrier before a store that might be speculatively | |
27495 | executed and that might have side effects even if aborted. | |
27496 | ||
27497 | @item -mr10k-cache-barrier=none | |
27498 | Disable the insertion of cache barriers. This is the default setting. | |
27499 | @end table | |
27500 | ||
ddf6fe37 | 27501 | @opindex mflush-func |
d77de738 ML |
27502 | @item -mflush-func=@var{func} |
27503 | @itemx -mno-flush-func | |
d77de738 ML |
27504 | Specifies the function to call to flush the I and D caches, or to not |
27505 | call any such function. If called, the function must take the same | |
27506 | arguments as the common @code{_flush_func}, that is, the address of the | |
27507 | memory range for which the cache is being flushed, the size of the | |
27508 | memory range, and the number 3 (to flush both caches). The default | |
27509 | depends on the target GCC was configured for, but commonly is either | |
27510 | @code{_flush_func} or @code{__cpu_flush}. | |
27511 | ||
d77de738 | 27512 | @opindex mbranch-cost |
ddf6fe37 | 27513 | @item mbranch-cost=@var{num} |
d77de738 ML |
27514 | Set the cost of branches to roughly @var{num} ``simple'' instructions. |
27515 | This cost is only a heuristic and is not guaranteed to produce | |
27516 | consistent results across releases. A zero cost redundantly selects | |
27517 | the default, which is based on the @option{-mtune} setting. | |
27518 | ||
d77de738 ML |
27519 | @opindex mbranch-likely |
27520 | @opindex mno-branch-likely | |
ddf6fe37 AA |
27521 | @item -mbranch-likely |
27522 | @itemx -mno-branch-likely | |
d77de738 ML |
27523 | Enable or disable use of Branch Likely instructions, regardless of the |
27524 | default for the selected architecture. By default, Branch Likely | |
27525 | instructions may be generated if they are supported by the selected | |
27526 | architecture. An exception is for the MIPS32 and MIPS64 architectures | |
27527 | and processors that implement those architectures; for those, Branch | |
27528 | Likely instructions are not be generated by default because the MIPS32 | |
27529 | and MIPS64 architectures specifically deprecate their use. | |
27530 | ||
d77de738 ML |
27531 | @opindex mcompact-branches=never |
27532 | @opindex mcompact-branches=optimal | |
27533 | @opindex mcompact-branches=always | |
ddf6fe37 AA |
27534 | @item -mcompact-branches=never |
27535 | @itemx -mcompact-branches=optimal | |
27536 | @itemx -mcompact-branches=always | |
d77de738 ML |
27537 | These options control which form of branches will be generated. The |
27538 | default is @option{-mcompact-branches=optimal}. | |
27539 | ||
27540 | The @option{-mcompact-branches=never} option ensures that compact branch | |
27541 | instructions will never be generated. | |
27542 | ||
27543 | The @option{-mcompact-branches=always} option ensures that a compact | |
27544 | branch instruction will be generated if available for MIPS Release 6 onwards. | |
27545 | If a compact branch instruction is not available (or pre-R6), | |
27546 | a delay slot form of the branch will be used instead. | |
27547 | ||
27548 | If it is used for MIPS16/microMIPS targets, it will be just ignored now. | |
27549 | The behaviour for MIPS16/microMIPS may change in future, | |
27550 | since they do have some compact branch instructions. | |
27551 | ||
27552 | The @option{-mcompact-branches=optimal} option will cause a delay slot | |
27553 | branch to be used if one is available in the current ISA and the delay | |
27554 | slot is successfully filled. If the delay slot is not filled, a compact | |
27555 | branch will be chosen if one is available. | |
27556 | ||
ddf6fe37 | 27557 | @opindex mfp-exceptions |
d77de738 ML |
27558 | @item -mfp-exceptions |
27559 | @itemx -mno-fp-exceptions | |
d77de738 ML |
27560 | Specifies whether FP exceptions are enabled. This affects how |
27561 | FP instructions are scheduled for some processors. | |
27562 | The default is that FP exceptions are | |
27563 | enabled. | |
27564 | ||
27565 | For instance, on the SB-1, if FP exceptions are disabled, and we are emitting | |
27566 | 64-bit code, then we can use both FP pipes. Otherwise, we can only use one | |
27567 | FP pipe. | |
27568 | ||
ddf6fe37 | 27569 | @opindex mvr4130-align |
d77de738 ML |
27570 | @item -mvr4130-align |
27571 | @itemx -mno-vr4130-align | |
d77de738 ML |
27572 | The VR4130 pipeline is two-way superscalar, but can only issue two |
27573 | instructions together if the first one is 8-byte aligned. When this | |
27574 | option is enabled, GCC aligns pairs of instructions that it | |
27575 | thinks should execute in parallel. | |
27576 | ||
27577 | This option only has an effect when optimizing for the VR4130. | |
27578 | It normally makes code faster, but at the expense of making it bigger. | |
27579 | It is enabled by default at optimization level @option{-O3}. | |
27580 | ||
ddf6fe37 | 27581 | @opindex msynci |
d77de738 ML |
27582 | @item -msynci |
27583 | @itemx -mno-synci | |
d77de738 ML |
27584 | Enable (disable) generation of @code{synci} instructions on |
27585 | architectures that support it. The @code{synci} instructions (if | |
27586 | enabled) are generated when @code{__builtin___clear_cache} is | |
27587 | compiled. | |
27588 | ||
27589 | This option defaults to @option{-mno-synci}, but the default can be | |
27590 | overridden by configuring GCC with @option{--with-synci}. | |
27591 | ||
27592 | When compiling code for single processor systems, it is generally safe | |
27593 | to use @code{synci}. However, on many multi-core (SMP) systems, it | |
27594 | does not invalidate the instruction caches on all cores and may lead | |
27595 | to undefined behavior. | |
27596 | ||
ddf6fe37 | 27597 | @opindex mrelax-pic-calls |
d77de738 ML |
27598 | @item -mrelax-pic-calls |
27599 | @itemx -mno-relax-pic-calls | |
d77de738 ML |
27600 | Try to turn PIC calls that are normally dispatched via register |
27601 | @code{$25} into direct calls. This is only possible if the linker can | |
27602 | resolve the destination at link time and if the destination is within | |
27603 | range for a direct call. | |
27604 | ||
27605 | @option{-mrelax-pic-calls} is the default if GCC was configured to use | |
27606 | an assembler and a linker that support the @code{.reloc} assembly | |
27607 | directive and @option{-mexplicit-relocs} is in effect. With | |
27608 | @option{-mno-explicit-relocs}, this optimization can be performed by the | |
27609 | assembler and the linker alone without help from the compiler. | |
27610 | ||
d77de738 ML |
27611 | @opindex mmcount-ra-address |
27612 | @opindex mno-mcount-ra-address | |
ddf6fe37 AA |
27613 | @item -mmcount-ra-address |
27614 | @itemx -mno-mcount-ra-address | |
d77de738 ML |
27615 | Emit (do not emit) code that allows @code{_mcount} to modify the |
27616 | calling function's return address. When enabled, this option extends | |
27617 | the usual @code{_mcount} interface with a new @var{ra-address} | |
27618 | parameter, which has type @code{intptr_t *} and is passed in register | |
27619 | @code{$12}. @code{_mcount} can then modify the return address by | |
27620 | doing both of the following: | |
27621 | @itemize | |
27622 | @item | |
27623 | Returning the new address in register @code{$31}. | |
27624 | @item | |
27625 | Storing the new address in @code{*@var{ra-address}}, | |
27626 | if @var{ra-address} is nonnull. | |
27627 | @end itemize | |
27628 | ||
27629 | The default is @option{-mno-mcount-ra-address}. | |
27630 | ||
ddf6fe37 | 27631 | @opindex mframe-header-opt |
d77de738 ML |
27632 | @item -mframe-header-opt |
27633 | @itemx -mno-frame-header-opt | |
d77de738 ML |
27634 | Enable (disable) frame header optimization in the o32 ABI. When using the |
27635 | o32 ABI, calling functions will allocate 16 bytes on the stack for the called | |
27636 | function to write out register arguments. When enabled, this optimization | |
27637 | will suppress the allocation of the frame header if it can be determined that | |
27638 | it is unused. | |
27639 | ||
27640 | This optimization is off by default at all optimization levels. | |
27641 | ||
ddf6fe37 | 27642 | @opindex mlxc1-sxc1 |
d77de738 ML |
27643 | @item -mlxc1-sxc1 |
27644 | @itemx -mno-lxc1-sxc1 | |
d77de738 ML |
27645 | When applicable, enable (disable) the generation of @code{lwxc1}, |
27646 | @code{swxc1}, @code{ldxc1}, @code{sdxc1} instructions. Enabled by default. | |
27647 | ||
ddf6fe37 | 27648 | @opindex mmadd4 |
d77de738 ML |
27649 | @item -mmadd4 |
27650 | @itemx -mno-madd4 | |
d77de738 ML |
27651 | When applicable, enable (disable) the generation of 4-operand @code{madd.s}, |
27652 | @code{madd.d} and related instructions. Enabled by default. | |
27653 | ||
27654 | @end table | |
27655 | ||
27656 | @node MMIX Options | |
27657 | @subsection MMIX Options | |
27658 | @cindex MMIX Options | |
27659 | ||
27660 | These options are defined for the MMIX: | |
27661 | ||
27662 | @table @gcctabopt | |
d77de738 ML |
27663 | @opindex mlibfuncs |
27664 | @opindex mno-libfuncs | |
ddf6fe37 AA |
27665 | @item -mlibfuncs |
27666 | @itemx -mno-libfuncs | |
d77de738 ML |
27667 | Specify that intrinsic library functions are being compiled, passing all |
27668 | values in registers, no matter the size. | |
27669 | ||
d77de738 ML |
27670 | @opindex mepsilon |
27671 | @opindex mno-epsilon | |
ddf6fe37 AA |
27672 | @item -mepsilon |
27673 | @itemx -mno-epsilon | |
d77de738 ML |
27674 | Generate floating-point comparison instructions that compare with respect |
27675 | to the @code{rE} epsilon register. | |
27676 | ||
d77de738 ML |
27677 | @opindex mabi=mmixware |
27678 | @opindex mabi=gnu | |
ddf6fe37 AA |
27679 | @item -mabi=mmixware |
27680 | @itemx -mabi=gnu | |
d77de738 ML |
27681 | Generate code that passes function parameters and return values that (in |
27682 | the called function) are seen as registers @code{$0} and up, as opposed to | |
27683 | the GNU ABI which uses global registers @code{$231} and up. | |
27684 | ||
d77de738 ML |
27685 | @opindex mzero-extend |
27686 | @opindex mno-zero-extend | |
ddf6fe37 AA |
27687 | @item -mzero-extend |
27688 | @itemx -mno-zero-extend | |
d77de738 ML |
27689 | When reading data from memory in sizes shorter than 64 bits, use (do not |
27690 | use) zero-extending load instructions by default, rather than | |
27691 | sign-extending ones. | |
27692 | ||
d77de738 ML |
27693 | @opindex mknuthdiv |
27694 | @opindex mno-knuthdiv | |
ddf6fe37 AA |
27695 | @item -mknuthdiv |
27696 | @itemx -mno-knuthdiv | |
d77de738 ML |
27697 | Make the result of a division yielding a remainder have the same sign as |
27698 | the divisor. With the default, @option{-mno-knuthdiv}, the sign of the | |
27699 | remainder follows the sign of the dividend. Both methods are | |
27700 | arithmetically valid, the latter being almost exclusively used. | |
27701 | ||
d77de738 ML |
27702 | @opindex mtoplevel-symbols |
27703 | @opindex mno-toplevel-symbols | |
ddf6fe37 AA |
27704 | @item -mtoplevel-symbols |
27705 | @itemx -mno-toplevel-symbols | |
d77de738 ML |
27706 | Prepend (do not prepend) a @samp{:} to all global symbols, so the assembly |
27707 | code can be used with the @code{PREFIX} assembly directive. | |
27708 | ||
d77de738 | 27709 | @opindex melf |
ddf6fe37 | 27710 | @item -melf |
d77de738 ML |
27711 | Generate an executable in the ELF format, rather than the default |
27712 | @samp{mmo} format used by the @command{mmix} simulator. | |
27713 | ||
d77de738 ML |
27714 | @opindex mbranch-predict |
27715 | @opindex mno-branch-predict | |
ddf6fe37 AA |
27716 | @item -mbranch-predict |
27717 | @itemx -mno-branch-predict | |
d77de738 ML |
27718 | Use (do not use) the probable-branch instructions, when static branch |
27719 | prediction indicates a probable branch. | |
27720 | ||
d77de738 ML |
27721 | @opindex mbase-addresses |
27722 | @opindex mno-base-addresses | |
ddf6fe37 AA |
27723 | @item -mbase-addresses |
27724 | @itemx -mno-base-addresses | |
d77de738 ML |
27725 | Generate (do not generate) code that uses @emph{base addresses}. Using a |
27726 | base address automatically generates a request (handled by the assembler | |
27727 | and the linker) for a constant to be set up in a global register. The | |
27728 | register is used for one or more base address requests within the range 0 | |
27729 | to 255 from the value held in the register. The generally leads to short | |
27730 | and fast code, but the number of different data items that can be | |
27731 | addressed is limited. This means that a program that uses lots of static | |
27732 | data may require @option{-mno-base-addresses}. | |
27733 | ||
d77de738 ML |
27734 | @opindex msingle-exit |
27735 | @opindex mno-single-exit | |
ddf6fe37 AA |
27736 | @item -msingle-exit |
27737 | @itemx -mno-single-exit | |
d77de738 ML |
27738 | Force (do not force) generated code to have a single exit point in each |
27739 | function. | |
27740 | @end table | |
27741 | ||
27742 | @node MN10300 Options | |
27743 | @subsection MN10300 Options | |
27744 | @cindex MN10300 options | |
27745 | ||
27746 | These @option{-m} options are defined for Matsushita MN10300 architectures: | |
27747 | ||
27748 | @table @gcctabopt | |
d77de738 | 27749 | @opindex mmult-bug |
ddf6fe37 | 27750 | @item -mmult-bug |
d77de738 ML |
27751 | Generate code to avoid bugs in the multiply instructions for the MN10300 |
27752 | processors. This is the default. | |
27753 | ||
d77de738 | 27754 | @opindex mno-mult-bug |
ddf6fe37 | 27755 | @item -mno-mult-bug |
d77de738 ML |
27756 | Do not generate code to avoid bugs in the multiply instructions for the |
27757 | MN10300 processors. | |
27758 | ||
d77de738 | 27759 | @opindex mam33 |
ddf6fe37 | 27760 | @item -mam33 |
d77de738 ML |
27761 | Generate code using features specific to the AM33 processor. |
27762 | ||
d77de738 | 27763 | @opindex mno-am33 |
ddf6fe37 | 27764 | @item -mno-am33 |
d77de738 ML |
27765 | Do not generate code using features specific to the AM33 processor. This |
27766 | is the default. | |
27767 | ||
d77de738 | 27768 | @opindex mam33-2 |
ddf6fe37 | 27769 | @item -mam33-2 |
d77de738 ML |
27770 | Generate code using features specific to the AM33/2.0 processor. |
27771 | ||
d77de738 | 27772 | @opindex mam34 |
ddf6fe37 | 27773 | @item -mam34 |
d77de738 ML |
27774 | Generate code using features specific to the AM34 processor. |
27775 | ||
d77de738 | 27776 | @opindex mtune |
ddf6fe37 | 27777 | @item -mtune=@var{cpu-type} |
d77de738 ML |
27778 | Use the timing characteristics of the indicated CPU type when |
27779 | scheduling instructions. This does not change the targeted processor | |
27780 | type. The CPU type must be one of @samp{mn10300}, @samp{am33}, | |
27781 | @samp{am33-2} or @samp{am34}. | |
27782 | ||
d77de738 | 27783 | @opindex mreturn-pointer-on-d0 |
ddf6fe37 | 27784 | @item -mreturn-pointer-on-d0 |
d77de738 ML |
27785 | When generating a function that returns a pointer, return the pointer |
27786 | in both @code{a0} and @code{d0}. Otherwise, the pointer is returned | |
27787 | only in @code{a0}, and attempts to call such functions without a prototype | |
27788 | result in errors. Note that this option is on by default; use | |
27789 | @option{-mno-return-pointer-on-d0} to disable it. | |
27790 | ||
d77de738 | 27791 | @opindex mno-crt0 |
ddf6fe37 | 27792 | @item -mno-crt0 |
d77de738 ML |
27793 | Do not link in the C run-time initialization object file. |
27794 | ||
d77de738 | 27795 | @opindex mrelax |
ddf6fe37 | 27796 | @item -mrelax |
d77de738 ML |
27797 | Indicate to the linker that it should perform a relaxation optimization pass |
27798 | to shorten branches, calls and absolute memory addresses. This option only | |
27799 | has an effect when used on the command line for the final link step. | |
27800 | ||
27801 | This option makes symbolic debugging impossible. | |
27802 | ||
d77de738 | 27803 | @opindex mliw |
ddf6fe37 | 27804 | @item -mliw |
d77de738 ML |
27805 | Allow the compiler to generate @emph{Long Instruction Word} |
27806 | instructions if the target is the @samp{AM33} or later. This is the | |
27807 | default. This option defines the preprocessor macro @code{__LIW__}. | |
27808 | ||
d77de738 | 27809 | @opindex mno-liw |
ddf6fe37 | 27810 | @item -mno-liw |
d77de738 ML |
27811 | Do not allow the compiler to generate @emph{Long Instruction Word} |
27812 | instructions. This option defines the preprocessor macro | |
27813 | @code{__NO_LIW__}. | |
27814 | ||
d77de738 | 27815 | @opindex msetlb |
ddf6fe37 | 27816 | @item -msetlb |
d77de738 ML |
27817 | Allow the compiler to generate the @emph{SETLB} and @emph{Lcc} |
27818 | instructions if the target is the @samp{AM33} or later. This is the | |
27819 | default. This option defines the preprocessor macro @code{__SETLB__}. | |
27820 | ||
d77de738 | 27821 | @opindex mno-setlb |
ddf6fe37 | 27822 | @item -mno-setlb |
d77de738 ML |
27823 | Do not allow the compiler to generate @emph{SETLB} or @emph{Lcc} |
27824 | instructions. This option defines the preprocessor macro | |
27825 | @code{__NO_SETLB__}. | |
27826 | ||
27827 | @end table | |
27828 | ||
27829 | @node Moxie Options | |
27830 | @subsection Moxie Options | |
27831 | @cindex Moxie Options | |
27832 | ||
27833 | @table @gcctabopt | |
27834 | ||
d77de738 | 27835 | @opindex meb |
ddf6fe37 | 27836 | @item -meb |
d77de738 ML |
27837 | Generate big-endian code. This is the default for @samp{moxie-*-*} |
27838 | configurations. | |
27839 | ||
d77de738 | 27840 | @opindex mel |
ddf6fe37 | 27841 | @item -mel |
d77de738 ML |
27842 | Generate little-endian code. |
27843 | ||
d77de738 | 27844 | @opindex mmul.x |
ddf6fe37 | 27845 | @item -mmul.x |
d77de738 ML |
27846 | Generate mul.x and umul.x instructions. This is the default for |
27847 | @samp{moxiebox-*-*} configurations. | |
27848 | ||
d77de738 | 27849 | @opindex mno-crt0 |
ddf6fe37 | 27850 | @item -mno-crt0 |
d77de738 ML |
27851 | Do not link in the C run-time initialization object file. |
27852 | ||
27853 | @end table | |
27854 | ||
27855 | @node MSP430 Options | |
27856 | @subsection MSP430 Options | |
27857 | @cindex MSP430 Options | |
27858 | ||
27859 | These options are defined for the MSP430: | |
27860 | ||
27861 | @table @gcctabopt | |
27862 | ||
d77de738 | 27863 | @opindex masm-hex |
ddf6fe37 | 27864 | @item -masm-hex |
d77de738 ML |
27865 | Force assembly output to always use hex constants. Normally such |
27866 | constants are signed decimals, but this option is available for | |
27867 | testsuite and/or aesthetic purposes. | |
27868 | ||
d77de738 | 27869 | @opindex mmcu= |
ddf6fe37 | 27870 | @item -mmcu= |
d77de738 ML |
27871 | Select the MCU to target. This is used to create a C preprocessor |
27872 | symbol based upon the MCU name, converted to upper case and pre- and | |
27873 | post-fixed with @samp{__}. This in turn is used by the | |
27874 | @file{msp430.h} header file to select an MCU-specific supplementary | |
27875 | header file. | |
27876 | ||
27877 | The option also sets the ISA to use. If the MCU name is one that is | |
27878 | known to only support the 430 ISA then that is selected, otherwise the | |
27879 | 430X ISA is selected. A generic MCU name of @samp{msp430} can also be | |
27880 | used to select the 430 ISA. Similarly the generic @samp{msp430x} MCU | |
27881 | name selects the 430X ISA. | |
27882 | ||
27883 | In addition an MCU-specific linker script is added to the linker | |
27884 | command line. The script's name is the name of the MCU with | |
27885 | @file{.ld} appended. Thus specifying @option{-mmcu=xxx} on the @command{gcc} | |
27886 | command line defines the C preprocessor symbol @code{__XXX__} and | |
27887 | cause the linker to search for a script called @file{xxx.ld}. | |
27888 | ||
27889 | The ISA and hardware multiply supported for the different MCUs is hard-coded | |
27890 | into GCC. However, an external @samp{devices.csv} file can be used to | |
27891 | extend device support beyond those that have been hard-coded. | |
27892 | ||
27893 | GCC searches for the @samp{devices.csv} file using the following methods in the | |
27894 | given precedence order, where the first method takes precendence over the | |
27895 | second which takes precedence over the third. | |
27896 | ||
27897 | @table @asis | |
27898 | @item Include path specified with @code{-I} and @code{-L} | |
27899 | @samp{devices.csv} will be searched for in each of the directories specified by | |
27900 | include paths and linker library search paths. | |
27901 | @item Path specified by the environment variable @samp{MSP430_GCC_INCLUDE_DIR} | |
27902 | Define the value of the global environment variable | |
27903 | @samp{MSP430_GCC_INCLUDE_DIR} | |
27904 | to the full path to the directory containing devices.csv, and GCC will search | |
27905 | this directory for devices.csv. If devices.csv is found, this directory will | |
27906 | also be registered as an include path, and linker library path. Header files | |
27907 | and linker scripts in this directory can therefore be used without manually | |
27908 | specifying @code{-I} and @code{-L} on the command line. | |
27909 | @item The @samp{msp430-elf@{,bare@}/include/devices} directory | |
27910 | Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the | |
27911 | toolchain root directory. This directory does not exist in a default | |
27912 | installation, but if the user has created it and copied @samp{devices.csv} | |
27913 | there, then the MCU data will be read. As above, this directory will | |
27914 | also be registered as an include path, and linker library path. | |
27915 | ||
27916 | @end table | |
27917 | If none of the above search methods find @samp{devices.csv}, then the | |
27918 | hard-coded MCU data is used. | |
27919 | ||
27920 | ||
d77de738 ML |
27921 | @opindex mwarn-mcu |
27922 | @opindex mno-warn-mcu | |
ddf6fe37 AA |
27923 | @item -mwarn-mcu |
27924 | @itemx -mno-warn-mcu | |
d77de738 ML |
27925 | This option enables or disables warnings about conflicts between the |
27926 | MCU name specified by the @option{-mmcu} option and the ISA set by the | |
27927 | @option{-mcpu} option and/or the hardware multiply support set by the | |
27928 | @option{-mhwmult} option. It also toggles warnings about unrecognized | |
27929 | MCU names. This option is on by default. | |
27930 | ||
d77de738 | 27931 | @opindex mcpu= |
ddf6fe37 | 27932 | @item -mcpu= |
d77de738 ML |
27933 | Specifies the ISA to use. Accepted values are @samp{msp430}, |
27934 | @samp{msp430x} and @samp{msp430xv2}. This option is deprecated. The | |
27935 | @option{-mmcu=} option should be used to select the ISA. | |
27936 | ||
d77de738 | 27937 | @opindex msim |
ddf6fe37 | 27938 | @item -msim |
d77de738 ML |
27939 | Link to the simulator runtime libraries and linker script. Overrides |
27940 | any scripts that would be selected by the @option{-mmcu=} option. | |
27941 | ||
d77de738 | 27942 | @opindex mlarge |
ddf6fe37 | 27943 | @item -mlarge |
d77de738 ML |
27944 | Use large-model addressing (20-bit pointers, 20-bit @code{size_t}). |
27945 | ||
d77de738 | 27946 | @opindex msmall |
ddf6fe37 | 27947 | @item -msmall |
d77de738 ML |
27948 | Use small-model addressing (16-bit pointers, 16-bit @code{size_t}). |
27949 | ||
d77de738 | 27950 | @opindex mrelax |
ddf6fe37 | 27951 | @item -mrelax |
d77de738 ML |
27952 | This option is passed to the assembler and linker, and allows the |
27953 | linker to perform certain optimizations that cannot be done until | |
27954 | the final link. | |
27955 | ||
d77de738 | 27956 | @opindex mhwmult= |
ddf6fe37 | 27957 | @item mhwmult= |
d77de738 ML |
27958 | Describes the type of hardware multiply supported by the target. |
27959 | Accepted values are @samp{none} for no hardware multiply, @samp{16bit} | |
27960 | for the original 16-bit-only multiply supported by early MCUs. | |
27961 | @samp{32bit} for the 16/32-bit multiply supported by later MCUs and | |
27962 | @samp{f5series} for the 16/32-bit multiply supported by F5-series MCUs. | |
27963 | A value of @samp{auto} can also be given. This tells GCC to deduce | |
27964 | the hardware multiply support based upon the MCU name provided by the | |
27965 | @option{-mmcu} option. If no @option{-mmcu} option is specified or if | |
27966 | the MCU name is not recognized then no hardware multiply support is | |
27967 | assumed. @code{auto} is the default setting. | |
27968 | ||
27969 | Hardware multiplies are normally performed by calling a library | |
27970 | routine. This saves space in the generated code. When compiling at | |
27971 | @option{-O3} or higher however the hardware multiplier is invoked | |
27972 | inline. This makes for bigger, but faster code. | |
27973 | ||
27974 | The hardware multiply routines disable interrupts whilst running and | |
27975 | restore the previous interrupt state when they finish. This makes | |
27976 | them safe to use inside interrupt handlers as well as in normal code. | |
27977 | ||
d77de738 | 27978 | @opindex minrt |
ddf6fe37 | 27979 | @item -minrt |
d77de738 ML |
27980 | Enable the use of a minimum runtime environment - no static |
27981 | initializers or constructors. This is intended for memory-constrained | |
27982 | devices. The compiler includes special symbols in some objects | |
27983 | that tell the linker and runtime which code fragments are required. | |
27984 | ||
d77de738 | 27985 | @opindex mtiny-printf |
ddf6fe37 | 27986 | @item -mtiny-printf |
d77de738 ML |
27987 | Enable reduced code size @code{printf} and @code{puts} library functions. |
27988 | The @samp{tiny} implementations of these functions are not reentrant, so | |
27989 | must be used with caution in multi-threaded applications. | |
27990 | ||
27991 | Support for streams has been removed and the string to be printed will | |
27992 | always be sent to stdout via the @code{write} syscall. The string is not | |
27993 | buffered before it is sent to write. | |
27994 | ||
27995 | This option requires Newlib Nano IO, so GCC must be configured with | |
27996 | @samp{--enable-newlib-nano-formatted-io}. | |
27997 | ||
d77de738 | 27998 | @opindex mmax-inline-shift= |
ddf6fe37 | 27999 | @item -mmax-inline-shift= |
d77de738 ML |
28000 | This option takes an integer between 0 and 64 inclusive, and sets |
28001 | the maximum number of inline shift instructions which should be emitted to | |
28002 | perform a shift operation by a constant amount. When this value needs to be | |
28003 | exceeded, an mspabi helper function is used instead. The default value is 4. | |
28004 | ||
28005 | This only affects cases where a shift by multiple positions cannot be | |
28006 | completed with a single instruction (e.g. all shifts >1 on the 430 ISA). | |
28007 | ||
28008 | Shifts of a 32-bit value are at least twice as costly, so the value passed for | |
28009 | this option is divided by 2 and the resulting value used instead. | |
28010 | ||
d77de738 ML |
28011 | @opindex mcode-region |
28012 | @opindex mdata-region | |
ddf6fe37 AA |
28013 | @item -mcode-region= |
28014 | @itemx -mdata-region= | |
d77de738 ML |
28015 | These options tell the compiler where to place functions and data that |
28016 | do not have one of the @code{lower}, @code{upper}, @code{either} or | |
28017 | @code{section} attributes. Possible values are @code{lower}, | |
28018 | @code{upper}, @code{either} or @code{any}. The first three behave | |
28019 | like the corresponding attribute. The fourth possible value - | |
28020 | @code{any} - is the default. It leaves placement entirely up to the | |
28021 | linker script and how it assigns the standard sections | |
28022 | (@code{.text}, @code{.data}, etc) to the memory regions. | |
28023 | ||
d77de738 | 28024 | @opindex msilicon-errata |
ddf6fe37 | 28025 | @item -msilicon-errata= |
d77de738 ML |
28026 | This option passes on a request to assembler to enable the fixes for |
28027 | the named silicon errata. | |
28028 | ||
d77de738 | 28029 | @opindex msilicon-errata-warn |
ddf6fe37 | 28030 | @item -msilicon-errata-warn= |
d77de738 ML |
28031 | This option passes on a request to the assembler to enable warning |
28032 | messages when a silicon errata might need to be applied. | |
28033 | ||
d77de738 ML |
28034 | @opindex mwarn-devices-csv |
28035 | @opindex mno-warn-devices-csv | |
ddf6fe37 AA |
28036 | @item -mwarn-devices-csv |
28037 | @itemx -mno-warn-devices-csv | |
d77de738 ML |
28038 | Warn if @samp{devices.csv} is not found or there are problem parsing it |
28039 | (default: on). | |
28040 | ||
28041 | @end table | |
28042 | ||
28043 | @node NDS32 Options | |
28044 | @subsection NDS32 Options | |
28045 | @cindex NDS32 Options | |
28046 | ||
28047 | These options are defined for NDS32 implementations: | |
28048 | ||
28049 | @table @gcctabopt | |
28050 | ||
d77de738 | 28051 | @opindex mbig-endian |
ddf6fe37 | 28052 | @item -mbig-endian |
d77de738 ML |
28053 | Generate code in big-endian mode. |
28054 | ||
d77de738 | 28055 | @opindex mlittle-endian |
ddf6fe37 | 28056 | @item -mlittle-endian |
d77de738 ML |
28057 | Generate code in little-endian mode. |
28058 | ||
d77de738 | 28059 | @opindex mreduced-regs |
ddf6fe37 | 28060 | @item -mreduced-regs |
d77de738 ML |
28061 | Use reduced-set registers for register allocation. |
28062 | ||
d77de738 | 28063 | @opindex mfull-regs |
ddf6fe37 | 28064 | @item -mfull-regs |
d77de738 ML |
28065 | Use full-set registers for register allocation. |
28066 | ||
d77de738 | 28067 | @opindex mcmov |
ddf6fe37 | 28068 | @item -mcmov |
d77de738 ML |
28069 | Generate conditional move instructions. |
28070 | ||
d77de738 | 28071 | @opindex mno-cmov |
ddf6fe37 | 28072 | @item -mno-cmov |
d77de738 ML |
28073 | Do not generate conditional move instructions. |
28074 | ||
d77de738 | 28075 | @opindex mext-perf |
ddf6fe37 | 28076 | @item -mext-perf |
d77de738 ML |
28077 | Generate performance extension instructions. |
28078 | ||
d77de738 | 28079 | @opindex mno-ext-perf |
ddf6fe37 | 28080 | @item -mno-ext-perf |
d77de738 ML |
28081 | Do not generate performance extension instructions. |
28082 | ||
d77de738 | 28083 | @opindex mext-perf2 |
ddf6fe37 | 28084 | @item -mext-perf2 |
d77de738 ML |
28085 | Generate performance extension 2 instructions. |
28086 | ||
d77de738 | 28087 | @opindex mno-ext-perf2 |
ddf6fe37 | 28088 | @item -mno-ext-perf2 |
d77de738 ML |
28089 | Do not generate performance extension 2 instructions. |
28090 | ||
d77de738 | 28091 | @opindex mext-string |
ddf6fe37 | 28092 | @item -mext-string |
d77de738 ML |
28093 | Generate string extension instructions. |
28094 | ||
d77de738 | 28095 | @opindex mno-ext-string |
ddf6fe37 | 28096 | @item -mno-ext-string |
d77de738 ML |
28097 | Do not generate string extension instructions. |
28098 | ||
d77de738 | 28099 | @opindex mv3push |
ddf6fe37 | 28100 | @item -mv3push |
d77de738 ML |
28101 | Generate v3 push25/pop25 instructions. |
28102 | ||
d77de738 | 28103 | @opindex mno-v3push |
ddf6fe37 | 28104 | @item -mno-v3push |
d77de738 ML |
28105 | Do not generate v3 push25/pop25 instructions. |
28106 | ||
d77de738 | 28107 | @opindex m16-bit |
ddf6fe37 | 28108 | @item -m16-bit |
d77de738 ML |
28109 | Generate 16-bit instructions. |
28110 | ||
d77de738 | 28111 | @opindex mno-16-bit |
ddf6fe37 | 28112 | @item -mno-16-bit |
d77de738 ML |
28113 | Do not generate 16-bit instructions. |
28114 | ||
d77de738 | 28115 | @opindex misr-vector-size |
ddf6fe37 | 28116 | @item -misr-vector-size=@var{num} |
d77de738 ML |
28117 | Specify the size of each interrupt vector, which must be 4 or 16. |
28118 | ||
d77de738 | 28119 | @opindex mcache-block-size |
ddf6fe37 | 28120 | @item -mcache-block-size=@var{num} |
d77de738 ML |
28121 | Specify the size of each cache block, |
28122 | which must be a power of 2 between 4 and 512. | |
28123 | ||
d77de738 | 28124 | @opindex march |
ddf6fe37 | 28125 | @item -march=@var{arch} |
d77de738 ML |
28126 | Specify the name of the target architecture. |
28127 | ||
d77de738 | 28128 | @opindex mcmodel |
ddf6fe37 | 28129 | @item -mcmodel=@var{code-model} |
d77de738 ML |
28130 | Set the code model to one of |
28131 | @table @asis | |
28132 | @item @samp{small} | |
28133 | All the data and read-only data segments must be within 512KB addressing space. | |
28134 | The text segment must be within 16MB addressing space. | |
28135 | @item @samp{medium} | |
28136 | The data segment must be within 512KB while the read-only data segment can be | |
28137 | within 4GB addressing space. The text segment should be still within 16MB | |
28138 | addressing space. | |
28139 | @item @samp{large} | |
28140 | All the text and data segments can be within 4GB addressing space. | |
28141 | @end table | |
28142 | ||
d77de738 | 28143 | @opindex mctor-dtor |
ddf6fe37 | 28144 | @item -mctor-dtor |
d77de738 ML |
28145 | Enable constructor/destructor feature. |
28146 | ||
d77de738 | 28147 | @opindex mrelax |
ddf6fe37 | 28148 | @item -mrelax |
d77de738 ML |
28149 | Guide linker to relax instructions. |
28150 | ||
28151 | @end table | |
28152 | ||
28153 | @node Nios II Options | |
28154 | @subsection Nios II Options | |
28155 | @cindex Nios II options | |
28156 | @cindex Altera Nios II options | |
28157 | ||
28158 | These are the options defined for the Altera Nios II processor. | |
28159 | ||
28160 | @table @gcctabopt | |
28161 | ||
d77de738 ML |
28162 | @opindex G |
28163 | @cindex smaller data references | |
f33d7a88 | 28164 | @item -G @var{num} |
d77de738 ML |
28165 | Put global and static objects less than or equal to @var{num} bytes |
28166 | into the small data or BSS sections instead of the normal data or BSS | |
28167 | sections. The default value of @var{num} is 8. | |
28168 | ||
ddf6fe37 AA |
28169 | @opindex mgpopt |
28170 | @opindex mno-gpopt | |
d77de738 ML |
28171 | @item -mgpopt=@var{option} |
28172 | @itemx -mgpopt | |
28173 | @itemx -mno-gpopt | |
d77de738 ML |
28174 | Generate (do not generate) GP-relative accesses. The following |
28175 | @var{option} names are recognized: | |
28176 | ||
28177 | @table @samp | |
28178 | ||
28179 | @item none | |
28180 | Do not generate GP-relative accesses. | |
28181 | ||
28182 | @item local | |
28183 | Generate GP-relative accesses for small data objects that are not | |
28184 | external, weak, or uninitialized common symbols. | |
28185 | Also use GP-relative addressing for objects that | |
28186 | have been explicitly placed in a small data section via a @code{section} | |
28187 | attribute. | |
28188 | ||
28189 | @item global | |
28190 | As for @samp{local}, but also generate GP-relative accesses for | |
28191 | small data objects that are external, weak, or common. If you use this option, | |
28192 | you must ensure that all parts of your program (including libraries) are | |
28193 | compiled with the same @option{-G} setting. | |
28194 | ||
28195 | @item data | |
28196 | Generate GP-relative accesses for all data objects in the program. If you | |
28197 | use this option, the entire data and BSS segments | |
28198 | of your program must fit in 64K of memory and you must use an appropriate | |
28199 | linker script to allocate them within the addressable range of the | |
28200 | global pointer. | |
28201 | ||
28202 | @item all | |
28203 | Generate GP-relative addresses for function pointers as well as data | |
28204 | pointers. If you use this option, the entire text, data, and BSS segments | |
28205 | of your program must fit in 64K of memory and you must use an appropriate | |
28206 | linker script to allocate them within the addressable range of the | |
28207 | global pointer. | |
28208 | ||
28209 | @end table | |
28210 | ||
28211 | @option{-mgpopt} is equivalent to @option{-mgpopt=local}, and | |
28212 | @option{-mno-gpopt} is equivalent to @option{-mgpopt=none}. | |
28213 | ||
28214 | The default is @option{-mgpopt} except when @option{-fpic} or | |
28215 | @option{-fPIC} is specified to generate position-independent code. | |
28216 | Note that the Nios II ABI does not permit GP-relative accesses from | |
28217 | shared libraries. | |
28218 | ||
28219 | You may need to specify @option{-mno-gpopt} explicitly when building | |
28220 | programs that include large amounts of small data, including large | |
28221 | GOT data sections. In this case, the 16-bit offset for GP-relative | |
28222 | addressing may not be large enough to allow access to the entire | |
28223 | small data section. | |
28224 | ||
d77de738 | 28225 | @opindex mgprel-sec |
ddf6fe37 | 28226 | @item -mgprel-sec=@var{regexp} |
d77de738 ML |
28227 | This option specifies additional section names that can be accessed via |
28228 | GP-relative addressing. It is most useful in conjunction with | |
28229 | @code{section} attributes on variable declarations | |
28230 | (@pxref{Common Variable Attributes}) and a custom linker script. | |
28231 | The @var{regexp} is a POSIX Extended Regular Expression. | |
28232 | ||
28233 | This option does not affect the behavior of the @option{-G} option, and | |
28234 | the specified sections are in addition to the standard @code{.sdata} | |
28235 | and @code{.sbss} small-data sections that are recognized by @option{-mgpopt}. | |
28236 | ||
d77de738 | 28237 | @opindex mr0rel-sec |
ddf6fe37 | 28238 | @item -mr0rel-sec=@var{regexp} |
d77de738 ML |
28239 | This option specifies names of sections that can be accessed via a |
28240 | 16-bit offset from @code{r0}; that is, in the low 32K or high 32K | |
28241 | of the 32-bit address space. It is most useful in conjunction with | |
28242 | @code{section} attributes on variable declarations | |
28243 | (@pxref{Common Variable Attributes}) and a custom linker script. | |
28244 | The @var{regexp} is a POSIX Extended Regular Expression. | |
28245 | ||
28246 | In contrast to the use of GP-relative addressing for small data, | |
28247 | zero-based addressing is never generated by default and there are no | |
28248 | conventional section names used in standard linker scripts for sections | |
28249 | in the low or high areas of memory. | |
28250 | ||
d77de738 ML |
28251 | @opindex mel |
28252 | @opindex meb | |
ddf6fe37 AA |
28253 | @item -mel |
28254 | @itemx -meb | |
d77de738 ML |
28255 | Generate little-endian (default) or big-endian (experimental) code, |
28256 | respectively. | |
28257 | ||
d77de738 | 28258 | @opindex march |
ddf6fe37 | 28259 | @item -march=@var{arch} |
d77de738 ML |
28260 | This specifies the name of the target Nios II architecture. GCC uses this |
28261 | name to determine what kind of instructions it can emit when generating | |
28262 | assembly code. Permissible names are: @samp{r1}, @samp{r2}. | |
28263 | ||
28264 | The preprocessor macro @code{__nios2_arch__} is available to programs, | |
28265 | with value 1 or 2, indicating the targeted ISA level. | |
28266 | ||
d77de738 ML |
28267 | @opindex mno-bypass-cache |
28268 | @opindex mbypass-cache | |
ddf6fe37 AA |
28269 | @item -mbypass-cache |
28270 | @itemx -mno-bypass-cache | |
d77de738 ML |
28271 | Force all load and store instructions to always bypass cache by |
28272 | using I/O variants of the instructions. The default is not to | |
28273 | bypass the cache. | |
28274 | ||
d77de738 ML |
28275 | @opindex mcache-volatile |
28276 | @opindex mno-cache-volatile | |
ddf6fe37 AA |
28277 | @item -mno-cache-volatile |
28278 | @itemx -mcache-volatile | |
d77de738 ML |
28279 | Volatile memory access bypass the cache using the I/O variants of |
28280 | the load and store instructions. The default is not to bypass the cache. | |
28281 | ||
d77de738 ML |
28282 | @opindex mno-fast-sw-div |
28283 | @opindex mfast-sw-div | |
ddf6fe37 AA |
28284 | @item -mno-fast-sw-div |
28285 | @itemx -mfast-sw-div | |
d77de738 ML |
28286 | Do not use table-based fast divide for small numbers. The default |
28287 | is to use the fast divide at @option{-O3} and above. | |
28288 | ||
d77de738 ML |
28289 | @opindex mno-hw-mul |
28290 | @opindex mhw-mul | |
28291 | @opindex mno-hw-mulx | |
28292 | @opindex mhw-mulx | |
28293 | @opindex mno-hw-div | |
28294 | @opindex mhw-div | |
ddf6fe37 AA |
28295 | @item -mno-hw-mul |
28296 | @itemx -mhw-mul | |
28297 | @itemx -mno-hw-mulx | |
28298 | @itemx -mhw-mulx | |
28299 | @itemx -mno-hw-div | |
28300 | @itemx -mhw-div | |
d77de738 ML |
28301 | Enable or disable emitting @code{mul}, @code{mulx} and @code{div} family of |
28302 | instructions by the compiler. The default is to emit @code{mul} | |
28303 | and not emit @code{div} and @code{mulx}. | |
28304 | ||
28305 | @item -mbmx | |
28306 | @itemx -mno-bmx | |
28307 | @itemx -mcdx | |
28308 | @itemx -mno-cdx | |
28309 | Enable or disable generation of Nios II R2 BMX (bit manipulation) and | |
28310 | CDX (code density) instructions. Enabling these instructions also | |
28311 | requires @option{-march=r2}. Since these instructions are optional | |
28312 | extensions to the R2 architecture, the default is not to emit them. | |
28313 | ||
d77de738 ML |
28314 | @opindex mcustom-@var{insn} |
28315 | @opindex mno-custom-@var{insn} | |
ddf6fe37 AA |
28316 | @item -mcustom-@var{insn}=@var{N} |
28317 | @itemx -mno-custom-@var{insn} | |
d77de738 ML |
28318 | Each @option{-mcustom-@var{insn}=@var{N}} option enables use of a |
28319 | custom instruction with encoding @var{N} when generating code that uses | |
28320 | @var{insn}. For example, @option{-mcustom-fadds=253} generates custom | |
28321 | instruction 253 for single-precision floating-point add operations instead | |
28322 | of the default behavior of using a library call. | |
28323 | ||
28324 | The following values of @var{insn} are supported. Except as otherwise | |
28325 | noted, floating-point operations are expected to be implemented with | |
28326 | normal IEEE 754 semantics and correspond directly to the C operators or the | |
28327 | equivalent GCC built-in functions (@pxref{Other Builtins}). | |
28328 | ||
28329 | Single-precision floating point: | |
28330 | @table @asis | |
28331 | ||
28332 | @item @samp{fadds}, @samp{fsubs}, @samp{fdivs}, @samp{fmuls} | |
28333 | Binary arithmetic operations. | |
28334 | ||
28335 | @item @samp{fnegs} | |
28336 | Unary negation. | |
28337 | ||
28338 | @item @samp{fabss} | |
28339 | Unary absolute value. | |
28340 | ||
28341 | @item @samp{fcmpeqs}, @samp{fcmpges}, @samp{fcmpgts}, @samp{fcmples}, @samp{fcmplts}, @samp{fcmpnes} | |
28342 | Comparison operations. | |
28343 | ||
28344 | @item @samp{fmins}, @samp{fmaxs} | |
28345 | Floating-point minimum and maximum. These instructions are only | |
28346 | generated if @option{-ffinite-math-only} is specified. | |
28347 | ||
28348 | @item @samp{fsqrts} | |
28349 | Unary square root operation. | |
28350 | ||
28351 | @item @samp{fcoss}, @samp{fsins}, @samp{ftans}, @samp{fatans}, @samp{fexps}, @samp{flogs} | |
28352 | Floating-point trigonometric and exponential functions. These instructions | |
28353 | are only generated if @option{-funsafe-math-optimizations} is also specified. | |
28354 | ||
28355 | @end table | |
28356 | ||
28357 | Double-precision floating point: | |
28358 | @table @asis | |
28359 | ||
28360 | @item @samp{faddd}, @samp{fsubd}, @samp{fdivd}, @samp{fmuld} | |
28361 | Binary arithmetic operations. | |
28362 | ||
28363 | @item @samp{fnegd} | |
28364 | Unary negation. | |
28365 | ||
28366 | @item @samp{fabsd} | |
28367 | Unary absolute value. | |
28368 | ||
28369 | @item @samp{fcmpeqd}, @samp{fcmpged}, @samp{fcmpgtd}, @samp{fcmpled}, @samp{fcmpltd}, @samp{fcmpned} | |
28370 | Comparison operations. | |
28371 | ||
28372 | @item @samp{fmind}, @samp{fmaxd} | |
28373 | Double-precision minimum and maximum. These instructions are only | |
28374 | generated if @option{-ffinite-math-only} is specified. | |
28375 | ||
28376 | @item @samp{fsqrtd} | |
28377 | Unary square root operation. | |
28378 | ||
28379 | @item @samp{fcosd}, @samp{fsind}, @samp{ftand}, @samp{fatand}, @samp{fexpd}, @samp{flogd} | |
28380 | Double-precision trigonometric and exponential functions. These instructions | |
28381 | are only generated if @option{-funsafe-math-optimizations} is also specified. | |
28382 | ||
28383 | @end table | |
28384 | ||
28385 | Conversions: | |
28386 | @table @asis | |
28387 | @item @samp{fextsd} | |
28388 | Conversion from single precision to double precision. | |
28389 | ||
28390 | @item @samp{ftruncds} | |
28391 | Conversion from double precision to single precision. | |
28392 | ||
28393 | @item @samp{fixsi}, @samp{fixsu}, @samp{fixdi}, @samp{fixdu} | |
28394 | Conversion from floating point to signed or unsigned integer types, with | |
28395 | truncation towards zero. | |
28396 | ||
28397 | @item @samp{round} | |
28398 | Conversion from single-precision floating point to signed integer, | |
28399 | rounding to the nearest integer and ties away from zero. | |
28400 | This corresponds to the @code{__builtin_lroundf} function when | |
28401 | @option{-fno-math-errno} is used. | |
28402 | ||
28403 | @item @samp{floatis}, @samp{floatus}, @samp{floatid}, @samp{floatud} | |
28404 | Conversion from signed or unsigned integer types to floating-point types. | |
28405 | ||
28406 | @end table | |
28407 | ||
28408 | In addition, all of the following transfer instructions for internal | |
28409 | registers X and Y must be provided to use any of the double-precision | |
28410 | floating-point instructions. Custom instructions taking two | |
28411 | double-precision source operands expect the first operand in the | |
28412 | 64-bit register X. The other operand (or only operand of a unary | |
28413 | operation) is given to the custom arithmetic instruction with the | |
28414 | least significant half in source register @var{src1} and the most | |
28415 | significant half in @var{src2}. A custom instruction that returns a | |
28416 | double-precision result returns the most significant 32 bits in the | |
28417 | destination register and the other half in 32-bit register Y. | |
28418 | GCC automatically generates the necessary code sequences to write | |
28419 | register X and/or read register Y when double-precision floating-point | |
28420 | instructions are used. | |
28421 | ||
28422 | @table @asis | |
28423 | ||
28424 | @item @samp{fwrx} | |
28425 | Write @var{src1} into the least significant half of X and @var{src2} into | |
28426 | the most significant half of X. | |
28427 | ||
28428 | @item @samp{fwry} | |
28429 | Write @var{src1} into Y. | |
28430 | ||
28431 | @item @samp{frdxhi}, @samp{frdxlo} | |
28432 | Read the most or least (respectively) significant half of X and store it in | |
28433 | @var{dest}. | |
28434 | ||
28435 | @item @samp{frdy} | |
28436 | Read the value of Y and store it into @var{dest}. | |
28437 | @end table | |
28438 | ||
28439 | Note that you can gain more local control over generation of Nios II custom | |
28440 | instructions by using the @code{target("custom-@var{insn}=@var{N}")} | |
28441 | and @code{target("no-custom-@var{insn}")} function attributes | |
28442 | (@pxref{Function Attributes}) | |
28443 | or pragmas (@pxref{Function Specific Option Pragmas}). | |
28444 | ||
d77de738 | 28445 | @opindex mcustom-fpu-cfg |
ddf6fe37 | 28446 | @item -mcustom-fpu-cfg=@var{name} |
d77de738 ML |
28447 | |
28448 | This option enables a predefined, named set of custom instruction encodings | |
28449 | (see @option{-mcustom-@var{insn}} above). | |
28450 | Currently, the following sets are defined: | |
28451 | ||
28452 | @option{-mcustom-fpu-cfg=60-1} is equivalent to: | |
43b72ede AA |
28453 | @gccoptlist{-mcustom-fmuls=252 |
28454 | -mcustom-fadds=253 | |
28455 | -mcustom-fsubs=254 | |
d77de738 ML |
28456 | -fsingle-precision-constant} |
28457 | ||
28458 | @option{-mcustom-fpu-cfg=60-2} is equivalent to: | |
43b72ede AA |
28459 | @gccoptlist{-mcustom-fmuls=252 |
28460 | -mcustom-fadds=253 | |
28461 | -mcustom-fsubs=254 | |
28462 | -mcustom-fdivs=255 | |
d77de738 ML |
28463 | -fsingle-precision-constant} |
28464 | ||
28465 | @option{-mcustom-fpu-cfg=72-3} is equivalent to: | |
43b72ede AA |
28466 | @gccoptlist{-mcustom-floatus=243 |
28467 | -mcustom-fixsi=244 | |
28468 | -mcustom-floatis=245 | |
28469 | -mcustom-fcmpgts=246 | |
28470 | -mcustom-fcmples=249 | |
28471 | -mcustom-fcmpeqs=250 | |
28472 | -mcustom-fcmpnes=251 | |
28473 | -mcustom-fmuls=252 | |
28474 | -mcustom-fadds=253 | |
28475 | -mcustom-fsubs=254 | |
28476 | -mcustom-fdivs=255 | |
d77de738 ML |
28477 | -fsingle-precision-constant} |
28478 | ||
28479 | @option{-mcustom-fpu-cfg=fph2} is equivalent to: | |
43b72ede AA |
28480 | @gccoptlist{-mcustom-fabss=224 |
28481 | -mcustom-fnegs=225 | |
28482 | -mcustom-fcmpnes=226 | |
28483 | -mcustom-fcmpeqs=227 | |
28484 | -mcustom-fcmpges=228 | |
28485 | -mcustom-fcmpgts=229 | |
28486 | -mcustom-fcmples=230 | |
28487 | -mcustom-fcmplts=231 | |
28488 | -mcustom-fmaxs=232 | |
28489 | -mcustom-fmins=233 | |
28490 | -mcustom-round=248 | |
28491 | -mcustom-fixsi=249 | |
28492 | -mcustom-floatis=250 | |
28493 | -mcustom-fsqrts=251 | |
28494 | -mcustom-fmuls=252 | |
28495 | -mcustom-fadds=253 | |
28496 | -mcustom-fsubs=254 | |
28497 | -mcustom-fdivs=255} | |
d77de738 ML |
28498 | |
28499 | Custom instruction assignments given by individual | |
28500 | @option{-mcustom-@var{insn}=} options override those given by | |
28501 | @option{-mcustom-fpu-cfg=}, regardless of the | |
28502 | order of the options on the command line. | |
28503 | ||
28504 | Note that you can gain more local control over selection of a FPU | |
28505 | configuration by using the @code{target("custom-fpu-cfg=@var{name}")} | |
28506 | function attribute (@pxref{Function Attributes}) | |
28507 | or pragma (@pxref{Function Specific Option Pragmas}). | |
28508 | ||
28509 | The name @var{fph2} is an abbreviation for @emph{Nios II Floating Point | |
28510 | Hardware 2 Component}. Please note that the custom instructions enabled by | |
28511 | @option{-mcustom-fmins=233} and @option{-mcustom-fmaxs=234} are only generated | |
28512 | if @option{-ffinite-math-only} is specified. The custom instruction enabled by | |
28513 | @option{-mcustom-round=248} is only generated if @option{-fno-math-errno} is | |
28514 | specified. In contrast to the other configurations, | |
28515 | @option{-fsingle-precision-constant} is not set. | |
28516 | ||
28517 | @end table | |
28518 | ||
28519 | These additional @samp{-m} options are available for the Altera Nios II | |
28520 | ELF (bare-metal) target: | |
28521 | ||
28522 | @table @gcctabopt | |
28523 | ||
d77de738 | 28524 | @opindex mhal |
ddf6fe37 | 28525 | @item -mhal |
d77de738 ML |
28526 | Link with HAL BSP. This suppresses linking with the GCC-provided C runtime |
28527 | startup and termination code, and is typically used in conjunction with | |
28528 | @option{-msys-crt0=} to specify the location of the alternate startup code | |
28529 | provided by the HAL BSP. | |
28530 | ||
d77de738 | 28531 | @opindex msmallc |
ddf6fe37 | 28532 | @item -msmallc |
d77de738 ML |
28533 | Link with a limited version of the C library, @option{-lsmallc}, rather than |
28534 | Newlib. | |
28535 | ||
d77de738 | 28536 | @opindex msys-crt0 |
ddf6fe37 | 28537 | @item -msys-crt0=@var{startfile} |
d77de738 ML |
28538 | @var{startfile} is the file name of the startfile (crt0) to use |
28539 | when linking. This option is only useful in conjunction with @option{-mhal}. | |
28540 | ||
d77de738 | 28541 | @opindex msys-lib |
ddf6fe37 | 28542 | @item -msys-lib=@var{systemlib} |
d77de738 ML |
28543 | @var{systemlib} is the library name of the library that provides |
28544 | low-level system calls required by the C library, | |
28545 | e.g.@: @code{read} and @code{write}. | |
28546 | This option is typically used to link with a library provided by a HAL BSP. | |
28547 | ||
28548 | @end table | |
28549 | ||
28550 | @node Nvidia PTX Options | |
28551 | @subsection Nvidia PTX Options | |
28552 | @cindex Nvidia PTX options | |
28553 | @cindex nvptx options | |
28554 | ||
28555 | These options are defined for Nvidia PTX: | |
28556 | ||
28557 | @table @gcctabopt | |
28558 | ||
d77de738 | 28559 | @opindex m64 |
ddf6fe37 | 28560 | @item -m64 |
d77de738 ML |
28561 | Ignored, but preserved for backward compatibility. Only 64-bit ABI is |
28562 | supported. | |
28563 | ||
d77de738 | 28564 | @opindex march |
ddf6fe37 | 28565 | @item -march=@var{architecture-string} |
d77de738 ML |
28566 | Generate code for the specified PTX ISA target architecture |
28567 | (e.g.@: @samp{sm_35}). Valid architecture strings are @samp{sm_30}, | |
28568 | @samp{sm_35}, @samp{sm_53}, @samp{sm_70}, @samp{sm_75} and | |
28569 | @samp{sm_80}. | |
28570 | The default depends on how the compiler has been configured, see | |
28571 | @option{--with-arch}. | |
28572 | ||
28573 | This option sets the value of the preprocessor macro | |
28574 | @code{__PTX_SM__}; for instance, for @samp{sm_35}, it has the value | |
28575 | @samp{350}. | |
28576 | ||
d77de738 | 28577 | @opindex misa |
ddf6fe37 | 28578 | @item -misa=@var{architecture-string} |
d77de738 ML |
28579 | Alias of @option{-march=}. |
28580 | ||
d77de738 | 28581 | @opindex march |
ddf6fe37 | 28582 | @item -march-map=@var{architecture-string} |
d77de738 ML |
28583 | Select the closest available @option{-march=} value that is not more |
28584 | capable. For instance, for @option{-march-map=sm_50} select | |
28585 | @option{-march=sm_35}, and for @option{-march-map=sm_53} select | |
28586 | @option{-march=sm_53}. | |
28587 | ||
d77de738 | 28588 | @opindex mptx |
ddf6fe37 | 28589 | @item -mptx=@var{version-string} |
d77de738 ML |
28590 | Generate code for the specified PTX ISA version (e.g.@: @samp{7.0}). |
28591 | Valid version strings include @samp{3.1}, @samp{6.0}, @samp{6.3}, and | |
28592 | @samp{7.0}. The default PTX ISA version is 6.0, unless a higher | |
28593 | version is required for specified PTX ISA target architecture via | |
28594 | option @option{-march=}. | |
28595 | ||
28596 | This option sets the values of the preprocessor macros | |
28597 | @code{__PTX_ISA_VERSION_MAJOR__} and @code{__PTX_ISA_VERSION_MINOR__}; | |
28598 | for instance, for @samp{3.1} the macros have the values @samp{3} and | |
28599 | @samp{1}, respectively. | |
28600 | ||
d77de738 | 28601 | @opindex mmainkernel |
ddf6fe37 | 28602 | @item -mmainkernel |
d77de738 ML |
28603 | Link in code for a __main kernel. This is for stand-alone instead of |
28604 | offloading execution. | |
28605 | ||
d77de738 | 28606 | @opindex moptimize |
ddf6fe37 | 28607 | @item -moptimize |
d77de738 ML |
28608 | Apply partitioned execution optimizations. This is the default when any |
28609 | level of optimization is selected. | |
28610 | ||
d77de738 | 28611 | @opindex msoft-stack |
ddf6fe37 | 28612 | @item -msoft-stack |
d77de738 ML |
28613 | Generate code that does not use @code{.local} memory |
28614 | directly for stack storage. Instead, a per-warp stack pointer is | |
28615 | maintained explicitly. This enables variable-length stack allocation (with | |
28616 | variable-length arrays or @code{alloca}), and when global memory is used for | |
28617 | underlying storage, makes it possible to access automatic variables from other | |
28618 | threads, or with atomic instructions. This code generation variant is used | |
28619 | for OpenMP offloading, but the option is exposed on its own for the purpose | |
28620 | of testing the compiler; to generate code suitable for linking into programs | |
28621 | using OpenMP offloading, use option @option{-mgomp}. | |
28622 | ||
d77de738 | 28623 | @opindex muniform-simt |
ddf6fe37 | 28624 | @item -muniform-simt |
d77de738 ML |
28625 | Switch to code generation variant that allows to execute all threads in each |
28626 | warp, while maintaining memory state and side effects as if only one thread | |
28627 | in each warp was active outside of OpenMP SIMD regions. All atomic operations | |
28628 | and calls to runtime (malloc, free, vprintf) are conditionally executed (iff | |
28629 | current lane index equals the master lane index), and the register being | |
28630 | assigned is copied via a shuffle instruction from the master lane. Outside of | |
28631 | SIMD regions lane 0 is the master; inside, each thread sees itself as the | |
28632 | master. Shared memory array @code{int __nvptx_uni[]} stores all-zeros or | |
28633 | all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD | |
28634 | regions). Each thread can bitwise-and the bitmask at position @code{tid.y} | |
28635 | with current lane index to compute the master lane index. | |
28636 | ||
d77de738 | 28637 | @opindex mgomp |
ddf6fe37 | 28638 | @item -mgomp |
d77de738 ML |
28639 | Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and |
28640 | @option{-muniform-simt} options, and selects corresponding multilib variant. | |
28641 | ||
28642 | @end table | |
28643 | ||
28644 | @node OpenRISC Options | |
28645 | @subsection OpenRISC Options | |
28646 | @cindex OpenRISC Options | |
28647 | ||
28648 | These options are defined for OpenRISC: | |
28649 | ||
28650 | @table @gcctabopt | |
28651 | ||
d77de738 | 28652 | @opindex mboard |
ddf6fe37 | 28653 | @item -mboard=@var{name} |
d77de738 ML |
28654 | Configure a board specific runtime. This will be passed to the linker for |
28655 | newlib board library linking. The default is @code{or1ksim}. | |
28656 | ||
d77de738 | 28657 | @opindex mnewlib |
ddf6fe37 | 28658 | @item -mnewlib |
d77de738 ML |
28659 | This option is ignored; it is for compatibility purposes only. This used to |
28660 | select linker and preprocessor options for use with newlib. | |
28661 | ||
d77de738 ML |
28662 | @opindex msoft-div |
28663 | @opindex mhard-div | |
ddf6fe37 AA |
28664 | @item -msoft-div |
28665 | @itemx -mhard-div | |
d77de738 ML |
28666 | Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions. |
28667 | This default is hardware divide. | |
28668 | ||
d77de738 ML |
28669 | @opindex msoft-mul |
28670 | @opindex mhard-mul | |
ddf6fe37 AA |
28671 | @item -msoft-mul |
28672 | @itemx -mhard-mul | |
d77de738 ML |
28673 | Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions. |
28674 | This default is hardware multiply. | |
28675 | ||
d77de738 ML |
28676 | @opindex msoft-float |
28677 | @opindex mhard-float | |
ddf6fe37 AA |
28678 | @item -msoft-float |
28679 | @itemx -mhard-float | |
d77de738 ML |
28680 | Select software or hardware for floating point operations. |
28681 | The default is software. | |
28682 | ||
d77de738 | 28683 | @opindex mdouble-float |
ddf6fe37 | 28684 | @item -mdouble-float |
d77de738 ML |
28685 | When @option{-mhard-float} is selected, enables generation of double-precision |
28686 | floating point instructions. By default functions from @file{libgcc} are used | |
28687 | to perform double-precision floating point operations. | |
28688 | ||
d77de738 | 28689 | @opindex munordered-float |
ddf6fe37 | 28690 | @item -munordered-float |
d77de738 ML |
28691 | When @option{-mhard-float} is selected, enables generation of unordered |
28692 | floating point compare and set flag (@code{lf.sfun*}) instructions. By default | |
28693 | functions from @file{libgcc} are used to perform unordered floating point | |
28694 | compare and set flag operations. | |
28695 | ||
d77de738 | 28696 | @opindex mcmov |
ddf6fe37 | 28697 | @item -mcmov |
d77de738 ML |
28698 | Enable generation of conditional move (@code{l.cmov}) instructions. By |
28699 | default the equivalent will be generated using set and branch. | |
28700 | ||
d77de738 | 28701 | @opindex mror |
ddf6fe37 | 28702 | @item -mror |
d77de738 ML |
28703 | Enable generation of rotate right (@code{l.ror}) instructions. By default |
28704 | functions from @file{libgcc} are used to perform rotate right operations. | |
28705 | ||
d77de738 | 28706 | @opindex mrori |
ddf6fe37 | 28707 | @item -mrori |
d77de738 ML |
28708 | Enable generation of rotate right with immediate (@code{l.rori}) instructions. |
28709 | By default functions from @file{libgcc} are used to perform rotate right with | |
28710 | immediate operations. | |
28711 | ||
d77de738 | 28712 | @opindex msext |
ddf6fe37 | 28713 | @item -msext |
d77de738 ML |
28714 | Enable generation of sign extension (@code{l.ext*}) instructions. By default |
28715 | memory loads are used to perform sign extension. | |
28716 | ||
d77de738 | 28717 | @opindex msfimm |
ddf6fe37 | 28718 | @item -msfimm |
d77de738 ML |
28719 | Enable generation of compare and set flag with immediate (@code{l.sf*i}) |
28720 | instructions. By default extra instructions will be generated to store the | |
28721 | immediate to a register first. | |
28722 | ||
d77de738 | 28723 | @opindex mshftimm |
ddf6fe37 | 28724 | @item -mshftimm |
d77de738 ML |
28725 | Enable generation of shift with immediate (@code{l.srai}, @code{l.srli}, |
28726 | @code{l.slli}) instructions. By default extra instructions will be generated | |
28727 | to store the immediate to a register first. | |
28728 | ||
d77de738 | 28729 | @opindex mcmodel=small |
ddf6fe37 | 28730 | @item -mcmodel=small |
d77de738 ML |
28731 | Generate OpenRISC code for the small model: The GOT is limited to 64k. This is |
28732 | the default model. | |
28733 | ||
d77de738 | 28734 | @opindex mcmodel=large |
ddf6fe37 | 28735 | @item -mcmodel=large |
d77de738 ML |
28736 | Generate OpenRISC code for the large model: The GOT may grow up to 4G in size. |
28737 | ||
28738 | ||
28739 | @end table | |
28740 | ||
28741 | @node PDP-11 Options | |
28742 | @subsection PDP-11 Options | |
28743 | @cindex PDP-11 Options | |
28744 | ||
28745 | These options are defined for the PDP-11: | |
28746 | ||
28747 | @table @gcctabopt | |
d77de738 | 28748 | @opindex mfpu |
ddf6fe37 | 28749 | @item -mfpu |
d77de738 ML |
28750 | Use hardware FPP floating point. This is the default. (FIS floating |
28751 | point on the PDP-11/40 is not supported.) Implies -m45. | |
28752 | ||
d77de738 | 28753 | @opindex msoft-float |
ddf6fe37 | 28754 | @item -msoft-float |
d77de738 ML |
28755 | Do not use hardware floating point. |
28756 | ||
d77de738 | 28757 | @opindex mac0 |
ddf6fe37 | 28758 | @item -mac0 |
d77de738 ML |
28759 | Return floating-point results in ac0 (fr0 in Unix assembler syntax). |
28760 | ||
d77de738 | 28761 | @opindex mno-ac0 |
ddf6fe37 | 28762 | @item -mno-ac0 |
d77de738 ML |
28763 | Return floating-point results in memory. This is the default. |
28764 | ||
d77de738 | 28765 | @opindex m40 |
ddf6fe37 | 28766 | @item -m40 |
d77de738 ML |
28767 | Generate code for a PDP-11/40. Implies -msoft-float -mno-split. |
28768 | ||
d77de738 | 28769 | @opindex m45 |
ddf6fe37 | 28770 | @item -m45 |
d77de738 ML |
28771 | Generate code for a PDP-11/45. This is the default. |
28772 | ||
d77de738 | 28773 | @opindex m10 |
ddf6fe37 | 28774 | @item -m10 |
d77de738 ML |
28775 | Generate code for a PDP-11/10. Implies -msoft-float -mno-split. |
28776 | ||
d77de738 ML |
28777 | @opindex mint16 |
28778 | @opindex mno-int32 | |
ddf6fe37 AA |
28779 | @item -mint16 |
28780 | @itemx -mno-int32 | |
d77de738 ML |
28781 | Use 16-bit @code{int}. This is the default. |
28782 | ||
d77de738 ML |
28783 | @opindex mint32 |
28784 | @opindex mno-int16 | |
ddf6fe37 AA |
28785 | @item -mint32 |
28786 | @itemx -mno-int16 | |
d77de738 ML |
28787 | Use 32-bit @code{int}. |
28788 | ||
d77de738 | 28789 | @opindex msplit |
ddf6fe37 | 28790 | @item -msplit |
d77de738 ML |
28791 | Target has split instruction and data space. Implies -m45. |
28792 | ||
d77de738 | 28793 | @opindex munix-asm |
ddf6fe37 | 28794 | @item -munix-asm |
d77de738 ML |
28795 | Use Unix assembler syntax. |
28796 | ||
d77de738 | 28797 | @opindex mdec-asm |
ddf6fe37 | 28798 | @item -mdec-asm |
d77de738 ML |
28799 | Use DEC assembler syntax. |
28800 | ||
d77de738 | 28801 | @opindex mgnu-asm |
ddf6fe37 | 28802 | @item -mgnu-asm |
d77de738 ML |
28803 | Use GNU assembler syntax. This is the default. |
28804 | ||
d77de738 | 28805 | @opindex mlra |
ddf6fe37 | 28806 | @item -mlra |
d77de738 ML |
28807 | Use the new LRA register allocator. By default, the old ``reload'' |
28808 | allocator is used. | |
28809 | @end table | |
28810 | ||
d77de738 ML |
28811 | @node PowerPC Options |
28812 | @subsection PowerPC Options | |
28813 | @cindex PowerPC options | |
28814 | ||
28815 | These are listed under @xref{RS/6000 and PowerPC Options}. | |
28816 | ||
28817 | @node PRU Options | |
28818 | @subsection PRU Options | |
28819 | @cindex PRU Options | |
28820 | ||
28821 | These command-line options are defined for PRU target: | |
28822 | ||
28823 | @table @gcctabopt | |
d77de738 | 28824 | @opindex minrt |
ddf6fe37 | 28825 | @item -minrt |
d77de738 ML |
28826 | Link with a minimum runtime environment, with no support for static |
28827 | initializers and constructors. Using this option can significantly reduce | |
28828 | the size of the final ELF binary. Beware that the compiler could still | |
28829 | generate code with static initializers and constructors. It is up to the | |
28830 | programmer to ensure that the source program will not use those features. | |
28831 | ||
d77de738 | 28832 | @opindex mmcu |
ddf6fe37 | 28833 | @item -mmcu=@var{mcu} |
d77de738 ML |
28834 | Specify the PRU MCU variant to use. Check Newlib for the exact list of |
28835 | supported MCUs. | |
28836 | ||
d77de738 | 28837 | @opindex mno-relax |
ddf6fe37 | 28838 | @item -mno-relax |
d77de738 ML |
28839 | Make GCC pass the @option{--no-relax} command-line option to the linker |
28840 | instead of the @option{--relax} option. | |
28841 | ||
d77de738 | 28842 | @opindex mloop |
ddf6fe37 | 28843 | @item -mloop |
d77de738 ML |
28844 | Allow (or do not allow) GCC to use the LOOP instruction. |
28845 | ||
d77de738 | 28846 | @opindex mabi |
ddf6fe37 | 28847 | @item -mabi=@var{variant} |
d77de738 ML |
28848 | Specify the ABI variant to output code for. @option{-mabi=ti} selects the |
28849 | unmodified TI ABI while @option{-mabi=gnu} selects a GNU variant that copes | |
28850 | more naturally with certain GCC assumptions. These are the differences: | |
28851 | ||
28852 | @table @samp | |
28853 | @item Function Pointer Size | |
28854 | TI ABI specifies that function (code) pointers are 16-bit, whereas GNU | |
28855 | supports only 32-bit data and code pointers. | |
28856 | ||
28857 | @item Optional Return Value Pointer | |
28858 | Function return values larger than 64 bits are passed by using a hidden | |
28859 | pointer as the first argument of the function. TI ABI, though, mandates that | |
28860 | the pointer can be NULL in case the caller is not using the returned value. | |
28861 | GNU always passes and expects a valid return value pointer. | |
28862 | ||
28863 | @end table | |
28864 | ||
28865 | The current @option{-mabi=ti} implementation simply raises a compile error | |
28866 | when any of the above code constructs is detected. As a consequence | |
28867 | the standard C library cannot be built and it is omitted when linking with | |
28868 | @option{-mabi=ti}. | |
28869 | ||
28870 | Relaxation is a GNU feature and for safety reasons is disabled when using | |
28871 | @option{-mabi=ti}. The TI toolchain does not emit relocations for QBBx | |
28872 | instructions, so the GNU linker cannot adjust them when shortening adjacent | |
28873 | LDI32 pseudo instructions. | |
28874 | ||
28875 | @end table | |
28876 | ||
28877 | @node RISC-V Options | |
28878 | @subsection RISC-V Options | |
28879 | @cindex RISC-V Options | |
28880 | ||
28881 | These command-line options are defined for RISC-V targets: | |
28882 | ||
28883 | @table @gcctabopt | |
d77de738 | 28884 | @opindex mbranch-cost |
ddf6fe37 | 28885 | @item -mbranch-cost=@var{n} |
d77de738 ML |
28886 | Set the cost of branches to roughly @var{n} instructions. |
28887 | ||
ddf6fe37 | 28888 | @opindex plt |
d77de738 ML |
28889 | @item -mplt |
28890 | @itemx -mno-plt | |
d77de738 ML |
28891 | When generating PIC code, do or don't allow the use of PLTs. Ignored for |
28892 | non-PIC. The default is @option{-mplt}. | |
28893 | ||
d77de738 | 28894 | @opindex mabi |
ddf6fe37 | 28895 | @item -mabi=@var{ABI-string} |
d77de738 ML |
28896 | Specify integer and floating-point calling convention. @var{ABI-string} |
28897 | contains two parts: the size of integer types and the registers used for | |
28898 | floating-point types. For example @samp{-march=rv64ifd -mabi=lp64d} means that | |
28899 | @samp{long} and pointers are 64-bit (implicitly defining @samp{int} to be | |
28900 | 32-bit), and that floating-point values up to 64 bits wide are passed in F | |
28901 | registers. Contrast this with @samp{-march=rv64ifd -mabi=lp64f}, which still | |
28902 | allows the compiler to generate code that uses the F and D extensions but only | |
28903 | allows floating-point values up to 32 bits long to be passed in registers; or | |
28904 | @samp{-march=rv64ifd -mabi=lp64}, in which no floating-point arguments will be | |
28905 | passed in registers. | |
28906 | ||
28907 | The default for this argument is system dependent, users who want a specific | |
28908 | calling convention should specify one explicitly. The valid calling | |
28909 | conventions are: @samp{ilp32}, @samp{ilp32f}, @samp{ilp32d}, @samp{lp64}, | |
28910 | @samp{lp64f}, and @samp{lp64d}. Some calling conventions are impossible to | |
28911 | implement on some ISAs: for example, @samp{-march=rv32if -mabi=ilp32d} is | |
28912 | invalid because the ABI requires 64-bit values be passed in F registers, but F | |
28913 | registers are only 32 bits wide. There is also the @samp{ilp32e} ABI that can | |
28914 | only be used with the @samp{rv32e} architecture. This ABI is not well | |
28915 | specified at present, and is subject to change. | |
28916 | ||
ddf6fe37 | 28917 | @opindex mfdiv |
d77de738 ML |
28918 | @item -mfdiv |
28919 | @itemx -mno-fdiv | |
d77de738 ML |
28920 | Do or don't use hardware floating-point divide and square root instructions. |
28921 | This requires the F or D extensions for floating-point registers. The default | |
28922 | is to use them if the specified architecture has these instructions. | |
28923 | ||
ddf6fe37 | 28924 | @opindex mdiv |
d77de738 ML |
28925 | @item -mdiv |
28926 | @itemx -mno-div | |
d77de738 ML |
28927 | Do or don't use hardware instructions for integer division. This requires the |
28928 | M extension. The default is to use them if the specified architecture has | |
28929 | these instructions. | |
28930 | ||
d77de738 | 28931 | @opindex misa-spec |
ddf6fe37 | 28932 | @item -misa-spec=@var{ISA-spec-string} |
d77de738 ML |
28933 | Specify the version of the RISC-V Unprivileged (formerly User-Level) |
28934 | ISA specification to produce code conforming to. The possibilities | |
28935 | for @var{ISA-spec-string} are: | |
28936 | @table @code | |
28937 | @item 2.2 | |
28938 | Produce code conforming to version 2.2. | |
28939 | @item 20190608 | |
28940 | Produce code conforming to version 20190608. | |
28941 | @item 20191213 | |
28942 | Produce code conforming to version 20191213. | |
28943 | @end table | |
28944 | The default is @option{-misa-spec=20191213} unless GCC has been configured | |
28945 | with @option{--with-isa-spec=} specifying a different default version. | |
28946 | ||
d77de738 | 28947 | @opindex march |
ddf6fe37 | 28948 | @item -march=@var{ISA-string} |
d77de738 ML |
28949 | Generate code for given RISC-V ISA (e.g.@: @samp{rv64im}). ISA strings must be |
28950 | lower-case. Examples include @samp{rv64i}, @samp{rv32g}, @samp{rv32e}, and | |
28951 | @samp{rv32imaf}. | |
28952 | ||
28953 | When @option{-march=} is not specified, use the setting from @option{-mcpu}. | |
28954 | ||
28955 | If both @option{-march} and @option{-mcpu=} are not specified, the default for | |
28956 | this argument is system dependent, users who want a specific architecture | |
28957 | extensions should specify one explicitly. | |
28958 | ||
d77de738 | 28959 | @opindex mcpu |
ddf6fe37 | 28960 | @item -mcpu=@var{processor-string} |
d77de738 ML |
28961 | Use architecture of and optimize the output for the given processor, specified |
28962 | by particular CPU name. | |
28963 | Permissible values for this option are: @samp{sifive-e20}, @samp{sifive-e21}, | |
28964 | @samp{sifive-e24}, @samp{sifive-e31}, @samp{sifive-e34}, @samp{sifive-e76}, | |
28965 | @samp{sifive-s21}, @samp{sifive-s51}, @samp{sifive-s54}, @samp{sifive-s76}, | |
aa37a91c | 28966 | @samp{sifive-u54}, and @samp{sifive-u74}. |
d77de738 | 28967 | |
d77de738 | 28968 | @opindex mtune |
ddf6fe37 | 28969 | @item -mtune=@var{processor-string} |
d77de738 ML |
28970 | Optimize the output for the given processor, specified by microarchitecture or |
28971 | particular CPU name. Permissible values for this option are: @samp{rocket}, | |
28972 | @samp{sifive-3-series}, @samp{sifive-5-series}, @samp{sifive-7-series}, | |
aa37a91c | 28973 | @samp{thead-c906}, @samp{size}, and all valid options for @option{-mcpu=}. |
d77de738 ML |
28974 | |
28975 | When @option{-mtune=} is not specified, use the setting from @option{-mcpu}, | |
28976 | the default is @samp{rocket} if both are not specified. | |
28977 | ||
28978 | The @samp{size} choice is not intended for use by end-users. This is used | |
28979 | when @option{-Os} is specified. It overrides the instruction cost info | |
28980 | provided by @option{-mtune=}, but does not override the pipeline info. This | |
28981 | helps reduce code size while still giving good performance. | |
28982 | ||
d77de738 | 28983 | @opindex mpreferred-stack-boundary |
ddf6fe37 | 28984 | @item -mpreferred-stack-boundary=@var{num} |
d77de738 ML |
28985 | Attempt to keep the stack boundary aligned to a 2 raised to @var{num} |
28986 | byte boundary. If @option{-mpreferred-stack-boundary} is not specified, | |
28987 | the default is 4 (16 bytes or 128-bits). | |
28988 | ||
28989 | @strong{Warning:} If you use this switch, then you must build all modules with | |
28990 | the same value, including any libraries. This includes the system libraries | |
28991 | and startup modules. | |
28992 | ||
d77de738 | 28993 | @opindex msmall-data-limit |
ddf6fe37 | 28994 | @item -msmall-data-limit=@var{n} |
d77de738 ML |
28995 | Put global and static data smaller than @var{n} bytes into a special section |
28996 | (on some targets). | |
28997 | ||
ddf6fe37 | 28998 | @opindex msave-restore |
d77de738 ML |
28999 | @item -msave-restore |
29000 | @itemx -mno-save-restore | |
d77de738 ML |
29001 | Do or don't use smaller but slower prologue and epilogue code that uses |
29002 | library function calls. The default is to use fast inline prologues and | |
29003 | epilogues. | |
29004 | ||
ddf6fe37 | 29005 | @opindex mshorten-memrefs |
d77de738 ML |
29006 | @item -mshorten-memrefs |
29007 | @itemx -mno-shorten-memrefs | |
d77de738 ML |
29008 | Do or do not attempt to make more use of compressed load/store instructions by |
29009 | replacing a load/store of 'base register + large offset' with a new load/store | |
29010 | of 'new base + small offset'. If the new base gets stored in a compressed | |
29011 | register, then the new load/store can be compressed. Currently targets 32-bit | |
29012 | integer load/stores only. | |
29013 | ||
ddf6fe37 | 29014 | @opindex mstrict-align |
d77de738 ML |
29015 | @item -mstrict-align |
29016 | @itemx -mno-strict-align | |
d77de738 ML |
29017 | Do not or do generate unaligned memory accesses. The default is set depending |
29018 | on whether the processor we are optimizing for supports fast unaligned access | |
29019 | or not. | |
29020 | ||
d77de738 | 29021 | @opindex mcmodel=medlow |
ddf6fe37 | 29022 | @item -mcmodel=medlow |
d77de738 ML |
29023 | Generate code for the medium-low code model. The program and its statically |
29024 | defined symbols must lie within a single 2 GiB address range and must lie | |
29025 | between absolute addresses @minus{}2 GiB and +2 GiB. Programs can be | |
29026 | statically or dynamically linked. This is the default code model. | |
29027 | ||
d77de738 | 29028 | @opindex mcmodel=medany |
ddf6fe37 | 29029 | @item -mcmodel=medany |
d77de738 ML |
29030 | Generate code for the medium-any code model. The program and its statically |
29031 | defined symbols must be within any single 2 GiB address range. Programs can be | |
29032 | statically or dynamically linked. | |
29033 | ||
29034 | The code generated by the medium-any code model is position-independent, but is | |
29035 | not guaranteed to function correctly when linked into position-independent | |
29036 | executables or libraries. | |
29037 | ||
29038 | @item -mexplicit-relocs | |
29039 | @itemx -mno-exlicit-relocs | |
29040 | Use or do not use assembler relocation operators when dealing with symbolic | |
29041 | addresses. The alternative is to use assembler macros instead, which may | |
29042 | limit optimization. | |
29043 | ||
ddf6fe37 | 29044 | @opindex mrelax |
d77de738 ML |
29045 | @item -mrelax |
29046 | @itemx -mno-relax | |
d77de738 ML |
29047 | Take advantage of linker relaxations to reduce the number of instructions |
29048 | required to materialize symbol addresses. The default is to take advantage of | |
29049 | linker relaxations. | |
29050 | ||
ddf6fe37 | 29051 | @opindex mriscv-attribute |
d77de738 ML |
29052 | @item -mriscv-attribute |
29053 | @itemx -mno-riscv-attribute | |
d77de738 ML |
29054 | Emit (do not emit) RISC-V attribute to record extra information into ELF |
29055 | objects. This feature requires at least binutils 2.32. | |
29056 | ||
ddf6fe37 | 29057 | @opindex mcsr-check |
d77de738 ML |
29058 | @item -mcsr-check |
29059 | @itemx -mno-csr-check | |
d77de738 ML |
29060 | Enables or disables the CSR checking. |
29061 | ||
d77de738 | 29062 | @opindex malign-data |
ddf6fe37 | 29063 | @item -malign-data=@var{type} |
d77de738 ML |
29064 | Control how GCC aligns variables and constants of array, structure, or union |
29065 | types. Supported values for @var{type} are @samp{xlen} which uses x register | |
29066 | width as the alignment value, and @samp{natural} which uses natural alignment. | |
29067 | @samp{xlen} is the default. | |
29068 | ||
d77de738 | 29069 | @opindex mbig-endian |
ddf6fe37 | 29070 | @item -mbig-endian |
d77de738 ML |
29071 | Generate big-endian code. This is the default when GCC is configured for a |
29072 | @samp{riscv64be-*-*} or @samp{riscv32be-*-*} target. | |
29073 | ||
d77de738 | 29074 | @opindex mlittle-endian |
ddf6fe37 | 29075 | @item -mlittle-endian |
d77de738 ML |
29076 | Generate little-endian code. This is the default when GCC is configured for a |
29077 | @samp{riscv64-*-*} or @samp{riscv32-*-*} but not a @samp{riscv64be-*-*} or | |
29078 | @samp{riscv32be-*-*} target. | |
29079 | ||
d77de738 ML |
29080 | @opindex mstack-protector-guard |
29081 | @opindex mstack-protector-guard-reg | |
29082 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
29083 | @item -mstack-protector-guard=@var{guard} |
29084 | @itemx -mstack-protector-guard-reg=@var{reg} | |
29085 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
29086 | Generate stack protection code using canary at @var{guard}. Supported |
29087 | locations are @samp{global} for a global canary or @samp{tls} for per-thread | |
29088 | canary in the TLS block. | |
29089 | ||
29090 | With the latter choice the options | |
29091 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
29092 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
29093 | which register to use as base register for reading the canary, | |
29094 | and from what offset from that base register. There is no default | |
29095 | register or offset as this is entirely for use within the Linux | |
29096 | kernel. | |
29097 | @end table | |
29098 | ||
29099 | @node RL78 Options | |
29100 | @subsection RL78 Options | |
29101 | @cindex RL78 Options | |
29102 | ||
29103 | @table @gcctabopt | |
29104 | ||
d77de738 | 29105 | @opindex msim |
ddf6fe37 | 29106 | @item -msim |
d77de738 ML |
29107 | Links in additional target libraries to support operation within a |
29108 | simulator. | |
29109 | ||
ddf6fe37 | 29110 | @opindex mmul |
d77de738 ML |
29111 | @item -mmul=none |
29112 | @itemx -mmul=g10 | |
29113 | @itemx -mmul=g13 | |
29114 | @itemx -mmul=g14 | |
29115 | @itemx -mmul=rl78 | |
d77de738 ML |
29116 | Specifies the type of hardware multiplication and division support to |
29117 | be used. The simplest is @code{none}, which uses software for both | |
29118 | multiplication and division. This is the default. The @code{g13} | |
29119 | value is for the hardware multiply/divide peripheral found on the | |
29120 | RL78/G13 (S2 core) targets. The @code{g14} value selects the use of | |
29121 | the multiplication and division instructions supported by the RL78/G14 | |
29122 | (S3 core) parts. The value @code{rl78} is an alias for @code{g14} and | |
29123 | the value @code{mg10} is an alias for @code{none}. | |
29124 | ||
29125 | In addition a C preprocessor macro is defined, based upon the setting | |
29126 | of this option. Possible values are: @code{__RL78_MUL_NONE__}, | |
29127 | @code{__RL78_MUL_G13__} or @code{__RL78_MUL_G14__}. | |
29128 | ||
ddf6fe37 | 29129 | @opindex mcpu |
d77de738 ML |
29130 | @item -mcpu=g10 |
29131 | @itemx -mcpu=g13 | |
29132 | @itemx -mcpu=g14 | |
29133 | @itemx -mcpu=rl78 | |
d77de738 ML |
29134 | Specifies the RL78 core to target. The default is the G14 core, also |
29135 | known as an S3 core or just RL78. The G13 or S2 core does not have | |
29136 | multiply or divide instructions, instead it uses a hardware peripheral | |
29137 | for these operations. The G10 or S1 core does not have register | |
29138 | banks, so it uses a different calling convention. | |
29139 | ||
29140 | If this option is set it also selects the type of hardware multiply | |
29141 | support to use, unless this is overridden by an explicit | |
29142 | @option{-mmul=none} option on the command line. Thus specifying | |
29143 | @option{-mcpu=g13} enables the use of the G13 hardware multiply | |
29144 | peripheral and specifying @option{-mcpu=g10} disables the use of | |
29145 | hardware multiplications altogether. | |
29146 | ||
29147 | Note, although the RL78/G14 core is the default target, specifying | |
29148 | @option{-mcpu=g14} or @option{-mcpu=rl78} on the command line does | |
29149 | change the behavior of the toolchain since it also enables G14 | |
29150 | hardware multiply support. If these options are not specified on the | |
29151 | command line then software multiplication routines will be used even | |
29152 | though the code targets the RL78 core. This is for backwards | |
29153 | compatibility with older toolchains which did not have hardware | |
29154 | multiply and divide support. | |
29155 | ||
29156 | In addition a C preprocessor macro is defined, based upon the setting | |
29157 | of this option. Possible values are: @code{__RL78_G10__}, | |
29158 | @code{__RL78_G13__} or @code{__RL78_G14__}. | |
29159 | ||
d77de738 ML |
29160 | @opindex mg10 |
29161 | @opindex mg13 | |
29162 | @opindex mg14 | |
29163 | @opindex mrl78 | |
ddf6fe37 AA |
29164 | @item -mg10 |
29165 | @itemx -mg13 | |
29166 | @itemx -mg14 | |
29167 | @itemx -mrl78 | |
d77de738 ML |
29168 | These are aliases for the corresponding @option{-mcpu=} option. They |
29169 | are provided for backwards compatibility. | |
29170 | ||
d77de738 | 29171 | @opindex mallregs |
ddf6fe37 | 29172 | @item -mallregs |
d77de738 ML |
29173 | Allow the compiler to use all of the available registers. By default |
29174 | registers @code{r24..r31} are reserved for use in interrupt handlers. | |
29175 | With this option enabled these registers can be used in ordinary | |
29176 | functions as well. | |
29177 | ||
d77de738 ML |
29178 | @opindex m64bit-doubles |
29179 | @opindex m32bit-doubles | |
ddf6fe37 AA |
29180 | @item -m64bit-doubles |
29181 | @itemx -m32bit-doubles | |
d77de738 ML |
29182 | Make the @code{double} data type be 64 bits (@option{-m64bit-doubles}) |
29183 | or 32 bits (@option{-m32bit-doubles}) in size. The default is | |
29184 | @option{-m32bit-doubles}. | |
29185 | ||
d77de738 ML |
29186 | @opindex msave-mduc-in-interrupts |
29187 | @opindex mno-save-mduc-in-interrupts | |
ddf6fe37 AA |
29188 | @item -msave-mduc-in-interrupts |
29189 | @itemx -mno-save-mduc-in-interrupts | |
d77de738 ML |
29190 | Specifies that interrupt handler functions should preserve the |
29191 | MDUC registers. This is only necessary if normal code might use | |
29192 | the MDUC registers, for example because it performs multiplication | |
29193 | and division operations. The default is to ignore the MDUC registers | |
29194 | as this makes the interrupt handlers faster. The target option -mg13 | |
29195 | needs to be passed for this to work as this feature is only available | |
29196 | on the G13 target (S2 core). The MDUC registers will only be saved | |
29197 | if the interrupt handler performs a multiplication or division | |
29198 | operation or it calls another function. | |
29199 | ||
29200 | @end table | |
29201 | ||
29202 | @node RS/6000 and PowerPC Options | |
29203 | @subsection IBM RS/6000 and PowerPC Options | |
29204 | @cindex RS/6000 and PowerPC Options | |
29205 | @cindex IBM RS/6000 and PowerPC Options | |
29206 | ||
29207 | These @samp{-m} options are defined for the IBM RS/6000 and PowerPC: | |
29208 | @table @gcctabopt | |
29209 | @item -mpowerpc-gpopt | |
29210 | @itemx -mno-powerpc-gpopt | |
29211 | @itemx -mpowerpc-gfxopt | |
29212 | @itemx -mno-powerpc-gfxopt | |
29213 | @need 800 | |
29214 | @itemx -mpowerpc64 | |
29215 | @itemx -mno-powerpc64 | |
29216 | @itemx -mmfcrf | |
29217 | @itemx -mno-mfcrf | |
29218 | @itemx -mpopcntb | |
29219 | @itemx -mno-popcntb | |
29220 | @itemx -mpopcntd | |
29221 | @itemx -mno-popcntd | |
29222 | @itemx -mfprnd | |
29223 | @itemx -mno-fprnd | |
29224 | @need 800 | |
d77de738 ML |
29225 | @opindex mpowerpc-gpopt |
29226 | @opindex mno-powerpc-gpopt | |
29227 | @opindex mpowerpc-gfxopt | |
29228 | @opindex mno-powerpc-gfxopt | |
29229 | @opindex mpowerpc64 | |
29230 | @opindex mno-powerpc64 | |
29231 | @opindex mmfcrf | |
29232 | @opindex mno-mfcrf | |
29233 | @opindex mpopcntb | |
29234 | @opindex mno-popcntb | |
29235 | @opindex mpopcntd | |
29236 | @opindex mno-popcntd | |
29237 | @opindex mfprnd | |
29238 | @opindex mno-fprnd | |
29239 | @opindex mcmpb | |
29240 | @opindex mno-cmpb | |
29241 | @opindex mhard-dfp | |
29242 | @opindex mno-hard-dfp | |
ddf6fe37 AA |
29243 | @itemx -mcmpb |
29244 | @itemx -mno-cmpb | |
29245 | @itemx -mhard-dfp | |
29246 | @itemx -mno-hard-dfp | |
d77de738 ML |
29247 | You use these options to specify which instructions are available on the |
29248 | processor you are using. The default value of these options is | |
29249 | determined when configuring GCC@. Specifying the | |
29250 | @option{-mcpu=@var{cpu_type}} overrides the specification of these | |
29251 | options. We recommend you use the @option{-mcpu=@var{cpu_type}} option | |
29252 | rather than the options listed above. | |
29253 | ||
29254 | Specifying @option{-mpowerpc-gpopt} allows | |
29255 | GCC to use the optional PowerPC architecture instructions in the | |
29256 | General Purpose group, including floating-point square root. Specifying | |
29257 | @option{-mpowerpc-gfxopt} allows GCC to | |
29258 | use the optional PowerPC architecture instructions in the Graphics | |
29259 | group, including floating-point select. | |
29260 | ||
29261 | The @option{-mmfcrf} option allows GCC to generate the move from | |
29262 | condition register field instruction implemented on the POWER4 | |
29263 | processor and other processors that support the PowerPC V2.01 | |
29264 | architecture. | |
29265 | The @option{-mpopcntb} option allows GCC to generate the popcount and | |
29266 | double-precision FP reciprocal estimate instruction implemented on the | |
29267 | POWER5 processor and other processors that support the PowerPC V2.02 | |
29268 | architecture. | |
29269 | The @option{-mpopcntd} option allows GCC to generate the popcount | |
29270 | instruction implemented on the POWER7 processor and other processors | |
29271 | that support the PowerPC V2.06 architecture. | |
29272 | The @option{-mfprnd} option allows GCC to generate the FP round to | |
29273 | integer instructions implemented on the POWER5+ processor and other | |
29274 | processors that support the PowerPC V2.03 architecture. | |
29275 | The @option{-mcmpb} option allows GCC to generate the compare bytes | |
29276 | instruction implemented on the POWER6 processor and other processors | |
29277 | that support the PowerPC V2.05 architecture. | |
29278 | The @option{-mhard-dfp} option allows GCC to generate the decimal | |
29279 | floating-point instructions implemented on some POWER processors. | |
29280 | ||
29281 | The @option{-mpowerpc64} option allows GCC to generate the additional | |
29282 | 64-bit instructions that are found in the full PowerPC64 architecture | |
29283 | and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to | |
29284 | @option{-mno-powerpc64}. | |
29285 | ||
d77de738 | 29286 | @opindex mcpu |
ddf6fe37 | 29287 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
29288 | Set architecture type, register usage, and |
29289 | instruction scheduling parameters for machine type @var{cpu_type}. | |
29290 | Supported values for @var{cpu_type} are @samp{401}, @samp{403}, | |
29291 | @samp{405}, @samp{405fp}, @samp{440}, @samp{440fp}, @samp{464}, @samp{464fp}, | |
29292 | @samp{476}, @samp{476fp}, @samp{505}, @samp{601}, @samp{602}, @samp{603}, | |
29293 | @samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{630}, @samp{740}, | |
29294 | @samp{7400}, @samp{7450}, @samp{750}, @samp{801}, @samp{821}, @samp{823}, | |
29295 | @samp{860}, @samp{970}, @samp{8540}, @samp{a2}, @samp{e300c2}, | |
29296 | @samp{e300c3}, @samp{e500mc}, @samp{e500mc64}, @samp{e5500}, | |
29297 | @samp{e6500}, @samp{ec603e}, @samp{G3}, @samp{G4}, @samp{G5}, | |
29298 | @samp{titan}, @samp{power3}, @samp{power4}, @samp{power5}, @samp{power5+}, | |
29299 | @samp{power6}, @samp{power6x}, @samp{power7}, @samp{power8}, | |
29300 | @samp{power9}, @samp{power10}, @samp{powerpc}, @samp{powerpc64}, | |
29301 | @samp{powerpc64le}, @samp{rs64}, and @samp{native}. | |
29302 | ||
29303 | @option{-mcpu=powerpc}, @option{-mcpu=powerpc64}, and | |
29304 | @option{-mcpu=powerpc64le} specify pure 32-bit PowerPC (either | |
29305 | endian), 64-bit big endian PowerPC and 64-bit little endian PowerPC | |
29306 | architecture machine types, with an appropriate, generic processor | |
29307 | model assumed for scheduling purposes. | |
29308 | ||
29309 | Specifying @samp{native} as cpu type detects and selects the | |
29310 | architecture option that corresponds to the host processor of the | |
29311 | system performing the compilation. | |
29312 | @option{-mcpu=native} has no effect if GCC does not recognize the | |
29313 | processor. | |
29314 | ||
29315 | The other options specify a specific processor. Code generated under | |
29316 | those options runs best on that processor, and may not run at all on | |
29317 | others. | |
29318 | ||
29319 | The @option{-mcpu} options automatically enable or disable the | |
29320 | following options: | |
29321 | ||
43b72ede AA |
29322 | @gccoptlist{-maltivec -mfprnd -mhard-float -mmfcrf -mmultiple |
29323 | -mpopcntb -mpopcntd -mpowerpc64 | |
29324 | -mpowerpc-gpopt -mpowerpc-gfxopt | |
29325 | -mmulhw -mdlmzb -mmfpgpr -mvsx | |
29326 | -mcrypto -mhtm -mpower8-fusion -mpower8-vector | |
29327 | -mquad-memory -mquad-memory-atomic -mfloat128 | |
29328 | -mfloat128-hardware -mprefixed -mpcrel -mmma | |
d77de738 ML |
29329 | -mrop-protect} |
29330 | ||
29331 | The particular options set for any particular CPU varies between | |
29332 | compiler versions, depending on what setting seems to produce optimal | |
29333 | code for that CPU; it doesn't necessarily reflect the actual hardware's | |
29334 | capabilities. If you wish to set an individual option to a particular | |
29335 | value, you may specify it after the @option{-mcpu} option, like | |
29336 | @option{-mcpu=970 -mno-altivec}. | |
29337 | ||
29338 | On AIX, the @option{-maltivec} and @option{-mpowerpc64} options are | |
29339 | not enabled or disabled by the @option{-mcpu} option at present because | |
29340 | AIX does not have full support for these options. You may still | |
29341 | enable or disable them individually if you're sure it'll work in your | |
29342 | environment. | |
29343 | ||
d77de738 | 29344 | @opindex mtune |
ddf6fe37 | 29345 | @item -mtune=@var{cpu_type} |
d77de738 ML |
29346 | Set the instruction scheduling parameters for machine type |
29347 | @var{cpu_type}, but do not set the architecture type or register usage, | |
29348 | as @option{-mcpu=@var{cpu_type}} does. The same | |
29349 | values for @var{cpu_type} are used for @option{-mtune} as for | |
29350 | @option{-mcpu}. If both are specified, the code generated uses the | |
29351 | architecture and registers set by @option{-mcpu}, but the | |
29352 | scheduling parameters set by @option{-mtune}. | |
29353 | ||
d77de738 | 29354 | @opindex mcmodel=small |
ddf6fe37 | 29355 | @item -mcmodel=small |
d77de738 ML |
29356 | Generate PowerPC64 code for the small model: The TOC is limited to |
29357 | 64k. | |
29358 | ||
d77de738 | 29359 | @opindex mcmodel=medium |
ddf6fe37 | 29360 | @item -mcmodel=medium |
d77de738 ML |
29361 | Generate PowerPC64 code for the medium model: The TOC and other static |
29362 | data may be up to a total of 4G in size. This is the default for 64-bit | |
29363 | Linux. | |
29364 | ||
d77de738 | 29365 | @opindex mcmodel=large |
ddf6fe37 | 29366 | @item -mcmodel=large |
d77de738 ML |
29367 | Generate PowerPC64 code for the large model: The TOC may be up to 4G |
29368 | in size. Other data and code is only limited by the 64-bit address | |
29369 | space. | |
29370 | ||
d77de738 ML |
29371 | @opindex maltivec |
29372 | @opindex mno-altivec | |
ddf6fe37 AA |
29373 | @item -maltivec |
29374 | @itemx -mno-altivec | |
d77de738 ML |
29375 | Generate code that uses (does not use) AltiVec instructions, and also |
29376 | enable the use of built-in functions that allow more direct access to | |
29377 | the AltiVec instruction set. You may also need to set | |
29378 | @option{-mabi=altivec} to adjust the current ABI with AltiVec ABI | |
29379 | enhancements. | |
29380 | ||
29381 | When @option{-maltivec} is used, the element order for AltiVec intrinsics | |
29382 | such as @code{vec_splat}, @code{vec_extract}, and @code{vec_insert} | |
29383 | match array element order corresponding to the endianness of the | |
29384 | target. That is, element zero identifies the leftmost element in a | |
29385 | vector register when targeting a big-endian platform, and identifies | |
29386 | the rightmost element in a vector register when targeting a | |
29387 | little-endian platform. | |
29388 | ||
d77de738 ML |
29389 | @opindex mvrsave |
29390 | @opindex mno-vrsave | |
ddf6fe37 AA |
29391 | @item -mvrsave |
29392 | @itemx -mno-vrsave | |
d77de738 ML |
29393 | Generate VRSAVE instructions when generating AltiVec code. |
29394 | ||
d77de738 | 29395 | @opindex msecure-plt |
ddf6fe37 | 29396 | @item -msecure-plt |
d77de738 ML |
29397 | Generate code that allows @command{ld} and @command{ld.so} |
29398 | to build executables and shared | |
29399 | libraries with non-executable @code{.plt} and @code{.got} sections. | |
29400 | This is a PowerPC | |
29401 | 32-bit SYSV ABI option. | |
29402 | ||
d77de738 | 29403 | @opindex mbss-plt |
ddf6fe37 | 29404 | @item -mbss-plt |
d77de738 ML |
29405 | Generate code that uses a BSS @code{.plt} section that @command{ld.so} |
29406 | fills in, and | |
29407 | requires @code{.plt} and @code{.got} | |
29408 | sections that are both writable and executable. | |
29409 | This is a PowerPC 32-bit SYSV ABI option. | |
29410 | ||
d77de738 ML |
29411 | @opindex misel |
29412 | @opindex mno-isel | |
ddf6fe37 AA |
29413 | @item -misel |
29414 | @itemx -mno-isel | |
d77de738 ML |
29415 | This switch enables or disables the generation of ISEL instructions. |
29416 | ||
d77de738 ML |
29417 | @opindex mvsx |
29418 | @opindex mno-vsx | |
ddf6fe37 AA |
29419 | @item -mvsx |
29420 | @itemx -mno-vsx | |
d77de738 ML |
29421 | Generate code that uses (does not use) vector/scalar (VSX) |
29422 | instructions, and also enable the use of built-in functions that allow | |
29423 | more direct access to the VSX instruction set. | |
29424 | ||
d77de738 ML |
29425 | @opindex mcrypto |
29426 | @opindex mno-crypto | |
ddf6fe37 AA |
29427 | @item -mcrypto |
29428 | @itemx -mno-crypto | |
d77de738 ML |
29429 | Enable the use (disable) of the built-in functions that allow direct |
29430 | access to the cryptographic instructions that were added in version | |
29431 | 2.07 of the PowerPC ISA. | |
29432 | ||
d77de738 ML |
29433 | @opindex mhtm |
29434 | @opindex mno-htm | |
ddf6fe37 AA |
29435 | @item -mhtm |
29436 | @itemx -mno-htm | |
d77de738 ML |
29437 | Enable (disable) the use of the built-in functions that allow direct |
29438 | access to the Hardware Transactional Memory (HTM) instructions that | |
29439 | were added in version 2.07 of the PowerPC ISA. | |
29440 | ||
d77de738 ML |
29441 | @opindex mpower8-fusion |
29442 | @opindex mno-power8-fusion | |
ddf6fe37 AA |
29443 | @item -mpower8-fusion |
29444 | @itemx -mno-power8-fusion | |
d77de738 ML |
29445 | Generate code that keeps (does not keeps) some integer operations |
29446 | adjacent so that the instructions can be fused together on power8 and | |
29447 | later processors. | |
29448 | ||
d77de738 ML |
29449 | @opindex mpower8-vector |
29450 | @opindex mno-power8-vector | |
ddf6fe37 AA |
29451 | @item -mpower8-vector |
29452 | @itemx -mno-power8-vector | |
d77de738 ML |
29453 | Generate code that uses (does not use) the vector and scalar |
29454 | instructions that were added in version 2.07 of the PowerPC ISA. Also | |
29455 | enable the use of built-in functions that allow more direct access to | |
29456 | the vector instructions. | |
29457 | ||
d77de738 ML |
29458 | @opindex mquad-memory |
29459 | @opindex mno-quad-memory | |
ddf6fe37 AA |
29460 | @item -mquad-memory |
29461 | @itemx -mno-quad-memory | |
d77de738 ML |
29462 | Generate code that uses (does not use) the non-atomic quad word memory |
29463 | instructions. The @option{-mquad-memory} option requires use of | |
29464 | 64-bit mode. | |
29465 | ||
d77de738 ML |
29466 | @opindex mquad-memory-atomic |
29467 | @opindex mno-quad-memory-atomic | |
ddf6fe37 AA |
29468 | @item -mquad-memory-atomic |
29469 | @itemx -mno-quad-memory-atomic | |
d77de738 ML |
29470 | Generate code that uses (does not use) the atomic quad word memory |
29471 | instructions. The @option{-mquad-memory-atomic} option requires use of | |
29472 | 64-bit mode. | |
29473 | ||
d77de738 ML |
29474 | @opindex mfloat128 |
29475 | @opindex mno-float128 | |
ddf6fe37 AA |
29476 | @item -mfloat128 |
29477 | @itemx -mno-float128 | |
d77de738 ML |
29478 | Enable/disable the @var{__float128} keyword for IEEE 128-bit floating point |
29479 | and use either software emulation for IEEE 128-bit floating point or | |
29480 | hardware instructions. | |
29481 | ||
29482 | The VSX instruction set (@option{-mvsx}) must be enabled to use the IEEE | |
29483 | 128-bit floating point support. The IEEE 128-bit floating point is only | |
29484 | supported on Linux. | |
29485 | ||
29486 | The default for @option{-mfloat128} is enabled on PowerPC Linux | |
29487 | systems using the VSX instruction set, and disabled on other systems. | |
29488 | ||
29489 | If you use the ISA 3.0 instruction set (@option{-mpower9-vector} or | |
29490 | @option{-mcpu=power9}) on a 64-bit system, the IEEE 128-bit floating | |
29491 | point support will also enable the generation of ISA 3.0 IEEE 128-bit | |
29492 | floating point instructions. Otherwise, if you do not specify to | |
29493 | generate ISA 3.0 instructions or you are targeting a 32-bit big endian | |
29494 | system, IEEE 128-bit floating point will be done with software | |
29495 | emulation. | |
29496 | ||
d77de738 ML |
29497 | @opindex mfloat128-hardware |
29498 | @opindex mno-float128-hardware | |
ddf6fe37 AA |
29499 | @item -mfloat128-hardware |
29500 | @itemx -mno-float128-hardware | |
d77de738 ML |
29501 | Enable/disable using ISA 3.0 hardware instructions to support the |
29502 | @var{__float128} data type. | |
29503 | ||
29504 | The default for @option{-mfloat128-hardware} is enabled on PowerPC | |
29505 | Linux systems using the ISA 3.0 instruction set, and disabled on other | |
29506 | systems. | |
29507 | ||
d77de738 ML |
29508 | @opindex m32 |
29509 | @opindex m64 | |
ddf6fe37 AA |
29510 | @item -m32 |
29511 | @itemx -m64 | |
d77de738 ML |
29512 | Generate code for 32-bit or 64-bit environments of Darwin and SVR4 |
29513 | targets (including GNU/Linux). The 32-bit environment sets int, long | |
29514 | and pointer to 32 bits and generates code that runs on any PowerPC | |
29515 | variant. The 64-bit environment sets int to 32 bits and long and | |
29516 | pointer to 64 bits, and generates code for PowerPC64, as for | |
29517 | @option{-mpowerpc64}. | |
29518 | ||
d77de738 ML |
29519 | @opindex mfull-toc |
29520 | @opindex mno-fp-in-toc | |
29521 | @opindex mno-sum-in-toc | |
29522 | @opindex mminimal-toc | |
ddf6fe37 AA |
29523 | @item -mfull-toc |
29524 | @itemx -mno-fp-in-toc | |
29525 | @itemx -mno-sum-in-toc | |
29526 | @itemx -mminimal-toc | |
d77de738 ML |
29527 | Modify generation of the TOC (Table Of Contents), which is created for |
29528 | every executable file. The @option{-mfull-toc} option is selected by | |
29529 | default. In that case, GCC allocates at least one TOC entry for | |
29530 | each unique non-automatic variable reference in your program. GCC | |
29531 | also places floating-point constants in the TOC@. However, only | |
29532 | 16,384 entries are available in the TOC@. | |
29533 | ||
29534 | If you receive a linker error message that saying you have overflowed | |
29535 | the available TOC space, you can reduce the amount of TOC space used | |
29536 | with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options. | |
29537 | @option{-mno-fp-in-toc} prevents GCC from putting floating-point | |
29538 | constants in the TOC and @option{-mno-sum-in-toc} forces GCC to | |
29539 | generate code to calculate the sum of an address and a constant at | |
29540 | run time instead of putting that sum into the TOC@. You may specify one | |
29541 | or both of these options. Each causes GCC to produce very slightly | |
29542 | slower and larger code at the expense of conserving TOC space. | |
29543 | ||
29544 | If you still run out of space in the TOC even when you specify both of | |
29545 | these options, specify @option{-mminimal-toc} instead. This option causes | |
29546 | GCC to make only one TOC entry for every file. When you specify this | |
29547 | option, GCC produces code that is slower and larger but which | |
29548 | uses extremely little TOC space. You may wish to use this option | |
29549 | only on files that contain less frequently-executed code. | |
29550 | ||
d77de738 ML |
29551 | @opindex maix64 |
29552 | @opindex maix32 | |
ddf6fe37 AA |
29553 | @item -maix64 |
29554 | @itemx -maix32 | |
d77de738 ML |
29555 | Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit |
29556 | @code{long} type, and the infrastructure needed to support them. | |
29557 | Specifying @option{-maix64} implies @option{-mpowerpc64}, | |
29558 | while @option{-maix32} disables the 64-bit ABI and | |
29559 | implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}. | |
29560 | ||
d77de738 ML |
29561 | @opindex mxl-compat |
29562 | @opindex mno-xl-compat | |
ddf6fe37 AA |
29563 | @item -mxl-compat |
29564 | @itemx -mno-xl-compat | |
d77de738 ML |
29565 | Produce code that conforms more closely to IBM XL compiler semantics |
29566 | when using AIX-compatible ABI@. Pass floating-point arguments to | |
29567 | prototyped functions beyond the register save area (RSA) on the stack | |
29568 | in addition to argument FPRs. Do not assume that most significant | |
29569 | double in 128-bit long double value is properly rounded when comparing | |
29570 | values and converting to double. Use XL symbol names for long double | |
29571 | support routines. | |
29572 | ||
29573 | The AIX calling convention was extended but not initially documented to | |
29574 | handle an obscure K&R C case of calling a function that takes the | |
29575 | address of its arguments with fewer arguments than declared. IBM XL | |
29576 | compilers access floating-point arguments that do not fit in the | |
29577 | RSA from the stack when a subroutine is compiled without | |
29578 | optimization. Because always storing floating-point arguments on the | |
29579 | stack is inefficient and rarely needed, this option is not enabled by | |
29580 | default and only is necessary when calling subroutines compiled by IBM | |
29581 | XL compilers without optimization. | |
29582 | ||
d77de738 | 29583 | @opindex mpe |
ddf6fe37 | 29584 | @item -mpe |
d77de738 ML |
29585 | Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an |
29586 | application written to use message passing with special startup code to | |
29587 | enable the application to run. The system must have PE installed in the | |
29588 | standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file | |
29589 | must be overridden with the @option{-specs=} option to specify the | |
29590 | appropriate directory location. The Parallel Environment does not | |
29591 | support threads, so the @option{-mpe} option and the @option{-pthread} | |
29592 | option are incompatible. | |
29593 | ||
d77de738 ML |
29594 | @opindex malign-natural |
29595 | @opindex malign-power | |
ddf6fe37 AA |
29596 | @item -malign-natural |
29597 | @itemx -malign-power | |
d77de738 ML |
29598 | On AIX, 32-bit Darwin, and 64-bit PowerPC GNU/Linux, the option |
29599 | @option{-malign-natural} overrides the ABI-defined alignment of larger | |
29600 | types, such as floating-point doubles, on their natural size-based boundary. | |
29601 | The option @option{-malign-power} instructs GCC to follow the ABI-specified | |
29602 | alignment rules. GCC defaults to the standard alignment defined in the ABI@. | |
29603 | ||
29604 | On 64-bit Darwin, natural alignment is the default, and @option{-malign-power} | |
29605 | is not supported. | |
29606 | ||
d77de738 ML |
29607 | @opindex msoft-float |
29608 | @opindex mhard-float | |
ddf6fe37 AA |
29609 | @item -msoft-float |
29610 | @itemx -mhard-float | |
d77de738 ML |
29611 | Generate code that does not use (uses) the floating-point register set. |
29612 | Software floating-point emulation is provided if you use the | |
29613 | @option{-msoft-float} option, and pass the option to GCC when linking. | |
29614 | ||
d77de738 ML |
29615 | @opindex mmultiple |
29616 | @opindex mno-multiple | |
ddf6fe37 AA |
29617 | @item -mmultiple |
29618 | @itemx -mno-multiple | |
d77de738 ML |
29619 | Generate code that uses (does not use) the load multiple word |
29620 | instructions and the store multiple word instructions. These | |
29621 | instructions are generated by default on POWER systems, and not | |
29622 | generated on PowerPC systems. Do not use @option{-mmultiple} on little-endian | |
29623 | PowerPC systems, since those instructions do not work when the | |
29624 | processor is in little-endian mode. The exceptions are PPC740 and | |
29625 | PPC750 which permit these instructions in little-endian mode. | |
29626 | ||
d77de738 ML |
29627 | @opindex mupdate |
29628 | @opindex mno-update | |
ddf6fe37 AA |
29629 | @item -mupdate |
29630 | @itemx -mno-update | |
d77de738 ML |
29631 | Generate code that uses (does not use) the load or store instructions |
29632 | that update the base register to the address of the calculated memory | |
29633 | location. These instructions are generated by default. If you use | |
29634 | @option{-mno-update}, there is a small window between the time that the | |
29635 | stack pointer is updated and the address of the previous frame is | |
29636 | stored, which means code that walks the stack frame across interrupts or | |
29637 | signals may get corrupted data. | |
29638 | ||
d77de738 ML |
29639 | @opindex mavoid-indexed-addresses |
29640 | @opindex mno-avoid-indexed-addresses | |
ddf6fe37 AA |
29641 | @item -mavoid-indexed-addresses |
29642 | @itemx -mno-avoid-indexed-addresses | |
d77de738 ML |
29643 | Generate code that tries to avoid (not avoid) the use of indexed load |
29644 | or store instructions. These instructions can incur a performance | |
29645 | penalty on Power6 processors in certain situations, such as when | |
29646 | stepping through large arrays that cross a 16M boundary. This option | |
29647 | is enabled by default when targeting Power6 and disabled otherwise. | |
29648 | ||
d77de738 ML |
29649 | @opindex mfused-madd |
29650 | @opindex mno-fused-madd | |
ddf6fe37 AA |
29651 | @item -mfused-madd |
29652 | @itemx -mno-fused-madd | |
d77de738 ML |
29653 | Generate code that uses (does not use) the floating-point multiply and |
29654 | accumulate instructions. These instructions are generated by default | |
29655 | if hardware floating point is used. The machine-dependent | |
29656 | @option{-mfused-madd} option is now mapped to the machine-independent | |
29657 | @option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is | |
29658 | mapped to @option{-ffp-contract=off}. | |
29659 | ||
d77de738 ML |
29660 | @opindex mmulhw |
29661 | @opindex mno-mulhw | |
ddf6fe37 AA |
29662 | @item -mmulhw |
29663 | @itemx -mno-mulhw | |
d77de738 ML |
29664 | Generate code that uses (does not use) the half-word multiply and |
29665 | multiply-accumulate instructions on the IBM 405, 440, 464 and 476 processors. | |
29666 | These instructions are generated by default when targeting those | |
29667 | processors. | |
29668 | ||
d77de738 ML |
29669 | @opindex mdlmzb |
29670 | @opindex mno-dlmzb | |
ddf6fe37 AA |
29671 | @item -mdlmzb |
29672 | @itemx -mno-dlmzb | |
d77de738 ML |
29673 | Generate code that uses (does not use) the string-search @samp{dlmzb} |
29674 | instruction on the IBM 405, 440, 464 and 476 processors. This instruction is | |
29675 | generated by default when targeting those processors. | |
29676 | ||
d77de738 ML |
29677 | @opindex mno-bit-align |
29678 | @opindex mbit-align | |
ddf6fe37 AA |
29679 | @item -mno-bit-align |
29680 | @itemx -mbit-align | |
d77de738 ML |
29681 | On System V.4 and embedded PowerPC systems do not (do) force structures |
29682 | and unions that contain bit-fields to be aligned to the base type of the | |
29683 | bit-field. | |
29684 | ||
29685 | For example, by default a structure containing nothing but 8 | |
29686 | @code{unsigned} bit-fields of length 1 is aligned to a 4-byte | |
29687 | boundary and has a size of 4 bytes. By using @option{-mno-bit-align}, | |
29688 | the structure is aligned to a 1-byte boundary and is 1 byte in | |
29689 | size. | |
29690 | ||
d77de738 ML |
29691 | @opindex mno-strict-align |
29692 | @opindex mstrict-align | |
ddf6fe37 AA |
29693 | @item -mno-strict-align |
29694 | @itemx -mstrict-align | |
d77de738 ML |
29695 | On System V.4 and embedded PowerPC systems do not (do) assume that |
29696 | unaligned memory references are handled by the system. | |
29697 | ||
d77de738 ML |
29698 | @opindex mrelocatable |
29699 | @opindex mno-relocatable | |
ddf6fe37 AA |
29700 | @item -mrelocatable |
29701 | @itemx -mno-relocatable | |
d77de738 ML |
29702 | Generate code that allows (does not allow) a static executable to be |
29703 | relocated to a different address at run time. A simple embedded | |
29704 | PowerPC system loader should relocate the entire contents of | |
29705 | @code{.got2} and 4-byte locations listed in the @code{.fixup} section, | |
29706 | a table of 32-bit addresses generated by this option. For this to | |
29707 | work, all objects linked together must be compiled with | |
29708 | @option{-mrelocatable} or @option{-mrelocatable-lib}. | |
29709 | @option{-mrelocatable} code aligns the stack to an 8-byte boundary. | |
29710 | ||
d77de738 ML |
29711 | @opindex mrelocatable-lib |
29712 | @opindex mno-relocatable-lib | |
ddf6fe37 AA |
29713 | @item -mrelocatable-lib |
29714 | @itemx -mno-relocatable-lib | |
d77de738 ML |
29715 | Like @option{-mrelocatable}, @option{-mrelocatable-lib} generates a |
29716 | @code{.fixup} section to allow static executables to be relocated at | |
29717 | run time, but @option{-mrelocatable-lib} does not use the smaller stack | |
29718 | alignment of @option{-mrelocatable}. Objects compiled with | |
29719 | @option{-mrelocatable-lib} may be linked with objects compiled with | |
29720 | any combination of the @option{-mrelocatable} options. | |
29721 | ||
d77de738 ML |
29722 | @opindex mno-toc |
29723 | @opindex mtoc | |
ddf6fe37 AA |
29724 | @item -mno-toc |
29725 | @itemx -mtoc | |
d77de738 ML |
29726 | On System V.4 and embedded PowerPC systems do not (do) assume that |
29727 | register 2 contains a pointer to a global area pointing to the addresses | |
29728 | used in the program. | |
29729 | ||
d77de738 ML |
29730 | @opindex mlittle |
29731 | @opindex mlittle-endian | |
ddf6fe37 AA |
29732 | @item -mlittle |
29733 | @itemx -mlittle-endian | |
d77de738 ML |
29734 | On System V.4 and embedded PowerPC systems compile code for the |
29735 | processor in little-endian mode. The @option{-mlittle-endian} option is | |
29736 | the same as @option{-mlittle}. | |
29737 | ||
d77de738 ML |
29738 | @opindex mbig |
29739 | @opindex mbig-endian | |
ddf6fe37 AA |
29740 | @item -mbig |
29741 | @itemx -mbig-endian | |
d77de738 ML |
29742 | On System V.4 and embedded PowerPC systems compile code for the |
29743 | processor in big-endian mode. The @option{-mbig-endian} option is | |
29744 | the same as @option{-mbig}. | |
29745 | ||
d77de738 | 29746 | @opindex mdynamic-no-pic |
ddf6fe37 | 29747 | @item -mdynamic-no-pic |
d77de738 ML |
29748 | On Darwin and Mac OS X systems, compile code so that it is not |
29749 | relocatable, but that its external references are relocatable. The | |
29750 | resulting code is suitable for applications, but not shared | |
29751 | libraries. | |
29752 | ||
d77de738 | 29753 | @opindex msingle-pic-base |
ddf6fe37 | 29754 | @item -msingle-pic-base |
d77de738 ML |
29755 | Treat the register used for PIC addressing as read-only, rather than |
29756 | loading it in the prologue for each function. The runtime system is | |
29757 | responsible for initializing this register with an appropriate value | |
29758 | before execution begins. | |
29759 | ||
d77de738 | 29760 | @opindex mprioritize-restricted-insns |
ddf6fe37 | 29761 | @item -mprioritize-restricted-insns=@var{priority} |
d77de738 ML |
29762 | This option controls the priority that is assigned to |
29763 | dispatch-slot restricted instructions during the second scheduling | |
29764 | pass. The argument @var{priority} takes the value @samp{0}, @samp{1}, | |
29765 | or @samp{2} to assign no, highest, or second-highest (respectively) | |
29766 | priority to dispatch-slot restricted | |
29767 | instructions. | |
29768 | ||
d77de738 | 29769 | @opindex msched-costly-dep |
ddf6fe37 | 29770 | @item -msched-costly-dep=@var{dependence_type} |
d77de738 ML |
29771 | This option controls which dependences are considered costly |
29772 | by the target during instruction scheduling. The argument | |
29773 | @var{dependence_type} takes one of the following values: | |
29774 | ||
29775 | @table @asis | |
29776 | @item @samp{no} | |
29777 | No dependence is costly. | |
29778 | ||
29779 | @item @samp{all} | |
29780 | All dependences are costly. | |
29781 | ||
29782 | @item @samp{true_store_to_load} | |
29783 | A true dependence from store to load is costly. | |
29784 | ||
29785 | @item @samp{store_to_load} | |
29786 | Any dependence from store to load is costly. | |
29787 | ||
29788 | @item @var{number} | |
29789 | Any dependence for which the latency is greater than or equal to | |
29790 | @var{number} is costly. | |
29791 | @end table | |
29792 | ||
d77de738 | 29793 | @opindex minsert-sched-nops |
ddf6fe37 | 29794 | @item -minsert-sched-nops=@var{scheme} |
d77de738 ML |
29795 | This option controls which NOP insertion scheme is used during |
29796 | the second scheduling pass. The argument @var{scheme} takes one of the | |
29797 | following values: | |
29798 | ||
29799 | @table @asis | |
29800 | @item @samp{no} | |
29801 | Don't insert NOPs. | |
29802 | ||
29803 | @item @samp{pad} | |
29804 | Pad with NOPs any dispatch group that has vacant issue slots, | |
29805 | according to the scheduler's grouping. | |
29806 | ||
29807 | @item @samp{regroup_exact} | |
29808 | Insert NOPs to force costly dependent insns into | |
29809 | separate groups. Insert exactly as many NOPs as needed to force an insn | |
29810 | to a new group, according to the estimated processor grouping. | |
29811 | ||
29812 | @item @var{number} | |
29813 | Insert NOPs to force costly dependent insns into | |
29814 | separate groups. Insert @var{number} NOPs to force an insn to a new group. | |
29815 | @end table | |
29816 | ||
d77de738 | 29817 | @opindex mcall-sysv |
ddf6fe37 | 29818 | @item -mcall-sysv |
d77de738 ML |
29819 | On System V.4 and embedded PowerPC systems compile code using calling |
29820 | conventions that adhere to the March 1995 draft of the System V | |
29821 | Application Binary Interface, PowerPC processor supplement. This is the | |
29822 | default unless you configured GCC using @samp{powerpc-*-eabiaix}. | |
29823 | ||
d77de738 ML |
29824 | @opindex mcall-sysv-eabi |
29825 | @opindex mcall-eabi | |
ddf6fe37 AA |
29826 | @item -mcall-sysv-eabi |
29827 | @itemx -mcall-eabi | |
d77de738 ML |
29828 | Specify both @option{-mcall-sysv} and @option{-meabi} options. |
29829 | ||
d77de738 | 29830 | @opindex mcall-sysv-noeabi |
ddf6fe37 | 29831 | @item -mcall-sysv-noeabi |
d77de738 ML |
29832 | Specify both @option{-mcall-sysv} and @option{-mno-eabi} options. |
29833 | ||
d7971cf7 | 29834 | @opindex mcall-aixdesc |
ddf6fe37 | 29835 | @item -mcall-aixdesc |
d77de738 ML |
29836 | On System V.4 and embedded PowerPC systems compile code for the AIX |
29837 | operating system. | |
29838 | ||
d77de738 | 29839 | @opindex mcall-linux |
ddf6fe37 | 29840 | @item -mcall-linux |
d77de738 ML |
29841 | On System V.4 and embedded PowerPC systems compile code for the |
29842 | Linux-based GNU system. | |
29843 | ||
d77de738 | 29844 | @opindex mcall-freebsd |
ddf6fe37 | 29845 | @item -mcall-freebsd |
d77de738 ML |
29846 | On System V.4 and embedded PowerPC systems compile code for the |
29847 | FreeBSD operating system. | |
29848 | ||
d77de738 | 29849 | @opindex mcall-netbsd |
ddf6fe37 | 29850 | @item -mcall-netbsd |
d77de738 ML |
29851 | On System V.4 and embedded PowerPC systems compile code for the |
29852 | NetBSD operating system. | |
29853 | ||
d7971cf7 | 29854 | @opindex mcall-openbsd |
ddf6fe37 | 29855 | @item -mcall-openbsd |
d77de738 ML |
29856 | On System V.4 and embedded PowerPC systems compile code for the |
29857 | OpenBSD operating system. | |
29858 | ||
d77de738 | 29859 | @opindex mtraceback |
ddf6fe37 | 29860 | @item -mtraceback=@var{traceback_type} |
d77de738 ML |
29861 | Select the type of traceback table. Valid values for @var{traceback_type} |
29862 | are @samp{full}, @samp{part}, and @samp{no}. | |
29863 | ||
d77de738 | 29864 | @opindex maix-struct-return |
ddf6fe37 | 29865 | @item -maix-struct-return |
d77de738 ML |
29866 | Return all structures in memory (as specified by the AIX ABI)@. |
29867 | ||
d77de738 | 29868 | @opindex msvr4-struct-return |
ddf6fe37 | 29869 | @item -msvr4-struct-return |
d77de738 ML |
29870 | Return structures smaller than 8 bytes in registers (as specified by the |
29871 | SVR4 ABI)@. | |
29872 | ||
d77de738 | 29873 | @opindex mabi |
ddf6fe37 | 29874 | @item -mabi=@var{abi-type} |
d77de738 ML |
29875 | Extend the current ABI with a particular extension, or remove such extension. |
29876 | Valid values are: @samp{altivec}, @samp{no-altivec}, | |
29877 | @samp{ibmlongdouble}, @samp{ieeelongdouble}, | |
29878 | @samp{elfv1}, @samp{elfv2}, | |
29879 | and for AIX: @samp{vec-extabi}, @samp{vec-default}@. | |
29880 | ||
d77de738 | 29881 | @opindex mabi=ibmlongdouble |
ddf6fe37 | 29882 | @item -mabi=ibmlongdouble |
d77de738 ML |
29883 | Change the current ABI to use IBM extended-precision long double. |
29884 | This is not likely to work if your system defaults to using IEEE | |
29885 | extended-precision long double. If you change the long double type | |
29886 | from IEEE extended-precision, the compiler will issue a warning unless | |
29887 | you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128} | |
29888 | to be enabled. | |
29889 | ||
d77de738 | 29890 | @opindex mabi=ieeelongdouble |
ddf6fe37 | 29891 | @item -mabi=ieeelongdouble |
d77de738 ML |
29892 | Change the current ABI to use IEEE extended-precision long double. |
29893 | This is not likely to work if your system defaults to using IBM | |
29894 | extended-precision long double. If you change the long double type | |
29895 | from IBM extended-precision, the compiler will issue a warning unless | |
29896 | you use the @option{-Wno-psabi} option. Requires @option{-mlong-double-128} | |
29897 | to be enabled. | |
29898 | ||
d77de738 | 29899 | @opindex mabi=elfv1 |
ddf6fe37 | 29900 | @item -mabi=elfv1 |
d77de738 ML |
29901 | Change the current ABI to use the ELFv1 ABI. |
29902 | This is the default ABI for big-endian PowerPC 64-bit Linux. | |
29903 | Overriding the default ABI requires special system support and is | |
29904 | likely to fail in spectacular ways. | |
29905 | ||
d77de738 | 29906 | @opindex mabi=elfv2 |
ddf6fe37 | 29907 | @item -mabi=elfv2 |
d77de738 ML |
29908 | Change the current ABI to use the ELFv2 ABI. |
29909 | This is the default ABI for little-endian PowerPC 64-bit Linux. | |
29910 | Overriding the default ABI requires special system support and is | |
29911 | likely to fail in spectacular ways. | |
29912 | ||
d77de738 ML |
29913 | @opindex mgnu-attribute |
29914 | @opindex mno-gnu-attribute | |
ddf6fe37 AA |
29915 | @item -mgnu-attribute |
29916 | @itemx -mno-gnu-attribute | |
d77de738 ML |
29917 | Emit .gnu_attribute assembly directives to set tag/value pairs in a |
29918 | .gnu.attributes section that specify ABI variations in function | |
29919 | parameters or return values. | |
29920 | ||
d77de738 ML |
29921 | @opindex mprototype |
29922 | @opindex mno-prototype | |
ddf6fe37 AA |
29923 | @item -mprototype |
29924 | @itemx -mno-prototype | |
d77de738 ML |
29925 | On System V.4 and embedded PowerPC systems assume that all calls to |
29926 | variable argument functions are properly prototyped. Otherwise, the | |
29927 | compiler must insert an instruction before every non-prototyped call to | |
29928 | set or clear bit 6 of the condition code register (@code{CR}) to | |
29929 | indicate whether floating-point values are passed in the floating-point | |
29930 | registers in case the function takes variable arguments. With | |
29931 | @option{-mprototype}, only calls to prototyped variable argument functions | |
29932 | set or clear the bit. | |
29933 | ||
d77de738 | 29934 | @opindex msim |
ddf6fe37 | 29935 | @item -msim |
d77de738 ML |
29936 | On embedded PowerPC systems, assume that the startup module is called |
29937 | @file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and | |
29938 | @file{libc.a}. This is the default for @samp{powerpc-*-eabisim} | |
29939 | configurations. | |
29940 | ||
d77de738 | 29941 | @opindex mmvme |
ddf6fe37 | 29942 | @item -mmvme |
d77de738 ML |
29943 | On embedded PowerPC systems, assume that the startup module is called |
29944 | @file{crt0.o} and the standard C libraries are @file{libmvme.a} and | |
29945 | @file{libc.a}. | |
29946 | ||
d77de738 | 29947 | @opindex mads |
ddf6fe37 | 29948 | @item -mads |
d77de738 ML |
29949 | On embedded PowerPC systems, assume that the startup module is called |
29950 | @file{crt0.o} and the standard C libraries are @file{libads.a} and | |
29951 | @file{libc.a}. | |
29952 | ||
d77de738 | 29953 | @opindex myellowknife |
ddf6fe37 | 29954 | @item -myellowknife |
d77de738 ML |
29955 | On embedded PowerPC systems, assume that the startup module is called |
29956 | @file{crt0.o} and the standard C libraries are @file{libyk.a} and | |
29957 | @file{libc.a}. | |
29958 | ||
d77de738 | 29959 | @opindex mvxworks |
ddf6fe37 | 29960 | @item -mvxworks |
d77de738 ML |
29961 | On System V.4 and embedded PowerPC systems, specify that you are |
29962 | compiling for a VxWorks system. | |
29963 | ||
d77de738 | 29964 | @opindex memb |
ddf6fe37 | 29965 | @item -memb |
d77de738 ML |
29966 | On embedded PowerPC systems, set the @code{PPC_EMB} bit in the ELF flags |
29967 | header to indicate that @samp{eabi} extended relocations are used. | |
29968 | ||
d77de738 ML |
29969 | @opindex meabi |
29970 | @opindex mno-eabi | |
ddf6fe37 AA |
29971 | @item -meabi |
29972 | @itemx -mno-eabi | |
d77de738 ML |
29973 | On System V.4 and embedded PowerPC systems do (do not) adhere to the |
29974 | Embedded Applications Binary Interface (EABI), which is a set of | |
29975 | modifications to the System V.4 specifications. Selecting @option{-meabi} | |
29976 | means that the stack is aligned to an 8-byte boundary, a function | |
29977 | @code{__eabi} is called from @code{main} to set up the EABI | |
29978 | environment, and the @option{-msdata} option can use both @code{r2} and | |
29979 | @code{r13} to point to two separate small data areas. Selecting | |
29980 | @option{-mno-eabi} means that the stack is aligned to a 16-byte boundary, | |
29981 | no EABI initialization function is called from @code{main}, and the | |
29982 | @option{-msdata} option only uses @code{r13} to point to a single | |
29983 | small data area. The @option{-meabi} option is on by default if you | |
29984 | configured GCC using one of the @samp{powerpc*-*-eabi*} options. | |
29985 | ||
d77de738 | 29986 | @opindex msdata=eabi |
ddf6fe37 | 29987 | @item -msdata=eabi |
d77de738 ML |
29988 | On System V.4 and embedded PowerPC systems, put small initialized |
29989 | @code{const} global and static data in the @code{.sdata2} section, which | |
29990 | is pointed to by register @code{r2}. Put small initialized | |
29991 | non-@code{const} global and static data in the @code{.sdata} section, | |
29992 | which is pointed to by register @code{r13}. Put small uninitialized | |
29993 | global and static data in the @code{.sbss} section, which is adjacent to | |
29994 | the @code{.sdata} section. The @option{-msdata=eabi} option is | |
29995 | incompatible with the @option{-mrelocatable} option. The | |
29996 | @option{-msdata=eabi} option also sets the @option{-memb} option. | |
29997 | ||
d77de738 | 29998 | @opindex msdata=sysv |
ddf6fe37 | 29999 | @item -msdata=sysv |
d77de738 ML |
30000 | On System V.4 and embedded PowerPC systems, put small global and static |
30001 | data in the @code{.sdata} section, which is pointed to by register | |
30002 | @code{r13}. Put small uninitialized global and static data in the | |
30003 | @code{.sbss} section, which is adjacent to the @code{.sdata} section. | |
30004 | The @option{-msdata=sysv} option is incompatible with the | |
30005 | @option{-mrelocatable} option. | |
30006 | ||
d77de738 ML |
30007 | @opindex msdata=default |
30008 | @opindex msdata | |
ddf6fe37 AA |
30009 | @item -msdata=default |
30010 | @itemx -msdata | |
d77de738 ML |
30011 | On System V.4 and embedded PowerPC systems, if @option{-meabi} is used, |
30012 | compile code the same as @option{-msdata=eabi}, otherwise compile code the | |
30013 | same as @option{-msdata=sysv}. | |
30014 | ||
d77de738 | 30015 | @opindex msdata=data |
ddf6fe37 | 30016 | @item -msdata=data |
d77de738 ML |
30017 | On System V.4 and embedded PowerPC systems, put small global |
30018 | data in the @code{.sdata} section. Put small uninitialized global | |
30019 | data in the @code{.sbss} section. Do not use register @code{r13} | |
30020 | to address small data however. This is the default behavior unless | |
30021 | other @option{-msdata} options are used. | |
30022 | ||
d77de738 ML |
30023 | @opindex msdata=none |
30024 | @opindex mno-sdata | |
ddf6fe37 AA |
30025 | @item -msdata=none |
30026 | @itemx -mno-sdata | |
d77de738 ML |
30027 | On embedded PowerPC systems, put all initialized global and static data |
30028 | in the @code{.data} section, and all uninitialized data in the | |
30029 | @code{.bss} section. | |
30030 | ||
d77de738 ML |
30031 | @opindex mreadonly-in-sdata |
30032 | @opindex mno-readonly-in-sdata | |
ddf6fe37 | 30033 | @item -mreadonly-in-sdata |
d77de738 ML |
30034 | Put read-only objects in the @code{.sdata} section as well. This is the |
30035 | default. | |
30036 | ||
d77de738 | 30037 | @opindex mblock-move-inline-limit |
ddf6fe37 | 30038 | @item -mblock-move-inline-limit=@var{num} |
d77de738 ML |
30039 | Inline all block moves (such as calls to @code{memcpy} or structure |
30040 | copies) less than or equal to @var{num} bytes. The minimum value for | |
30041 | @var{num} is 32 bytes on 32-bit targets and 64 bytes on 64-bit | |
30042 | targets. The default value is target-specific. | |
30043 | ||
d77de738 | 30044 | @opindex mblock-compare-inline-limit |
ddf6fe37 | 30045 | @item -mblock-compare-inline-limit=@var{num} |
d77de738 ML |
30046 | Generate non-looping inline code for all block compares (such as calls |
30047 | to @code{memcmp} or structure compares) less than or equal to @var{num} | |
30048 | bytes. If @var{num} is 0, all inline expansion (non-loop and loop) of | |
30049 | block compare is disabled. The default value is target-specific. | |
30050 | ||
d77de738 | 30051 | @opindex mblock-compare-inline-loop-limit |
ddf6fe37 | 30052 | @item -mblock-compare-inline-loop-limit=@var{num} |
d77de738 ML |
30053 | Generate an inline expansion using loop code for all block compares that |
30054 | are less than or equal to @var{num} bytes, but greater than the limit | |
30055 | for non-loop inline block compare expansion. If the block length is not | |
30056 | constant, at most @var{num} bytes will be compared before @code{memcmp} | |
30057 | is called to compare the remainder of the block. The default value is | |
30058 | target-specific. | |
30059 | ||
d77de738 | 30060 | @opindex mstring-compare-inline-limit |
ddf6fe37 | 30061 | @item -mstring-compare-inline-limit=@var{num} |
d77de738 ML |
30062 | Compare at most @var{num} string bytes with inline code. |
30063 | If the difference or end of string is not found at the | |
30064 | end of the inline compare a call to @code{strcmp} or @code{strncmp} will | |
30065 | take care of the rest of the comparison. The default is 64 bytes. | |
30066 | ||
d77de738 ML |
30067 | @opindex G |
30068 | @cindex smaller data references (PowerPC) | |
30069 | @cindex .sdata/.sdata2 references (PowerPC) | |
f33d7a88 | 30070 | @item -G @var{num} |
d77de738 ML |
30071 | On embedded PowerPC systems, put global and static items less than or |
30072 | equal to @var{num} bytes into the small data or BSS sections instead of | |
30073 | the normal data or BSS section. By default, @var{num} is 8. The | |
30074 | @option{-G @var{num}} switch is also passed to the linker. | |
30075 | All modules should be compiled with the same @option{-G @var{num}} value. | |
30076 | ||
d77de738 ML |
30077 | @opindex mregnames |
30078 | @opindex mno-regnames | |
ddf6fe37 AA |
30079 | @item -mregnames |
30080 | @itemx -mno-regnames | |
d77de738 ML |
30081 | On System V.4 and embedded PowerPC systems do (do not) emit register |
30082 | names in the assembly language output using symbolic forms. | |
30083 | ||
d77de738 ML |
30084 | @opindex mlongcall |
30085 | @opindex mno-longcall | |
ddf6fe37 AA |
30086 | @item -mlongcall |
30087 | @itemx -mno-longcall | |
d77de738 ML |
30088 | By default assume that all calls are far away so that a longer and more |
30089 | expensive calling sequence is required. This is required for calls | |
30090 | farther than 32 megabytes (33,554,432 bytes) from the current location. | |
30091 | A short call is generated if the compiler knows | |
30092 | the call cannot be that far away. This setting can be overridden by | |
30093 | the @code{shortcall} function attribute, or by @code{#pragma | |
30094 | longcall(0)}. | |
30095 | ||
30096 | Some linkers are capable of detecting out-of-range calls and generating | |
30097 | glue code on the fly. On these systems, long calls are unnecessary and | |
30098 | generate slower code. As of this writing, the AIX linker can do this, | |
30099 | as can the GNU linker for PowerPC/64. It is planned to add this feature | |
30100 | to the GNU linker for 32-bit PowerPC systems as well. | |
30101 | ||
30102 | On PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU linkers, | |
30103 | GCC can generate long calls using an inline PLT call sequence (see | |
30104 | @option{-mpltseq}). PowerPC with @option{-mbss-plt} and PowerPC64 | |
30105 | ELFv1 (big-endian) do not support inline PLT calls. | |
30106 | ||
30107 | On Darwin/PPC systems, @code{#pragma longcall} generates @code{jbsr | |
30108 | callee, L42}, plus a @dfn{branch island} (glue code). The two target | |
30109 | addresses represent the callee and the branch island. The | |
30110 | Darwin/PPC linker prefers the first address and generates a @code{bl | |
30111 | callee} if the PPC @code{bl} instruction reaches the callee directly; | |
30112 | otherwise, the linker generates @code{bl L42} to call the branch | |
30113 | island. The branch island is appended to the body of the | |
30114 | calling function; it computes the full 32-bit address of the callee | |
30115 | and jumps to it. | |
30116 | ||
30117 | On Mach-O (Darwin) systems, this option directs the compiler emit to | |
30118 | the glue for every direct call, and the Darwin linker decides whether | |
30119 | to use or discard it. | |
30120 | ||
30121 | In the future, GCC may ignore all longcall specifications | |
30122 | when the linker is known to generate glue. | |
30123 | ||
d77de738 ML |
30124 | @opindex mpltseq |
30125 | @opindex mno-pltseq | |
ddf6fe37 AA |
30126 | @item -mpltseq |
30127 | @itemx -mno-pltseq | |
d77de738 ML |
30128 | Implement (do not implement) -fno-plt and long calls using an inline |
30129 | PLT call sequence that supports lazy linking and long calls to | |
30130 | functions in dlopen'd shared libraries. Inline PLT calls are only | |
30131 | supported on PowerPC64 ELFv2 and 32-bit PowerPC systems with newer GNU | |
30132 | linkers, and are enabled by default if the support is detected when | |
30133 | configuring GCC, and, in the case of 32-bit PowerPC, if GCC is | |
30134 | configured with @option{--enable-secureplt}. @option{-mpltseq} code | |
30135 | and @option{-mbss-plt} 32-bit PowerPC relocatable objects may not be | |
30136 | linked together. | |
30137 | ||
d77de738 ML |
30138 | @opindex mtls-markers |
30139 | @opindex mno-tls-markers | |
ddf6fe37 AA |
30140 | @item -mtls-markers |
30141 | @itemx -mno-tls-markers | |
d77de738 ML |
30142 | Mark (do not mark) calls to @code{__tls_get_addr} with a relocation |
30143 | specifying the function argument. The relocation allows the linker to | |
30144 | reliably associate function call with argument setup instructions for | |
30145 | TLS optimization, which in turn allows GCC to better schedule the | |
30146 | sequence. | |
30147 | ||
ddf6fe37 | 30148 | @opindex mrecip |
d77de738 ML |
30149 | @item -mrecip |
30150 | @itemx -mno-recip | |
d77de738 ML |
30151 | This option enables use of the reciprocal estimate and |
30152 | reciprocal square root estimate instructions with additional | |
30153 | Newton-Raphson steps to increase precision instead of doing a divide or | |
30154 | square root and divide for floating-point arguments. You should use | |
30155 | the @option{-ffast-math} option when using @option{-mrecip} (or at | |
30156 | least @option{-funsafe-math-optimizations}, | |
30157 | @option{-ffinite-math-only}, @option{-freciprocal-math} and | |
30158 | @option{-fno-trapping-math}). Note that while the throughput of the | |
30159 | sequence is generally higher than the throughput of the non-reciprocal | |
30160 | instruction, the precision of the sequence can be decreased by up to 2 | |
30161 | ulp (i.e.@: the inverse of 1.0 equals 0.99999994) for reciprocal square | |
30162 | roots. | |
30163 | ||
d77de738 | 30164 | @opindex mrecip=opt |
ddf6fe37 | 30165 | @item -mrecip=@var{opt} |
d77de738 ML |
30166 | This option controls which reciprocal estimate instructions |
30167 | may be used. @var{opt} is a comma-separated list of options, which may | |
30168 | be preceded by a @code{!} to invert the option: | |
30169 | ||
30170 | @table @samp | |
30171 | ||
30172 | @item all | |
30173 | Enable all estimate instructions. | |
30174 | ||
30175 | @item default | |
30176 | Enable the default instructions, equivalent to @option{-mrecip}. | |
30177 | ||
30178 | @item none | |
30179 | Disable all estimate instructions, equivalent to @option{-mno-recip}. | |
30180 | ||
30181 | @item div | |
30182 | Enable the reciprocal approximation instructions for both | |
30183 | single and double precision. | |
30184 | ||
30185 | @item divf | |
30186 | Enable the single-precision reciprocal approximation instructions. | |
30187 | ||
30188 | @item divd | |
30189 | Enable the double-precision reciprocal approximation instructions. | |
30190 | ||
30191 | @item rsqrt | |
30192 | Enable the reciprocal square root approximation instructions for both | |
30193 | single and double precision. | |
30194 | ||
30195 | @item rsqrtf | |
30196 | Enable the single-precision reciprocal square root approximation instructions. | |
30197 | ||
30198 | @item rsqrtd | |
30199 | Enable the double-precision reciprocal square root approximation instructions. | |
30200 | ||
30201 | @end table | |
30202 | ||
30203 | So, for example, @option{-mrecip=all,!rsqrtd} enables | |
30204 | all of the reciprocal estimate instructions, except for the | |
30205 | @code{FRSQRTE}, @code{XSRSQRTEDP}, and @code{XVRSQRTEDP} instructions | |
30206 | which handle the double-precision reciprocal square root calculations. | |
30207 | ||
ddf6fe37 | 30208 | @opindex mrecip-precision |
d77de738 ML |
30209 | @item -mrecip-precision |
30210 | @itemx -mno-recip-precision | |
d77de738 ML |
30211 | Assume (do not assume) that the reciprocal estimate instructions |
30212 | provide higher-precision estimates than is mandated by the PowerPC | |
30213 | ABI. Selecting @option{-mcpu=power6}, @option{-mcpu=power7} or | |
30214 | @option{-mcpu=power8} automatically selects @option{-mrecip-precision}. | |
30215 | The double-precision square root estimate instructions are not generated by | |
30216 | default on low-precision machines, since they do not provide an | |
30217 | estimate that converges after three steps. | |
30218 | ||
d77de738 | 30219 | @opindex mveclibabi |
ddf6fe37 | 30220 | @item -mveclibabi=@var{type} |
d77de738 ML |
30221 | Specifies the ABI type to use for vectorizing intrinsics using an |
30222 | external library. The only type supported at present is @samp{mass}, | |
30223 | which specifies to use IBM's Mathematical Acceleration Subsystem | |
30224 | (MASS) libraries for vectorizing intrinsics using external libraries. | |
30225 | GCC currently emits calls to @code{acosd2}, @code{acosf4}, | |
30226 | @code{acoshd2}, @code{acoshf4}, @code{asind2}, @code{asinf4}, | |
30227 | @code{asinhd2}, @code{asinhf4}, @code{atan2d2}, @code{atan2f4}, | |
30228 | @code{atand2}, @code{atanf4}, @code{atanhd2}, @code{atanhf4}, | |
30229 | @code{cbrtd2}, @code{cbrtf4}, @code{cosd2}, @code{cosf4}, | |
30230 | @code{coshd2}, @code{coshf4}, @code{erfcd2}, @code{erfcf4}, | |
30231 | @code{erfd2}, @code{erff4}, @code{exp2d2}, @code{exp2f4}, | |
30232 | @code{expd2}, @code{expf4}, @code{expm1d2}, @code{expm1f4}, | |
30233 | @code{hypotd2}, @code{hypotf4}, @code{lgammad2}, @code{lgammaf4}, | |
30234 | @code{log10d2}, @code{log10f4}, @code{log1pd2}, @code{log1pf4}, | |
30235 | @code{log2d2}, @code{log2f4}, @code{logd2}, @code{logf4}, | |
30236 | @code{powd2}, @code{powf4}, @code{sind2}, @code{sinf4}, @code{sinhd2}, | |
30237 | @code{sinhf4}, @code{sqrtd2}, @code{sqrtf4}, @code{tand2}, | |
30238 | @code{tanf4}, @code{tanhd2}, and @code{tanhf4} when generating code | |
30239 | for power7. Both @option{-ftree-vectorize} and | |
30240 | @option{-funsafe-math-optimizations} must also be enabled. The MASS | |
30241 | libraries must be specified at link time. | |
30242 | ||
ddf6fe37 | 30243 | @opindex mfriz |
d77de738 ML |
30244 | @item -mfriz |
30245 | @itemx -mno-friz | |
d77de738 ML |
30246 | Generate (do not generate) the @code{friz} instruction when the |
30247 | @option{-funsafe-math-optimizations} option is used to optimize | |
30248 | rounding of floating-point values to 64-bit integer and back to floating | |
30249 | point. The @code{friz} instruction does not return the same value if | |
30250 | the floating-point number is too large to fit in an integer. | |
30251 | ||
ddf6fe37 | 30252 | @opindex mpointers-to-nested-functions |
d77de738 ML |
30253 | @item -mpointers-to-nested-functions |
30254 | @itemx -mno-pointers-to-nested-functions | |
d77de738 ML |
30255 | Generate (do not generate) code to load up the static chain register |
30256 | (@code{r11}) when calling through a pointer on AIX and 64-bit Linux | |
30257 | systems where a function pointer points to a 3-word descriptor giving | |
30258 | the function address, TOC value to be loaded in register @code{r2}, and | |
30259 | static chain value to be loaded in register @code{r11}. The | |
30260 | @option{-mpointers-to-nested-functions} is on by default. You cannot | |
30261 | call through pointers to nested functions or pointers | |
30262 | to functions compiled in other languages that use the static chain if | |
30263 | you use @option{-mno-pointers-to-nested-functions}. | |
30264 | ||
ddf6fe37 | 30265 | @opindex msave-toc-indirect |
d77de738 ML |
30266 | @item -msave-toc-indirect |
30267 | @itemx -mno-save-toc-indirect | |
d77de738 ML |
30268 | Generate (do not generate) code to save the TOC value in the reserved |
30269 | stack location in the function prologue if the function calls through | |
30270 | a pointer on AIX and 64-bit Linux systems. If the TOC value is not | |
30271 | saved in the prologue, it is saved just before the call through the | |
30272 | pointer. The @option{-mno-save-toc-indirect} option is the default. | |
30273 | ||
ddf6fe37 | 30274 | @opindex mcompat-align-parm |
d77de738 ML |
30275 | @item -mcompat-align-parm |
30276 | @itemx -mno-compat-align-parm | |
d77de738 ML |
30277 | Generate (do not generate) code to pass structure parameters with a |
30278 | maximum alignment of 64 bits, for compatibility with older versions | |
30279 | of GCC. | |
30280 | ||
30281 | Older versions of GCC (prior to 4.9.0) incorrectly did not align a | |
30282 | structure parameter on a 128-bit boundary when that structure contained | |
30283 | a member requiring 128-bit alignment. This is corrected in more | |
30284 | recent versions of GCC. This option may be used to generate code | |
30285 | that is compatible with functions compiled with older versions of | |
30286 | GCC. | |
30287 | ||
30288 | The @option{-mno-compat-align-parm} option is the default. | |
30289 | ||
d77de738 ML |
30290 | @opindex mstack-protector-guard |
30291 | @opindex mstack-protector-guard-reg | |
30292 | @opindex mstack-protector-guard-offset | |
30293 | @opindex mstack-protector-guard-symbol | |
ddf6fe37 AA |
30294 | @item -mstack-protector-guard=@var{guard} |
30295 | @itemx -mstack-protector-guard-reg=@var{reg} | |
30296 | @itemx -mstack-protector-guard-offset=@var{offset} | |
30297 | @itemx -mstack-protector-guard-symbol=@var{symbol} | |
d77de738 ML |
30298 | Generate stack protection code using canary at @var{guard}. Supported |
30299 | locations are @samp{global} for global canary or @samp{tls} for per-thread | |
30300 | canary in the TLS block (the default with GNU libc version 2.4 or later). | |
30301 | ||
30302 | With the latter choice the options | |
30303 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
30304 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
30305 | which register to use as base register for reading the canary, and from what | |
30306 | offset from that base register. The default for those is as specified in the | |
30307 | relevant ABI. @option{-mstack-protector-guard-symbol=@var{symbol}} overrides | |
30308 | the offset with a symbol reference to a canary in the TLS block. | |
30309 | ||
d77de738 ML |
30310 | @opindex mpcrel |
30311 | @opindex mno-pcrel | |
ddf6fe37 AA |
30312 | @item -mpcrel |
30313 | @itemx -mno-pcrel | |
d77de738 ML |
30314 | Generate (do not generate) pc-relative addressing. The @option{-mpcrel} |
30315 | option requires that the medium code model (@option{-mcmodel=medium}) | |
30316 | and prefixed addressing (@option{-mprefixed}) options are enabled. | |
30317 | ||
d77de738 ML |
30318 | @opindex mprefixed |
30319 | @opindex mno-prefixed | |
ddf6fe37 AA |
30320 | @item -mprefixed |
30321 | @itemx -mno-prefixed | |
d77de738 ML |
30322 | Generate (do not generate) addressing modes using prefixed load and |
30323 | store instructions. The @option{-mprefixed} option requires that | |
30324 | the option @option{-mcpu=power10} (or later) is enabled. | |
30325 | ||
d77de738 ML |
30326 | @opindex mmma |
30327 | @opindex mno-mma | |
ddf6fe37 AA |
30328 | @item -mmma |
30329 | @itemx -mno-mma | |
d77de738 ML |
30330 | Generate (do not generate) the MMA instructions. The @option{-mma} |
30331 | option requires that the option @option{-mcpu=power10} (or later) | |
30332 | is enabled. | |
30333 | ||
d77de738 ML |
30334 | @opindex mrop-protect |
30335 | @opindex mno-rop-protect | |
ddf6fe37 AA |
30336 | @item -mrop-protect |
30337 | @itemx -mno-rop-protect | |
d77de738 ML |
30338 | Generate (do not generate) ROP protection instructions when the target |
30339 | processor supports them. Currently this option disables the shrink-wrap | |
30340 | optimization (@option{-fshrink-wrap}). | |
30341 | ||
d77de738 ML |
30342 | @opindex mprivileged |
30343 | @opindex mno-privileged | |
ddf6fe37 AA |
30344 | @item -mprivileged |
30345 | @itemx -mno-privileged | |
d77de738 ML |
30346 | Generate (do not generate) code that will run in privileged state. |
30347 | ||
d77de738 ML |
30348 | @opindex block-ops-unaligned-vsx |
30349 | @opindex no-block-ops-unaligned-vsx | |
ddf6fe37 AA |
30350 | @item -mblock-ops-unaligned-vsx |
30351 | @itemx -mno-block-ops-unaligned-vsx | |
d77de738 ML |
30352 | Generate (do not generate) unaligned vsx loads and stores for |
30353 | inline expansion of @code{memcpy} and @code{memmove}. | |
30354 | ||
30355 | @item --param rs6000-vect-unroll-limit= | |
30356 | The vectorizer will check with target information to determine whether it | |
30357 | would be beneficial to unroll the main vectorized loop and by how much. This | |
30358 | parameter sets the upper bound of how much the vectorizer will unroll the main | |
30359 | loop. The default value is four. | |
30360 | ||
30361 | @end table | |
30362 | ||
30363 | @node RX Options | |
30364 | @subsection RX Options | |
30365 | @cindex RX Options | |
30366 | ||
30367 | These command-line options are defined for RX targets: | |
30368 | ||
30369 | @table @gcctabopt | |
d77de738 ML |
30370 | @opindex m64bit-doubles |
30371 | @opindex m32bit-doubles | |
ddf6fe37 AA |
30372 | @item -m64bit-doubles |
30373 | @itemx -m32bit-doubles | |
d77de738 ML |
30374 | Make the @code{double} data type be 64 bits (@option{-m64bit-doubles}) |
30375 | or 32 bits (@option{-m32bit-doubles}) in size. The default is | |
30376 | @option{-m32bit-doubles}. @emph{Note} RX floating-point hardware only | |
30377 | works on 32-bit values, which is why the default is | |
30378 | @option{-m32bit-doubles}. | |
30379 | ||
d77de738 ML |
30380 | @opindex fpu |
30381 | @opindex nofpu | |
ddf6fe37 AA |
30382 | @item -fpu |
30383 | @itemx -nofpu | |
d77de738 ML |
30384 | Enables (@option{-fpu}) or disables (@option{-nofpu}) the use of RX |
30385 | floating-point hardware. The default is enabled for the RX600 | |
30386 | series and disabled for the RX200 series. | |
30387 | ||
30388 | Floating-point instructions are only generated for 32-bit floating-point | |
30389 | values, however, so the FPU hardware is not used for doubles if the | |
30390 | @option{-m64bit-doubles} option is used. | |
30391 | ||
30392 | @emph{Note} If the @option{-fpu} option is enabled then | |
30393 | @option{-funsafe-math-optimizations} is also enabled automatically. | |
30394 | This is because the RX FPU instructions are themselves unsafe. | |
30395 | ||
d77de738 | 30396 | @opindex mcpu |
ddf6fe37 | 30397 | @item -mcpu=@var{name} |
d77de738 ML |
30398 | Selects the type of RX CPU to be targeted. Currently three types are |
30399 | supported, the generic @samp{RX600} and @samp{RX200} series hardware and | |
30400 | the specific @samp{RX610} CPU. The default is @samp{RX600}. | |
30401 | ||
30402 | The only difference between @samp{RX600} and @samp{RX610} is that the | |
30403 | @samp{RX610} does not support the @code{MVTIPL} instruction. | |
30404 | ||
30405 | The @samp{RX200} series does not have a hardware floating-point unit | |
30406 | and so @option{-nofpu} is enabled by default when this type is | |
30407 | selected. | |
30408 | ||
d77de738 ML |
30409 | @opindex mbig-endian-data |
30410 | @opindex mlittle-endian-data | |
ddf6fe37 AA |
30411 | @item -mbig-endian-data |
30412 | @itemx -mlittle-endian-data | |
d77de738 ML |
30413 | Store data (but not code) in the big-endian format. The default is |
30414 | @option{-mlittle-endian-data}, i.e.@: to store data in the little-endian | |
30415 | format. | |
30416 | ||
d77de738 | 30417 | @opindex msmall-data-limit |
ddf6fe37 | 30418 | @item -msmall-data-limit=@var{N} |
d77de738 ML |
30419 | Specifies the maximum size in bytes of global and static variables |
30420 | which can be placed into the small data area. Using the small data | |
30421 | area can lead to smaller and faster code, but the size of area is | |
30422 | limited and it is up to the programmer to ensure that the area does | |
30423 | not overflow. Also when the small data area is used one of the RX's | |
30424 | registers (usually @code{r13}) is reserved for use pointing to this | |
30425 | area, so it is no longer available for use by the compiler. This | |
30426 | could result in slower and/or larger code if variables are pushed onto | |
30427 | the stack instead of being held in this register. | |
30428 | ||
30429 | Note, common variables (variables that have not been initialized) and | |
30430 | constants are not placed into the small data area as they are assigned | |
30431 | to other sections in the output executable. | |
30432 | ||
30433 | The default value is zero, which disables this feature. Note, this | |
30434 | feature is not enabled by default with higher optimization levels | |
30435 | (@option{-O2} etc) because of the potentially detrimental effects of | |
30436 | reserving a register. It is up to the programmer to experiment and | |
30437 | discover whether this feature is of benefit to their program. See the | |
30438 | description of the @option{-mpid} option for a description of how the | |
30439 | actual register to hold the small data area pointer is chosen. | |
30440 | ||
d77de738 ML |
30441 | @opindex msim |
30442 | @opindex mno-sim | |
ddf6fe37 AA |
30443 | @item -msim |
30444 | @itemx -mno-sim | |
d77de738 ML |
30445 | Use the simulator runtime. The default is to use the libgloss |
30446 | board-specific runtime. | |
30447 | ||
d77de738 ML |
30448 | @opindex mas100-syntax |
30449 | @opindex mno-as100-syntax | |
ddf6fe37 AA |
30450 | @item -mas100-syntax |
30451 | @itemx -mno-as100-syntax | |
d77de738 ML |
30452 | When generating assembler output use a syntax that is compatible with |
30453 | Renesas's AS100 assembler. This syntax can also be handled by the GAS | |
30454 | assembler, but it has some restrictions so it is not generated by default. | |
30455 | ||
d77de738 | 30456 | @opindex mmax-constant-size |
ddf6fe37 | 30457 | @item -mmax-constant-size=@var{N} |
d77de738 ML |
30458 | Specifies the maximum size, in bytes, of a constant that can be used as |
30459 | an operand in a RX instruction. Although the RX instruction set does | |
30460 | allow constants of up to 4 bytes in length to be used in instructions, | |
30461 | a longer value equates to a longer instruction. Thus in some | |
30462 | circumstances it can be beneficial to restrict the size of constants | |
30463 | that are used in instructions. Constants that are too big are instead | |
30464 | placed into a constant pool and referenced via register indirection. | |
30465 | ||
30466 | The value @var{N} can be between 0 and 4. A value of 0 (the default) | |
30467 | or 4 means that constants of any size are allowed. | |
30468 | ||
d77de738 | 30469 | @opindex mrelax |
ddf6fe37 | 30470 | @item -mrelax |
d77de738 ML |
30471 | Enable linker relaxation. Linker relaxation is a process whereby the |
30472 | linker attempts to reduce the size of a program by finding shorter | |
30473 | versions of various instructions. Disabled by default. | |
30474 | ||
d77de738 | 30475 | @opindex mint-register |
ddf6fe37 | 30476 | @item -mint-register=@var{N} |
d77de738 ML |
30477 | Specify the number of registers to reserve for fast interrupt handler |
30478 | functions. The value @var{N} can be between 0 and 4. A value of 1 | |
30479 | means that register @code{r13} is reserved for the exclusive use | |
30480 | of fast interrupt handlers. A value of 2 reserves @code{r13} and | |
30481 | @code{r12}. A value of 3 reserves @code{r13}, @code{r12} and | |
30482 | @code{r11}, and a value of 4 reserves @code{r13} through @code{r10}. | |
30483 | A value of 0, the default, does not reserve any registers. | |
30484 | ||
d77de738 | 30485 | @opindex msave-acc-in-interrupts |
ddf6fe37 | 30486 | @item -msave-acc-in-interrupts |
d77de738 ML |
30487 | Specifies that interrupt handler functions should preserve the |
30488 | accumulator register. This is only necessary if normal code might use | |
30489 | the accumulator register, for example because it performs 64-bit | |
30490 | multiplications. The default is to ignore the accumulator as this | |
30491 | makes the interrupt handlers faster. | |
30492 | ||
d77de738 ML |
30493 | @opindex mpid |
30494 | @opindex mno-pid | |
ddf6fe37 AA |
30495 | @item -mpid |
30496 | @itemx -mno-pid | |
d77de738 ML |
30497 | Enables the generation of position independent data. When enabled any |
30498 | access to constant data is done via an offset from a base address | |
30499 | held in a register. This allows the location of constant data to be | |
30500 | determined at run time without requiring the executable to be | |
30501 | relocated, which is a benefit to embedded applications with tight | |
30502 | memory constraints. Data that can be modified is not affected by this | |
30503 | option. | |
30504 | ||
30505 | Note, using this feature reserves a register, usually @code{r13}, for | |
30506 | the constant data base address. This can result in slower and/or | |
30507 | larger code, especially in complicated functions. | |
30508 | ||
30509 | The actual register chosen to hold the constant data base address | |
30510 | depends upon whether the @option{-msmall-data-limit} and/or the | |
30511 | @option{-mint-register} command-line options are enabled. Starting | |
30512 | with register @code{r13} and proceeding downwards, registers are | |
30513 | allocated first to satisfy the requirements of @option{-mint-register}, | |
30514 | then @option{-mpid} and finally @option{-msmall-data-limit}. Thus it | |
30515 | is possible for the small data area register to be @code{r8} if both | |
30516 | @option{-mint-register=4} and @option{-mpid} are specified on the | |
30517 | command line. | |
30518 | ||
30519 | By default this feature is not enabled. The default can be restored | |
30520 | via the @option{-mno-pid} command-line option. | |
30521 | ||
d77de738 ML |
30522 | @opindex mno-warn-multiple-fast-interrupts |
30523 | @opindex mwarn-multiple-fast-interrupts | |
ddf6fe37 AA |
30524 | @item -mno-warn-multiple-fast-interrupts |
30525 | @itemx -mwarn-multiple-fast-interrupts | |
d77de738 ML |
30526 | Prevents GCC from issuing a warning message if it finds more than one |
30527 | fast interrupt handler when it is compiling a file. The default is to | |
30528 | issue a warning for each extra fast interrupt handler found, as the RX | |
30529 | only supports one such interrupt. | |
30530 | ||
d77de738 ML |
30531 | @opindex mallow-string-insns |
30532 | @opindex mno-allow-string-insns | |
ddf6fe37 AA |
30533 | @item -mallow-string-insns |
30534 | @itemx -mno-allow-string-insns | |
d77de738 ML |
30535 | Enables or disables the use of the string manipulation instructions |
30536 | @code{SMOVF}, @code{SCMPU}, @code{SMOVB}, @code{SMOVU}, @code{SUNTIL} | |
30537 | @code{SWHILE} and also the @code{RMPA} instruction. These | |
30538 | instructions may prefetch data, which is not safe to do if accessing | |
30539 | an I/O register. (See section 12.2.7 of the RX62N Group User's Manual | |
30540 | for more information). | |
30541 | ||
30542 | The default is to allow these instructions, but it is not possible for | |
30543 | GCC to reliably detect all circumstances where a string instruction | |
30544 | might be used to access an I/O register, so their use cannot be | |
30545 | disabled automatically. Instead it is reliant upon the programmer to | |
30546 | use the @option{-mno-allow-string-insns} option if their program | |
30547 | accesses I/O space. | |
30548 | ||
30549 | When the instructions are enabled GCC defines the C preprocessor | |
30550 | symbol @code{__RX_ALLOW_STRING_INSNS__}, otherwise it defines the | |
30551 | symbol @code{__RX_DISALLOW_STRING_INSNS__}. | |
30552 | ||
d77de738 ML |
30553 | @opindex mjsr |
30554 | @opindex mno-jsr | |
ddf6fe37 AA |
30555 | @item -mjsr |
30556 | @itemx -mno-jsr | |
d77de738 ML |
30557 | Use only (or not only) @code{JSR} instructions to access functions. |
30558 | This option can be used when code size exceeds the range of @code{BSR} | |
30559 | instructions. Note that @option{-mno-jsr} does not mean to not use | |
30560 | @code{JSR} but instead means that any type of branch may be used. | |
30561 | @end table | |
30562 | ||
30563 | @emph{Note:} The generic GCC command-line option @option{-ffixed-@var{reg}} | |
30564 | has special significance to the RX port when used with the | |
30565 | @code{interrupt} function attribute. This attribute indicates a | |
30566 | function intended to process fast interrupts. GCC ensures | |
30567 | that it only uses the registers @code{r10}, @code{r11}, @code{r12} | |
30568 | and/or @code{r13} and only provided that the normal use of the | |
30569 | corresponding registers have been restricted via the | |
30570 | @option{-ffixed-@var{reg}} or @option{-mint-register} command-line | |
30571 | options. | |
30572 | ||
30573 | @node S/390 and zSeries Options | |
30574 | @subsection S/390 and zSeries Options | |
30575 | @cindex S/390 and zSeries Options | |
30576 | ||
30577 | These are the @samp{-m} options defined for the S/390 and zSeries architecture. | |
30578 | ||
30579 | @table @gcctabopt | |
d77de738 ML |
30580 | @opindex mhard-float |
30581 | @opindex msoft-float | |
ddf6fe37 AA |
30582 | @item -mhard-float |
30583 | @itemx -msoft-float | |
d77de738 ML |
30584 | Use (do not use) the hardware floating-point instructions and registers |
30585 | for floating-point operations. When @option{-msoft-float} is specified, | |
30586 | functions in @file{libgcc.a} are used to perform floating-point | |
30587 | operations. When @option{-mhard-float} is specified, the compiler | |
30588 | generates IEEE floating-point instructions. This is the default. | |
30589 | ||
d77de738 ML |
30590 | @opindex mhard-dfp |
30591 | @opindex mno-hard-dfp | |
ddf6fe37 AA |
30592 | @item -mhard-dfp |
30593 | @itemx -mno-hard-dfp | |
d77de738 ML |
30594 | Use (do not use) the hardware decimal-floating-point instructions for |
30595 | decimal-floating-point operations. When @option{-mno-hard-dfp} is | |
30596 | specified, functions in @file{libgcc.a} are used to perform | |
30597 | decimal-floating-point operations. When @option{-mhard-dfp} is | |
30598 | specified, the compiler generates decimal-floating-point hardware | |
30599 | instructions. This is the default for @option{-march=z9-ec} or higher. | |
30600 | ||
d77de738 ML |
30601 | @opindex mlong-double-64 |
30602 | @opindex mlong-double-128 | |
ddf6fe37 AA |
30603 | @item -mlong-double-64 |
30604 | @itemx -mlong-double-128 | |
d77de738 ML |
30605 | These switches control the size of @code{long double} type. A size |
30606 | of 64 bits makes the @code{long double} type equivalent to the @code{double} | |
30607 | type. This is the default. | |
30608 | ||
d77de738 ML |
30609 | @opindex mbackchain |
30610 | @opindex mno-backchain | |
ddf6fe37 AA |
30611 | @item -mbackchain |
30612 | @itemx -mno-backchain | |
d77de738 ML |
30613 | Store (do not store) the address of the caller's frame as backchain pointer |
30614 | into the callee's stack frame. | |
30615 | A backchain may be needed to allow debugging using tools that do not understand | |
30616 | DWARF call frame information. | |
30617 | When @option{-mno-packed-stack} is in effect, the backchain pointer is stored | |
30618 | at the bottom of the stack frame; when @option{-mpacked-stack} is in effect, | |
30619 | the backchain is placed into the topmost word of the 96/160 byte register | |
30620 | save area. | |
30621 | ||
30622 | In general, code compiled with @option{-mbackchain} is call-compatible with | |
30623 | code compiled with @option{-mno-backchain}; however, use of the backchain | |
30624 | for debugging purposes usually requires that the whole binary is built with | |
30625 | @option{-mbackchain}. Note that the combination of @option{-mbackchain}, | |
30626 | @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order | |
30627 | to build a linux kernel use @option{-msoft-float}. | |
30628 | ||
30629 | The default is to not maintain the backchain. | |
30630 | ||
d77de738 ML |
30631 | @opindex mpacked-stack |
30632 | @opindex mno-packed-stack | |
ddf6fe37 AA |
30633 | @item -mpacked-stack |
30634 | @itemx -mno-packed-stack | |
d77de738 ML |
30635 | Use (do not use) the packed stack layout. When @option{-mno-packed-stack} is |
30636 | specified, the compiler uses the all fields of the 96/160 byte register save | |
30637 | area only for their default purpose; unused fields still take up stack space. | |
30638 | When @option{-mpacked-stack} is specified, register save slots are densely | |
30639 | packed at the top of the register save area; unused space is reused for other | |
30640 | purposes, allowing for more efficient use of the available stack space. | |
30641 | However, when @option{-mbackchain} is also in effect, the topmost word of | |
30642 | the save area is always used to store the backchain, and the return address | |
30643 | register is always saved two words below the backchain. | |
30644 | ||
30645 | As long as the stack frame backchain is not used, code generated with | |
30646 | @option{-mpacked-stack} is call-compatible with code generated with | |
30647 | @option{-mno-packed-stack}. Note that some non-FSF releases of GCC 2.95 for | |
30648 | S/390 or zSeries generated code that uses the stack frame backchain at run | |
30649 | time, not just for debugging purposes. Such code is not call-compatible | |
30650 | with code compiled with @option{-mpacked-stack}. Also, note that the | |
30651 | combination of @option{-mbackchain}, | |
30652 | @option{-mpacked-stack} and @option{-mhard-float} is not supported. In order | |
30653 | to build a linux kernel use @option{-msoft-float}. | |
30654 | ||
30655 | The default is to not use the packed stack layout. | |
30656 | ||
d77de738 ML |
30657 | @opindex msmall-exec |
30658 | @opindex mno-small-exec | |
ddf6fe37 AA |
30659 | @item -msmall-exec |
30660 | @itemx -mno-small-exec | |
d77de738 ML |
30661 | Generate (or do not generate) code using the @code{bras} instruction |
30662 | to do subroutine calls. | |
30663 | This only works reliably if the total executable size does not | |
30664 | exceed 64k. The default is to use the @code{basr} instruction instead, | |
30665 | which does not have this limitation. | |
30666 | ||
d77de738 ML |
30667 | @opindex m64 |
30668 | @opindex m31 | |
ddf6fe37 AA |
30669 | @item -m64 |
30670 | @itemx -m31 | |
d77de738 ML |
30671 | When @option{-m31} is specified, generate code compliant to the |
30672 | GNU/Linux for S/390 ABI@. When @option{-m64} is specified, generate | |
30673 | code compliant to the GNU/Linux for zSeries ABI@. This allows GCC in | |
30674 | particular to generate 64-bit instructions. For the @samp{s390} | |
30675 | targets, the default is @option{-m31}, while the @samp{s390x} | |
30676 | targets default to @option{-m64}. | |
30677 | ||
d77de738 ML |
30678 | @opindex mzarch |
30679 | @opindex mesa | |
ddf6fe37 AA |
30680 | @item -mzarch |
30681 | @itemx -mesa | |
d77de738 ML |
30682 | When @option{-mzarch} is specified, generate code using the |
30683 | instructions available on z/Architecture. | |
30684 | When @option{-mesa} is specified, generate code using the | |
30685 | instructions available on ESA/390. Note that @option{-mesa} is | |
30686 | not possible with @option{-m64}. | |
30687 | When generating code compliant to the GNU/Linux for S/390 ABI, | |
30688 | the default is @option{-mesa}. When generating code compliant | |
30689 | to the GNU/Linux for zSeries ABI, the default is @option{-mzarch}. | |
30690 | ||
d77de738 ML |
30691 | @opindex mhtm |
30692 | @opindex mno-htm | |
ddf6fe37 AA |
30693 | @item -mhtm |
30694 | @itemx -mno-htm | |
d77de738 ML |
30695 | The @option{-mhtm} option enables a set of builtins making use of |
30696 | instructions available with the transactional execution facility | |
30697 | introduced with the IBM zEnterprise EC12 machine generation | |
30698 | @ref{S/390 System z Built-in Functions}. | |
30699 | @option{-mhtm} is enabled by default when using @option{-march=zEC12}. | |
30700 | ||
d77de738 ML |
30701 | @opindex mvx |
30702 | @opindex mno-vx | |
ddf6fe37 AA |
30703 | @item -mvx |
30704 | @itemx -mno-vx | |
d77de738 ML |
30705 | When @option{-mvx} is specified, generate code using the instructions |
30706 | available with the vector extension facility introduced with the IBM | |
30707 | z13 machine generation. | |
30708 | This option changes the ABI for some vector type values with regard to | |
30709 | alignment and calling conventions. In case vector type values are | |
30710 | being used in an ABI-relevant context a GAS @samp{.gnu_attribute} | |
30711 | command will be added to mark the resulting binary with the ABI used. | |
30712 | @option{-mvx} is enabled by default when using @option{-march=z13}. | |
30713 | ||
d77de738 ML |
30714 | @opindex mzvector |
30715 | @opindex mno-zvector | |
ddf6fe37 AA |
30716 | @item -mzvector |
30717 | @itemx -mno-zvector | |
d77de738 ML |
30718 | The @option{-mzvector} option enables vector language extensions and |
30719 | builtins using instructions available with the vector extension | |
30720 | facility introduced with the IBM z13 machine generation. | |
30721 | This option adds support for @samp{vector} to be used as a keyword to | |
30722 | define vector type variables and arguments. @samp{vector} is only | |
30723 | available when GNU extensions are enabled. It will not be expanded | |
30724 | when requesting strict standard compliance e.g.@: with @option{-std=c99}. | |
30725 | In addition to the GCC low-level builtins @option{-mzvector} enables | |
30726 | a set of builtins added for compatibility with AltiVec-style | |
30727 | implementations like Power and Cell. In order to make use of these | |
30728 | builtins the header file @file{vecintrin.h} needs to be included. | |
30729 | @option{-mzvector} is disabled by default. | |
30730 | ||
d77de738 ML |
30731 | @opindex mmvcle |
30732 | @opindex mno-mvcle | |
ddf6fe37 AA |
30733 | @item -mmvcle |
30734 | @itemx -mno-mvcle | |
d77de738 ML |
30735 | Generate (or do not generate) code using the @code{mvcle} instruction |
30736 | to perform block moves. When @option{-mno-mvcle} is specified, | |
30737 | use a @code{mvc} loop instead. This is the default unless optimizing for | |
30738 | size. | |
30739 | ||
d77de738 ML |
30740 | @opindex mdebug |
30741 | @opindex mno-debug | |
ddf6fe37 AA |
30742 | @item -mdebug |
30743 | @itemx -mno-debug | |
d77de738 ML |
30744 | Print (or do not print) additional debug information when compiling. |
30745 | The default is to not print debug information. | |
30746 | ||
d77de738 | 30747 | @opindex march |
ddf6fe37 | 30748 | @item -march=@var{cpu-type} |
d77de738 ML |
30749 | Generate code that runs on @var{cpu-type}, which is the name of a |
30750 | system representing a certain processor type. Possible values for | |
30751 | @var{cpu-type} are @samp{z900}/@samp{arch5}, @samp{z990}/@samp{arch6}, | |
30752 | @samp{z9-109}, @samp{z9-ec}/@samp{arch7}, @samp{z10}/@samp{arch8}, | |
30753 | @samp{z196}/@samp{arch9}, @samp{zEC12}, @samp{z13}/@samp{arch11}, | |
30754 | @samp{z14}/@samp{arch12}, @samp{z15}/@samp{arch13}, | |
30755 | @samp{z16}/@samp{arch14}, and @samp{native}. | |
30756 | ||
30757 | The default is @option{-march=z900}. | |
30758 | ||
30759 | Specifying @samp{native} as cpu type can be used to select the best | |
30760 | architecture option for the host processor. | |
30761 | @option{-march=native} has no effect if GCC does not recognize the | |
30762 | processor. | |
30763 | ||
d77de738 | 30764 | @opindex mtune |
ddf6fe37 | 30765 | @item -mtune=@var{cpu-type} |
d77de738 ML |
30766 | Tune to @var{cpu-type} everything applicable about the generated code, |
30767 | except for the ABI and the set of available instructions. | |
30768 | The list of @var{cpu-type} values is the same as for @option{-march}. | |
30769 | The default is the value used for @option{-march}. | |
30770 | ||
d77de738 ML |
30771 | @opindex mtpf-trace |
30772 | @opindex mno-tpf-trace | |
ddf6fe37 AA |
30773 | @item -mtpf-trace |
30774 | @itemx -mno-tpf-trace | |
d77de738 ML |
30775 | Generate code that adds (does not add) in TPF OS specific branches to trace |
30776 | routines in the operating system. This option is off by default, even | |
30777 | when compiling for the TPF OS@. | |
30778 | ||
d77de738 ML |
30779 | @opindex mtpf-trace-skip |
30780 | @opindex mno-tpf-trace-skip | |
ddf6fe37 AA |
30781 | @item -mtpf-trace-skip |
30782 | @itemx -mno-tpf-trace-skip | |
d77de738 ML |
30783 | Generate code that changes (does not change) the default branch |
30784 | targets enabled by @option{-mtpf-trace} to point to specialized trace | |
30785 | routines providing the ability of selectively skipping function trace | |
30786 | entries for the TPF OS. This option is off by default, even when | |
30787 | compiling for the TPF OS and specifying @option{-mtpf-trace}. | |
30788 | ||
d77de738 ML |
30789 | @opindex mfused-madd |
30790 | @opindex mno-fused-madd | |
ddf6fe37 AA |
30791 | @item -mfused-madd |
30792 | @itemx -mno-fused-madd | |
d77de738 ML |
30793 | Generate code that uses (does not use) the floating-point multiply and |
30794 | accumulate instructions. These instructions are generated by default if | |
30795 | hardware floating point is used. | |
30796 | ||
d77de738 | 30797 | @opindex mwarn-framesize |
ddf6fe37 | 30798 | @item -mwarn-framesize=@var{framesize} |
d77de738 ML |
30799 | Emit a warning if the current function exceeds the given frame size. Because |
30800 | this is a compile-time check it doesn't need to be a real problem when the program | |
30801 | runs. It is intended to identify functions that most probably cause | |
30802 | a stack overflow. It is useful to be used in an environment with limited stack | |
30803 | size e.g.@: the linux kernel. | |
30804 | ||
d77de738 | 30805 | @opindex mwarn-dynamicstack |
ddf6fe37 | 30806 | @item -mwarn-dynamicstack |
d77de738 ML |
30807 | Emit a warning if the function calls @code{alloca} or uses dynamically-sized |
30808 | arrays. This is generally a bad idea with a limited stack size. | |
30809 | ||
d77de738 ML |
30810 | @opindex mstack-guard |
30811 | @opindex mstack-size | |
ddf6fe37 AA |
30812 | @item -mstack-guard=@var{stack-guard} |
30813 | @itemx -mstack-size=@var{stack-size} | |
d77de738 ML |
30814 | If these options are provided the S/390 back end emits additional instructions in |
30815 | the function prologue that trigger a trap if the stack size is @var{stack-guard} | |
30816 | bytes above the @var{stack-size} (remember that the stack on S/390 grows downward). | |
30817 | If the @var{stack-guard} option is omitted the smallest power of 2 larger than | |
30818 | the frame size of the compiled function is chosen. | |
30819 | These options are intended to be used to help debugging stack overflow problems. | |
30820 | The additionally emitted code causes only little overhead and hence can also be | |
30821 | used in production-like systems without greater performance degradation. The given | |
30822 | values have to be exact powers of 2 and @var{stack-size} has to be greater than | |
30823 | @var{stack-guard} without exceeding 64k. | |
30824 | In order to be efficient the extra code makes the assumption that the stack starts | |
30825 | at an address aligned to the value given by @var{stack-size}. | |
30826 | The @var{stack-guard} option can only be used in conjunction with @var{stack-size}. | |
30827 | ||
d77de738 | 30828 | @opindex mhotpatch |
ddf6fe37 | 30829 | @item -mhotpatch=@var{pre-halfwords},@var{post-halfwords} |
d77de738 ML |
30830 | If the hotpatch option is enabled, a ``hot-patching'' function |
30831 | prologue is generated for all functions in the compilation unit. | |
30832 | The funtion label is prepended with the given number of two-byte | |
30833 | NOP instructions (@var{pre-halfwords}, maximum 1000000). After | |
30834 | the label, 2 * @var{post-halfwords} bytes are appended, using the | |
30835 | largest NOP like instructions the architecture allows (maximum | |
30836 | 1000000). | |
30837 | ||
30838 | If both arguments are zero, hotpatching is disabled. | |
30839 | ||
30840 | This option can be overridden for individual functions with the | |
30841 | @code{hotpatch} attribute. | |
30842 | @end table | |
30843 | ||
d77de738 ML |
30844 | @node SH Options |
30845 | @subsection SH Options | |
30846 | ||
30847 | These @samp{-m} options are defined for the SH implementations: | |
30848 | ||
30849 | @table @gcctabopt | |
d77de738 | 30850 | @opindex m1 |
ddf6fe37 | 30851 | @item -m1 |
d77de738 ML |
30852 | Generate code for the SH1. |
30853 | ||
d77de738 | 30854 | @opindex m2 |
ddf6fe37 | 30855 | @item -m2 |
d77de738 ML |
30856 | Generate code for the SH2. |
30857 | ||
30858 | @item -m2e | |
30859 | Generate code for the SH2e. | |
30860 | ||
d77de738 | 30861 | @opindex m2a-nofpu |
ddf6fe37 | 30862 | @item -m2a-nofpu |
d77de738 ML |
30863 | Generate code for the SH2a without FPU, or for a SH2a-FPU in such a way |
30864 | that the floating-point unit is not used. | |
30865 | ||
d77de738 | 30866 | @opindex m2a-single-only |
ddf6fe37 | 30867 | @item -m2a-single-only |
d77de738 ML |
30868 | Generate code for the SH2a-FPU, in such a way that no double-precision |
30869 | floating-point operations are used. | |
30870 | ||
d77de738 | 30871 | @opindex m2a-single |
ddf6fe37 | 30872 | @item -m2a-single |
d77de738 ML |
30873 | Generate code for the SH2a-FPU assuming the floating-point unit is in |
30874 | single-precision mode by default. | |
30875 | ||
d77de738 | 30876 | @opindex m2a |
ddf6fe37 | 30877 | @item -m2a |
d77de738 ML |
30878 | Generate code for the SH2a-FPU assuming the floating-point unit is in |
30879 | double-precision mode by default. | |
30880 | ||
d77de738 | 30881 | @opindex m3 |
ddf6fe37 | 30882 | @item -m3 |
d77de738 ML |
30883 | Generate code for the SH3. |
30884 | ||
d77de738 | 30885 | @opindex m3e |
ddf6fe37 | 30886 | @item -m3e |
d77de738 ML |
30887 | Generate code for the SH3e. |
30888 | ||
d77de738 | 30889 | @opindex m4-nofpu |
ddf6fe37 | 30890 | @item -m4-nofpu |
d77de738 ML |
30891 | Generate code for the SH4 without a floating-point unit. |
30892 | ||
d77de738 | 30893 | @opindex m4-single-only |
ddf6fe37 | 30894 | @item -m4-single-only |
d77de738 ML |
30895 | Generate code for the SH4 with a floating-point unit that only |
30896 | supports single-precision arithmetic. | |
30897 | ||
d77de738 | 30898 | @opindex m4-single |
ddf6fe37 | 30899 | @item -m4-single |
d77de738 ML |
30900 | Generate code for the SH4 assuming the floating-point unit is in |
30901 | single-precision mode by default. | |
30902 | ||
d77de738 | 30903 | @opindex m4 |
ddf6fe37 | 30904 | @item -m4 |
d77de738 ML |
30905 | Generate code for the SH4. |
30906 | ||
d77de738 | 30907 | @opindex m4-100 |
ddf6fe37 | 30908 | @item -m4-100 |
d77de738 ML |
30909 | Generate code for SH4-100. |
30910 | ||
d77de738 | 30911 | @opindex m4-100-nofpu |
ddf6fe37 | 30912 | @item -m4-100-nofpu |
d77de738 ML |
30913 | Generate code for SH4-100 in such a way that the |
30914 | floating-point unit is not used. | |
30915 | ||
d77de738 | 30916 | @opindex m4-100-single |
ddf6fe37 | 30917 | @item -m4-100-single |
d77de738 ML |
30918 | Generate code for SH4-100 assuming the floating-point unit is in |
30919 | single-precision mode by default. | |
30920 | ||
d77de738 | 30921 | @opindex m4-100-single-only |
ddf6fe37 | 30922 | @item -m4-100-single-only |
d77de738 ML |
30923 | Generate code for SH4-100 in such a way that no double-precision |
30924 | floating-point operations are used. | |
30925 | ||
d77de738 | 30926 | @opindex m4-200 |
ddf6fe37 | 30927 | @item -m4-200 |
d77de738 ML |
30928 | Generate code for SH4-200. |
30929 | ||
d77de738 | 30930 | @opindex m4-200-nofpu |
ddf6fe37 | 30931 | @item -m4-200-nofpu |
d77de738 ML |
30932 | Generate code for SH4-200 without in such a way that the |
30933 | floating-point unit is not used. | |
30934 | ||
d77de738 | 30935 | @opindex m4-200-single |
ddf6fe37 | 30936 | @item -m4-200-single |
d77de738 ML |
30937 | Generate code for SH4-200 assuming the floating-point unit is in |
30938 | single-precision mode by default. | |
30939 | ||
d77de738 | 30940 | @opindex m4-200-single-only |
ddf6fe37 | 30941 | @item -m4-200-single-only |
d77de738 ML |
30942 | Generate code for SH4-200 in such a way that no double-precision |
30943 | floating-point operations are used. | |
30944 | ||
d77de738 | 30945 | @opindex m4-300 |
ddf6fe37 | 30946 | @item -m4-300 |
d77de738 ML |
30947 | Generate code for SH4-300. |
30948 | ||
d77de738 | 30949 | @opindex m4-300-nofpu |
ddf6fe37 | 30950 | @item -m4-300-nofpu |
d77de738 ML |
30951 | Generate code for SH4-300 without in such a way that the |
30952 | floating-point unit is not used. | |
30953 | ||
d77de738 | 30954 | @opindex m4-300-single |
ddf6fe37 | 30955 | @item -m4-300-single |
d77de738 ML |
30956 | Generate code for SH4-300 in such a way that no double-precision |
30957 | floating-point operations are used. | |
30958 | ||
d77de738 | 30959 | @opindex m4-300-single-only |
ddf6fe37 | 30960 | @item -m4-300-single-only |
d77de738 ML |
30961 | Generate code for SH4-300 in such a way that no double-precision |
30962 | floating-point operations are used. | |
30963 | ||
d77de738 | 30964 | @opindex m4-340 |
ddf6fe37 | 30965 | @item -m4-340 |
d77de738 ML |
30966 | Generate code for SH4-340 (no MMU, no FPU). |
30967 | ||
d77de738 | 30968 | @opindex m4-500 |
ddf6fe37 | 30969 | @item -m4-500 |
d77de738 ML |
30970 | Generate code for SH4-500 (no FPU). Passes @option{-isa=sh4-nofpu} to the |
30971 | assembler. | |
30972 | ||
d77de738 | 30973 | @opindex m4a-nofpu |
ddf6fe37 | 30974 | @item -m4a-nofpu |
d77de738 ML |
30975 | Generate code for the SH4al-dsp, or for a SH4a in such a way that the |
30976 | floating-point unit is not used. | |
30977 | ||
d77de738 | 30978 | @opindex m4a-single-only |
ddf6fe37 | 30979 | @item -m4a-single-only |
d77de738 ML |
30980 | Generate code for the SH4a, in such a way that no double-precision |
30981 | floating-point operations are used. | |
30982 | ||
d77de738 | 30983 | @opindex m4a-single |
ddf6fe37 | 30984 | @item -m4a-single |
d77de738 ML |
30985 | Generate code for the SH4a assuming the floating-point unit is in |
30986 | single-precision mode by default. | |
30987 | ||
d77de738 | 30988 | @opindex m4a |
ddf6fe37 | 30989 | @item -m4a |
d77de738 ML |
30990 | Generate code for the SH4a. |
30991 | ||
d77de738 | 30992 | @opindex m4al |
ddf6fe37 | 30993 | @item -m4al |
d77de738 ML |
30994 | Same as @option{-m4a-nofpu}, except that it implicitly passes |
30995 | @option{-dsp} to the assembler. GCC doesn't generate any DSP | |
30996 | instructions at the moment. | |
30997 | ||
d77de738 | 30998 | @opindex mb |
ddf6fe37 | 30999 | @item -mb |
d77de738 ML |
31000 | Compile code for the processor in big-endian mode. |
31001 | ||
d77de738 | 31002 | @opindex ml |
ddf6fe37 | 31003 | @item -ml |
d77de738 ML |
31004 | Compile code for the processor in little-endian mode. |
31005 | ||
d77de738 | 31006 | @opindex mdalign |
ddf6fe37 | 31007 | @item -mdalign |
d77de738 ML |
31008 | Align doubles at 64-bit boundaries. Note that this changes the calling |
31009 | conventions, and thus some functions from the standard C library do | |
31010 | not work unless you recompile it first with @option{-mdalign}. | |
31011 | ||
d77de738 | 31012 | @opindex mrelax |
ddf6fe37 | 31013 | @item -mrelax |
d77de738 ML |
31014 | Shorten some address references at link time, when possible; uses the |
31015 | linker option @option{-relax}. | |
31016 | ||
d77de738 | 31017 | @opindex mbigtable |
ddf6fe37 | 31018 | @item -mbigtable |
d77de738 ML |
31019 | Use 32-bit offsets in @code{switch} tables. The default is to use |
31020 | 16-bit offsets. | |
31021 | ||
d77de738 | 31022 | @opindex mbitops |
ddf6fe37 | 31023 | @item -mbitops |
d77de738 ML |
31024 | Enable the use of bit manipulation instructions on SH2A. |
31025 | ||
d77de738 | 31026 | @opindex mfmovd |
ddf6fe37 | 31027 | @item -mfmovd |
d77de738 ML |
31028 | Enable the use of the instruction @code{fmovd}. Check @option{-mdalign} for |
31029 | alignment constraints. | |
31030 | ||
d77de738 | 31031 | @opindex mrenesas |
ddf6fe37 | 31032 | @item -mrenesas |
d77de738 ML |
31033 | Comply with the calling conventions defined by Renesas. |
31034 | ||
d77de738 | 31035 | @opindex mno-renesas |
ddf6fe37 | 31036 | @item -mno-renesas |
d77de738 ML |
31037 | Comply with the calling conventions defined for GCC before the Renesas |
31038 | conventions were available. This option is the default for all | |
31039 | targets of the SH toolchain. | |
31040 | ||
d77de738 | 31041 | @opindex mnomacsave |
ddf6fe37 | 31042 | @item -mnomacsave |
d77de738 ML |
31043 | Mark the @code{MAC} register as call-clobbered, even if |
31044 | @option{-mrenesas} is given. | |
31045 | ||
d77de738 ML |
31046 | @opindex mieee |
31047 | @opindex mno-ieee | |
ddf6fe37 AA |
31048 | @item -mieee |
31049 | @itemx -mno-ieee | |
d77de738 ML |
31050 | Control the IEEE compliance of floating-point comparisons, which affects the |
31051 | handling of cases where the result of a comparison is unordered. By default | |
31052 | @option{-mieee} is implicitly enabled. If @option{-ffinite-math-only} is | |
31053 | enabled @option{-mno-ieee} is implicitly set, which results in faster | |
31054 | floating-point greater-equal and less-equal comparisons. The implicit settings | |
31055 | can be overridden by specifying either @option{-mieee} or @option{-mno-ieee}. | |
31056 | ||
d77de738 | 31057 | @opindex minline-ic_invalidate |
ddf6fe37 | 31058 | @item -minline-ic_invalidate |
d77de738 ML |
31059 | Inline code to invalidate instruction cache entries after setting up |
31060 | nested function trampolines. | |
31061 | This option has no effect if @option{-musermode} is in effect and the selected | |
31062 | code generation option (e.g.@: @option{-m4}) does not allow the use of the @code{icbi} | |
31063 | instruction. | |
31064 | If the selected code generation option does not allow the use of the @code{icbi} | |
31065 | instruction, and @option{-musermode} is not in effect, the inlined code | |
31066 | manipulates the instruction cache address array directly with an associative | |
31067 | write. This not only requires privileged mode at run time, but it also | |
31068 | fails if the cache line had been mapped via the TLB and has become unmapped. | |
31069 | ||
d77de738 | 31070 | @opindex misize |
ddf6fe37 | 31071 | @item -misize |
d77de738 ML |
31072 | Dump instruction size and location in the assembly code. |
31073 | ||
d77de738 | 31074 | @opindex mpadstruct |
ddf6fe37 | 31075 | @item -mpadstruct |
d77de738 ML |
31076 | This option is deprecated. It pads structures to multiple of 4 bytes, |
31077 | which is incompatible with the SH ABI@. | |
31078 | ||
d77de738 | 31079 | @opindex matomic-model=@var{model} |
ddf6fe37 | 31080 | @item -matomic-model=@var{model} |
d77de738 ML |
31081 | Sets the model of atomic operations and additional parameters as a comma |
31082 | separated list. For details on the atomic built-in functions see | |
31083 | @ref{__atomic Builtins}. The following models and parameters are supported: | |
31084 | ||
31085 | @table @samp | |
31086 | ||
31087 | @item none | |
31088 | Disable compiler generated atomic sequences and emit library calls for atomic | |
31089 | operations. This is the default if the target is not @code{sh*-*-linux*}. | |
31090 | ||
31091 | @item soft-gusa | |
31092 | Generate GNU/Linux compatible gUSA software atomic sequences for the atomic | |
31093 | built-in functions. The generated atomic sequences require additional support | |
31094 | from the interrupt/exception handling code of the system and are only suitable | |
31095 | for SH3* and SH4* single-core systems. This option is enabled by default when | |
31096 | the target is @code{sh*-*-linux*} and SH3* or SH4*. When the target is SH4A, | |
31097 | this option also partially utilizes the hardware atomic instructions | |
31098 | @code{movli.l} and @code{movco.l} to create more efficient code, unless | |
31099 | @samp{strict} is specified. | |
31100 | ||
31101 | @item soft-tcb | |
31102 | Generate software atomic sequences that use a variable in the thread control | |
31103 | block. This is a variation of the gUSA sequences which can also be used on | |
31104 | SH1* and SH2* targets. The generated atomic sequences require additional | |
31105 | support from the interrupt/exception handling code of the system and are only | |
31106 | suitable for single-core systems. When using this model, the @samp{gbr-offset=} | |
31107 | parameter has to be specified as well. | |
31108 | ||
31109 | @item soft-imask | |
31110 | Generate software atomic sequences that temporarily disable interrupts by | |
31111 | setting @code{SR.IMASK = 1111}. This model works only when the program runs | |
31112 | in privileged mode and is only suitable for single-core systems. Additional | |
31113 | support from the interrupt/exception handling code of the system is not | |
31114 | required. This model is enabled by default when the target is | |
31115 | @code{sh*-*-linux*} and SH1* or SH2*. | |
31116 | ||
31117 | @item hard-llcs | |
31118 | Generate hardware atomic sequences using the @code{movli.l} and @code{movco.l} | |
31119 | instructions only. This is only available on SH4A and is suitable for | |
31120 | multi-core systems. Since the hardware instructions support only 32 bit atomic | |
31121 | variables access to 8 or 16 bit variables is emulated with 32 bit accesses. | |
31122 | Code compiled with this option is also compatible with other software | |
31123 | atomic model interrupt/exception handling systems if executed on an SH4A | |
31124 | system. Additional support from the interrupt/exception handling code of the | |
31125 | system is not required for this model. | |
31126 | ||
31127 | @item gbr-offset= | |
31128 | This parameter specifies the offset in bytes of the variable in the thread | |
31129 | control block structure that should be used by the generated atomic sequences | |
31130 | when the @samp{soft-tcb} model has been selected. For other models this | |
31131 | parameter is ignored. The specified value must be an integer multiple of four | |
31132 | and in the range 0-1020. | |
31133 | ||
31134 | @item strict | |
31135 | This parameter prevents mixed usage of multiple atomic models, even if they | |
31136 | are compatible, and makes the compiler generate atomic sequences of the | |
31137 | specified model only. | |
31138 | ||
31139 | @end table | |
31140 | ||
d77de738 | 31141 | @opindex mtas |
ddf6fe37 | 31142 | @item -mtas |
d77de738 ML |
31143 | Generate the @code{tas.b} opcode for @code{__atomic_test_and_set}. |
31144 | Notice that depending on the particular hardware and software configuration | |
31145 | this can degrade overall performance due to the operand cache line flushes | |
31146 | that are implied by the @code{tas.b} instruction. On multi-core SH4A | |
31147 | processors the @code{tas.b} instruction must be used with caution since it | |
31148 | can result in data corruption for certain cache configurations. | |
31149 | ||
d77de738 | 31150 | @opindex mprefergot |
ddf6fe37 | 31151 | @item -mprefergot |
d77de738 ML |
31152 | When generating position-independent code, emit function calls using |
31153 | the Global Offset Table instead of the Procedure Linkage Table. | |
31154 | ||
d77de738 ML |
31155 | @opindex musermode |
31156 | @opindex mno-usermode | |
ddf6fe37 AA |
31157 | @item -musermode |
31158 | @itemx -mno-usermode | |
d77de738 ML |
31159 | Don't allow (allow) the compiler generating privileged mode code. Specifying |
31160 | @option{-musermode} also implies @option{-mno-inline-ic_invalidate} if the | |
31161 | inlined code would not work in user mode. @option{-musermode} is the default | |
31162 | when the target is @code{sh*-*-linux*}. If the target is SH1* or SH2* | |
31163 | @option{-musermode} has no effect, since there is no user mode. | |
31164 | ||
d77de738 | 31165 | @opindex multcost=@var{number} |
ddf6fe37 | 31166 | @item -multcost=@var{number} |
d77de738 ML |
31167 | Set the cost to assume for a multiply insn. |
31168 | ||
d77de738 | 31169 | @opindex mdiv=@var{strategy} |
ddf6fe37 | 31170 | @item -mdiv=@var{strategy} |
d77de738 ML |
31171 | Set the division strategy to be used for integer division operations. |
31172 | @var{strategy} can be one of: | |
31173 | ||
31174 | @table @samp | |
31175 | ||
31176 | @item call-div1 | |
31177 | Calls a library function that uses the single-step division instruction | |
31178 | @code{div1} to perform the operation. Division by zero calculates an | |
31179 | unspecified result and does not trap. This is the default except for SH4, | |
31180 | SH2A and SHcompact. | |
31181 | ||
31182 | @item call-fp | |
31183 | Calls a library function that performs the operation in double precision | |
31184 | floating point. Division by zero causes a floating-point exception. This is | |
31185 | the default for SHcompact with FPU. Specifying this for targets that do not | |
31186 | have a double precision FPU defaults to @code{call-div1}. | |
31187 | ||
31188 | @item call-table | |
31189 | Calls a library function that uses a lookup table for small divisors and | |
31190 | the @code{div1} instruction with case distinction for larger divisors. Division | |
31191 | by zero calculates an unspecified result and does not trap. This is the default | |
31192 | for SH4. Specifying this for targets that do not have dynamic shift | |
31193 | instructions defaults to @code{call-div1}. | |
31194 | ||
31195 | @end table | |
31196 | ||
31197 | When a division strategy has not been specified the default strategy is | |
31198 | selected based on the current target. For SH2A the default strategy is to | |
31199 | use the @code{divs} and @code{divu} instructions instead of library function | |
31200 | calls. | |
31201 | ||
d77de738 | 31202 | @opindex maccumulate-outgoing-args |
ddf6fe37 | 31203 | @item -maccumulate-outgoing-args |
d77de738 ML |
31204 | Reserve space once for outgoing arguments in the function prologue rather |
31205 | than around each call. Generally beneficial for performance and size. Also | |
31206 | needed for unwinding to avoid changing the stack frame around conditional code. | |
31207 | ||
d77de738 | 31208 | @opindex mdivsi3_libfunc=@var{name} |
ddf6fe37 | 31209 | @item -mdivsi3_libfunc=@var{name} |
d77de738 ML |
31210 | Set the name of the library function used for 32-bit signed division to |
31211 | @var{name}. | |
31212 | This only affects the name used in the @samp{call} division strategies, and | |
31213 | the compiler still expects the same sets of input/output/clobbered registers as | |
31214 | if this option were not present. | |
31215 | ||
d77de738 | 31216 | @opindex mfixed-range |
ddf6fe37 | 31217 | @item -mfixed-range=@var{register-range} |
d77de738 ML |
31218 | Generate code treating the given register range as fixed registers. |
31219 | A fixed register is one that the register allocator cannot use. This is | |
31220 | useful when compiling kernel code. A register range is specified as | |
31221 | two registers separated by a dash. Multiple register ranges can be | |
31222 | specified separated by a comma. | |
31223 | ||
d77de738 | 31224 | @opindex mbranch-cost=@var{num} |
ddf6fe37 | 31225 | @item -mbranch-cost=@var{num} |
d77de738 ML |
31226 | Assume @var{num} to be the cost for a branch instruction. Higher numbers |
31227 | make the compiler try to generate more branch-free code if possible. | |
31228 | If not specified the value is selected depending on the processor type that | |
31229 | is being compiled for. | |
31230 | ||
d77de738 ML |
31231 | @opindex mzdcbranch |
31232 | @opindex mno-zdcbranch | |
ddf6fe37 AA |
31233 | @item -mzdcbranch |
31234 | @itemx -mno-zdcbranch | |
d77de738 ML |
31235 | Assume (do not assume) that zero displacement conditional branch instructions |
31236 | @code{bt} and @code{bf} are fast. If @option{-mzdcbranch} is specified, the | |
31237 | compiler prefers zero displacement branch code sequences. This is | |
31238 | enabled by default when generating code for SH4 and SH4A. It can be explicitly | |
31239 | disabled by specifying @option{-mno-zdcbranch}. | |
31240 | ||
d77de738 | 31241 | @opindex mcbranch-force-delay-slot |
ddf6fe37 | 31242 | @item -mcbranch-force-delay-slot |
d77de738 ML |
31243 | Force the usage of delay slots for conditional branches, which stuffs the delay |
31244 | slot with a @code{nop} if a suitable instruction cannot be found. By default | |
31245 | this option is disabled. It can be enabled to work around hardware bugs as | |
31246 | found in the original SH7055. | |
31247 | ||
d77de738 ML |
31248 | @opindex mfused-madd |
31249 | @opindex mno-fused-madd | |
ddf6fe37 AA |
31250 | @item -mfused-madd |
31251 | @itemx -mno-fused-madd | |
d77de738 ML |
31252 | Generate code that uses (does not use) the floating-point multiply and |
31253 | accumulate instructions. These instructions are generated by default | |
31254 | if hardware floating point is used. The machine-dependent | |
31255 | @option{-mfused-madd} option is now mapped to the machine-independent | |
31256 | @option{-ffp-contract=fast} option, and @option{-mno-fused-madd} is | |
31257 | mapped to @option{-ffp-contract=off}. | |
31258 | ||
d77de738 ML |
31259 | @opindex mfsca |
31260 | @opindex mno-fsca | |
ddf6fe37 AA |
31261 | @item -mfsca |
31262 | @itemx -mno-fsca | |
d77de738 ML |
31263 | Allow or disallow the compiler to emit the @code{fsca} instruction for sine |
31264 | and cosine approximations. The option @option{-mfsca} must be used in | |
31265 | combination with @option{-funsafe-math-optimizations}. It is enabled by default | |
31266 | when generating code for SH4A. Using @option{-mno-fsca} disables sine and cosine | |
31267 | approximations even if @option{-funsafe-math-optimizations} is in effect. | |
31268 | ||
d77de738 ML |
31269 | @opindex mfsrra |
31270 | @opindex mno-fsrra | |
ddf6fe37 AA |
31271 | @item -mfsrra |
31272 | @itemx -mno-fsrra | |
d77de738 ML |
31273 | Allow or disallow the compiler to emit the @code{fsrra} instruction for |
31274 | reciprocal square root approximations. The option @option{-mfsrra} must be used | |
31275 | in combination with @option{-funsafe-math-optimizations} and | |
31276 | @option{-ffinite-math-only}. It is enabled by default when generating code for | |
31277 | SH4A. Using @option{-mno-fsrra} disables reciprocal square root approximations | |
31278 | even if @option{-funsafe-math-optimizations} and @option{-ffinite-math-only} are | |
31279 | in effect. | |
31280 | ||
d77de738 | 31281 | @opindex mpretend-cmove |
ddf6fe37 | 31282 | @item -mpretend-cmove |
d77de738 ML |
31283 | Prefer zero-displacement conditional branches for conditional move instruction |
31284 | patterns. This can result in faster code on the SH4 processor. | |
31285 | ||
d77de738 | 31286 | @opindex fdpic |
ddf6fe37 | 31287 | @item -mfdpic |
d77de738 ML |
31288 | Generate code using the FDPIC ABI. |
31289 | ||
31290 | @end table | |
31291 | ||
31292 | @node Solaris 2 Options | |
31293 | @subsection Solaris 2 Options | |
31294 | @cindex Solaris 2 options | |
31295 | ||
31296 | These @samp{-m} options are supported on Solaris 2: | |
31297 | ||
31298 | @table @gcctabopt | |
d77de738 | 31299 | @opindex mclear-hwcap |
ddf6fe37 | 31300 | @item -mclear-hwcap |
d77de738 ML |
31301 | @option{-mclear-hwcap} tells the compiler to remove the hardware |
31302 | capabilities generated by the Solaris assembler. This is only necessary | |
31303 | when object files use ISA extensions not supported by the current | |
31304 | machine, but check at runtime whether or not to use them. | |
31305 | ||
d77de738 | 31306 | @opindex mimpure-text |
ddf6fe37 | 31307 | @item -mimpure-text |
d77de738 ML |
31308 | @option{-mimpure-text}, used in addition to @option{-shared}, tells |
31309 | the compiler to not pass @option{-z text} to the linker when linking a | |
31310 | shared object. Using this option, you can link position-dependent | |
31311 | code into a shared object. | |
31312 | ||
31313 | @option{-mimpure-text} suppresses the ``relocations remain against | |
31314 | allocatable but non-writable sections'' linker error message. | |
31315 | However, the necessary relocations trigger copy-on-write, and the | |
31316 | shared object is not actually shared across processes. Instead of | |
31317 | using @option{-mimpure-text}, you should compile all source code with | |
31318 | @option{-fpic} or @option{-fPIC}. | |
31319 | ||
31320 | @end table | |
31321 | ||
31322 | These switches are supported in addition to the above on Solaris 2: | |
31323 | ||
31324 | @table @gcctabopt | |
d77de738 | 31325 | @opindex pthreads |
ddf6fe37 | 31326 | @item -pthreads |
d77de738 ML |
31327 | This is a synonym for @option{-pthread}. |
31328 | @end table | |
31329 | ||
31330 | @node SPARC Options | |
31331 | @subsection SPARC Options | |
31332 | @cindex SPARC options | |
31333 | ||
31334 | These @samp{-m} options are supported on the SPARC: | |
31335 | ||
31336 | @table @gcctabopt | |
d77de738 ML |
31337 | @opindex mno-app-regs |
31338 | @opindex mapp-regs | |
ddf6fe37 AA |
31339 | @item -mno-app-regs |
31340 | @itemx -mapp-regs | |
d77de738 ML |
31341 | Specify @option{-mapp-regs} to generate output using the global registers |
31342 | 2 through 4, which the SPARC SVR4 ABI reserves for applications. Like the | |
31343 | global register 1, each global register 2 through 4 is then treated as an | |
31344 | allocable register that is clobbered by function calls. This is the default. | |
31345 | ||
31346 | To be fully SVR4 ABI-compliant at the cost of some performance loss, | |
31347 | specify @option{-mno-app-regs}. You should compile libraries and system | |
31348 | software with this option. | |
31349 | ||
d77de738 ML |
31350 | @opindex mflat |
31351 | @opindex mno-flat | |
ddf6fe37 AA |
31352 | @item -mflat |
31353 | @itemx -mno-flat | |
d77de738 ML |
31354 | With @option{-mflat}, the compiler does not generate save/restore instructions |
31355 | and uses a ``flat'' or single register window model. This model is compatible | |
31356 | with the regular register window model. The local registers and the input | |
31357 | registers (0--5) are still treated as ``call-saved'' registers and are | |
31358 | saved on the stack as needed. | |
31359 | ||
31360 | With @option{-mno-flat} (the default), the compiler generates save/restore | |
31361 | instructions (except for leaf functions). This is the normal operating mode. | |
31362 | ||
d77de738 ML |
31363 | @opindex mfpu |
31364 | @opindex mhard-float | |
ddf6fe37 AA |
31365 | @item -mfpu |
31366 | @itemx -mhard-float | |
d77de738 ML |
31367 | Generate output containing floating-point instructions. This is the |
31368 | default. | |
31369 | ||
d77de738 ML |
31370 | @opindex mno-fpu |
31371 | @opindex msoft-float | |
ddf6fe37 AA |
31372 | @item -mno-fpu |
31373 | @itemx -msoft-float | |
d77de738 ML |
31374 | Generate output containing library calls for floating point. |
31375 | @strong{Warning:} the requisite libraries are not available for all SPARC | |
31376 | targets. Normally the facilities of the machine's usual C compiler are | |
31377 | used, but this cannot be done directly in cross-compilation. You must make | |
31378 | your own arrangements to provide suitable library functions for | |
31379 | cross-compilation. The embedded targets @samp{sparc-*-aout} and | |
31380 | @samp{sparclite-*-*} do provide software floating-point support. | |
31381 | ||
31382 | @option{-msoft-float} changes the calling convention in the output file; | |
31383 | therefore, it is only useful if you compile @emph{all} of a program with | |
31384 | this option. In particular, you need to compile @file{libgcc.a}, the | |
31385 | library that comes with GCC, with @option{-msoft-float} in order for | |
31386 | this to work. | |
31387 | ||
d77de738 | 31388 | @opindex mhard-quad-float |
ddf6fe37 | 31389 | @item -mhard-quad-float |
d77de738 ML |
31390 | Generate output containing quad-word (long double) floating-point |
31391 | instructions. | |
31392 | ||
d77de738 | 31393 | @opindex msoft-quad-float |
ddf6fe37 | 31394 | @item -msoft-quad-float |
d77de738 ML |
31395 | Generate output containing library calls for quad-word (long double) |
31396 | floating-point instructions. The functions called are those specified | |
31397 | in the SPARC ABI@. This is the default. | |
31398 | ||
31399 | As of this writing, there are no SPARC implementations that have hardware | |
31400 | support for the quad-word floating-point instructions. They all invoke | |
31401 | a trap handler for one of these instructions, and then the trap handler | |
31402 | emulates the effect of the instruction. Because of the trap handler overhead, | |
31403 | this is much slower than calling the ABI library routines. Thus the | |
31404 | @option{-msoft-quad-float} option is the default. | |
31405 | ||
d77de738 ML |
31406 | @opindex mno-unaligned-doubles |
31407 | @opindex munaligned-doubles | |
ddf6fe37 AA |
31408 | @item -mno-unaligned-doubles |
31409 | @itemx -munaligned-doubles | |
d77de738 ML |
31410 | Assume that doubles have 8-byte alignment. This is the default. |
31411 | ||
31412 | With @option{-munaligned-doubles}, GCC assumes that doubles have 8-byte | |
31413 | alignment only if they are contained in another type, or if they have an | |
31414 | absolute address. Otherwise, it assumes they have 4-byte alignment. | |
31415 | Specifying this option avoids some rare compatibility problems with code | |
31416 | generated by other compilers. It is not the default because it results | |
31417 | in a performance loss, especially for floating-point code. | |
31418 | ||
d77de738 ML |
31419 | @opindex muser-mode |
31420 | @opindex mno-user-mode | |
ddf6fe37 AA |
31421 | @item -muser-mode |
31422 | @itemx -mno-user-mode | |
d77de738 ML |
31423 | Do not generate code that can only run in supervisor mode. This is relevant |
31424 | only for the @code{casa} instruction emitted for the LEON3 processor. This | |
31425 | is the default. | |
31426 | ||
d77de738 ML |
31427 | @opindex mfaster-structs |
31428 | @opindex mno-faster-structs | |
ddf6fe37 AA |
31429 | @item -mfaster-structs |
31430 | @itemx -mno-faster-structs | |
d77de738 ML |
31431 | With @option{-mfaster-structs}, the compiler assumes that structures |
31432 | should have 8-byte alignment. This enables the use of pairs of | |
31433 | @code{ldd} and @code{std} instructions for copies in structure | |
31434 | assignment, in place of twice as many @code{ld} and @code{st} pairs. | |
31435 | However, the use of this changed alignment directly violates the SPARC | |
31436 | ABI@. Thus, it's intended only for use on targets where the developer | |
31437 | acknowledges that their resulting code is not directly in line with | |
31438 | the rules of the ABI@. | |
31439 | ||
d77de738 ML |
31440 | @opindex mstd-struct-return |
31441 | @opindex mno-std-struct-return | |
ddf6fe37 AA |
31442 | @item -mstd-struct-return |
31443 | @itemx -mno-std-struct-return | |
d77de738 ML |
31444 | With @option{-mstd-struct-return}, the compiler generates checking code |
31445 | in functions returning structures or unions to detect size mismatches | |
31446 | between the two sides of function calls, as per the 32-bit ABI@. | |
31447 | ||
31448 | The default is @option{-mno-std-struct-return}. This option has no effect | |
31449 | in 64-bit mode. | |
31450 | ||
d77de738 ML |
31451 | @opindex mlra |
31452 | @opindex mno-lra | |
ddf6fe37 AA |
31453 | @item -mlra |
31454 | @itemx -mno-lra | |
d77de738 ML |
31455 | Enable Local Register Allocation. This is the default for SPARC since GCC 7 |
31456 | so @option{-mno-lra} needs to be passed to get old Reload. | |
31457 | ||
d77de738 | 31458 | @opindex mcpu |
ddf6fe37 | 31459 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
31460 | Set the instruction set, register set, and instruction scheduling parameters |
31461 | for machine type @var{cpu_type}. Supported values for @var{cpu_type} are | |
31462 | @samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{hypersparc}, | |
31463 | @samp{leon}, @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{sparclite}, | |
31464 | @samp{f930}, @samp{f934}, @samp{sparclite86x}, @samp{sparclet}, @samp{tsc701}, | |
31465 | @samp{v9}, @samp{ultrasparc}, @samp{ultrasparc3}, @samp{niagara}, | |
31466 | @samp{niagara2}, @samp{niagara3}, @samp{niagara4}, @samp{niagara7} and | |
31467 | @samp{m8}. | |
31468 | ||
31469 | Native Solaris and GNU/Linux toolchains also support the value @samp{native}, | |
31470 | which selects the best architecture option for the host processor. | |
31471 | @option{-mcpu=native} has no effect if GCC does not recognize | |
31472 | the processor. | |
31473 | ||
31474 | Default instruction scheduling parameters are used for values that select | |
31475 | an architecture and not an implementation. These are @samp{v7}, @samp{v8}, | |
31476 | @samp{sparclite}, @samp{sparclet}, @samp{v9}. | |
31477 | ||
31478 | Here is a list of each supported architecture and their supported | |
31479 | implementations. | |
31480 | ||
31481 | @table @asis | |
31482 | @item v7 | |
31483 | cypress, leon3v7 | |
31484 | ||
31485 | @item v8 | |
31486 | supersparc, hypersparc, leon, leon3, leon5 | |
31487 | ||
31488 | @item sparclite | |
31489 | f930, f934, sparclite86x | |
31490 | ||
31491 | @item sparclet | |
31492 | tsc701 | |
31493 | ||
31494 | @item v9 | |
31495 | ultrasparc, ultrasparc3, niagara, niagara2, niagara3, niagara4, | |
31496 | niagara7, m8 | |
31497 | @end table | |
31498 | ||
31499 | By default (unless configured otherwise), GCC generates code for the V7 | |
31500 | variant of the SPARC architecture. With @option{-mcpu=cypress}, the compiler | |
31501 | additionally optimizes it for the Cypress CY7C602 chip, as used in the | |
31502 | SPARCStation/SPARCServer 3xx series. This is also appropriate for the older | |
31503 | SPARCStation 1, 2, IPX etc. | |
31504 | ||
31505 | With @option{-mcpu=v8}, GCC generates code for the V8 variant of the SPARC | |
31506 | architecture. The only difference from V7 code is that the compiler emits | |
31507 | the integer multiply and integer divide instructions which exist in SPARC-V8 | |
31508 | but not in SPARC-V7. With @option{-mcpu=supersparc}, the compiler additionally | |
31509 | optimizes it for the SuperSPARC chip, as used in the SPARCStation 10, 1000 and | |
31510 | 2000 series. | |
31511 | ||
31512 | With @option{-mcpu=sparclite}, GCC generates code for the SPARClite variant of | |
31513 | the SPARC architecture. This adds the integer multiply, integer divide step | |
31514 | and scan (@code{ffs}) instructions which exist in SPARClite but not in SPARC-V7. | |
31515 | With @option{-mcpu=f930}, the compiler additionally optimizes it for the | |
31516 | Fujitsu MB86930 chip, which is the original SPARClite, with no FPU@. With | |
31517 | @option{-mcpu=f934}, the compiler additionally optimizes it for the Fujitsu | |
31518 | MB86934 chip, which is the more recent SPARClite with FPU@. | |
31519 | ||
31520 | With @option{-mcpu=sparclet}, GCC generates code for the SPARClet variant of | |
31521 | the SPARC architecture. This adds the integer multiply, multiply/accumulate, | |
31522 | integer divide step and scan (@code{ffs}) instructions which exist in SPARClet | |
31523 | but not in SPARC-V7. With @option{-mcpu=tsc701}, the compiler additionally | |
31524 | optimizes it for the TEMIC SPARClet chip. | |
31525 | ||
31526 | With @option{-mcpu=v9}, GCC generates code for the V9 variant of the SPARC | |
31527 | architecture. This adds 64-bit integer and floating-point move instructions, | |
31528 | 3 additional floating-point condition code registers and conditional move | |
31529 | instructions. With @option{-mcpu=ultrasparc}, the compiler additionally | |
31530 | optimizes it for the Sun UltraSPARC I/II/IIi chips. With | |
31531 | @option{-mcpu=ultrasparc3}, the compiler additionally optimizes it for the | |
31532 | Sun UltraSPARC III/III+/IIIi/IIIi+/IV/IV+ chips. With | |
31533 | @option{-mcpu=niagara}, the compiler additionally optimizes it for | |
31534 | Sun UltraSPARC T1 chips. With @option{-mcpu=niagara2}, the compiler | |
31535 | additionally optimizes it for Sun UltraSPARC T2 chips. With | |
31536 | @option{-mcpu=niagara3}, the compiler additionally optimizes it for Sun | |
31537 | UltraSPARC T3 chips. With @option{-mcpu=niagara4}, the compiler | |
31538 | additionally optimizes it for Sun UltraSPARC T4 chips. With | |
31539 | @option{-mcpu=niagara7}, the compiler additionally optimizes it for | |
31540 | Oracle SPARC M7 chips. With @option{-mcpu=m8}, the compiler | |
31541 | additionally optimizes it for Oracle M8 chips. | |
31542 | ||
d77de738 | 31543 | @opindex mtune |
ddf6fe37 | 31544 | @item -mtune=@var{cpu_type} |
d77de738 ML |
31545 | Set the instruction scheduling parameters for machine type |
31546 | @var{cpu_type}, but do not set the instruction set or register set that the | |
31547 | option @option{-mcpu=@var{cpu_type}} does. | |
31548 | ||
31549 | The same values for @option{-mcpu=@var{cpu_type}} can be used for | |
31550 | @option{-mtune=@var{cpu_type}}, but the only useful values are those | |
31551 | that select a particular CPU implementation. Those are | |
31552 | @samp{cypress}, @samp{supersparc}, @samp{hypersparc}, @samp{leon}, | |
31553 | @samp{leon3}, @samp{leon3v7}, @samp{leon5}, @samp{f930}, @samp{f934}, | |
31554 | @samp{sparclite86x}, @samp{tsc701}, @samp{ultrasparc}, | |
31555 | @samp{ultrasparc3}, @samp{niagara}, @samp{niagara2}, @samp{niagara3}, | |
31556 | @samp{niagara4}, @samp{niagara7} and @samp{m8}. With native Solaris | |
31557 | and GNU/Linux toolchains, @samp{native} can also be used. | |
31558 | ||
d77de738 ML |
31559 | @opindex mv8plus |
31560 | @opindex mno-v8plus | |
ddf6fe37 AA |
31561 | @item -mv8plus |
31562 | @itemx -mno-v8plus | |
d77de738 ML |
31563 | With @option{-mv8plus}, GCC generates code for the SPARC-V8+ ABI@. The |
31564 | difference from the V8 ABI is that the global and out registers are | |
31565 | considered 64 bits wide. This is enabled by default on Solaris in 32-bit | |
31566 | mode for all SPARC-V9 processors. | |
31567 | ||
d77de738 ML |
31568 | @opindex mvis |
31569 | @opindex mno-vis | |
ddf6fe37 AA |
31570 | @item -mvis |
31571 | @itemx -mno-vis | |
d77de738 ML |
31572 | With @option{-mvis}, GCC generates code that takes advantage of the UltraSPARC |
31573 | Visual Instruction Set extensions. The default is @option{-mno-vis}. | |
31574 | ||
d77de738 ML |
31575 | @opindex mvis2 |
31576 | @opindex mno-vis2 | |
ddf6fe37 AA |
31577 | @item -mvis2 |
31578 | @itemx -mno-vis2 | |
d77de738 ML |
31579 | With @option{-mvis2}, GCC generates code that takes advantage of |
31580 | version 2.0 of the UltraSPARC Visual Instruction Set extensions. The | |
31581 | default is @option{-mvis2} when targeting a cpu that supports such | |
31582 | instructions, such as UltraSPARC-III and later. Setting @option{-mvis2} | |
31583 | also sets @option{-mvis}. | |
31584 | ||
d77de738 ML |
31585 | @opindex mvis3 |
31586 | @opindex mno-vis3 | |
ddf6fe37 AA |
31587 | @item -mvis3 |
31588 | @itemx -mno-vis3 | |
d77de738 ML |
31589 | With @option{-mvis3}, GCC generates code that takes advantage of |
31590 | version 3.0 of the UltraSPARC Visual Instruction Set extensions. The | |
31591 | default is @option{-mvis3} when targeting a cpu that supports such | |
31592 | instructions, such as niagara-3 and later. Setting @option{-mvis3} | |
31593 | also sets @option{-mvis2} and @option{-mvis}. | |
31594 | ||
d77de738 ML |
31595 | @opindex mvis4 |
31596 | @opindex mno-vis4 | |
ddf6fe37 AA |
31597 | @item -mvis4 |
31598 | @itemx -mno-vis4 | |
d77de738 ML |
31599 | With @option{-mvis4}, GCC generates code that takes advantage of |
31600 | version 4.0 of the UltraSPARC Visual Instruction Set extensions. The | |
31601 | default is @option{-mvis4} when targeting a cpu that supports such | |
31602 | instructions, such as niagara-7 and later. Setting @option{-mvis4} | |
31603 | also sets @option{-mvis3}, @option{-mvis2} and @option{-mvis}. | |
31604 | ||
d77de738 ML |
31605 | @opindex mvis4b |
31606 | @opindex mno-vis4b | |
ddf6fe37 AA |
31607 | @item -mvis4b |
31608 | @itemx -mno-vis4b | |
d77de738 ML |
31609 | With @option{-mvis4b}, GCC generates code that takes advantage of |
31610 | version 4.0 of the UltraSPARC Visual Instruction Set extensions, plus | |
31611 | the additional VIS instructions introduced in the Oracle SPARC | |
31612 | Architecture 2017. The default is @option{-mvis4b} when targeting a | |
31613 | cpu that supports such instructions, such as m8 and later. Setting | |
31614 | @option{-mvis4b} also sets @option{-mvis4}, @option{-mvis3}, | |
31615 | @option{-mvis2} and @option{-mvis}. | |
31616 | ||
d77de738 ML |
31617 | @opindex mcbcond |
31618 | @opindex mno-cbcond | |
ddf6fe37 AA |
31619 | @item -mcbcond |
31620 | @itemx -mno-cbcond | |
d77de738 ML |
31621 | With @option{-mcbcond}, GCC generates code that takes advantage of the UltraSPARC |
31622 | Compare-and-Branch-on-Condition instructions. The default is @option{-mcbcond} | |
31623 | when targeting a CPU that supports such instructions, such as Niagara-4 and | |
31624 | later. | |
31625 | ||
d77de738 ML |
31626 | @opindex mfmaf |
31627 | @opindex mno-fmaf | |
ddf6fe37 AA |
31628 | @item -mfmaf |
31629 | @itemx -mno-fmaf | |
d77de738 ML |
31630 | With @option{-mfmaf}, GCC generates code that takes advantage of the UltraSPARC |
31631 | Fused Multiply-Add Floating-point instructions. The default is @option{-mfmaf} | |
31632 | when targeting a CPU that supports such instructions, such as Niagara-3 and | |
31633 | later. | |
31634 | ||
d77de738 ML |
31635 | @opindex mfsmuld |
31636 | @opindex mno-fsmuld | |
ddf6fe37 AA |
31637 | @item -mfsmuld |
31638 | @itemx -mno-fsmuld | |
d77de738 ML |
31639 | With @option{-mfsmuld}, GCC generates code that takes advantage of the |
31640 | Floating-point Multiply Single to Double (FsMULd) instruction. The default is | |
31641 | @option{-mfsmuld} when targeting a CPU supporting the architecture versions V8 | |
31642 | or V9 with FPU except @option{-mcpu=leon}. | |
31643 | ||
d77de738 ML |
31644 | @opindex mpopc |
31645 | @opindex mno-popc | |
ddf6fe37 AA |
31646 | @item -mpopc |
31647 | @itemx -mno-popc | |
d77de738 ML |
31648 | With @option{-mpopc}, GCC generates code that takes advantage of the UltraSPARC |
31649 | Population Count instruction. The default is @option{-mpopc} | |
31650 | when targeting a CPU that supports such an instruction, such as Niagara-2 and | |
31651 | later. | |
31652 | ||
d77de738 ML |
31653 | @opindex msubxc |
31654 | @opindex mno-subxc | |
ddf6fe37 AA |
31655 | @item -msubxc |
31656 | @itemx -mno-subxc | |
d77de738 ML |
31657 | With @option{-msubxc}, GCC generates code that takes advantage of the UltraSPARC |
31658 | Subtract-Extended-with-Carry instruction. The default is @option{-msubxc} | |
31659 | when targeting a CPU that supports such an instruction, such as Niagara-7 and | |
31660 | later. | |
31661 | ||
d77de738 | 31662 | @opindex mfix-at697f |
ddf6fe37 | 31663 | @item -mfix-at697f |
d77de738 ML |
31664 | Enable the documented workaround for the single erratum of the Atmel AT697F |
31665 | processor (which corresponds to erratum #13 of the AT697E processor). | |
31666 | ||
d77de738 | 31667 | @opindex mfix-ut699 |
ddf6fe37 | 31668 | @item -mfix-ut699 |
d77de738 ML |
31669 | Enable the documented workarounds for the floating-point errata and the data |
31670 | cache nullify errata of the UT699 processor. | |
31671 | ||
d77de738 | 31672 | @opindex mfix-ut700 |
ddf6fe37 | 31673 | @item -mfix-ut700 |
d77de738 ML |
31674 | Enable the documented workaround for the back-to-back store errata of |
31675 | the UT699E/UT700 processor. | |
31676 | ||
d77de738 | 31677 | @opindex mfix-gr712rc |
ddf6fe37 | 31678 | @item -mfix-gr712rc |
d77de738 ML |
31679 | Enable the documented workaround for the back-to-back store errata of |
31680 | the GR712RC processor. | |
31681 | @end table | |
31682 | ||
31683 | These @samp{-m} options are supported in addition to the above | |
31684 | on SPARC-V9 processors in 64-bit environments: | |
31685 | ||
31686 | @table @gcctabopt | |
d77de738 ML |
31687 | @opindex m32 |
31688 | @opindex m64 | |
ddf6fe37 AA |
31689 | @item -m32 |
31690 | @itemx -m64 | |
d77de738 ML |
31691 | Generate code for a 32-bit or 64-bit environment. |
31692 | The 32-bit environment sets int, long and pointer to 32 bits. | |
31693 | The 64-bit environment sets int to 32 bits and long and pointer | |
31694 | to 64 bits. | |
31695 | ||
d77de738 | 31696 | @opindex mcmodel |
ddf6fe37 | 31697 | @item -mcmodel=@var{which} |
d77de738 ML |
31698 | Set the code model to one of |
31699 | ||
31700 | @table @samp | |
31701 | @item medlow | |
31702 | The Medium/Low code model: 64-bit addresses, programs | |
31703 | must be linked in the low 32 bits of memory. Programs can be statically | |
31704 | or dynamically linked. | |
31705 | ||
31706 | @item medmid | |
31707 | The Medium/Middle code model: 64-bit addresses, programs | |
31708 | must be linked in the low 44 bits of memory, the text and data segments must | |
31709 | be less than 2GB in size and the data segment must be located within 2GB of | |
31710 | the text segment. | |
31711 | ||
31712 | @item medany | |
31713 | The Medium/Anywhere code model: 64-bit addresses, programs | |
31714 | may be linked anywhere in memory, the text and data segments must be less | |
31715 | than 2GB in size and the data segment must be located within 2GB of the | |
31716 | text segment. | |
31717 | ||
31718 | @item embmedany | |
31719 | The Medium/Anywhere code model for embedded systems: | |
31720 | 64-bit addresses, the text and data segments must be less than 2GB in | |
31721 | size, both starting anywhere in memory (determined at link time). The | |
31722 | global register %g4 points to the base of the data segment. Programs | |
31723 | are statically linked and PIC is not supported. | |
31724 | @end table | |
31725 | ||
d77de738 | 31726 | @opindex mmemory-model |
ddf6fe37 | 31727 | @item -mmemory-model=@var{mem-model} |
d77de738 ML |
31728 | Set the memory model in force on the processor to one of |
31729 | ||
31730 | @table @samp | |
31731 | @item default | |
31732 | The default memory model for the processor and operating system. | |
31733 | ||
31734 | @item rmo | |
31735 | Relaxed Memory Order | |
31736 | ||
31737 | @item pso | |
31738 | Partial Store Order | |
31739 | ||
31740 | @item tso | |
31741 | Total Store Order | |
31742 | ||
31743 | @item sc | |
31744 | Sequential Consistency | |
31745 | @end table | |
31746 | ||
31747 | These memory models are formally defined in Appendix D of the SPARC-V9 | |
31748 | architecture manual, as set in the processor's @code{PSTATE.MM} field. | |
31749 | ||
d77de738 ML |
31750 | @opindex mstack-bias |
31751 | @opindex mno-stack-bias | |
ddf6fe37 AA |
31752 | @item -mstack-bias |
31753 | @itemx -mno-stack-bias | |
d77de738 ML |
31754 | With @option{-mstack-bias}, GCC assumes that the stack pointer, and |
31755 | frame pointer if present, are offset by @minus{}2047 which must be added back | |
31756 | when making stack frame references. This is the default in 64-bit mode. | |
31757 | Otherwise, assume no such offset is present. | |
31758 | @end table | |
31759 | ||
31760 | @node System V Options | |
31761 | @subsection Options for System V | |
31762 | ||
31763 | These additional options are available on System V Release 4 for | |
31764 | compatibility with other compilers on those systems: | |
31765 | ||
31766 | @table @gcctabopt | |
d77de738 | 31767 | @opindex G |
ddf6fe37 | 31768 | @item -G |
d77de738 ML |
31769 | Create a shared object. |
31770 | It is recommended that @option{-symbolic} or @option{-shared} be used instead. | |
31771 | ||
d77de738 | 31772 | @opindex Qy |
ddf6fe37 | 31773 | @item -Qy |
d77de738 ML |
31774 | Identify the versions of each tool used by the compiler, in a |
31775 | @code{.ident} assembler directive in the output. | |
31776 | ||
d77de738 | 31777 | @opindex Qn |
ddf6fe37 | 31778 | @item -Qn |
d77de738 ML |
31779 | Refrain from adding @code{.ident} directives to the output file (this is |
31780 | the default). | |
31781 | ||
d77de738 | 31782 | @opindex YP |
ddf6fe37 | 31783 | @item -YP,@var{dirs} |
d77de738 ML |
31784 | Search the directories @var{dirs}, and no others, for libraries |
31785 | specified with @option{-l}. | |
31786 | ||
d77de738 | 31787 | @opindex Ym |
ddf6fe37 | 31788 | @item -Ym,@var{dir} |
d77de738 ML |
31789 | Look in the directory @var{dir} to find the M4 preprocessor. |
31790 | The assembler uses this option. | |
31791 | @c This is supposed to go with a -Yd for predefined M4 macro files, but | |
31792 | @c the generic assembler that comes with Solaris takes just -Ym. | |
31793 | @end table | |
31794 | ||
31795 | @node V850 Options | |
31796 | @subsection V850 Options | |
31797 | @cindex V850 Options | |
31798 | ||
31799 | These @samp{-m} options are defined for V850 implementations: | |
31800 | ||
31801 | @table @gcctabopt | |
d77de738 ML |
31802 | @opindex mlong-calls |
31803 | @opindex mno-long-calls | |
ddf6fe37 AA |
31804 | @item -mlong-calls |
31805 | @itemx -mno-long-calls | |
d77de738 ML |
31806 | Treat all calls as being far away (near). If calls are assumed to be |
31807 | far away, the compiler always loads the function's address into a | |
31808 | register, and calls indirect through the pointer. | |
31809 | ||
d77de738 ML |
31810 | @opindex mno-ep |
31811 | @opindex mep | |
ddf6fe37 AA |
31812 | @item -mno-ep |
31813 | @itemx -mep | |
d77de738 ML |
31814 | Do not optimize (do optimize) basic blocks that use the same index |
31815 | pointer 4 or more times to copy pointer into the @code{ep} register, and | |
31816 | use the shorter @code{sld} and @code{sst} instructions. The @option{-mep} | |
31817 | option is on by default if you optimize. | |
31818 | ||
d77de738 ML |
31819 | @opindex mno-prolog-function |
31820 | @opindex mprolog-function | |
ddf6fe37 AA |
31821 | @item -mno-prolog-function |
31822 | @itemx -mprolog-function | |
d77de738 ML |
31823 | Do not use (do use) external functions to save and restore registers |
31824 | at the prologue and epilogue of a function. The external functions | |
31825 | are slower, but use less code space if more than one function saves | |
31826 | the same number of registers. The @option{-mprolog-function} option | |
31827 | is on by default if you optimize. | |
31828 | ||
d77de738 | 31829 | @opindex mspace |
ddf6fe37 | 31830 | @item -mspace |
d77de738 ML |
31831 | Try to make the code as small as possible. At present, this just turns |
31832 | on the @option{-mep} and @option{-mprolog-function} options. | |
31833 | ||
d77de738 | 31834 | @opindex mtda |
ddf6fe37 | 31835 | @item -mtda=@var{n} |
d77de738 ML |
31836 | Put static or global variables whose size is @var{n} bytes or less into |
31837 | the tiny data area that register @code{ep} points to. The tiny data | |
31838 | area can hold up to 256 bytes in total (128 bytes for byte references). | |
31839 | ||
d77de738 | 31840 | @opindex msda |
ddf6fe37 | 31841 | @item -msda=@var{n} |
d77de738 ML |
31842 | Put static or global variables whose size is @var{n} bytes or less into |
31843 | the small data area that register @code{gp} points to. The small data | |
31844 | area can hold up to 64 kilobytes. | |
31845 | ||
d77de738 | 31846 | @opindex mzda |
ddf6fe37 | 31847 | @item -mzda=@var{n} |
d77de738 ML |
31848 | Put static or global variables whose size is @var{n} bytes or less into |
31849 | the first 32 kilobytes of memory. | |
31850 | ||
d77de738 | 31851 | @opindex mv850 |
ddf6fe37 | 31852 | @item -mv850 |
d77de738 ML |
31853 | Specify that the target processor is the V850. |
31854 | ||
d77de738 | 31855 | @opindex mv850e3v5 |
ddf6fe37 | 31856 | @item -mv850e3v5 |
d77de738 ML |
31857 | Specify that the target processor is the V850E3V5. The preprocessor |
31858 | constant @code{__v850e3v5__} is defined if this option is used. | |
31859 | ||
d77de738 | 31860 | @opindex mv850e2v4 |
ddf6fe37 | 31861 | @item -mv850e2v4 |
d77de738 ML |
31862 | Specify that the target processor is the V850E3V5. This is an alias for |
31863 | the @option{-mv850e3v5} option. | |
31864 | ||
d77de738 | 31865 | @opindex mv850e2v3 |
ddf6fe37 | 31866 | @item -mv850e2v3 |
d77de738 ML |
31867 | Specify that the target processor is the V850E2V3. The preprocessor |
31868 | constant @code{__v850e2v3__} is defined if this option is used. | |
31869 | ||
d77de738 | 31870 | @opindex mv850e2 |
ddf6fe37 | 31871 | @item -mv850e2 |
d77de738 ML |
31872 | Specify that the target processor is the V850E2. The preprocessor |
31873 | constant @code{__v850e2__} is defined if this option is used. | |
31874 | ||
d77de738 | 31875 | @opindex mv850e1 |
ddf6fe37 | 31876 | @item -mv850e1 |
d77de738 ML |
31877 | Specify that the target processor is the V850E1. The preprocessor |
31878 | constants @code{__v850e1__} and @code{__v850e__} are defined if | |
31879 | this option is used. | |
31880 | ||
d77de738 | 31881 | @opindex mv850es |
ddf6fe37 | 31882 | @item -mv850es |
d77de738 ML |
31883 | Specify that the target processor is the V850ES. This is an alias for |
31884 | the @option{-mv850e1} option. | |
31885 | ||
d77de738 | 31886 | @opindex mv850e |
ddf6fe37 | 31887 | @item -mv850e |
d77de738 ML |
31888 | Specify that the target processor is the V850E@. The preprocessor |
31889 | constant @code{__v850e__} is defined if this option is used. | |
31890 | ||
31891 | If neither @option{-mv850} nor @option{-mv850e} nor @option{-mv850e1} | |
31892 | nor @option{-mv850e2} nor @option{-mv850e2v3} nor @option{-mv850e3v5} | |
31893 | are defined then a default target processor is chosen and the | |
31894 | relevant @samp{__v850*__} preprocessor constant is defined. | |
31895 | ||
31896 | The preprocessor constants @code{__v850} and @code{__v851__} are always | |
31897 | defined, regardless of which processor variant is the target. | |
31898 | ||
d77de738 ML |
31899 | @opindex mdisable-callt |
31900 | @opindex mno-disable-callt | |
ddf6fe37 AA |
31901 | @item -mdisable-callt |
31902 | @itemx -mno-disable-callt | |
d77de738 ML |
31903 | This option suppresses generation of the @code{CALLT} instruction for the |
31904 | v850e, v850e1, v850e2, v850e2v3 and v850e3v5 flavors of the v850 | |
31905 | architecture. | |
31906 | ||
31907 | This option is enabled by default when the RH850 ABI is | |
31908 | in use (see @option{-mrh850-abi}), and disabled by default when the | |
31909 | GCC ABI is in use. If @code{CALLT} instructions are being generated | |
31910 | then the C preprocessor symbol @code{__V850_CALLT__} is defined. | |
31911 | ||
d77de738 ML |
31912 | @opindex mrelax |
31913 | @opindex mno-relax | |
ddf6fe37 AA |
31914 | @item -mrelax |
31915 | @itemx -mno-relax | |
d77de738 ML |
31916 | Pass on (or do not pass on) the @option{-mrelax} command-line option |
31917 | to the assembler. | |
31918 | ||
d77de738 ML |
31919 | @opindex mlong-jumps |
31920 | @opindex mno-long-jumps | |
ddf6fe37 AA |
31921 | @item -mlong-jumps |
31922 | @itemx -mno-long-jumps | |
d77de738 ML |
31923 | Disable (or re-enable) the generation of PC-relative jump instructions. |
31924 | ||
d77de738 ML |
31925 | @opindex msoft-float |
31926 | @opindex mhard-float | |
ddf6fe37 AA |
31927 | @item -msoft-float |
31928 | @itemx -mhard-float | |
d77de738 ML |
31929 | Disable (or re-enable) the generation of hardware floating point |
31930 | instructions. This option is only significant when the target | |
31931 | architecture is @samp{V850E2V3} or higher. If hardware floating point | |
31932 | instructions are being generated then the C preprocessor symbol | |
31933 | @code{__FPU_OK__} is defined, otherwise the symbol | |
31934 | @code{__NO_FPU__} is defined. | |
31935 | ||
d77de738 | 31936 | @opindex mloop |
ddf6fe37 | 31937 | @item -mloop |
d77de738 ML |
31938 | Enables the use of the e3v5 LOOP instruction. The use of this |
31939 | instruction is not enabled by default when the e3v5 architecture is | |
31940 | selected because its use is still experimental. | |
31941 | ||
d77de738 ML |
31942 | @opindex mrh850-abi |
31943 | @opindex mghs | |
ddf6fe37 AA |
31944 | @item -mrh850-abi |
31945 | @itemx -mghs | |
d77de738 ML |
31946 | Enables support for the RH850 version of the V850 ABI. This is the |
31947 | default. With this version of the ABI the following rules apply: | |
31948 | ||
31949 | @itemize | |
31950 | @item | |
31951 | Integer sized structures and unions are returned via a memory pointer | |
31952 | rather than a register. | |
31953 | ||
31954 | @item | |
31955 | Large structures and unions (more than 8 bytes in size) are passed by | |
31956 | value. | |
31957 | ||
31958 | @item | |
31959 | Functions are aligned to 16-bit boundaries. | |
31960 | ||
31961 | @item | |
31962 | The @option{-m8byte-align} command-line option is supported. | |
31963 | ||
31964 | @item | |
31965 | The @option{-mdisable-callt} command-line option is enabled by | |
31966 | default. The @option{-mno-disable-callt} command-line option is not | |
31967 | supported. | |
31968 | @end itemize | |
31969 | ||
31970 | When this version of the ABI is enabled the C preprocessor symbol | |
31971 | @code{__V850_RH850_ABI__} is defined. | |
31972 | ||
d77de738 | 31973 | @opindex mgcc-abi |
ddf6fe37 | 31974 | @item -mgcc-abi |
d77de738 ML |
31975 | Enables support for the old GCC version of the V850 ABI. With this |
31976 | version of the ABI the following rules apply: | |
31977 | ||
31978 | @itemize | |
31979 | @item | |
31980 | Integer sized structures and unions are returned in register @code{r10}. | |
31981 | ||
31982 | @item | |
31983 | Large structures and unions (more than 8 bytes in size) are passed by | |
31984 | reference. | |
31985 | ||
31986 | @item | |
31987 | Functions are aligned to 32-bit boundaries, unless optimizing for | |
31988 | size. | |
31989 | ||
31990 | @item | |
31991 | The @option{-m8byte-align} command-line option is not supported. | |
31992 | ||
31993 | @item | |
31994 | The @option{-mdisable-callt} command-line option is supported but not | |
31995 | enabled by default. | |
31996 | @end itemize | |
31997 | ||
31998 | When this version of the ABI is enabled the C preprocessor symbol | |
31999 | @code{__V850_GCC_ABI__} is defined. | |
32000 | ||
d77de738 ML |
32001 | @opindex m8byte-align |
32002 | @opindex mno-8byte-align | |
ddf6fe37 AA |
32003 | @item -m8byte-align |
32004 | @itemx -mno-8byte-align | |
d77de738 ML |
32005 | Enables support for @code{double} and @code{long long} types to be |
32006 | aligned on 8-byte boundaries. The default is to restrict the | |
32007 | alignment of all objects to at most 4-bytes. When | |
32008 | @option{-m8byte-align} is in effect the C preprocessor symbol | |
32009 | @code{__V850_8BYTE_ALIGN__} is defined. | |
32010 | ||
d77de738 | 32011 | @opindex mbig-switch |
ddf6fe37 | 32012 | @item -mbig-switch |
d77de738 ML |
32013 | Generate code suitable for big switch tables. Use this option only if |
32014 | the assembler/linker complain about out of range branches within a switch | |
32015 | table. | |
32016 | ||
d77de738 | 32017 | @opindex mapp-regs |
ddf6fe37 | 32018 | @item -mapp-regs |
d77de738 ML |
32019 | This option causes r2 and r5 to be used in the code generated by |
32020 | the compiler. This setting is the default. | |
32021 | ||
d77de738 | 32022 | @opindex mno-app-regs |
ddf6fe37 | 32023 | @item -mno-app-regs |
d77de738 ML |
32024 | This option causes r2 and r5 to be treated as fixed registers. |
32025 | ||
32026 | @end table | |
32027 | ||
32028 | @node VAX Options | |
32029 | @subsection VAX Options | |
32030 | @cindex VAX options | |
32031 | ||
32032 | These @samp{-m} options are defined for the VAX: | |
32033 | ||
32034 | @table @gcctabopt | |
d77de738 | 32035 | @opindex munix |
ddf6fe37 | 32036 | @item -munix |
d77de738 ML |
32037 | Do not output certain jump instructions (@code{aobleq} and so on) |
32038 | that the Unix assembler for the VAX cannot handle across long | |
32039 | ranges. | |
32040 | ||
d77de738 | 32041 | @opindex mgnu |
ddf6fe37 | 32042 | @item -mgnu |
d77de738 ML |
32043 | Do output those jump instructions, on the assumption that the |
32044 | GNU assembler is being used. | |
32045 | ||
d77de738 | 32046 | @opindex mg |
ddf6fe37 | 32047 | @item -mg |
d77de738 ML |
32048 | Output code for G-format floating-point numbers instead of D-format. |
32049 | ||
d77de738 ML |
32050 | @opindex mlra |
32051 | @opindex mno-lra | |
ddf6fe37 AA |
32052 | @item -mlra |
32053 | @itemx -mno-lra | |
d77de738 ML |
32054 | Enable Local Register Allocation. This is still experimental for the VAX, |
32055 | so by default the compiler uses standard reload. | |
32056 | @end table | |
32057 | ||
32058 | @node Visium Options | |
32059 | @subsection Visium Options | |
32060 | @cindex Visium options | |
32061 | ||
32062 | @table @gcctabopt | |
32063 | ||
d77de738 | 32064 | @opindex mdebug |
ddf6fe37 | 32065 | @item -mdebug |
d77de738 ML |
32066 | A program which performs file I/O and is destined to run on an MCM target |
32067 | should be linked with this option. It causes the libraries libc.a and | |
32068 | libdebug.a to be linked. The program should be run on the target under | |
32069 | the control of the GDB remote debugging stub. | |
32070 | ||
d77de738 | 32071 | @opindex msim |
ddf6fe37 | 32072 | @item -msim |
d77de738 ML |
32073 | A program which performs file I/O and is destined to run on the simulator |
32074 | should be linked with option. This causes libraries libc.a and libsim.a to | |
32075 | be linked. | |
32076 | ||
d77de738 ML |
32077 | @opindex mfpu |
32078 | @opindex mhard-float | |
ddf6fe37 AA |
32079 | @item -mfpu |
32080 | @itemx -mhard-float | |
d77de738 ML |
32081 | Generate code containing floating-point instructions. This is the |
32082 | default. | |
32083 | ||
d77de738 ML |
32084 | @opindex mno-fpu |
32085 | @opindex msoft-float | |
ddf6fe37 AA |
32086 | @item -mno-fpu |
32087 | @itemx -msoft-float | |
d77de738 ML |
32088 | Generate code containing library calls for floating-point. |
32089 | ||
32090 | @option{-msoft-float} changes the calling convention in the output file; | |
32091 | therefore, it is only useful if you compile @emph{all} of a program with | |
32092 | this option. In particular, you need to compile @file{libgcc.a}, the | |
32093 | library that comes with GCC, with @option{-msoft-float} in order for | |
32094 | this to work. | |
32095 | ||
d77de738 | 32096 | @opindex mcpu |
ddf6fe37 | 32097 | @item -mcpu=@var{cpu_type} |
d77de738 ML |
32098 | Set the instruction set, register set, and instruction scheduling parameters |
32099 | for machine type @var{cpu_type}. Supported values for @var{cpu_type} are | |
32100 | @samp{mcm}, @samp{gr5} and @samp{gr6}. | |
32101 | ||
32102 | @samp{mcm} is a synonym of @samp{gr5} present for backward compatibility. | |
32103 | ||
32104 | By default (unless configured otherwise), GCC generates code for the GR5 | |
32105 | variant of the Visium architecture. | |
32106 | ||
32107 | With @option{-mcpu=gr6}, GCC generates code for the GR6 variant of the Visium | |
32108 | architecture. The only difference from GR5 code is that the compiler will | |
32109 | generate block move instructions. | |
32110 | ||
d77de738 | 32111 | @opindex mtune |
ddf6fe37 | 32112 | @item -mtune=@var{cpu_type} |
d77de738 ML |
32113 | Set the instruction scheduling parameters for machine type @var{cpu_type}, |
32114 | but do not set the instruction set or register set that the option | |
32115 | @option{-mcpu=@var{cpu_type}} would. | |
32116 | ||
d77de738 | 32117 | @opindex msv-mode |
ddf6fe37 | 32118 | @item -msv-mode |
d77de738 ML |
32119 | Generate code for the supervisor mode, where there are no restrictions on |
32120 | the access to general registers. This is the default. | |
32121 | ||
d77de738 | 32122 | @opindex muser-mode |
ddf6fe37 | 32123 | @item -muser-mode |
d77de738 ML |
32124 | Generate code for the user mode, where the access to some general registers |
32125 | is forbidden: on the GR5, registers r24 to r31 cannot be accessed in this | |
32126 | mode; on the GR6, only registers r29 to r31 are affected. | |
32127 | @end table | |
32128 | ||
32129 | @node VMS Options | |
32130 | @subsection VMS Options | |
32131 | ||
32132 | These @samp{-m} options are defined for the VMS implementations: | |
32133 | ||
32134 | @table @gcctabopt | |
d77de738 | 32135 | @opindex mvms-return-codes |
ddf6fe37 | 32136 | @item -mvms-return-codes |
d77de738 ML |
32137 | Return VMS condition codes from @code{main}. The default is to return POSIX-style |
32138 | condition (e.g.@: error) codes. | |
32139 | ||
d77de738 | 32140 | @opindex mdebug-main=@var{prefix} |
ddf6fe37 | 32141 | @item -mdebug-main=@var{prefix} |
d77de738 ML |
32142 | Flag the first routine whose name starts with @var{prefix} as the main |
32143 | routine for the debugger. | |
32144 | ||
d77de738 | 32145 | @opindex mmalloc64 |
ddf6fe37 | 32146 | @item -mmalloc64 |
d77de738 ML |
32147 | Default to 64-bit memory allocation routines. |
32148 | ||
d77de738 | 32149 | @opindex mpointer-size=@var{size} |
ddf6fe37 | 32150 | @item -mpointer-size=@var{size} |
d77de738 ML |
32151 | Set the default size of pointers. Possible options for @var{size} are |
32152 | @samp{32} or @samp{short} for 32 bit pointers, @samp{64} or @samp{long} | |
32153 | for 64 bit pointers, and @samp{no} for supporting only 32 bit pointers. | |
32154 | The later option disables @code{pragma pointer_size}. | |
32155 | @end table | |
32156 | ||
32157 | @node VxWorks Options | |
32158 | @subsection VxWorks Options | |
32159 | @cindex VxWorks Options | |
32160 | ||
32161 | The options in this section are defined for all VxWorks targets. | |
32162 | Options specific to the target hardware are listed with the other | |
32163 | options for that target. | |
32164 | ||
32165 | @table @gcctabopt | |
d77de738 | 32166 | @opindex mrtp |
ddf6fe37 | 32167 | @item -mrtp |
d77de738 ML |
32168 | GCC can generate code for both VxWorks kernels and real time processes |
32169 | (RTPs). This option switches from the former to the latter. It also | |
32170 | defines the preprocessor macro @code{__RTP__}. | |
32171 | ||
d77de738 | 32172 | @opindex non-static |
ddf6fe37 | 32173 | @item -non-static |
d77de738 ML |
32174 | Link an RTP executable against shared libraries rather than static |
32175 | libraries. The options @option{-static} and @option{-shared} can | |
32176 | also be used for RTPs (@pxref{Link Options}); @option{-static} | |
32177 | is the default. | |
32178 | ||
d77de738 ML |
32179 | @opindex Bstatic |
32180 | @opindex Bdynamic | |
ddf6fe37 AA |
32181 | @item -Bstatic |
32182 | @itemx -Bdynamic | |
d77de738 ML |
32183 | These options are passed down to the linker. They are defined for |
32184 | compatibility with Diab. | |
32185 | ||
d77de738 | 32186 | @opindex Xbind-lazy |
ddf6fe37 | 32187 | @item -Xbind-lazy |
d77de738 ML |
32188 | Enable lazy binding of function calls. This option is equivalent to |
32189 | @option{-Wl,-z,now} and is defined for compatibility with Diab. | |
32190 | ||
d77de738 | 32191 | @opindex Xbind-now |
ddf6fe37 | 32192 | @item -Xbind-now |
d77de738 ML |
32193 | Disable lazy binding of function calls. This option is the default and |
32194 | is defined for compatibility with Diab. | |
32195 | @end table | |
32196 | ||
32197 | @node x86 Options | |
32198 | @subsection x86 Options | |
32199 | @cindex x86 Options | |
32200 | ||
32201 | These @samp{-m} options are defined for the x86 family of computers. | |
32202 | ||
32203 | @table @gcctabopt | |
32204 | ||
d77de738 | 32205 | @opindex march |
ddf6fe37 | 32206 | @item -march=@var{cpu-type} |
d77de738 ML |
32207 | Generate instructions for the machine type @var{cpu-type}. In contrast to |
32208 | @option{-mtune=@var{cpu-type}}, which merely tunes the generated code | |
32209 | for the specified @var{cpu-type}, @option{-march=@var{cpu-type}} allows GCC | |
32210 | to generate code that may not run at all on processors other than the one | |
32211 | indicated. Specifying @option{-march=@var{cpu-type}} implies | |
32212 | @option{-mtune=@var{cpu-type}}, except where noted otherwise. | |
32213 | ||
32214 | The choices for @var{cpu-type} are: | |
32215 | ||
32216 | @table @samp | |
32217 | @item native | |
32218 | This selects the CPU to generate code for at compilation time by determining | |
32219 | the processor type of the compiling machine. Using @option{-march=native} | |
32220 | enables all instruction subsets supported by the local machine (hence | |
32221 | the result might not run on different machines). Using @option{-mtune=native} | |
32222 | produces code optimized for the local machine under the constraints | |
32223 | of the selected instruction set. | |
32224 | ||
32225 | @item x86-64 | |
32226 | A generic CPU with 64-bit extensions. | |
32227 | ||
32228 | @item x86-64-v2 | |
32229 | @itemx x86-64-v3 | |
32230 | @itemx x86-64-v4 | |
32231 | These choices for @var{cpu-type} select the corresponding | |
32232 | micro-architecture level from the x86-64 psABI. On ABIs other than | |
32233 | the x86-64 psABI they select the same CPU features as the x86-64 psABI | |
32234 | documents for the particular micro-architecture level. | |
32235 | ||
32236 | Since these @var{cpu-type} values do not have a corresponding | |
32237 | @option{-mtune} setting, using @option{-march} with these values enables | |
32238 | generic tuning. Specific tuning can be enabled using the | |
32239 | @option{-mtune=@var{other-cpu-type}} option with an appropriate | |
32240 | @var{other-cpu-type} value. | |
32241 | ||
32242 | @item i386 | |
32243 | Original Intel i386 CPU@. | |
32244 | ||
32245 | @item i486 | |
32246 | Intel i486 CPU@. (No scheduling is implemented for this chip.) | |
32247 | ||
32248 | @item i586 | |
32249 | @itemx pentium | |
32250 | Intel Pentium CPU with no MMX support. | |
32251 | ||
32252 | @item lakemont | |
32253 | Intel Lakemont MCU, based on Intel Pentium CPU. | |
32254 | ||
32255 | @item pentium-mmx | |
32256 | Intel Pentium MMX CPU, based on Pentium core with MMX instruction set support. | |
32257 | ||
32258 | @item pentiumpro | |
32259 | Intel Pentium Pro CPU@. | |
32260 | ||
32261 | @item i686 | |
32262 | When used with @option{-march}, the Pentium Pro | |
32263 | instruction set is used, so the code runs on all i686 family chips. | |
32264 | When used with @option{-mtune}, it has the same meaning as @samp{generic}. | |
32265 | ||
32266 | @item pentium2 | |
32267 | Intel Pentium II CPU, based on Pentium Pro core with MMX and FXSR instruction | |
32268 | set support. | |
32269 | ||
32270 | @item pentium3 | |
32271 | @itemx pentium3m | |
32272 | Intel Pentium III CPU, based on Pentium Pro core with MMX, FXSR and SSE | |
32273 | instruction set support. | |
32274 | ||
32275 | @item pentium-m | |
32276 | Intel Pentium M; low-power version of Intel Pentium III CPU | |
32277 | with MMX, SSE, SSE2 and FXSR instruction set support. Used by Centrino | |
32278 | notebooks. | |
32279 | ||
32280 | @item pentium4 | |
32281 | @itemx pentium4m | |
32282 | Intel Pentium 4 CPU with MMX, SSE, SSE2 and FXSR instruction set support. | |
32283 | ||
32284 | @item prescott | |
32285 | Improved version of Intel Pentium 4 CPU with MMX, SSE, SSE2, SSE3 and FXSR | |
32286 | instruction set support. | |
32287 | ||
32288 | @item nocona | |
32289 | Improved version of Intel Pentium 4 CPU with 64-bit extensions, MMX, SSE, | |
32290 | SSE2, SSE3 and FXSR instruction set support. | |
32291 | ||
32292 | @item core2 | |
32293 | Intel Core 2 CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, CX16, | |
32294 | SAHF and FXSR instruction set support. | |
32295 | ||
32296 | @item nehalem | |
32297 | Intel Nehalem CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
32298 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF and FXSR instruction set support. | |
32299 | ||
32300 | @item westmere | |
32301 | Intel Westmere CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
32302 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR and PCLMUL instruction set support. | |
32303 | ||
32304 | @item sandybridge | |
32305 | Intel Sandy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
32306 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE and PCLMUL instruction set | |
32307 | support. | |
32308 | ||
32309 | @item ivybridge | |
32310 | Intel Ivy Bridge CPU with 64-bit extensions, MMX, SSE, SSE2, SSE3, SSSE3, | |
32311 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND | |
32312 | and F16C instruction set support. | |
32313 | ||
32314 | @item haswell | |
32315 | Intel Haswell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32316 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32317 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE and HLE instruction set support. | |
32318 | ||
32319 | @item broadwell | |
32320 | Intel Broadwell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32321 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32322 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX and PREFETCHW | |
32323 | instruction set support. | |
32324 | ||
32325 | @item skylake | |
32326 | Intel Skylake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32327 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32328 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
32329 | CLFLUSHOPT, XSAVEC, XSAVES and SGX instruction set support. | |
32330 | ||
32331 | @item bonnell | |
32332 | Intel Bonnell CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3 and SSSE3 | |
32333 | instruction set support. | |
32334 | ||
32335 | @item silvermont | |
32336 | Intel Silvermont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32337 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW and RDRND | |
32338 | instruction set support. | |
32339 | ||
32340 | @item goldmont | |
32341 | Intel Goldmont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32342 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA, | |
32343 | RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT and FSGSBASE instruction | |
32344 | set support. | |
32345 | ||
32346 | @item goldmont-plus | |
32347 | Intel Goldmont Plus CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32348 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, | |
32349 | SHA, RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, | |
32350 | RDPID and SGX instruction set support. | |
32351 | ||
32352 | @item tremont | |
32353 | Intel Tremont CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32354 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, PCLMUL, PREFETCHW, RDRND, AES, SHA, | |
32355 | RDSEED, XSAVE, XSAVEC, XSAVES, XSAVEOPT, CLFLUSHOPT, FSGSBASE, PTWRITE, RDPID, | |
32356 | SGX, CLWB, GFNI-SSE, MOVDIRI, MOVDIR64B, CLDEMOTE and WAITPKG instruction set | |
32357 | support. | |
32358 | ||
32359 | @item sierraforest | |
32360 | Intel Sierra Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32361 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
32362 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
32363 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
32364 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
32365 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set support. | |
32366 | ||
32367 | @item grandridge | |
32368 | Intel Grand Ridge CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32369 | SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, | |
32370 | XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, | |
32371 | MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, | |
32372 | PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, | |
32373 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD and RAOINT instruction set | |
32374 | support. | |
32375 | ||
32376 | @item knl | |
32377 | Intel Knight's Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32378 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32379 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32380 | AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1 instruction set support. | |
32381 | ||
32382 | @item knm | |
32383 | Intel Knights Mill CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32384 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32385 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32386 | AVX512PF, AVX512ER, AVX512F, AVX512CD and PREFETCHWT1, AVX5124VNNIW, | |
32387 | AVX5124FMAPS and AVX512VPOPCNTDQ instruction set support. | |
32388 | ||
32389 | @item skylake-avx512 | |
32390 | Intel Skylake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32391 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32392 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32393 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, | |
32394 | AVX512DQ and AVX512CD instruction set support. | |
32395 | ||
32396 | @item cannonlake | |
32397 | Intel Cannonlake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, | |
32398 | SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, | |
32399 | FSGSBASE, RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, | |
32400 | PREFETCHW, AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, | |
32401 | AVX512DQ, AVX512CD, PKU, AVX512VBMI, AVX512IFMA and SHA instruction set | |
32402 | support. | |
32403 | ||
32404 | @item icelake-client | |
32405 | Intel Icelake Client CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32406 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32407 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32408 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
32409 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2 | |
32410 | , VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support. | |
32411 | ||
32412 | @item icelake-server | |
32413 | Intel Icelake Server CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32414 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32415 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32416 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
32417 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2 | |
32418 | , VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD and CLWB | |
32419 | instruction set support. | |
32420 | ||
32421 | @item cascadelake | |
32422 | Intel Cascadelake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32423 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32424 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
32425 | CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ, | |
32426 | AVX512CD and AVX512VNNI instruction set support. | |
32427 | ||
32428 | @item cooperlake | |
32429 | Intel cooperlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32430 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32431 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
32432 | CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, CLWB, AVX512VL, AVX512BW, AVX512DQ, | |
32433 | AVX512CD, AVX512VNNI and AVX512BF16 instruction set support. | |
32434 | ||
32435 | @item tigerlake | |
32436 | Intel Tigerlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32437 | SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32438 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
32439 | CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD | |
32440 | PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
32441 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, MOVDIRI, MOVDIR64B, CLWB, | |
32442 | AVX512VP2INTERSECT and KEYLOCKER instruction set support. | |
32443 | ||
32444 | @item sapphirerapids | |
32445 | Intel sapphirerapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32446 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32447 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32448 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
32449 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
32450 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB, | |
32451 | MOVDIRI, MOVDIR64B, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, TSXLDTRK, | |
29ecb952 | 32452 | UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16 and AVX512BF16 |
d77de738 ML |
32453 | instruction set support. |
32454 | ||
32455 | @item alderlake | |
32456 | Intel Alderlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, | |
32457 | SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES, | |
32458 | XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B, | |
32459 | CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU, | |
32460 | VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and AVX-VNNI instruction set | |
32461 | support. | |
32462 | ||
32463 | @item rocketlake | |
32464 | Intel Rocketlake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3 | |
32465 | , SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, RDRND, | |
32466 | F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, AES, | |
32467 | CLFLUSHOPT, XSAVEC, XSAVES, AVX512F, AVX512VL, AVX512BW, AVX512DQ, AVX512CD | |
32468 | PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
32469 | VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support. | |
32470 | ||
32471 | @item graniterapids | |
32472 | Intel graniterapids CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3, | |
32473 | SSSE3, SSE4.1, SSE4.2, POPCNT, CX16, SAHF, FXSR, AVX, XSAVE, PCLMUL, FSGSBASE, | |
32474 | RDRND, F16C, AVX2, BMI, BMI2, LZCNT, FMA, MOVBE, HLE, RDSEED, ADCX, PREFETCHW, | |
32475 | AES, CLFLUSHOPT, XSAVEC, XSAVES, SGX, AVX512F, AVX512VL, AVX512BW, AVX512DQ, | |
32476 | AVX512CD, PKU, AVX512VBMI, AVX512IFMA, SHA, AVX512VNNI, GFNI, VAES, AVX512VBMI2, | |
32477 | VPCLMULQDQ, AVX512BITALG, RDPID, AVX512VPOPCNTDQ, PCONFIG, WBNOINVD, CLWB, | |
32478 | MOVDIRI, MOVDIR64B, AVX512VP2INTERSECT, ENQCMD, CLDEMOTE, PTWRITE, WAITPKG, | |
29ecb952 | 32479 | SERIALIZE, TSXLDTRK, UINTR, AMX-BF16, AMX-TILE, AMX-INT8, AVX-VNNI, AVX512-FP16, |
d77de738 ML |
32480 | AVX512BF16, AMX-FP16 and PREFETCHI instruction set support. |
32481 | ||
32482 | @item k6 | |
32483 | AMD K6 CPU with MMX instruction set support. | |
32484 | ||
32485 | @item k6-2 | |
32486 | @itemx k6-3 | |
32487 | Improved versions of AMD K6 CPU with MMX and 3DNow!@: instruction set support. | |
32488 | ||
32489 | @item athlon | |
32490 | @itemx athlon-tbird | |
32491 | AMD Athlon CPU with MMX, 3dNOW!, enhanced 3DNow!@: and SSE prefetch instructions | |
32492 | support. | |
32493 | ||
32494 | @item athlon-4 | |
32495 | @itemx athlon-xp | |
32496 | @itemx athlon-mp | |
32497 | Improved AMD Athlon CPU with MMX, 3DNow!, enhanced 3DNow!@: and full SSE | |
32498 | instruction set support. | |
32499 | ||
32500 | @item k8 | |
32501 | @itemx opteron | |
32502 | @itemx athlon64 | |
32503 | @itemx athlon-fx | |
32504 | Processors based on the AMD K8 core with x86-64 instruction set support, | |
32505 | including the AMD Opteron, Athlon 64, and Athlon 64 FX processors. | |
32506 | (This supersets MMX, SSE, SSE2, 3DNow!, enhanced 3DNow!@: and 64-bit | |
32507 | instruction set extensions.) | |
32508 | ||
32509 | @item k8-sse3 | |
32510 | @itemx opteron-sse3 | |
32511 | @itemx athlon64-sse3 | |
32512 | Improved versions of AMD K8 cores with SSE3 instruction set support. | |
32513 | ||
32514 | @item amdfam10 | |
32515 | @itemx barcelona | |
32516 | CPUs based on AMD Family 10h cores with x86-64 instruction set support. (This | |
32517 | supersets MMX, SSE, SSE2, SSE3, SSE4A, 3DNow!, enhanced 3DNow!, ABM and 64-bit | |
32518 | instruction set extensions.) | |
32519 | ||
32520 | @item bdver1 | |
32521 | CPUs based on AMD Family 15h cores with x86-64 instruction set support. (This | |
32522 | supersets FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, | |
32523 | SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set extensions.) | |
32524 | ||
32525 | @item bdver2 | |
32526 | AMD Family 15h core based CPUs with x86-64 instruction set support. (This | |
32527 | supersets BMI, TBM, F16C, FMA, FMA4, AVX, XOP, LWP, AES, PCLMUL, CX16, MMX, | |
32528 | SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and 64-bit instruction set | |
32529 | extensions.) | |
32530 | ||
32531 | @item bdver3 | |
32532 | AMD Family 15h core based CPUs with x86-64 instruction set support. (This | |
32533 | supersets BMI, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, XOP, LWP, AES, | |
32534 | PCLMUL, CX16, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, SSE4.2, ABM and | |
32535 | 64-bit instruction set extensions.) | |
32536 | ||
32537 | @item bdver4 | |
32538 | AMD Family 15h core based CPUs with x86-64 instruction set support. (This | |
32539 | supersets BMI, BMI2, TBM, F16C, FMA, FMA4, FSGSBASE, AVX, AVX2, XOP, LWP, | |
32540 | AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, SSE4.1, | |
32541 | SSE4.2, ABM and 64-bit instruction set extensions.) | |
32542 | ||
32543 | @item znver1 | |
32544 | AMD Family 17h core based CPUs with x86-64 instruction set support. (This | |
32545 | supersets BMI, BMI2, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, MWAITX, | |
32546 | SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, SSSE3, | |
32547 | SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, and 64-bit | |
32548 | instruction set extensions.) | |
32549 | ||
32550 | @item znver2 | |
32551 | AMD Family 17h core based CPUs with x86-64 instruction set support. (This | |
32552 | supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, | |
32553 | MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, | |
32554 | SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, | |
32555 | WBNOINVD, and 64-bit instruction set extensions.) | |
32556 | ||
32557 | @item znver3 | |
32558 | AMD Family 19h core based CPUs with x86-64 instruction set support. (This | |
32559 | supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, | |
32560 | MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, | |
32561 | SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, | |
32562 | WBNOINVD, PKU, VPCLMULQDQ, VAES, and 64-bit instruction set extensions.) | |
32563 | ||
32564 | @item znver4 | |
32565 | AMD Family 19h core based CPUs with x86-64 instruction set support. (This | |
32566 | supersets BMI, BMI2, CLWB, F16C, FMA, FSGSBASE, AVX, AVX2, ADCX, RDSEED, | |
32567 | MWAITX, SHA, CLZERO, AES, PCLMUL, CX16, MOVBE, MMX, SSE, SSE2, SSE3, SSE4A, | |
32568 | SSSE3, SSE4.1, SSE4.2, ABM, XSAVEC, XSAVES, CLFLUSHOPT, POPCNT, RDPID, | |
32569 | WBNOINVD, PKU, VPCLMULQDQ, VAES, AVX512F, AVX512DQ, AVX512IFMA, AVX512CD, | |
32570 | AVX512BW, AVX512VL, AVX512BF16, AVX512VBMI, AVX512VBMI2, AVX512VNNI, | |
32571 | AVX512BITALG, AVX512VPOPCNTDQ, GFNI and 64-bit instruction set extensions.) | |
32572 | ||
32573 | @item btver1 | |
32574 | CPUs based on AMD Family 14h cores with x86-64 instruction set support. (This | |
32575 | supersets MMX, SSE, SSE2, SSE3, SSSE3, SSE4A, CX16, ABM and 64-bit | |
32576 | instruction set extensions.) | |
32577 | ||
32578 | @item btver2 | |
32579 | CPUs based on AMD Family 16h cores with x86-64 instruction set support. This | |
32580 | includes MOVBE, F16C, BMI, AVX, PCLMUL, AES, SSE4.2, SSE4.1, CX16, ABM, | |
32581 | SSE4A, SSSE3, SSE3, SSE2, SSE, MMX and 64-bit instruction set extensions. | |
32582 | ||
32583 | @item winchip-c6 | |
32584 | IDT WinChip C6 CPU, dealt in same way as i486 with additional MMX instruction | |
32585 | set support. | |
32586 | ||
32587 | @item winchip2 | |
32588 | IDT WinChip 2 CPU, dealt in same way as i486 with additional MMX and 3DNow!@: | |
32589 | instruction set support. | |
32590 | ||
32591 | @item c3 | |
32592 | VIA C3 CPU with MMX and 3DNow!@: instruction set support. | |
32593 | (No scheduling is implemented for this chip.) | |
32594 | ||
32595 | @item c3-2 | |
32596 | VIA C3-2 (Nehemiah/C5XL) CPU with MMX and SSE instruction set support. | |
32597 | (No scheduling is implemented for this chip.) | |
32598 | ||
32599 | @item c7 | |
32600 | VIA C7 (Esther) CPU with MMX, SSE, SSE2 and SSE3 instruction set support. | |
32601 | (No scheduling is implemented for this chip.) | |
32602 | ||
32603 | @item samuel-2 | |
32604 | VIA Eden Samuel 2 CPU with MMX and 3DNow!@: instruction set support. | |
32605 | (No scheduling is implemented for this chip.) | |
32606 | ||
32607 | @item nehemiah | |
32608 | VIA Eden Nehemiah CPU with MMX and SSE instruction set support. | |
32609 | (No scheduling is implemented for this chip.) | |
32610 | ||
32611 | @item esther | |
32612 | VIA Eden Esther CPU with MMX, SSE, SSE2 and SSE3 instruction set support. | |
32613 | (No scheduling is implemented for this chip.) | |
32614 | ||
32615 | @item eden-x2 | |
32616 | VIA Eden X2 CPU with x86-64, MMX, SSE, SSE2 and SSE3 instruction set support. | |
32617 | (No scheduling is implemented for this chip.) | |
32618 | ||
32619 | @item eden-x4 | |
32620 | VIA Eden X4 CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, | |
32621 | AVX and AVX2 instruction set support. | |
32622 | (No scheduling is implemented for this chip.) | |
32623 | ||
32624 | @item nano | |
32625 | Generic VIA Nano CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 | |
32626 | instruction set support. | |
32627 | (No scheduling is implemented for this chip.) | |
32628 | ||
32629 | @item nano-1000 | |
32630 | VIA Nano 1xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 | |
32631 | instruction set support. | |
32632 | (No scheduling is implemented for this chip.) | |
32633 | ||
32634 | @item nano-2000 | |
32635 | VIA Nano 2xxx CPU with x86-64, MMX, SSE, SSE2, SSE3 and SSSE3 | |
32636 | instruction set support. | |
32637 | (No scheduling is implemented for this chip.) | |
32638 | ||
32639 | @item nano-3000 | |
32640 | VIA Nano 3xxx CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 | |
32641 | instruction set support. | |
32642 | (No scheduling is implemented for this chip.) | |
32643 | ||
32644 | @item nano-x2 | |
32645 | VIA Nano Dual Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 | |
32646 | instruction set support. | |
32647 | (No scheduling is implemented for this chip.) | |
32648 | ||
32649 | @item nano-x4 | |
32650 | VIA Nano Quad Core CPU with x86-64, MMX, SSE, SSE2, SSE3, SSSE3 and SSE4.1 | |
32651 | instruction set support. | |
32652 | (No scheduling is implemented for this chip.) | |
32653 | ||
32654 | @item lujiazui | |
32655 | ZHAOXIN lujiazui CPU with x86-64, MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, | |
32656 | SSE4.2, AVX, POPCNT, AES, PCLMUL, RDRND, XSAVE, XSAVEOPT, FSGSBASE, CX16, | |
32657 | ABM, BMI, BMI2, F16C, FXSR, RDSEED instruction set support. | |
32658 | ||
32659 | @item geode | |
32660 | AMD Geode embedded processor with MMX and 3DNow!@: instruction set support. | |
32661 | @end table | |
32662 | ||
d77de738 | 32663 | @opindex mtune |
ddf6fe37 | 32664 | @item -mtune=@var{cpu-type} |
d77de738 ML |
32665 | Tune to @var{cpu-type} everything applicable about the generated code, except |
32666 | for the ABI and the set of available instructions. | |
32667 | While picking a specific @var{cpu-type} schedules things appropriately | |
32668 | for that particular chip, the compiler does not generate any code that | |
32669 | cannot run on the default machine type unless you use a | |
32670 | @option{-march=@var{cpu-type}} option. | |
32671 | For example, if GCC is configured for i686-pc-linux-gnu | |
32672 | then @option{-mtune=pentium4} generates code that is tuned for Pentium 4 | |
32673 | but still runs on i686 machines. | |
32674 | ||
32675 | The choices for @var{cpu-type} are the same as for @option{-march}. | |
32676 | In addition, @option{-mtune} supports 2 extra choices for @var{cpu-type}: | |
32677 | ||
32678 | @table @samp | |
32679 | @item generic | |
32680 | Produce code optimized for the most common IA32/@/AMD64/@/EM64T processors. | |
32681 | If you know the CPU on which your code will run, then you should use | |
32682 | the corresponding @option{-mtune} or @option{-march} option instead of | |
32683 | @option{-mtune=generic}. But, if you do not know exactly what CPU users | |
32684 | of your application will have, then you should use this option. | |
32685 | ||
32686 | As new processors are deployed in the marketplace, the behavior of this | |
32687 | option will change. Therefore, if you upgrade to a newer version of | |
32688 | GCC, code generation controlled by this option will change to reflect | |
32689 | the processors | |
32690 | that are most common at the time that version of GCC is released. | |
32691 | ||
32692 | There is no @option{-march=generic} option because @option{-march} | |
32693 | indicates the instruction set the compiler can use, and there is no | |
32694 | generic instruction set applicable to all processors. In contrast, | |
32695 | @option{-mtune} indicates the processor (or, in this case, collection of | |
32696 | processors) for which the code is optimized. | |
32697 | ||
32698 | @item intel | |
32699 | Produce code optimized for the most current Intel processors, which are | |
32700 | Haswell and Silvermont for this version of GCC. If you know the CPU | |
32701 | on which your code will run, then you should use the corresponding | |
32702 | @option{-mtune} or @option{-march} option instead of @option{-mtune=intel}. | |
32703 | But, if you want your application performs better on both Haswell and | |
32704 | Silvermont, then you should use this option. | |
32705 | ||
32706 | As new Intel processors are deployed in the marketplace, the behavior of | |
32707 | this option will change. Therefore, if you upgrade to a newer version of | |
32708 | GCC, code generation controlled by this option will change to reflect | |
32709 | the most current Intel processors at the time that version of GCC is | |
32710 | released. | |
32711 | ||
32712 | There is no @option{-march=intel} option because @option{-march} indicates | |
32713 | the instruction set the compiler can use, and there is no common | |
32714 | instruction set applicable to all processors. In contrast, | |
32715 | @option{-mtune} indicates the processor (or, in this case, collection of | |
32716 | processors) for which the code is optimized. | |
32717 | @end table | |
32718 | ||
d77de738 | 32719 | @opindex mcpu |
ddf6fe37 | 32720 | @item -mcpu=@var{cpu-type} |
d77de738 ML |
32721 | A deprecated synonym for @option{-mtune}. |
32722 | ||
d77de738 | 32723 | @opindex mfpmath |
ddf6fe37 | 32724 | @item -mfpmath=@var{unit} |
d77de738 ML |
32725 | Generate floating-point arithmetic for selected unit @var{unit}. The choices |
32726 | for @var{unit} are: | |
32727 | ||
32728 | @table @samp | |
32729 | @item 387 | |
32730 | Use the standard 387 floating-point coprocessor present on the majority of chips and | |
32731 | emulated otherwise. Code compiled with this option runs almost everywhere. | |
32732 | The temporary results are computed in 80-bit precision instead of the precision | |
32733 | specified by the type, resulting in slightly different results compared to most | |
32734 | of other chips. See @option{-ffloat-store} for more detailed description. | |
32735 | ||
32736 | This is the default choice for non-Darwin x86-32 targets. | |
32737 | ||
32738 | @item sse | |
32739 | Use scalar floating-point instructions present in the SSE instruction set. | |
32740 | This instruction set is supported by Pentium III and newer chips, | |
32741 | and in the AMD line | |
32742 | by Athlon-4, Athlon XP and Athlon MP chips. The earlier version of the SSE | |
32743 | instruction set supports only single-precision arithmetic, thus the double and | |
32744 | extended-precision arithmetic are still done using 387. A later version, present | |
32745 | only in Pentium 4 and AMD x86-64 chips, supports double-precision | |
32746 | arithmetic too. | |
32747 | ||
32748 | For the x86-32 compiler, you must use @option{-march=@var{cpu-type}}, @option{-msse} | |
32749 | or @option{-msse2} switches to enable SSE extensions and make this option | |
32750 | effective. For the x86-64 compiler, these extensions are enabled by default. | |
32751 | ||
32752 | The resulting code should be considerably faster in the majority of cases and avoid | |
32753 | the numerical instability problems of 387 code, but may break some existing | |
32754 | code that expects temporaries to be 80 bits. | |
32755 | ||
32756 | This is the default choice for the x86-64 compiler, Darwin x86-32 targets, | |
32757 | and the default choice for x86-32 targets with the SSE2 instruction set | |
32758 | when @option{-ffast-math} is enabled. | |
32759 | ||
32760 | @item sse,387 | |
32761 | @itemx sse+387 | |
32762 | @itemx both | |
32763 | Attempt to utilize both instruction sets at once. This effectively doubles the | |
32764 | amount of available registers, and on chips with separate execution units for | |
32765 | 387 and SSE the execution resources too. Use this option with care, as it is | |
32766 | still experimental, because the GCC register allocator does not model separate | |
32767 | functional units well, resulting in unstable performance. | |
32768 | @end table | |
32769 | ||
d77de738 | 32770 | @opindex masm=@var{dialect} |
ddf6fe37 | 32771 | @item -masm=@var{dialect} |
d77de738 ML |
32772 | Output assembly instructions using selected @var{dialect}. Also affects |
32773 | which dialect is used for basic @code{asm} (@pxref{Basic Asm}) and | |
32774 | extended @code{asm} (@pxref{Extended Asm}). Supported choices (in dialect | |
32775 | order) are @samp{att} or @samp{intel}. The default is @samp{att}. Darwin does | |
32776 | not support @samp{intel}. | |
32777 | ||
d77de738 ML |
32778 | @opindex mieee-fp |
32779 | @opindex mno-ieee-fp | |
ddf6fe37 AA |
32780 | @item -mieee-fp |
32781 | @itemx -mno-ieee-fp | |
d77de738 ML |
32782 | Control whether or not the compiler uses IEEE floating-point |
32783 | comparisons. These correctly handle the case where the result of a | |
32784 | comparison is unordered. | |
32785 | ||
30348d30 | 32786 | @opindex m80387 |
d77de738 | 32787 | @opindex mhard-float |
ddf6fe37 AA |
32788 | @item -m80387 |
32789 | @itemx -mhard-float | |
d77de738 ML |
32790 | Generate output containing 80387 instructions for floating point. |
32791 | ||
d77de738 ML |
32792 | @opindex no-80387 |
32793 | @opindex msoft-float | |
ddf6fe37 AA |
32794 | @item -mno-80387 |
32795 | @itemx -msoft-float | |
d77de738 ML |
32796 | Generate output containing library calls for floating point. |
32797 | ||
32798 | @strong{Warning:} the requisite libraries are not part of GCC@. | |
32799 | Normally the facilities of the machine's usual C compiler are used, but | |
32800 | this cannot be done directly in cross-compilation. You must make your | |
32801 | own arrangements to provide suitable library functions for | |
32802 | cross-compilation. | |
32803 | ||
32804 | On machines where a function returns floating-point results in the 80387 | |
32805 | register stack, some floating-point opcodes may be emitted even if | |
32806 | @option{-msoft-float} is used. | |
32807 | ||
d77de738 ML |
32808 | @opindex mno-fp-ret-in-387 |
32809 | @opindex mfp-ret-in-387 | |
ddf6fe37 | 32810 | @item -mno-fp-ret-in-387 |
d77de738 ML |
32811 | Do not use the FPU registers for return values of functions. |
32812 | ||
32813 | The usual calling convention has functions return values of types | |
32814 | @code{float} and @code{double} in an FPU register, even if there | |
32815 | is no FPU@. The idea is that the operating system should emulate | |
32816 | an FPU@. | |
32817 | ||
32818 | The option @option{-mno-fp-ret-in-387} causes such values to be returned | |
32819 | in ordinary CPU registers instead. | |
32820 | ||
d77de738 ML |
32821 | @opindex mno-fancy-math-387 |
32822 | @opindex mfancy-math-387 | |
ddf6fe37 | 32823 | @item -mno-fancy-math-387 |
d77de738 ML |
32824 | Some 387 emulators do not support the @code{sin}, @code{cos} and |
32825 | @code{sqrt} instructions for the 387. Specify this option to avoid | |
32826 | generating those instructions. | |
32827 | This option is overridden when @option{-march} | |
32828 | indicates that the target CPU always has an FPU and so the | |
32829 | instruction does not need emulation. These | |
32830 | instructions are not generated unless you also use the | |
32831 | @option{-funsafe-math-optimizations} switch. | |
32832 | ||
d77de738 ML |
32833 | @opindex malign-double |
32834 | @opindex mno-align-double | |
ddf6fe37 AA |
32835 | @item -malign-double |
32836 | @itemx -mno-align-double | |
d77de738 ML |
32837 | Control whether GCC aligns @code{double}, @code{long double}, and |
32838 | @code{long long} variables on a two-word boundary or a one-word | |
32839 | boundary. Aligning @code{double} variables on a two-word boundary | |
32840 | produces code that runs somewhat faster on a Pentium at the | |
32841 | expense of more memory. | |
32842 | ||
32843 | On x86-64, @option{-malign-double} is enabled by default. | |
32844 | ||
32845 | @strong{Warning:} if you use the @option{-malign-double} switch, | |
32846 | structures containing the above types are aligned differently than | |
32847 | the published application binary interface specifications for the x86-32 | |
32848 | and are not binary compatible with structures in code compiled | |
32849 | without that switch. | |
32850 | ||
d77de738 ML |
32851 | @opindex m96bit-long-double |
32852 | @opindex m128bit-long-double | |
ddf6fe37 AA |
32853 | @item -m96bit-long-double |
32854 | @itemx -m128bit-long-double | |
d77de738 ML |
32855 | These switches control the size of @code{long double} type. The x86-32 |
32856 | application binary interface specifies the size to be 96 bits, | |
32857 | so @option{-m96bit-long-double} is the default in 32-bit mode. | |
32858 | ||
32859 | Modern architectures (Pentium and newer) prefer @code{long double} | |
32860 | to be aligned to an 8- or 16-byte boundary. In arrays or structures | |
32861 | conforming to the ABI, this is not possible. So specifying | |
32862 | @option{-m128bit-long-double} aligns @code{long double} | |
32863 | to a 16-byte boundary by padding the @code{long double} with an additional | |
32864 | 32-bit zero. | |
32865 | ||
32866 | In the x86-64 compiler, @option{-m128bit-long-double} is the default choice as | |
32867 | its ABI specifies that @code{long double} is aligned on 16-byte boundary. | |
32868 | ||
32869 | Notice that neither of these options enable any extra precision over the x87 | |
32870 | standard of 80 bits for a @code{long double}. | |
32871 | ||
32872 | @strong{Warning:} if you override the default value for your target ABI, this | |
32873 | changes the size of | |
32874 | structures and arrays containing @code{long double} variables, | |
32875 | as well as modifying the function calling convention for functions taking | |
32876 | @code{long double}. Hence they are not binary-compatible | |
32877 | with code compiled without that switch. | |
32878 | ||
d77de738 ML |
32879 | @opindex mlong-double-64 |
32880 | @opindex mlong-double-80 | |
32881 | @opindex mlong-double-128 | |
ddf6fe37 AA |
32882 | @item -mlong-double-64 |
32883 | @itemx -mlong-double-80 | |
32884 | @itemx -mlong-double-128 | |
d77de738 ML |
32885 | These switches control the size of @code{long double} type. A size |
32886 | of 64 bits makes the @code{long double} type equivalent to the @code{double} | |
32887 | type. This is the default for 32-bit Bionic C library. A size | |
32888 | of 128 bits makes the @code{long double} type equivalent to the | |
32889 | @code{__float128} type. This is the default for 64-bit Bionic C library. | |
32890 | ||
32891 | @strong{Warning:} if you override the default value for your target ABI, this | |
32892 | changes the size of | |
32893 | structures and arrays containing @code{long double} variables, | |
32894 | as well as modifying the function calling convention for functions taking | |
32895 | @code{long double}. Hence they are not binary-compatible | |
32896 | with code compiled without that switch. | |
32897 | ||
d77de738 | 32898 | @opindex malign-data |
ddf6fe37 | 32899 | @item -malign-data=@var{type} |
d77de738 ML |
32900 | Control how GCC aligns variables. Supported values for @var{type} are |
32901 | @samp{compat} uses increased alignment value compatible uses GCC 4.8 | |
32902 | and earlier, @samp{abi} uses alignment value as specified by the | |
32903 | psABI, and @samp{cacheline} uses increased alignment value to match | |
32904 | the cache line size. @samp{compat} is the default. | |
32905 | ||
d77de738 | 32906 | @opindex mlarge-data-threshold |
ddf6fe37 | 32907 | @item -mlarge-data-threshold=@var{threshold} |
d77de738 ML |
32908 | When @option{-mcmodel=medium} is specified, data objects larger than |
32909 | @var{threshold} are placed in the large data section. This value must be the | |
32910 | same across all objects linked into the binary, and defaults to 65535. | |
32911 | ||
d77de738 | 32912 | @opindex mrtd |
ddf6fe37 | 32913 | @item -mrtd |
d77de738 ML |
32914 | Use a different function-calling convention, in which functions that |
32915 | take a fixed number of arguments return with the @code{ret @var{num}} | |
32916 | instruction, which pops their arguments while returning. This saves one | |
32917 | instruction in the caller since there is no need to pop the arguments | |
32918 | there. | |
32919 | ||
32920 | You can specify that an individual function is called with this calling | |
32921 | sequence with the function attribute @code{stdcall}. You can also | |
32922 | override the @option{-mrtd} option by using the function attribute | |
32923 | @code{cdecl}. @xref{Function Attributes}. | |
32924 | ||
32925 | @strong{Warning:} this calling convention is incompatible with the one | |
32926 | normally used on Unix, so you cannot use it if you need to call | |
32927 | libraries compiled with the Unix compiler. | |
32928 | ||
32929 | Also, you must provide function prototypes for all functions that | |
32930 | take variable numbers of arguments (including @code{printf}); | |
32931 | otherwise incorrect code is generated for calls to those | |
32932 | functions. | |
32933 | ||
32934 | In addition, seriously incorrect code results if you call a | |
32935 | function with too many arguments. (Normally, extra arguments are | |
32936 | harmlessly ignored.) | |
32937 | ||
d77de738 | 32938 | @opindex mregparm |
ddf6fe37 | 32939 | @item -mregparm=@var{num} |
d77de738 ML |
32940 | Control how many registers are used to pass integer arguments. By |
32941 | default, no registers are used to pass arguments, and at most 3 | |
32942 | registers can be used. You can control this behavior for a specific | |
32943 | function by using the function attribute @code{regparm}. | |
32944 | @xref{Function Attributes}. | |
32945 | ||
32946 | @strong{Warning:} if you use this switch, and | |
32947 | @var{num} is nonzero, then you must build all modules with the same | |
32948 | value, including any libraries. This includes the system libraries and | |
32949 | startup modules. | |
32950 | ||
d77de738 | 32951 | @opindex msseregparm |
ddf6fe37 | 32952 | @item -msseregparm |
d77de738 ML |
32953 | Use SSE register passing conventions for float and double arguments |
32954 | and return values. You can control this behavior for a specific | |
32955 | function by using the function attribute @code{sseregparm}. | |
32956 | @xref{Function Attributes}. | |
32957 | ||
32958 | @strong{Warning:} if you use this switch then you must build all | |
32959 | modules with the same value, including any libraries. This includes | |
32960 | the system libraries and startup modules. | |
32961 | ||
d77de738 | 32962 | @opindex mvect8-ret-in-mem |
ddf6fe37 | 32963 | @item -mvect8-ret-in-mem |
d77de738 ML |
32964 | Return 8-byte vectors in memory instead of MMX registers. This is the |
32965 | default on VxWorks to match the ABI of the Sun Studio compilers until | |
32966 | version 12. @emph{Only} use this option if you need to remain | |
32967 | compatible with existing code produced by those previous compiler | |
32968 | versions or older versions of GCC@. | |
32969 | ||
d77de738 ML |
32970 | @opindex mpc32 |
32971 | @opindex mpc64 | |
32972 | @opindex mpc80 | |
ddf6fe37 AA |
32973 | @item -mpc32 |
32974 | @itemx -mpc64 | |
32975 | @itemx -mpc80 | |
d77de738 ML |
32976 | |
32977 | Set 80387 floating-point precision to 32, 64 or 80 bits. When @option{-mpc32} | |
32978 | is specified, the significands of results of floating-point operations are | |
32979 | rounded to 24 bits (single precision); @option{-mpc64} rounds the | |
32980 | significands of results of floating-point operations to 53 bits (double | |
32981 | precision) and @option{-mpc80} rounds the significands of results of | |
32982 | floating-point operations to 64 bits (extended double precision), which is | |
32983 | the default. When this option is used, floating-point operations in higher | |
32984 | precisions are not available to the programmer without setting the FPU | |
32985 | control word explicitly. | |
32986 | ||
32987 | Setting the rounding of floating-point operations to less than the default | |
32988 | 80 bits can speed some programs by 2% or more. Note that some mathematical | |
32989 | libraries assume that extended-precision (80-bit) floating-point operations | |
32990 | are enabled by default; routines in such libraries could suffer significant | |
32991 | loss of accuracy, typically through so-called ``catastrophic cancellation'', | |
32992 | when this option is used to set the precision to less than extended precision. | |
32993 | ||
e54375d8 | 32994 | @opindex mdaz-ftz |
ddf6fe37 | 32995 | @item -mdaz-ftz |
e54375d8 | 32996 | |
32997 | The flush-to-zero (FTZ) and denormals-are-zero (DAZ) flags in the MXCSR register | |
32998 | are used to control floating-point calculations.SSE and AVX instructions | |
32999 | including scalar and vector instructions could benefit from enabling the FTZ | |
33000 | and DAZ flags when @option{-mdaz-ftz} is specified. Don't set FTZ/DAZ flags | |
33001 | when @option{-mno-daz-ftz} or @option{-shared} is specified, @option{-mdaz-ftz} | |
33002 | will set FTZ/DAZ flags even with @option{-shared}. | |
33003 | ||
d77de738 | 33004 | @opindex mstackrealign |
ddf6fe37 | 33005 | @item -mstackrealign |
d77de738 ML |
33006 | Realign the stack at entry. On the x86, the @option{-mstackrealign} |
33007 | option generates an alternate prologue and epilogue that realigns the | |
33008 | run-time stack if necessary. This supports mixing legacy codes that keep | |
33009 | 4-byte stack alignment with modern codes that keep 16-byte stack alignment for | |
33010 | SSE compatibility. See also the attribute @code{force_align_arg_pointer}, | |
33011 | applicable to individual functions. | |
33012 | ||
d77de738 | 33013 | @opindex mpreferred-stack-boundary |
ddf6fe37 | 33014 | @item -mpreferred-stack-boundary=@var{num} |
d77de738 ML |
33015 | Attempt to keep the stack boundary aligned to a 2 raised to @var{num} |
33016 | byte boundary. If @option{-mpreferred-stack-boundary} is not specified, | |
33017 | the default is 4 (16 bytes or 128 bits). | |
33018 | ||
33019 | @strong{Warning:} When generating code for the x86-64 architecture with | |
33020 | SSE extensions disabled, @option{-mpreferred-stack-boundary=3} can be | |
33021 | used to keep the stack boundary aligned to 8 byte boundary. Since | |
33022 | x86-64 ABI require 16 byte stack alignment, this is ABI incompatible and | |
33023 | intended to be used in controlled environment where stack space is | |
33024 | important limitation. This option leads to wrong code when functions | |
33025 | compiled with 16 byte stack alignment (such as functions from a standard | |
33026 | library) are called with misaligned stack. In this case, SSE | |
33027 | instructions may lead to misaligned memory access traps. In addition, | |
33028 | variable arguments are handled incorrectly for 16 byte aligned | |
33029 | objects (including x87 long double and __int128), leading to wrong | |
33030 | results. You must build all modules with | |
33031 | @option{-mpreferred-stack-boundary=3}, including any libraries. This | |
33032 | includes the system libraries and startup modules. | |
33033 | ||
d77de738 | 33034 | @opindex mincoming-stack-boundary |
ddf6fe37 | 33035 | @item -mincoming-stack-boundary=@var{num} |
d77de738 ML |
33036 | Assume the incoming stack is aligned to a 2 raised to @var{num} byte |
33037 | boundary. If @option{-mincoming-stack-boundary} is not specified, | |
33038 | the one specified by @option{-mpreferred-stack-boundary} is used. | |
33039 | ||
33040 | On Pentium and Pentium Pro, @code{double} and @code{long double} values | |
33041 | should be aligned to an 8-byte boundary (see @option{-malign-double}) or | |
33042 | suffer significant run time performance penalties. On Pentium III, the | |
33043 | Streaming SIMD Extension (SSE) data type @code{__m128} may not work | |
33044 | properly if it is not 16-byte aligned. | |
33045 | ||
33046 | To ensure proper alignment of this values on the stack, the stack boundary | |
33047 | must be as aligned as that required by any value stored on the stack. | |
33048 | Further, every function must be generated such that it keeps the stack | |
33049 | aligned. Thus calling a function compiled with a higher preferred | |
33050 | stack boundary from a function compiled with a lower preferred stack | |
33051 | boundary most likely misaligns the stack. It is recommended that | |
33052 | libraries that use callbacks always use the default setting. | |
33053 | ||
33054 | This extra alignment does consume extra stack space, and generally | |
33055 | increases code size. Code that is sensitive to stack space usage, such | |
33056 | as embedded systems and operating system kernels, may want to reduce the | |
33057 | preferred alignment to @option{-mpreferred-stack-boundary=2}. | |
33058 | ||
33059 | @need 200 | |
d77de738 | 33060 | @opindex mmmx |
ddf6fe37 | 33061 | @item -mmmx |
d77de738 | 33062 | @need 200 |
d77de738 | 33063 | @opindex msse |
ddf6fe37 | 33064 | @itemx -msse |
d77de738 | 33065 | @need 200 |
d77de738 | 33066 | @opindex msse2 |
ddf6fe37 | 33067 | @itemx -msse2 |
d77de738 | 33068 | @need 200 |
d77de738 | 33069 | @opindex msse3 |
ddf6fe37 | 33070 | @itemx -msse3 |
d77de738 | 33071 | @need 200 |
d77de738 | 33072 | @opindex mssse3 |
ddf6fe37 | 33073 | @itemx -mssse3 |
d77de738 | 33074 | @need 200 |
d77de738 | 33075 | @opindex msse4 |
ddf6fe37 | 33076 | @itemx -msse4 |
d77de738 | 33077 | @need 200 |
d77de738 | 33078 | @opindex msse4a |
ddf6fe37 | 33079 | @itemx -msse4a |
d77de738 | 33080 | @need 200 |
d77de738 | 33081 | @opindex msse4.1 |
ddf6fe37 | 33082 | @itemx -msse4.1 |
d77de738 | 33083 | @need 200 |
d77de738 | 33084 | @opindex msse4.2 |
ddf6fe37 | 33085 | @itemx -msse4.2 |
d77de738 | 33086 | @need 200 |
d77de738 | 33087 | @opindex mavx |
ddf6fe37 | 33088 | @itemx -mavx |
d77de738 | 33089 | @need 200 |
d77de738 | 33090 | @opindex mavx2 |
ddf6fe37 | 33091 | @itemx -mavx2 |
d77de738 | 33092 | @need 200 |
d77de738 | 33093 | @opindex mavx512f |
ddf6fe37 | 33094 | @itemx -mavx512f |
d77de738 | 33095 | @need 200 |
d77de738 | 33096 | @opindex mavx512pf |
ddf6fe37 | 33097 | @itemx -mavx512pf |
d77de738 | 33098 | @need 200 |
d77de738 | 33099 | @opindex mavx512er |
ddf6fe37 | 33100 | @itemx -mavx512er |
d77de738 | 33101 | @need 200 |
d77de738 | 33102 | @opindex mavx512cd |
ddf6fe37 | 33103 | @itemx -mavx512cd |
d77de738 | 33104 | @need 200 |
d77de738 | 33105 | @opindex mavx512vl |
ddf6fe37 | 33106 | @itemx -mavx512vl |
d77de738 | 33107 | @need 200 |
d77de738 | 33108 | @opindex mavx512bw |
ddf6fe37 | 33109 | @itemx -mavx512bw |
d77de738 | 33110 | @need 200 |
d77de738 | 33111 | @opindex mavx512dq |
ddf6fe37 | 33112 | @itemx -mavx512dq |
d77de738 | 33113 | @need 200 |
d77de738 | 33114 | @opindex mavx512ifma |
ddf6fe37 | 33115 | @itemx -mavx512ifma |
d77de738 | 33116 | @need 200 |
d77de738 | 33117 | @opindex mavx512vbmi |
ddf6fe37 | 33118 | @itemx -mavx512vbmi |
d77de738 | 33119 | @need 200 |
d77de738 | 33120 | @opindex msha |
ddf6fe37 | 33121 | @itemx -msha |
d77de738 | 33122 | @need 200 |
d77de738 | 33123 | @opindex maes |
ddf6fe37 | 33124 | @itemx -maes |
d77de738 | 33125 | @need 200 |
d77de738 | 33126 | @opindex mpclmul |
ddf6fe37 | 33127 | @itemx -mpclmul |
d77de738 | 33128 | @need 200 |
d77de738 | 33129 | @opindex mclflushopt |
ddf6fe37 | 33130 | @itemx -mclflushopt |
d77de738 | 33131 | @need 200 |
d77de738 | 33132 | @opindex mclwb |
ddf6fe37 | 33133 | @itemx -mclwb |
d77de738 | 33134 | @need 200 |
d77de738 | 33135 | @opindex mfsgsbase |
ddf6fe37 | 33136 | @itemx -mfsgsbase |
d77de738 | 33137 | @need 200 |
d77de738 | 33138 | @opindex mptwrite |
ddf6fe37 | 33139 | @itemx -mptwrite |
d77de738 | 33140 | @need 200 |
d77de738 | 33141 | @opindex mrdrnd |
ddf6fe37 | 33142 | @itemx -mrdrnd |
d77de738 | 33143 | @need 200 |
d77de738 | 33144 | @opindex mf16c |
ddf6fe37 | 33145 | @itemx -mf16c |
d77de738 | 33146 | @need 200 |
d77de738 | 33147 | @opindex mfma |
ddf6fe37 | 33148 | @itemx -mfma |
d77de738 | 33149 | @need 200 |
d77de738 | 33150 | @opindex mpconfig |
ddf6fe37 | 33151 | @itemx -mpconfig |
d77de738 | 33152 | @need 200 |
d77de738 | 33153 | @opindex mwbnoinvd |
ddf6fe37 | 33154 | @itemx -mwbnoinvd |
d77de738 | 33155 | @need 200 |
d77de738 | 33156 | @opindex mfma4 |
ddf6fe37 | 33157 | @itemx -mfma4 |
d77de738 | 33158 | @need 200 |
d77de738 | 33159 | @opindex mprfchw |
ddf6fe37 | 33160 | @itemx -mprfchw |
d77de738 | 33161 | @need 200 |
d77de738 | 33162 | @opindex mrdpid |
ddf6fe37 | 33163 | @itemx -mrdpid |
d77de738 | 33164 | @need 200 |
d77de738 | 33165 | @opindex mprefetchwt1 |
ddf6fe37 | 33166 | @itemx -mprefetchwt1 |
d77de738 | 33167 | @need 200 |
d77de738 | 33168 | @opindex mrdseed |
ddf6fe37 | 33169 | @itemx -mrdseed |
d77de738 | 33170 | @need 200 |
d77de738 | 33171 | @opindex msgx |
ddf6fe37 | 33172 | @itemx -msgx |
d77de738 | 33173 | @need 200 |
d77de738 | 33174 | @opindex mxop |
ddf6fe37 | 33175 | @itemx -mxop |
d77de738 | 33176 | @need 200 |
d77de738 | 33177 | @opindex mlwp |
ddf6fe37 | 33178 | @itemx -mlwp |
d77de738 | 33179 | @need 200 |
d77de738 | 33180 | @opindex m3dnow |
ddf6fe37 | 33181 | @itemx -m3dnow |
d77de738 | 33182 | @need 200 |
d77de738 | 33183 | @opindex m3dnowa |
ddf6fe37 | 33184 | @itemx -m3dnowa |
d77de738 | 33185 | @need 200 |
d77de738 | 33186 | @opindex mpopcnt |
ddf6fe37 | 33187 | @itemx -mpopcnt |
d77de738 | 33188 | @need 200 |
d77de738 | 33189 | @opindex mabm |
ddf6fe37 | 33190 | @itemx -mabm |
d77de738 | 33191 | @need 200 |
d77de738 | 33192 | @opindex madx |
ddf6fe37 | 33193 | @itemx -madx |
d77de738 | 33194 | @need 200 |
d77de738 | 33195 | @opindex mbmi |
ddf6fe37 | 33196 | @itemx -mbmi |
d77de738 | 33197 | @need 200 |
d77de738 | 33198 | @opindex mbmi2 |
ddf6fe37 | 33199 | @itemx -mbmi2 |
d77de738 | 33200 | @need 200 |
d77de738 | 33201 | @opindex mlzcnt |
ddf6fe37 | 33202 | @itemx -mlzcnt |
d77de738 | 33203 | @need 200 |
d77de738 | 33204 | @opindex mfxsr |
ddf6fe37 | 33205 | @itemx -mfxsr |
d77de738 | 33206 | @need 200 |
d77de738 | 33207 | @opindex mxsave |
ddf6fe37 | 33208 | @itemx -mxsave |
d77de738 | 33209 | @need 200 |
d77de738 | 33210 | @opindex mxsaveopt |
ddf6fe37 | 33211 | @itemx -mxsaveopt |
d77de738 | 33212 | @need 200 |
d77de738 | 33213 | @opindex mxsavec |
ddf6fe37 | 33214 | @itemx -mxsavec |
d77de738 | 33215 | @need 200 |
d77de738 | 33216 | @opindex mxsaves |
ddf6fe37 | 33217 | @itemx -mxsaves |
d77de738 | 33218 | @need 200 |
d77de738 | 33219 | @opindex mrtm |
ddf6fe37 | 33220 | @itemx -mrtm |
d77de738 | 33221 | @need 200 |
d77de738 | 33222 | @opindex mhle |
ddf6fe37 | 33223 | @itemx -mhle |
d77de738 | 33224 | @need 200 |
d77de738 | 33225 | @opindex mtbm |
ddf6fe37 | 33226 | @itemx -mtbm |
d77de738 | 33227 | @need 200 |
d77de738 | 33228 | @opindex mmwaitx |
ddf6fe37 | 33229 | @itemx -mmwaitx |
d77de738 | 33230 | @need 200 |
d77de738 | 33231 | @opindex mclzero |
ddf6fe37 | 33232 | @itemx -mclzero |
d77de738 | 33233 | @need 200 |
d77de738 | 33234 | @opindex mpku |
ddf6fe37 | 33235 | @itemx -mpku |
d77de738 | 33236 | @need 200 |
d77de738 | 33237 | @opindex mavx512vbmi2 |
ddf6fe37 | 33238 | @itemx -mavx512vbmi2 |
d77de738 | 33239 | @need 200 |
d77de738 | 33240 | @opindex mavx512bf16 |
ddf6fe37 | 33241 | @itemx -mavx512bf16 |
d77de738 | 33242 | @need 200 |
d77de738 | 33243 | @opindex mavx512fp16 |
ddf6fe37 | 33244 | @itemx -mavx512fp16 |
d77de738 | 33245 | @need 200 |
d77de738 | 33246 | @opindex mgfni |
ddf6fe37 | 33247 | @itemx -mgfni |
d77de738 | 33248 | @need 200 |
d77de738 | 33249 | @opindex mvaes |
ddf6fe37 | 33250 | @itemx -mvaes |
d77de738 | 33251 | @need 200 |
d77de738 | 33252 | @opindex mwaitpkg |
ddf6fe37 | 33253 | @itemx -mwaitpkg |
d77de738 | 33254 | @need 200 |
d77de738 | 33255 | @opindex mvpclmulqdq |
ddf6fe37 | 33256 | @itemx -mvpclmulqdq |
d77de738 | 33257 | @need 200 |
d77de738 | 33258 | @opindex mavx512bitalg |
ddf6fe37 | 33259 | @itemx -mavx512bitalg |
d77de738 | 33260 | @need 200 |
d77de738 | 33261 | @opindex mmovdiri |
ddf6fe37 | 33262 | @itemx -mmovdiri |
d77de738 | 33263 | @need 200 |
d77de738 | 33264 | @opindex mmovdir64b |
ddf6fe37 | 33265 | @itemx -mmovdir64b |
d77de738 | 33266 | @need 200 |
d77de738 | 33267 | @opindex menqcmd |
d77de738 | 33268 | @opindex muintr |
ddf6fe37 AA |
33269 | @itemx -menqcmd |
33270 | @itemx -muintr | |
d77de738 | 33271 | @need 200 |
d77de738 | 33272 | @opindex mtsxldtrk |
ddf6fe37 | 33273 | @itemx -mtsxldtrk |
d77de738 | 33274 | @need 200 |
d77de738 | 33275 | @opindex mavx512vpopcntdq |
ddf6fe37 | 33276 | @itemx -mavx512vpopcntdq |
d77de738 | 33277 | @need 200 |
d77de738 | 33278 | @opindex mavx512vp2intersect |
ddf6fe37 | 33279 | @itemx -mavx512vp2intersect |
d77de738 | 33280 | @need 200 |
d77de738 | 33281 | @opindex mavx5124fmaps |
ddf6fe37 | 33282 | @itemx -mavx5124fmaps |
d77de738 | 33283 | @need 200 |
d77de738 | 33284 | @opindex mavx512vnni |
ddf6fe37 | 33285 | @itemx -mavx512vnni |
d77de738 | 33286 | @need 200 |
d77de738 | 33287 | @opindex mavxvnni |
ddf6fe37 | 33288 | @itemx -mavxvnni |
d77de738 | 33289 | @need 200 |
d77de738 | 33290 | @opindex mavx5124vnniw |
ddf6fe37 | 33291 | @itemx -mavx5124vnniw |
d77de738 | 33292 | @need 200 |
d77de738 | 33293 | @opindex mcldemote |
ddf6fe37 | 33294 | @itemx -mcldemote |
d77de738 | 33295 | @need 200 |
d77de738 | 33296 | @opindex mserialize |
ddf6fe37 | 33297 | @itemx -mserialize |
d77de738 | 33298 | @need 200 |
d77de738 | 33299 | @opindex mamx-tile |
ddf6fe37 | 33300 | @itemx -mamx-tile |
d77de738 | 33301 | @need 200 |
d77de738 | 33302 | @opindex mamx-int8 |
ddf6fe37 | 33303 | @itemx -mamx-int8 |
d77de738 | 33304 | @need 200 |
d77de738 | 33305 | @opindex mamx-bf16 |
ddf6fe37 | 33306 | @itemx -mamx-bf16 |
d77de738 | 33307 | @need 200 |
d77de738 | 33308 | @opindex mhreset |
d77de738 | 33309 | @opindex mkl |
ddf6fe37 AA |
33310 | @itemx -mhreset |
33311 | @itemx -mkl | |
d77de738 | 33312 | @need 200 |
d77de738 | 33313 | @opindex mwidekl |
ddf6fe37 | 33314 | @itemx -mwidekl |
d77de738 | 33315 | @need 200 |
d77de738 | 33316 | @opindex mavxifma |
ddf6fe37 | 33317 | @itemx -mavxifma |
d77de738 | 33318 | @need 200 |
d77de738 | 33319 | @opindex mavxvnniint8 |
ddf6fe37 | 33320 | @itemx -mavxvnniint8 |
d77de738 | 33321 | @need 200 |
d77de738 | 33322 | @opindex mavxneconvert |
ddf6fe37 | 33323 | @itemx -mavxneconvert |
d77de738 | 33324 | @need 200 |
d77de738 | 33325 | @opindex mcmpccxadd |
ddf6fe37 | 33326 | @itemx -mcmpccxadd |
d77de738 | 33327 | @need 200 |
d77de738 | 33328 | @opindex mamx-fp16 |
ddf6fe37 | 33329 | @itemx -mamx-fp16 |
d77de738 | 33330 | @need 200 |
d77de738 | 33331 | @opindex mprefetchi |
ddf6fe37 | 33332 | @itemx -mprefetchi |
d77de738 | 33333 | @need 200 |
d77de738 | 33334 | @opindex mraoint |
ddf6fe37 | 33335 | @itemx -mraoint |
d77de738 ML |
33336 | These switches enable the use of instructions in the MMX, SSE, |
33337 | SSE2, SSE3, SSSE3, SSE4, SSE4A, SSE4.1, SSE4.2, AVX, AVX2, AVX512F, AVX512PF, | |
33338 | AVX512ER, AVX512CD, AVX512VL, AVX512BW, AVX512DQ, AVX512IFMA, AVX512VBMI, SHA, | |
33339 | AES, PCLMUL, CLFLUSHOPT, CLWB, FSGSBASE, PTWRITE, RDRND, F16C, FMA, PCONFIG, | |
33340 | WBNOINVD, FMA4, PREFETCHW, RDPID, PREFETCHWT1, RDSEED, SGX, XOP, LWP, | |
33341 | 3DNow!@:, enhanced 3DNow!@:, POPCNT, ABM, ADX, BMI, BMI2, LZCNT, FXSR, XSAVE, | |
33342 | XSAVEOPT, XSAVEC, XSAVES, RTM, HLE, TBM, MWAITX, CLZERO, PKU, AVX512VBMI2, | |
33343 | GFNI, VAES, WAITPKG, VPCLMULQDQ, AVX512BITALG, MOVDIRI, MOVDIR64B, AVX512BF16, | |
33344 | ENQCMD, AVX512VPOPCNTDQ, AVX5124FMAPS, AVX512VNNI, AVX5124VNNIW, SERIALIZE, | |
29ecb952 | 33345 | UINTR, HRESET, AMXTILE, AMXINT8, AMXBF16, KL, WIDEKL, AVXVNNI, AVX512-FP16, |
d77de738 ML |
33346 | AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AMX-FP16, PREFETCHI, RAOINT or |
33347 | CLDEMOTE extended instruction sets. Each has a corresponding @option{-mno-} | |
33348 | option to disable use of these instructions. | |
33349 | ||
33350 | These extensions are also available as built-in functions: see | |
33351 | @ref{x86 Built-in Functions}, for details of the functions enabled and | |
33352 | disabled by these switches. | |
33353 | ||
33354 | To generate SSE/SSE2 instructions automatically from floating-point | |
33355 | code (as opposed to 387 instructions), see @option{-mfpmath=sse}. | |
33356 | ||
33357 | GCC depresses SSEx instructions when @option{-mavx} is used. Instead, it | |
33358 | generates new AVX instructions or AVX equivalence for all SSEx instructions | |
33359 | when needed. | |
33360 | ||
33361 | These options enable GCC to use these extended instructions in | |
33362 | generated code, even without @option{-mfpmath=sse}. Applications that | |
33363 | perform run-time CPU detection must compile separate files for each | |
33364 | supported architecture, using the appropriate flags. In particular, | |
33365 | the file containing the CPU detection code should be compiled without | |
33366 | these options. | |
33367 | ||
d77de738 | 33368 | @opindex mdump-tune-features |
ddf6fe37 | 33369 | @item -mdump-tune-features |
d77de738 ML |
33370 | This option instructs GCC to dump the names of the x86 performance |
33371 | tuning features and default settings. The names can be used in | |
33372 | @option{-mtune-ctrl=@var{feature-list}}. | |
33373 | ||
d77de738 | 33374 | @opindex mtune-ctrl=@var{feature-list} |
ddf6fe37 | 33375 | @item -mtune-ctrl=@var{feature-list} |
d77de738 ML |
33376 | This option is used to do fine grain control of x86 code generation features. |
33377 | @var{feature-list} is a comma separated list of @var{feature} names. See also | |
33378 | @option{-mdump-tune-features}. When specified, the @var{feature} is turned | |
33379 | on if it is not preceded with @samp{^}, otherwise, it is turned off. | |
33380 | @option{-mtune-ctrl=@var{feature-list}} is intended to be used by GCC | |
33381 | developers. Using it may lead to code paths not covered by testing and can | |
33382 | potentially result in compiler ICEs or runtime errors. | |
33383 | ||
d77de738 | 33384 | @opindex mno-default |
ddf6fe37 | 33385 | @item -mno-default |
d77de738 ML |
33386 | This option instructs GCC to turn off all tunable features. See also |
33387 | @option{-mtune-ctrl=@var{feature-list}} and @option{-mdump-tune-features}. | |
33388 | ||
d77de738 | 33389 | @opindex mcld |
ddf6fe37 | 33390 | @item -mcld |
d77de738 ML |
33391 | This option instructs GCC to emit a @code{cld} instruction in the prologue |
33392 | of functions that use string instructions. String instructions depend on | |
33393 | the DF flag to select between autoincrement or autodecrement mode. While the | |
33394 | ABI specifies the DF flag to be cleared on function entry, some operating | |
33395 | systems violate this specification by not clearing the DF flag in their | |
33396 | exception dispatchers. The exception handler can be invoked with the DF flag | |
33397 | set, which leads to wrong direction mode when string instructions are used. | |
33398 | This option can be enabled by default on 32-bit x86 targets by configuring | |
33399 | GCC with the @option{--enable-cld} configure option. Generation of @code{cld} | |
33400 | instructions can be suppressed with the @option{-mno-cld} compiler option | |
33401 | in this case. | |
33402 | ||
d77de738 | 33403 | @opindex mvzeroupper |
ddf6fe37 | 33404 | @item -mvzeroupper |
d77de738 ML |
33405 | This option instructs GCC to emit a @code{vzeroupper} instruction |
33406 | before a transfer of control flow out of the function to minimize | |
33407 | the AVX to SSE transition penalty as well as remove unnecessary @code{zeroupper} | |
33408 | intrinsics. | |
33409 | ||
d77de738 | 33410 | @opindex mprefer-avx128 |
ddf6fe37 | 33411 | @item -mprefer-avx128 |
d77de738 ML |
33412 | This option instructs GCC to use 128-bit AVX instructions instead of |
33413 | 256-bit AVX instructions in the auto-vectorizer. | |
33414 | ||
d77de738 | 33415 | @opindex mprefer-vector-width |
ddf6fe37 | 33416 | @item -mprefer-vector-width=@var{opt} |
d77de738 ML |
33417 | This option instructs GCC to use @var{opt}-bit vector width in instructions |
33418 | instead of default on the selected platform. | |
33419 | ||
d77de738 | 33420 | @opindex mmove-max |
ddf6fe37 | 33421 | @item -mmove-max=@var{bits} |
d77de738 ML |
33422 | This option instructs GCC to set the maximum number of bits can be |
33423 | moved from memory to memory efficiently to @var{bits}. The valid | |
33424 | @var{bits} are 128, 256 and 512. | |
33425 | ||
d77de738 | 33426 | @opindex mstore-max |
ddf6fe37 | 33427 | @item -mstore-max=@var{bits} |
d77de738 ML |
33428 | This option instructs GCC to set the maximum number of bits can be |
33429 | stored to memory efficiently to @var{bits}. The valid @var{bits} are | |
33430 | 128, 256 and 512. | |
33431 | ||
33432 | @table @samp | |
33433 | @item none | |
33434 | No extra limitations applied to GCC other than defined by the selected platform. | |
33435 | ||
33436 | @item 128 | |
33437 | Prefer 128-bit vector width for instructions. | |
33438 | ||
33439 | @item 256 | |
33440 | Prefer 256-bit vector width for instructions. | |
33441 | ||
33442 | @item 512 | |
33443 | Prefer 512-bit vector width for instructions. | |
33444 | @end table | |
33445 | ||
d77de738 | 33446 | @opindex mcx16 |
ddf6fe37 | 33447 | @item -mcx16 |
d77de738 ML |
33448 | This option enables GCC to generate @code{CMPXCHG16B} instructions in 64-bit |
33449 | code to implement compare-and-exchange operations on 16-byte aligned 128-bit | |
33450 | objects. This is useful for atomic updates of data structures exceeding one | |
33451 | machine word in size. The compiler uses this instruction to implement | |
33452 | @ref{__sync Builtins}. However, for @ref{__atomic Builtins} operating on | |
33453 | 128-bit integers, a library call is always used. | |
33454 | ||
d77de738 | 33455 | @opindex msahf |
ddf6fe37 | 33456 | @item -msahf |
d77de738 ML |
33457 | This option enables generation of @code{SAHF} instructions in 64-bit code. |
33458 | Early Intel Pentium 4 CPUs with Intel 64 support, | |
33459 | prior to the introduction of Pentium 4 G1 step in December 2005, | |
33460 | lacked the @code{LAHF} and @code{SAHF} instructions | |
33461 | which are supported by AMD64. | |
33462 | These are load and store instructions, respectively, for certain status flags. | |
33463 | In 64-bit mode, the @code{SAHF} instruction is used to optimize @code{fmod}, | |
33464 | @code{drem}, and @code{remainder} built-in functions; | |
33465 | see @ref{Other Builtins} for details. | |
33466 | ||
d77de738 | 33467 | @opindex mmovbe |
ddf6fe37 | 33468 | @item -mmovbe |
d77de738 ML |
33469 | This option enables use of the @code{movbe} instruction to implement |
33470 | @code{__builtin_bswap32} and @code{__builtin_bswap64}. | |
33471 | ||
d77de738 | 33472 | @opindex mshstk |
ddf6fe37 | 33473 | @item -mshstk |
d77de738 ML |
33474 | The @option{-mshstk} option enables shadow stack built-in functions |
33475 | from x86 Control-flow Enforcement Technology (CET). | |
33476 | ||
d77de738 | 33477 | @opindex mcrc32 |
ddf6fe37 | 33478 | @item -mcrc32 |
d77de738 ML |
33479 | This option enables built-in functions @code{__builtin_ia32_crc32qi}, |
33480 | @code{__builtin_ia32_crc32hi}, @code{__builtin_ia32_crc32si} and | |
33481 | @code{__builtin_ia32_crc32di} to generate the @code{crc32} machine instruction. | |
33482 | ||
d77de738 | 33483 | @opindex mmwait |
ddf6fe37 | 33484 | @item -mmwait |
d77de738 ML |
33485 | This option enables built-in functions @code{__builtin_ia32_monitor}, |
33486 | and @code{__builtin_ia32_mwait} to generate the @code{monitor} and | |
33487 | @code{mwait} machine instructions. | |
33488 | ||
d77de738 | 33489 | @opindex mrecip |
ddf6fe37 | 33490 | @item -mrecip |
d77de738 ML |
33491 | This option enables use of @code{RCPSS} and @code{RSQRTSS} instructions |
33492 | (and their vectorized variants @code{RCPPS} and @code{RSQRTPS}) | |
33493 | with an additional Newton-Raphson step | |
33494 | to increase precision instead of @code{DIVSS} and @code{SQRTSS} | |
33495 | (and their vectorized | |
33496 | variants) for single-precision floating-point arguments. These instructions | |
33497 | are generated only when @option{-funsafe-math-optimizations} is enabled | |
33498 | together with @option{-ffinite-math-only} and @option{-fno-trapping-math}. | |
33499 | Note that while the throughput of the sequence is higher than the throughput | |
33500 | of the non-reciprocal instruction, the precision of the sequence can be | |
33501 | decreased by up to 2 ulp (i.e.@: the inverse of 1.0 equals 0.99999994). | |
33502 | ||
33503 | Note that GCC implements @code{1.0f/sqrtf(@var{x})} in terms of @code{RSQRTSS} | |
33504 | (or @code{RSQRTPS}) already with @option{-ffast-math} (or the above option | |
33505 | combination), and doesn't need @option{-mrecip}. | |
33506 | ||
33507 | Also note that GCC emits the above sequence with additional Newton-Raphson step | |
33508 | for vectorized single-float division and vectorized @code{sqrtf(@var{x})} | |
33509 | already with @option{-ffast-math} (or the above option combination), and | |
33510 | doesn't need @option{-mrecip}. | |
33511 | ||
d77de738 | 33512 | @opindex mrecip=opt |
ddf6fe37 | 33513 | @item -mrecip=@var{opt} |
d77de738 ML |
33514 | This option controls which reciprocal estimate instructions |
33515 | may be used. @var{opt} is a comma-separated list of options, which may | |
33516 | be preceded by a @samp{!} to invert the option: | |
33517 | ||
33518 | @table @samp | |
33519 | @item all | |
33520 | Enable all estimate instructions. | |
33521 | ||
33522 | @item default | |
33523 | Enable the default instructions, equivalent to @option{-mrecip}. | |
33524 | ||
33525 | @item none | |
33526 | Disable all estimate instructions, equivalent to @option{-mno-recip}. | |
33527 | ||
33528 | @item div | |
33529 | Enable the approximation for scalar division. | |
33530 | ||
33531 | @item vec-div | |
33532 | Enable the approximation for vectorized division. | |
33533 | ||
33534 | @item sqrt | |
33535 | Enable the approximation for scalar square root. | |
33536 | ||
33537 | @item vec-sqrt | |
33538 | Enable the approximation for vectorized square root. | |
33539 | @end table | |
33540 | ||
33541 | So, for example, @option{-mrecip=all,!sqrt} enables | |
33542 | all of the reciprocal approximations, except for square root. | |
33543 | ||
d77de738 | 33544 | @opindex mveclibabi |
ddf6fe37 | 33545 | @item -mveclibabi=@var{type} |
d77de738 ML |
33546 | Specifies the ABI type to use for vectorizing intrinsics using an |
33547 | external library. Supported values for @var{type} are @samp{svml} | |
33548 | for the Intel short | |
33549 | vector math library and @samp{acml} for the AMD math core library. | |
33550 | To use this option, both @option{-ftree-vectorize} and | |
33551 | @option{-funsafe-math-optimizations} have to be enabled, and an SVML or ACML | |
33552 | ABI-compatible library must be specified at link time. | |
33553 | ||
33554 | GCC currently emits calls to @code{vmldExp2}, | |
33555 | @code{vmldLn2}, @code{vmldLog102}, @code{vmldPow2}, | |
33556 | @code{vmldTanh2}, @code{vmldTan2}, @code{vmldAtan2}, @code{vmldAtanh2}, | |
33557 | @code{vmldCbrt2}, @code{vmldSinh2}, @code{vmldSin2}, @code{vmldAsinh2}, | |
33558 | @code{vmldAsin2}, @code{vmldCosh2}, @code{vmldCos2}, @code{vmldAcosh2}, | |
33559 | @code{vmldAcos2}, @code{vmlsExp4}, @code{vmlsLn4}, | |
33560 | @code{vmlsLog104}, @code{vmlsPow4}, @code{vmlsTanh4}, @code{vmlsTan4}, | |
33561 | @code{vmlsAtan4}, @code{vmlsAtanh4}, @code{vmlsCbrt4}, @code{vmlsSinh4}, | |
33562 | @code{vmlsSin4}, @code{vmlsAsinh4}, @code{vmlsAsin4}, @code{vmlsCosh4}, | |
33563 | @code{vmlsCos4}, @code{vmlsAcosh4} and @code{vmlsAcos4} for corresponding | |
33564 | function type when @option{-mveclibabi=svml} is used, and @code{__vrd2_sin}, | |
33565 | @code{__vrd2_cos}, @code{__vrd2_exp}, @code{__vrd2_log}, @code{__vrd2_log2}, | |
33566 | @code{__vrd2_log10}, @code{__vrs4_sinf}, @code{__vrs4_cosf}, | |
33567 | @code{__vrs4_expf}, @code{__vrs4_logf}, @code{__vrs4_log2f}, | |
33568 | @code{__vrs4_log10f} and @code{__vrs4_powf} for the corresponding function type | |
33569 | when @option{-mveclibabi=acml} is used. | |
33570 | ||
d77de738 | 33571 | @opindex mabi |
ddf6fe37 | 33572 | @item -mabi=@var{name} |
d77de738 ML |
33573 | Generate code for the specified calling convention. Permissible values |
33574 | are @samp{sysv} for the ABI used on GNU/Linux and other systems, and | |
33575 | @samp{ms} for the Microsoft ABI. The default is to use the Microsoft | |
33576 | ABI when targeting Microsoft Windows and the SysV ABI on all other systems. | |
33577 | You can control this behavior for specific functions by | |
33578 | using the function attributes @code{ms_abi} and @code{sysv_abi}. | |
33579 | @xref{Function Attributes}. | |
33580 | ||
d77de738 | 33581 | @opindex mforce-indirect-call |
ddf6fe37 | 33582 | @item -mforce-indirect-call |
d77de738 ML |
33583 | Force all calls to functions to be indirect. This is useful |
33584 | when using Intel Processor Trace where it generates more precise timing | |
33585 | information for function calls. | |
33586 | ||
d77de738 | 33587 | @opindex mmanual-endbr |
ddf6fe37 | 33588 | @item -mmanual-endbr |
d77de738 ML |
33589 | Insert ENDBR instruction at function entry only via the @code{cf_check} |
33590 | function attribute. This is useful when used with the option | |
33591 | @option{-fcf-protection=branch} to control ENDBR insertion at the | |
33592 | function entry. | |
33593 | ||
d77de738 | 33594 | @opindex mcet-switch |
ddf6fe37 | 33595 | @item -mcet-switch |
d77de738 ML |
33596 | By default, CET instrumentation is turned off on switch statements that |
33597 | use a jump table and indirect branch track is disabled. Since jump | |
33598 | tables are stored in read-only memory, this does not result in a direct | |
33599 | loss of hardening. But if the jump table index is attacker-controlled, | |
33600 | the indirect jump may not be constrained by CET. This option turns on | |
33601 | CET instrumentation to enable indirect branch track for switch statements | |
33602 | with jump tables which leads to the jump targets reachable via any indirect | |
33603 | jumps. | |
33604 | ||
d77de738 ML |
33605 | @opindex mcall-ms2sysv-xlogues |
33606 | @opindex mno-call-ms2sysv-xlogues | |
ddf6fe37 | 33607 | @item -mcall-ms2sysv-xlogues |
d77de738 ML |
33608 | Due to differences in 64-bit ABIs, any Microsoft ABI function that calls a |
33609 | System V ABI function must consider RSI, RDI and XMM6-15 as clobbered. By | |
33610 | default, the code for saving and restoring these registers is emitted inline, | |
33611 | resulting in fairly lengthy prologues and epilogues. Using | |
33612 | @option{-mcall-ms2sysv-xlogues} emits prologues and epilogues that | |
33613 | use stubs in the static portion of libgcc to perform these saves and restores, | |
33614 | thus reducing function size at the cost of a few extra instructions. | |
33615 | ||
d77de738 | 33616 | @opindex mtls-dialect |
ddf6fe37 | 33617 | @item -mtls-dialect=@var{type} |
d77de738 ML |
33618 | Generate code to access thread-local storage using the @samp{gnu} or |
33619 | @samp{gnu2} conventions. @samp{gnu} is the conservative default; | |
33620 | @samp{gnu2} is more efficient, but it may add compile- and run-time | |
33621 | requirements that cannot be satisfied on all systems. | |
33622 | ||
d77de738 ML |
33623 | @opindex mpush-args |
33624 | @opindex mno-push-args | |
ddf6fe37 AA |
33625 | @item -mpush-args |
33626 | @itemx -mno-push-args | |
d77de738 ML |
33627 | Use PUSH operations to store outgoing parameters. This method is shorter |
33628 | and usually equally fast as method using SUB/MOV operations and is enabled | |
33629 | by default. In some cases disabling it may improve performance because of | |
33630 | improved scheduling and reduced dependencies. | |
33631 | ||
d77de738 | 33632 | @opindex maccumulate-outgoing-args |
ddf6fe37 | 33633 | @item -maccumulate-outgoing-args |
d77de738 ML |
33634 | If enabled, the maximum amount of space required for outgoing arguments is |
33635 | computed in the function prologue. This is faster on most modern CPUs | |
33636 | because of reduced dependencies, improved scheduling and reduced stack usage | |
33637 | when the preferred stack boundary is not equal to 2. The drawback is a notable | |
33638 | increase in code size. This switch implies @option{-mno-push-args}. | |
33639 | ||
d77de738 | 33640 | @opindex mthreads |
ddf6fe37 | 33641 | @item -mthreads |
d77de738 ML |
33642 | Support thread-safe exception handling on MinGW. Programs that rely |
33643 | on thread-safe exception handling must compile and link all code with the | |
33644 | @option{-mthreads} option. When compiling, @option{-mthreads} defines | |
33645 | @option{-D_MT}; when linking, it links in a special thread helper library | |
33646 | @option{-lmingwthrd} which cleans up per-thread exception-handling data. | |
33647 | ||
d77de738 ML |
33648 | @opindex mms-bitfields |
33649 | @opindex mno-ms-bitfields | |
ddf6fe37 AA |
33650 | @item -mms-bitfields |
33651 | @itemx -mno-ms-bitfields | |
d77de738 ML |
33652 | |
33653 | Enable/disable bit-field layout compatible with the native Microsoft | |
33654 | Windows compiler. | |
33655 | ||
33656 | If @code{packed} is used on a structure, or if bit-fields are used, | |
33657 | it may be that the Microsoft ABI lays out the structure differently | |
33658 | than the way GCC normally does. Particularly when moving packed | |
33659 | data between functions compiled with GCC and the native Microsoft compiler | |
33660 | (either via function call or as data in a file), it may be necessary to access | |
33661 | either format. | |
33662 | ||
33663 | This option is enabled by default for Microsoft Windows | |
33664 | targets. This behavior can also be controlled locally by use of variable | |
33665 | or type attributes. For more information, see @ref{x86 Variable Attributes} | |
33666 | and @ref{x86 Type Attributes}. | |
33667 | ||
33668 | The Microsoft structure layout algorithm is fairly simple with the exception | |
33669 | of the bit-field packing. | |
33670 | The padding and alignment of members of structures and whether a bit-field | |
33671 | can straddle a storage-unit boundary are determine by these rules: | |
33672 | ||
33673 | @enumerate | |
33674 | @item Structure members are stored sequentially in the order in which they are | |
33675 | declared: the first member has the lowest memory address and the last member | |
33676 | the highest. | |
33677 | ||
33678 | @item Every data object has an alignment requirement. The alignment requirement | |
33679 | for all data except structures, unions, and arrays is either the size of the | |
33680 | object or the current packing size (specified with either the | |
33681 | @code{aligned} attribute or the @code{pack} pragma), | |
33682 | whichever is less. For structures, unions, and arrays, | |
33683 | the alignment requirement is the largest alignment requirement of its members. | |
33684 | Every object is allocated an offset so that: | |
33685 | ||
33686 | @smallexample | |
33687 | offset % alignment_requirement == 0 | |
33688 | @end smallexample | |
33689 | ||
33690 | @item Adjacent bit-fields are packed into the same 1-, 2-, or 4-byte allocation | |
33691 | unit if the integral types are the same size and if the next bit-field fits | |
33692 | into the current allocation unit without crossing the boundary imposed by the | |
33693 | common alignment requirements of the bit-fields. | |
33694 | @end enumerate | |
33695 | ||
33696 | MSVC interprets zero-length bit-fields in the following ways: | |
33697 | ||
33698 | @enumerate | |
33699 | @item If a zero-length bit-field is inserted between two bit-fields that | |
33700 | are normally coalesced, the bit-fields are not coalesced. | |
33701 | ||
33702 | For example: | |
33703 | ||
33704 | @smallexample | |
33705 | struct | |
33706 | @{ | |
33707 | unsigned long bf_1 : 12; | |
33708 | unsigned long : 0; | |
33709 | unsigned long bf_2 : 12; | |
33710 | @} t1; | |
33711 | @end smallexample | |
33712 | ||
33713 | @noindent | |
33714 | The size of @code{t1} is 8 bytes with the zero-length bit-field. If the | |
33715 | zero-length bit-field were removed, @code{t1}'s size would be 4 bytes. | |
33716 | ||
33717 | @item If a zero-length bit-field is inserted after a bit-field, @code{foo}, and the | |
33718 | alignment of the zero-length bit-field is greater than the member that follows it, | |
33719 | @code{bar}, @code{bar} is aligned as the type of the zero-length bit-field. | |
33720 | ||
33721 | For example: | |
33722 | ||
33723 | @smallexample | |
33724 | struct | |
33725 | @{ | |
33726 | char foo : 4; | |
33727 | short : 0; | |
33728 | char bar; | |
33729 | @} t2; | |
33730 | ||
33731 | struct | |
33732 | @{ | |
33733 | char foo : 4; | |
33734 | short : 0; | |
33735 | double bar; | |
33736 | @} t3; | |
33737 | @end smallexample | |
33738 | ||
33739 | @noindent | |
33740 | For @code{t2}, @code{bar} is placed at offset 2, rather than offset 1. | |
33741 | Accordingly, the size of @code{t2} is 4. For @code{t3}, the zero-length | |
33742 | bit-field does not affect the alignment of @code{bar} or, as a result, the size | |
33743 | of the structure. | |
33744 | ||
33745 | Taking this into account, it is important to note the following: | |
33746 | ||
33747 | @enumerate | |
33748 | @item If a zero-length bit-field follows a normal bit-field, the type of the | |
33749 | zero-length bit-field may affect the alignment of the structure as whole. For | |
33750 | example, @code{t2} has a size of 4 bytes, since the zero-length bit-field follows a | |
33751 | normal bit-field, and is of type short. | |
33752 | ||
33753 | @item Even if a zero-length bit-field is not followed by a normal bit-field, it may | |
33754 | still affect the alignment of the structure: | |
33755 | ||
33756 | @smallexample | |
33757 | struct | |
33758 | @{ | |
33759 | char foo : 6; | |
33760 | long : 0; | |
33761 | @} t4; | |
33762 | @end smallexample | |
33763 | ||
33764 | @noindent | |
33765 | Here, @code{t4} takes up 4 bytes. | |
33766 | @end enumerate | |
33767 | ||
33768 | @item Zero-length bit-fields following non-bit-field members are ignored: | |
33769 | ||
33770 | @smallexample | |
33771 | struct | |
33772 | @{ | |
33773 | char foo; | |
33774 | long : 0; | |
33775 | char bar; | |
33776 | @} t5; | |
33777 | @end smallexample | |
33778 | ||
33779 | @noindent | |
33780 | Here, @code{t5} takes up 2 bytes. | |
33781 | @end enumerate | |
33782 | ||
33783 | ||
d77de738 ML |
33784 | @opindex mno-align-stringops |
33785 | @opindex malign-stringops | |
ddf6fe37 | 33786 | @item -mno-align-stringops |
d77de738 ML |
33787 | Do not align the destination of inlined string operations. This switch reduces |
33788 | code size and improves performance in case the destination is already aligned, | |
33789 | but GCC doesn't know about it. | |
33790 | ||
d77de738 | 33791 | @opindex minline-all-stringops |
ddf6fe37 | 33792 | @item -minline-all-stringops |
d77de738 ML |
33793 | By default GCC inlines string operations only when the destination is |
33794 | known to be aligned to least a 4-byte boundary. | |
33795 | This enables more inlining and increases code | |
33796 | size, but may improve performance of code that depends on fast | |
33797 | @code{memcpy} and @code{memset} for short lengths. | |
33798 | The option enables inline expansion of @code{strlen} for all | |
33799 | pointer alignments. | |
33800 | ||
d77de738 | 33801 | @opindex minline-stringops-dynamically |
ddf6fe37 | 33802 | @item -minline-stringops-dynamically |
d77de738 ML |
33803 | For string operations of unknown size, use run-time checks with |
33804 | inline code for small blocks and a library call for large blocks. | |
33805 | ||
d77de738 | 33806 | @opindex mstringop-strategy=@var{alg} |
ddf6fe37 | 33807 | @item -mstringop-strategy=@var{alg} |
d77de738 ML |
33808 | Override the internal decision heuristic for the particular algorithm to use |
33809 | for inlining string operations. The allowed values for @var{alg} are: | |
33810 | ||
33811 | @table @samp | |
33812 | @item rep_byte | |
33813 | @itemx rep_4byte | |
33814 | @itemx rep_8byte | |
33815 | Expand using i386 @code{rep} prefix of the specified size. | |
33816 | ||
33817 | @item byte_loop | |
33818 | @itemx loop | |
33819 | @itemx unrolled_loop | |
33820 | Expand into an inline loop. | |
33821 | ||
33822 | @item libcall | |
33823 | Always use a library call. | |
33824 | @end table | |
33825 | ||
d77de738 | 33826 | @opindex mmemcpy-strategy=@var{strategy} |
ddf6fe37 | 33827 | @item -mmemcpy-strategy=@var{strategy} |
d77de738 ML |
33828 | Override the internal decision heuristic to decide if @code{__builtin_memcpy} |
33829 | should be inlined and what inline algorithm to use when the expected size | |
33830 | of the copy operation is known. @var{strategy} | |
33831 | is a comma-separated list of @var{alg}:@var{max_size}:@var{dest_align} triplets. | |
33832 | @var{alg} is specified in @option{-mstringop-strategy}, @var{max_size} specifies | |
33833 | the max byte size with which inline algorithm @var{alg} is allowed. For the last | |
33834 | triplet, the @var{max_size} must be @code{-1}. The @var{max_size} of the triplets | |
33835 | in the list must be specified in increasing order. The minimal byte size for | |
33836 | @var{alg} is @code{0} for the first triplet and @code{@var{max_size} + 1} of the | |
33837 | preceding range. | |
33838 | ||
d77de738 | 33839 | @opindex mmemset-strategy=@var{strategy} |
ddf6fe37 | 33840 | @item -mmemset-strategy=@var{strategy} |
d77de738 ML |
33841 | The option is similar to @option{-mmemcpy-strategy=} except that it is to control |
33842 | @code{__builtin_memset} expansion. | |
33843 | ||
d77de738 | 33844 | @opindex momit-leaf-frame-pointer |
ddf6fe37 | 33845 | @item -momit-leaf-frame-pointer |
d77de738 ML |
33846 | Don't keep the frame pointer in a register for leaf functions. This |
33847 | avoids the instructions to save, set up, and restore frame pointers and | |
33848 | makes an extra register available in leaf functions. The option | |
33849 | @option{-fomit-leaf-frame-pointer} removes the frame pointer for leaf functions, | |
33850 | which might make debugging harder. | |
33851 | ||
ddf6fe37 | 33852 | @opindex mtls-direct-seg-refs |
d77de738 ML |
33853 | @item -mtls-direct-seg-refs |
33854 | @itemx -mno-tls-direct-seg-refs | |
d77de738 ML |
33855 | Controls whether TLS variables may be accessed with offsets from the |
33856 | TLS segment register (@code{%gs} for 32-bit, @code{%fs} for 64-bit), | |
33857 | or whether the thread base pointer must be added. Whether or not this | |
33858 | is valid depends on the operating system, and whether it maps the | |
33859 | segment to cover the entire TLS area. | |
33860 | ||
33861 | For systems that use the GNU C Library, the default is on. | |
33862 | ||
ddf6fe37 | 33863 | @opindex msse2avx |
d77de738 ML |
33864 | @item -msse2avx |
33865 | @itemx -mno-sse2avx | |
d77de738 ML |
33866 | Specify that the assembler should encode SSE instructions with VEX |
33867 | prefix. The option @option{-mavx} turns this on by default. | |
33868 | ||
ddf6fe37 | 33869 | @opindex mfentry |
d77de738 ML |
33870 | @item -mfentry |
33871 | @itemx -mno-fentry | |
d77de738 ML |
33872 | If profiling is active (@option{-pg}), put the profiling |
33873 | counter call before the prologue. | |
33874 | Note: On x86 architectures the attribute @code{ms_hook_prologue} | |
33875 | isn't possible at the moment for @option{-mfentry} and @option{-pg}. | |
33876 | ||
ddf6fe37 | 33877 | @opindex mrecord-mcount |
d77de738 ML |
33878 | @item -mrecord-mcount |
33879 | @itemx -mno-record-mcount | |
d77de738 ML |
33880 | If profiling is active (@option{-pg}), generate a __mcount_loc section |
33881 | that contains pointers to each profiling call. This is useful for | |
33882 | automatically patching and out calls. | |
33883 | ||
ddf6fe37 | 33884 | @opindex mnop-mcount |
d77de738 ML |
33885 | @item -mnop-mcount |
33886 | @itemx -mno-nop-mcount | |
d77de738 ML |
33887 | If profiling is active (@option{-pg}), generate the calls to |
33888 | the profiling functions as NOPs. This is useful when they | |
33889 | should be patched in later dynamically. This is likely only | |
33890 | useful together with @option{-mrecord-mcount}. | |
33891 | ||
d77de738 | 33892 | @opindex minstrument-return |
ddf6fe37 | 33893 | @item -minstrument-return=@var{type} |
d77de738 ML |
33894 | Instrument function exit in -pg -mfentry instrumented functions with |
33895 | call to specified function. This only instruments true returns ending | |
33896 | with ret, but not sibling calls ending with jump. Valid types | |
33897 | are @var{none} to not instrument, @var{call} to generate a call to __return__, | |
33898 | or @var{nop5} to generate a 5 byte nop. | |
33899 | ||
ddf6fe37 | 33900 | @opindex mrecord-return |
d77de738 ML |
33901 | @item -mrecord-return |
33902 | @itemx -mno-record-return | |
d77de738 ML |
33903 | Generate a __return_loc section pointing to all return instrumentation code. |
33904 | ||
d77de738 | 33905 | @opindex mfentry-name |
ddf6fe37 | 33906 | @item -mfentry-name=@var{name} |
d77de738 ML |
33907 | Set name of __fentry__ symbol called at function entry for -pg -mfentry functions. |
33908 | ||
d77de738 | 33909 | @opindex mfentry-section |
ddf6fe37 | 33910 | @item -mfentry-section=@var{name} |
d77de738 ML |
33911 | Set name of section to record -mrecord-mcount calls (default __mcount_loc). |
33912 | ||
ddf6fe37 | 33913 | @opindex mskip-rax-setup |
d77de738 ML |
33914 | @item -mskip-rax-setup |
33915 | @itemx -mno-skip-rax-setup | |
d77de738 ML |
33916 | When generating code for the x86-64 architecture with SSE extensions |
33917 | disabled, @option{-mskip-rax-setup} can be used to skip setting up RAX | |
33918 | register when there are no variable arguments passed in vector registers. | |
33919 | ||
33920 | @strong{Warning:} Since RAX register is used to avoid unnecessarily | |
33921 | saving vector registers on stack when passing variable arguments, the | |
33922 | impacts of this option are callees may waste some stack space, | |
33923 | misbehave or jump to a random location. GCC 4.4 or newer don't have | |
33924 | those issues, regardless the RAX register value. | |
33925 | ||
ddf6fe37 | 33926 | @opindex m8bit-idiv |
d77de738 ML |
33927 | @item -m8bit-idiv |
33928 | @itemx -mno-8bit-idiv | |
d77de738 ML |
33929 | On some processors, like Intel Atom, 8-bit unsigned integer divide is |
33930 | much faster than 32-bit/64-bit integer divide. This option generates a | |
33931 | run-time check. If both dividend and divisor are within range of 0 | |
33932 | to 255, 8-bit unsigned integer divide is used instead of | |
33933 | 32-bit/64-bit integer divide. | |
33934 | ||
d77de738 ML |
33935 | @opindex mavx256-split-unaligned-load |
33936 | @opindex mavx256-split-unaligned-store | |
ddf6fe37 AA |
33937 | @item -mavx256-split-unaligned-load |
33938 | @itemx -mavx256-split-unaligned-store | |
d77de738 ML |
33939 | Split 32-byte AVX unaligned load and store. |
33940 | ||
d77de738 ML |
33941 | @opindex mstack-protector-guard |
33942 | @opindex mstack-protector-guard-reg | |
33943 | @opindex mstack-protector-guard-offset | |
ddf6fe37 AA |
33944 | @item -mstack-protector-guard=@var{guard} |
33945 | @itemx -mstack-protector-guard-reg=@var{reg} | |
33946 | @itemx -mstack-protector-guard-offset=@var{offset} | |
d77de738 ML |
33947 | Generate stack protection code using canary at @var{guard}. Supported |
33948 | locations are @samp{global} for global canary or @samp{tls} for per-thread | |
33949 | canary in the TLS block (the default). This option has effect only when | |
33950 | @option{-fstack-protector} or @option{-fstack-protector-all} is specified. | |
33951 | ||
33952 | With the latter choice the options | |
33953 | @option{-mstack-protector-guard-reg=@var{reg}} and | |
33954 | @option{-mstack-protector-guard-offset=@var{offset}} furthermore specify | |
33955 | which segment register (@code{%fs} or @code{%gs}) to use as base register | |
33956 | for reading the canary, and from what offset from that base register. | |
33957 | The default for those is as specified in the relevant ABI. | |
33958 | ||
d77de738 | 33959 | @opindex mgeneral-regs-only |
ddf6fe37 | 33960 | @item -mgeneral-regs-only |
d77de738 ML |
33961 | Generate code that uses only the general-purpose registers. This |
33962 | prevents the compiler from using floating-point, vector, mask and bound | |
33963 | registers. | |
33964 | ||
d77de738 | 33965 | @opindex mrelax-cmpxchg-loop |
ddf6fe37 | 33966 | @item -mrelax-cmpxchg-loop |
85966f0d AM |
33967 | When emitting a compare-and-swap loop for @ref{__sync Builtins} |
33968 | and @ref{__atomic Builtins} lacking a native instruction, optimize | |
33969 | for the highly contended case by issuing an atomic load before the | |
33970 | @code{CMPXCHG} instruction, and using the @code{PAUSE} instruction | |
33971 | to save CPU power when restarting the loop. | |
d77de738 | 33972 | |
d77de738 | 33973 | @opindex mindirect-branch |
ddf6fe37 | 33974 | @item -mindirect-branch=@var{choice} |
d77de738 ML |
33975 | Convert indirect call and jump with @var{choice}. The default is |
33976 | @samp{keep}, which keeps indirect call and jump unmodified. | |
33977 | @samp{thunk} converts indirect call and jump to call and return thunk. | |
33978 | @samp{thunk-inline} converts indirect call and jump to inlined call | |
33979 | and return thunk. @samp{thunk-extern} converts indirect call and jump | |
33980 | to external call and return thunk provided in a separate object file. | |
33981 | You can control this behavior for a specific function by using the | |
33982 | function attribute @code{indirect_branch}. @xref{Function Attributes}. | |
33983 | ||
33984 | Note that @option{-mcmodel=large} is incompatible with | |
33985 | @option{-mindirect-branch=thunk} and | |
33986 | @option{-mindirect-branch=thunk-extern} since the thunk function may | |
33987 | not be reachable in the large code model. | |
33988 | ||
33989 | Note that @option{-mindirect-branch=thunk-extern} is compatible with | |
33990 | @option{-fcf-protection=branch} since the external thunk can be made | |
33991 | to enable control-flow check. | |
33992 | ||
d77de738 | 33993 | @opindex mfunction-return |
ddf6fe37 | 33994 | @item -mfunction-return=@var{choice} |
d77de738 ML |
33995 | Convert function return with @var{choice}. The default is @samp{keep}, |
33996 | which keeps function return unmodified. @samp{thunk} converts function | |
33997 | return to call and return thunk. @samp{thunk-inline} converts function | |
33998 | return to inlined call and return thunk. @samp{thunk-extern} converts | |
33999 | function return to external call and return thunk provided in a separate | |
34000 | object file. You can control this behavior for a specific function by | |
34001 | using the function attribute @code{function_return}. | |
34002 | @xref{Function Attributes}. | |
34003 | ||
34004 | Note that @option{-mindirect-return=thunk-extern} is compatible with | |
34005 | @option{-fcf-protection=branch} since the external thunk can be made | |
34006 | to enable control-flow check. | |
34007 | ||
34008 | Note that @option{-mcmodel=large} is incompatible with | |
34009 | @option{-mfunction-return=thunk} and | |
34010 | @option{-mfunction-return=thunk-extern} since the thunk function may | |
34011 | not be reachable in the large code model. | |
34012 | ||
34013 | ||
d77de738 | 34014 | @opindex mindirect-branch-register |
ddf6fe37 | 34015 | @item -mindirect-branch-register |
d77de738 ML |
34016 | Force indirect call and jump via register. |
34017 | ||
d77de738 | 34018 | @opindex mharden-sls |
ddf6fe37 | 34019 | @item -mharden-sls=@var{choice} |
d77de738 ML |
34020 | Generate code to mitigate against straight line speculation (SLS) with |
34021 | @var{choice}. The default is @samp{none} which disables all SLS | |
34022 | hardening. @samp{return} enables SLS hardening for function returns. | |
34023 | @samp{indirect-jmp} enables SLS hardening for indirect jumps. | |
34024 | @samp{all} enables all SLS hardening. | |
34025 | ||
d77de738 | 34026 | @opindex mindirect-branch-cs-prefix |
ddf6fe37 | 34027 | @item -mindirect-branch-cs-prefix |
d77de738 ML |
34028 | Add CS prefix to call and jmp to indirect thunk with branch target in |
34029 | r8-r15 registers so that the call and jmp instruction length is 6 bytes | |
34030 | to allow them to be replaced with @samp{lfence; call *%r8-r15} or | |
34031 | @samp{lfence; jmp *%r8-r15} at run-time. | |
34032 | ||
34033 | @end table | |
34034 | ||
34035 | These @samp{-m} switches are supported in addition to the above | |
34036 | on x86-64 processors in 64-bit environments. | |
34037 | ||
34038 | @table @gcctabopt | |
d77de738 ML |
34039 | @opindex m32 |
34040 | @opindex m64 | |
34041 | @opindex mx32 | |
34042 | @opindex m16 | |
34043 | @opindex miamcu | |
ddf6fe37 AA |
34044 | @item -m32 |
34045 | @itemx -m64 | |
34046 | @itemx -mx32 | |
34047 | @itemx -m16 | |
34048 | @itemx -miamcu | |
d77de738 ML |
34049 | Generate code for a 16-bit, 32-bit or 64-bit environment. |
34050 | The @option{-m32} option sets @code{int}, @code{long}, and pointer types | |
34051 | to 32 bits, and | |
34052 | generates code that runs on any i386 system. | |
34053 | ||
34054 | The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer | |
34055 | types to 64 bits, and generates code for the x86-64 architecture. | |
34056 | For Darwin only the @option{-m64} option also turns off the @option{-fno-pic} | |
34057 | and @option{-mdynamic-no-pic} options. | |
34058 | ||
34059 | The @option{-mx32} option sets @code{int}, @code{long}, and pointer types | |
34060 | to 32 bits, and | |
34061 | generates code for the x86-64 architecture. | |
34062 | ||
34063 | The @option{-m16} option is the same as @option{-m32}, except for that | |
34064 | it outputs the @code{.code16gcc} assembly directive at the beginning of | |
34065 | the assembly output so that the binary can run in 16-bit mode. | |
34066 | ||
34067 | The @option{-miamcu} option generates code which conforms to Intel MCU | |
34068 | psABI. It requires the @option{-m32} option to be turned on. | |
34069 | ||
d77de738 ML |
34070 | @opindex mno-red-zone |
34071 | @opindex mred-zone | |
ddf6fe37 | 34072 | @item -mno-red-zone |
d77de738 ML |
34073 | Do not use a so-called ``red zone'' for x86-64 code. The red zone is mandated |
34074 | by the x86-64 ABI; it is a 128-byte area beyond the location of the | |
34075 | stack pointer that is not modified by signal or interrupt handlers | |
34076 | and therefore can be used for temporary data without adjusting the stack | |
34077 | pointer. The flag @option{-mno-red-zone} disables this red zone. | |
34078 | ||
d77de738 | 34079 | @opindex mcmodel=small |
ddf6fe37 | 34080 | @item -mcmodel=small |
d77de738 ML |
34081 | Generate code for the small code model: the program and its symbols must |
34082 | be linked in the lower 2 GB of the address space. Pointers are 64 bits. | |
34083 | Programs can be statically or dynamically linked. This is the default | |
34084 | code model. | |
34085 | ||
d77de738 | 34086 | @opindex mcmodel=kernel |
ddf6fe37 | 34087 | @item -mcmodel=kernel |
d77de738 ML |
34088 | Generate code for the kernel code model. The kernel runs in the |
34089 | negative 2 GB of the address space. | |
34090 | This model has to be used for Linux kernel code. | |
34091 | ||
d77de738 | 34092 | @opindex mcmodel=medium |
ddf6fe37 | 34093 | @item -mcmodel=medium |
d77de738 ML |
34094 | Generate code for the medium model: the program is linked in the lower 2 |
34095 | GB of the address space. Small symbols are also placed there. Symbols | |
34096 | with sizes larger than @option{-mlarge-data-threshold} are put into | |
34097 | large data or BSS sections and can be located above 2GB. Programs can | |
34098 | be statically or dynamically linked. | |
34099 | ||
d77de738 | 34100 | @opindex mcmodel=large |
ddf6fe37 | 34101 | @item -mcmodel=large |
d77de738 ML |
34102 | Generate code for the large model. This model makes no assumptions |
34103 | about addresses and sizes of sections. | |
34104 | ||
d77de738 | 34105 | @opindex maddress-mode=long |
ddf6fe37 | 34106 | @item -maddress-mode=long |
d77de738 ML |
34107 | Generate code for long address mode. This is only supported for 64-bit |
34108 | and x32 environments. It is the default address mode for 64-bit | |
34109 | environments. | |
34110 | ||
d77de738 | 34111 | @opindex maddress-mode=short |
ddf6fe37 | 34112 | @item -maddress-mode=short |
d77de738 ML |
34113 | Generate code for short address mode. This is only supported for 32-bit |
34114 | and x32 environments. It is the default address mode for 32-bit and | |
34115 | x32 environments. | |
34116 | ||
ddf6fe37 | 34117 | @opindex mneeded |
d77de738 ML |
34118 | @item -mneeded |
34119 | @itemx -mno-needed | |
d77de738 ML |
34120 | Emit GNU_PROPERTY_X86_ISA_1_NEEDED GNU property for Linux target to |
34121 | indicate the micro-architecture ISA level required to execute the binary. | |
34122 | ||
d77de738 ML |
34123 | @opindex mno-direct-extern-access |
34124 | @opindex mdirect-extern-access | |
ddf6fe37 | 34125 | @item -mno-direct-extern-access |
d77de738 ML |
34126 | Without @option{-fpic} nor @option{-fPIC}, always use the GOT pointer |
34127 | to access external symbols. With @option{-fpic} or @option{-fPIC}, | |
34128 | treat access to protected symbols as local symbols. The default is | |
34129 | @option{-mdirect-extern-access}. | |
34130 | ||
34131 | @strong{Warning:} shared libraries compiled with | |
34132 | @option{-mno-direct-extern-access} and executable compiled with | |
34133 | @option{-mdirect-extern-access} may not be binary compatible if | |
34134 | protected symbols are used in shared libraries and executable. | |
ce51e843 | 34135 | |
ce51e843 ML |
34136 | @opindex munroll-only-small-loops |
34137 | @opindex mno-unroll-only-small-loops | |
ddf6fe37 | 34138 | @item -munroll-only-small-loops |
ce51e843 ML |
34139 | Controls conservative small loop unrolling. It is default enabled by |
34140 | O2, and unrolls loop with less than 4 insns by 1 time. Explicit | |
34141 | -f[no-]unroll-[all-]loops would disable this flag to avoid any | |
34142 | unintended unrolling behavior that user does not want. | |
bb576017 | 34143 | |
bb576017 | 34144 | @opindex mlam |
ddf6fe37 | 34145 | @item -mlam=@var{choice} |
bb576017 | 34146 | LAM(linear-address masking) allows special bits in the pointer to be used |
34147 | for metadata. The default is @samp{none}. With @samp{u48}, pointer bits in | |
34148 | positions 62:48 can be used for metadata; With @samp{u57}, pointer bits in | |
34149 | positions 62:57 can be used for metadata. | |
d77de738 ML |
34150 | @end table |
34151 | ||
34152 | @node x86 Windows Options | |
34153 | @subsection x86 Windows Options | |
34154 | @cindex x86 Windows Options | |
34155 | @cindex Windows Options for x86 | |
34156 | ||
34157 | These additional options are available for Microsoft Windows targets: | |
34158 | ||
34159 | @table @gcctabopt | |
d77de738 | 34160 | @opindex mconsole |
ddf6fe37 | 34161 | @item -mconsole |
d77de738 ML |
34162 | This option |
34163 | specifies that a console application is to be generated, by | |
34164 | instructing the linker to set the PE header subsystem type | |
34165 | required for console applications. | |
34166 | This option is available for Cygwin and MinGW targets and is | |
34167 | enabled by default on those targets. | |
34168 | ||
d77de738 | 34169 | @opindex mdll |
ddf6fe37 | 34170 | @item -mdll |
d77de738 ML |
34171 | This option is available for Cygwin and MinGW targets. It |
34172 | specifies that a DLL---a dynamic link library---is to be | |
34173 | generated, enabling the selection of the required runtime | |
34174 | startup object and entry point. | |
34175 | ||
d77de738 | 34176 | @opindex mnop-fun-dllimport |
ddf6fe37 | 34177 | @item -mnop-fun-dllimport |
d77de738 ML |
34178 | This option is available for Cygwin and MinGW targets. It |
34179 | specifies that the @code{dllimport} attribute should be ignored. | |
34180 | ||
d77de738 | 34181 | @opindex mthreads |
ddf6fe37 | 34182 | @item -mthreads |
d77de738 ML |
34183 | This option is available for MinGW targets. It specifies |
34184 | that MinGW-specific thread support is to be used. | |
34185 | ||
d77de738 | 34186 | @opindex municode |
ddf6fe37 | 34187 | @item -municode |
d77de738 ML |
34188 | This option is available for MinGW-w64 targets. It causes |
34189 | the @code{UNICODE} preprocessor macro to be predefined, and | |
34190 | chooses Unicode-capable runtime startup code. | |
34191 | ||
d77de738 | 34192 | @opindex mwin32 |
ddf6fe37 | 34193 | @item -mwin32 |
d77de738 ML |
34194 | This option is available for Cygwin and MinGW targets. It |
34195 | specifies that the typical Microsoft Windows predefined macros are to | |
34196 | be set in the pre-processor, but does not influence the choice | |
34197 | of runtime library/startup code. | |
34198 | ||
d77de738 | 34199 | @opindex mwindows |
ddf6fe37 | 34200 | @item -mwindows |
d77de738 ML |
34201 | This option is available for Cygwin and MinGW targets. It |
34202 | specifies that a GUI application is to be generated by | |
34203 | instructing the linker to set the PE header subsystem type | |
34204 | appropriately. | |
34205 | ||
d77de738 ML |
34206 | @opindex fno-set-stack-executable |
34207 | @opindex fset-stack-executable | |
ddf6fe37 | 34208 | @item -fno-set-stack-executable |
d77de738 ML |
34209 | This option is available for MinGW targets. It specifies that |
34210 | the executable flag for the stack used by nested functions isn't | |
34211 | set. This is necessary for binaries running in kernel mode of | |
34212 | Microsoft Windows, as there the User32 API, which is used to set executable | |
34213 | privileges, isn't available. | |
34214 | ||
d77de738 ML |
34215 | @opindex fno-writable-relocated-rdata |
34216 | @opindex fwritable-relocated-rdata | |
ddf6fe37 | 34217 | @item -fwritable-relocated-rdata |
d77de738 ML |
34218 | This option is available for MinGW and Cygwin targets. It specifies |
34219 | that relocated-data in read-only section is put into the @code{.data} | |
34220 | section. This is a necessary for older runtimes not supporting | |
34221 | modification of @code{.rdata} sections for pseudo-relocation. | |
34222 | ||
d77de738 | 34223 | @opindex mpe-aligned-commons |
ddf6fe37 | 34224 | @item -mpe-aligned-commons |
d77de738 ML |
34225 | This option is available for Cygwin and MinGW targets. It |
34226 | specifies that the GNU extension to the PE file format that | |
34227 | permits the correct alignment of COMMON variables should be | |
34228 | used when generating code. It is enabled by default if | |
34229 | GCC detects that the target assembler found during configuration | |
34230 | supports the feature. | |
34231 | @end table | |
34232 | ||
34233 | See also under @ref{x86 Options} for standard options. | |
34234 | ||
34235 | @node Xstormy16 Options | |
34236 | @subsection Xstormy16 Options | |
34237 | @cindex Xstormy16 Options | |
34238 | ||
34239 | These options are defined for Xstormy16: | |
34240 | ||
34241 | @table @gcctabopt | |
d77de738 | 34242 | @opindex msim |
ddf6fe37 | 34243 | @item -msim |
d77de738 ML |
34244 | Choose startup files and linker script suitable for the simulator. |
34245 | @end table | |
34246 | ||
34247 | @node Xtensa Options | |
34248 | @subsection Xtensa Options | |
34249 | @cindex Xtensa Options | |
34250 | ||
34251 | These options are supported for Xtensa targets: | |
34252 | ||
34253 | @table @gcctabopt | |
d77de738 ML |
34254 | @opindex mconst16 |
34255 | @opindex mno-const16 | |
ddf6fe37 AA |
34256 | @item -mconst16 |
34257 | @itemx -mno-const16 | |
d77de738 ML |
34258 | Enable or disable use of @code{CONST16} instructions for loading |
34259 | constant values. The @code{CONST16} instruction is currently not a | |
34260 | standard option from Tensilica. When enabled, @code{CONST16} | |
34261 | instructions are always used in place of the standard @code{L32R} | |
34262 | instructions. The use of @code{CONST16} is enabled by default only if | |
34263 | the @code{L32R} instruction is not available. | |
34264 | ||
d77de738 ML |
34265 | @opindex mfused-madd |
34266 | @opindex mno-fused-madd | |
ddf6fe37 AA |
34267 | @item -mfused-madd |
34268 | @itemx -mno-fused-madd | |
d77de738 ML |
34269 | Enable or disable use of fused multiply/add and multiply/subtract |
34270 | instructions in the floating-point option. This has no effect if the | |
34271 | floating-point option is not also enabled. Disabling fused multiply/add | |
34272 | and multiply/subtract instructions forces the compiler to use separate | |
34273 | instructions for the multiply and add/subtract operations. This may be | |
34274 | desirable in some cases where strict IEEE 754-compliant results are | |
34275 | required: the fused multiply add/subtract instructions do not round the | |
34276 | intermediate result, thereby producing results with @emph{more} bits of | |
34277 | precision than specified by the IEEE standard. Disabling fused multiply | |
34278 | add/subtract instructions also ensures that the program output is not | |
34279 | sensitive to the compiler's ability to combine multiply and add/subtract | |
34280 | operations. | |
34281 | ||
d77de738 ML |
34282 | @opindex mserialize-volatile |
34283 | @opindex mno-serialize-volatile | |
ddf6fe37 AA |
34284 | @item -mserialize-volatile |
34285 | @itemx -mno-serialize-volatile | |
d77de738 ML |
34286 | When this option is enabled, GCC inserts @code{MEMW} instructions before |
34287 | @code{volatile} memory references to guarantee sequential consistency. | |
34288 | The default is @option{-mserialize-volatile}. Use | |
34289 | @option{-mno-serialize-volatile} to omit the @code{MEMW} instructions. | |
34290 | ||
d77de738 | 34291 | @opindex mforce-no-pic |
ddf6fe37 | 34292 | @item -mforce-no-pic |
d77de738 ML |
34293 | For targets, like GNU/Linux, where all user-mode Xtensa code must be |
34294 | position-independent code (PIC), this option disables PIC for compiling | |
34295 | kernel code. | |
34296 | ||
d77de738 ML |
34297 | @opindex mtext-section-literals |
34298 | @opindex mno-text-section-literals | |
ddf6fe37 AA |
34299 | @item -mtext-section-literals |
34300 | @itemx -mno-text-section-literals | |
d77de738 ML |
34301 | These options control the treatment of literal pools. The default is |
34302 | @option{-mno-text-section-literals}, which places literals in a separate | |
34303 | section in the output file. This allows the literal pool to be placed | |
34304 | in a data RAM/ROM, and it also allows the linker to combine literal | |
34305 | pools from separate object files to remove redundant literals and | |
34306 | improve code size. With @option{-mtext-section-literals}, the literals | |
34307 | are interspersed in the text section in order to keep them as close as | |
34308 | possible to their references. This may be necessary for large assembly | |
34309 | files. Literals for each function are placed right before that function. | |
34310 | ||
d77de738 ML |
34311 | @opindex mauto-litpools |
34312 | @opindex mno-auto-litpools | |
ddf6fe37 AA |
34313 | @item -mauto-litpools |
34314 | @itemx -mno-auto-litpools | |
d77de738 ML |
34315 | These options control the treatment of literal pools. The default is |
34316 | @option{-mno-auto-litpools}, which places literals in a separate | |
34317 | section in the output file unless @option{-mtext-section-literals} is | |
34318 | used. With @option{-mauto-litpools} the literals are interspersed in | |
34319 | the text section by the assembler. Compiler does not produce explicit | |
34320 | @code{.literal} directives and loads literals into registers with | |
34321 | @code{MOVI} instructions instead of @code{L32R} to let the assembler | |
34322 | do relaxation and place literals as necessary. This option allows | |
34323 | assembler to create several literal pools per function and assemble | |
34324 | very big functions, which may not be possible with | |
34325 | @option{-mtext-section-literals}. | |
34326 | ||
d77de738 ML |
34327 | @opindex mtarget-align |
34328 | @opindex mno-target-align | |
ddf6fe37 AA |
34329 | @item -mtarget-align |
34330 | @itemx -mno-target-align | |
d77de738 ML |
34331 | When this option is enabled, GCC instructs the assembler to |
34332 | automatically align instructions to reduce branch penalties at the | |
34333 | expense of some code density. The assembler attempts to widen density | |
34334 | instructions to align branch targets and the instructions following call | |
34335 | instructions. If there are not enough preceding safe density | |
34336 | instructions to align a target, no widening is performed. The | |
34337 | default is @option{-mtarget-align}. These options do not affect the | |
34338 | treatment of auto-aligned instructions like @code{LOOP}, which the | |
34339 | assembler always aligns, either by widening density instructions or | |
34340 | by inserting NOP instructions. | |
34341 | ||
d77de738 ML |
34342 | @opindex mlongcalls |
34343 | @opindex mno-longcalls | |
ddf6fe37 AA |
34344 | @item -mlongcalls |
34345 | @itemx -mno-longcalls | |
d77de738 ML |
34346 | When this option is enabled, GCC instructs the assembler to translate |
34347 | direct calls to indirect calls unless it can determine that the target | |
34348 | of a direct call is in the range allowed by the call instruction. This | |
34349 | translation typically occurs for calls to functions in other source | |
34350 | files. Specifically, the assembler translates a direct @code{CALL} | |
34351 | instruction into an @code{L32R} followed by a @code{CALLX} instruction. | |
34352 | The default is @option{-mno-longcalls}. This option should be used in | |
34353 | programs where the call target can potentially be out of range. This | |
34354 | option is implemented in the assembler, not the compiler, so the | |
34355 | assembly code generated by GCC still shows direct call | |
34356 | instructions---look at the disassembled object code to see the actual | |
34357 | instructions. Note that the assembler uses an indirect call for | |
34358 | every cross-file call, not just those that really are out of range. | |
34359 | ||
d77de738 | 34360 | @opindex mabi |
ddf6fe37 | 34361 | @item -mabi=@var{name} |
d77de738 ML |
34362 | Generate code for the specified ABI@. Permissible values are: @samp{call0}, |
34363 | @samp{windowed}. Default ABI is chosen by the Xtensa core configuration. | |
34364 | ||
d77de738 | 34365 | @opindex mabi=call0 |
ddf6fe37 | 34366 | @item -mabi=call0 |
d77de738 ML |
34367 | When this option is enabled function parameters are passed in registers |
34368 | @code{a2} through @code{a7}, registers @code{a12} through @code{a15} are | |
34369 | caller-saved, and register @code{a15} may be used as a frame pointer. | |
34370 | When this version of the ABI is enabled the C preprocessor symbol | |
34371 | @code{__XTENSA_CALL0_ABI__} is defined. | |
34372 | ||
d77de738 | 34373 | @opindex mabi=windowed |
ddf6fe37 | 34374 | @item -mabi=windowed |
d77de738 ML |
34375 | When this option is enabled function parameters are passed in registers |
34376 | @code{a10} through @code{a15}, and called function rotates register window | |
34377 | by 8 registers on entry so that its arguments are found in registers | |
34378 | @code{a2} through @code{a7}. Register @code{a7} may be used as a frame | |
34379 | pointer. Register window is rotated 8 registers back upon return. | |
34380 | When this version of the ABI is enabled the C preprocessor symbol | |
34381 | @code{__XTENSA_WINDOWED_ABI__} is defined. | |
34382 | ||
d77de738 | 34383 | @opindex mextra-l32r-costs |
ddf6fe37 | 34384 | @item -mextra-l32r-costs=@var{n} |
d77de738 ML |
34385 | Specify an extra cost of instruction RAM/ROM access for @code{L32R} |
34386 | instructions, in clock cycles. This affects, when optimizing for speed, | |
34387 | whether loading a constant from literal pool using @code{L32R} or | |
34388 | synthesizing the constant from a small one with a couple of arithmetic | |
34389 | instructions. The default value is 0. | |
34390 | @end table | |
34391 | ||
34392 | @node zSeries Options | |
34393 | @subsection zSeries Options | |
34394 | @cindex zSeries options | |
34395 | ||
34396 | These are listed under @xref{S/390 and zSeries Options}. | |
34397 | ||
34398 | ||
34399 | @c man end | |
34400 | ||
34401 | @node Spec Files | |
34402 | @section Specifying Subprocesses and the Switches to Pass to Them | |
34403 | @cindex Spec Files | |
34404 | ||
34405 | @command{gcc} is a driver program. It performs its job by invoking a | |
34406 | sequence of other programs to do the work of compiling, assembling and | |
34407 | linking. GCC interprets its command-line parameters and uses these to | |
34408 | deduce which programs it should invoke, and which command-line options | |
34409 | it ought to place on their command lines. This behavior is controlled | |
34410 | by @dfn{spec strings}. In most cases there is one spec string for each | |
34411 | program that GCC can invoke, but a few programs have multiple spec | |
34412 | strings to control their behavior. The spec strings built into GCC can | |
34413 | be overridden by using the @option{-specs=} command-line switch to specify | |
34414 | a spec file. | |
34415 | ||
34416 | @dfn{Spec files} are plain-text files that are used to construct spec | |
34417 | strings. They consist of a sequence of directives separated by blank | |
34418 | lines. The type of directive is determined by the first non-whitespace | |
34419 | character on the line, which can be one of the following: | |
34420 | ||
34421 | @table @code | |
34422 | @item %@var{command} | |
34423 | Issues a @var{command} to the spec file processor. The commands that can | |
34424 | appear here are: | |
34425 | ||
34426 | @table @code | |
d77de738 | 34427 | @cindex @code{%include} |
f33d7a88 | 34428 | @item %include <@var{file}> |
d77de738 ML |
34429 | Search for @var{file} and insert its text at the current point in the |
34430 | specs file. | |
34431 | ||
d77de738 | 34432 | @cindex @code{%include_noerr} |
f33d7a88 | 34433 | @item %include_noerr <@var{file}> |
d77de738 ML |
34434 | Just like @samp{%include}, but do not generate an error message if the include |
34435 | file cannot be found. | |
34436 | ||
d77de738 | 34437 | @cindex @code{%rename} |
f33d7a88 | 34438 | @item %rename @var{old_name} @var{new_name} |
d77de738 ML |
34439 | Rename the spec string @var{old_name} to @var{new_name}. |
34440 | ||
34441 | @end table | |
34442 | ||
34443 | @item *[@var{spec_name}]: | |
34444 | This tells the compiler to create, override or delete the named spec | |
34445 | string. All lines after this directive up to the next directive or | |
34446 | blank line are considered to be the text for the spec string. If this | |
34447 | results in an empty string then the spec is deleted. (Or, if the | |
34448 | spec did not exist, then nothing happens.) Otherwise, if the spec | |
34449 | does not currently exist a new spec is created. If the spec does | |
34450 | exist then its contents are overridden by the text of this | |
34451 | directive, unless the first character of that text is the @samp{+} | |
34452 | character, in which case the text is appended to the spec. | |
34453 | ||
34454 | @item [@var{suffix}]: | |
34455 | Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive | |
34456 | and up to the next directive or blank line are considered to make up the | |
34457 | spec string for the indicated suffix. When the compiler encounters an | |
34458 | input file with the named suffix, it processes the spec string in | |
34459 | order to work out how to compile that file. For example: | |
34460 | ||
34461 | @smallexample | |
34462 | .ZZ: | |
34463 | z-compile -input %i | |
34464 | @end smallexample | |
34465 | ||
34466 | This says that any input file whose name ends in @samp{.ZZ} should be | |
34467 | passed to the program @samp{z-compile}, which should be invoked with the | |
34468 | command-line switch @option{-input} and with the result of performing the | |
34469 | @samp{%i} substitution. (See below.) | |
34470 | ||
34471 | As an alternative to providing a spec string, the text following a | |
34472 | suffix directive can be one of the following: | |
34473 | ||
34474 | @table @code | |
34475 | @item @@@var{language} | |
34476 | This says that the suffix is an alias for a known @var{language}. This is | |
34477 | similar to using the @option{-x} command-line switch to GCC to specify a | |
34478 | language explicitly. For example: | |
34479 | ||
34480 | @smallexample | |
34481 | .ZZ: | |
34482 | @@c++ | |
34483 | @end smallexample | |
34484 | ||
34485 | Says that .ZZ files are, in fact, C++ source files. | |
34486 | ||
34487 | @item #@var{name} | |
34488 | This causes an error messages saying: | |
34489 | ||
34490 | @smallexample | |
34491 | @var{name} compiler not installed on this system. | |
34492 | @end smallexample | |
34493 | @end table | |
34494 | ||
34495 | GCC already has an extensive list of suffixes built into it. | |
34496 | This directive adds an entry to the end of the list of suffixes, but | |
34497 | since the list is searched from the end backwards, it is effectively | |
34498 | possible to override earlier entries using this technique. | |
34499 | ||
34500 | @end table | |
34501 | ||
34502 | GCC has the following spec strings built into it. Spec files can | |
34503 | override these strings or create their own. Note that individual | |
34504 | targets can also add their own spec strings to this list. | |
34505 | ||
34506 | @smallexample | |
34507 | asm Options to pass to the assembler | |
34508 | asm_final Options to pass to the assembler post-processor | |
34509 | cpp Options to pass to the C preprocessor | |
34510 | cc1 Options to pass to the C compiler | |
34511 | cc1plus Options to pass to the C++ compiler | |
34512 | endfile Object files to include at the end of the link | |
34513 | link Options to pass to the linker | |
34514 | lib Libraries to include on the command line to the linker | |
34515 | libgcc Decides which GCC support library to pass to the linker | |
34516 | linker Sets the name of the linker | |
34517 | predefines Defines to be passed to the C preprocessor | |
34518 | signed_char Defines to pass to CPP to say whether @code{char} is signed | |
34519 | by default | |
34520 | startfile Object files to include at the start of the link | |
34521 | @end smallexample | |
34522 | ||
34523 | Here is a small example of a spec file: | |
34524 | ||
34525 | @smallexample | |
34526 | %rename lib old_lib | |
34527 | ||
34528 | *lib: | |
34529 | --start-group -lgcc -lc -leval1 --end-group %(old_lib) | |
34530 | @end smallexample | |
34531 | ||
34532 | This example renames the spec called @samp{lib} to @samp{old_lib} and | |
34533 | then overrides the previous definition of @samp{lib} with a new one. | |
34534 | The new definition adds in some extra command-line options before | |
34535 | including the text of the old definition. | |
34536 | ||
34537 | @dfn{Spec strings} are a list of command-line options to be passed to their | |
34538 | corresponding program. In addition, the spec strings can contain | |
34539 | @samp{%}-prefixed sequences to substitute variable text or to | |
34540 | conditionally insert text into the command line. Using these constructs | |
34541 | it is possible to generate quite complex command lines. | |
34542 | ||
34543 | Here is a table of all defined @samp{%}-sequences for spec | |
34544 | strings. Note that spaces are not generated automatically around the | |
34545 | results of expanding these sequences. Therefore you can concatenate them | |
34546 | together or combine them with constant text in a single argument. | |
34547 | ||
34548 | @table @code | |
34549 | @item %% | |
34550 | Substitute one @samp{%} into the program name or argument. | |
34551 | ||
34552 | @item %" | |
34553 | Substitute an empty argument. | |
34554 | ||
34555 | @item %i | |
34556 | Substitute the name of the input file being processed. | |
34557 | ||
34558 | @item %b | |
34559 | Substitute the basename for outputs related with the input file being | |
34560 | processed. This is often the substring up to (and not including) the | |
34561 | last period and not including the directory but, unless %w is active, it | |
34562 | expands to the basename for auxiliary outputs, which may be influenced | |
34563 | by an explicit output name, and by various other options that control | |
34564 | how auxiliary outputs are named. | |
34565 | ||
34566 | @item %B | |
34567 | This is the same as @samp{%b}, but include the file suffix (text after | |
34568 | the last period). Without %w, it expands to the basename for dump | |
34569 | outputs. | |
34570 | ||
34571 | @item %d | |
34572 | Marks the argument containing or following the @samp{%d} as a | |
34573 | temporary file name, so that that file is deleted if GCC exits | |
34574 | successfully. Unlike @samp{%g}, this contributes no text to the | |
34575 | argument. | |
34576 | ||
34577 | @item %g@var{suffix} | |
34578 | Substitute a file name that has suffix @var{suffix} and is chosen | |
34579 | once per compilation, and mark the argument in the same way as | |
34580 | @samp{%d}. To reduce exposure to denial-of-service attacks, the file | |
34581 | name is now chosen in a way that is hard to predict even when previously | |
34582 | chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s} | |
34583 | might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches | |
34584 | the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is | |
34585 | treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g} | |
34586 | was simply substituted with a file name chosen once per compilation, | |
34587 | without regard to any appended suffix (which was therefore treated | |
34588 | just like ordinary text), making such attacks more likely to succeed. | |
34589 | ||
34590 | @item %u@var{suffix} | |
34591 | Like @samp{%g}, but generates a new temporary file name | |
34592 | each time it appears instead of once per compilation. | |
34593 | ||
34594 | @item %U@var{suffix} | |
34595 | Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a | |
34596 | new one if there is no such last file name. In the absence of any | |
34597 | @samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share | |
34598 | the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s} | |
34599 | involves the generation of two distinct file names, one | |
34600 | for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was | |
34601 | simply substituted with a file name chosen for the previous @samp{%u}, | |
34602 | without regard to any appended suffix. | |
34603 | ||
34604 | @item %j@var{suffix} | |
34605 | Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is | |
34606 | writable, and if @option{-save-temps} is not used; | |
34607 | otherwise, substitute the name | |
34608 | of a temporary file, just like @samp{%u}. This temporary file is not | |
34609 | meant for communication between processes, but rather as a junk | |
34610 | disposal mechanism. | |
34611 | ||
34612 | @item %|@var{suffix} | |
34613 | @itemx %m@var{suffix} | |
34614 | Like @samp{%g}, except if @option{-pipe} is in effect. In that case | |
34615 | @samp{%|} substitutes a single dash and @samp{%m} substitutes nothing at | |
34616 | all. These are the two most common ways to instruct a program that it | |
34617 | should read from standard input or write to standard output. If you | |
34618 | need something more elaborate you can use an @samp{%@{pipe:@code{X}@}} | |
34619 | construct: see for example @file{gcc/fortran/lang-specs.h}. | |
34620 | ||
34621 | @item %.@var{SUFFIX} | |
34622 | Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args | |
34623 | when it is subsequently output with @samp{%*}. @var{SUFFIX} is | |
34624 | terminated by the next space or %. | |
34625 | ||
34626 | @item %w | |
34627 | Marks the argument containing or following the @samp{%w} as the | |
34628 | designated output file of this compilation. This puts the argument | |
34629 | into the sequence of arguments that @samp{%o} substitutes. | |
34630 | ||
34631 | @item %V | |
34632 | Indicates that this compilation produces no output file. | |
34633 | ||
34634 | @item %o | |
34635 | Substitutes the names of all the output files, with spaces | |
34636 | automatically placed around them. You should write spaces | |
34637 | around the @samp{%o} as well or the results are undefined. | |
34638 | @samp{%o} is for use in the specs for running the linker. | |
34639 | Input files whose names have no recognized suffix are not compiled | |
34640 | at all, but they are included among the output files, so they are | |
34641 | linked. | |
34642 | ||
34643 | @item %O | |
34644 | Substitutes the suffix for object files. Note that this is | |
34645 | handled specially when it immediately follows @samp{%g, %u, or %U}, | |
34646 | because of the need for those to form complete file names. The | |
34647 | handling is such that @samp{%O} is treated exactly as if it had already | |
34648 | been substituted, except that @samp{%g, %u, and %U} do not currently | |
34649 | support additional @var{suffix} characters following @samp{%O} as they do | |
34650 | following, for example, @samp{.o}. | |
34651 | ||
34652 | @item %I | |
34653 | Substitute any of @option{-iprefix} (made from @env{GCC_EXEC_PREFIX}), | |
34654 | @option{-isysroot} (made from @env{TARGET_SYSTEM_ROOT}), | |
34655 | @option{-isystem} (made from @env{COMPILER_PATH} and @option{-B} options) | |
34656 | and @option{-imultilib} as necessary. | |
34657 | ||
34658 | @item %s | |
34659 | Current argument is the name of a library or startup file of some sort. | |
34660 | Search for that file in a standard list of directories and substitute | |
34661 | the full name found. The current working directory is included in the | |
34662 | list of directories scanned. | |
34663 | ||
34664 | @item %T | |
34665 | Current argument is the name of a linker script. Search for that file | |
34666 | in the current list of directories to scan for libraries. If the file | |
34667 | is located insert a @option{--script} option into the command line | |
34668 | followed by the full path name found. If the file is not found then | |
34669 | generate an error message. Note: the current working directory is not | |
34670 | searched. | |
34671 | ||
34672 | @item %e@var{str} | |
34673 | Print @var{str} as an error message. @var{str} is terminated by a newline. | |
34674 | Use this when inconsistent options are detected. | |
34675 | ||
34676 | @item %n@var{str} | |
34677 | Print @var{str} as a notice. @var{str} is terminated by a newline. | |
34678 | ||
34679 | @item %(@var{name}) | |
34680 | Substitute the contents of spec string @var{name} at this point. | |
34681 | ||
34682 | @item %x@{@var{option}@} | |
34683 | Accumulate an option for @samp{%X}. | |
34684 | ||
34685 | @item %X | |
34686 | Output the accumulated linker options specified by a @samp{%x} spec string. | |
34687 | ||
34688 | @item %Y | |
34689 | Output the accumulated assembler options specified by @option{-Wa}. | |
34690 | ||
34691 | @item %Z | |
34692 | Output the accumulated preprocessor options specified by @option{-Wp}. | |
34693 | ||
34694 | @item %M | |
34695 | Output @code{multilib_os_dir}. | |
34696 | ||
34697 | @item %R | |
34698 | Output the concatenation of @code{target_system_root} and @code{target_sysroot_suffix}. | |
34699 | ||
34700 | @item %a | |
34701 | Process the @code{asm} spec. This is used to compute the | |
34702 | switches to be passed to the assembler. | |
34703 | ||
34704 | @item %A | |
34705 | Process the @code{asm_final} spec. This is a spec string for | |
34706 | passing switches to an assembler post-processor, if such a program is | |
34707 | needed. | |
34708 | ||
34709 | @item %l | |
34710 | Process the @code{link} spec. This is the spec for computing the | |
34711 | command line passed to the linker. Typically it makes use of the | |
34712 | @samp{%L %G %S %D and %E} sequences. | |
34713 | ||
34714 | @item %D | |
34715 | Dump out a @option{-L} option for each directory that GCC believes might | |
34716 | contain startup files. If the target supports multilibs then the | |
34717 | current multilib directory is prepended to each of these paths. | |
34718 | ||
34719 | @item %L | |
34720 | Process the @code{lib} spec. This is a spec string for deciding which | |
34721 | libraries are included on the command line to the linker. | |
34722 | ||
34723 | @item %G | |
34724 | Process the @code{libgcc} spec. This is a spec string for deciding | |
34725 | which GCC support library is included on the command line to the linker. | |
34726 | ||
34727 | @item %S | |
34728 | Process the @code{startfile} spec. This is a spec for deciding which | |
34729 | object files are the first ones passed to the linker. Typically | |
34730 | this might be a file named @file{crt0.o}. | |
34731 | ||
34732 | @item %E | |
34733 | Process the @code{endfile} spec. This is a spec string that specifies | |
34734 | the last object files that are passed to the linker. | |
34735 | ||
34736 | @item %C | |
34737 | Process the @code{cpp} spec. This is used to construct the arguments | |
34738 | to be passed to the C preprocessor. | |
34739 | ||
34740 | @item %1 | |
34741 | Process the @code{cc1} spec. This is used to construct the options to be | |
34742 | passed to the actual C compiler (@command{cc1}). | |
34743 | ||
34744 | @item %2 | |
34745 | Process the @code{cc1plus} spec. This is used to construct the options to be | |
34746 | passed to the actual C++ compiler (@command{cc1plus}). | |
34747 | ||
34748 | @item %* | |
34749 | Substitute the variable part of a matched option. See below. | |
34750 | Note that each comma in the substituted string is replaced by | |
34751 | a single space. | |
34752 | ||
34753 | @item %<S | |
34754 | Remove all occurrences of @code{-S} from the command line. Note---this | |
34755 | command is position dependent. @samp{%} commands in the spec string | |
34756 | before this one see @code{-S}, @samp{%} commands in the spec string | |
34757 | after this one do not. | |
34758 | ||
34759 | @item %<S* | |
34760 | Similar to @samp{%<S}, but match all switches beginning with @code{-S}. | |
34761 | ||
34762 | @item %>S | |
34763 | Similar to @samp{%<S}, but keep @code{-S} in the GCC command line. | |
34764 | ||
34765 | @item %:@var{function}(@var{args}) | |
34766 | Call the named function @var{function}, passing it @var{args}. | |
34767 | @var{args} is first processed as a nested spec string, then split | |
34768 | into an argument vector in the usual fashion. The function returns | |
34769 | a string which is processed as if it had appeared literally as part | |
34770 | of the current spec. | |
34771 | ||
34772 | The following built-in spec functions are provided: | |
34773 | ||
34774 | @table @code | |
34775 | @item @code{getenv} | |
34776 | The @code{getenv} spec function takes two arguments: an environment | |
34777 | variable name and a string. If the environment variable is not | |
34778 | defined, a fatal error is issued. Otherwise, the return value is the | |
34779 | value of the environment variable concatenated with the string. For | |
34780 | example, if @env{TOPDIR} is defined as @file{/path/to/top}, then: | |
34781 | ||
34782 | @smallexample | |
34783 | %:getenv(TOPDIR /include) | |
34784 | @end smallexample | |
34785 | ||
34786 | expands to @file{/path/to/top/include}. | |
34787 | ||
34788 | @item @code{if-exists} | |
34789 | The @code{if-exists} spec function takes one argument, an absolute | |
34790 | pathname to a file. If the file exists, @code{if-exists} returns the | |
34791 | pathname. Here is a small example of its usage: | |
34792 | ||
34793 | @smallexample | |
34794 | *startfile: | |
34795 | crt0%O%s %:if-exists(crti%O%s) crtbegin%O%s | |
34796 | @end smallexample | |
34797 | ||
34798 | @item @code{if-exists-else} | |
34799 | The @code{if-exists-else} spec function is similar to the @code{if-exists} | |
34800 | spec function, except that it takes two arguments. The first argument is | |
34801 | an absolute pathname to a file. If the file exists, @code{if-exists-else} | |
34802 | returns the pathname. If it does not exist, it returns the second argument. | |
34803 | This way, @code{if-exists-else} can be used to select one file or another, | |
34804 | based on the existence of the first. Here is a small example of its usage: | |
34805 | ||
34806 | @smallexample | |
34807 | *startfile: | |
34808 | crt0%O%s %:if-exists(crti%O%s) \ | |
34809 | %:if-exists-else(crtbeginT%O%s crtbegin%O%s) | |
34810 | @end smallexample | |
34811 | ||
34812 | @item @code{if-exists-then-else} | |
34813 | The @code{if-exists-then-else} spec function takes at least two arguments | |
34814 | and an optional third one. The first argument is an absolute pathname to a | |
34815 | file. If the file exists, the function returns the second argument. | |
34816 | If the file does not exist, the function returns the third argument if there | |
34817 | is one, or NULL otherwise. This can be used to expand one text, or optionally | |
34818 | another, based on the existence of a file. Here is a small example of its | |
34819 | usage: | |
34820 | ||
34821 | @smallexample | |
34822 | -l%:if-exists-then-else(%:getenv(VSB_DIR rtnet.h) rtnet net) | |
34823 | @end smallexample | |
34824 | ||
34825 | @item @code{sanitize} | |
34826 | The @code{sanitize} spec function takes no arguments. It returns non-NULL if | |
34827 | any address, thread or undefined behavior sanitizers are active. | |
34828 | ||
34829 | @smallexample | |
34830 | %@{%:sanitize(address):-funwind-tables@} | |
34831 | @end smallexample | |
34832 | ||
34833 | @item @code{replace-outfile} | |
34834 | The @code{replace-outfile} spec function takes two arguments. It looks for the | |
34835 | first argument in the outfiles array and replaces it with the second argument. Here | |
34836 | is a small example of its usage: | |
34837 | ||
34838 | @smallexample | |
34839 | %@{fgnu-runtime:%:replace-outfile(-lobjc -lobjc-gnu)@} | |
34840 | @end smallexample | |
34841 | ||
34842 | @item @code{remove-outfile} | |
34843 | The @code{remove-outfile} spec function takes one argument. It looks for the | |
34844 | first argument in the outfiles array and removes it. Here is a small example | |
34845 | its usage: | |
34846 | ||
34847 | @smallexample | |
34848 | %:remove-outfile(-lm) | |
34849 | @end smallexample | |
34850 | ||
34851 | @item @code{version-compare} | |
34852 | The @code{version-compare} spec function takes four or five arguments of the following | |
34853 | form: | |
34854 | ||
34855 | @smallexample | |
34856 | <comparison-op> <arg1> [<arg2>] <switch> <result> | |
34857 | @end smallexample | |
34858 | ||
34859 | It returns @code{result} if the comparison evaluates to true, and NULL if it doesn't. | |
34860 | The supported @code{comparison-op} values are: | |
34861 | ||
34862 | @table @code | |
34863 | @item >= | |
34864 | True if @code{switch} is a later (or same) version than @code{arg1} | |
34865 | ||
34866 | @item !> | |
34867 | Opposite of @code{>=} | |
34868 | ||
34869 | @item < | |
34870 | True if @code{switch} is an earlier version than @code{arg1} | |
34871 | ||
34872 | @item !< | |
34873 | Opposite of @code{<} | |
34874 | ||
34875 | @item >< | |
34876 | True if @code{switch} is @code{arg1} or later, and earlier than @code{arg2} | |
34877 | ||
34878 | @item <> | |
34879 | True if @code{switch} is earlier than @code{arg1}, or is @code{arg2} or later | |
34880 | @end table | |
34881 | ||
34882 | If the @code{switch} is not present at all, the condition is false unless the first character | |
34883 | of the @code{comparison-op} is @code{!}. | |
34884 | ||
34885 | @smallexample | |
34886 | %:version-compare(>= 10.3 mmacosx-version-min= -lmx) | |
34887 | @end smallexample | |
34888 | ||
34889 | The above example would add @option{-lmx} if @option{-mmacosx-version-min=10.3.9} was | |
34890 | passed. | |
34891 | ||
34892 | @item @code{include} | |
34893 | The @code{include} spec function behaves much like @code{%include}, with the advantage | |
34894 | that it can be nested inside a spec and thus be conditionalized. It takes one argument, | |
34895 | the filename, and looks for it in the startfile path. It always returns NULL. | |
34896 | ||
34897 | @smallexample | |
34898 | %@{static-libasan|static:%:include(libsanitizer.spec)%(link_libasan)@} | |
34899 | @end smallexample | |
34900 | ||
34901 | @item @code{pass-through-libs} | |
34902 | The @code{pass-through-libs} spec function takes any number of arguments. It | |
34903 | finds any @option{-l} options and any non-options ending in @file{.a} (which it | |
34904 | assumes are the names of linker input library archive files) and returns a | |
34905 | result containing all the found arguments each prepended by | |
34906 | @option{-plugin-opt=-pass-through=} and joined by spaces. This list is | |
34907 | intended to be passed to the LTO linker plugin. | |
34908 | ||
34909 | @smallexample | |
34910 | %:pass-through-libs(%G %L %G) | |
34911 | @end smallexample | |
34912 | ||
34913 | @item @code{print-asm-header} | |
34914 | The @code{print-asm-header} function takes no arguments and simply | |
34915 | prints a banner like: | |
34916 | ||
34917 | @smallexample | |
34918 | Assembler options | |
34919 | ================= | |
34920 | ||
34921 | Use "-Wa,OPTION" to pass "OPTION" to the assembler. | |
34922 | @end smallexample | |
34923 | ||
34924 | It is used to separate compiler options from assembler options | |
34925 | in the @option{--target-help} output. | |
34926 | ||
34927 | @item @code{gt} | |
34928 | The @code{gt} spec function takes two or more arguments. It returns @code{""} (the | |
34929 | empty string) if the second-to-last argument is greater than the last argument, and NULL | |
34930 | otherwise. The following example inserts the @code{link_gomp} spec if the last | |
34931 | @option{-ftree-parallelize-loops=} option given on the command line is greater than 1: | |
34932 | ||
34933 | @smallexample | |
34934 | %@{%:gt(%@{ftree-parallelize-loops=*:%*@} 1):%:include(libgomp.spec)%(link_gomp)@} | |
34935 | @end smallexample | |
34936 | ||
34937 | @item @code{debug-level-gt} | |
34938 | The @code{debug-level-gt} spec function takes one argument and returns @code{""} (the | |
34939 | empty string) if @code{debug_info_level} is greater than the specified number, and NULL | |
34940 | otherwise. | |
34941 | ||
34942 | @smallexample | |
34943 | %@{%:debug-level-gt(0):%@{gdwarf*:--gdwarf2@}@} | |
34944 | @end smallexample | |
34945 | @end table | |
34946 | ||
34947 | @item %@{S@} | |
34948 | Substitutes the @code{-S} switch, if that switch is given to GCC@. | |
34949 | If that switch is not specified, this substitutes nothing. Note that | |
34950 | the leading dash is omitted when specifying this option, and it is | |
34951 | automatically inserted if the substitution is performed. Thus the spec | |
34952 | string @samp{%@{foo@}} matches the command-line option @option{-foo} | |
34953 | and outputs the command-line option @option{-foo}. | |
34954 | ||
34955 | @item %W@{S@} | |
34956 | Like %@{@code{S}@} but mark last argument supplied within as a file to be | |
34957 | deleted on failure. | |
34958 | ||
34959 | @item %@@@{S@} | |
34960 | Like %@{@code{S}@} but puts the result into a @code{FILE} and substitutes | |
34961 | @code{@@FILE} if an @code{@@file} argument has been supplied. | |
34962 | ||
34963 | @item %@{S*@} | |
34964 | Substitutes all the switches specified to GCC whose names start | |
34965 | with @code{-S}, but which also take an argument. This is used for | |
34966 | switches like @option{-o}, @option{-D}, @option{-I}, etc. | |
34967 | GCC considers @option{-o foo} as being | |
34968 | one switch whose name starts with @samp{o}. %@{o*@} substitutes this | |
34969 | text, including the space. Thus two arguments are generated. | |
34970 | ||
34971 | @item %@{S*&T*@} | |
34972 | Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options | |
34973 | (the order of @code{S} and @code{T} in the spec is not significant). | |
34974 | There can be any number of ampersand-separated variables; for each the | |
34975 | wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}. | |
34976 | ||
34977 | @item %@{S:X@} | |
34978 | Substitutes @code{X}, if the @option{-S} switch is given to GCC@. | |
34979 | ||
34980 | @item %@{!S:X@} | |
34981 | Substitutes @code{X}, if the @option{-S} switch is @emph{not} given to GCC@. | |
34982 | ||
34983 | @item %@{S*:X@} | |
34984 | Substitutes @code{X} if one or more switches whose names start with | |
34985 | @code{-S} are specified to GCC@. Normally @code{X} is substituted only | |
34986 | once, no matter how many such switches appeared. However, if @code{%*} | |
34987 | appears somewhere in @code{X}, then @code{X} is substituted once | |
34988 | for each matching switch, with the @code{%*} replaced by the part of | |
34989 | that switch matching the @code{*}. | |
34990 | ||
34991 | If @code{%*} appears as the last part of a spec sequence then a space | |
34992 | is added after the end of the last substitution. If there is more | |
34993 | text in the sequence, however, then a space is not generated. This | |
34994 | allows the @code{%*} substitution to be used as part of a larger | |
34995 | string. For example, a spec string like this: | |
34996 | ||
34997 | @smallexample | |
34998 | %@{mcu=*:--script=%*/memory.ld@} | |
34999 | @end smallexample | |
35000 | ||
35001 | @noindent | |
35002 | when matching an option like @option{-mcu=newchip} produces: | |
35003 | ||
35004 | @smallexample | |
35005 | --script=newchip/memory.ld | |
35006 | @end smallexample | |
35007 | ||
35008 | @item %@{.S:X@} | |
35009 | Substitutes @code{X}, if processing a file with suffix @code{S}. | |
35010 | ||
35011 | @item %@{!.S:X@} | |
35012 | Substitutes @code{X}, if @emph{not} processing a file with suffix @code{S}. | |
35013 | ||
35014 | @item %@{,S:X@} | |
35015 | Substitutes @code{X}, if processing a file for language @code{S}. | |
35016 | ||
35017 | @item %@{!,S:X@} | |
35018 | Substitutes @code{X}, if not processing a file for language @code{S}. | |
35019 | ||
35020 | @item %@{S|P:X@} | |
35021 | Substitutes @code{X} if either @code{-S} or @code{-P} is given to | |
35022 | GCC@. This may be combined with @samp{!}, @samp{.}, @samp{,}, and | |
35023 | @code{*} sequences as well, although they have a stronger binding than | |
35024 | the @samp{|}. If @code{%*} appears in @code{X}, all of the | |
35025 | alternatives must be starred, and only the first matching alternative | |
35026 | is substituted. | |
35027 | ||
35028 | For example, a spec string like this: | |
35029 | ||
35030 | @smallexample | |
35031 | %@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@} | |
35032 | @end smallexample | |
35033 | ||
35034 | @noindent | |
35035 | outputs the following command-line options from the following input | |
35036 | command-line options: | |
35037 | ||
35038 | @smallexample | |
35039 | fred.c -foo -baz | |
35040 | jim.d -bar -boggle | |
35041 | -d fred.c -foo -baz -boggle | |
35042 | -d jim.d -bar -baz -boggle | |
35043 | @end smallexample | |
35044 | ||
35045 | @item %@{%:@var{function}(@var{args}):X@} | |
35046 | ||
35047 | Call function named @var{function} with args @var{args}. If the | |
35048 | function returns non-NULL, then @code{X} is substituted, if it returns | |
35049 | NULL, it isn't substituted. | |
35050 | ||
35051 | @item %@{S:X; T:Y; :D@} | |
35052 | ||
35053 | If @code{S} is given to GCC, substitutes @code{X}; else if @code{T} is | |
35054 | given to GCC, substitutes @code{Y}; else substitutes @code{D}. There can | |
35055 | be as many clauses as you need. This may be combined with @code{.}, | |
35056 | @code{,}, @code{!}, @code{|}, and @code{*} as needed. | |
35057 | ||
35058 | ||
35059 | @end table | |
35060 | ||
35061 | The switch matching text @code{S} in a @samp{%@{S@}}, @samp{%@{S:X@}} | |
35062 | or similar construct can use a backslash to ignore the special meaning | |
35063 | of the character following it, thus allowing literal matching of a | |
35064 | character that is otherwise specially treated. For example, | |
35065 | @samp{%@{std=iso9899\:1999:X@}} substitutes @code{X} if the | |
35066 | @option{-std=iso9899:1999} option is given. | |
35067 | ||
35068 | The conditional text @code{X} in a @samp{%@{S:X@}} or similar | |
35069 | construct may contain other nested @samp{%} constructs or spaces, or | |
35070 | even newlines. They are processed as usual, as described above. | |
35071 | Trailing white space in @code{X} is ignored. White space may also | |
35072 | appear anywhere on the left side of the colon in these constructs, | |
35073 | except between @code{.} or @code{*} and the corresponding word. | |
35074 | ||
35075 | The @option{-O}, @option{-f}, @option{-m}, and @option{-W} switches are | |
35076 | handled specifically in these constructs. If another value of | |
35077 | @option{-O} or the negated form of a @option{-f}, @option{-m}, or | |
35078 | @option{-W} switch is found later in the command line, the earlier | |
35079 | switch value is ignored, except with @{@code{S}*@} where @code{S} is | |
35080 | just one letter, which passes all matching options. | |
35081 | ||
35082 | The character @samp{|} at the beginning of the predicate text is used to | |
35083 | indicate that a command should be piped to the following command, but | |
35084 | only if @option{-pipe} is specified. | |
35085 | ||
35086 | It is built into GCC which switches take arguments and which do not. | |
35087 | (You might think it would be useful to generalize this to allow each | |
35088 | compiler's spec to say which switches take arguments. But this cannot | |
35089 | be done in a consistent fashion. GCC cannot even decide which input | |
35090 | files have been specified without knowing which switches take arguments, | |
35091 | and it must know which input files to compile in order to tell which | |
35092 | compilers to run). | |
35093 | ||
35094 | GCC also knows implicitly that arguments starting in @option{-l} are to be | |
35095 | treated as compiler output files, and passed to the linker in their | |
35096 | proper position among the other output files. | |
35097 | ||
35098 | @node Environment Variables | |
35099 | @section Environment Variables Affecting GCC | |
35100 | @cindex environment variables | |
35101 | ||
35102 | @c man begin ENVIRONMENT | |
35103 | This section describes several environment variables that affect how GCC | |
35104 | operates. Some of them work by specifying directories or prefixes to use | |
35105 | when searching for various kinds of files. Some are used to specify other | |
35106 | aspects of the compilation environment. | |
35107 | ||
35108 | Note that you can also specify places to search using options such as | |
35109 | @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These | |
35110 | take precedence over places specified using environment variables, which | |
35111 | in turn take precedence over those specified by the configuration of GCC@. | |
35112 | @xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint, | |
35113 | GNU Compiler Collection (GCC) Internals}. | |
35114 | ||
35115 | @table @env | |
f33d7a88 AA |
35116 | @vindex LANG |
35117 | @vindex LC_CTYPE | |
35118 | @c @vindex LC_COLLATE | |
35119 | @vindex LC_MESSAGES | |
35120 | @c @vindex LC_MONETARY | |
35121 | @c @vindex LC_NUMERIC | |
35122 | @c @vindex LC_TIME | |
35123 | @vindex LC_ALL | |
35124 | @cindex locale | |
d77de738 ML |
35125 | @item LANG |
35126 | @itemx LC_CTYPE | |
35127 | @c @itemx LC_COLLATE | |
35128 | @itemx LC_MESSAGES | |
35129 | @c @itemx LC_MONETARY | |
35130 | @c @itemx LC_NUMERIC | |
35131 | @c @itemx LC_TIME | |
35132 | @itemx LC_ALL | |
d77de738 ML |
35133 | These environment variables control the way that GCC uses |
35134 | localization information which allows GCC to work with different | |
35135 | national conventions. GCC inspects the locale categories | |
35136 | @env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do | |
35137 | so. These locale categories can be set to any value supported by your | |
35138 | installation. A typical value is @samp{en_GB.UTF-8} for English in the United | |
35139 | Kingdom encoded in UTF-8. | |
35140 | ||
35141 | The @env{LC_CTYPE} environment variable specifies character | |
35142 | classification. GCC uses it to determine the character boundaries in | |
35143 | a string; this is needed for some multibyte encodings that contain quote | |
35144 | and escape characters that are otherwise interpreted as a string | |
35145 | end or escape. | |
35146 | ||
35147 | The @env{LC_MESSAGES} environment variable specifies the language to | |
35148 | use in diagnostic messages. | |
35149 | ||
35150 | If the @env{LC_ALL} environment variable is set, it overrides the value | |
35151 | of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE} | |
35152 | and @env{LC_MESSAGES} default to the value of the @env{LANG} | |
35153 | environment variable. If none of these variables are set, GCC | |
35154 | defaults to traditional C English behavior. | |
35155 | ||
f33d7a88 | 35156 | @vindex TMPDIR |
d77de738 | 35157 | @item TMPDIR |
d77de738 ML |
35158 | If @env{TMPDIR} is set, it specifies the directory to use for temporary |
35159 | files. GCC uses temporary files to hold the output of one stage of | |
35160 | compilation which is to be used as input to the next stage: for example, | |
35161 | the output of the preprocessor, which is the input to the compiler | |
35162 | proper. | |
35163 | ||
f33d7a88 | 35164 | @vindex GCC_COMPARE_DEBUG |
d77de738 | 35165 | @item GCC_COMPARE_DEBUG |
d77de738 ML |
35166 | Setting @env{GCC_COMPARE_DEBUG} is nearly equivalent to passing |
35167 | @option{-fcompare-debug} to the compiler driver. See the documentation | |
35168 | of this option for more details. | |
35169 | ||
f33d7a88 | 35170 | @vindex GCC_EXEC_PREFIX |
d77de738 | 35171 | @item GCC_EXEC_PREFIX |
d77de738 ML |
35172 | If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the |
35173 | names of the subprograms executed by the compiler. No slash is added | |
35174 | when this prefix is combined with the name of a subprogram, but you can | |
35175 | specify a prefix that ends with a slash if you wish. | |
35176 | ||
35177 | If @env{GCC_EXEC_PREFIX} is not set, GCC attempts to figure out | |
35178 | an appropriate prefix to use based on the pathname it is invoked with. | |
35179 | ||
35180 | If GCC cannot find the subprogram using the specified prefix, it | |
35181 | tries looking in the usual places for the subprogram. | |
35182 | ||
35183 | The default value of @env{GCC_EXEC_PREFIX} is | |
35184 | @file{@var{prefix}/lib/gcc/} where @var{prefix} is the prefix to | |
35185 | the installed compiler. In many cases @var{prefix} is the value | |
35186 | of @code{prefix} when you ran the @file{configure} script. | |
35187 | ||
35188 | Other prefixes specified with @option{-B} take precedence over this prefix. | |
35189 | ||
35190 | This prefix is also used for finding files such as @file{crt0.o} that are | |
35191 | used for linking. | |
35192 | ||
35193 | In addition, the prefix is used in an unusual way in finding the | |
35194 | directories to search for header files. For each of the standard | |
35195 | directories whose name normally begins with @samp{/usr/local/lib/gcc} | |
35196 | (more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries | |
35197 | replacing that beginning with the specified prefix to produce an | |
35198 | alternate directory name. Thus, with @option{-Bfoo/}, GCC searches | |
35199 | @file{foo/bar} just before it searches the standard directory | |
35200 | @file{/usr/local/lib/bar}. | |
35201 | If a standard directory begins with the configured | |
35202 | @var{prefix} then the value of @var{prefix} is replaced by | |
35203 | @env{GCC_EXEC_PREFIX} when looking for header files. | |
35204 | ||
f33d7a88 | 35205 | @vindex COMPILER_PATH |
d77de738 | 35206 | @item COMPILER_PATH |
d77de738 ML |
35207 | The value of @env{COMPILER_PATH} is a colon-separated list of |
35208 | directories, much like @env{PATH}. GCC tries the directories thus | |
35209 | specified when searching for subprograms, if it cannot find the | |
35210 | subprograms using @env{GCC_EXEC_PREFIX}. | |
35211 | ||
f33d7a88 | 35212 | @vindex LIBRARY_PATH |
d77de738 | 35213 | @item LIBRARY_PATH |
d77de738 ML |
35214 | The value of @env{LIBRARY_PATH} is a colon-separated list of |
35215 | directories, much like @env{PATH}. When configured as a native compiler, | |
35216 | GCC tries the directories thus specified when searching for special | |
35217 | linker files, if it cannot find them using @env{GCC_EXEC_PREFIX}. Linking | |
35218 | using GCC also uses these directories when searching for ordinary | |
35219 | libraries for the @option{-l} option (but directories specified with | |
35220 | @option{-L} come first). | |
35221 | ||
f33d7a88 | 35222 | @vindex LANG |
d77de738 | 35223 | @cindex locale definition |
f33d7a88 | 35224 | @item LANG |
d77de738 ML |
35225 | This variable is used to pass locale information to the compiler. One way in |
35226 | which this information is used is to determine the character set to be used | |
35227 | when character literals, string literals and comments are parsed in C and C++. | |
35228 | When the compiler is configured to allow multibyte characters, | |
35229 | the following values for @env{LANG} are recognized: | |
35230 | ||
35231 | @table @samp | |
35232 | @item C-JIS | |
35233 | Recognize JIS characters. | |
35234 | @item C-SJIS | |
35235 | Recognize SJIS characters. | |
35236 | @item C-EUCJP | |
35237 | Recognize EUCJP characters. | |
35238 | @end table | |
35239 | ||
35240 | If @env{LANG} is not defined, or if it has some other value, then the | |
35241 | compiler uses @code{mblen} and @code{mbtowc} as defined by the default locale to | |
35242 | recognize and translate multibyte characters. | |
35243 | ||
f33d7a88 | 35244 | @vindex GCC_EXTRA_DIAGNOSTIC_OUTPUT |
d77de738 | 35245 | @item GCC_EXTRA_DIAGNOSTIC_OUTPUT |
d77de738 ML |
35246 | If @env{GCC_EXTRA_DIAGNOSTIC_OUTPUT} is set to one of the following values, |
35247 | then additional text will be emitted to stderr when fix-it hints are | |
35248 | emitted. @option{-fdiagnostics-parseable-fixits} and | |
35249 | @option{-fno-diagnostics-parseable-fixits} take precedence over this | |
35250 | environment variable. | |
35251 | ||
35252 | @table @samp | |
35253 | @item fixits-v1 | |
35254 | Emit parseable fix-it hints, equivalent to | |
35255 | @option{-fdiagnostics-parseable-fixits}. In particular, columns are | |
35256 | expressed as a count of bytes, starting at byte 1 for the initial column. | |
35257 | ||
35258 | @item fixits-v2 | |
35259 | As @code{fixits-v1}, but columns are expressed as display columns, | |
35260 | as per @option{-fdiagnostics-column-unit=display}. | |
35261 | @end table | |
35262 | ||
35263 | @end table | |
35264 | ||
35265 | @noindent | |
35266 | Some additional environment variables affect the behavior of the | |
35267 | preprocessor. | |
35268 | ||
35269 | @include cppenv.texi | |
35270 | ||
35271 | @c man end | |
35272 | ||
35273 | @node Precompiled Headers | |
35274 | @section Using Precompiled Headers | |
35275 | @cindex precompiled headers | |
35276 | @cindex speed of compilation | |
35277 | ||
35278 | Often large projects have many header files that are included in every | |
35279 | source file. The time the compiler takes to process these header files | |
35280 | over and over again can account for nearly all of the time required to | |
35281 | build the project. To make builds faster, GCC allows you to | |
35282 | @dfn{precompile} a header file. | |
35283 | ||
35284 | To create a precompiled header file, simply compile it as you would any | |
35285 | other file, if necessary using the @option{-x} option to make the driver | |
35286 | treat it as a C or C++ header file. You may want to use a | |
35287 | tool like @command{make} to keep the precompiled header up-to-date when | |
35288 | the headers it contains change. | |
35289 | ||
35290 | A precompiled header file is searched for when @code{#include} is | |
35291 | seen in the compilation. As it searches for the included file | |
35292 | (@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the | |
35293 | compiler looks for a precompiled header in each directory just before it | |
35294 | looks for the include file in that directory. The name searched for is | |
35295 | the name specified in the @code{#include} with @samp{.gch} appended. If | |
35296 | the precompiled header file cannot be used, it is ignored. | |
35297 | ||
35298 | For instance, if you have @code{#include "all.h"}, and you have | |
35299 | @file{all.h.gch} in the same directory as @file{all.h}, then the | |
35300 | precompiled header file is used if possible, and the original | |
35301 | header is used otherwise. | |
35302 | ||
35303 | Alternatively, you might decide to put the precompiled header file in a | |
35304 | directory and use @option{-I} to ensure that directory is searched | |
35305 | before (or instead of) the directory containing the original header. | |
35306 | Then, if you want to check that the precompiled header file is always | |
35307 | used, you can put a file of the same name as the original header in this | |
35308 | directory containing an @code{#error} command. | |
35309 | ||
35310 | This also works with @option{-include}. So yet another way to use | |
35311 | precompiled headers, good for projects not designed with precompiled | |
35312 | header files in mind, is to simply take most of the header files used by | |
35313 | a project, include them from another header file, precompile that header | |
35314 | file, and @option{-include} the precompiled header. If the header files | |
35315 | have guards against multiple inclusion, they are skipped because | |
35316 | they've already been included (in the precompiled header). | |
35317 | ||
35318 | If you need to precompile the same header file for different | |
35319 | languages, targets, or compiler options, you can instead make a | |
35320 | @emph{directory} named like @file{all.h.gch}, and put each precompiled | |
35321 | header in the directory, perhaps using @option{-o}. It doesn't matter | |
35322 | what you call the files in the directory; every precompiled header in | |
35323 | the directory is considered. The first precompiled header | |
35324 | encountered in the directory that is valid for this compilation is | |
35325 | used; they're searched in no particular order. | |
35326 | ||
35327 | There are many other possibilities, limited only by your imagination, | |
35328 | good sense, and the constraints of your build system. | |
35329 | ||
35330 | A precompiled header file can be used only when these conditions apply: | |
35331 | ||
35332 | @itemize | |
35333 | @item | |
35334 | Only one precompiled header can be used in a particular compilation. | |
35335 | ||
35336 | @item | |
35337 | A precompiled header cannot be used once the first C token is seen. You | |
35338 | can have preprocessor directives before a precompiled header; you cannot | |
35339 | include a precompiled header from inside another header. | |
35340 | ||
35341 | @item | |
35342 | The precompiled header file must be produced for the same language as | |
35343 | the current compilation. You cannot use a C precompiled header for a C++ | |
35344 | compilation. | |
35345 | ||
35346 | @item | |
35347 | The precompiled header file must have been produced by the same compiler | |
35348 | binary as the current compilation is using. | |
35349 | ||
35350 | @item | |
35351 | Any macros defined before the precompiled header is included must | |
35352 | either be defined in the same way as when the precompiled header was | |
35353 | generated, or must not affect the precompiled header, which usually | |
35354 | means that they don't appear in the precompiled header at all. | |
35355 | ||
35356 | The @option{-D} option is one way to define a macro before a | |
35357 | precompiled header is included; using a @code{#define} can also do it. | |
35358 | There are also some options that define macros implicitly, like | |
35359 | @option{-O} and @option{-Wdeprecated}; the same rule applies to macros | |
35360 | defined this way. | |
35361 | ||
35362 | @item If debugging information is output when using the precompiled | |
35363 | header, using @option{-g} or similar, the same kind of debugging information | |
35364 | must have been output when building the precompiled header. However, | |
35365 | a precompiled header built using @option{-g} can be used in a compilation | |
35366 | when no debugging information is being output. | |
35367 | ||
35368 | @item The same @option{-m} options must generally be used when building | |
35369 | and using the precompiled header. @xref{Submodel Options}, | |
35370 | for any cases where this rule is relaxed. | |
35371 | ||
35372 | @item Each of the following options must be the same when building and using | |
35373 | the precompiled header: | |
35374 | ||
35375 | @gccoptlist{-fexceptions} | |
35376 | ||
35377 | @item | |
35378 | Some other command-line options starting with @option{-f}, | |
35379 | @option{-p}, or @option{-O} must be defined in the same way as when | |
35380 | the precompiled header was generated. At present, it's not clear | |
35381 | which options are safe to change and which are not; the safest choice | |
35382 | is to use exactly the same options when generating and using the | |
35383 | precompiled header. The following are known to be safe: | |
35384 | ||
43b72ede AA |
35385 | @gccoptlist{-fmessage-length= -fpreprocessed -fsched-interblock |
35386 | -fsched-spec -fsched-spec-load -fsched-spec-load-dangerous | |
35387 | -fsched-verbose=@var{number} -fschedule-insns -fvisibility= | |
d77de738 ML |
35388 | -pedantic-errors} |
35389 | ||
35390 | @item Address space layout randomization (ASLR) can lead to not binary identical | |
35391 | PCH files. If you rely on stable PCH file contents disable ASLR when generating | |
35392 | PCH files. | |
35393 | ||
35394 | @end itemize | |
35395 | ||
35396 | For all of these except the last, the compiler automatically | |
35397 | ignores the precompiled header if the conditions aren't met. If you | |
35398 | find an option combination that doesn't work and doesn't cause the | |
35399 | precompiled header to be ignored, please consider filing a bug report, | |
35400 | see @ref{Bugs}. | |
35401 | ||
35402 | If you do use differing options when generating and using the | |
35403 | precompiled header, the actual behavior is a mixture of the | |
35404 | behavior for the options. For instance, if you use @option{-g} to | |
35405 | generate the precompiled header but not when using it, you may or may | |
35406 | not get debugging information for routines in the precompiled header. | |
35407 | ||
35408 | @node C++ Modules | |
35409 | @section C++ Modules | |
35410 | @cindex speed of compilation | |
35411 | ||
35412 | Modules are a C++20 language feature. As the name suggests, they | |
35413 | provides a modular compilation system, intending to provide both | |
35414 | faster builds and better library isolation. The ``Merging Modules'' | |
35415 | paper @uref{https://wg21.link/p1103}, provides the easiest to read set | |
35416 | of changes to the standard, although it does not capture later | |
35417 | changes. | |
35418 | ||
35419 | @emph{G++'s modules support is not complete.} Other than bugs, the | |
35420 | known missing pieces are: | |
35421 | ||
35422 | @table @emph | |
35423 | ||
35424 | @item Private Module Fragment | |
35425 | The Private Module Fragment is recognized, but an error is emitted. | |
35426 | ||
35427 | @item Partition definition visibility rules | |
35428 | Entities may be defined in implementation partitions, and those | |
35429 | definitions are not available outside of the module. This is not | |
35430 | implemented, and the definitions are available to extra-module use. | |
35431 | ||
35432 | @item Textual merging of reachable GM entities | |
35433 | Entities may be multiply defined across different header-units. | |
35434 | These must be de-duplicated, and this is implemented across imports, | |
35435 | or when an import redefines a textually-defined entity. However the | |
35436 | reverse is not implemented---textually redefining an entity that has | |
35437 | been defined in an imported header-unit. A redefinition error is | |
35438 | emitted. | |
35439 | ||
35440 | @item Translation-Unit local referencing rules | |
35441 | Papers p1815 (@uref{https://wg21.link/p1815}) and p2003 | |
35442 | (@uref{https://wg21.link/p2003}) add limitations on which entities an | |
35443 | exported region may reference (for instance, the entities an exported | |
35444 | template definition may reference). These are not fully implemented. | |
35445 | ||
35446 | @item Standard Library Header Units | |
35447 | The Standard Library is not provided as importable header units. If | |
35448 | you want to import such units, you must explicitly build them first. | |
35449 | If you do not do this with care, you may have multiple declarations, | |
35450 | which the module machinery must merge---compiler resource usage can be | |
35451 | affected by how you partition header files into header units. | |
35452 | ||
35453 | @end table | |
35454 | ||
35455 | Modular compilation is @emph{not} enabled with just the | |
35456 | @option{-std=c++20} option. You must explicitly enable it with the | |
35457 | @option{-fmodules-ts} option. It is independent of the language | |
35458 | version selected, although in pre-C++20 versions, it is of course an | |
35459 | extension. | |
35460 | ||
35461 | No new source file suffixes are required or supported. If you wish to | |
35462 | use a non-standard suffix (@pxref{Overall Options}), you also need | |
35463 | to provide a @option{-x c++} option too.@footnote{Some users like to | |
35464 | distinguish module interface files with a new suffix, such as naming | |
35465 | the source @code{module.cppm}, which involves | |
35466 | teaching all tools about the new suffix. A different scheme, such as | |
35467 | naming @code{module-m.cpp} would be less invasive.} | |
35468 | ||
35469 | Compiling a module interface unit produces an additional output (to | |
35470 | the assembly or object file), called a Compiled Module Interface | |
35471 | (CMI). This encodes the exported declarations of the module. | |
35472 | Importing a module reads in the CMI. The import graph is a Directed | |
35473 | Acyclic Graph (DAG). You must build imports before the importer. | |
35474 | ||
35475 | Header files may themselves be compiled to header units, which are a | |
35476 | transitional ability aiming at faster compilation. The | |
35477 | @option{-fmodule-header} option is used to enable this, and implies | |
35478 | the @option{-fmodules-ts} option. These CMIs are named by the fully | |
35479 | resolved underlying header file, and thus may be a complete pathname | |
35480 | containing subdirectories. If the header file is found at an absolute | |
35481 | pathname, the CMI location is still relative to a CMI root directory. | |
35482 | ||
35483 | As header files often have no suffix, you commonly have to specify a | |
35484 | @option{-x} option to tell the compiler the source is a header file. | |
35485 | You may use @option{-x c++-header}, @option{-x c++-user-header} or | |
35486 | @option{-x c++-system-header}. When used in conjunction with | |
35487 | @option{-fmodules-ts}, these all imply an appropriate | |
35488 | @option{-fmodule-header} option. The latter two variants use the | |
35489 | user or system include path to search for the file specified. This | |
35490 | allows you to, for instance, compile standard library header files as | |
35491 | header units, without needing to know exactly where they are | |
35492 | installed. Specifying the language as one of these variants also | |
35493 | inhibits output of the object file, as header files have no associated | |
35494 | object file. | |
35495 | ||
35496 | The @option{-fmodule-only} option disables generation of the | |
35497 | associated object file for compiling a module interface. Only the CMI | |
35498 | is generated. This option is implied when using the | |
35499 | @option{-fmodule-header} option. | |
35500 | ||
35501 | The @option{-flang-info-include-translate} and | |
35502 | @option{-flang-info-include-translate-not} options notes whether | |
35503 | include translation occurs or not. With no argument, the first will | |
35504 | note all include translation. The second will note all | |
35505 | non-translations of include files not known to intentionally be | |
35506 | textual. With an argument, queries about include translation of a | |
35507 | header files with that particular trailing pathname are noted. You | |
35508 | may repeat this form to cover several different header files. This | |
35509 | option may be helpful in determining whether include translation is | |
35510 | happening---if it is working correctly, it behaves as if it isn't | |
35511 | there at all. | |
35512 | ||
35513 | The @option{-flang-info-module-cmi} option can be used to determine | |
35514 | where the compiler is reading a CMI from. Without the option, the | |
35515 | compiler is silent when such a read is successful. This option has an | |
35516 | optional argument, which will restrict the notification to just the | |
35517 | set of named modules or header units specified. | |
35518 | ||
35519 | The @option{-Winvalid-imported-macros} option causes all imported macros | |
35520 | to be resolved at the end of compilation. Without this, imported | |
35521 | macros are only resolved when expanded or (re)defined. This option | |
35522 | detects conflicting import definitions for all macros. | |
35523 | ||
35524 | For details of the @option{-fmodule-mapper} family of options, | |
35525 | @pxref{C++ Module Mapper}. | |
35526 | ||
35527 | @menu | |
35528 | * C++ Module Mapper:: Module Mapper | |
35529 | * C++ Module Preprocessing:: Module Preprocessing | |
35530 | * C++ Compiled Module Interface:: Compiled Module Interface | |
35531 | @end menu | |
35532 | ||
35533 | @node C++ Module Mapper | |
35534 | @subsection Module Mapper | |
35535 | @cindex C++ Module Mapper | |
35536 | ||
35537 | A module mapper provides a server or file that the compiler queries to | |
35538 | determine the mapping between module names and CMI files. It is also | |
35539 | used to build CMIs on demand. @emph{Mapper functionality is in its | |
35540 | infancy and is intended for experimentation with build system | |
35541 | interactions.} | |
35542 | ||
35543 | You can specify a mapper with the @option{-fmodule-mapper=@var{val}} | |
35544 | option or @env{CXX_MODULE_MAPPER} environment variable. The value may | |
35545 | have one of the following forms: | |
35546 | ||
35547 | @table @gcctabopt | |
35548 | ||
35549 | @item @r{[}@var{hostname}@r{]}:@var{port}@r{[}?@var{ident}@r{]} | |
35550 | An optional hostname and a numeric port number to connect to. If the | |
35551 | hostname is omitted, the loopback address is used. If the hostname | |
35552 | corresponds to multiple IPV6 addresses, these are tried in turn, until | |
35553 | one is successful. If your host lacks IPv6, this form is | |
35554 | non-functional. If you must use IPv4 use | |
35555 | @option{-fmodule-mapper='|ncat @var{ipv4host} @var{port}'}. | |
35556 | ||
35557 | @item =@var{socket}@r{[}?@var{ident}@r{]} | |
35558 | A local domain socket. If your host lacks local domain sockets, this | |
35559 | form is non-functional. | |
35560 | ||
35561 | @item |@var{program}@r{[}?@var{ident}@r{]} @r{[}@var{args...}@r{]} | |
35562 | A program to spawn, and communicate with on its stdin/stdout streams. | |
35563 | Your @var{PATH} environment variable is searched for the program. | |
35564 | Arguments are separated by space characters, (it is not possible for | |
35565 | one of the arguments delivered to the program to contain a space). An | |
35566 | exception is if @var{program} begins with @@. In that case | |
35567 | @var{program} (sans @@) is looked for in the compiler's internal | |
35568 | binary directory. Thus the sample mapper-server can be specified | |
35569 | with @code{@@g++-mapper-server}. | |
35570 | ||
35571 | @item <>@r{[}?@var{ident}@r{]} | |
35572 | @item <>@var{inout}@r{[}?@var{ident}@r{]} | |
35573 | @item <@var{in}>@var{out}@r{[}?@var{ident}@r{]} | |
35574 | Named pipes or file descriptors to communicate over. The first form, | |
35575 | @option{<>}, communicates over stdin and stdout. The other forms | |
35576 | allow you to specify a file descriptor or name a pipe. A numeric value | |
35577 | is interpreted as a file descriptor, otherwise named pipe is opened. | |
35578 | The second form specifies a bidirectional pipe and the last form | |
35579 | allows specifying two independent pipes. Using file descriptors | |
35580 | directly in this manner is fragile in general, as it can require the | |
35581 | cooperation of intermediate processes. In particular using stdin & | |
35582 | stdout is fraught with danger as other compiler options might also | |
35583 | cause the compiler to read stdin or write stdout, and it can have | |
35584 | unfortunate interactions with signal delivery from the terminal. | |
35585 | ||
35586 | @item @var{file}@r{[}?@var{ident}@r{]} | |
35587 | A mapping file consisting of space-separated module-name, filename | |
35588 | pairs, one per line. Only the mappings for the direct imports and any | |
35589 | module export name need be provided. If other mappings are provided, | |
35590 | they override those stored in any imported CMI files. A repository | |
35591 | root may be specified in the mapping file by using @samp{$root} as the | |
35592 | module name in the first active line. Use of this option will disable | |
35593 | any default module->CMI name mapping. | |
35594 | ||
35595 | @end table | |
35596 | ||
35597 | As shown, an optional @var{ident} may suffix the first word of the | |
35598 | option, indicated by a @samp{?} prefix. The value is used in the | |
35599 | initial handshake with the module server, or to specify a prefix on | |
35600 | mapping file lines. In the server case, the main source file name is | |
35601 | used if no @var{ident} is specified. In the file case, all non-blank | |
35602 | lines are significant, unless a value is specified, in which case only | |
35603 | lines beginning with @var{ident} are significant. The @var{ident} | |
35604 | must be separated by whitespace from the module name. Be aware that | |
35605 | @samp{<}, @samp{>}, @samp{?}, and @samp{|} characters are often | |
35606 | significant to the shell, and therefore may need quoting. | |
35607 | ||
35608 | The mapper is connected to or loaded lazily, when the first module | |
35609 | mapping is required. The networking protocols are only supported on | |
35610 | hosts that provide networking. If no mapper is specified a default is | |
35611 | provided. | |
35612 | ||
35613 | A project-specific mapper is expected to be provided by the build | |
35614 | system that invokes the compiler. It is not expected that a | |
35615 | general-purpose server is provided for all compilations. As such, the | |
35616 | server will know the build configuration, the compiler it invoked, and | |
35617 | the environment (such as working directory) in which that is | |
35618 | operating. As it may parallelize builds, several compilations may | |
35619 | connect to the same socket. | |
35620 | ||
35621 | The default mapper generates CMI files in a @samp{gcm.cache} | |
35622 | directory. CMI files have a @samp{.gcm} suffix. The module unit name | |
35623 | is used directly to provide the basename. Header units construct a | |
35624 | relative path using the underlying header file name. If the path is | |
35625 | already relative, a @samp{,} directory is prepended. Internal | |
35626 | @samp{..} components are translated to @samp{,,}. No attempt is made | |
35627 | to canonicalize these filenames beyond that done by the preprocessor's | |
35628 | include search algorithm, as in general it is ambiguous when symbolic | |
35629 | links are present. | |
35630 | ||
35631 | The mapper protocol was published as ``A Module Mapper'' | |
35632 | @uref{https://wg21.link/p1184}. The implementation is provided by | |
35633 | @command{libcody}, @uref{https://github.com/urnathan/libcody}, | |
35634 | which specifies the canonical protocol definition. A proof of concept | |
35635 | server implementation embedded in @command{make} was described in | |
35636 | ''Make Me A Module'', @uref{https://wg21.link/p1602}. | |
35637 | ||
35638 | @node C++ Module Preprocessing | |
35639 | @subsection Module Preprocessing | |
35640 | @cindex C++ Module Preprocessing | |
35641 | ||
35642 | Modules affect preprocessing because of header units and include | |
35643 | translation. Some uses of the preprocessor as a separate step either | |
35644 | do not produce a correct output, or require CMIs to be available. | |
35645 | ||
35646 | Header units import macros. These macros can affect later conditional | |
35647 | inclusion, which therefore can cascade to differing import sets. When | |
35648 | preprocessing, it is necessary to load the CMI. If a header unit is | |
35649 | unavailable, the preprocessor issues a warning and continue (when | |
35650 | not just preprocessing, an error is emitted). Detecting such imports | |
35651 | requires preprocessor tokenization of the input stream to phase 4 | |
35652 | (macro expansion). | |
35653 | ||
35654 | Include translation converts @code{#include}, @code{#include_next} and | |
35655 | @code{#import} directives to internal @code{import} declarations. | |
35656 | Whether a particular directive is translated is controlled by the | |
35657 | module mapper. Header unit names are canonicalized during | |
35658 | preprocessing. | |
35659 | ||
35660 | Dependency information can be emitted for macro import, extending the | |
35661 | functionality of @option{-MD} and @option{-MMD} options. Detection of | |
35662 | import declarations also requires phase 4 preprocessing, and thus | |
35663 | requires full preprocessing (or compilation). | |
35664 | ||
35665 | The @option{-M}, @option{-MM} and @option{-E -fdirectives-only} options halt | |
35666 | preprocessing before phase 4. | |
35667 | ||
35668 | The @option{-save-temps} option uses @option{-fdirectives-only} for | |
35669 | preprocessing, and preserve the macro definitions in the preprocessed | |
35670 | output. Usually you also want to use this option when explicitly | |
35671 | preprocessing a header-unit, or consuming such preprocessed output: | |
35672 | ||
35673 | @smallexample | |
35674 | g++ -fmodules-ts -E -fdirectives-only my-header.hh -o my-header.ii | |
35675 | g++ -x c++-header -fmodules-ts -fpreprocessed -fdirectives-only my-header.ii | |
35676 | @end smallexample | |
35677 | ||
35678 | @node C++ Compiled Module Interface | |
35679 | @subsection Compiled Module Interface | |
35680 | @cindex C++ Compiled Module Interface | |
35681 | ||
35682 | CMIs are an additional artifact when compiling named module | |
35683 | interfaces, partitions or header units. These are read when | |
35684 | importing. CMI contents are implementation-specific, and in GCC's | |
35685 | case tied to the compiler version. Consider them a rebuildable cache | |
35686 | artifact, not a distributable object. | |
35687 | ||
35688 | When creating an output CMI, any missing directory components are | |
35689 | created in a manner that is safe for concurrent builds creating | |
35690 | multiple, different, CMIs within a common subdirectory tree. | |
35691 | ||
35692 | CMI contents are written to a temporary file, which is then atomically | |
35693 | renamed. Observers either see old contents (if there is an | |
35694 | existing file), or complete new contents. They do not observe the | |
35695 | CMI during its creation. This is unlike object file writing, which | |
35696 | may be observed by an external process. | |
35697 | ||
35698 | CMIs are read in lazily, if the host OS provides @code{mmap} | |
35699 | functionality. Generally blocks are read when name lookup or template | |
35700 | instantiation occurs. To inhibit this, the @option{-fno-module-lazy} | |
35701 | option may be used. | |
35702 | ||
35703 | The @option{--param lazy-modules=@var{n}} parameter controls the limit | |
35704 | on the number of concurrently open module files during lazy loading. | |
35705 | Should more modules be imported, an LRU algorithm is used to determine | |
35706 | which files to close---until that file is needed again. This limit | |
35707 | may be exceeded with deep module dependency hierarchies. With large | |
35708 | code bases there may be more imports than the process limit of file | |
35709 | descriptors. By default, the limit is a few less than the per-process | |
35710 | file descriptor hard limit, if that is determinable.@footnote{Where | |
35711 | applicable the soft limit is incremented as needed towards the hard limit.} | |
35712 | ||
35713 | GCC CMIs use ELF32 as an architecture-neutral encapsulation mechanism. | |
35714 | You may use @command{readelf} to inspect them, although section | |
35715 | contents are largely undecipherable. There is a section named | |
35716 | @code{.gnu.c++.README}, which contains human-readable text. Other | |
35717 | than the first line, each line consists of @code{@var{tag}: @code{value}} | |
35718 | tuples. | |
35719 | ||
35720 | @smallexample | |
35721 | > @command{readelf -p.gnu.c++.README gcm.cache/foo.gcm} | |
35722 | ||
35723 | String dump of section '.gnu.c++.README': | |
35724 | [ 0] GNU C++ primary module interface | |
35725 | [ 21] compiler: 11.0.0 20201116 (experimental) [c++-modules revision 20201116-0454] | |
35726 | [ 6f] version: 2020/11/16-04:54 | |
35727 | [ 89] module: foo | |
35728 | [ 95] source: c_b.ii | |
35729 | [ a4] dialect: C++20/coroutines | |
35730 | [ be] cwd: /data/users/nathans/modules/obj/x86_64/gcc | |
35731 | [ ee] repository: gcm.cache | |
35732 | [ 104] buildtime: 2020/11/16 15:03:21 UTC | |
35733 | [ 127] localtime: 2020/11/16 07:03:21 PST | |
35734 | [ 14a] export: foo:part1 foo-part1.gcm | |
35735 | @end smallexample | |
35736 | ||
35737 | Amongst other things, this lists the source that was built, C++ | |
35738 | dialect used and imports of the module.@footnote{The precise contents | |
35739 | of this output may change.} The timestamp is the same value as that | |
35740 | provided by the @code{__DATE__} & @code{__TIME__} macros, and may be | |
35741 | explicitly specified with the environment variable | |
35742 | @code{SOURCE_DATE_EPOCH}. For further details | |
35743 | @pxref{Environment Variables}. | |
35744 | ||
35745 | A set of related CMIs may be copied, provided the relative pathnames | |
35746 | are preserved. | |
35747 | ||
35748 | The @code{.gnu.c++.README} contents do not affect CMI integrity, and | |
35749 | it may be removed or altered. The section numbering of the sections | |
35750 | whose names do not begin with @code{.gnu.c++.}, or are not the string | |
35751 | section is significant and must not be altered. |